{"record":{"id":"541a270317e4a438","repo":"codex-team/editor.js","slug":"to-enable-read-only-mode-all-connected-tools-shoul","errorCode":null,"errorMessage":"To enable read-only mode all connected tools should support it. Tools ${this.toolsDontSupportReadOnly.join(', ')} don't support read-only mode.","messagePattern":"To enable read-only mode all connected tools should support it\\. Tools (.+?) don't support read-only mode\\.","errorType":"exception","errorClass":"CriticalError","httpStatus":null,"severity":"critical","filePath":"src/components/modules/readonly.ts","lineNumber":124,"sourceCode":"\n    /**\n     * Save current Editor Blocks and render again\n     */\n    const savedBlocks = await this.Editor.Saver.save();\n\n    await this.Editor.BlockManager.clear();\n    await this.Editor.Renderer.render(savedBlocks.blocks);\n\n    this.Editor.ModificationsObserver.enable();\n\n    return this.readOnlyEnabled;\n  }\n\n  /**\n   * Throws an error about tools which don't support read-only mode\n   */\n  private throwCriticalError(): never {\n    throw new CriticalError(\n      `To enable read-only mode all connected tools should support it. Tools ${this.toolsDontSupportReadOnly.join(', ')} don't support read-only mode.`\n    );\n  }\n}\n","sourceCodeStart":106,"sourceCodeEnd":129,"githubUrl":"https://github.com/codex-team/editor.js/blob/5f45dabbe5690b7033b2f9047d3985add5045fdd/src/components/modules/readonly.ts#L106-L129","documentation":"ReadonlyMode.prepare/toggle checks every registered block tool for the isReadOnlySupported flag; if any tool lacks it, enabling read-only would silently break those tools, so a CriticalError is thrown listing the offending tools. CriticalError typically halts editor initialization.","triggerScenarios":"Calling editor.readOnly.toggle(true) (or setting readOnly in a way that triggers prepare) while at least one tool (often a third-party one) does not declare `static get isReadOnlySupported() { return true; }`.","commonSituations":"Enabling read-only mode in an app using older/3rd-party tools (embeds, checkboxes, custom tools) that predate the read-only API; upgrading Editor.js and flipping readOnly on for the first time.","solutions":["Add `static get isReadOnlySupported() { return true; }` to each tool named in the message (only if the tool truly renders safely read-only)","Replace/remove the unsupported tool","Keep readOnly off until all tools declare support"],"exampleFix":"// before\nclass MyTool {\n  static get toolbox() { return {...}; }\n}\n// after\nclass MyTool {\n  static get isReadOnlySupported() { return true; }\n  static get toolbox() { return {...}; }\n}","handlingStrategy":"validation","validationCode":"const allSupport = Object.values(toolsConfig).every(t => (t as any).isReadOnlySupported === true); if (allSupport) editor.readOnly.toggle(true);","typeGuard":"const supportsReadOnly = (t: unknown): boolean => (t as any)?.isReadOnlySupported === true;","tryCatchPattern":"try { await editor.readOnly.toggle(true); } catch (e) { if (e instanceof CriticalError && e.message.includes('read-only mode')) { /* disable readOnly, patch tools */ return; } throw e; }","preventionTips":["Declare isReadOnlySupported on every custom tool","Audit third-party tools before enabling read-only"],"tags":["read-only","tool-support","critical-error","editorjs"],"backgroundTag":"unsupported-operation","analyzedSha":"5f45dabbe5690b7033b2f9047d3985add5045fdd","analyzedAt":"2026-08-27T22:50:23.124Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}