如何解决单击时从React Quill内容元素节点更新React应用状态
我想允许React Quill编辑器主体中的特定元素在点击时更新应用上下文。
我该怎么办?
这是我制作的自定义污点:
/* Mention blot config
====================== */
class MentionBlot extends BlockEmbed {
static create(data) {
const node = super.create();
const denotationChar = document.createElement("span");
denotationChar.className = "ql-mention-denotation-char";
denotationChar.innerHTML = data.denotationChar;
node.appendChild(denotationChar);
node.innerHTML += data.value;
return MentionBlot.setDataValues(node,data);
}
static setDataValues(element,data) {
const domNode = element;
Object.keys(data).forEach((key) => {
domNode.dataset[key] = data[key];
});
return domNode;
}
static value(domNode) {
return domNode.dataset;
}
}
MentionBlot.blotName = "mentionCustom";
MentionBlot.tagName = "span";
MentionBlot.className = "mention";
Quill.register("formats/mentionCustom",MentionBlot);
这是它的渲染方式:
Screenshot of the elements in the editor
谢谢:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。