@ootc/markdown 0.1.0 → 0.2.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.
Files changed (207) hide show
  1. package/README.md +63 -9
  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.js +1 -1
  8. package/dist/components/code-block/CodeBlock.d.ts +7 -1
  9. package/dist/components/markdown/MarkdownPreview.d.ts +8 -2
  10. package/dist/components/markdown-editor/MarkdownEditor.d.ts +4 -1
  11. package/dist/css/MarkdownPreview.css +1 -1
  12. package/dist/css/plugin-mermaid.css +1 -0
  13. package/dist/editor.cjs +1 -1
  14. package/dist/editor.js +24 -22
  15. package/dist/index-BJZhyxD_.cjs +9 -0
  16. package/dist/index-DWVMYNE4.js +800 -0
  17. package/dist/index-HmBYTPyZ.js +1179 -0
  18. package/dist/index-jsnhzgIQ.cjs +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/jsx-runtime-DXgJBoQh.js +264 -0
  22. package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
  23. package/dist/plugin-highlight.cjs +1 -0
  24. package/dist/plugin-highlight.d.ts +3 -0
  25. package/dist/plugin-highlight.js +20 -0
  26. package/dist/plugin-katex.cjs +1 -0
  27. package/dist/plugin-katex.d.ts +3 -0
  28. package/dist/plugin-katex.js +12 -0
  29. package/dist/plugin-mermaid.cjs +1 -0
  30. package/dist/plugin-mermaid.css +1 -0
  31. package/dist/plugin-mermaid.d.ts +3 -0
  32. package/dist/plugin-mermaid.js +266 -0
  33. package/dist/plugins/highlight/index.d.ts +9 -0
  34. package/dist/plugins/katex/index.d.ts +12 -0
  35. package/dist/plugins/mermaid/MermaidDiagram.d.ts +7 -0
  36. package/dist/plugins/mermaid/index.d.ts +11 -0
  37. package/dist/plugins/types.d.ts +38 -0
  38. package/dist/preview.cjs +1 -1
  39. package/dist/preview.js +2 -2
  40. package/dist/style.css +1 -0
  41. package/package.json +49 -9
  42. package/dist/CodeBlock-B_Wu_RsD.cjs +0 -15
  43. package/dist/CodeBlock-BdSjKnRY.js +0 -2320
  44. package/dist/MarkdownPreview-CcTDfsgR.js +0 -20425
  45. package/dist/MarkdownPreview-imz9Sn8T.cjs +0 -295
  46. package/dist/_baseUniq-CmzFJAby.js +0 -477
  47. package/dist/_baseUniq-DTl9zLUk.cjs +0 -1
  48. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  49. package/dist/_commonjsHelpers-DwGv2jUC.cjs +0 -1
  50. package/dist/arc-CLsgE_FO.cjs +0 -1
  51. package/dist/arc-DN0J6orD.js +0 -83
  52. package/dist/architectureDiagram-VXUJARFQ-C0Ox22_L.cjs +0 -36
  53. package/dist/architectureDiagram-VXUJARFQ-DD1WVkEB.js +0 -4662
  54. package/dist/blockDiagram-VD42YOAC-CXFrXgPY.cjs +0 -122
  55. package/dist/blockDiagram-VD42YOAC-DzX-b-6d.js +0 -2256
  56. package/dist/c4Diagram-YG6GDRKO-8tK3jTST.cjs +0 -10
  57. package/dist/c4Diagram-YG6GDRKO-CBo9Z0K5.js +0 -1580
  58. package/dist/channel-BWUNfmCm.js +0 -5
  59. package/dist/channel-MPm5yYgZ.cjs +0 -1
  60. package/dist/chunk-4BX2VUAB-BC2JrFPv.js +0 -8
  61. package/dist/chunk-4BX2VUAB-CVibkmL0.cjs +0 -1
  62. package/dist/chunk-55IACEB6-CzZUDZ70.js +0 -8
  63. package/dist/chunk-55IACEB6-DZnx2f_C.cjs +0 -1
  64. package/dist/chunk-B4BG7PRW-D0a_-7vE.cjs +0 -165
  65. package/dist/chunk-B4BG7PRW-DU2I6H4s.js +0 -1375
  66. package/dist/chunk-DI55MBZ5-BuXMX149.js +0 -1370
  67. package/dist/chunk-DI55MBZ5-Dr1JJdkm.cjs +0 -220
  68. package/dist/chunk-FMBD7UC4-DekHPa2I.cjs +0 -15
  69. package/dist/chunk-FMBD7UC4-RBUwxloo.js +0 -19
  70. package/dist/chunk-QN33PNHL-B6FGlZxV.js +0 -19
  71. package/dist/chunk-QN33PNHL-C1YRBk0j.cjs +0 -1
  72. package/dist/chunk-QZHKN3VN-BspjB43V.cjs +0 -1
  73. package/dist/chunk-QZHKN3VN-DR_oy1P1.js +0 -15
  74. package/dist/chunk-TZMSLE5B-BRck7Be7.cjs +0 -1
  75. package/dist/chunk-TZMSLE5B-pyixj0XE.js +0 -64
  76. package/dist/classDiagram-2ON5EDUG-Bvw7buPq.cjs +0 -1
  77. package/dist/classDiagram-2ON5EDUG-DK3Yvqrk.js +0 -16
  78. package/dist/classDiagram-v2-WZHVMYZB-Bvw7buPq.cjs +0 -1
  79. package/dist/classDiagram-v2-WZHVMYZB-DK3Yvqrk.js +0 -16
  80. package/dist/clone-D2V_3-x6.cjs +0 -1
  81. package/dist/clone-O816pP2i.js +0 -8
  82. package/dist/cose-bilkent-S5V4N54A-Bu3r2cA0.js +0 -2609
  83. package/dist/cose-bilkent-S5V4N54A-vz9hoE-P.cjs +0 -1
  84. package/dist/cytoscape.esm-CNUX3VTg.cjs +0 -321
  85. package/dist/cytoscape.esm-Cvf3sx9F.js +0 -18704
  86. package/dist/dagre-6UL2VRFP-D2UBESo6.cjs +0 -4
  87. package/dist/dagre-6UL2VRFP-DiBRZkX2.js +0 -443
  88. package/dist/defaultLocale-D7EN2tov.js +0 -171
  89. package/dist/defaultLocale-DIVzfLaQ.cjs +0 -1
  90. package/dist/diagram-PSM6KHXK-CUF6rC_5.js +0 -531
  91. package/dist/diagram-PSM6KHXK-uKXJz4r1.cjs +0 -24
  92. package/dist/diagram-QEK2KX5R-Da150Pqe.js +0 -217
  93. package/dist/diagram-QEK2KX5R-kQTDsG_x.cjs +0 -43
  94. package/dist/diagram-S2PKOQOG-C5ATPkHT.cjs +0 -24
  95. package/dist/diagram-S2PKOQOG-DA2RxLrC.js +0 -142
  96. package/dist/erDiagram-Q2GNP2WA-BsCdOw62.cjs +0 -60
  97. package/dist/erDiagram-Q2GNP2WA-YfCaUJjx.js +0 -841
  98. package/dist/flowDiagram-NV44I4VS-BG0KW3ec.cjs +0 -162
  99. package/dist/flowDiagram-NV44I4VS-D7WLCw1w.js +0 -1620
  100. package/dist/fonts/font-00b26ac8.woff2 +0 -0
  101. package/dist/fonts/font-036d4e95.woff2 +0 -0
  102. package/dist/fonts/font-07d8e303.ttf +0 -0
  103. package/dist/fonts/font-08ce98e5.ttf +0 -0
  104. package/dist/fonts/font-0cdd387c.woff2 +0 -0
  105. package/dist/fonts/font-0d85ae7c.ttf +0 -0
  106. package/dist/fonts/font-0f60d1b8.woff2 +0 -0
  107. package/dist/fonts/font-11e4dc8a.woff +0 -0
  108. package/dist/fonts/font-138ac28d.ttf +0 -0
  109. package/dist/fonts/font-1ae6bd74.woff +0 -0
  110. package/dist/fonts/font-1c67f068.ttf +0 -0
  111. package/dist/fonts/font-1e6f9579.ttf +0 -0
  112. package/dist/fonts/font-1ece03f7.ttf +0 -0
  113. package/dist/fonts/font-2014c523.woff +0 -0
  114. package/dist/fonts/font-30da91e8.woff +0 -0
  115. package/dist/fonts/font-3398dd02.woff +0 -0
  116. package/dist/fonts/font-3931dd81.ttf +0 -0
  117. package/dist/fonts/font-500e04d5.ttf +0 -0
  118. package/dist/fonts/font-51814d27.woff2 +0 -0
  119. package/dist/fonts/font-5d53e70a.woff2 +0 -0
  120. package/dist/fonts/font-5e28753b.woff +0 -0
  121. package/dist/fonts/font-68534840.ttf +0 -0
  122. package/dist/fonts/font-68e8c73e.woff2 +0 -0
  123. package/dist/fonts/font-6ab6b62e.woff +0 -0
  124. package/dist/fonts/font-6b47c401.woff2 +0 -0
  125. package/dist/fonts/font-70ee1f64.ttf +0 -0
  126. package/dist/fonts/font-71d517d6.woff2 +0 -0
  127. package/dist/fonts/font-73d59127.woff2 +0 -0
  128. package/dist/fonts/font-74444efd.woff2 +0 -0
  129. package/dist/fonts/font-7af58c5e.woff2 +0 -0
  130. package/dist/fonts/font-850c0af5.woff +0 -0
  131. package/dist/fonts/font-8a8d2445.woff +0 -0
  132. package/dist/fonts/font-9163df9c.ttf +0 -0
  133. package/dist/fonts/font-91ee6750.woff +0 -0
  134. package/dist/fonts/font-95b6d2f1.ttf +0 -0
  135. package/dist/fonts/font-97479ca6.woff2 +0 -0
  136. package/dist/fonts/font-99cd42a3.woff2 +0 -0
  137. package/dist/fonts/font-99f9c675.woff +0 -0
  138. package/dist/fonts/font-9be7ceb8.woff +0 -0
  139. package/dist/fonts/font-a4af7d41.woff2 +0 -0
  140. package/dist/fonts/font-a6b2099f.ttf +0 -0
  141. package/dist/fonts/font-a6f7ec0d.woff +0 -0
  142. package/dist/fonts/font-c2342cd8.woff2 +0 -0
  143. package/dist/fonts/font-c6368d87.woff +0 -0
  144. package/dist/fonts/font-c647367d.ttf +0 -0
  145. package/dist/fonts/font-c76c5d69.woff +0 -0
  146. package/dist/fonts/font-c943cc98.woff +0 -0
  147. package/dist/fonts/font-d0332f52.ttf +0 -0
  148. package/dist/fonts/font-d04c5421.woff2 +0 -0
  149. package/dist/fonts/font-d96cdf2b.woff +0 -0
  150. package/dist/fonts/font-dc47344d.woff2 +0 -0
  151. package/dist/fonts/font-de7701e4.woff2 +0 -0
  152. package/dist/fonts/font-e14fed02.woff +0 -0
  153. package/dist/fonts/font-e99ae511.woff2 +0 -0
  154. package/dist/fonts/font-ece03cfd.woff +0 -0
  155. package/dist/fonts/font-ed0b7437.ttf +0 -0
  156. package/dist/fonts/font-f01f3e87.ttf +0 -0
  157. package/dist/fonts/font-f1d6ef86.woff +0 -0
  158. package/dist/fonts/font-f36ea897.ttf +0 -0
  159. package/dist/fonts/font-f9377ab0.ttf +0 -0
  160. package/dist/ganttDiagram-JELNMOA3-BUA8njzO.cjs +0 -267
  161. package/dist/ganttDiagram-JELNMOA3-DSi9nt2I.js +0 -2671
  162. package/dist/gitGraphDiagram-NY62KEGX-C_9BbRSY.cjs +0 -65
  163. package/dist/gitGraphDiagram-NY62KEGX-Dr7HXTzE.js +0 -699
  164. package/dist/graph-Bd_3fIRG.cjs +0 -1
  165. package/dist/graph-DKQwyqwf.js +0 -381
  166. package/dist/index-BCrgOJjI.js +0 -38514
  167. package/dist/index-CPmaHYSB.cjs +0 -3920
  168. package/dist/infoDiagram-WHAUD3N6-LqpiKtaK.cjs +0 -2
  169. package/dist/infoDiagram-WHAUD3N6-cs5PUkbs.js +0 -24
  170. package/dist/init-CHZsXQcr.cjs +0 -1
  171. package/dist/init-DjUOC4st.js +0 -16
  172. package/dist/journeyDiagram-XKPGCS4Q-Uzzobun-.cjs +0 -139
  173. package/dist/journeyDiagram-XKPGCS4Q-Xh1PuBF3.js +0 -834
  174. package/dist/kanban-definition-3W4ZIXB7-BGNcniUS.cjs +0 -89
  175. package/dist/kanban-definition-3W4ZIXB7-BrCevkcy.js +0 -719
  176. package/dist/layout-C1JPMjBE.cjs +0 -1
  177. package/dist/layout-DCT3c1G0.js +0 -1441
  178. package/dist/linear-1V2v3HAv.js +0 -259
  179. package/dist/linear-BguQgdYO.cjs +0 -1
  180. package/dist/mermaid.core-B7U3vlPn.js +0 -15269
  181. package/dist/mermaid.core-Bi8BVJjR.cjs +0 -249
  182. package/dist/min-DxTpsh5w.js +0 -38
  183. package/dist/min-IWR7y697.cjs +0 -1
  184. package/dist/mindmap-definition-VGOIOE7T-Bo_AaB3S.cjs +0 -68
  185. package/dist/mindmap-definition-VGOIOE7T-y7MJRkKb.js +0 -784
  186. package/dist/ordinal-B6-f3MAq.js +0 -61
  187. package/dist/ordinal-CagbB1m8.cjs +0 -1
  188. package/dist/pieDiagram-ADFJNKIX-B3MwEiQQ.cjs +0 -30
  189. package/dist/pieDiagram-ADFJNKIX-Dat2qDxW.js +0 -161
  190. package/dist/quadrantDiagram-AYHSOK5B-BPI6p5FS.js +0 -1022
  191. package/dist/quadrantDiagram-AYHSOK5B-DJPxR-7E.cjs +0 -7
  192. package/dist/requirementDiagram-UZGBJVZJ-BjJSqttW.js +0 -850
  193. package/dist/requirementDiagram-UZGBJVZJ-CmIwuHrt.cjs +0 -64
  194. package/dist/sankeyDiagram-TZEHDZUN-CLroAHms.cjs +0 -10
  195. package/dist/sankeyDiagram-TZEHDZUN-jMmEhl5n.js +0 -810
  196. package/dist/sequenceDiagram-WL72ISMW-BVZMWdMT.cjs +0 -145
  197. package/dist/sequenceDiagram-WL72ISMW-CqGWWpuM.js +0 -2511
  198. package/dist/stateDiagram-FKZM4ZOC-DYHXgEjX.cjs +0 -1
  199. package/dist/stateDiagram-FKZM4ZOC-h1ovMUWJ.js +0 -263
  200. package/dist/stateDiagram-v2-4FDKWEC3-Di23ehqW.cjs +0 -1
  201. package/dist/stateDiagram-v2-4FDKWEC3-GGpuzcKb.js +0 -16
  202. package/dist/timeline-definition-IT6M3QCI-DC_axTKs.js +0 -795
  203. package/dist/timeline-definition-IT6M3QCI-DYx-RdCk.cjs +0 -61
  204. package/dist/treemap-KMMF4GRG-B-9lqUoG.js +0 -14192
  205. package/dist/treemap-KMMF4GRG-EXqF5Yz1.cjs +0 -128
  206. package/dist/xychartDiagram-PRI3JC2R-CedpkbBs.cjs +0 -7
  207. package/dist/xychartDiagram-PRI3JC2R-gFwsBSHN.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,6 +53,9 @@ 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
36
59
 
37
60
  Each entrypoint has both a named and a default export, so it works with `React.lazy` directly:
38
61
 
@@ -51,13 +74,36 @@ export function Doc({content}: {content: string}) {
51
74
  }
52
75
  ```
53
76
 
54
- ### Lazy loading
77
+ ### Opt-in dependencies
78
+
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:
55
82
 
56
- The heaviest dependencies are behind dynamic imports and are fetched only when they are actually needed:
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 |
57
88
 
58
- - **Syntax highlighting grammars** (`@wooorm/starry-night`, ~1.7 MB) load when the first code block renders. They are shared process-wide, so subsequent code blocks reuse them.
59
- - **Mermaid** loads when a rendered document contains a `mermaid` code fence.
60
- - **KaTeX fonts** ship as separate font files under `dist/fonts/` rather than base64 data URIs, so the browser downloads only the faces a page actually uses.
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
+ ```
61
107
 
62
108
  ### MarkdownPreview
63
109
 
@@ -65,6 +111,7 @@ Props:
65
111
  - `content: string`
66
112
  - `compact?: boolean`
67
113
  - `theme?: "system" | "light" | "dark"` (default: `"system"`)
114
+ - `plugins?: MarkdownPlugin[]`
68
115
 
69
116
  `compact` removes default spacing and reduces vertical rhythm for tighter layouts.
70
117
 
@@ -86,6 +133,7 @@ Props:
86
133
  - `disabled?: boolean`
87
134
  - `rows?: number`
88
135
  - `className?: string`
136
+ - `plugins?: MarkdownPlugin[]` (forwarded to the preview pane)
89
137
 
90
138
  ### CodeBlock
91
139
 
@@ -94,6 +142,7 @@ Props:
94
142
  - `language: string`
95
143
  - `className?: string`
96
144
  - `theme?: "system" | "light" | "dark"` (default: `"system"`)
145
+ - `plugins?: MarkdownPlugin[]` (only `highlight` hooks are used)
97
146
 
98
147
  ## Styles
99
148
 
@@ -107,12 +156,17 @@ Styles are split per entrypoint, so you can import only what the page uses:
107
156
  | `@ootc/markdown/code.css` | `CodeBlock` |
108
157
  | `@ootc/markdown/preview.css` | `MarkdownPreview` (includes `CodeBlock` and KaTeX) |
109
158
  | `@ootc/markdown/editor.css` | `MarkdownEditor` (includes both of the above) |
159
+ | `@ootc/markdown/plugin-mermaid.css` | diagram container, pan/zoom (needed with `mermaidPlugin`) |
110
160
 
111
161
  ```ts
112
162
  import '@ootc/markdown/preview.css';
113
163
  ```
114
164
 
115
- Each of these is a thin file that `@import`s the underlying stylesheets in `dist/css/`, which in turn reference the font files in `dist/fonts/`. Bundlers resolve and copy both automatically.
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.
116
170
 
117
171
  ## Dark Mode
118
172
 
@@ -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
+ };