Possible to store history?

Is it possible to store the undo history and restore it later? I have multiple “documents” that the user can switch between and I’d like to store their last scroll, selection, and history stack so they can switch back and forth between documents without keeping them in memory.

You can just keep a copy of the editor state, and swap that back in. It won’t preserve scroll position, but that’s rather easy to do in your own code, and selection, document, and undo history are all part of the state.

Great! I didn’t think of doing that with the whole state, just parts of it. And it looks like the state can be serialized and restored (toJSON/fromJSON), so I could keep it out of memory too if needed?

History doesn’t currently support JSON serialization, so no, dumping it to disk isn’t quite so easy.

Ok, well thank you. Keeping it in memory right now is good.