Browse Source

Fix ComponentDelete command. Closes #5633

pull/5642/head
Artur Arseniev 2 years ago
parent
commit
f70fd96df2
  1. 9
      src/commands/view/ComponentDelete.ts

9
src/commands/view/ComponentDelete.ts

@ -4,24 +4,25 @@ import { CommandObject } from './CommandAbstract';
const command: CommandObject<{ component?: Component }> = {
run(ed, s, opts = {}) {
const toSelect: Component[] = [];
const removed: Component[] = [];
let components = opts.component || ed.getSelectedAll();
components = isArray(components) ? [...components] : [components];
components.filter(Boolean).forEach(component => {
if (!component.get('removable')) {
toSelect.push(component);
return this.em.logWarning('The element is not removable', {
component,
});
}
removed.push(component);
const cmp = component.delegate?.remove?.(component) || component;
cmp.remove();
});
ed.select(toSelect);
ed.selectRemove(removed);
return components;
return removed;
},
};

Loading…
Cancel
Save