@haklex/rich-renderer-mermaid 0.0.65 → 0.0.67
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.
- package/README.md +40 -23
- package/dist/MermaidEditRenderer.d.ts +1 -1
- package/dist/MermaidEditRenderer.d.ts.map +1 -1
- package/dist/{MermaidRenderer-uCCuxjy5.js → MermaidRenderer-v-jwdXd2.js} +7 -11
- package/dist/MermaidRenderer.d.ts +2 -1
- package/dist/MermaidRenderer.d.ts.map +1 -1
- package/dist/index.mjs +33 -110
- package/dist/mermaid-theme.d.ts +5 -5
- package/dist/mermaid-theme.d.ts.map +1 -1
- package/dist/static.mjs +1 -1
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -1,46 +1,63 @@
|
|
|
1
1
|
# @haklex/rich-renderer-mermaid
|
|
2
2
|
|
|
3
|
-
Mermaid
|
|
3
|
+
Mermaid diagram renderer with interactive zoom and pan controls.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpm add @haklex/rich-renderer-mermaid
|
|
8
|
+
pnpm add @haklex/rich-renderer-mermaid
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Peer Dependencies
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## 功能
|
|
19
|
-
|
|
20
|
-
- Mermaid 图表渲染
|
|
21
|
-
- 缩放平移
|
|
22
|
-
- 编辑对话框
|
|
13
|
+
| Package | Version |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `react` | `>=19` |
|
|
16
|
+
| `react-dom` | `>=19` |
|
|
23
17
|
|
|
24
|
-
##
|
|
18
|
+
## Usage
|
|
25
19
|
|
|
26
20
|
```tsx
|
|
27
|
-
import { MermaidRenderer } from '@haklex/rich-renderer-mermaid'
|
|
28
|
-
import type { RendererConfig } from '@haklex/rich-editor'
|
|
21
|
+
import { MermaidRenderer } from '@haklex/rich-renderer-mermaid/static'
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
// Register in a static RendererConfig
|
|
24
|
+
const rendererConfig = {
|
|
25
|
+
// ...other renderers
|
|
31
26
|
Mermaid: MermaidRenderer,
|
|
32
27
|
}
|
|
33
28
|
```
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
For edit mode:
|
|
36
31
|
|
|
37
|
-
```
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
```tsx
|
|
33
|
+
import { MermaidEditRenderer } from '@haklex/rich-renderer-mermaid'
|
|
34
|
+
|
|
35
|
+
const editRendererConfig = {
|
|
36
|
+
// ...other renderers
|
|
37
|
+
Mermaid: MermaidEditRenderer,
|
|
41
38
|
}
|
|
42
39
|
```
|
|
43
40
|
|
|
41
|
+
## Exports
|
|
42
|
+
|
|
43
|
+
### Components
|
|
44
|
+
|
|
45
|
+
- `MermaidRenderer` — Static (read-only) renderer with zoom and pan
|
|
46
|
+
- `MermaidEditRenderer` — Edit (interactive) renderer
|
|
47
|
+
|
|
48
|
+
### Sub-path Exports
|
|
49
|
+
|
|
50
|
+
| Path | Description |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `@haklex/rich-renderer-mermaid` | Full exports (edit + static) |
|
|
53
|
+
| `@haklex/rich-renderer-mermaid/static` | Static-only renderer |
|
|
54
|
+
| `@haklex/rich-renderer-mermaid/utils` | Mermaid utility functions |
|
|
55
|
+
| `@haklex/rich-renderer-mermaid/style.css` | Stylesheet |
|
|
56
|
+
|
|
57
|
+
## Part of Haklex
|
|
58
|
+
|
|
59
|
+
This package is part of the [Haklex](../../README.md) rich editor ecosystem.
|
|
60
|
+
|
|
44
61
|
## License
|
|
45
62
|
|
|
46
63
|
MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MermaidRendererProps } from '@haklex/rich-editor';
|
|
1
|
+
import { MermaidRendererProps } from '@haklex/rich-editor/renderers';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
export declare const MermaidEditRenderer: FC<MermaidRendererProps>;
|
|
4
4
|
//# sourceMappingURL=MermaidEditRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidEditRenderer.d.ts","sourceRoot":"","sources":["../src/MermaidEditRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MermaidEditRenderer.d.ts","sourceRoot":"","sources":["../src/MermaidEditRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAgB1E,OAAO,KAAK,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAiU7C,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,oBAAoB,CAsDxD,CAAC"}
|
|
@@ -64,11 +64,7 @@ function mix(fg, bg, percent) {
|
|
|
64
64
|
const [fR, fG, fB] = parseHex(fg);
|
|
65
65
|
const [bR, bG, bB] = parseHex(bg);
|
|
66
66
|
const p = percent / 100;
|
|
67
|
-
return toHex(
|
|
68
|
-
fR * p + bR * (1 - p),
|
|
69
|
-
fG * p + bG * (1 - p),
|
|
70
|
-
fB * p + bB * (1 - p)
|
|
71
|
-
);
|
|
67
|
+
return toHex(fR * p + bR * (1 - p), fG * p + bG * (1 - p), fB * p + bB * (1 - p));
|
|
72
68
|
}
|
|
73
69
|
function deriveTokens(bg, fg) {
|
|
74
70
|
return {
|
|
@@ -554,18 +550,18 @@ function useMermaidRender(content, preferredColorScheme) {
|
|
|
554
550
|
}
|
|
555
551
|
return { loading, error, imgSrc, svg, width, height };
|
|
556
552
|
}
|
|
557
|
-
const MermaidRenderer = ({
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
);
|
|
553
|
+
const MermaidRenderer = ({
|
|
554
|
+
content,
|
|
555
|
+
colorScheme
|
|
556
|
+
}) => {
|
|
557
|
+
const { loading, error, imgSrc, width, height } = useMermaidRender(content, colorScheme);
|
|
562
558
|
if (loading) {
|
|
563
559
|
return /* @__PURE__ */ jsx("pre", { className: mermaidLoading, children: /* @__PURE__ */ jsx("code", { children: content }) });
|
|
564
560
|
}
|
|
565
561
|
if (!imgSrc) {
|
|
566
562
|
return /* @__PURE__ */ jsx("div", { className: mermaidError, children: error || "Render failed" });
|
|
567
563
|
}
|
|
568
|
-
return /* @__PURE__ */ jsx("div", { className: mermaidContainer, style: { cursor: "default" }, children: /* @__PURE__ */ jsx("img", {
|
|
564
|
+
return /* @__PURE__ */ jsx("div", { className: mermaidContainer, style: { cursor: "default" }, children: /* @__PURE__ */ jsx("img", { alt: "Mermaid diagram", height, src: imgSrc, width }) });
|
|
569
565
|
};
|
|
570
566
|
export {
|
|
571
567
|
editorViewItem as A,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ColorScheme
|
|
1
|
+
import { ColorScheme } from '@haklex/rich-editor';
|
|
2
|
+
import { MermaidRendererProps } from '@haklex/rich-editor/renderers';
|
|
2
3
|
import { FC } from 'react';
|
|
3
4
|
export declare const MermaidRenderer: FC<MermaidRendererProps & {
|
|
4
5
|
colorScheme?: ColorScheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidRenderer.d.ts","sourceRoot":"","sources":["../src/MermaidRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"MermaidRenderer.d.ts","sourceRoot":"","sources":["../src/MermaidRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,GAAG;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,CAuBpF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
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-
|
|
8
|
-
import { M } from "./MermaidRenderer-
|
|
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-v-jwdXd2.js";
|
|
8
|
+
import { M } from "./MermaidRenderer-v-jwdXd2.js";
|
|
9
9
|
const TEMPLATES = [
|
|
10
10
|
{
|
|
11
11
|
label: "Flowchart",
|
|
@@ -34,10 +34,7 @@ const MermaidLivePreview = ({ code, svgRef, colorScheme }) => {
|
|
|
34
34
|
const t = setTimeout(() => setDebounced(code), 300);
|
|
35
35
|
return () => clearTimeout(t);
|
|
36
36
|
}, [code]);
|
|
37
|
-
const { loading, error, imgSrc, svg, width, height } = useMermaidRender(
|
|
38
|
-
debounced,
|
|
39
|
-
colorScheme
|
|
40
|
-
);
|
|
37
|
+
const { loading, error, imgSrc, svg, width, height } = useMermaidRender(debounced, colorScheme);
|
|
41
38
|
useEffect(() => {
|
|
42
39
|
svgRef.current = svg;
|
|
43
40
|
}, [svg, svgRef]);
|
|
@@ -54,7 +51,7 @@ const MermaidLivePreview = ({ code, svgRef, colorScheme }) => {
|
|
|
54
51
|
/* @__PURE__ */ jsx("p", { className: editorPreviewErrorMsg, children: error })
|
|
55
52
|
] }) });
|
|
56
53
|
}
|
|
57
|
-
return /* @__PURE__ */ jsx("div", { className: editorPreviewWrap, children: /* @__PURE__ */ jsxs(TransformWrapper, { initialScale: 1, minScale: 0.3,
|
|
54
|
+
return /* @__PURE__ */ jsx("div", { className: editorPreviewWrap, children: /* @__PURE__ */ jsxs(TransformWrapper, { initialScale: 1, maxScale: 5, minScale: 0.3, children: [
|
|
58
55
|
/* @__PURE__ */ jsx(ZoomControls, {}),
|
|
59
56
|
/* @__PURE__ */ jsx(
|
|
60
57
|
TransformComponent,
|
|
@@ -65,23 +62,12 @@ const MermaidLivePreview = ({ code, svgRef, colorScheme }) => {
|
|
|
65
62
|
display: "flex",
|
|
66
63
|
justifyContent: "center"
|
|
67
64
|
},
|
|
68
|
-
children: /* @__PURE__ */ jsx(
|
|
69
|
-
"img",
|
|
70
|
-
{
|
|
71
|
-
src: imgSrc,
|
|
72
|
-
alt: "Mermaid diagram",
|
|
73
|
-
width,
|
|
74
|
-
height
|
|
75
|
-
}
|
|
76
|
-
)
|
|
65
|
+
children: /* @__PURE__ */ jsx("img", { alt: "Mermaid diagram", height, src: imgSrc, width })
|
|
77
66
|
}
|
|
78
67
|
)
|
|
79
68
|
] }) });
|
|
80
69
|
};
|
|
81
|
-
const CodeEditor = ({
|
|
82
|
-
value,
|
|
83
|
-
onChange
|
|
84
|
-
}) => {
|
|
70
|
+
const CodeEditor = ({ value, onChange }) => {
|
|
85
71
|
const textareaRef = useRef(null);
|
|
86
72
|
const gutterRef = useRef(null);
|
|
87
73
|
const lineCount = value.split("\n").length;
|
|
@@ -103,7 +89,7 @@ const CodeEditor = ({
|
|
|
103
89
|
const ta = e.currentTarget;
|
|
104
90
|
const start = ta.selectionStart;
|
|
105
91
|
const end = ta.selectionEnd;
|
|
106
|
-
onChange(`${value.
|
|
92
|
+
onChange(`${value.slice(0, Math.max(0, start))} ${value.slice(Math.max(0, end))}`);
|
|
107
93
|
requestAnimationFrame(() => {
|
|
108
94
|
ta.selectionStart = ta.selectionEnd = start + 2;
|
|
109
95
|
});
|
|
@@ -112,17 +98,17 @@ const CodeEditor = ({
|
|
|
112
98
|
[value, onChange]
|
|
113
99
|
);
|
|
114
100
|
return /* @__PURE__ */ jsxs("div", { className: codeEditor, children: [
|
|
115
|
-
/* @__PURE__ */ jsx("div", {
|
|
101
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: codeGutter, ref: gutterRef, children: Array.from({ length: lineCount }, (_, i) => /* @__PURE__ */ jsx("div", { className: codeGutterLine, children: i + 1 }, i)) }),
|
|
116
102
|
/* @__PURE__ */ jsx(
|
|
117
103
|
"textarea",
|
|
118
104
|
{
|
|
119
|
-
ref: textareaRef,
|
|
120
105
|
className: codeArea,
|
|
106
|
+
placeholder: "Enter Mermaid code...",
|
|
107
|
+
ref: textareaRef,
|
|
108
|
+
spellCheck: false,
|
|
121
109
|
value,
|
|
122
110
|
onChange: (e) => onChange(e.target.value),
|
|
123
|
-
onKeyDown: handleKeyDown
|
|
124
|
-
spellCheck: false,
|
|
125
|
-
placeholder: "Enter Mermaid code..."
|
|
111
|
+
onKeyDown: handleKeyDown
|
|
126
112
|
}
|
|
127
113
|
)
|
|
128
114
|
] });
|
|
@@ -148,10 +134,7 @@ const MermaidEditorContent = ({ initialContent, onSave, dismiss, colorScheme })
|
|
|
148
134
|
a.click();
|
|
149
135
|
URL.revokeObjectURL(url);
|
|
150
136
|
}, []);
|
|
151
|
-
const handleReset = useCallback(
|
|
152
|
-
() => setCode(initialContent),
|
|
153
|
-
[initialContent]
|
|
154
|
-
);
|
|
137
|
+
const handleReset = useCallback(() => setCode(initialContent), [initialContent]);
|
|
155
138
|
const handleSave = useCallback(() => {
|
|
156
139
|
onSave(code);
|
|
157
140
|
dismiss();
|
|
@@ -159,8 +142,8 @@ const MermaidEditorContent = ({ initialContent, onSave, dismiss, colorScheme })
|
|
|
159
142
|
const viewBtn = (mode, Icon) => /* @__PURE__ */ jsx(
|
|
160
143
|
"button",
|
|
161
144
|
{
|
|
162
|
-
type: "button",
|
|
163
145
|
className: `${editorViewItem}${activeView === mode ? ` ${editorViewItemActive}` : ""}`,
|
|
146
|
+
type: "button",
|
|
164
147
|
onClick: () => setActiveView(mode),
|
|
165
148
|
children: /* @__PURE__ */ jsx(Icon, { size: 14 })
|
|
166
149
|
}
|
|
@@ -176,8 +159,8 @@ const MermaidEditorContent = ({ initialContent, onSave, dismiss, colorScheme })
|
|
|
176
159
|
TEMPLATES.map((tpl) => /* @__PURE__ */ jsx(
|
|
177
160
|
"button",
|
|
178
161
|
{
|
|
179
|
-
type: "button",
|
|
180
162
|
className: editorTplBtn,
|
|
163
|
+
type: "button",
|
|
181
164
|
onClick: () => setCode(tpl.code),
|
|
182
165
|
children: tpl.label
|
|
183
166
|
},
|
|
@@ -194,44 +177,26 @@ const MermaidEditorContent = ({ initialContent, onSave, dismiss, colorScheme })
|
|
|
194
177
|
/* @__PURE__ */ jsx(
|
|
195
178
|
"button",
|
|
196
179
|
{
|
|
197
|
-
type: "button",
|
|
198
180
|
className: editorIconBtn,
|
|
199
|
-
onClick: handleCopy,
|
|
200
181
|
title: copied ? "Copied!" : "Copy code",
|
|
182
|
+
type: "button",
|
|
183
|
+
onClick: handleCopy,
|
|
201
184
|
children: /* @__PURE__ */ jsx(Copy, { size: 14 })
|
|
202
185
|
}
|
|
203
186
|
),
|
|
204
187
|
/* @__PURE__ */ jsx(
|
|
205
188
|
"button",
|
|
206
189
|
{
|
|
207
|
-
type: "button",
|
|
208
190
|
className: editorIconBtn,
|
|
209
|
-
onClick: handleDownload,
|
|
210
191
|
title: "Download SVG",
|
|
211
|
-
children: /* @__PURE__ */ jsx(Download, { size: 14 })
|
|
212
|
-
}
|
|
213
|
-
),
|
|
214
|
-
/* @__PURE__ */ jsx(
|
|
215
|
-
"button",
|
|
216
|
-
{
|
|
217
192
|
type: "button",
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
title: "Reset",
|
|
221
|
-
children: /* @__PURE__ */ jsx(RotateCcw, { size: 14 })
|
|
193
|
+
onClick: handleDownload,
|
|
194
|
+
children: /* @__PURE__ */ jsx(Download, { size: 14 })
|
|
222
195
|
}
|
|
223
196
|
),
|
|
197
|
+
/* @__PURE__ */ jsx("button", { className: editorIconBtn, title: "Reset", type: "button", onClick: handleReset, children: /* @__PURE__ */ jsx(RotateCcw, { size: 14 }) }),
|
|
224
198
|
/* @__PURE__ */ jsx("div", { className: editorSep }),
|
|
225
|
-
/* @__PURE__ */ jsx(
|
|
226
|
-
"button",
|
|
227
|
-
{
|
|
228
|
-
type: "button",
|
|
229
|
-
className: editorIconBtn,
|
|
230
|
-
onClick: dismiss,
|
|
231
|
-
title: "Close",
|
|
232
|
-
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
233
|
-
}
|
|
234
|
-
)
|
|
199
|
+
/* @__PURE__ */ jsx("button", { className: editorIconBtn, title: "Close", type: "button", onClick: dismiss, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
|
|
235
200
|
] })
|
|
236
201
|
] }),
|
|
237
202
|
/* @__PURE__ */ jsxs("div", { className: editorBody, children: [
|
|
@@ -247,58 +212,24 @@ const MermaidEditorContent = ({ initialContent, onSave, dismiss, colorScheme })
|
|
|
247
212
|
),
|
|
248
213
|
activeView !== "code" && /* @__PURE__ */ jsxs("div", { className: editorPreviewPane, children: [
|
|
249
214
|
/* @__PURE__ */ jsx("div", { className: editorPaneLabel, children: "Preview" }),
|
|
250
|
-
/* @__PURE__ */ jsx(
|
|
251
|
-
MermaidLivePreview,
|
|
252
|
-
{
|
|
253
|
-
code,
|
|
254
|
-
svgRef,
|
|
255
|
-
colorScheme
|
|
256
|
-
}
|
|
257
|
-
)
|
|
215
|
+
/* @__PURE__ */ jsx(MermaidLivePreview, { code, colorScheme, svgRef })
|
|
258
216
|
] })
|
|
259
217
|
] }),
|
|
260
218
|
/* @__PURE__ */ jsx("div", { className: editorFooter, children: /* @__PURE__ */ jsxs("div", { className: footerActions, children: [
|
|
261
|
-
/* @__PURE__ */ jsx(
|
|
262
|
-
|
|
263
|
-
{
|
|
264
|
-
type: "button",
|
|
265
|
-
className: footerBtnCancel,
|
|
266
|
-
onClick: dismiss,
|
|
267
|
-
children: "Cancel"
|
|
268
|
-
}
|
|
269
|
-
),
|
|
270
|
-
/* @__PURE__ */ jsx(
|
|
271
|
-
"button",
|
|
272
|
-
{
|
|
273
|
-
type: "button",
|
|
274
|
-
className: footerBtnSave,
|
|
275
|
-
onClick: handleSave,
|
|
276
|
-
children: "Save"
|
|
277
|
-
}
|
|
278
|
-
)
|
|
219
|
+
/* @__PURE__ */ jsx("button", { className: footerBtnCancel, type: "button", onClick: dismiss, children: "Cancel" }),
|
|
220
|
+
/* @__PURE__ */ jsx("button", { className: footerBtnSave, type: "button", onClick: handleSave, children: "Save" })
|
|
279
221
|
] }) })
|
|
280
222
|
] });
|
|
281
223
|
};
|
|
282
224
|
const ZoomControls = () => {
|
|
283
225
|
const { zoomIn, zoomOut, resetTransform } = useControls();
|
|
284
226
|
return /* @__PURE__ */ jsxs("div", { className: zoomControls, children: [
|
|
285
|
-
/* @__PURE__ */ jsx("button", { type: "button",
|
|
286
|
-
/* @__PURE__ */ jsx("button", { type: "button",
|
|
287
|
-
/* @__PURE__ */ jsx(
|
|
288
|
-
"button",
|
|
289
|
-
{
|
|
290
|
-
type: "button",
|
|
291
|
-
className: zoomBtn,
|
|
292
|
-
onClick: () => resetTransform(),
|
|
293
|
-
children: /* @__PURE__ */ jsx(Maximize2, { size: 14 })
|
|
294
|
-
}
|
|
295
|
-
)
|
|
227
|
+
/* @__PURE__ */ jsx("button", { className: zoomBtn, type: "button", onClick: () => zoomIn(), children: /* @__PURE__ */ jsx(ZoomIn, { size: 14 }) }),
|
|
228
|
+
/* @__PURE__ */ jsx("button", { className: zoomBtn, type: "button", onClick: () => zoomOut(), children: /* @__PURE__ */ jsx(ZoomOut, { size: 14 }) }),
|
|
229
|
+
/* @__PURE__ */ jsx("button", { className: zoomBtn, type: "button", onClick: () => resetTransform(), children: /* @__PURE__ */ jsx(Maximize2, { size: 14 }) })
|
|
296
230
|
] });
|
|
297
231
|
};
|
|
298
|
-
const MermaidEditRenderer = ({
|
|
299
|
-
content,
|
|
300
|
-
onContentChange
|
|
301
|
-
}) => {
|
|
232
|
+
const MermaidEditRenderer = ({ content, onContentChange }) => {
|
|
302
233
|
const colorScheme = useColorScheme();
|
|
303
234
|
const { loading, error, imgSrc, width, height } = useMermaidRender(content);
|
|
304
235
|
const { className: portalClassName } = usePortalTheme();
|
|
@@ -308,10 +239,10 @@ const MermaidEditRenderer = ({
|
|
|
308
239
|
content: ({ dismiss }) => /* @__PURE__ */ jsx(
|
|
309
240
|
MermaidEditorContent,
|
|
310
241
|
{
|
|
311
|
-
|
|
312
|
-
onSave: onContentChange,
|
|
242
|
+
colorScheme,
|
|
313
243
|
dismiss,
|
|
314
|
-
|
|
244
|
+
initialContent: content,
|
|
245
|
+
onSave: onContentChange
|
|
315
246
|
}
|
|
316
247
|
),
|
|
317
248
|
className: editorPopup,
|
|
@@ -329,7 +260,7 @@ const MermaidEditRenderer = ({
|
|
|
329
260
|
}
|
|
330
261
|
return /* @__PURE__ */ jsxs("div", { className: mermaidContainer, children: [
|
|
331
262
|
onContentChange && /* @__PURE__ */ jsx("span", { className: mermaidEditHint, onClick: handleClick, children: "Edit" }),
|
|
332
|
-
/* @__PURE__ */ jsxs(TransformWrapper, { initialScale: 1, minScale: 0.5,
|
|
263
|
+
/* @__PURE__ */ jsxs(TransformWrapper, { initialScale: 1, maxScale: 4, minScale: 0.5, children: [
|
|
333
264
|
/* @__PURE__ */ jsx(ZoomControls, {}),
|
|
334
265
|
/* @__PURE__ */ jsx(
|
|
335
266
|
TransformComponent,
|
|
@@ -340,15 +271,7 @@ const MermaidEditRenderer = ({
|
|
|
340
271
|
display: "flex",
|
|
341
272
|
justifyContent: "center"
|
|
342
273
|
},
|
|
343
|
-
children: /* @__PURE__ */ jsx(
|
|
344
|
-
"img",
|
|
345
|
-
{
|
|
346
|
-
src: imgSrc,
|
|
347
|
-
alt: "Mermaid diagram",
|
|
348
|
-
width,
|
|
349
|
-
height
|
|
350
|
-
}
|
|
351
|
-
)
|
|
274
|
+
children: /* @__PURE__ */ jsx("img", { alt: "Mermaid diagram", height, src: imgSrc, width })
|
|
352
275
|
}
|
|
353
276
|
)
|
|
354
277
|
] })
|
package/dist/mermaid-theme.d.ts
CHANGED
|
@@ -13,17 +13,17 @@ interface MermaidThemeConfig {
|
|
|
13
13
|
themeVariables: Record<string, string>;
|
|
14
14
|
}
|
|
15
15
|
export interface ThemeTokens {
|
|
16
|
+
arrow: string;
|
|
16
17
|
bg: string;
|
|
17
18
|
fg: string;
|
|
19
|
+
groupHeader: string;
|
|
20
|
+
innerStroke: string;
|
|
18
21
|
line: string;
|
|
19
|
-
arrow: string;
|
|
20
22
|
nodeFill: string;
|
|
21
23
|
nodeStroke: string;
|
|
22
|
-
groupHeader: string;
|
|
23
|
-
innerStroke: string;
|
|
24
|
-
textSec: string;
|
|
25
|
-
textMuted: string;
|
|
26
24
|
textFaint: string;
|
|
25
|
+
textMuted: string;
|
|
26
|
+
textSec: string;
|
|
27
27
|
}
|
|
28
28
|
export declare function deriveTokens(bg: string, fg: string): ThemeTokens;
|
|
29
29
|
export declare const lightTheme: MermaidThemeConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid-theme.d.ts","sourceRoot":"","sources":["../src/mermaid-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mermaid-theme.d.ts","sourceRoot":"","sources":["../src/mermaid-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAoCD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAchE;AAqJD,eAAO,MAAM,UAAU,oBAAmC,CAAC;AAG3D,eAAO,MAAM,SAAS,oBAAmC,CAAC;AAE1D,eAAO,MAAM,WAAW,aAAqC,CAAC;AAC9D,eAAO,MAAM,UAAU,aAAqC,CAAC"}
|
package/dist/static.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-renderer-mermaid",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.0.65",
|
|
3
|
+
"version": "0.0.67",
|
|
5
4
|
"description": "Mermaid diagram renderer",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Innei/haklex.git",
|
|
8
|
+
"directory": "packages/rich-renderer-mermaid"
|
|
9
|
+
},
|
|
6
10
|
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
14
|
"import": "./dist/index.mjs",
|
|
@@ -23,17 +28,13 @@
|
|
|
23
28
|
"files": [
|
|
24
29
|
"dist"
|
|
25
30
|
],
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"react": ">=19",
|
|
28
|
-
"react-dom": ">=19"
|
|
29
|
-
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"lucide-react": "^0.577.0",
|
|
32
33
|
"mermaid": "^11.12.3",
|
|
33
34
|
"react-zoom-pan-pinch": "^3.7.0",
|
|
34
|
-
"@haklex/rich-
|
|
35
|
-
"@haklex/rich-editor": "0.0.
|
|
36
|
-
"@haklex/rich-
|
|
35
|
+
"@haklex/rich-editor": "0.0.67",
|
|
36
|
+
"@haklex/rich-editor-ui": "0.0.67",
|
|
37
|
+
"@haklex/rich-style-token": "0.0.67"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/react": "^19.2.14",
|
|
@@ -46,6 +47,10 @@
|
|
|
46
47
|
"vite": "^7.3.1",
|
|
47
48
|
"vite-plugin-dts": "^4.5.4"
|
|
48
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react": ">=19",
|
|
52
|
+
"react-dom": ">=19"
|
|
53
|
+
},
|
|
49
54
|
"publishConfig": {
|
|
50
55
|
"access": "public"
|
|
51
56
|
},
|