我使用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
谢谢!
发布于 2020-08-30 05:22:51
我解决了。
我需要在配置对象中添加onSelect方法,并添加“提及”作为格式数组的元素。
无论哪种方式都要感谢您:)
https://stackoverflow.com/questions/63649679
复制相似问题