Browse Source

Fix ComponentDelete command. Closes #5633

pull/5642/head
Artur Arseniev 3 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 }> = { const command: CommandObject<{ component?: Component }> = {
run(ed, s, opts = {}) { run(ed, s, opts = {}) {
const toSelect: Component[] = []; const removed: Component[] = [];
let components = opts.component || ed.getSelectedAll(); let components = opts.component || ed.getSelectedAll();
components = isArray(components) ? [...components] : [components]; components = isArray(components) ? [...components] : [components];
components.filter(Boolean).forEach(component => { components.filter(Boolean).forEach(component => {
if (!component.get('removable')) { if (!component.get('removable')) {
toSelect.push(component);
return this.em.logWarning('The element is not removable', { return this.em.logWarning('The element is not removable', {
component, component,
}); });
} }
removed.push(component);
const cmp = component.delegate?.remove?.(component) || component; const cmp = component.delegate?.remove?.(component) || component;
cmp.remove(); cmp.remove();
}); });
ed.select(toSelect); ed.selectRemove(removed);
return components; return removed;
}, },
}; };

Loading…
Cancel
Save