Browse Source

Added `run` and `stop` events for Commands

drag-rules
Artur Arseniev 8 years ago
parent
commit
870791d149
  1. 2
      docs/.vuepress/components/demos/DemoCanvasOnly.js
  2. 2
      src/commands/view/CommandAbstract.js
  3. 2
      src/editor/index.js

2
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: [] },
});

2
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;
},

2
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)

Loading…
Cancel
Save