From 7a1530d91160912a633cb7cc878135620de63b0d Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Wed, 6 Aug 2025 22:26:30 +0800 Subject: [PATCH 1/4] refactor: remove unnecessary `Element` check [DOMPurify v3.2.2][1] narrowed down the types of these hooks so that these are known to have the `Element` type, which means checking the type of these at runtime is unnecessary. [1]: https://github.com/cure53/DOMPurify/releases/tag/3.2.2 See: fe3cffbb673a25b81989aacb06e5d0eda35326db See: https://github.com/cure53/DOMPurify/commit/4cdfd1ffef091823d72d91cc78616eb7070b22a0 --- packages/mermaid/src/diagrams/common/common.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index 00c9b8313..4b73bb02f 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -33,13 +33,13 @@ function setupDompurifyHooks() { const TEMPORARY_ATTRIBUTE = 'data-temp-href-target'; DOMPurify.addHook('beforeSanitizeAttributes', (node) => { - if (node instanceof Element && node.tagName === 'A' && node.hasAttribute('target')) { + if (node.tagName === 'A' && node.hasAttribute('target')) { node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute('target') ?? ''); } }); DOMPurify.addHook('afterSanitizeAttributes', (node) => { - if (node instanceof Element && node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) { + if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) { node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) ?? ''); node.removeAttribute(TEMPORARY_ATTRIBUTE); if (node.getAttribute('target') === '_blank') { From 5af489d8ddd0b8d7c2f6f5fd4db70b935ff51693 Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Fri, 8 Aug 2025 14:17:09 +0530 Subject: [PATCH 2/4] Fix border style for hand drawn shapes --- .../shapes/handDrawnShapeStyles.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts index 99dedd919..16a201e14 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts @@ -104,8 +104,23 @@ export const userNodeOverrides = (node: Node, options: any) => { seed: handDrawnSeed, strokeWidth: stylesMap.get('stroke-width')?.replace('px', '') || 1.3, fillLineDash: [0, 0], + strokeLineDash: getStrokeDashArray(stylesMap.get('stroke-dasharray')), }, options ); return result; }; + +const getStrokeDashArray = (strokeDasharrayStyle?: string) => { + if (!strokeDasharrayStyle) { + return [0, 0]; + } + const dashArray = strokeDasharrayStyle.trim().split(/\s+/).map(Number); + if (dashArray.length === 1) { + const val = isNaN(dashArray[0]) ? 0 : dashArray[0]; + return [val, val]; + } + const first = isNaN(dashArray[0]) ? 0 : dashArray[0]; + const second = isNaN(dashArray[1]) ? 0 : dashArray[1]; + return [first, second]; +}; From 4d62d5963238400270e9314c6e4d506f48147074 Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Fri, 8 Aug 2025 14:19:03 +0530 Subject: [PATCH 3/4] added changeset --- .changeset/six-planets-rescue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/six-planets-rescue.md diff --git a/.changeset/six-planets-rescue.md b/.changeset/six-planets-rescue.md new file mode 100644 index 000000000..8b04a69ed --- /dev/null +++ b/.changeset/six-planets-rescue.md @@ -0,0 +1,5 @@ +--- +'mermaid': patch +--- + +fix: node border style for handdrawn shapes From bb2d6973ba3b6c22c239dfaa99fc564aec108d09 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 02:12:30 +0000 Subject: [PATCH 4/4] chore(deps): update peter-evans/create-pull-request digest to 1310d7d --- .github/workflows/e2e-timings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-timings.yml b/.github/workflows/e2e-timings.yml index ef009fa2b..f4c28acad 100644 --- a/.github/workflows/e2e-timings.yml +++ b/.github/workflows/e2e-timings.yml @@ -58,7 +58,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Commit and create pull request - uses: peter-evans/create-pull-request@07cbaebb4bfc9c5d7db426ea5a5f585df29dd0a0 + uses: peter-evans/create-pull-request@1310d7dab503600742045e6fd4b84dda64352858 with: add-paths: | cypress/timings.json