From 870791d149d909d0432b8f52e0d5c78bdcad90ea Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 12 Mar 2019 08:41:12 +0100 Subject: [PATCH] Added `run` and `stop` events for Commands --- docs/.vuepress/components/demos/DemoCanvasOnly.js | 2 +- src/commands/view/CommandAbstract.js | 2 ++ src/editor/index.js | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/.vuepress/components/demos/DemoCanvasOnly.js b/docs/.vuepress/components/demos/DemoCanvasOnly.js index 9c45ebb4a..102996614 100644 --- a/docs/.vuepress/components/demos/DemoCanvasOnly.js +++ b/docs/.vuepress/components/demos/DemoCanvasOnly.js @@ -8,7 +8,7 @@ const editor = grapesjs.init({ height: '300px', width: 'auto', // Disable the storage manager for the moment - storageManager: { type: null }, + storageManager: false, // Avoid any default panel panels: { defaults: [] }, }); diff --git a/src/commands/view/CommandAbstract.js b/src/commands/view/CommandAbstract.js index 7b0aad099..a389b9446 100644 --- a/src/commands/view/CommandAbstract.js +++ b/src/commands/view/CommandAbstract.js @@ -109,6 +109,7 @@ export default Backbone.View.extend({ const sender = options.sender || editor; const result = this.run(editor, sender, options); editor.trigger(`run:${id}`, result, options); + editor.trigger('run', id, result, options); return result; }, @@ -124,6 +125,7 @@ export default Backbone.View.extend({ editor.trigger(`stop:${id}:before`, options); const result = this.stop(editor, sender, options); editor.trigger(`stop:${id}`, result, options); + editor.trigger('stop', id, result, options); return result; }, diff --git a/src/editor/index.js b/src/editor/index.js index b3c2060bb..98dc264b3 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -87,6 +87,8 @@ * * `run:{commandName}:before` - Triggered before the command is called * * `stop:{commandName}:before` - Triggered before the command is called to stop * * `abort:{commandName}` - Triggered when the command execution is aborted (`editor.on(`run:preview:before`, opts => opts.abort = 1);`) + * * `run` - Triggered on run of any command. The id and the result are passed as arguments to the callback + * * `stop` - Triggered on stop of any command. The id and the result are passed as arguments to the callback * ### General * * `canvasScroll` - Canvas is scrolled * * `update` - The structure of the template is updated (its HTML/CSS)