From 3b07616692e6be8ab56bb25c648e8d7902324d58 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 13 Jan 2018 02:07:14 +0100 Subject: [PATCH] Stop using `dragContent` in Droppable and add activeOnRender --- src/block_manager/view/BlockView.js | 8 ++++++-- src/utils/Droppable.js | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/block_manager/view/BlockView.js b/src/block_manager/view/BlockView.js index bae9e572a..39243d9d8 100644 --- a/src/block_manager/view/BlockView.js +++ b/src/block_manager/view/BlockView.js @@ -4,7 +4,12 @@ import { on, off, hasDnd } from 'utils/mixins'; module.exports = Backbone.View.extend({ events: { mousedown: 'startDrag', - dragstart: 'handleDragStart' + dragstart: 'handleDragStart', + dragend: 'handleDragEnd' + }, + + handleDragEnd(ev) { + console.log('handleDragEnd'); }, initialize(o, config = {}) { @@ -36,7 +41,6 @@ module.exports = Backbone.View.extend({ const isObj = isObject(content); const type = isObj ? 'text/json' : 'text'; const data = isObj ? JSON.stringify(content) : content; - console.log('handleDragStart', data); // Note: data are not available on dragenter for security reason ev.dataTransfer.setData(type, data); }, diff --git a/src/utils/Droppable.js b/src/utils/Droppable.js index 5edf4d607..6853371ef 100644 --- a/src/utils/Droppable.js +++ b/src/utils/Droppable.js @@ -36,7 +36,6 @@ export default class Droppable { // force out like in BlockView const sorter = this.sorter; cancel && (sorter.moved = 0); - //em.set('dragContent', ''); sorter.endMove(); em.trigger('canvas:dragend', ev); } @@ -71,7 +70,14 @@ export default class Droppable { itemSel: '*', pfx: 'gjs-', onStart: () => em.stopDefault(), - onEndMove: () => em.runDefault(), + onEndMove: model => { + em.runDefault(); + + if (model && model.get && model.get('activeOnRender')) { + model.trigger('active'); + model.set('activeOnRender', 0); + } + }, document: canvas.getFrameEl().contentDocument }); const content = this.getContentByData(dt).content || '
';