问题描述
我正在使用Quill-Mention在Quill JS中实现React Quill,但是当单击列表中的项目时,我无法设法更新编辑器内容。
单击正确的符号时,我可以正确地显示列表,它会相应显示数据。但是,当我单击它时,它消失了,并且项目值未添加到编辑器内容中。
这是我的测试方式:
const suggestPeople = searchTerm => {
const allPeople = [
{
id: 1,value: "Fredrik Sundqvist"
},{
id: 2,value: "Patrik Sjölin"
}
];
return allPeople.filter(person => person.value.includes(searchTerm));
};
/* Mention module config
====================== */
const mentionModule = {
allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,mentionDenotationChars: ["·"],source: async function(searchTerm,renderList) {
const matchedPeople = await suggestPeople(searchTerm);
renderList(matchedPeople);
}
};
quill.register("modules/mentions",quillMention);
const modules = {
Syntax: true,clipboard: {
matchVisual: false
},toolbar: {
container: "#toolbar",},mention: mentionModule
};
Screenshot showing Quill Mention dropdown list working
谢谢!
解决方法
我解决了。
我需要在配置对象中添加onSelect方法,并在格式数组的元素中添加“提及”。
无论哪种方式,谢谢你: