@ootc/markdown 0.0.9 → 0.2.0
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 +96 -4
- package/dist/CodeBlock-BquZ4WRk.cjs +2 -0
- package/dist/CodeBlock-DSwq2gw5.js +74 -0
- package/dist/MarkdownPreview-CMvzqhTd.js +7592 -0
- package/dist/MarkdownPreview-DfDx-wep.cjs +29 -0
- package/dist/code.cjs +1 -1
- package/dist/code.css +1 -0
- package/dist/code.d.ts +3 -1
- package/dist/code.js +3 -2
- package/dist/components/code-block/CodeBlock.d.ts +7 -1
- package/dist/components/markdown/MarkdownPreview.d.ts +8 -2
- package/dist/components/markdown-editor/MarkdownEditor.d.ts +4 -1
- package/dist/css/CodeBlock.css +1 -0
- package/dist/css/MarkdownPreview.css +1 -0
- package/dist/css/editor.css +1 -0
- package/dist/css/plugin-mermaid.css +1 -0
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +3 -0
- package/dist/editor.d.ts +3 -1
- package/dist/editor.js +28 -25
- package/dist/index-BJZhyxD_.cjs +9 -0
- package/dist/index-DWVMYNE4.js +800 -0
- package/dist/index-HmBYTPyZ.js +1179 -0
- package/dist/index-jsnhzgIQ.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/jsx-runtime-DXgJBoQh.js +264 -0
- package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
- package/dist/plugin-highlight.cjs +1 -0
- package/dist/plugin-highlight.js +20 -0
- package/dist/plugin-katex.cjs +1 -0
- package/dist/plugin-katex.js +12 -0
- package/dist/plugin-mermaid.cjs +1 -0
- package/dist/plugin-mermaid.css +1 -0
- package/dist/plugin-mermaid.js +266 -0
- package/dist/plugins/types.d.ts +38 -0
- package/dist/preview.cjs +1 -1
- package/dist/preview.css +2 -0
- package/dist/preview.d.ts +3 -1
- package/dist/preview.js +4 -3
- package/dist/style.css +4 -1
- package/package.json +76 -21
- package/dist/CodeBlock-BYxQBfWO.js +0 -40827
- package/dist/CodeBlock-CJ6j8Wkl.cjs +0 -3934
- package/dist/MarkdownPreview-DcWMewhy.cjs +0 -295
- package/dist/MarkdownPreview-lqJAnu4B.js +0 -20424
- package/dist/_baseUniq-BfVwFITD.js +0 -477
- package/dist/_baseUniq-D-3LoSZp.cjs +0 -1
- package/dist/arc-CyzqoBTV.js +0 -83
- package/dist/arc-DrpGAtaq.cjs +0 -1
- package/dist/architecture-U656AL7Q-C8Bj_Ouy.cjs +0 -1
- package/dist/architecture-U656AL7Q-DTKdLHLe.js +0 -5
- package/dist/architectureDiagram-VXUJARFQ-B8EG6DIA.js +0 -4662
- package/dist/architectureDiagram-VXUJARFQ-DJ1ub7X0.cjs +0 -36
- package/dist/blockDiagram-VD42YOAC-CKNTgeZ8.js +0 -2256
- package/dist/blockDiagram-VD42YOAC-G-1iOwuq.cjs +0 -122
- package/dist/c4Diagram-YG6GDRKO-BJ1Ka924.cjs +0 -10
- package/dist/c4Diagram-YG6GDRKO-Bokkq4pO.js +0 -1580
- package/dist/channel-C4noxv-h.js +0 -5
- package/dist/channel-DvIIEA3u.cjs +0 -1
- package/dist/chunk-4BX2VUAB-B5M-5e_l.cjs +0 -1
- package/dist/chunk-4BX2VUAB-ByoAwp1j.js +0 -8
- package/dist/chunk-55IACEB6-BpG-_f0h.cjs +0 -1
- package/dist/chunk-55IACEB6-DRnx6y7F.js +0 -8
- package/dist/chunk-B4BG7PRW-0toVGVN-.js +0 -1375
- package/dist/chunk-B4BG7PRW-evUM3dip.cjs +0 -165
- package/dist/chunk-DI55MBZ5-CyInK_-M.js +0 -1370
- package/dist/chunk-DI55MBZ5-DKs4p2E0.cjs +0 -220
- package/dist/chunk-FMBD7UC4-BwUpmqhP.js +0 -19
- package/dist/chunk-FMBD7UC4-cpOVGF_2.cjs +0 -15
- package/dist/chunk-QN33PNHL-C7XXEbKU.js +0 -19
- package/dist/chunk-QN33PNHL-CEdYSNej.cjs +0 -1
- package/dist/chunk-QZHKN3VN-hppYv0Iu.cjs +0 -1
- package/dist/chunk-QZHKN3VN-qqHBDA_I.js +0 -15
- package/dist/chunk-TZMSLE5B-B9QqMSFM.js +0 -64
- package/dist/chunk-TZMSLE5B-Bklau4qu.cjs +0 -1
- package/dist/classDiagram-2ON5EDUG-CYKX_y1c.js +0 -16
- package/dist/classDiagram-2ON5EDUG-TgiEUsUn.cjs +0 -1
- package/dist/classDiagram-v2-WZHVMYZB-CYKX_y1c.js +0 -16
- package/dist/classDiagram-v2-WZHVMYZB-TgiEUsUn.cjs +0 -1
- package/dist/clone-CE64n2kf.js +0 -8
- package/dist/clone-jaW02xOC.cjs +0 -1
- package/dist/cose-bilkent-S5V4N54A-B_XAF1ZT.js +0 -2609
- package/dist/cose-bilkent-S5V4N54A-DSZx3rxe.cjs +0 -1
- package/dist/cytoscape.esm-CNUX3VTg.cjs +0 -321
- package/dist/cytoscape.esm-Cvf3sx9F.js +0 -18704
- package/dist/dagre-6UL2VRFP-Biy3Qm3K.js +0 -443
- package/dist/dagre-6UL2VRFP-C8MiPDEQ.cjs +0 -4
- package/dist/defaultLocale-D7EN2tov.js +0 -171
- package/dist/defaultLocale-DIVzfLaQ.cjs +0 -1
- package/dist/diagram-PSM6KHXK-B1y0Lt7Z.cjs +0 -24
- package/dist/diagram-PSM6KHXK-CIfbagcO.js +0 -531
- package/dist/diagram-QEK2KX5R-BJNTbg0b.cjs +0 -43
- package/dist/diagram-QEK2KX5R-BQz0yqem.js +0 -217
- package/dist/diagram-S2PKOQOG-BGsratMZ.js +0 -142
- package/dist/diagram-S2PKOQOG-BK_tj5Pz.cjs +0 -24
- package/dist/erDiagram-Q2GNP2WA-CJbuwIgY.cjs +0 -60
- package/dist/erDiagram-Q2GNP2WA-CurkAz8N.js +0 -841
- package/dist/flowDiagram-NV44I4VS-DAMyok8X.js +0 -1620
- package/dist/flowDiagram-NV44I4VS-DnmHUmh1.cjs +0 -162
- package/dist/ganttDiagram-JELNMOA3-DxXvW49B.cjs +0 -267
- package/dist/ganttDiagram-JELNMOA3-oVlSmAjl.js +0 -2671
- package/dist/gitGraph-F6HP7TQM-DUSMetNW.js +0 -5
- package/dist/gitGraph-F6HP7TQM-DveZcMpA.cjs +0 -1
- package/dist/gitGraphDiagram-NY62KEGX-CFdtd4Gb.js +0 -699
- package/dist/gitGraphDiagram-NY62KEGX-CspGhCdP.cjs +0 -65
- package/dist/graph-Bza-HyX6.js +0 -381
- package/dist/graph-CE_Z8OkL.cjs +0 -1
- package/dist/info-NVLQJR56-3ayytpiF.js +0 -5
- package/dist/info-NVLQJR56-D-IKjb_E.cjs +0 -1
- package/dist/infoDiagram-WHAUD3N6--LngDYSE.cjs +0 -2
- package/dist/infoDiagram-WHAUD3N6-BtO0qT6g.js +0 -24
- package/dist/init-CHZsXQcr.cjs +0 -1
- package/dist/init-DjUOC4st.js +0 -16
- package/dist/journeyDiagram-XKPGCS4Q-DCvKw6yJ.cjs +0 -139
- package/dist/journeyDiagram-XKPGCS4Q-Unrh_bjo.js +0 -834
- package/dist/kanban-definition-3W4ZIXB7-CRa6bR24.cjs +0 -89
- package/dist/kanban-definition-3W4ZIXB7-Vpm6gG9R.js +0 -719
- package/dist/layout-BJzrWbaG.cjs +0 -1
- package/dist/layout-D6Pf3Nys.js +0 -1441
- package/dist/linear-C0E_OSxf.js +0 -259
- package/dist/linear-TSwNFrBs.cjs +0 -1
- package/dist/mermaid-parser.core-B9wV8XMP.js +0 -14177
- package/dist/mermaid-parser.core-Ba9EAFlD.cjs +0 -128
- package/dist/mermaid.core-B1lFjYb9.js +0 -15269
- package/dist/mermaid.core-C8vi9eg6.cjs +0 -249
- package/dist/min-BC6TlZcq.cjs +0 -1
- package/dist/min-DT5Wu4V1.js +0 -38
- package/dist/mindmap-definition-VGOIOE7T-COA86V4i.js +0 -784
- package/dist/mindmap-definition-VGOIOE7T-D9oMyZ2M.cjs +0 -68
- package/dist/ordinal-B6-f3MAq.js +0 -61
- package/dist/ordinal-CagbB1m8.cjs +0 -1
- package/dist/packet-BFZMPI3H-BZI0_bZt.js +0 -5
- package/dist/packet-BFZMPI3H-D4pnK0Ol.cjs +0 -1
- package/dist/pie-7BOR55EZ-DS6huTOL.cjs +0 -1
- package/dist/pie-7BOR55EZ-DgzTX76e.js +0 -5
- package/dist/pieDiagram-ADFJNKIX-CYW3Diea.js +0 -161
- package/dist/pieDiagram-ADFJNKIX-CxPAjreR.cjs +0 -30
- package/dist/quadrantDiagram-AYHSOK5B-BT94kssD.js +0 -1022
- package/dist/quadrantDiagram-AYHSOK5B-ehLphI_D.cjs +0 -7
- package/dist/radar-NHE76QYJ-CKcVnf1I.cjs +0 -1
- package/dist/radar-NHE76QYJ-D8cZitaQ.js +0 -5
- package/dist/requirementDiagram-UZGBJVZJ-B4UYGl6e.js +0 -850
- package/dist/requirementDiagram-UZGBJVZJ-BDLj6-Do.cjs +0 -64
- package/dist/sankeyDiagram-TZEHDZUN-CAWsWdn8.js +0 -810
- package/dist/sankeyDiagram-TZEHDZUN-DUb360Ep.cjs +0 -10
- package/dist/sequenceDiagram-WL72ISMW-Bb4Tkhf2.cjs +0 -145
- package/dist/sequenceDiagram-WL72ISMW-DsmW0gAI.js +0 -2511
- package/dist/stateDiagram-FKZM4ZOC-Da-8DKdP.js +0 -263
- package/dist/stateDiagram-FKZM4ZOC-jOvG1Jmy.cjs +0 -1
- package/dist/stateDiagram-v2-4FDKWEC3-GMZ8nH4e.js +0 -16
- package/dist/stateDiagram-v2-4FDKWEC3-mWKIMY-b.cjs +0 -1
- package/dist/timeline-definition-IT6M3QCI-BdnDlTsf.cjs +0 -61
- package/dist/timeline-definition-IT6M3QCI-CvJDgHLW.js +0 -795
- package/dist/treemap-KMMF4GRG-BVy_kMp3.js +0 -5
- package/dist/treemap-KMMF4GRG-BsA9nu7r.cjs +0 -1
- package/dist/xychartDiagram-PRI3JC2R-CYXNZ7B0.cjs +0 -7
- package/dist/xychartDiagram-PRI3JC2R-wG1xpI1S.js +0 -1340
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { useRef as R, useState as M, useId as ne, useMemo as $, useEffect as Y, useCallback as _, createElement as ie } from "react";
|
|
2
|
+
import { j as N } from "./jsx-runtime-DXgJBoQh.js";
|
|
3
|
+
const oe = "_mermaidContainer_1x453_1", ae = "_mermaidCanPan_1x453_9", se = "_mermaidPanning_1x453_17", ce = "_mermaidViewport_1x453_22", de = "_mermaidDiagram_1x453_30", le = "_mermaidError_1x453_41", ue = "_mermaidErrorDetails_1x453_51", C = {
|
|
4
|
+
mermaidContainer: oe,
|
|
5
|
+
mermaidCanPan: ae,
|
|
6
|
+
mermaidPanning: se,
|
|
7
|
+
mermaidViewport: ce,
|
|
8
|
+
mermaidDiagram: de,
|
|
9
|
+
mermaidError: le,
|
|
10
|
+
mermaidErrorDetails: ue
|
|
11
|
+
}, me = "markdown-mermaid";
|
|
12
|
+
let S = null;
|
|
13
|
+
function fe() {
|
|
14
|
+
return S || (S = import("mermaid")), S;
|
|
15
|
+
}
|
|
16
|
+
function X(t, i, n) {
|
|
17
|
+
if (typeof window > "u" || typeof document > "u")
|
|
18
|
+
return i;
|
|
19
|
+
const l = n ?? document.documentElement;
|
|
20
|
+
return l && getComputedStyle(l).getPropertyValue(t).trim() || i;
|
|
21
|
+
}
|
|
22
|
+
function W(t = "system") {
|
|
23
|
+
if (t === "light" || t === "dark")
|
|
24
|
+
return t;
|
|
25
|
+
if (typeof window > "u" || typeof document > "u" || !document.documentElement)
|
|
26
|
+
return "light";
|
|
27
|
+
const n = document.documentElement.getAttribute("data-theme");
|
|
28
|
+
return n === "dark" ? "dark" : n === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
29
|
+
}
|
|
30
|
+
function ge(t, i) {
|
|
31
|
+
const n = t === "dark" ? "#d4d4d4" : "#222222", l = t === "dark" ? "#569cd6" : "#1f6feb", u = t === "dark" ? "#1e1e1e" : "#ffffff", g = t === "dark" ? "#2d2d30" : "#f6f8fa", h = X("--md-text", n, i), a = X("--md-heading", l, i), k = X("--preview-bg", u, i), c = X("--md-pre-bg", g, i), P = X("--md-code-bg", c, i), m = a;
|
|
32
|
+
return {
|
|
33
|
+
startOnLoad: !1,
|
|
34
|
+
theme: "base",
|
|
35
|
+
themeVariables: {
|
|
36
|
+
background: k,
|
|
37
|
+
fontFamily: "inherit",
|
|
38
|
+
primaryColor: c,
|
|
39
|
+
primaryTextColor: h,
|
|
40
|
+
primaryBorderColor: m,
|
|
41
|
+
secondaryColor: P,
|
|
42
|
+
secondaryTextColor: h,
|
|
43
|
+
tertiaryColor: c,
|
|
44
|
+
lineColor: m,
|
|
45
|
+
arrowheadColor: m,
|
|
46
|
+
textColor: h,
|
|
47
|
+
edgeLabelBackground: c,
|
|
48
|
+
clusterBkg: c,
|
|
49
|
+
clusterBorder: m,
|
|
50
|
+
labelBoxBorderColor: m,
|
|
51
|
+
nodeBorder: m,
|
|
52
|
+
actorBorder: m,
|
|
53
|
+
actorLineColor: m,
|
|
54
|
+
noteBorderColor: m
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function he(t = "system") {
|
|
59
|
+
const [i, n] = M(() => W(t));
|
|
60
|
+
return Y(() => {
|
|
61
|
+
if (t === "light" || t === "dark") {
|
|
62
|
+
n(t);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof window > "u" || typeof document > "u" || !document.documentElement)
|
|
66
|
+
return;
|
|
67
|
+
const l = () => n(W(t));
|
|
68
|
+
l();
|
|
69
|
+
const u = window.matchMedia("(prefers-color-scheme: dark)"), g = () => l();
|
|
70
|
+
try {
|
|
71
|
+
u.addEventListener("change", g);
|
|
72
|
+
} catch {
|
|
73
|
+
u.addListener(g);
|
|
74
|
+
}
|
|
75
|
+
const h = new MutationObserver((a) => {
|
|
76
|
+
for (const k of a)
|
|
77
|
+
if (k.type === "attributes") {
|
|
78
|
+
l();
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return h.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-theme"] }), () => {
|
|
83
|
+
try {
|
|
84
|
+
u.removeEventListener("change", g);
|
|
85
|
+
} catch {
|
|
86
|
+
u.removeListener(g);
|
|
87
|
+
}
|
|
88
|
+
h.disconnect();
|
|
89
|
+
};
|
|
90
|
+
}, [t]), i;
|
|
91
|
+
}
|
|
92
|
+
function pe({ code: t, theme: i }) {
|
|
93
|
+
const n = R(null), l = R(null), u = R(null), [g, h] = M(null), [a, k] = M(1), [c, P] = M(null), [m, v] = M({ x: 0, y: 0 }), [A, j] = M(!1), H = ne(), T = $(() => `${me}-${H.replace(/[:]/g, "-")}`, [H]), V = he(i), E = R({
|
|
94
|
+
pointerId: null,
|
|
95
|
+
lastX: 0,
|
|
96
|
+
lastY: 0,
|
|
97
|
+
active: !1
|
|
98
|
+
});
|
|
99
|
+
Y(() => {
|
|
100
|
+
k(1), v({ x: 0, y: 0 });
|
|
101
|
+
}, [t]), Y(() => {
|
|
102
|
+
let e = !1;
|
|
103
|
+
h(null);
|
|
104
|
+
const r = n.current;
|
|
105
|
+
return r && (r.innerHTML = ""), u.current = null, P(null), (async () => {
|
|
106
|
+
try {
|
|
107
|
+
const { default: o } = await fe();
|
|
108
|
+
if (e) return;
|
|
109
|
+
o.initialize(ge(V, n.current));
|
|
110
|
+
const { svg: p, bindFunctions: f } = await o.render(T, t.trim());
|
|
111
|
+
if (e) return;
|
|
112
|
+
const D = n.current;
|
|
113
|
+
if (!D) return;
|
|
114
|
+
D.innerHTML = p, f && f(D);
|
|
115
|
+
const s = D.querySelector("svg");
|
|
116
|
+
if (s) {
|
|
117
|
+
s.style.maxWidth = "none", u.current = s;
|
|
118
|
+
const B = s.getAttribute("width") || "", L = s.getAttribute("height") || "", I = Number.parseFloat(B), F = Number.parseFloat(L), ee = B.includes("%"), te = L.includes("%");
|
|
119
|
+
let y = !Number.isNaN(I) && Number.isFinite(I) && I > 0 && !ee ? I : 0, x = !Number.isNaN(F) && Number.isFinite(F) && F > 0 && !te ? F : 0;
|
|
120
|
+
if (!y || !x) {
|
|
121
|
+
const w = s.getBoundingClientRect();
|
|
122
|
+
y = y || w.width, x = x || w.height;
|
|
123
|
+
}
|
|
124
|
+
if ((!y || !x) && s.viewBox) {
|
|
125
|
+
const { width: w, height: re } = s.viewBox.baseVal;
|
|
126
|
+
y = y || w, x = x || re;
|
|
127
|
+
}
|
|
128
|
+
e || (y > 0 && x > 0 ? P((w) => w && w.width === y && w.height === x ? w : { width: y, height: x }) : P(null));
|
|
129
|
+
} else e || P(null);
|
|
130
|
+
} catch (o) {
|
|
131
|
+
if (e) return;
|
|
132
|
+
const p = o instanceof Error ? o.message : String(o);
|
|
133
|
+
h(p);
|
|
134
|
+
const f = n.current;
|
|
135
|
+
f && (f.innerHTML = ""), u.current = null, P(null);
|
|
136
|
+
}
|
|
137
|
+
})(), () => {
|
|
138
|
+
e = !0;
|
|
139
|
+
};
|
|
140
|
+
}, [t, T, V]);
|
|
141
|
+
const b = _((e) => {
|
|
142
|
+
const { pointerId: r, active: d } = E.current;
|
|
143
|
+
if (d) {
|
|
144
|
+
if (r !== null) {
|
|
145
|
+
const o = e ?? l.current;
|
|
146
|
+
if (o && typeof o.releasePointerCapture == "function")
|
|
147
|
+
try {
|
|
148
|
+
o.releasePointerCapture(r);
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
E.current = { pointerId: null, lastX: 0, lastY: 0, active: !1 }, j(!1);
|
|
153
|
+
}
|
|
154
|
+
}, []), q = _((e) => {
|
|
155
|
+
const r = l.current;
|
|
156
|
+
if (r) {
|
|
157
|
+
if (e.ctrlKey || e.metaKey) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
const d = r.getBoundingClientRect(), o = e.clientX - d.left, p = e.clientY - d.top;
|
|
160
|
+
k((f) => {
|
|
161
|
+
const D = f * (e.deltaY > 0 ? 0.9 : 1.1), s = Math.min(Math.max(D, 0.25), 4);
|
|
162
|
+
return !Number.isFinite(s) || s === f ? f : (v((B) => {
|
|
163
|
+
if (s <= 1.0001)
|
|
164
|
+
return { x: 0, y: 0 };
|
|
165
|
+
const L = (o - B.x) / f, I = (p - B.y) / f;
|
|
166
|
+
return {
|
|
167
|
+
x: o - L * s,
|
|
168
|
+
y: p - I * s
|
|
169
|
+
};
|
|
170
|
+
}), s);
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
a <= 1 || (e.preventDefault(), v((d) => ({
|
|
175
|
+
x: d.x - e.deltaX,
|
|
176
|
+
y: d.y - e.deltaY
|
|
177
|
+
})));
|
|
178
|
+
}
|
|
179
|
+
}, [a]), z = _((e) => {
|
|
180
|
+
if (e.button !== 0 || a <= 1)
|
|
181
|
+
return;
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
const r = e.currentTarget;
|
|
184
|
+
if (E.current = {
|
|
185
|
+
pointerId: e.pointerId,
|
|
186
|
+
lastX: e.clientX,
|
|
187
|
+
lastY: e.clientY,
|
|
188
|
+
active: !0
|
|
189
|
+
}, j(!0), typeof r.setPointerCapture == "function")
|
|
190
|
+
try {
|
|
191
|
+
r.setPointerCapture(e.pointerId);
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}, [a]), O = _((e) => {
|
|
195
|
+
const r = E.current;
|
|
196
|
+
if (!r.active || r.pointerId !== e.pointerId)
|
|
197
|
+
return;
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
const d = e.clientX - r.lastX, o = e.clientY - r.lastY;
|
|
200
|
+
!d && !o || (r.lastX = e.clientX, r.lastY = e.clientY, v((p) => ({
|
|
201
|
+
x: p.x + d,
|
|
202
|
+
y: p.y + o
|
|
203
|
+
})));
|
|
204
|
+
}, []), K = _((e) => {
|
|
205
|
+
E.current.pointerId === e.pointerId && b(e.currentTarget);
|
|
206
|
+
}, [b]), U = _((e) => {
|
|
207
|
+
E.current.pointerId === e.pointerId && b(e.currentTarget);
|
|
208
|
+
}, [b]), G = _((e) => {
|
|
209
|
+
E.current.active && b(e.currentTarget);
|
|
210
|
+
}, [b]);
|
|
211
|
+
Y(() => () => {
|
|
212
|
+
b();
|
|
213
|
+
}, [b]), Y(() => {
|
|
214
|
+
const e = u.current;
|
|
215
|
+
if (!e || !c)
|
|
216
|
+
return;
|
|
217
|
+
const r = c.width * a, d = c.height * a;
|
|
218
|
+
e.style.width = `${r}px`, e.style.height = `${d}px`;
|
|
219
|
+
}, [c, a]);
|
|
220
|
+
const J = $(() => {
|
|
221
|
+
if (c)
|
|
222
|
+
return {
|
|
223
|
+
width: `${c.width * a}px`,
|
|
224
|
+
height: `${c.height * a}px`
|
|
225
|
+
};
|
|
226
|
+
}, [c, a]), Q = a > 1, Z = [
|
|
227
|
+
C.mermaidContainer,
|
|
228
|
+
Q ? C.mermaidCanPan : "",
|
|
229
|
+
A ? C.mermaidPanning : ""
|
|
230
|
+
].filter(Boolean).join(" ");
|
|
231
|
+
return g ? /* @__PURE__ */ N.jsx("div", { className: C.mermaidContainer, children: /* @__PURE__ */ N.jsx("div", { className: C.mermaidError, children: /* @__PURE__ */ N.jsx("div", { className: C.mermaidErrorDetails, children: g }) }) }) : /* @__PURE__ */ N.jsx("div", { className: Z, onWheel: q, children: /* @__PURE__ */ N.jsx(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
ref: l,
|
|
235
|
+
className: C.mermaidViewport,
|
|
236
|
+
style: J,
|
|
237
|
+
onPointerDown: z,
|
|
238
|
+
onPointerMove: O,
|
|
239
|
+
onPointerUp: K,
|
|
240
|
+
onPointerCancel: U,
|
|
241
|
+
onPointerLeave: G,
|
|
242
|
+
children: /* @__PURE__ */ N.jsx(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
ref: n,
|
|
246
|
+
className: C.mermaidDiagram,
|
|
247
|
+
role: "img",
|
|
248
|
+
"aria-label": "Mermaid diagram",
|
|
249
|
+
style: {
|
|
250
|
+
transform: `translate(${m.x}px, ${m.y}px)`,
|
|
251
|
+
transformOrigin: "0 0"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
) });
|
|
257
|
+
}
|
|
258
|
+
const we = {
|
|
259
|
+
name: "mermaid",
|
|
260
|
+
renderFence: ({ code: t, language: i, theme: n }) => i !== "mermaid" ? null : ie(pe, { code: t, theme: n })
|
|
261
|
+
};
|
|
262
|
+
export {
|
|
263
|
+
pe as MermaidDiagram,
|
|
264
|
+
we as default,
|
|
265
|
+
we as mermaidPlugin
|
|
266
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Options as ReactMarkdownOptions } from 'react-markdown';
|
|
3
|
+
import type { MarkdownThemeMode } from '../theme-mode';
|
|
4
|
+
type PluginList = NonNullable<ReactMarkdownOptions['remarkPlugins']>;
|
|
5
|
+
export interface FenceContext {
|
|
6
|
+
/** Fence body, with the trailing newline already stripped. */
|
|
7
|
+
code: string;
|
|
8
|
+
/** Language flag on the fence, e.g. `mermaid` in ```mermaid. */
|
|
9
|
+
language: string;
|
|
10
|
+
theme: MarkdownThemeMode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Opt-in extension point for the heavy dependencies (Mermaid, syntax highlighting
|
|
14
|
+
* grammars, KaTeX). The base package references none of them; each lives behind its
|
|
15
|
+
* own entrypoint so a consumer's bundler can prove it unreachable when unused.
|
|
16
|
+
*
|
|
17
|
+
* Plugins are consulted in array order.
|
|
18
|
+
*/
|
|
19
|
+
export interface MarkdownPlugin {
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Claim a fenced code block and render it. Return `null` to decline, in which
|
|
23
|
+
* case the next plugin is tried and the fence ultimately falls back to a plain
|
|
24
|
+
* code block.
|
|
25
|
+
*/
|
|
26
|
+
renderFence?: (context: FenceContext) => ReactNode | null;
|
|
27
|
+
/**
|
|
28
|
+
* Turn a code block into highlighted HTML. Return `null` to decline, in which
|
|
29
|
+
* case the code renders unhighlighted. The first plugin to return a non-null
|
|
30
|
+
* result wins.
|
|
31
|
+
*/
|
|
32
|
+
highlight?: (code: string, language: string) => Promise<string | null>;
|
|
33
|
+
/** remark plugins to add to the markdown pipeline. */
|
|
34
|
+
remarkPlugins?: PluginList;
|
|
35
|
+
/** rehype plugins to add to the markdown pipeline. */
|
|
36
|
+
rehypePlugins?: PluginList;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
package/dist/preview.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./CodeBlock-BquZ4WRk.cjs");const e=require("./MarkdownPreview-DfDx-wep.cjs");exports.MarkdownPreview=e.MarkdownPreview;exports.default=e.MarkdownPreview;
|
package/dist/preview.css
ADDED
package/dist/preview.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './theme.css';
|
|
2
|
-
|
|
2
|
+
import MarkdownPreview from './components/markdown/MarkdownPreview';
|
|
3
|
+
export { MarkdownPreview };
|
|
3
4
|
export type { MarkdownPreviewProps } from './components/markdown/MarkdownPreview';
|
|
4
5
|
export type { MarkdownThemeMode } from './theme-mode';
|
|
6
|
+
export default MarkdownPreview;
|
package/dist/preview.js
CHANGED