Monaco-editor: Editor serialization

Created on 18 Oct 2016  路  4Comments  路  Source: microsoft/monaco-editor

monaco-editor npm version: 0.6.1
Browser: Electron
OS: Windows 10

Hi, is there any way to serialize the editing session? I want to have the capability to save the code, selection range, cursor, undo manager etc. on the server side.
I've found saveViewState method, but i can't find the way to serialize the editor model.

api feature-request

Most helpful comment

Agree with @fabiospampinato even if I could get the last 100-1000 edits, it'd be better than nothing. Just have that be a configurable option and let the dev/user make the choices.

This is super painful for using this as a component of a complex application.

All 4 comments

At this time there's no API to serialize the undo/redo stack, so that would be lost, the view state contains the cursor state (selection state) and scroll state, you can save the model text via model.getValue(). We plan to add serializable undo/redo stack soon, but it is problematic w.r.t. what should be its limit (number of edits vs size of the edits) -- today the undo stack is unbounded which is okaysh given it sits in memory, when serializing it, we need to introduce some cut-off heuristics.

when serializing it, we need to introduce some cut-off heuristics.

Maybe the burden of this could be passed on the user by requiring an argument for the maximum number of steps to preserve or something?

Agree with @fabiospampinato even if I could get the last 100-1000 edits, it'd be better than nothing. Just have that be a configurable option and let the dev/user make the choices.

This is super painful for using this as a component of a complex application.

Also forgot to call out that this is super important in regards to just being able to re-hydrate state of the editor if the user's work spans across application sessions. It's super handy/amazing when a developer discovers they can still undo work they did the previous time the app ran.

Was this page helpful?
0 / 5 - 0 ratings