我使用 Quill 提及 ngx-quill。 每个文本编辑和格式设置都有效。 我找不到 QUILL Mention LIST 的 onSelect 事件。 我最终想要的是将提到的对象(将从下拉列表中选择)推送到数组中。 提及点击和悬停是与提及元素相关的唯一可用的事件侦听器。 如何获取选定的提及???
HTML
<quill-editor [modules]="{ mention: mentionConfig }" [style]="{height: '300px'}"></quill-editor>
Angular TS 导入
import Quill from 'quill';
import 'quill-mention';
import { QuillEditorComponent } from 'ngx-quill';
TS / JS
@ViewChild(QuillEditorComponent) editor!: QuillEditorComponent;
mentionConfig = {
allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
mentionDenotationChars: ["@"],
"toolbar":false,
source: (searchTerm: string, renderList:any) => {
// Your mention source logic here
const values = [
{ id: 1, value: 'Alice' },
{ id: 2, value: 'Bob' },
{ id: 3, value: 'Charlie' },
];
const matches = values.filter(mention => mention.value.toLowerCase().includes(searchTerm.toLowerCase()));
renderList(matches, searchTerm);
}
};
TS / JS
@ViewChild(QuillEditorComponent) editor!: QuillEditorComponent;
mentionConfig = {
allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
onSelect: (item, insertItem)=>{
console.log(item);//Will have the added suggestion/Tag
}
mentionDenotationChars: ["@"],
"toolbar":false,
source: (searchTerm: string, renderList:any) => {
// Your mention source logic here
const values = [
{ id: 1, value: 'Alice' },
{ id: 2, value: 'Bob' },
{ id: 3, value: 'Charlie' },
];
const matches = values.filter(mention => mention.value.toLowerCase().includes(searchTerm.toLowerCase()));
renderList(matches, searchTerm);
}
};