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'; |
import { isArray } from 'underscore'; |
||||
|
|
||||
export default { |
export default { |
||||
run(ed, sender, opts = {}) { |
run(ed, s, opts = {}) { |
||||
const toSelect = []; |
const toSelect = []; |
||||
let components = opts.component || ed.getSelectedAll(); |
let components = opts.component || ed.getSelectedAll(); |
||||
components = isArray(components) ? [...components] : [components]; |
components = isArray(components) ? [...components] : [components]; |
||||
|
|
||||
// It's important to deselect components first otherwise,
|
components.filter(Boolean).forEach(component => { |
||||
// with undo, the component will be set with the wrong `collection`
|
if (!component.get('removable')) { |
||||
ed.select(null); |
toSelect.push(component); |
||||
|
|
||||
components.forEach(component => { |
|
||||
if (!component || !component.get('removable')) { |
|
||||
return this.em.logWarning('The element is not removable', { |
return this.em.logWarning('The element is not removable', { |
||||
component |
component, |
||||
}); |
}); |
||||
} |
} |
||||
component.remove(); |
component.remove(); |
||||
component.collection && toSelect.push(component); |
|
||||
}); |
}); |
||||
|
|
||||
toSelect.length && ed.select(toSelect); |
ed.select(toSelect); |
||||
|
|
||||
return components; |
return components; |
||||
} |
}, |
||||
}; |
}; |
||||
|
|||||
Loading…
Reference in new issue