mirror of https://github.com/artf/grapesjs.git
3 changed files with 47 additions and 40 deletions
@ -0,0 +1,6 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
ed.DomComponents.clear(); |
|||
ed.CssComposer.clear(); |
|||
} |
|||
}; |
|||
@ -0,0 +1,25 @@ |
|||
import { isArray } from 'underscore'; |
|||
|
|||
module.exports = { |
|||
run(ed, sender, opts = {}) { |
|||
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; |
|||
coll && coll.remove(component); |
|||
} |
|||
}); |
|||
|
|||
return components; |
|||
} |
|||
}; |
|||
Loading…
Reference in new issue