Skip to content

Commit

Permalink
Fix ComponentDelete command. Closes #5633
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jan 21, 2024
1 parent 9245595 commit f70fd96
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/commands/view/ComponentDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};

Expand Down

0 comments on commit f70fd96

Please sign in to comment.