Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/extensions/MentionExt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const createMention = (onMentionLoad: (query: string) => any[] | Promise<

// 只要前一个字符是英文/数字,就不触发,避免邮箱的情况
if (offsetInParent > 0 && text.length >= offsetInParent) {
const beforeChar = text.charAt(offsetInParent)
// 如果字符中包含@则直接拿@前一个字符判断
const firstAtIndex = text.indexOf('@')
let beforeChar = text.charAt(offsetInParent)
if (firstAtIndex !== -1) {
beforeChar = text.charAt(firstAtIndex - 1)
}
return !/^[a-zA-Z0-9]$/.test(beforeChar)
}
return true // 行首等情况允许
Expand Down
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ window.aiEditor = new AiEditor({
{
id: 5,
label: 'Jerry Hall'
},
{
id: 6,
label: '张三'
},
{
id: 7,
label: '李四'
},
{
id: 8,
label: '王五'
}
].filter(item => item.label.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5)
resolve(data)
Expand Down