editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Mark as changed

Open meiyasan opened this issue 2 years ago • 4 comments

Hello,

I have been trying to find a way to mark a block as changed in a plugin extension. Since programmatically modifications don't trigger onChange anymore, I cannot find a way to mark a block as changed.

Is there a way to do so ?

meiyasan avatar Jul 23 '23 00:07 meiyasan

Or maybe a "onSave" method in EditorJS declaration ?

meiyasan avatar Jul 23 '23 01:07 meiyasan

Since programmatically modifications don't trigger onChange anymore

what do you mean?

neSpecc avatar Aug 20 '23 18:08 neSpecc

Twicking html using JavaScript doesn't trigger onChange event and I would like to find a way to trigger onChange by myself.

meiyasan avatar Aug 29 '23 23:08 meiyasan

@xkzl you can do this in your block:

  /**
   * @param {ImageToolData} tool.data - previously saved data
   * @param {boolean} tool.readOnly - read-only mode flag
   * @param {BlockAPI|{}} tool.block - current Block API
   */
  constructor({ data, readOnly, block }) {
    this.block = block;
  }
  
  someMethod() {
    this.block.dispatchChange(); // will trigger 'block-changed'
  }

bettysteger avatar Nov 28 '23 17:11 bettysteger