mirror of https://github.com/artf/grapesjs.git
1 changed files with 7 additions and 11 deletions
@ -1,27 +1,23 @@ |
|||
import { isArray } from 'underscore'; |
|||
|
|||
export default { |
|||
run(ed, sender, opts = {}) { |
|||
run(ed, s, opts = {}) { |
|||
const toSelect = []; |
|||
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')) { |
|||
components.filter(Boolean).forEach(component => { |
|||
if (!component.get('removable')) { |
|||
toSelect.push(component); |
|||
return this.em.logWarning('The element is not removable', { |
|||
component |
|||
component, |
|||
}); |
|||
} |
|||
component.remove(); |
|||
component.collection && toSelect.push(component); |
|||
}); |
|||
|
|||
toSelect.length && ed.select(toSelect); |
|||
ed.select(toSelect); |
|||
|
|||
return components; |
|||
} |
|||
}, |
|||
}; |
|||
|
|||
Loading…
Reference in new issue