Quill:当污点改变时调用哪种方法?

S. *_*bov 5 quill parchment

当我用自己的污点包裹的文字改变时,我需要做点什么.

羊皮纸文档中我得到的方法update将在污点变化时调用.我尝试在代码中使用它,但是当用我的污点包裹的文本发生变化时,这种方法不会被调用.

可能是我用这种方法不正确?或者我应该使用另一种方法?

小智 0

您应该使用文本更改事件:

this.quill.on('text-change', (range, oldRange, source) => {

 // Returns the leaf Blot at the specified index within the document
 let [leaf, offset] = this.quill.getLeaf(range.index); // Experimental API

  if(leaf.domNode.nodeName === 'yourBlotTag') {
    //Do something
  }

}
Run Code Online (Sandbox Code Playgroud)