Browse Source

Add move method to Component

pull/3229/head
Artur Arseniev 6 years ago
parent
commit
c1c637749b
  1. 16
      src/dom_components/model/Component.js

16
src/dom_components/model/Component.js

@ -1359,6 +1359,22 @@ const Component = Backbone.Model.extend(Styleable).extend(
return coll && coll.remove(this, opts);
},
/**
* Move the component to another destination component
* @param {Component} component Destination component (so the current one will be appended as a child)
* @param {Object} opts Options for the append action
* @returns {this}
* @example
* // Move the selected component on top of the wrapper
* const dest = editor.getWrapper();
* editor.getSelected().move(dest, { at: 0 });
*/
move(component, opts = {}) {
this.remove({ temporary: 1 });
component && component.append(this, opts);
return this;
},
/**
* Reset id of the component and any of its style rule
* @param {Object} [opts={}] Options

Loading…
Cancel
Save