From 49e051059ec29d995773ac7560ad5d32b99dd9ce Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Fri, 14 Oct 2022 13:46:42 +0200 Subject: [PATCH] Add LoadEditor to smart component --- public/smartcomponent/svg-layout-designer.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/public/smartcomponent/svg-layout-designer.ts b/public/smartcomponent/svg-layout-designer.ts index 067e96f..c6ccf8b 100644 --- a/public/smartcomponent/svg-layout-designer.ts +++ b/public/smartcomponent/svg-layout-designer.ts @@ -128,6 +128,23 @@ /// App Events /// + /** + * Load an existing editor state and its history + * This is a macro function for + * ReviveEditorState -> SetEditor -> SetHistory + * @param editorState + */ + public LoadEditor(editorState: IEditorState) { + this.ReviveEditorState(editorState, (state) => { + this.SetEditor(state, (currentState) => { + setTimeout(() => { + this.app.Editor.SetHistory({ history: state.history, historyCurrentStep: state.historyCurrentStep }); + }, 200); + }); + }); + } + + /** * Not to be confused with setHistory, * change the default configuration for the new containers, symbols etc.