import { isArray } from 'underscore';

module.exports = {
  run(ed, sender, opts = {}) {
    if (!ed.Canvas.hasFocus() || ed.getModel().isEditing()) return;
    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')) {
        console.warn('The element is not removable', component);
        return;
      }
      if (component) {
        const coll = component.collection;
        coll && coll.remove(component);
      }
    });

    return components;
  }
};

@@ -94,33 +94,8 @@
 if (
-!ed.Canvas.hasFocus() %7C%7C 
 ed.g
@@ -661,16 +661,64 @@
 ection;%0A
+        component.trigger('component:destroy');%0A
         

Add component:destroy event to ComponentDelete