@deepseek-ai/dsh-client-ui-primitives 0.2.2-alpha.3 → 0.2.2-rc.2

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 (412) hide show
  1. package/README.i18n.yaml +16 -16
  2. package/README.md +21 -14
  3. package/README.zh.md +21 -14
  4. package/lib/HoverCard.module.css +8 -3
  5. package/lib/JsonTree.module.css +7 -17
  6. package/lib/Menu.module.css +157 -37
  7. package/lib/Modal.module.css +16 -0
  8. package/lib/QuotePreview.module.css +37 -0
  9. package/lib/RiskConfirmation.module.css +11 -37
  10. package/lib/Toast.module.css +2 -3
  11. package/lib/Tooltip.module.css +2 -1
  12. package/lib/index.js +1447 -776
  13. package/lib/index.js.map +1 -0
  14. package/lib/markdown/CodeBlock.module.css +64 -0
  15. package/lib/markdown/MarkdownText.module.css +20 -1
  16. package/lib/types/AnimatedRows.d.ts +3 -0
  17. package/lib/types/AnimatedRows.d.ts.map +1 -0
  18. package/lib/types/AnimatedRows.js.map +1 -0
  19. package/lib/types/BrandWordmark.d.ts.map +1 -0
  20. package/lib/types/BrandWordmark.js.map +1 -0
  21. package/lib/types/Button.d.ts.map +1 -0
  22. package/lib/types/Button.js.map +1 -0
  23. package/lib/types/Checkbox.d.ts +3 -1
  24. package/lib/types/Checkbox.d.ts.map +1 -0
  25. package/lib/types/Checkbox.js.map +1 -0
  26. package/lib/types/CodeFileIcon.d.ts.map +1 -0
  27. package/lib/types/CodeFileIcon.js.map +1 -0
  28. package/lib/types/CodeToolbar.d.ts.map +1 -0
  29. package/lib/types/CodeToolbar.js.map +1 -0
  30. package/lib/types/CommandText.d.ts.map +1 -0
  31. package/lib/types/CommandText.js.map +1 -0
  32. package/lib/types/ConfigField.d.ts.map +1 -0
  33. package/lib/types/ConfigField.js.map +1 -0
  34. package/lib/types/ConnectionIndicator.d.ts.map +1 -0
  35. package/lib/types/ConnectionIndicator.js.map +1 -0
  36. package/lib/types/DetailDocument.d.ts.map +1 -0
  37. package/lib/types/DetailDocument.js.map +1 -0
  38. package/lib/types/DiffBlock.d.ts.map +1 -0
  39. package/lib/types/DiffBlock.js.map +1 -0
  40. package/lib/types/DisclosureRow.d.ts.map +1 -0
  41. package/lib/types/DisclosureRow.js.map +1 -0
  42. package/lib/types/DraggableImage.d.ts.map +1 -0
  43. package/lib/types/DraggableImage.js.map +1 -0
  44. package/lib/types/FileTypeIcon.d.ts.map +1 -0
  45. package/lib/types/FileTypeIcon.js.map +1 -0
  46. package/lib/types/FishLogo.d.ts.map +1 -0
  47. package/lib/types/FishLogo.js.map +1 -0
  48. package/lib/types/FoldToggle.d.ts.map +1 -0
  49. package/lib/types/FoldToggle.js.map +1 -0
  50. package/lib/types/HoverCard.d.ts.map +1 -0
  51. package/lib/types/HoverCard.js.map +1 -0
  52. package/lib/types/HoverCardGroup.d.ts.map +1 -0
  53. package/lib/types/HoverCardGroup.js.map +1 -0
  54. package/lib/types/ImageLightbox.d.ts.map +1 -0
  55. package/lib/types/ImageLightbox.js.map +1 -0
  56. package/lib/types/ImagePreview.d.ts.map +1 -0
  57. package/lib/types/ImagePreview.js.map +1 -0
  58. package/lib/types/InlineEditor.d.ts.map +1 -0
  59. package/lib/types/InlineEditor.js.map +1 -0
  60. package/lib/types/Input.d.ts.map +1 -0
  61. package/lib/types/Input.js.map +1 -0
  62. package/lib/types/JsonTree.d.ts.map +1 -0
  63. package/lib/types/JsonTree.js.map +1 -0
  64. package/lib/types/LinkIcon.d.ts.map +1 -0
  65. package/lib/types/LinkIcon.js.map +1 -0
  66. package/lib/types/Menu.d.ts +26 -14
  67. package/lib/types/Menu.d.ts.map +1 -0
  68. package/lib/types/Menu.js.map +1 -0
  69. package/lib/types/MenuGroup.d.ts.map +1 -0
  70. package/lib/types/MenuGroup.js.map +1 -0
  71. package/lib/types/MenuRow.d.ts +37 -0
  72. package/lib/types/MenuRow.d.ts.map +1 -0
  73. package/lib/types/MenuRow.js.map +1 -0
  74. package/lib/types/MenuSurface.d.ts.map +1 -0
  75. package/lib/types/MenuSurface.js.map +1 -0
  76. package/lib/types/Modal.d.ts +3 -1
  77. package/lib/types/Modal.d.ts.map +1 -0
  78. package/lib/types/Modal.js.map +1 -0
  79. package/lib/types/PathLabel.d.ts.map +1 -0
  80. package/lib/types/PathLabel.js.map +1 -0
  81. package/lib/types/PermissionIcon.d.ts.map +1 -0
  82. package/lib/types/PermissionIcon.js.map +1 -0
  83. package/lib/types/Pill.d.ts.map +1 -0
  84. package/lib/types/Pill.js.map +1 -0
  85. package/lib/types/QuotePreview.d.ts +17 -4
  86. package/lib/types/QuotePreview.d.ts.map +1 -0
  87. package/lib/types/QuotePreview.js.map +1 -0
  88. package/lib/types/ReadBlock.d.ts.map +1 -0
  89. package/lib/types/ReadBlock.js.map +1 -0
  90. package/lib/types/ReferenceIcon.d.ts.map +1 -0
  91. package/lib/types/ReferenceIcon.js.map +1 -0
  92. package/lib/types/RiskConfirmation.d.ts.map +1 -0
  93. package/lib/types/RiskConfirmation.js.map +1 -0
  94. package/lib/types/SearchBlock.d.ts.map +1 -0
  95. package/lib/types/SearchBlock.js.map +1 -0
  96. package/lib/types/SegmentedControl.d.ts.map +1 -0
  97. package/lib/types/SegmentedControl.js.map +1 -0
  98. package/lib/types/SegmentedTabs.d.ts.map +1 -0
  99. package/lib/types/SegmentedTabs.js.map +1 -0
  100. package/lib/types/ShortcutKeys.d.ts.map +1 -0
  101. package/lib/types/ShortcutKeys.js.map +1 -0
  102. package/lib/types/SiteGlyph.d.ts.map +1 -0
  103. package/lib/types/SiteGlyph.js.map +1 -0
  104. package/lib/types/StateDot.d.ts.map +1 -0
  105. package/lib/types/StateDot.js.map +1 -0
  106. package/lib/types/SubmenuPanel.d.ts +19 -0
  107. package/lib/types/SubmenuPanel.d.ts.map +1 -0
  108. package/lib/types/SubmenuPanel.js.map +1 -0
  109. package/lib/types/Switch.d.ts.map +1 -0
  110. package/lib/types/Switch.js.map +1 -0
  111. package/lib/types/Tag.d.ts.map +1 -0
  112. package/lib/types/Tag.js.map +1 -0
  113. package/lib/types/TerminalBlock.d.ts.map +1 -0
  114. package/lib/types/TerminalBlock.js.map +1 -0
  115. package/lib/types/TextShimmer.d.ts.map +1 -0
  116. package/lib/types/TextShimmer.js.map +1 -0
  117. package/lib/types/Toast.d.ts.map +1 -0
  118. package/lib/types/Toast.js.map +1 -0
  119. package/lib/types/Tooltip.d.ts.map +1 -0
  120. package/lib/types/Tooltip.js.map +1 -0
  121. package/lib/types/UserMessageBubble.d.ts.map +1 -0
  122. package/lib/types/UserMessageBubble.js.map +1 -0
  123. package/lib/types/WebBlock.d.ts.map +1 -0
  124. package/lib/types/WebBlock.js.map +1 -0
  125. package/lib/types/ZoomControls.d.ts.map +1 -0
  126. package/lib/types/ZoomControls.js.map +1 -0
  127. package/lib/types/ansi.d.ts.map +1 -0
  128. package/lib/types/ansi.js.map +1 -0
  129. package/lib/types/clipboard.d.ts.map +1 -0
  130. package/lib/types/clipboard.js.map +1 -0
  131. package/lib/types/code-file-icon-artwork.d.ts.map +1 -0
  132. package/lib/types/code-file-icon-artwork.js.map +1 -0
  133. package/lib/types/code-file-types.d.ts.map +1 -0
  134. package/lib/types/code-file-types.js.map +1 -0
  135. package/lib/types/code-highlighting.d.ts.map +1 -0
  136. package/lib/types/code-highlighting.js.map +1 -0
  137. package/lib/types/darwin-desktop.d.ts.map +1 -0
  138. package/lib/types/darwin-desktop.js.map +1 -0
  139. package/lib/types/document-zoom.d.ts.map +1 -0
  140. package/lib/types/document-zoom.js.map +1 -0
  141. package/lib/types/file-drag-actions.d.ts.map +1 -0
  142. package/lib/types/file-drag-actions.js.map +1 -0
  143. package/lib/types/file-size.d.ts.map +1 -0
  144. package/lib/types/file-size.js.map +1 -0
  145. package/lib/types/focus.d.ts.map +1 -0
  146. package/lib/types/focus.js.map +1 -0
  147. package/lib/types/guide-artwork.d.ts.map +1 -0
  148. package/lib/types/guide-artwork.js.map +1 -0
  149. package/lib/types/head-tail-cap.d.ts.map +1 -0
  150. package/lib/types/head-tail-cap.js.map +1 -0
  151. package/lib/types/icons/artwork.d.ts +12 -0
  152. package/lib/types/icons/artwork.d.ts.map +1 -0
  153. package/lib/types/icons/artwork.js.map +1 -0
  154. package/lib/types/icons/index.d.ts +12 -0
  155. package/lib/types/icons/index.d.ts.map +1 -0
  156. package/lib/types/icons/index.js.map +1 -0
  157. package/lib/types/icons/props.d.ts.map +1 -0
  158. package/lib/types/icons/props.js.map +1 -0
  159. package/lib/types/icons/shared-artwork.d.ts.map +1 -0
  160. package/lib/types/icons/shared-artwork.js.map +1 -0
  161. package/lib/types/image-drag.d.ts.map +1 -0
  162. package/lib/types/image-drag.js.map +1 -0
  163. package/lib/types/index.d.ts +5 -4
  164. package/lib/types/index.d.ts.map +1 -0
  165. package/lib/types/index.js.map +1 -0
  166. package/lib/types/input-modality.d.ts.map +1 -0
  167. package/lib/types/input-modality.js.map +1 -0
  168. package/lib/types/keyboard-composition.d.ts.map +1 -0
  169. package/lib/types/keyboard-composition.js.map +1 -0
  170. package/lib/types/markdown/CodeBlock.d.ts +8 -1
  171. package/lib/types/markdown/CodeBlock.d.ts.map +1 -0
  172. package/lib/types/markdown/CodeBlock.js.map +1 -0
  173. package/lib/types/markdown/FenceBlocks.d.ts +31 -0
  174. package/lib/types/markdown/FenceBlocks.d.ts.map +1 -0
  175. package/lib/types/markdown/FenceBlocks.js.map +1 -0
  176. package/lib/types/markdown/JsonBlock.d.ts.map +1 -0
  177. package/lib/types/markdown/JsonBlock.js.map +1 -0
  178. package/lib/types/markdown/MarkdownDelegate.d.ts +23 -1
  179. package/lib/types/markdown/MarkdownDelegate.d.ts.map +1 -0
  180. package/lib/types/markdown/MarkdownDelegate.js.map +1 -0
  181. package/lib/types/markdown/MarkdownText.d.ts +2 -0
  182. package/lib/types/markdown/MarkdownText.d.ts.map +1 -0
  183. package/lib/types/markdown/MarkdownText.js.map +1 -0
  184. package/lib/types/markdown/cjkFriendlyStrong.d.ts.map +1 -0
  185. package/lib/types/markdown/cjkFriendlyStrong.js.map +1 -0
  186. package/lib/types/markdown/copy-tex.d.ts +14 -0
  187. package/lib/types/markdown/copy-tex.d.ts.map +1 -0
  188. package/lib/types/markdown/copy-tex.js.map +1 -0
  189. package/lib/types/markdown/diff-fence.d.ts +58 -0
  190. package/lib/types/markdown/diff-fence.d.ts.map +1 -0
  191. package/lib/types/markdown/diff-fence.js.map +1 -0
  192. package/lib/types/markdown/file-link.d.ts.map +1 -0
  193. package/lib/types/markdown/file-link.js.map +1 -0
  194. package/lib/types/markdown/highlight.d.ts +18 -0
  195. package/lib/types/markdown/highlight.d.ts.map +1 -0
  196. package/lib/types/markdown/highlight.js.map +1 -0
  197. package/lib/types/markdown/incremental.d.ts.map +1 -0
  198. package/lib/types/markdown/incremental.js.map +1 -0
  199. package/lib/types/markdown/katex.d.ts.map +1 -0
  200. package/lib/types/markdown/katex.js.map +1 -0
  201. package/lib/types/markdown/local-image-syntax.d.ts.map +1 -0
  202. package/lib/types/markdown/local-image-syntax.js.map +1 -0
  203. package/lib/types/markdown/mathCompatibility.d.ts.map +1 -0
  204. package/lib/types/markdown/mathCompatibility.js.map +1 -0
  205. package/lib/types/markdown/parse.d.ts.map +1 -0
  206. package/lib/types/markdown/parse.js.map +1 -0
  207. package/lib/types/markdown/plain-text.d.ts.map +1 -0
  208. package/lib/types/markdown/plain-text.js.map +1 -0
  209. package/lib/types/markdown/quote-text.d.ts.map +1 -0
  210. package/lib/types/markdown/quote-text.js.map +1 -0
  211. package/lib/types/markdown/render.d.ts.map +1 -0
  212. package/lib/types/markdown/render.js.map +1 -0
  213. package/lib/types/markdown/useViewportHighlighting.d.ts.map +1 -0
  214. package/lib/types/markdown/useViewportHighlighting.js.map +1 -0
  215. package/lib/types/markdown/windows-path-destinations.d.ts.map +1 -0
  216. package/lib/types/markdown/windows-path-destinations.js.map +1 -0
  217. package/lib/types/menu-submenu-position.d.ts +15 -0
  218. package/lib/types/menu-submenu-position.d.ts.map +1 -0
  219. package/lib/types/menu-submenu-position.js.map +1 -0
  220. package/lib/types/overlay-top-margin.d.ts.map +1 -0
  221. package/lib/types/overlay-top-margin.js.map +1 -0
  222. package/lib/types/plugin-artwork.d.ts.map +1 -0
  223. package/lib/types/plugin-artwork.js.map +1 -0
  224. package/lib/types/pointer-grace.d.ts.map +1 -0
  225. package/lib/types/pointer-grace.js.map +1 -0
  226. package/lib/types/rank-by-name.d.ts.map +1 -0
  227. package/lib/types/rank-by-name.js.map +1 -0
  228. package/lib/types/relative-time.d.ts.map +1 -0
  229. package/lib/types/relative-time.js.map +1 -0
  230. package/lib/types/settings-form/SettingsForm.d.ts.map +1 -0
  231. package/lib/types/settings-form/SettingsForm.js.map +1 -0
  232. package/lib/types/settings-form/fields.d.ts.map +1 -0
  233. package/lib/types/settings-form/fields.js.map +1 -0
  234. package/lib/types/settings-form/form-model.d.ts.map +1 -0
  235. package/lib/types/settings-form/form-model.js.map +1 -0
  236. package/lib/types/tooltip-placement.d.ts.map +1 -0
  237. package/lib/types/tooltip-placement.js.map +1 -0
  238. package/lib/types/use-clipboard-copy.d.ts.map +1 -0
  239. package/lib/types/use-clipboard-copy.js.map +1 -0
  240. package/lib/types/useAnchoredMaxHeight.d.ts.map +1 -0
  241. package/lib/types/useAnchoredMaxHeight.js.map +1 -0
  242. package/lib/types/useDismissOnOutsidePointer.d.ts.map +1 -0
  243. package/lib/types/useDismissOnOutsidePointer.js.map +1 -0
  244. package/lib/types/useMenuSubmenu.d.ts +43 -0
  245. package/lib/types/useMenuSubmenu.d.ts.map +1 -0
  246. package/lib/types/useMenuSubmenu.js.map +1 -0
  247. package/lib/types/useModalLayer.d.ts.map +1 -0
  248. package/lib/types/useModalLayer.js.map +1 -0
  249. package/lib/types/useRowDragPreview.d.ts.map +1 -0
  250. package/lib/types/useRowDragPreview.js.map +1 -0
  251. package/lib/types/user-text.d.ts.map +1 -0
  252. package/lib/types/user-text.js.map +1 -0
  253. package/package.json +11 -8
  254. package/src/AnimatedRows.module.css +7 -0
  255. package/src/AnimatedRows.tsx +195 -0
  256. package/src/BrandWordmark.tsx +59 -0
  257. package/src/Button.module.css +84 -0
  258. package/src/Button.tsx +36 -0
  259. package/src/Checkbox.module.css +28 -0
  260. package/src/Checkbox.tsx +34 -0
  261. package/src/CodeCard.module.css +85 -0
  262. package/src/CodeFileIcon.tsx +28 -0
  263. package/src/CodeToolbar.tsx +62 -0
  264. package/src/CommandText.module.css +12 -0
  265. package/src/CommandText.tsx +46 -0
  266. package/src/ConfigField.module.css +12 -0
  267. package/src/ConfigField.tsx +53 -0
  268. package/src/ConnectionIndicator.module.css +120 -0
  269. package/src/ConnectionIndicator.tsx +103 -0
  270. package/src/DetailDocument.module.css +67 -0
  271. package/src/DetailDocument.tsx +120 -0
  272. package/src/DiffBlock.module.css +82 -0
  273. package/src/DiffBlock.tsx +221 -0
  274. package/src/DisclosureRow.module.css +115 -0
  275. package/src/DisclosureRow.tsx +124 -0
  276. package/src/DraggableImage.tsx +26 -0
  277. package/src/FileTypeIcon.module.css +50 -0
  278. package/src/FileTypeIcon.tsx +285 -0
  279. package/src/FishLogo.tsx +28 -0
  280. package/src/FoldToggle.tsx +33 -0
  281. package/src/HoverCard.module.css +108 -0
  282. package/src/HoverCard.tsx +356 -0
  283. package/src/HoverCardGroup.tsx +77 -0
  284. package/src/ImageLightbox.module.css +54 -0
  285. package/src/ImageLightbox.tsx +72 -0
  286. package/src/ImagePreview.module.css +24 -0
  287. package/src/ImagePreview.tsx +36 -0
  288. package/src/InlineEditor.module.css +23 -0
  289. package/src/InlineEditor.tsx +69 -0
  290. package/src/Input.module.css +38 -0
  291. package/src/Input.tsx +24 -0
  292. package/src/JsonTree.module.css +371 -0
  293. package/src/JsonTree.tsx +850 -0
  294. package/src/LinkIcon.tsx +118 -0
  295. package/src/Menu.module.css +443 -0
  296. package/src/Menu.tsx +553 -0
  297. package/src/MenuGroup.module.css +37 -0
  298. package/src/MenuGroup.tsx +103 -0
  299. package/src/MenuRow.tsx +89 -0
  300. package/src/MenuSurface.module.css +65 -0
  301. package/src/MenuSurface.tsx +54 -0
  302. package/src/Modal.module.css +147 -0
  303. package/src/Modal.tsx +96 -0
  304. package/src/PathLabel.module.css +28 -0
  305. package/src/PathLabel.tsx +41 -0
  306. package/src/PermissionIcon.tsx +119 -0
  307. package/src/Pill.module.css +30 -0
  308. package/src/Pill.tsx +36 -0
  309. package/src/QuotePreview.module.css +138 -0
  310. package/src/QuotePreview.tsx +133 -0
  311. package/src/ReadBlock.module.css +45 -0
  312. package/src/ReadBlock.tsx +151 -0
  313. package/src/ReferenceIcon.tsx +49 -0
  314. package/src/RiskConfirmation.module.css +47 -0
  315. package/src/RiskConfirmation.tsx +79 -0
  316. package/src/RowDragPreview.module.css +12 -0
  317. package/src/SearchBlock.module.css +114 -0
  318. package/src/SearchBlock.tsx +281 -0
  319. package/src/SegmentedControl.module.css +81 -0
  320. package/src/SegmentedControl.tsx +140 -0
  321. package/src/SegmentedTabs.module.css +77 -0
  322. package/src/SegmentedTabs.tsx +84 -0
  323. package/src/ShortcutKeys.module.css +33 -0
  324. package/src/ShortcutKeys.tsx +12 -0
  325. package/src/SiteGlyph.tsx +149 -0
  326. package/src/StateDot.module.css +100 -0
  327. package/src/StateDot.tsx +77 -0
  328. package/src/SubmenuPanel.tsx +51 -0
  329. package/src/Switch.module.css +49 -0
  330. package/src/Switch.tsx +42 -0
  331. package/src/Tag.module.css +57 -0
  332. package/src/Tag.tsx +42 -0
  333. package/src/TerminalBlock.module.css +207 -0
  334. package/src/TerminalBlock.tsx +294 -0
  335. package/src/TextShimmer.module.css +88 -0
  336. package/src/TextShimmer.tsx +58 -0
  337. package/src/Toast.module.css +102 -0
  338. package/src/Toast.tsx +101 -0
  339. package/src/Tooltip.module.css +68 -0
  340. package/src/Tooltip.tsx +273 -0
  341. package/src/UserMessageBubble.module.css +11 -0
  342. package/src/UserMessageBubble.tsx +16 -0
  343. package/src/WebBlock.module.css +153 -0
  344. package/src/WebBlock.tsx +196 -0
  345. package/src/ZoomControls.module.css +54 -0
  346. package/src/ZoomControls.tsx +92 -0
  347. package/src/ansi.ts +447 -0
  348. package/src/clipboard.ts +47 -0
  349. package/src/code-file-icon-artwork.manifest.json +71 -0
  350. package/src/code-file-icon-artwork.ts +60 -0
  351. package/src/code-file-types.ts +340 -0
  352. package/src/code-highlighting.ts +25 -0
  353. package/src/css-modules.d.ts +6 -0
  354. package/src/darwin-desktop.ts +11 -0
  355. package/src/document-zoom.ts +12 -0
  356. package/src/file-drag-actions.ts +29 -0
  357. package/src/file-size.ts +16 -0
  358. package/src/focus.ts +44 -0
  359. package/src/guide-artwork.tsx +32 -0
  360. package/src/head-tail-cap.ts +27 -0
  361. package/src/icons/artwork.ts +156 -0
  362. package/src/icons/index.tsx +634 -0
  363. package/src/icons/props.ts +8 -0
  364. package/src/icons/shared-artwork.tsx +71 -0
  365. package/src/image-drag.ts +84 -0
  366. package/src/index.ts +142 -0
  367. package/src/input-modality.ts +59 -0
  368. package/src/keyboard-composition.ts +36 -0
  369. package/src/markdown/CodeBlock.module.css +209 -0
  370. package/src/markdown/CodeBlock.tsx +268 -0
  371. package/src/markdown/FenceBlocks.tsx +51 -0
  372. package/src/markdown/JsonBlock.module.css +34 -0
  373. package/src/markdown/JsonBlock.tsx +36 -0
  374. package/src/markdown/MarkdownDelegate.tsx +102 -0
  375. package/src/markdown/MarkdownText.module.css +511 -0
  376. package/src/markdown/MarkdownText.tsx +218 -0
  377. package/src/markdown/cjkFriendlyStrong.ts +83 -0
  378. package/src/markdown/copy-tex.ts +53 -0
  379. package/src/markdown/diff-fence.ts +212 -0
  380. package/src/markdown/file-link.ts +45 -0
  381. package/src/markdown/highlight.ts +689 -0
  382. package/src/markdown/incremental.ts +360 -0
  383. package/src/markdown/katex.tsx +90 -0
  384. package/src/markdown/local-image-syntax.ts +29 -0
  385. package/src/markdown/mathCompatibility.ts +349 -0
  386. package/src/markdown/parse.ts +49 -0
  387. package/src/markdown/plain-text.ts +121 -0
  388. package/src/markdown/quote-text.ts +10 -0
  389. package/src/markdown/render.tsx +834 -0
  390. package/src/markdown/useViewportHighlighting.ts +72 -0
  391. package/src/markdown/windows-path-destinations.ts +34 -0
  392. package/src/menu-submenu-position.ts +20 -0
  393. package/src/overlay-top-margin.ts +18 -0
  394. package/src/plugin-artwork.tsx +110 -0
  395. package/src/pointer-grace.ts +47 -0
  396. package/src/rank-by-name.ts +93 -0
  397. package/src/relative-time.ts +36 -0
  398. package/src/settings-form/SettingsForm.module.css +53 -0
  399. package/src/settings-form/SettingsForm.tsx +74 -0
  400. package/src/settings-form/fields.module.css +153 -0
  401. package/src/settings-form/fields.tsx +151 -0
  402. package/src/settings-form/form-model.ts +393 -0
  403. package/src/tooltip-placement.ts +60 -0
  404. package/src/use-clipboard-copy.ts +44 -0
  405. package/src/useAnchoredMaxHeight.ts +45 -0
  406. package/src/useDismissOnOutsidePointer.ts +34 -0
  407. package/src/useMenuSubmenu.ts +182 -0
  408. package/src/useModalLayer.ts +108 -0
  409. package/src/useRowDragPreview.ts +76 -0
  410. package/src/user-text.module.css +46 -0
  411. package/src/user-text.tsx +67 -0
  412. package/lib/types/useAnchoredPosition.d.ts +0 -36
@@ -0,0 +1,268 @@
1
+ import { Fragment, useCallback, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
+ import type { CSSProperties, ReactNode, Ref } from 'react'
3
+ import clsx from 'clsx'
4
+ import { writeClipboard } from '../clipboard.ts'
5
+ import { CodeToolbar, type CodeToolbarLabels } from '../CodeToolbar.tsx'
6
+ import {
7
+ diffFenceTokens, isDiffContent, isDiffFenceLanguage, parseDiffFence,
8
+ } from './diff-fence.ts'
9
+ import type { DiffRow } from './diff-fence.ts'
10
+ import {
11
+ StreamingHighlightSession, grammarLoadCount, highlightToHtml, subscribeGrammarLoaded,
12
+ } from './highlight.ts'
13
+ import type { HighlightSpan, StreamingHighlightFrame } from './highlight.ts'
14
+ import { useViewportHighlighting } from './useViewportHighlighting.ts'
15
+ import css from './CodeBlock.module.css'
16
+
17
+ export interface CodeBlockProps {
18
+ /** The source text, rendered verbatim (trailing newline trimmed for display). */
19
+ code: string
20
+ /** Grammar hint (markdown fence info string or a fixed caller id); unknown = plain. */
21
+ lang?: string | undefined
22
+ /**
23
+ * Render unified-diff rows: row colors by marker column, and each file's
24
+ * removed and added sides tokenized with the language its header names.
25
+ * Omitted, a `diff` or `patch` `lang` selects them; `true` or `false` forces
26
+ * the choice for any `lang`.
27
+ */
28
+ diff?: boolean | undefined
29
+ /**
30
+ * The code is still growing (a streaming markdown fence): highlight through
31
+ * a per-instance {@link StreamingHighlightSession}, which re-tokenizes only
32
+ * appended text and keeps completed line groups (and DOM) untouched. The
33
+ * caller must keep the component instance stable across growth (a
34
+ * stream-stable React key); an unchanged streamed fence also retains that
35
+ * tree when it settles. Cold settled callers get shiki's HTML.
36
+ */
37
+ streaming?: boolean | undefined
38
+ /** Extra class merged onto the wrapper (callers position; this component draws). */
39
+ className?: string | undefined
40
+ /** Ref for the stable source-content wrapper, for owners that use it as a scrollport. */
41
+ contentRef?: Ref<HTMLDivElement> | undefined
42
+ /** Show a numbered gutter without adding numbers to copied source. Defaults to false. */
43
+ lineNumbers?: boolean | undefined
44
+ /** Show the language and copy header; false when the caller supplies a toolbar. Defaults to true. */
45
+ showHeader?: boolean | undefined
46
+ /** Copy-button idle label; the owner passes localized copy (this package is cordis-free, so copy arrives via props). */
47
+ copyLabel: string
48
+ /** Copy-button label during the post-copy confirmation window. */
49
+ copiedLabel: string
50
+ /** Enable the shared card toolbar and spacing; omit for custom toolbar layouts. */
51
+ toolbarLabels?: CodeToolbarLabels | undefined
52
+ /** With toolbarLabels, use the owner's wrapping preference and omit the toolbar's local wrap action. */
53
+ wrap?: boolean | undefined
54
+ }
55
+
56
+ /**
57
+ * The `pre` attributes shiki's HTML arm emits for the css-variables theme,
58
+ * mirrored so the streaming arm's tree is interchangeable with the settled
59
+ * swap (`tests/streaming-code-block.client.spec.tsx` pins the two arms'
60
+ * parity).
61
+ */
62
+ const SHIKI_PRE_PROPS = {
63
+ className: 'shiki css-variables',
64
+ style: { backgroundColor: 'var(--shiki-background)', color: 'var(--shiki-foreground)' },
65
+ tabIndex: 0,
66
+ } as const
67
+
68
+ /** Completed-line group size; React reconciles groups while the DOM remains line-for-line identical. */
69
+ const STREAMING_LINE_GROUP_SIZE = 32
70
+
71
+ /** Line class per row kind; context rows keep the block's default ink. */
72
+ const DIFF_ROW_CLASS: Record<DiffRow['kind'], string | undefined> = {
73
+ add: css.diffAdd,
74
+ del: css.diffDel,
75
+ hunk: css.diffHunk,
76
+ meta: css.diffMeta,
77
+ context: css.diffContext,
78
+ }
79
+
80
+ /** One diff row: optional marker column, then the body with its token colors. */
81
+ function renderDiffRow(row: DiffRow, index: number, tokens: readonly HighlightSpan[] | undefined): ReactNode {
82
+ const kindClass = DIFF_ROW_CLASS[row.kind]
83
+ return (
84
+ <Fragment key={index}>
85
+ {index > 0 && '\n'}
86
+ <span className={clsx('line', css.diffLine, kindClass)}>
87
+ {isDiffContent(row)
88
+ ? <Fragment>
89
+ <span className={css.diffMarker}>{row.marker}</span>
90
+ {tokens === undefined
91
+ ? row.body
92
+ : tokens.map((span, spanIndex) => <span key={spanIndex} style={span.style}>{span.text}</span>)}
93
+ </Fragment>
94
+ : row.raw}
95
+ </span>
96
+ </Fragment>
97
+ )
98
+ }
99
+
100
+ function renderLine(line: readonly HighlightSpan[], index: number): ReactNode {
101
+ return (
102
+ <Fragment key={index}>
103
+ {index > 0 && '\n'}
104
+ <span className="line">
105
+ {line.map((span, spanIndex) => <span key={spanIndex} style={span.style}>{span.text}</span>)}
106
+ </span>
107
+ </Fragment>
108
+ )
109
+ }
110
+
111
+ export function CodeBlock({
112
+ code, lang, diff, streaming, className, contentRef, lineNumbers = false, showHeader = true, copyLabel, copiedLabel, toolbarLabels, wrap,
113
+ }: CodeBlockProps) {
114
+ const trimmed = code.endsWith('\n') ? code.slice(0, -1) : code
115
+ const diffRows = useMemo(() => ((diff ?? isDiffFenceLanguage(lang)) ? parseDiffFence(trimmed) : undefined),
116
+ [trimmed, lang, diff])
117
+ const sourceLines = lineNumbers ? trimmed.split('\n') : undefined
118
+ const rootRef = useRef<HTMLDivElement>(null)
119
+ // Diff rows join the same viewport gate as grammar-highlighted fences, so an
120
+ // off-screen fence paints its row colors without tokenizing the body.
121
+ const highlighting = useViewportHighlighting(rootRef, diffRows === undefined ? lang : 'diff')
122
+ // Re-render when a lazy grammar finishes loading, so a fence that showed plain
123
+ // text while its language's grammar imported picks up highlighting. The
124
+ // snapshot value is opaque; only its change across renders drives the memo.
125
+ const loaded = useSyncExternalStore(subscribeGrammarLoaded, grammarLoadCount, grammarLoadCount)
126
+ // Each file's old and new sides are tokenized separately; a growing fence
127
+ // re-tokenizes per chunk because that grouping has no incremental path, and
128
+ // diffs in a fence are short enough to accept it.
129
+ const diffTokens = useMemo(
130
+ () => (diffRows === undefined || !highlighting ? undefined : diffFenceTokens(diffRows)),
131
+ [diffRows, highlighting, loaded],
132
+ )
133
+ // Streaming state lives in refs mutated inside the memo (the MarkdownText
134
+ // streaming-cache pattern): the session's caches carry across chunks only
135
+ // because the owner keys this instance stably while the fence grows.
136
+ const sessionRef = useRef<StreamingHighlightSession | null>(null)
137
+ const lineCacheRef = useRef<{
138
+ code: string
139
+ lang: string | undefined
140
+ generation: number
141
+ frame: StreamingHighlightFrame
142
+ groups: ReactNode[]
143
+ pending: ReactNode[]
144
+ nextLine: number
145
+ body: ReactNode
146
+ } | null>(null)
147
+ const settledRef = useRef(false)
148
+ const streamedBody = useMemo(() => {
149
+ // A diff fence draws its own rows; the session's single-language stream is unused.
150
+ if (!highlighting || diffRows !== undefined) {
151
+ sessionRef.current = null
152
+ lineCacheRef.current = null
153
+ settledRef.current = false
154
+ return undefined
155
+ }
156
+ if (streaming !== true) {
157
+ const previous = lineCacheRef.current
158
+ if (previous !== null && previous.code === trimmed && previous.lang === lang) {
159
+ settledRef.current = true
160
+ return previous.body
161
+ }
162
+ sessionRef.current = null
163
+ lineCacheRef.current = null
164
+ settledRef.current = true
165
+ return undefined
166
+ }
167
+ if (settledRef.current) {
168
+ sessionRef.current = null
169
+ lineCacheRef.current = null
170
+ settledRef.current = false
171
+ }
172
+ sessionRef.current ??= new StreamingHighlightSession()
173
+ const frame = sessionRef.current.updateFrame(trimmed, lang)
174
+ if (frame === undefined) {
175
+ lineCacheRef.current = null
176
+ return undefined
177
+ }
178
+ const previous = lineCacheRef.current
179
+ if (previous?.frame === frame && previous.code === trimmed && previous.lang === lang) {
180
+ return previous.body
181
+ }
182
+ const sameGeneration = previous?.generation === frame.generation
183
+ const groups = sameGeneration ? [...previous.groups] : []
184
+ let pending = sameGeneration ? [...previous.pending] : []
185
+ let nextLine = sameGeneration ? previous.nextLine : 0
186
+ for (const line of frame.appended) {
187
+ pending.push(renderLine(line, nextLine))
188
+ nextLine += 1
189
+ if (pending.length !== STREAMING_LINE_GROUP_SIZE) continue
190
+ const start = nextLine - pending.length
191
+ groups.push(<Fragment key={start}>{pending}</Fragment>)
192
+ pending = []
193
+ }
194
+ const tail = frame.tail.map((line, index) => renderLine(line, nextLine + index))
195
+ const tailGroup = <Fragment key={nextLine - pending.length}>{[...pending, ...tail]}</Fragment>
196
+ const body = <pre {...SHIKI_PRE_PROPS}><code>{groups}{tailGroup}</code></pre>
197
+ lineCacheRef.current = {
198
+ code: trimmed, lang, generation: frame.generation, frame, groups, pending, nextLine, body,
199
+ }
200
+ return body
201
+ }, [streaming, highlighting, diffRows, trimmed, lang, loaded])
202
+ const html = useMemo(
203
+ () => (diffRows === undefined && highlighting && streaming !== true && streamedBody === undefined
204
+ ? highlightToHtml(trimmed, lang)
205
+ : undefined),
206
+ [diffRows, streaming, highlighting, streamedBody, trimmed, lang, loaded],
207
+ )
208
+ const [copied, setCopied] = useState(false)
209
+ const [localWrapped, setWrapped] = useState(true)
210
+ const wrapped = wrap ?? localWrapped
211
+
212
+ const onCopy = useCallback(() => {
213
+ if (copied) return
214
+ /* v8 ignore next -- both arms always mount a <pre>; trimmed is the
215
+ typed fallback if the DOM shape ever diverges. */
216
+ const text = rootRef.current?.querySelector('pre')?.textContent ?? trimmed
217
+ void writeClipboard(text).then((ok) => {
218
+ if (!ok) return
219
+ setCopied(true)
220
+ window.setTimeout(() => { setCopied(false) }, 1000)
221
+ })
222
+ }, [copied, trimmed])
223
+
224
+ // shiki's HTML output is a static span tree it generated from `code` (no
225
+ // user HTML passes through), the sanctioned innerHTML consumption path per
226
+ // shiki's own docs.
227
+ const body = diffRows !== undefined
228
+ ? (
229
+ <pre className={css.plain}><code>{diffRows.rows.map((row, index) => renderDiffRow(row, index, diffTokens?.get(index)))}</code></pre>
230
+ )
231
+ : streamedBody !== undefined
232
+ ? streamedBody
233
+ : html === undefined
234
+ ? (
235
+ <pre className={css.plain}><code>{sourceLines === undefined ? trimmed : sourceLines.map((line, index) => (
236
+ <Fragment key={index}>{index > 0 && '\n'}<span className="line">{line}</span></Fragment>
237
+ ))}</code></pre>
238
+ )
239
+ : (
240
+ <div dangerouslySetInnerHTML={{ __html: html }} />
241
+ )
242
+
243
+ return (
244
+ <div ref={rootRef} className={clsx(css.block, 'md-code-block', lineNumbers && css.numbered, diffRows !== undefined && !lineNumbers && css.diffFence, toolbarLabels !== undefined && css.card, className)}
245
+ data-line-numbers={lineNumbers || undefined}
246
+ data-code-wrap={toolbarLabels === undefined ? undefined : wrapped}
247
+ style={sourceLines === undefined ? undefined : {
248
+ '--dsl-code-block-line-number-width': `${Math.max(2, String(sourceLines.length).length)}ch`,
249
+ } as CSSProperties}>
250
+ {/* These paired attributes are stable semantic hooks for owner styling and DOM tests. */}
251
+ {showHeader && <div className={css.bannerWrap}>
252
+ {toolbarLabels !== undefined ? <CodeToolbar
253
+ lang={lang} labels={toolbarLabels} copyLabel={copyLabel} copiedLabel={copiedLabel}
254
+ copied={copied} wrapped={wrapped} onCopy={onCopy}
255
+ onWrap={wrap === undefined ? () => { setWrapped(value => !value) } : undefined}
256
+ /> : <div className={css.banner} data-code-block-banner>
257
+ <div className={css.infostring} data-text-interaction-exclude="">{lang ?? ''}</div>
258
+ <div className={css.action}>
259
+ <button type="button" className={css.copyButton} onClick={onCopy}>
260
+ {copied ? copiedLabel : copyLabel}
261
+ </button>
262
+ </div>
263
+ </div>}
264
+ </div>}
265
+ <div ref={contentRef} className={css.content} data-code-block-content>{body}</div>
266
+ </div>
267
+ )
268
+ }
@@ -0,0 +1,51 @@
1
+ /** Fence presets: the code and math blocks a Markdown document renders for one fence. */
2
+ import type { ReactNode } from 'react'
3
+ import { CodeBlock } from './CodeBlock.tsx'
4
+ import { renderTexToReact } from './katex.tsx'
5
+ import type { MarkdownCodeLabels } from './render.tsx'
6
+
7
+ /** Inputs of {@link FenceCodeBlock}. */
8
+ export interface FenceCodeBlockProps {
9
+ /** Grammar hint and banner text; omitted renders plain code. */
10
+ lang?: string | undefined
11
+ /** The fence body without its closing newline. */
12
+ code: string
13
+ /** The surrounding document is still streaming; the block keeps its instance as `code` grows. */
14
+ streaming: boolean
15
+ /** Localized code-block chrome. */
16
+ labels: MarkdownCodeLabels
17
+ /** Unified-diff rows; omitted follows `lang` as {@link CodeBlock} does. */
18
+ diff?: boolean | undefined
19
+ }
20
+
21
+ /**
22
+ * Render one fence body as a code block.
23
+ * @param props - fence language, body, streaming state, chrome labels, and diff choice.
24
+ * @returns the code block.
25
+ */
26
+ export function FenceCodeBlock({ lang, code, streaming, labels, diff }: FenceCodeBlockProps): ReactNode {
27
+ return (
28
+ <CodeBlock
29
+ // The replaced hast pipeline appended one synthetic newline that
30
+ // CodeBlock's display trim removes; feeding the bare value would make
31
+ // that trim eat a REAL trailing blank line inside the fence instead.
32
+ code={`${code}\n`}
33
+ lang={lang}
34
+ streaming={streaming}
35
+ diff={diff}
36
+ copyLabel={labels.copyLabel}
37
+ copiedLabel={labels.copiedLabel}
38
+ toolbarLabels={labels.toolbarLabels}
39
+ />
40
+ )
41
+ }
42
+
43
+ /**
44
+ * Render one `math` fence body as display TeX.
45
+ * @param props - the fence body without its closing newline.
46
+ * @returns the typeset formula.
47
+ */
48
+ export function FenceMathBlock({ code }: { code: string }): ReactNode {
49
+ // rehype-katex parity: its text extraction saw the code block's trailing newline.
50
+ return <>{renderTexToReact(`${code}\n`, true)}</>
51
+ }
@@ -0,0 +1,34 @@
1
+ .root {
2
+ margin: 4px 0;
3
+ }
4
+
5
+ .toggle {
6
+ font-size: 12px;
7
+ line-height: 18px;
8
+ color: var(--dsw-alias-label-secondary);
9
+ padding: 2px 6px;
10
+ border: none;
11
+ background: transparent;
12
+ cursor: pointer;
13
+ border-radius: var(--dsw-radius-sm);
14
+ }
15
+
16
+ @media (hover: hover) {
17
+ .toggle:hover {
18
+ background: var(--dsw-alias-interactive-bg-hover);
19
+ }
20
+ }
21
+
22
+ .body {
23
+ margin: 4px 0 0;
24
+ padding: 8px;
25
+ max-height: 200px;
26
+ overflow: auto;
27
+ background: var(--dsw-alias-markdown-code-block);
28
+ border: 0.5px solid var(--dsw-alias-border-l1);
29
+ border-radius: var(--dsw-radius-lg);
30
+ font-family: var(--ds-font-family-code);
31
+ font-size: 11px;
32
+ line-height: 16px;
33
+ color: var(--dsw-alias-label-primary);
34
+ }
@@ -0,0 +1,36 @@
1
+ // JsonBlock: collapsible JSON block (conversation side; independent from the RPC panel's PayloadJson to avoid cross-panel coupling).
2
+
3
+ import { useMemo, useState } from 'react'
4
+ import css from './JsonBlock.module.css'
5
+
6
+ const MAX_CHARS = 20_000
7
+
8
+ export function JsonBlock({ label, payload, defaultOpen = false, truncatedLabel }: {
9
+ label: string
10
+ payload: unknown
11
+ defaultOpen?: boolean
12
+ /** Footer appended when the body exceeds the char cap, given the full length (this package is cordis-free, so copy arrives via props). */
13
+ truncatedLabel: (total: number) => string
14
+ }) {
15
+ const [open, setOpen] = useState(defaultOpen)
16
+ const body = useMemo(() => {
17
+ if (!open) return ''
18
+ let s: string
19
+ try {
20
+ // lib typing hides stringify's undefined arm (undefined/function/symbol payloads).
21
+ // oxlint-disable-next-line typescript/no-unnecessary-condition
22
+ s = JSON.stringify(payload, null, 2) ?? String(payload)
23
+ } catch {
24
+ s = String(payload)
25
+ }
26
+ return s.length > MAX_CHARS ? `${s.slice(0, MAX_CHARS)}\n${truncatedLabel(s.length)}` : s
27
+ }, [open, payload, truncatedLabel])
28
+ return (
29
+ <div className={css.root}>
30
+ <button type="button" className={css.toggle} onClick={() => { setOpen(v => !v) }}>
31
+ {open ? '▾' : '▸'} {label}
32
+ </button>
33
+ {open && <pre className={css.body}>{body}</pre>}
34
+ </div>
35
+ )
36
+ }
@@ -0,0 +1,102 @@
1
+ /** Consumer-owned navigation for Markdown links. */
2
+ import { createContext, useContext, useMemo } from 'react'
3
+ import type { HTMLAttributes, ReactNode } from 'react'
4
+ import type { FileDragActions } from '../file-drag-actions.ts'
5
+ import type { ImageLightboxLabels } from '../ImageLightbox.tsx'
6
+
7
+ /**
8
+ * Handle one sanitized absolute HTTP(S) URL selected from Markdown.
9
+ * @param href - destination URL.
10
+ */
11
+ export type MarkdownExternalLinkHandler = (href: string) => void
12
+
13
+ /** Explicit object and viewport coordinates from the element owning a context gesture. */
14
+ export type MarkdownMenuTarget =
15
+ | { kind: 'file'; path: string; line?: number }
16
+ | { kind: 'url'; url: string }
17
+ | { kind: 'image'; url: string; path?: string; name?: string; mediaType?: string }
18
+
19
+ /** One Markdown code fence whose language is final, as {@link MarkdownDelegate.renderCode} receives it. */
20
+ export interface MarkdownDelegateFenceInfo {
21
+ /**
22
+ * The info string's language word, cut at its first character outside
23
+ * letters, digits, `_`, and `-`, then lowercased (`c++` yields `c`).
24
+ */
25
+ readonly lang: string
26
+ /** The fence body without its closing newline. */
27
+ readonly code: string
28
+ /** The surrounding document is still streaming, so `code` may still change. */
29
+ readonly streaming: boolean
30
+ /** The info string after the language word, as the author wrote it; absent when the fence names only a language. */
31
+ readonly meta?: string | undefined
32
+ }
33
+
34
+ /** Navigation capabilities supplied by the nearest Markdown owner. */
35
+ export interface MarkdownDelegate {
36
+ /** Open an object menu without executing its normal activation. */
37
+ readonly getTriggerProps?: ((target: MarkdownMenuTarget) => Pick<HTMLAttributes<HTMLElement>, 'onContextMenu' | 'onKeyDown' | 'tabIndex'>) | undefined
38
+ /**
39
+ * Image previews for decoded local paths in this owner's workspace. The renderer
40
+ * appends a per-mount `load` query parameter to `api/file` route URLs.
41
+ */
42
+ readonly fileImages?: {
43
+ fileDrag: FileDragActions
44
+ resolve: (path: string) => string | undefined
45
+ resourceAddress?: ((path: string) => string) | undefined
46
+ labels: ImageLightboxLabels & { open: string; loading: string; failed: string }
47
+ } | undefined
48
+ /** Ordinary HTTP(S) activation; absent handlers retain native anchor behavior. */
49
+ readonly openExternalLink?: MarkdownExternalLinkHandler | undefined
50
+ /**
51
+ * Open a decoded local destination from settled Markdown; absent handlers leave plain text.
52
+ * @param path - Absolute or workspace-relative file path.
53
+ * @param options - First line to reveal when the destination specifies a line or range.
54
+ */
55
+ readonly openFile?: ((path: string, options?: { line?: number }) => void) | undefined
56
+ /**
57
+ * Render one fence whose language is final: it has a language and content.
58
+ * Absent, the document renders fences with its built-in code and math blocks;
59
+ * present, the owner renders every such fence, including `diff` and `math`.
60
+ * @param fence - language, body, and streaming state.
61
+ * @returns the rendered block.
62
+ */
63
+ readonly renderCode?: ((fence: MarkdownDelegateFenceInfo) => ReactNode) | undefined
64
+ }
65
+
66
+ const MarkdownDelegateContext = createContext<MarkdownDelegate>({})
67
+
68
+ /** Props for one Markdown navigation scope. */
69
+ export interface MarkdownDelegateProviderProps extends MarkdownDelegate {
70
+ readonly children: ReactNode
71
+ }
72
+
73
+ /**
74
+ * Scope Markdown navigation without threading callbacks through renderers.
75
+ * Nested providers replace the enclosing capabilities. Handler changes reach cached links.
76
+ * @param props - Child tree and its file and HTTP(S) link handlers.
77
+ * @returns the scoped child tree.
78
+ */
79
+ export function MarkdownDelegateProvider({
80
+ children,
81
+ openExternalLink,
82
+ openFile,
83
+ fileImages,
84
+ getTriggerProps,
85
+ renderCode,
86
+ }: MarkdownDelegateProviderProps): ReactNode {
87
+ const delegate = useMemo(() => ({ openExternalLink, openFile, fileImages, getTriggerProps, renderCode }),
88
+ [openExternalLink, openFile, fileImages, getTriggerProps, renderCode])
89
+ return (
90
+ <MarkdownDelegateContext.Provider value={delegate}>
91
+ {children}
92
+ </MarkdownDelegateContext.Provider>
93
+ )
94
+ }
95
+
96
+ /**
97
+ * Read the nearest Markdown navigation capabilities.
98
+ * @returns Owner callbacks, or an empty delegate outside a provider.
99
+ */
100
+ export function useMarkdownDelegate(): MarkdownDelegate {
101
+ return useContext(MarkdownDelegateContext)
102
+ }