Browse Source

Improve resizable component model property

Passing an object, will use it as additional options
pull/261/head
Artur Arseniev 9 years ago
parent
commit
9202520b28
  1. 1
      src/dom_components/model/Component.js
  2. 8
      src/dom_components/view/ComponentView.js

1
src/dom_components/model/Component.js

@ -43,6 +43,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({
copyable: true,
// Indicates if it's possible to resize the component (at the moment implemented only on Image Components)
// It's also possible to pass an object as options for the Resizer
resizable: false,
// Allow to edit the content of the component (used on Text components)

8
src/dom_components/view/ComponentView.js

@ -248,6 +248,7 @@ module.exports = Backbone.View.extend({
var attrName = 'data-' + pfx + 'handler';
var resizeClass = pfx + 'resizing';
var model = this.model;
var resizable = model.get('resizable');
var modelToStyle;
var toggleBodyClass = (method, e, opts) => {
@ -259,7 +260,7 @@ module.exports = Backbone.View.extend({
}
};
if(editor && model.get('resizable')) {
if(editor && resizable) {
let resizeOptions = {
onStart(e, opts) {
toggleBodyClass('addClass', e, opts);
@ -290,6 +291,11 @@ module.exports = Backbone.View.extend({
}
}
};
if (typeof resizable == 'object') {
resizeOptions = Object.assign(resizeOptions, resizable);
}
editor.runCommand('resize', {
el: this.el,
options: resizeOptions

Loading…
Cancel
Save