From 4280280722c3295b86968e361030305f66ea8291 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 11 Dec 2017 02:42:31 +0100 Subject: [PATCH] Clear the UndoManager on `loaded` event --- src/editor/index.js | 1 + src/editor/model/Editor.js | 7 +++---- src/undo_manager/index.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/editor/index.js b/src/editor/index.js index e9e133b5b..fac28d08f 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -571,6 +571,7 @@ module.exports = config => { // Do post render stuff after the iframe is loaded otherwise it'll // be empty during tests em.on('loaded', () => { + this.UndoManager.clear(); em.get('modules').forEach(module => { module.postRender && module.postRender(editorView); }); diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 62f10f0c1..6cb880b9d 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -88,11 +88,10 @@ module.exports = Backbone.Model.extend({ module.onLoad(); }); - // Stuff to do post load (eg. init undo manager for loaded components) + // Stuff to do post load const postLoad = () => { - this.get('modules').forEach(module => - module.postLoad && module.postLoad(this) - ); + const modules = this.get('modules'); + modules.forEach(module => module.postLoad && module.postLoad(this)); clb && clb(); }; diff --git a/src/undo_manager/index.js b/src/undo_manager/index.js index df26561b6..41908f78c 100644 --- a/src/undo_manager/index.js +++ b/src/undo_manager/index.js @@ -1,5 +1,5 @@ /** - * This module allows to manage the stack of changes applied on canvas + * This module allows to manage the stack of changes applied in canvas * * You can access the module in this way * ```js