From b6db9fec8702482540e9ca63fc212c9c8dfdc71b Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 13 Jan 2026 15:13:55 -0800 Subject: [PATCH] feat: Add `IPathObject.updateReplacing()` --- core/block_svg.ts | 6 +----- core/renderers/common/i_path_object.ts | 9 +++++++++ core/renderers/common/path_object.ts | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index 269081a6e..231af949d 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -1735,11 +1735,7 @@ export class BlockSvg * @internal */ fadeForReplacement(add: boolean) { - if (add) { - this.addClass('blocklyReplaceable'); - } else { - this.removeClass('blocklyReplaceable'); - } + this.pathObject.updateReplacing?.(add); } /** diff --git a/core/renderers/common/i_path_object.ts b/core/renderers/common/i_path_object.ts index a68c3a411..a7379bbea 100644 --- a/core/renderers/common/i_path_object.ts +++ b/core/renderers/common/i_path_object.ts @@ -106,4 +106,13 @@ export interface IPathObject { * @param blockStyle The block style to use. */ setStyle?(blockStyle: BlockStyle): void; + + /** + * Add or remove styling indicating that a block will be bumped out and + * replaced by another block that is mid-move. + * + * @param replacing True if the block is at risk of being replaced, false + * otherwise. + */ + updateReplacing?(replacing: boolean): void; } diff --git a/core/renderers/common/path_object.ts b/core/renderers/common/path_object.ts index 50ea9252d..e6cb4962f 100644 --- a/core/renderers/common/path_object.ts +++ b/core/renderers/common/path_object.ts @@ -191,6 +191,17 @@ export class PathObject implements IPathObject { this.setClass_('blocklyDraggable', enable); } + /** + * Add or remove styling indicating that a block will be bumped out and + * replaced by another block that is mid-move. + * + * @param replacing True if the block is at risk of being replaced, false + * otherwise. + */ + updateReplacing(replacing: boolean) { + this.setClass_('blocklyReplaceable', replacing); + } + /** Adds the given path as a connection highlight for the given connection. */ addConnectionHighlight( connection: RenderedConnection,