codex-team / editor.js

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

Why do all Blocks get initialized twice? When you initiate the editor with readOnly true, i've got a problem with custom block tool #2878

Open bettysteger opened 5 days ago

bettysteger commented 5 days ago

I created a custom Block via https://editorjs.io/tools-api/.

I am creating the Editorjs with readOnly true, and when i output the data from my Tool constructor, it will get initialized twice with different readOnly values.

constructor({ data, config, api, readOnly, block }) {
  console.log('readOnly', readOnly);
}
// readOnly false
// readOnly true

Expected behavior: Just initialize every block once?

That means i need to change my custom block tool, so it handles the "switch" from edit to readOnly... But i don't really need a toggle. i just want to show the content in read-only mode.

Codepen: https://codepen.io/bettyst/pen/azooqYQ

Device, Browser, OS:

Editor.js version: 2.29 and latest

bettysteger commented 5 days ago

Additionally i think a few plugins are not loaded correctly: