codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.23k stars 2.06k forks source link

Ability to differentiate block content delete vs clear / re-renders. #2505

Open krisnik opened 11 months ago

krisnik commented 11 months ago

Describe a bug.

In 2.28.x release, editorjs clear method triggers EditorJS onChange method with block-removed event type.

Side effect of it being, upon toggling readOnly - all the blocks are being cleared and re-rendered. With these events, the onChange event listener ends up deleting the blocks that are stored in our local state that are updated based on block-update, block-created and block-removed events.

What we would need is some sort of flag to differentiate between actual delete vs clear + re-render for us to ignore such events on event listener.

Steps to reproduce:

Here is the code snippet from readOnly.ts

https://github.com/codex-team/editor.js/blob/next/src/components/modules/readonly.ts#L97-#L102

Expected behavior:

Screenshots:

Device, Browser, OS:

Editor.js version:

Plugins you use with their versions:

krisnik commented 11 months ago

Hello @neSpecc , Could you please suggest a work around / solution here?

ErBat commented 3 months ago

Having the same issue