From 8ef5d324fd92532886f3fbfc08fd5ce25337ebd1 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 30 Oct 2024 13:32:03 +0100 Subject: [PATCH] Typescript fixes --- .../rendering-elements/shapes/kanbanItem.ts | 15 +++++++-------- .../rendering-elements/shapes/util.ts | 5 ++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts index 34ba7873d5..fba867a71a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/kanbanItem.ts @@ -27,7 +27,7 @@ export async function kanbanItem( { config }: ShapeRenderOptions ) { const { labelStyles, nodeStyles } = styles2String(kanbanNode); - kanbanNode.labelStyle = labelStyles; + kanbanNode.labelStyle = labelStyles || ''; const labelPaddingX = 10; const orgWidth = kanbanNode.width; @@ -54,11 +54,10 @@ export async function kanbanItem( const options = { useHtmlLabels: kanbanNode.useHtmlLabels, - labelStyle: kanbanNode.labelStyle, + labelStyle: kanbanNode.labelStyle || '', width: kanbanNode.width, - icon: kanbanNode.icon, img: kanbanNode.img, - padding: kanbanNode.padding, + padding: kanbanNode.padding || 8, centerLabel: false, }; let labelEl, bbox2; @@ -121,15 +120,15 @@ export async function kanbanItem( : rc.rectangle(x, y, totalWidth, totalHeight, options); rect = shapeSvg.insert(() => roughNode, ':first-child'); - rect.attr('class', 'basic label-container').attr('style', cssStyles); + rect.attr('class', 'basic label-container').attr('style', cssStyles ? cssStyles : null); } else { rect = shapeSvg.insert('rect', ':first-child'); rect .attr('class', 'basic label-container __APA__') .attr('style', nodeStyles) - .attr('rx', rx) - .attr('ry', ry) + .attr('rx', rx ?? 5) + .attr('ry', ry ?? 5) .attr('x', x) .attr('y', y) .attr('width', totalWidth) @@ -137,7 +136,7 @@ export async function kanbanItem( const priority = 'priority' in kanbanNode && kanbanNode.priority; if (priority) { - const line = shapeSvg.append('line', ':first-child'); + const line = shapeSvg.append('line'); const lineX = x + 2; const y1 = y + Math.floor((rx ?? 0) / 2); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts index 09b45eacdf..52471ecc07 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.ts @@ -133,7 +133,10 @@ export const insertLabel = async ( const useHtmlLabels = options.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels); // Create the label and insert it after the rect - const labelEl = parent.insert('g').attr('class', 'label').attr('style', options.labelStyle); + const labelEl = parent + .insert('g') + .attr('class', 'label') + .attr('style', options.labelStyle || ''); const text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), { useHtmlLabels,