react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

DeRegister DeleteItemsAction from Canvas Engine

Open mathiasbaldissera opened this issue 7 years ago • 1 comments

At the constructor of the Canvas Engine, is registered the DeleteItemsAction, but this Action is not exported from the react-canvas-core libary , and there's no method to get and deregister it. Is there any workaround to remove this Action from the Engine without changing the library source code?

mathiasbaldissera avatar Sep 11 '19 03:09 mathiasbaldissera

Same question here!

Terrible hack, I know:

    let key = 0, subKey = 0
    _.forEach(this.state.engine.getActionEventBus(), (actionBus) => {
      _.forEach(actionBus, (action) => {
          if (key === 0 && subKey === 1) // DeleteItemsAction
          {
            this.state.engine.getActionEventBus().deregisterAction(action)
          }
          subKey++
      })
      key++
    })
  }

Without the need of DeleteItemsAction or re-creating CanvasEngine. I used lodash (the _.)

Letrab avatar Sep 19 '19 09:09 Letrab