Reset history plugin state

#1

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.

0 Likes

#2

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.

0 Likes

#3

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.

0 Likes

#4

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.

0 Likes

#5

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

0 Likes