Browse Source

Re-enable `block:drag:*` events

pull/1229/head
Artur Arseniev 8 years ago
parent
commit
30236cdc31
  1. 13
      src/block_manager/view/BlockView.js
  2. 5
      src/editor/index.js

13
src/block_manager/view/BlockView.js

@ -6,6 +6,7 @@ module.exports = Backbone.View.extend({
events: {
mousedown: 'startDrag',
dragstart: 'handleDragStart',
drag: 'handleDrag',
dragend: 'handleDragEnd'
},
@ -34,7 +35,8 @@ module.exports = Backbone.View.extend({
},
handleDragStart(ev) {
const content = this.model.get('content');
const { em, model } = this;
const content = model.get('content');
const isObj = isObject(content);
const type = isObj ? 'text/json' : 'text';
const data = isObj ? JSON.stringify(content) : content;
@ -43,7 +45,12 @@ module.exports = Backbone.View.extend({
// but will use dragContent as I need it for the Sorter context
// IE11 supports only 'text' data type
ev.dataTransfer.setData('text', data);
this.em.set('dragContent', content);
em.set('dragContent', content);
em.trigger('block:drag:start', model, ev);
},
handleDrag(ev) {
this.em.trigger('block:drag', this.model, ev);
},
handleDragEnd() {
@ -72,6 +79,8 @@ module.exports = Backbone.View.extend({
dragResult: null,
dragContent: null
});
em.trigger('block:drag:stop', result, model);
},
/**

5
src/editor/index.js

@ -22,8 +22,9 @@
* ## Blocks
* * `block:add` - New block added
* * `block:remove` - Block removed
* * `block:drag:start` - Started dragging new block, Event object is passed as an argument
* * `block:drag:stop` - Block dropped inside canvas, the new model is passed as an argument to the callback
* * `block:drag:start` - Started dragging block, model of the block is passed as an argument
* * `block:drag` - Dragging block, the block's model and the drag event are passed as arguments
* * `block:drag:stop` - Dragging of the block is stopped. As agruments for the callback you get, the dropped component model (if dropped successfully) and the model of the block
* ## Assets
* * `asset:add` - New asset added
* * `asset:remove` - Asset removed

Loading…
Cancel
Save