Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What and why
Closes #114
setContent(content, { resetHistory: true })unregistered and registered the history plugin again. That produces a newstate.pluginsarray, so ProseMirror'sEditorView.updatePluginViewsdestroyed and recreated the view of every plugin (bubble menus, drag handle, slash commands...) on each content replacement, and the history plugin moved to the end of the plugin order.resetHistorynow finds the history plugin ineditor.state.plugins(its key starts withhistory$) and dispatches one transaction withtr.setMeta(historyPlugin, { historyState: historyPlugin.spec.state.init({}, editor.state) })andaddToHistory: false.prosemirror-historyreturns thathistoryStatefrom itsapply, so the history is replaced while the plugin list, its order and every plugin view stay as they are. No-op when there is no history plugin (undoRedodisabled).How it was tested
Two new tests in
tests/set-content.spec.ts(Chromium and WebKit): aftersetContent(..., { resetHistory: true })on an editor with a registered test plugin,editor.state.pluginskeeps its identity, and the test plugin's viewdestroyis not called. Both fail onupstream/mainand pass with the fix. The existingresetHistorytest still covers undo and redo being unavailable and new edits being undoable.Locally:
npm run lint,npm run build:libandnpm run test:e2e -- --project=chromium --project=webkitpass (383 passed, 25 skipped). Firefox is left to CI.Checklist
npm run build:lib,npm run lintandnpm run test:e2epass (Chromium and WebKit locally, Firefox in CI)changes/fixed.reset-history-plugin-views.mdadded🤖 Generated with Claude Code