Repository navigation
Conversation
Add the editor-destroy change: Core/EditorJS destroy() lifecycle, optional destroy() on tools, required destroy() on the adapter plugin, and a repo-wide rule that listeners are released through AbortController (owned by SDK base classes where they exist). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#174 now covers teardown for every UI plugin (listeners, holders, popovers, the EditorjsUI wrapper, pending inline toolbar config). Drop the ui delta and the UI tasks; keep only InlineToolbarUI destroying its inline tool instances, done after #174 lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
There is no way to tear an editor down. Neither
CorenorEditorJShas adestroy(), so unmounting an editor (route change, component unmount, several editors on one page, React StrictMode) leaks the editor DOM, the document-wideselectionchangelistener, the collaboration WebSocket, timers, and every tool and plugin instance. Several plugins already implementdestroy(), and thecore/sdkspecs already say it's called on teardown, but nothing calls it.Board card: Clean up (Core APIs).
What Changes
This PR is the OpenSpec change only (
openspec/changes/editor-destroy). Implementation follows in stacked PRs.Core#destroy()/EditorJS#destroy(): synchronous, idempotent. Tears down plugins in reverse construction order (unregistering their public APIs), thenUndoRedoManager,SelectionManager,BlockRenderer(each block's tool instance and adapter), then the adapter plugin. A throwing step is logged and teardown continues. The model is never mutated, so nothing reaches undo history or collaboration.use()/initialize()throw afterwards.destroy()during a pendinginitialize()makes it reject with aDOMExceptionnamedAbortError(the platform convention, as withfetch). The bundle handles its own ready promise:AbortErroris ignored, other init errors are logged, so neither is reported as an unhandled rejection; awaitingisReadystill rejects.destroy()onBlockTool/InlineTool, called once per instance the editor creates.destroy()becomes required onEditorJSAdapterPlugin.architecturespec): every component releases listeners through oneAbortController; unsubscribe functions returned byonUpdate/onCaretUpdateare tied to itsabortevent. SDK base classes (BlockToolAdapter) own the controller and expose aprotected signalto subclasses.selectionchangewatcher: reference-counted, so several editors can be destroyed independently.InlineToolbarUIdestroying the inline tool instances it creates, done after fix(ui): remove blocks holder listeners and detach it on destroy #174 lands.Modified capabilities:
architecture,core,sdk,dom-adapters,editorjs-bundle. Supersedes the "Core currently does not expose a globaldestroy()" note indocs/plugins.md(docs are updated in the implementation PR).Stack
Core/EditorJSdestroy(), core services, tool contracts,BlockToolAdaptercontroller (targets this branch)Verification
openspec validate editor-destroy --type changepasses.🤖 Generated with Claude Code