-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
208 additions
and
138 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
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,3 +1,3 @@ | ||
# vue-mentions | ||
|
||
@vue @metions | ||
@vue @mentions |
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
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,34 @@ | ||
<script lang="ts" setup> | ||
import { onMounted, ref } from 'vue' | ||
import { createMentions } from 'mentions.js' | ||
import 'mentions.js/mentions.css' | ||
const inputValue = ref('') | ||
const containerRef = ref() | ||
const mentions = createMentions({ | ||
value: '', | ||
options: [ | ||
{ id: '1', name: 'John' }, | ||
{ id: '2', name: 'Jack' }, | ||
{ id: '3', name: 'Tom' }, | ||
{ id: '4', name: 'Jerry' } | ||
] | ||
}) | ||
mentions.on('change', (value) => { | ||
inputValue.value = value | ||
}) | ||
onMounted(() => { | ||
mentions.mount(containerRef.value) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div ref="containerRef" /> | ||
<p>output:</p> | ||
<output>{{ inputValue }}</output> | ||
</div> | ||
</template> |
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,32 +1,55 @@ | ||
--- | ||
# https://vitepress.dev/reference/default-theme-home-page | ||
layout: home | ||
|
||
hero: | ||
name: "mentions.js" | ||
text: "A mentions input base on vanilla JS." | ||
# tagline: My great project tagline | ||
actions: | ||
- theme: brand | ||
text: Getting Started | ||
link: /#getting-started | ||
- theme: alt | ||
text: Playground | ||
link: /playground | ||
|
||
# features: | ||
# - title: Feature A | ||
# details: Lorem ipsum dolor sit amet, consectetur adipiscing elit | ||
# - title: Feature B | ||
# details: Lorem ipsum dolor sit amet, consectetur adipiscing elit | ||
# - title: Feature C | ||
# details: Lorem ipsum dolor sit amet, consectetur adipiscing elit | ||
--- | ||
<script setup> | ||
import Mentions from './components/Mentions.vue' | ||
</script> | ||
|
||
<h1 style="font-size:56px;line-height:64px;font-weight:bold;color:#10b981">mentions.js</h1> | ||
<p style="font-size:56px;line-height:64px;font-weight:bold">A mentions input base on vanilla JS.</p> | ||
|
||
## Getting Started | ||
|
||
```bash | ||
npm install | ||
npm install mentions.js | ||
``` | ||
|
||
## Usage Mentions | ||
```js | ||
import { createMentions } from 'mentions.js' | ||
import 'mentions.js/mentions.css' | ||
|
||
const mentions = createMentions({ | ||
value: '', | ||
options: [ | ||
{ id: 1, name: 'John' }, | ||
{ id: 2, name: 'Jack' }, | ||
{ id: 3, name: 'Tom' }, | ||
{ id: 4, name: 'Jerry' }, | ||
], | ||
}) | ||
|
||
mentions.on('change', (value) => { | ||
console.log(value) | ||
}) | ||
|
||
mentions.mount(document.getElementById('container')) | ||
``` | ||
|
||
## createMentions Options | ||
|
||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| type | `input` \| `textarea` | `input` | render input type. | | ||
| value | `string` | `''` | The initial value of the mentions input. | | ||
| options | See the table below | `[]` | The options of the mentions input. | | ||
| placeholder | `string` | `'@'` | The placeholder of the mentions input. | | ||
|
||
### Options | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| id | `string` | The id of the option. | | ||
| name | `string` | The name of the option. | | ||
| disabled | `boolean` | Whether the option is disabled. | | ||
| customRender | `(option: MentionDropdownListOption, index: number) => string` | Custom render option. | | ||
|
||
## Playground | ||
|
||
<Mentions /> |
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 |
---|---|---|
|
@@ -15,5 +15,8 @@ | |
"devDependencies": { | ||
"vitepress": "^1.0.0-beta.1", | ||
"vue": "^3.2.47" | ||
}, | ||
"dependencies": { | ||
"mentions.js": "*" | ||
} | ||
} |
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
Oops, something went wrong.