javascript - Quill - 提及未在 Quill JS 编辑器内容中插入提及值(使用 React Quill)
问题描述
我正在使用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
};
谢谢!
解决方案
我解决了。
我需要在配置对象中添加 onSelect 方法,并添加“提及”作为格式数组的元素。
无论哪种方式都谢谢你:)
推荐阅读
- junit - Mocking AEM Asset Manager using WCM IO
- jdbc - 尝试使用回滚运行 EXPLAIN ANALYZE
- javascript - 为什么我的嵌套 Vue 模板文件不渲染?
- python - 获取字典的随机子集
- java - Thymeleaf template and Spring Boot : Creating a radio input from Java enum
- sql - How to upload a .txt file to SQL table every 5 miniutes?
- java - Android studio not giving suggestions from android-src.jar
- java - 如何将数据从类传递到片段?
- rest - 在 Couchbase 中添加文档并缺少 JSON 正文
- python - 在数据框中标记用户的出席情况