@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.
Files changed (160) hide show
  1. package/README.md +96 -4
  2. package/dist/CodeBlock-BquZ4WRk.cjs +2 -0
  3. package/dist/CodeBlock-DSwq2gw5.js +74 -0
  4. package/dist/MarkdownPreview-CMvzqhTd.js +7592 -0
  5. package/dist/MarkdownPreview-DfDx-wep.cjs +29 -0
  6. package/dist/code.cjs +1 -1
  7. package/dist/code.css +1 -0
  8. package/dist/code.d.ts +3 -1
  9. package/dist/code.js +3 -2
  10. package/dist/components/code-block/CodeBlock.d.ts +7 -1
  11. package/dist/components/markdown/MarkdownPreview.d.ts +8 -2
  12. package/dist/components/markdown-editor/MarkdownEditor.d.ts +4 -1
  13. package/dist/css/CodeBlock.css +1 -0
  14. package/dist/css/MarkdownPreview.css +1 -0
  15. package/dist/css/editor.css +1 -0
  16. package/dist/css/plugin-mermaid.css +1 -0
  17. package/dist/editor.cjs +1 -1
  18. package/dist/editor.css +3 -0
  19. package/dist/editor.d.ts +3 -1
  20. package/dist/editor.js +28 -25
  21. package/dist/index-BJZhyxD_.cjs +9 -0
  22. package/dist/index-DWVMYNE4.js +800 -0
  23. package/dist/index-HmBYTPyZ.js +1179 -0
  24. package/dist/index-jsnhzgIQ.cjs +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.css +1 -0
  27. package/dist/index.d.ts +3 -1
  28. package/dist/index.js +3 -2
  29. package/dist/jsx-runtime-DXgJBoQh.js +264 -0
  30. package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
  31. package/dist/plugin-highlight.cjs +1 -0
  32. package/dist/plugin-highlight.js +20 -0
  33. package/dist/plugin-katex.cjs +1 -0
  34. package/dist/plugin-katex.js +12 -0
  35. package/dist/plugin-mermaid.cjs +1 -0
  36. package/dist/plugin-mermaid.css +1 -0
  37. package/dist/plugin-mermaid.js +266 -0
  38. package/dist/plugins/types.d.ts +38 -0
  39. package/dist/preview.cjs +1 -1
  40. package/dist/preview.css +2 -0
  41. package/dist/preview.d.ts +3 -1
  42. package/dist/preview.js +4 -3
  43. package/dist/style.css +4 -1
  44. package/package.json +76 -21
  45. package/dist/CodeBlock-BYxQBfWO.js +0 -40827
  46. package/dist/CodeBlock-CJ6j8Wkl.cjs +0 -3934
  47. package/dist/MarkdownPreview-DcWMewhy.cjs +0 -295
  48. package/dist/MarkdownPreview-lqJAnu4B.js +0 -20424
  49. package/dist/_baseUniq-BfVwFITD.js +0 -477
  50. package/dist/_baseUniq-D-3LoSZp.cjs +0 -1
  51. package/dist/arc-CyzqoBTV.js +0 -83
  52. package/dist/arc-DrpGAtaq.cjs +0 -1
  53. package/dist/architecture-U656AL7Q-C8Bj_Ouy.cjs +0 -1
  54. package/dist/architecture-U656AL7Q-DTKdLHLe.js +0 -5
  55. package/dist/architectureDiagram-VXUJARFQ-B8EG6DIA.js +0 -4662
  56. package/dist/architectureDiagram-VXUJARFQ-DJ1ub7X0.cjs +0 -36
  57. package/dist/blockDiagram-VD42YOAC-CKNTgeZ8.js +0 -2256
  58. package/dist/blockDiagram-VD42YOAC-G-1iOwuq.cjs +0 -122
  59. package/dist/c4Diagram-YG6GDRKO-BJ1Ka924.cjs +0 -10
  60. package/dist/c4Diagram-YG6GDRKO-Bokkq4pO.js +0 -1580
  61. package/dist/channel-C4noxv-h.js +0 -5
  62. package/dist/channel-DvIIEA3u.cjs +0 -1
  63. package/dist/chunk-4BX2VUAB-B5M-5e_l.cjs +0 -1
  64. package/dist/chunk-4BX2VUAB-ByoAwp1j.js +0 -8
  65. package/dist/chunk-55IACEB6-BpG-_f0h.cjs +0 -1
  66. package/dist/chunk-55IACEB6-DRnx6y7F.js +0 -8
  67. package/dist/chunk-B4BG7PRW-0toVGVN-.js +0 -1375
  68. package/dist/chunk-B4BG7PRW-evUM3dip.cjs +0 -165
  69. package/dist/chunk-DI55MBZ5-CyInK_-M.js +0 -1370
  70. package/dist/chunk-DI55MBZ5-DKs4p2E0.cjs +0 -220
  71. package/dist/chunk-FMBD7UC4-BwUpmqhP.js +0 -19
  72. package/dist/chunk-FMBD7UC4-cpOVGF_2.cjs +0 -15
  73. package/dist/chunk-QN33PNHL-C7XXEbKU.js +0 -19
  74. package/dist/chunk-QN33PNHL-CEdYSNej.cjs +0 -1
  75. package/dist/chunk-QZHKN3VN-hppYv0Iu.cjs +0 -1
  76. package/dist/chunk-QZHKN3VN-qqHBDA_I.js +0 -15
  77. package/dist/chunk-TZMSLE5B-B9QqMSFM.js +0 -64
  78. package/dist/chunk-TZMSLE5B-Bklau4qu.cjs +0 -1
  79. package/dist/classDiagram-2ON5EDUG-CYKX_y1c.js +0 -16
  80. package/dist/classDiagram-2ON5EDUG-TgiEUsUn.cjs +0 -1
  81. package/dist/classDiagram-v2-WZHVMYZB-CYKX_y1c.js +0 -16
  82. package/dist/classDiagram-v2-WZHVMYZB-TgiEUsUn.cjs +0 -1
  83. package/dist/clone-CE64n2kf.js +0 -8
  84. package/dist/clone-jaW02xOC.cjs +0 -1
  85. package/dist/cose-bilkent-S5V4N54A-B_XAF1ZT.js +0 -2609
  86. package/dist/cose-bilkent-S5V4N54A-DSZx3rxe.cjs +0 -1
  87. package/dist/cytoscape.esm-CNUX3VTg.cjs +0 -321
  88. package/dist/cytoscape.esm-Cvf3sx9F.js +0 -18704
  89. package/dist/dagre-6UL2VRFP-Biy3Qm3K.js +0 -443
  90. package/dist/dagre-6UL2VRFP-C8MiPDEQ.cjs +0 -4
  91. package/dist/defaultLocale-D7EN2tov.js +0 -171
  92. package/dist/defaultLocale-DIVzfLaQ.cjs +0 -1
  93. package/dist/diagram-PSM6KHXK-B1y0Lt7Z.cjs +0 -24
  94. package/dist/diagram-PSM6KHXK-CIfbagcO.js +0 -531
  95. package/dist/diagram-QEK2KX5R-BJNTbg0b.cjs +0 -43
  96. package/dist/diagram-QEK2KX5R-BQz0yqem.js +0 -217
  97. package/dist/diagram-S2PKOQOG-BGsratMZ.js +0 -142
  98. package/dist/diagram-S2PKOQOG-BK_tj5Pz.cjs +0 -24
  99. package/dist/erDiagram-Q2GNP2WA-CJbuwIgY.cjs +0 -60
  100. package/dist/erDiagram-Q2GNP2WA-CurkAz8N.js +0 -841
  101. package/dist/flowDiagram-NV44I4VS-DAMyok8X.js +0 -1620
  102. package/dist/flowDiagram-NV44I4VS-DnmHUmh1.cjs +0 -162
  103. package/dist/ganttDiagram-JELNMOA3-DxXvW49B.cjs +0 -267
  104. package/dist/ganttDiagram-JELNMOA3-oVlSmAjl.js +0 -2671
  105. package/dist/gitGraph-F6HP7TQM-DUSMetNW.js +0 -5
  106. package/dist/gitGraph-F6HP7TQM-DveZcMpA.cjs +0 -1
  107. package/dist/gitGraphDiagram-NY62KEGX-CFdtd4Gb.js +0 -699
  108. package/dist/gitGraphDiagram-NY62KEGX-CspGhCdP.cjs +0 -65
  109. package/dist/graph-Bza-HyX6.js +0 -381
  110. package/dist/graph-CE_Z8OkL.cjs +0 -1
  111. package/dist/info-NVLQJR56-3ayytpiF.js +0 -5
  112. package/dist/info-NVLQJR56-D-IKjb_E.cjs +0 -1
  113. package/dist/infoDiagram-WHAUD3N6--LngDYSE.cjs +0 -2
  114. package/dist/infoDiagram-WHAUD3N6-BtO0qT6g.js +0 -24
  115. package/dist/init-CHZsXQcr.cjs +0 -1
  116. package/dist/init-DjUOC4st.js +0 -16
  117. package/dist/journeyDiagram-XKPGCS4Q-DCvKw6yJ.cjs +0 -139
  118. package/dist/journeyDiagram-XKPGCS4Q-Unrh_bjo.js +0 -834
  119. package/dist/kanban-definition-3W4ZIXB7-CRa6bR24.cjs +0 -89
  120. package/dist/kanban-definition-3W4ZIXB7-Vpm6gG9R.js +0 -719
  121. package/dist/layout-BJzrWbaG.cjs +0 -1
  122. package/dist/layout-D6Pf3Nys.js +0 -1441
  123. package/dist/linear-C0E_OSxf.js +0 -259
  124. package/dist/linear-TSwNFrBs.cjs +0 -1
  125. package/dist/mermaid-parser.core-B9wV8XMP.js +0 -14177
  126. package/dist/mermaid-parser.core-Ba9EAFlD.cjs +0 -128
  127. package/dist/mermaid.core-B1lFjYb9.js +0 -15269
  128. package/dist/mermaid.core-C8vi9eg6.cjs +0 -249
  129. package/dist/min-BC6TlZcq.cjs +0 -1
  130. package/dist/min-DT5Wu4V1.js +0 -38
  131. package/dist/mindmap-definition-VGOIOE7T-COA86V4i.js +0 -784
  132. package/dist/mindmap-definition-VGOIOE7T-D9oMyZ2M.cjs +0 -68
  133. package/dist/ordinal-B6-f3MAq.js +0 -61
  134. package/dist/ordinal-CagbB1m8.cjs +0 -1
  135. package/dist/packet-BFZMPI3H-BZI0_bZt.js +0 -5
  136. package/dist/packet-BFZMPI3H-D4pnK0Ol.cjs +0 -1
  137. package/dist/pie-7BOR55EZ-DS6huTOL.cjs +0 -1
  138. package/dist/pie-7BOR55EZ-DgzTX76e.js +0 -5
  139. package/dist/pieDiagram-ADFJNKIX-CYW3Diea.js +0 -161
  140. package/dist/pieDiagram-ADFJNKIX-CxPAjreR.cjs +0 -30
  141. package/dist/quadrantDiagram-AYHSOK5B-BT94kssD.js +0 -1022
  142. package/dist/quadrantDiagram-AYHSOK5B-ehLphI_D.cjs +0 -7
  143. package/dist/radar-NHE76QYJ-CKcVnf1I.cjs +0 -1
  144. package/dist/radar-NHE76QYJ-D8cZitaQ.js +0 -5
  145. package/dist/requirementDiagram-UZGBJVZJ-B4UYGl6e.js +0 -850
  146. package/dist/requirementDiagram-UZGBJVZJ-BDLj6-Do.cjs +0 -64
  147. package/dist/sankeyDiagram-TZEHDZUN-CAWsWdn8.js +0 -810
  148. package/dist/sankeyDiagram-TZEHDZUN-DUb360Ep.cjs +0 -10
  149. package/dist/sequenceDiagram-WL72ISMW-Bb4Tkhf2.cjs +0 -145
  150. package/dist/sequenceDiagram-WL72ISMW-DsmW0gAI.js +0 -2511
  151. package/dist/stateDiagram-FKZM4ZOC-Da-8DKdP.js +0 -263
  152. package/dist/stateDiagram-FKZM4ZOC-jOvG1Jmy.cjs +0 -1
  153. package/dist/stateDiagram-v2-4FDKWEC3-GMZ8nH4e.js +0 -16
  154. package/dist/stateDiagram-v2-4FDKWEC3-mWKIMY-b.cjs +0 -1
  155. package/dist/timeline-definition-IT6M3QCI-BdnDlTsf.cjs +0 -61
  156. package/dist/timeline-definition-IT6M3QCI-CvJDgHLW.js +0 -795
  157. package/dist/treemap-KMMF4GRG-BVy_kMp3.js +0 -5
  158. package/dist/treemap-KMMF4GRG-BsA9nu7r.cjs +0 -1
  159. package/dist/xychartDiagram-PRI3JC2R-CYXNZ7B0.cjs +0 -7
  160. package/dist/xychartDiagram-PRI3JC2R-wG1xpI1S.js +0 -1340
package/README.md CHANGED
@@ -8,6 +8,18 @@ React components for markdown rendering and editing.
8
8
  pnpm add @ootc/markdown
9
9
  ```
10
10
 
11
+ The heavy features are opt-in and ship as **optional peer dependencies** — install only
12
+ what you use:
13
+
14
+ ```bash
15
+ pnpm add mermaid # diagrams
16
+ pnpm add @wooorm/starry-night # syntax highlighting
17
+ pnpm add katex remark-math rehype-katex # math
18
+ ```
19
+
20
+ Nothing above is required. Without them the preview still renders GFM markdown; code
21
+ fences render unhighlighted and ```mermaid fences render as ordinary code blocks.
22
+
11
23
  ## Usage
12
24
 
13
25
  ```tsx
@@ -16,12 +28,20 @@ import {MarkdownPreview} from '@ootc/markdown/preview';
16
28
  import {MarkdownEditor} from '@ootc/markdown/editor';
17
29
  import '@ootc/markdown/style.css';
18
30
 
31
+ // opt in to only what you need
32
+ import {mermaidPlugin} from '@ootc/markdown/plugin-mermaid';
33
+ import {highlightPlugin} from '@ootc/markdown/plugin-highlight';
34
+ import {katexPlugin} from '@ootc/markdown/plugin-katex';
35
+ import '@ootc/markdown/plugin-mermaid.css';
36
+
37
+ const plugins = [mermaidPlugin, highlightPlugin, katexPlugin];
38
+
19
39
  export default function Demo() {
20
40
  return (
21
41
  <div style={{display: 'grid', gap: 16}}>
22
- <MarkdownPreview content={'# Hello\n\n```ts\nconst x = 1;\n```'} />
23
- <CodeBlock code={'console.log("hi")'} language="ts" />
24
- <MarkdownEditor value={'# Edit me'} onChange={() => {}} />
42
+ <MarkdownPreview content={'# Hello\n\n```ts\nconst x = 1;\n```'} plugins={plugins} />
43
+ <CodeBlock code={'console.log("hi")'} language="ts" plugins={[highlightPlugin]} />
44
+ <MarkdownEditor value={'# Edit me'} onChange={() => {}} plugins={plugins} />
25
45
  </div>
26
46
  );
27
47
  }
@@ -33,8 +53,57 @@ export default function Demo() {
33
53
  - `@ootc/markdown/code`: `CodeBlock`
34
54
  - `@ootc/markdown/preview`: `MarkdownPreview`
35
55
  - `@ootc/markdown/editor`: `MarkdownEditor`
56
+ - `@ootc/markdown/plugin-mermaid`: `mermaidPlugin` — renders ```mermaid fences as diagrams
57
+ - `@ootc/markdown/plugin-highlight`: `highlightPlugin` — syntax highlighting via starry-night
58
+ - `@ootc/markdown/plugin-katex`: `katexPlugin` — `$inline$` and `$$display$$` math
59
+
60
+ Each entrypoint has both a named and a default export, so it works with `React.lazy` directly:
61
+
62
+ ```tsx
63
+ import {lazy, Suspense} from 'react';
64
+ import '@ootc/markdown/preview.css';
65
+
66
+ const MarkdownPreview = lazy(() => import('@ootc/markdown/preview'));
67
+
68
+ export function Doc({content}: {content: string}) {
69
+ return (
70
+ <Suspense fallback={null}>
71
+ <MarkdownPreview content={content} />
72
+ </Suspense>
73
+ );
74
+ }
75
+ ```
76
+
77
+ ### Opt-in dependencies
36
78
 
37
- `@ootc/markdown/preview` lazy-loads Mermaid only when a rendered document contains a `mermaid` code fence.
79
+ The three heavy dependencies are **not bundled** into this package. Each lives behind
80
+ its own entrypoint and is an optional peer dependency, so a bundler can prove it
81
+ unreachable when you don't pass the plugin:
82
+
83
+ | Plugin | Peer dependency | Cost when opted in |
84
+ | --- | --- | --- |
85
+ | `plugin-mermaid` | `mermaid` | ~2.8 MB, loaded lazily on the first diagram |
86
+ | `plugin-highlight` | `@wooorm/starry-night` | ~1.7 MB of grammars, loaded lazily on the first code block |
87
+ | `plugin-katex` | `katex`, `remark-math`, `rehype-katex` | eager; KaTeX fonts load as needed |
88
+
89
+ Mermaid and the highlighting grammars stay behind dynamic imports even when enabled,
90
+ so they never enter your initial bundle. KaTeX loads eagerly with the plugin because
91
+ it participates in the markdown pipeline itself.
92
+
93
+ Plugins are consulted in array order; the first to claim a fence wins.
94
+
95
+ ### Migrating from 0.1.x
96
+
97
+ `0.2.0` makes diagrams, highlighting and math opt-in. Previously they were always on.
98
+ To restore the old behavior, install the peers and pass all three plugins:
99
+
100
+ ```tsx
101
+ import {mermaidPlugin} from '@ootc/markdown/plugin-mermaid';
102
+ import {highlightPlugin} from '@ootc/markdown/plugin-highlight';
103
+ import {katexPlugin} from '@ootc/markdown/plugin-katex';
104
+
105
+ <MarkdownPreview content={md} plugins={[mermaidPlugin, highlightPlugin, katexPlugin]} />
106
+ ```
38
107
 
39
108
  ### MarkdownPreview
40
109
 
@@ -42,6 +111,7 @@ Props:
42
111
  - `content: string`
43
112
  - `compact?: boolean`
44
113
  - `theme?: "system" | "light" | "dark"` (default: `"system"`)
114
+ - `plugins?: MarkdownPlugin[]`
45
115
 
46
116
  `compact` removes default spacing and reduces vertical rhythm for tighter layouts.
47
117
 
@@ -63,6 +133,7 @@ Props:
63
133
  - `disabled?: boolean`
64
134
  - `rows?: number`
65
135
  - `className?: string`
136
+ - `plugins?: MarkdownPlugin[]` (forwarded to the preview pane)
66
137
 
67
138
  ### CodeBlock
68
139
 
@@ -71,11 +142,32 @@ Props:
71
142
  - `language: string`
72
143
  - `className?: string`
73
144
  - `theme?: "system" | "light" | "dark"` (default: `"system"`)
145
+ - `plugins?: MarkdownPlugin[]` (only `highlight` hooks are used)
74
146
 
75
147
  ## Styles
76
148
 
77
149
  This package ships CSS modules. The preview also imports KaTeX styles internally.
78
150
 
151
+ Styles are split per entrypoint, so you can import only what the page uses:
152
+
153
+ | Import | Covers |
154
+ | --- | --- |
155
+ | `@ootc/markdown/style.css` | everything (safe default) |
156
+ | `@ootc/markdown/code.css` | `CodeBlock` |
157
+ | `@ootc/markdown/preview.css` | `MarkdownPreview` (includes `CodeBlock` and KaTeX) |
158
+ | `@ootc/markdown/editor.css` | `MarkdownEditor` (includes both of the above) |
159
+ | `@ootc/markdown/plugin-mermaid.css` | diagram container, pan/zoom (needed with `mermaidPlugin`) |
160
+
161
+ ```ts
162
+ import '@ootc/markdown/preview.css';
163
+ ```
164
+
165
+ Each of these is a thin file that `@import`s the underlying stylesheets in `dist/css/`.
166
+ Bundlers resolve and copy them automatically.
167
+
168
+ `plugin-katex` has no stylesheet of its own — it imports `katex/dist/katex.min.css`
169
+ from your own KaTeX install, so the fonts come from there rather than from this package.
170
+
79
171
  ## Dark Mode
80
172
 
81
173
  The components support both light and dark themes.
@@ -0,0 +1,2 @@
1
+ "use strict";const o=require("./jsx-runtime-nZSsnGb7.cjs"),a=require("react"),k="_container_8h8ah_1",S="_loadingCodeBlock_8h8ah_5",E="_copyButton_8h8ah_17",L="_copyButtonSingleLine_8h8ah_31",R="_codeBlock_8h8ah_41",i={container:k,loadingCodeBlock:S,copyButton:E,copyButtonSingleLine:L,codeBlock:R};function $({code:t,language:s,className:r="",theme:c="system",plugins:h}){const[y,l]=a.useState(""),[m,u]=a.useState(!0),[f,p]=a.useState(!1),B=!t.trimEnd().includes(`
2
+ `);a.useEffect(()=>{let n=!1;const g=(h??[]).map(e=>e.highlight).filter(e=>!!e);if(g.length===0){l(d(t)),u(!1);return}u(!0);async function C(){try{for(const e of g){const x=await e(t,s);if(n)return;if(x!==null){l(x);return}}l(d(t))}catch(e){console.error("Syntax highlighting error:",e),n||l(d(t))}finally{n||u(!1)}}return C(),()=>{n=!0}},[t,s,h]);const _=async()=>{try{await navigator.clipboard.writeText(t),p(!0),setTimeout(()=>p(!1),2e3)}catch(n){console.error("Failed to copy:",n)}},j=()=>o.jsxRuntimeExports.jsx("code",{dangerouslySetInnerHTML:{__html:y}});return m?o.jsxRuntimeExports.jsx("div",{className:i.container,"data-theme":c==="system"?void 0:c,children:o.jsxRuntimeExports.jsx("pre",{className:`${i.loadingCodeBlock} ${r}`,children:o.jsxRuntimeExports.jsx("code",{children:t})})}):o.jsxRuntimeExports.jsxs("div",{className:i.container,"data-theme":c==="system"?void 0:c,children:[o.jsxRuntimeExports.jsx("button",{onClick:_,className:`${i.copyButton} ${B?i.copyButtonSingleLine:""}`,title:"Copy code",children:f?"Copied!":"Copy"}),o.jsxRuntimeExports.jsx("pre",{className:`${i.codeBlock} ${r}`,children:j()})]})}function d(t){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.replace(/[&<>"']/g,r=>s[r])}exports.CodeBlock=$;
@@ -0,0 +1,74 @@
1
+ import { j as o } from "./jsx-runtime-DXgJBoQh.js";
2
+ import { useState as h, useEffect as j } from "react";
3
+ const L = "_container_8h8ah_1", S = "_loadingCodeBlock_8h8ah_5", $ = "_copyButton_8h8ah_17", v = "_copyButtonSingleLine_8h8ah_31", N = "_codeBlock_8h8ah_41", i = {
4
+ container: L,
5
+ loadingCodeBlock: S,
6
+ copyButton: $,
7
+ copyButtonSingleLine: v,
8
+ codeBlock: N
9
+ };
10
+ function H({ code: t, language: c, className: r = "", theme: s = "system", plugins: u }) {
11
+ const [f, l] = h(""), [m, a] = h(!0), [B, g] = h(!1), _ = !t.trimEnd().includes(`
12
+ `);
13
+ j(() => {
14
+ let n = !1;
15
+ const p = (u ?? []).map((e) => e.highlight).filter((e) => !!e);
16
+ if (p.length === 0) {
17
+ l(d(t)), a(!1);
18
+ return;
19
+ }
20
+ a(!0);
21
+ async function k() {
22
+ try {
23
+ for (const e of p) {
24
+ const y = await e(t, c);
25
+ if (n) return;
26
+ if (y !== null) {
27
+ l(y);
28
+ return;
29
+ }
30
+ }
31
+ l(d(t));
32
+ } catch (e) {
33
+ console.error("Syntax highlighting error:", e), n || l(d(t));
34
+ } finally {
35
+ n || a(!1);
36
+ }
37
+ }
38
+ return k(), () => {
39
+ n = !0;
40
+ };
41
+ }, [t, c, u]);
42
+ const C = async () => {
43
+ try {
44
+ await navigator.clipboard.writeText(t), g(!0), setTimeout(() => g(!1), 2e3);
45
+ } catch (n) {
46
+ console.error("Failed to copy:", n);
47
+ }
48
+ }, x = () => /* @__PURE__ */ o.jsx("code", { dangerouslySetInnerHTML: { __html: f } });
49
+ return m ? /* @__PURE__ */ o.jsx("div", { className: i.container, "data-theme": s === "system" ? void 0 : s, children: /* @__PURE__ */ o.jsx("pre", { className: `${i.loadingCodeBlock} ${r}`, children: /* @__PURE__ */ o.jsx("code", { children: t }) }) }) : /* @__PURE__ */ o.jsxs("div", { className: i.container, "data-theme": s === "system" ? void 0 : s, children: [
50
+ /* @__PURE__ */ o.jsx(
51
+ "button",
52
+ {
53
+ onClick: C,
54
+ className: `${i.copyButton} ${_ ? i.copyButtonSingleLine : ""}`,
55
+ title: "Copy code",
56
+ children: B ? "Copied!" : "Copy"
57
+ }
58
+ ),
59
+ /* @__PURE__ */ o.jsx("pre", { className: `${i.codeBlock} ${r}`, children: x() })
60
+ ] });
61
+ }
62
+ function d(t) {
63
+ const c = {
64
+ "&": "&amp;",
65
+ "<": "&lt;",
66
+ ">": "&gt;",
67
+ '"': "&quot;",
68
+ "'": "&#039;"
69
+ };
70
+ return t.replace(/[&<>"']/g, (r) => c[r]);
71
+ }
72
+ export {
73
+ H as C
74
+ };