docs(fluent-editor): add mention module demo (#1888)

This commit is contained in:
Kagol 2024-08-12 15:36:00 +08:00 committed by GitHub
parent 7602aa28bf
commit e519280059
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 0 deletions

View File

@ -16,6 +16,21 @@ const TOOLBAR_CONFIG = [
['fullscreen', 'emoji', 'help', 'screenshot'],
]
// @
const searchKey = 'name'
const mentionList = [
{
name: 'Jack',
age: 26,
cn: 'Jack 杰克'
},
{
name: 'Lucy',
age: 22,
cn: 'Lucy 露西'
}
]
onMounted(() => {
editor = new FluentEditor('#editor', {
theme: 'snow',
@ -23,6 +38,15 @@ onMounted(() => {
toolbar: {
container: TOOLBAR_CONFIG
},
mention: {
itemKey: 'cn',
searchKey,
search: function(term) {
return mentionList.filter(item => {
return item[searchKey] && String(item[searchKey]).includes(term)
})
}
},
file: true
}
})