codex-team / codex-team/editor.js

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

Open
#2,878 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.