Slate: Serialize redo/undo stack?

Created on 5 Jan 2017  路  2Comments  路  Source: ianstormtaylor/slate

Hi there,

I wonder if it is possible to serialize the redo/ undo stack together with the document content?
So that once I save and close the browser, open it again to load the document from a file, I
would still be able to do undo and redo on the changes I made previously?

question

Most helpful comment

Hey @khanhhaduc, it's definitely possible. You'd need to serialize/deserialize it on your own though since it's not supported out of the box. I don't think it'd would be too hard, if you take a look at the source to see how State objects are created with a History.

I'd also accept a pull request that split History into its own src/models/history.js and exported it at the top-level to make this use case easier if you wanted to write one!

All 2 comments

Hey @khanhhaduc, it's definitely possible. You'd need to serialize/deserialize it on your own though since it's not supported out of the box. I don't think it'd would be too hard, if you take a look at the source to see how State objects are created with a History.

I'd also accept a pull request that split History into its own src/models/history.js and exported it at the top-level to make this use case easier if you wanted to write one!

Did not think of separating History but that actually makes much sense. Will be looking into doing so as I will be using this feature, as mentioned in #2678 and #2672

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markolofsen picture markolofsen  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

adrianclay picture adrianclay  路  3Comments