Browse Source

Add `update` event to generaly listen any change to the template

pull/1874/head
Artur Arseniev 7 years ago
parent
commit
225c54703a
  1. 5
      src/editor/index.js
  2. 3
      src/editor/model/Editor.js

5
src/editor/index.js

@ -88,10 +88,11 @@
* * `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);`)
* ### General
* * `canvasScroll` - Triggered when the canvas is scrolle
* * `canvasScroll` - Canvas is scrolled
* * `update` - The structure of the template is updated (its HTML/CSS)
* * `undo` - Undo executed
* * `redo` - Redo executed
* * `load` - When the editor is loaded
* * `load` - Editor is loaded
*
* @module Editor
*/

3
src/editor/model/Editor.js

@ -34,6 +34,7 @@ const deps = [
const Backbone = require('backbone');
const { Collection } = Backbone;
let timedInterval;
let updateItr;
require('utils/extender')({
Backbone: Backbone,
@ -156,6 +157,8 @@ module.exports = Backbone.Model.extend({
updateChanges() {
const stm = this.get('StorageManager');
const changes = this.get('changesCount');
updateItr && clearTimeout(updateItr);
updateItr = setTimeout(() => this.trigger('update'));
if (this.config.noticeOnUnload) {
window.onbeforeunload = changes ? e => 1 : null;

Loading…
Cancel
Save