resetHistory command to forget the undo/redo history #11

Closed
massifrg wants to merge 2 commits from master into master
massifrg commented 2026-01-21 19:04:35 +01:00 (Migrated from github.com)

This is a PR for this discussion

The effect of resetHistory is the same of running the plugin's state.init() function again.

Sometimes I want to reuse an editor with a different document, but I want to forget the history, because it would get me to the previous, different document.

This is a PR for [this discussion](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/6) The effect of `resetHistory` is the same of running the plugin's state.init() function again. Sometimes I want to reuse an editor with a different document, but I want to forget the history, because it would get me to the previous, different document.
marijnh commented 2026-01-21 23:22:12 +01:00 (Migrated from github.com)

Are you certain that your use case isn't better served by just creating a fresh EditorState and putting that in the existing view? Other plugins could be holding onto other state that doesn't belong in the new document. (I know I mentioned on the forum, a long time ago, that I'd welcome a PR for this, but I've come to the conclusion that reusing a state when loading a new document is usually not the right approach.)

Are you certain that your use case isn't better served by just creating a fresh `EditorState` and putting that in the existing view? Other plugins could be holding onto other state that doesn't belong in the new document. (I know I mentioned on the forum, a _long_ time ago, that I'd welcome a PR for this, but I've come to the conclusion that reusing a state when loading a new document is usually not the right approach.)
massifrg commented 2026-01-22 10:17:54 +01:00 (Migrated from github.com)

Thanks for the tip, @marijnh. I'll follow your advice, though I need to know how to create a fresh EditorState through tiptap's wrapper functions.
I'm not particularly attached to this PR, it's been a good way to learn something.

Thanks for the tip, @marijnh. I'll follow your advice, though I need to know how to create a fresh EditorState through tiptap's wrapper functions. I'm not particularly attached to this PR, it's been a good way to learn something.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-history!11
No description provided.