mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
803 B
27 lines
803 B
import { isArray } from 'underscore';
|
|
|
|
module.exports = {
|
|
run(ed, sender, opts = {}) {
|
|
if (ed.getModel().isEditing()) return;
|
|
let components = opts.component || ed.getSelectedAll();
|
|
components = isArray(components) ? [...components] : [components];
|
|
|
|
// It's important to deselect components first otherwise,
|
|
// with undo, the component will be set with the wrong `collection`
|
|
ed.select(null);
|
|
|
|
components.forEach(component => {
|
|
if (!component || !component.get('removable')) {
|
|
console.warn('The element is not removable', component);
|
|
return;
|
|
}
|
|
if (component) {
|
|
const coll = component.collection;
|
|
component.trigger('component:destroy');
|
|
coll && coll.remove(component);
|
|
}
|
|
});
|
|
|
|
return components;
|
|
}
|
|
};
|
|
|