|
|
@ -1,4 +1,4 @@ |
|
|
import { bindAll } from 'underscore'; |
|
|
import { bindAll, isElement } from 'underscore'; |
|
|
import { on, off, getUnitFromValue } from 'utils/mixins'; |
|
|
import { on, off, getUnitFromValue } from 'utils/mixins'; |
|
|
|
|
|
|
|
|
const ToolbarView = require('dom_components/view/ToolbarView'); |
|
|
const ToolbarView = require('dom_components/view/ToolbarView'); |
|
|
@ -186,6 +186,7 @@ module.exports = { |
|
|
if (model) { |
|
|
if (model) { |
|
|
if (model.get('selectable')) { |
|
|
if (model.get('selectable')) { |
|
|
editor.select(model); |
|
|
editor.select(model); |
|
|
|
|
|
this.initResize(model); |
|
|
} else { |
|
|
} else { |
|
|
let parent = model.parent(); |
|
|
let parent = model.parent(); |
|
|
while (parent && !parent.get('selectable')) parent = parent.parent(); |
|
|
while (parent && !parent.get('selectable')) parent = parent.parent(); |
|
|
@ -262,7 +263,8 @@ module.exports = { |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
onSelect() { |
|
|
onSelect() { |
|
|
const editor = this.editor; |
|
|
// Get the selected model directly from the Editor as the event might
|
|
|
|
|
|
// be triggered manually without the model
|
|
|
const model = this.em.getSelected(); |
|
|
const model = this.em.getSelected(); |
|
|
this.updateToolbar(model); |
|
|
this.updateToolbar(model); |
|
|
|
|
|
|
|
|
@ -273,26 +275,27 @@ module.exports = { |
|
|
this.hideHighlighter(); |
|
|
this.hideHighlighter(); |
|
|
this.initResize(el); |
|
|
this.initResize(el); |
|
|
} else { |
|
|
} else { |
|
|
editor.stopCommand('resize'); |
|
|
this.editor.stopCommand('resize'); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Init resizer on the element if possible |
|
|
* Init resizer on the element if possible |
|
|
* @param {HTMLElement} el |
|
|
* @param {HTMLElement|Component} elem |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
initResize(el) { |
|
|
initResize(elem) { |
|
|
var em = this.em; |
|
|
const em = this.em; |
|
|
var editor = em ? em.get('Editor') : ''; |
|
|
const editor = em ? em.get('Editor') : ''; |
|
|
var config = em ? em.get('Config') : ''; |
|
|
const config = em ? em.get('Config') : ''; |
|
|
var pfx = config.stylePrefix || ''; |
|
|
const pfx = config.stylePrefix || ''; |
|
|
var attrName = `data-${pfx}handler`; |
|
|
const attrName = `data-${pfx}handler`; |
|
|
var resizeClass = `${pfx}resizing`; |
|
|
const resizeClass = `${pfx}resizing`; |
|
|
var model = em.get('selectedComponent'); |
|
|
const model = !isElement(elem) ? elem : em.getSelected(); |
|
|
var resizable = model.get('resizable'); |
|
|
const resizable = model.get('resizable'); |
|
|
var options = {}; |
|
|
const el = isElement(elem) ? elem : model.getEl(); |
|
|
var modelToStyle; |
|
|
let options = {}; |
|
|
|
|
|
let modelToStyle; |
|
|
|
|
|
|
|
|
var toggleBodyClass = (method, e, opts) => { |
|
|
var toggleBodyClass = (method, e, opts) => { |
|
|
const docs = opts.docs; |
|
|
const docs = opts.docs; |
|
|
@ -376,11 +379,12 @@ module.exports = { |
|
|
if (typeof resizable == 'object') { |
|
|
if (typeof resizable == 'object') { |
|
|
options = { ...options, ...resizable }; |
|
|
options = { ...options, ...resizable }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
editor.runCommand('resize', { el, options }); |
|
|
editor.runCommand('resize', { el, options }); |
|
|
|
|
|
|
|
|
// On undo/redo the resizer rect is not updating, need somehow to call
|
|
|
// On undo/redo the resizer rect is not updating, need somehow to call
|
|
|
// this.updateRect on undo/redo action
|
|
|
// this.updateRect on undo/redo action
|
|
|
|
|
|
} else { |
|
|
|
|
|
editor.stopCommand('resize'); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|