@haklex/rich-renderer-mermaid 0.0.110 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -222,9 +222,7 @@ const CORNER_RADIUS = {
222
222
  diamond: 4
223
223
  };
224
224
  function roundNodePolygons(doc, radius) {
225
- const polygons = doc.querySelectorAll(
226
- ".node > polygon, .node polygon"
227
- );
225
+ const polygons = doc.querySelectorAll(".node > polygon, .node polygon");
228
226
  for (const polygon of polygons) {
229
227
  const points = polygon.points;
230
228
  if (points.numberOfItems < 3) continue;
@@ -274,10 +272,7 @@ function applyCornerRounding(doc) {
274
272
  applyRadius(".er > rect", CORNER_RADIUS.entity);
275
273
  applyRadius(".cluster > rect", CORNER_RADIUS.subgraphOuter);
276
274
  applyRadius(".actor", CORNER_RADIUS.actor);
277
- applyRadius(
278
- ".activation0, .activation1, .activation2",
279
- CORNER_RADIUS.activation
280
- );
275
+ applyRadius(".activation0, .activation1, .activation2", CORNER_RADIUS.activation);
281
276
  roundNodePolygons(doc, CORNER_RADIUS.diamond);
282
277
  }
283
278
  function buildVisualCss(tokens) {
@@ -454,13 +449,22 @@ function buildVisualCss(tokens) {
454
449
  `;
455
450
  }
456
451
  function postProcessMermaidSvg(svg, tokens) {
452
+ const normalizedSvg = svg.replaceAll(/<br\s*>/gi, "<br/>");
457
453
  const parser = new DOMParser();
458
- const doc = parser.parseFromString(svg, "image/svg+xml");
454
+ const doc = parser.parseFromString(normalizedSvg, "image/svg+xml");
459
455
  const parseError = doc.querySelector("parsererror");
460
- if (parseError) return svg;
456
+ if (parseError) return normalizedSvg;
461
457
  const root = doc.documentElement;
462
- if (!root || root.tagName.toLowerCase() !== "svg") return svg;
458
+ if (!root || root.tagName.toLowerCase() !== "svg") return normalizedSvg;
463
459
  applyCornerRounding(doc);
460
+ const viewBox = root.getAttribute("viewBox");
461
+ if (viewBox) {
462
+ const parts = viewBox.split(/\s+/).map(Number);
463
+ if (parts.length === 4 && parts[2] > 0 && parts[3] > 0) {
464
+ root.setAttribute("width", String(parts[2]));
465
+ root.setAttribute("height", String(parts[3]));
466
+ }
467
+ }
464
468
  const existingOverride = root.querySelector("style[data-visual-overrides]");
465
469
  existingOverride?.remove();
466
470
  const styleEl = doc.createElementNS("http://www.w3.org/2000/svg", "style");
package/dist/index.mjs CHANGED
@@ -4,8 +4,8 @@ import { usePortalTheme, presentDialog } from "@haklex/rich-editor-ui";
4
4
  import { FishSymbol, Copy, Download, RotateCcw, X, ZoomIn, ZoomOut, Maximize2, CircleAlert, Code2, Columns2, Eye } from "lucide-react";
5
5
  import { useCallback, useState, useRef, useEffect } from "react";
6
6
  import { TransformWrapper, TransformComponent, useControls } from "react-zoom-pan-pinch";
7
- import { u as useMermaidRender, e as editorPopup, m as mermaidLoading, a as mermaidError, b as mermaidContainer, c as mermaidEditHint, d as editorHeader, f as editorHeaderLeft, g as editorTitle, h as editorSep, i as editorTplBtn, j as editorHeaderRight, k as editorViewToggle, l as editorIconBtn, n as editorBody, o as editorPane, p as editorPaneFull, q as editorPaneHalf, r as editorPaneLabel, s as editorPreviewPane, t as editorFooter, v as footerActions, w as footerBtnCancel, x as footerBtnSave, z as zoomControls, y as zoomBtn, A as editorViewItem, B as editorViewItemActive, C as codeEditor, D as codeGutter, E as codeGutterLine, F as codeArea, G as editorPreviewWrap, H as editorPreviewEmpty, I as editorPreviewErrorWrap, J as editorPreviewErrorIcon, K as editorPreviewErrorTitle, L as editorPreviewErrorMsg } from "./MermaidRenderer-CZN-HzPn.js";
8
- import { M } from "./MermaidRenderer-CZN-HzPn.js";
7
+ import { u as useMermaidRender, e as editorPopup, m as mermaidLoading, a as mermaidError, b as mermaidContainer, c as mermaidEditHint, d as editorHeader, f as editorHeaderLeft, g as editorTitle, h as editorSep, i as editorTplBtn, j as editorHeaderRight, k as editorViewToggle, l as editorIconBtn, n as editorBody, o as editorPane, p as editorPaneFull, q as editorPaneHalf, r as editorPaneLabel, s as editorPreviewPane, t as editorFooter, v as footerActions, w as footerBtnCancel, x as footerBtnSave, z as zoomControls, y as zoomBtn, A as editorViewItem, B as editorViewItemActive, C as codeEditor, D as codeGutter, E as codeGutterLine, F as codeArea, G as editorPreviewWrap, H as editorPreviewEmpty, I as editorPreviewErrorWrap, J as editorPreviewErrorIcon, K as editorPreviewErrorTitle, L as editorPreviewErrorMsg } from "./MermaidRenderer-CUSX3JgB.js";
8
+ import { M } from "./MermaidRenderer-CUSX3JgB.js";
9
9
  const TEMPLATES = [
10
10
  {
11
11
  label: "Flowchart",
package/dist/static.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { M } from "./MermaidRenderer-CZN-HzPn.js";
1
+ import { M } from "./MermaidRenderer-CUSX3JgB.js";
2
2
  export {
3
3
  M as MermaidRenderer
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"svg-post-process.d.ts","sourceRoot":"","sources":["../src/svg-post-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAwRlD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,GAClB,MAAM,CA6BR"}
1
+ {"version":3,"file":"svg-post-process.d.ts","sourceRoot":"","sources":["../src/svg-post-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmRnD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAmD9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-renderer-mermaid",
3
- "version": "0.0.110",
3
+ "version": "0.1.1",
4
4
  "description": "Mermaid diagram renderer",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,9 +31,9 @@
31
31
  "dependencies": {
32
32
  "mermaid": "^11.12.3",
33
33
  "react-zoom-pan-pinch": "^3.7.0",
34
- "@haklex/rich-style-token": "0.0.110",
35
- "@haklex/rich-editor-ui": "0.0.110",
36
- "@haklex/rich-editor": "0.0.110"
34
+ "@haklex/rich-editor": "0.1.1",
35
+ "@haklex/rich-style-token": "0.1.1",
36
+ "@haklex/rich-editor-ui": "0.1.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "^19.2.14",