diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index f175cb0d1..21cd953c1 100644 --- a/src/dom_components/model/Component.js +++ b/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