Guard editor getters (commands, getHTML, getText) against null managers after destroy
Affected Packages
@tiptap/extension-text-align
Tiptap Version
3.23.1
Browser Used
Chrome
What happened?
This is related to #7849.
The 3.23.0 memory-leak fix introduced this cleanup inside Editor.destroy():
this.extensionManager.destroy()
this.extensionManager = null as any
this.schema = null as any
this.commandManager = null as anyThe matching getters (commands, chain, can, getHTML, getText) were not updated to handle the null state. Any post-destroy access would throw a TypeError: Cannot read properties of null (reading 'commands') instead of the silent no-op behavior of 3.18 and earlier.
PR #8210 partially fixes what we were running into by falling back to static methods on CommandManager. In particular, this PR fixed chain and can.
https://github.com/ueberdosis/tiptap/pull/7871 and this PR (https://github.com/ueberdosis/tiptap/issues/7849) set up a proxy whose every property will resolve to () => false, with then explicitly undefined so await editor.chain() doesn't hang treating the proxy as thenable. Neither of these PRs were accepted. I believe a new, more narrowly scoped PR should be drafted to fix up the remaining getters (commands, getHTML, and getText) by reusing CommandManager.
Expected Behavior
When a getter handles the null state, it does not throw
Reproducible Example URL (Optional)
No response
Additional Context (Optional)
No response
Source: ueberdosis/tiptap