fix!: Make IPathObject styling methods optional (#8332)

This commit is contained in:
Shashwat Pathak
2024-07-12 22:06:25 +05:30
committed by GitHub
parent 5a32c3fe43
commit dd18edd343
2 changed files with 18 additions and 18 deletions

View File

@@ -849,7 +849,7 @@ export class BlockSvg
* @internal
*/
applyColour() {
this.pathObject.applyColour(this);
this.pathObject.applyColour?.(this);
const icons = this.getIcons();
for (let i = 0; i < icons.length; i++) {
@@ -1115,7 +1115,7 @@ export class BlockSvg
.getConstants()
.getBlockStyleForColour(this.colour_);
this.pathObject.setStyle(styleObj.style);
this.pathObject.setStyle?.(styleObj.style);
this.style = styleObj.style;
this.styleName_ = styleObj.name;
@@ -1137,7 +1137,7 @@ export class BlockSvg
if (blockStyle) {
this.hat = blockStyle.hat;
this.pathObject.setStyle(blockStyle);
this.pathObject.setStyle?.(blockStyle);
// Set colour to match Block.
this.colour_ = blockStyle.colourPrimary;
this.style = blockStyle;

View File

@@ -49,21 +49,6 @@ export interface IPathObject {
*/
setPath(pathString: string): void;
/**
* Apply the stored colours to the block's path, taking into account whether
* the paths belong to a shadow block.
*
* @param block The source block.
*/
applyColour(block: BlockSvg): void;
/**
* Update the style.
*
* @param blockStyle The block style to use.
*/
setStyle(blockStyle: BlockStyle): void;
/**
* Flip the SVG paths in RTL.
*/
@@ -130,8 +115,23 @@ export interface IPathObject {
rtl: boolean,
): void;
/**
* Apply the stored colours to the block's path, taking into account whether
* the paths belong to a shadow block.
*
* @param block The source block.
*/
applyColour?(block: BlockSvg): void;
/**
* Removes any highlight associated with the given connection, if it exists.
*/
removeConnectionHighlight?(connection: RenderedConnection): void;
/**
* Update the style.
*
* @param blockStyle The block style to use.
*/
setStyle?(blockStyle: BlockStyle): void;
}