-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
286 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Collin Henderson | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,67 @@ | ||
# Vue 3 + Typescript + Vite | ||
# vue-tribute ![test](https://github.com/syropian/vue-tribute/workflows/test/badge.svg?branch=next) | ||
|
||
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. | ||
A tiny Vue.js wrapper around Zurb's Tribute library for ES6 native @mentions. | ||
|
||
## Recommended IDE Setup | ||
> 🚦 Looking for Vue 2 support? Check out the [master branch](https://github.com/syropian/vue-tribute). | ||
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) | ||
## Install | ||
|
||
## Type Support For `.vue` Imports in TS | ||
```bash | ||
$ npm install vue-tribute@next --save | ||
# or... | ||
$ yarn add vue-tribute@next | ||
``` | ||
|
||
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette. | ||
_or_ | ||
|
||
Use the UMD build from [Unpkg](https://unpkg.com/vue-tribute), available as `VueTribute` in the global scope. | ||
|
||
```html | ||
<script src="/vendor/vue.js" /> | ||
<script src="https://unpkg.com/vue-tribute@next" /> | ||
``` | ||
### Globally | ||
Import and register the module as a plugin. | ||
```javascript | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import VueTribute from 'vue-tribute' | ||
createApp(App).use(VueTribute).mount('#app') | ||
``` | ||
### Per-component | ||
```javascript | ||
import { VueTribute } from 'vue-tribute' | ||
export default { | ||
components: { VueTribute }, | ||
setup() { | ||
... | ||
}, | ||
} | ||
``` | ||
## Usage | ||
Wrap a single **text input**, **textarea**, or **contenteditable** element within the `VueTribute` component. You should then pass a [valid Tribute collection(s) object](https://github.com/zurb/tribute#initializing) to the component. | ||
## Events | ||
All [custom Tribute events](https://github.com/zurb/tribute#events) will work as expected. Simply attach listeners for them like you would any other event. | ||
```vue | ||
<template> | ||
<vue-tribute :options="options"> | ||
<input type="text" placeholder="@..." @tribute-replaced="doSomething" /> | ||
</vue-tribute> | ||
</template> | ||
``` | ||
## License | ||
MIT © [Collin Henderson](https://github.com/syropian) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<template> | ||
<div id="container"> | ||
<vue-tribute :options="options"> | ||
<input type="text" class="" placeholder="@..." /> | ||
<input type="text" class="w-3/4 sm:1/2 input" placeholder="@..." /> | ||
</vue-tribute> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import VueTribute from '../lib' | ||
import { VueTribute } from '../lib' | ||
const options = { | ||
trigger: '@', | ||
values: [ | ||
{ key: 'Collin Henderson', value: 'syropian' }, | ||
{ key: 'Sarah Drasner', value: 'sarah_edo' }, | ||
{ key: 'Evan You', value: 'youyuxi' }, | ||
{ key: 'Adam Wathan', value: 'adamwathan' }, | ||
{ key: 'Rich Harris', value: 'Rich_Harris' }, | ||
], | ||
positionMenu: true, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<div id="container"> | ||
<vue-tribute :options="options"> | ||
<div class="w-3/4 sm:1/2 input" placeholder="@..." contenteditable>@</div> | ||
</vue-tribute> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { VueTribute } from '../lib' | ||
const options = { | ||
trigger: '@', | ||
values: [ | ||
{ key: 'Sarah Drasner', value: 'sarah_edo' }, | ||
{ key: 'Evan You', value: 'youyuxi' }, | ||
{ key: 'Adam Wathan', value: 'adamwathan' }, | ||
{ key: 'Rich Harris', value: 'Rich_Harris' }, | ||
], | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<div id="container"> | ||
<vue-tribute :options="options"> | ||
<textarea class="w-3/4 sm:1/2 input" placeholder="@..." /> | ||
</vue-tribute> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { VueTribute } from '../lib' | ||
const options = { | ||
trigger: '@', | ||
values: [ | ||
{ key: 'Sarah Drasner', value: 'sarah_edo' }, | ||
{ key: 'Evan You', value: 'youyuxi' }, | ||
{ key: 'Adam Wathan', value: 'adamwathan' }, | ||
{ key: 'Rich Harris', value: 'Rich_Harris' }, | ||
], | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import 'highlight.js/lib/common' | ||
import hljs from 'highlight.js/lib/core' | ||
import html from 'highlight.js/lib/languages/xml' | ||
import bash from 'highlight.js/lib/languages/bash' | ||
import javascript from 'highlight.js/lib/languages/javascript' | ||
import hljsVuePlugin from '@highlightjs/vue-plugin' | ||
import 'highlight.js/styles/atom-one-dark.css' | ||
import './app.css' | ||
|
||
hljs.registerLanguage('html', html) | ||
hljs.registerLanguage('javascript', javascript) | ||
hljs.registerLanguage('bash', bash) | ||
|
||
createApp(App).use(hljsVuePlugin).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters