diff --git a/lib/canvas_editor/init/canvas_editor.js b/lib/canvas_editor/init/canvas_editor.js index c2092bd0..58aa12ad 100644 --- a/lib/canvas_editor/init/canvas_editor.js +++ b/lib/canvas_editor/init/canvas_editor.js @@ -105,6 +105,10 @@ function initCanvasEditor( this.#destroy = null; } + get isDestroyed() { + return !this.#editorArea; + } + moleculeChanged() { this.#checkNotDestroyed(); @@ -112,7 +116,7 @@ function initCanvasEditor( } #checkNotDestroyed() { - if (!this.#editorArea) { + if (this.isDestroyed) { throw new Error('CanvasEditor has been destroyed'); } } diff --git a/types.d.ts b/types.d.ts index 251c62e2..45865a04 100644 --- a/types.d.ts +++ b/types.d.ts @@ -3883,6 +3883,11 @@ export declare class CanvasEditor { * All methods will throw an error after calling this. */ destroy(): void; + + /** + * Returns whether the editor has been destroyed. + */ + get isDestroyed(): boolean; } interface CanvasEditorElementModeEnum {