【发布时间】:2020-08-29 17:05:26
【问题描述】:
我正在使用React Quill 在Quill JS 中实现Quill-Mention,但在单击列表中的项目时我无法更新编辑器内容。
单击正确的符号时,我可以正确呈现列表,并相应地显示数据。但是,当我单击它时,它会消失,并且项目值不会添加到编辑器内容中。
这是我的测试方法:
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
谢谢!
【问题讨论】:
标签: javascript reactjs quill react-quill