fix(blockSettings): prevent warning on initial read-only mode toggle (#2969)

Co-authored-by: Peter <specc.dev@gmail.com>
This commit is contained in:
KoshaevEugeny 2026-01-08 01:44:19 +03:00 committed by GitHub
commit 90d6dec90e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View file

@ -1,5 +1,9 @@
# Changelog
### 2.31.1
- `Fix` - Prevent the warning from appearing when `readOnly` mode is initially set to `true`
### 2.31.0
- `New` - Inline tools (those with `isReadOnlySupported` specified) can now be used in read-only mode

View file

@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.31.0",
"version": "2.31.1",
"description": "Editor.js — open source block-style WYSIWYG editor with JSON output",
"main": "dist/editorjs.umd.js",
"module": "dist/editorjs.mjs",

View file

@ -68,6 +68,11 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
return 'flipper' in this.popover ? this.popover?.flipper : undefined;
}
/**
* Flag that indicates whether the `EditorMobileLayoutToggled` event listener is attached.
*/
private hasMobileLayoutToggleListener = false;
/**
* Page selection utils
*/
@ -92,6 +97,7 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
}
this.eventsDispatcher.on(EditorMobileLayoutToggled, this.close);
this.hasMobileLayoutToggleListener = true;
}
/**
@ -100,7 +106,11 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
public destroy(): void {
this.removeAllNodes();
this.listeners.destroy();
this.eventsDispatcher.off(EditorMobileLayoutToggled, this.close);
if (this.hasMobileLayoutToggleListener) {
this.eventsDispatcher.off(EditorMobileLayoutToggled, this.close);
this.hasMobileLayoutToggleListener = false;
}
}
/**