From d46d55f73890c48b07079634ebedd77d31141457 Mon Sep 17 00:00:00 2001 From: YAMADA Yutaka Date: Mon, 3 Oct 2022 10:40:20 +0900 Subject: [PATCH] fix: Modifying size update handling for multiline field in parent block. --- core/field_multilineinput.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/field_multilineinput.ts b/core/field_multilineinput.ts index 8a5ba7dc6a5..bee2d095d32 100644 --- a/core/field_multilineinput.ts +++ b/core/field_multilineinput.ts @@ -270,11 +270,15 @@ export class FieldMultilineInput extends FieldTextInput { /** Updates the size of the field based on the text. */ protected override updateSize_() { const nodes = this.textGroup_.childNodes; + const fontSize = this.getConstants()!.FIELD_TEXT_FONTSIZE; + const fontWeight = this.getConstants()!.FIELD_TEXT_FONTWEIGHT; + const fontFamily = this.getConstants()!.FIELD_TEXT_FONTFAMILY; let totalWidth = 0; let totalHeight = 0; for (let i = 0; i < nodes.length; i++) { const tspan = nodes[i] as SVGTextElement; - const textWidth = dom.getTextWidth(tspan); + const textWidth = + dom.getFastTextWidth(tspan, fontSize, fontWeight, fontFamily); if (textWidth > totalWidth) { totalWidth = textWidth; } @@ -290,9 +294,6 @@ export class FieldMultilineInput extends FieldTextInput { const actualEditorLines = this.value_.split('\n'); const dummyTextElement = dom.createSvgElement( Svg.TEXT, {'class': 'blocklyText blocklyMultilineText'}); - const fontSize = this.getConstants()!.FIELD_TEXT_FONTSIZE; - const fontWeight = this.getConstants()!.FIELD_TEXT_FONTWEIGHT; - const fontFamily = this.getConstants()!.FIELD_TEXT_FONTFAMILY; for (let i = 0; i < actualEditorLines.length; i++) { if (actualEditorLines[i].length > this.maxDisplayLength) {