# Reset history plugin state

**URL:** https://discuss.prosemirror.net/t/reset-history-plugin-state/1883
**Category:** Uncategorized
**Created:** [April 11, 2019, 8:28pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883 "2019-04-11T20:28:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)
#### Post date: [April 11, 2019, 8:28pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/1 "2019-04-11T20:28:29Z")

</div>

Hi, I’m sure this is a trivial question but, I’m wondering if I’m missing something here. Is there a way to completely reset the historystate to the init state based on the prosemirror-history module? Or is that impossible? I guess I could hack the plugin and take the apply function, and wrap it.

But thats where I’m at with this. I need to be able to drop the historystate to an empty state. And there doesnt appear to be a non-hack way to do this.

---

<div class="post-metadata">

### Author: ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)
#### Post date: [April 11, 2019, 9:19pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/2 "2019-04-11T21:19:36Z")

</div>

I should add that I know you can do stuff like creating a new state based off the EditorState class, and all sorts of stuff that is much weirder but, this is undesirable for us to swap out EditorStates in our editor environment or do manipulation of immutable objects like EditorState.

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)
#### Post date: [April 12, 2019, 8:21am UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/3 "2019-04-12T08:21:13Z")

</div>

No, this does not currently exist. It would be possible to add such a feature to the history plugin—it’d basically involve adding support for a special type of transaction metadata to reset the history state, and then exporting a function that creates such a transaction, somewhat similar to `closeHistory`.

---

<div class="post-metadata">

### Author: ![JCHollett](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@JCHollett](https://discuss.prosemirror.net/u/JCHollett)
#### Post date: [April 13, 2019, 9:02pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/4 "2019-04-13T21:02:46Z")

</div>

Thanks for the reply. I dont think we want to fork the module, so its likely I’ll wrap the plugin which is awkward but, seems to be the suggested solution with one of my co-workers.

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)
#### Post date: [April 15, 2019, 2:17pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/5 "2019-04-15T14:17:47Z")

</div>

I didn’t suggest a fork—I mean to say I’d accept a pull request that implements such a feature.

---

<div class="post-metadata">

### Author: ![alessiostalla](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/alessiostalla/32/2318_2.png) [@alessiostalla](https://discuss.prosemirror.net/u/alessiostalla)
#### Post date: [November 17, 2021, 2:25pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/6 "2021-11-17T14:25:22Z")

</div>

Sorry for resurrecting an old thread, but did somebody ever write such a PR? I see there are open issues on GitHub. I’m willing to give it a shot but I’d like to avoid duplicating effort.

---

<div class="post-metadata">

### Author: ![massi](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@massi](https://discuss.prosemirror.net/u/massi)
#### Post date: [January 21, 2026, 6:10pm UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/7 "2026-01-21T18:10:06Z")

</div>

I made a [PR](https://github.com/ProseMirror/prosemirror-history/pull/11) for this feature.

It adds the `resetHistory` command, that has the same effect of running the plugin’s `state.init()` function again.

I’m pondering whether to test the undo and redo branches and return `false` in case they are both empty. For now, `resetHistory` always returns `true`.

---

<div class="post-metadata">

### Author: ![massi](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@massi](https://discuss.prosemirror.net/u/massi)
#### Post date: [January 22, 2026, 9:29am UTC](https://discuss.prosemirror.net/t/reset-history-plugin-state/1883/8 "2026-01-22T09:29:41Z")

</div>

I’m following @marijn advice, that “reusing a state when loading a new document is usually not the right approach”, so I abandoned the PR.

In situations where you want to reuse an editor for a different document, and you don’t want the previous document to reappear as a result of an undo, it’s better to create a new EditorState (with a fresh history plugin) and update the editor’s view with that state.
