这一切都与模型有关.
如果您恢复相同的型号,您将拥有Undo& Redo堆栈
见例子
var model = editorInstance.getModel();
var viewState = editorInstance.saveViewState();
//Destroy your instance for whatever reason
editorInstance.dispose();
//When you create the new instance load the model that you saved
var newInstance = monaco.editor.create(elem, options);
newInstance.setModel(model);
newInstance.restoreViewState(viewState);
可能有帮助的东西就是与摩纳哥事件挂钩
monaco.editor.onWillDisposeModel(saveModel)
viewState可用于恢复编辑器的光标位置.