From e0295270e0c490146cde2d161eeb2d8ae6a7adcf Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 14 Nov 2020 14:44:16 +0100 Subject: [PATCH] Add destroy method to Commands module --- src/commands/index.js | 4 ++++ src/editor/model/Editor.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands/index.js b/src/commands/index.js index 2e2561816..6790a0c08 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -424,6 +424,10 @@ export default () => { if (!command.stop) command.noStop = 1; const cmd = CommandAbstract.extend(command); return new cmd(c); + }, + + destroy() { + [em, c, commands, defaultCommands, active].forEach(i => (i = {})); } }; }; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 1267f6af1..e984c6c90 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -761,7 +761,8 @@ export default Backbone.Model.extend({ LayerManager, AssetManager, BlockManager, - CodeManager + CodeManager, + Commands } = this.attributes; this.stopDefault(); DomComponents.clear(); @@ -775,6 +776,7 @@ export default Backbone.Model.extend({ AssetManager.destroy(); BlockManager.destroy(); CodeManager.destroy(); + Commands.destroy(); this.view.remove(); this.stopListening(); this.clear({ silent: true });