5

I need to do something when text, wrapped with my own blot, changed.

From parchment documentation i got that method update will called when blot changes. I try to use it in code, but this method does't called when text, wrapped with my blot, changes.

May be I use this method incorrect? Or I should use another method?

S. Zobov
  • 154
  • 2
  • 15

1 Answers1

0

You should use text-change event:

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
  }

}
Dertsaf
  • 27
  • 8
  • Thank you, I'll check it soon. By the way, it would be better to provide an example to the answer on any sandbox platform, like [codepen](https://codepen.io) or [jsfiddle](https://jsfiddle.net/). – S. Zobov Aug 24 '18 at 08:59