const editor = new EditorJS()
editor.destroy(); // TypeError: null is not an object (evaluating 'this.flipper.deactivate')
Steps to reproduce:
editor.destroy() from the consoleTypeError: null is not an object (evaluating 'this.flipper.deactivate')Expected behavior:
The editor destroys correctly.
Device, Browser, OS:
Safari
Editor.js version:
2.19
On editor destroy, we loop through moduleInstances and call destroy of each module.
https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/codex.ts#L85
moduleInstances contain both BlockSettings and Toolbar
https://github.com/codex-team/editor.js/blob/next/src/types-internal/editor-modules.d.ts
So when looping through the moduleInstances, we call BlockSettings destroy. Now as the loops continues, it reaches Toolbar and calls the destroy of it which agains attempts to destroy BlockSettings. This causes the editor to crash as BlockSettings was already destroyed. (Same with Toolbox)
https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/components/modules/toolbar/index.ts#L383
Is it ok to destroy an Editor level module from within another module? If yes, then should BlockSettings and Toolbox be contained within Toolbar and accessed only via Editor.Toolbar.BlockSettings?
Do you plan to create a release with this bugfix?
Do you plan to create a release with this bugfix?
yes
waiting for the release @neSpecc
Most helpful comment
yes