Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击时从React Quill内容元素节点更新React应用程序状态_Javascript_Reactjs_Quill_React Quill - Fatal编程技术网

Javascript 单击时从React Quill内容元素节点更新React应用程序状态

Javascript 单击时从React Quill内容元素节点更新React应用程序状态,javascript,reactjs,quill,react-quill,Javascript,Reactjs,Quill,React Quill,我想允许React羽毛笔编辑器主体中的特定元素在单击时更新应用程序上下文 我怎么做 这是我做的自定义污渍: /* Mention blot config ====================== */ class MentionBlot extends BlockEmbed { static create(data) { const node = super.create(); const denotationChar = document.createElement(&

我想允许React羽毛笔编辑器主体中的特定元素在单击时更新应用程序上下文

我怎么做

这是我做的自定义污渍:

/* 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);
以下是它的呈现方式:

谢谢:)