feat: Add IPathObject.updateReplacing()

This commit is contained in:
Aaron Dodson
2026-01-13 15:13:55 -08:00
parent 7f4ec3a9ea
commit b6db9fec87
3 changed files with 21 additions and 5 deletions

View File

@@ -1735,11 +1735,7 @@ export class BlockSvg
* @internal
*/
fadeForReplacement(add: boolean) {
if (add) {
this.addClass('blocklyReplaceable');
} else {
this.removeClass('blocklyReplaceable');
}
this.pathObject.updateReplacing?.(add);
}
/**

View File

@@ -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;
}

View File

@@ -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,