diff --git a/src/components/block/index.ts b/src/components/block/index.ts index 493f9657c..1cb96a4c0 100644 --- a/src/components/block/index.ts +++ b/src/components/block/index.ts @@ -528,7 +528,7 @@ export default class Block extends EventsDispatcher { try { // eslint-disable-next-line no-useless-call - this.toolInstance[methodName].call(this.toolInstance, params); + return this.toolInstance[methodName].call(this.toolInstance, params); } catch (e) { _.log(`Error during '${methodName}' call: ${e.message}`, 'error'); } diff --git a/src/components/modules/blockManager.ts b/src/components/modules/blockManager.ts index ae8e4818c..8d752c0f4 100644 --- a/src/components/modules/blockManager.ts +++ b/src/components/modules/blockManager.ts @@ -546,6 +546,14 @@ export default class BlockManager extends Module { continue; } + /** + * prevent deletion if return -1 + */ + const ret: any = this.blocks[index].call('beforeSelectedDestroy'); + if (ret === -1) { + continue; + } + this.removeBlock(this.blocks[index]); firstSelectedBlockIndex = index; }