@delali/web-editor 0.0.0-stage → 0.4.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 (476) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +201 -0
  3. package/README.md +167 -2
  4. package/dist/components/editor/chat-comment-effects.d.ts +2 -0
  5. package/dist/components/editor/chat-types.d.ts +20 -0
  6. package/dist/components/editor/collaboration/base-collaboration-plugin.d.ts +14 -0
  7. package/dist/components/editor/collaboration/collaboration-plugin.d.ts +6 -0
  8. package/dist/components/editor/collaboration/collaboration-session.d.ts +30 -0
  9. package/dist/components/editor/collaboration/collaboration-starter.d.ts +9 -0
  10. package/dist/components/editor/collaboration/editor-collaboration.d.ts +16 -0
  11. package/dist/components/editor/collaboration/editor-collaboration.js +293 -0
  12. package/dist/components/editor/collaboration/remote-cursor-overlay.d.ts +1 -0
  13. package/dist/components/editor/collaboration/shared-document.d.ts +18 -0
  14. package/dist/components/editor/create-editor-plugins.d.ts +3 -0
  15. package/dist/components/editor/create-editor-plugins.js +25204 -0
  16. package/dist/components/editor/create-viewer-plugins.d.ts +3 -0
  17. package/dist/components/editor/editor-base-kit.d.ts +329 -0
  18. package/dist/components/editor/editor-base-kit.js +3136 -0
  19. package/dist/components/editor/editor-config.d.ts +14 -0
  20. package/dist/components/editor/editor-config.js +145 -0
  21. package/dist/components/editor/editor-kit.d.ts +3978 -0
  22. package/dist/components/editor/editor-kit.js +18781 -0
  23. package/dist/components/editor/plate-types.d.ts +99 -0
  24. package/dist/components/editor/plugins/accordion-group-base-kit.d.ts +2 -0
  25. package/dist/components/editor/plugins/accordion-group-kit.d.ts +3 -0
  26. package/dist/components/editor/plugins/accordion-types.d.ts +14 -0
  27. package/dist/components/editor/plugins/ai-kit.d.ts +248 -0
  28. package/dist/components/editor/plugins/align-base-kit.d.ts +3 -0
  29. package/dist/components/editor/plugins/api-doc/expandable-base-kit.d.ts +24 -0
  30. package/dist/components/editor/plugins/api-doc/expandable-kit.d.ts +29 -0
  31. package/dist/components/editor/plugins/api-doc/expandable-types.d.ts +7 -0
  32. package/dist/components/editor/plugins/api-doc/panel-base-kit.d.ts +2 -0
  33. package/dist/components/editor/plugins/api-doc/panel-kit.d.ts +3 -0
  34. package/dist/components/editor/plugins/api-doc/panel-types.d.ts +7 -0
  35. package/dist/components/editor/plugins/api-doc/response-field-base-kit.d.ts +3 -0
  36. package/dist/components/editor/plugins/api-doc/response-field-kit.d.ts +4 -0
  37. package/dist/components/editor/plugins/api-doc/response-field-types.d.ts +17 -0
  38. package/dist/components/editor/plugins/autoformat-kit.d.ts +1 -0
  39. package/dist/components/editor/plugins/badge-base-kit.d.ts +2 -0
  40. package/dist/components/editor/plugins/badge-kit.d.ts +3 -0
  41. package/dist/components/editor/plugins/badge-types.d.ts +24 -0
  42. package/dist/components/editor/plugins/banner-base-kit.d.ts +2 -0
  43. package/dist/components/editor/plugins/banner-kit.d.ts +3 -0
  44. package/dist/components/editor/plugins/banner-types.d.ts +15 -0
  45. package/dist/components/editor/plugins/basic-blocks-base-kit.d.ts +5 -0
  46. package/dist/components/editor/plugins/basic-blocks-kit.d.ts +5 -0
  47. package/dist/components/editor/plugins/basic-marks-base-kit.d.ts +19 -0
  48. package/dist/components/editor/plugins/basic-marks-kit.d.ts +35 -0
  49. package/dist/components/editor/plugins/basic-nodes-kit.d.ts +21 -0
  50. package/dist/components/editor/plugins/block-menu-kit.d.ts +165 -0
  51. package/dist/components/editor/plugins/block-placeholder-kit.d.ts +14 -0
  52. package/dist/components/editor/plugins/block-selection-kit.d.ts +137 -0
  53. package/dist/components/editor/plugins/callout-base-kit.d.ts +20 -0
  54. package/dist/components/editor/plugins/callout-kit.d.ts +20 -0
  55. package/dist/components/editor/plugins/callout-types.d.ts +18 -0
  56. package/dist/components/editor/plugins/card-base-kit.d.ts +2 -0
  57. package/dist/components/editor/plugins/card-kit.d.ts +3 -0
  58. package/dist/components/editor/plugins/card-types.d.ts +14 -0
  59. package/dist/components/editor/plugins/caret-placement-kit.d.ts +8 -0
  60. package/dist/components/editor/plugins/code-block-base-kit.d.ts +7 -0
  61. package/dist/components/editor/plugins/code-block-input-rule-gate.d.ts +4 -0
  62. package/dist/components/editor/plugins/code-block-kit.d.ts +7 -0
  63. package/dist/components/editor/plugins/color-base-kit.d.ts +2 -0
  64. package/dist/components/editor/plugins/color-kit.d.ts +3 -0
  65. package/dist/components/editor/plugins/color-types.d.ts +18 -0
  66. package/dist/components/editor/plugins/column-base-kit.d.ts +1 -0
  67. package/dist/components/editor/plugins/column-kit.d.ts +1 -0
  68. package/dist/components/editor/plugins/comment-base-kit.d.ts +47 -0
  69. package/dist/components/editor/plugins/comment-kit.d.ts +71 -0
  70. package/dist/components/editor/plugins/copilot-kit.d.ts +72 -0
  71. package/dist/components/editor/plugins/cursor-overlay-kit.d.ts +11 -0
  72. package/dist/components/editor/plugins/date-base-kit.d.ts +19 -0
  73. package/dist/components/editor/plugins/date-kit.d.ts +19 -0
  74. package/dist/components/editor/plugins/discussion-kit.d.ts +31 -0
  75. package/dist/components/editor/plugins/dnd-kit.d.ts +20 -0
  76. package/dist/components/editor/plugins/docx-kit.d.ts +1 -0
  77. package/dist/components/editor/plugins/emoji-kit.d.ts +9 -0
  78. package/dist/components/editor/plugins/exit-break-kit.d.ts +4 -0
  79. package/dist/components/editor/plugins/floating-toolbar-kit.d.ts +1 -0
  80. package/dist/components/editor/plugins/font-base-kit.d.ts +9 -0
  81. package/dist/components/editor/plugins/font-kit.d.ts +9 -0
  82. package/dist/components/editor/plugins/fraction-input-rule.d.ts +12 -0
  83. package/dist/components/editor/plugins/frame-base-kit.d.ts +2 -0
  84. package/dist/components/editor/plugins/frame-kit.d.ts +3 -0
  85. package/dist/components/editor/plugins/frame-types.d.ts +10 -0
  86. package/dist/components/editor/plugins/icon-base-kit.d.ts +2 -0
  87. package/dist/components/editor/plugins/icon-kit.d.ts +3 -0
  88. package/dist/components/editor/plugins/icon-types.d.ts +15 -0
  89. package/dist/components/editor/plugins/indent-base-kit.d.ts +1 -0
  90. package/dist/components/editor/plugins/indent-kit.d.ts +5 -0
  91. package/dist/components/editor/plugins/input-rule-gate.d.ts +8 -0
  92. package/dist/components/editor/plugins/line-height-base-kit.d.ts +3 -0
  93. package/dist/components/editor/plugins/link-base-kit.d.ts +2 -0
  94. package/dist/components/editor/plugins/link-kit.d.ts +89 -0
  95. package/dist/components/editor/plugins/list-base-kit.d.ts +1 -0
  96. package/dist/components/editor/plugins/list-kit.d.ts +16 -0
  97. package/dist/components/editor/plugins/mark-input-rule-gate.d.ts +2 -0
  98. package/dist/components/editor/plugins/markdown-kit.d.ts +19 -0
  99. package/dist/components/editor/plugins/math-base-kit.d.ts +9 -0
  100. package/dist/components/editor/plugins/math-kit.d.ts +9 -0
  101. package/dist/components/editor/plugins/media-base-kit.d.ts +25 -0
  102. package/dist/components/editor/plugins/media-kit.d.ts +38 -0
  103. package/dist/components/editor/plugins/mention-base-kit.d.ts +11 -0
  104. package/dist/components/editor/plugins/mention-kit.d.ts +11 -0
  105. package/dist/components/editor/plugins/mermaid-base-kit.d.ts +2 -0
  106. package/dist/components/editor/plugins/mermaid-kit.d.ts +3 -0
  107. package/dist/components/editor/plugins/mermaid-types.d.ts +14 -0
  108. package/dist/components/editor/plugins/shared/color-selector.d.ts +9 -0
  109. package/dist/components/editor/plugins/shared/component-popover.d.ts +12 -0
  110. package/dist/components/editor/plugins/slash-kit.d.ts +1 -0
  111. package/dist/components/editor/plugins/steps-base-kit.d.ts +3 -0
  112. package/dist/components/editor/plugins/steps-kit.d.ts +4 -0
  113. package/dist/components/editor/plugins/steps-types.d.ts +18 -0
  114. package/dist/components/editor/plugins/suggestion-base-kit.d.ts +32 -0
  115. package/dist/components/editor/plugins/suggestion-kit.d.ts +53 -0
  116. package/dist/components/editor/plugins/tabbed-code-block-base-kit.d.ts +32 -0
  117. package/dist/components/editor/plugins/tabbed-code-block-kit.d.ts +33 -0
  118. package/dist/components/editor/plugins/tabbed-code-block-types.d.ts +29 -0
  119. package/dist/components/editor/plugins/table-base-kit.d.ts +94 -0
  120. package/dist/components/editor/plugins/table-kit.d.ts +162 -0
  121. package/dist/components/editor/plugins/tabs-base-kit.d.ts +2 -0
  122. package/dist/components/editor/plugins/tabs-kit.d.ts +3 -0
  123. package/dist/components/editor/plugins/tabs-types.d.ts +14 -0
  124. package/dist/components/editor/plugins/text-substitution-input-rule-gate.d.ts +4 -0
  125. package/dist/components/editor/plugins/tiles-base-kit.d.ts +3 -0
  126. package/dist/components/editor/plugins/tiles-kit.d.ts +4 -0
  127. package/dist/components/editor/plugins/tiles-types.d.ts +16 -0
  128. package/dist/components/editor/plugins/toc-base-kit.d.ts +1 -0
  129. package/dist/components/editor/plugins/toc-kit.d.ts +5 -0
  130. package/dist/components/editor/plugins/todo-to-bullet-kit.d.ts +7 -0
  131. package/dist/components/editor/plugins/toggle-base-kit.d.ts +12 -0
  132. package/dist/components/editor/plugins/toggle-kit.d.ts +16 -0
  133. package/dist/components/editor/plugins/tooltip-base-kit.d.ts +2 -0
  134. package/dist/components/editor/plugins/tooltip-html.d.ts +27 -0
  135. package/dist/components/editor/plugins/tooltip-kit.d.ts +3 -0
  136. package/dist/components/editor/plugins/tooltip-types.d.ts +10 -0
  137. package/dist/components/editor/plugins/tree-base-kit.d.ts +2 -0
  138. package/dist/components/editor/plugins/tree-kit.d.ts +3 -0
  139. package/dist/components/editor/plugins/tree-types.d.ts +26 -0
  140. package/dist/components/editor/plugins/typed-conversion-options.d.ts +13 -0
  141. package/dist/components/editor/plugins/update-base-kit.d.ts +1 -0
  142. package/dist/components/editor/plugins/update-kit.d.ts +4 -0
  143. package/dist/components/editor/plugins/update-types.d.ts +19 -0
  144. package/dist/components/editor/plugins/web-address-text.d.ts +1 -0
  145. package/dist/components/editor/transforms.d.ts +8 -0
  146. package/dist/components/editor/use-chat.d.ts +3 -0
  147. package/dist/components/editor/use-chat.js +3315 -0
  148. package/dist/components/editor/use-typed-conversion-options.d.ts +3 -0
  149. package/dist/components/editor/version-history/chunk-node.d.ts +7 -0
  150. package/dist/components/editor/version-history/chunk-plugin.d.ts +6 -0
  151. package/dist/components/editor/version-history/collapse-blocks-without-diff.d.ts +4 -0
  152. package/dist/components/editor/version-history/diff-node.d.ts +9 -0
  153. package/dist/components/editor/version-history/diff-plate.d.ts +7 -0
  154. package/dist/components/editor/version-history/diff-plugin.d.ts +8 -0
  155. package/dist/components/editor/version-history/index.d.ts +9 -0
  156. package/dist/components/editor/version-history/index.js +19179 -0
  157. package/dist/components/editor/version-history/use-object-version.d.ts +1 -0
  158. package/dist/components/editor/version-history/use-reset-editor-on-change.d.ts +7 -0
  159. package/dist/components/editor/version-history/version-plate.d.ts +7 -0
  160. package/dist/components/editor/web-editor.d.ts +6 -0
  161. package/dist/components/editor/web-editor.js +27295 -0
  162. package/dist/context/editor-adapter-context.d.ts +13 -0
  163. package/dist/context/editor-adapter-context.js +124 -0
  164. package/dist/context/editor-adapter.d.ts +262 -0
  165. package/dist/context/editor-toc-context.d.ts +16 -0
  166. package/dist/context/heading-slug-context.d.ts +11 -0
  167. package/dist/context/link-resolution-context.d.ts +24 -0
  168. package/dist/context/link-resolution-store.d.ts +20 -0
  169. package/dist/context/portal-container.d.ts +7 -0
  170. package/dist/hooks/use-copy-to-clipboard.d.ts +10 -0
  171. package/dist/hooks/use-dark-mode.d.ts +1 -0
  172. package/dist/hooks/use-debounce-callback.d.ts +108 -0
  173. package/dist/hooks/use-debounce.d.ts +1 -0
  174. package/dist/hooks/use-is-touch-device.d.ts +1 -0
  175. package/dist/hooks/use-lock-scroll.d.ts +1 -0
  176. package/dist/hooks/use-media-query.d.ts +2 -0
  177. package/dist/hooks/use-mounted.d.ts +6 -0
  178. package/dist/hooks/use-on-click-outside.d.ts +26 -0
  179. package/dist/hooks/use-shield-input-selection-from-editor.d.ts +3 -0
  180. package/dist/hooks/use-upload-file.d.ts +25 -0
  181. package/dist/hooks/use-upload-file.js +129 -0
  182. package/dist/lib/accepted-file-types.d.ts +1 -0
  183. package/dist/lib/block-features.d.ts +11 -0
  184. package/dist/lib/comment-mark-strip.d.ts +24 -0
  185. package/dist/lib/comment-mark-strip.js +56 -0
  186. package/dist/lib/download-file.d.ts +1 -0
  187. package/dist/lib/editor-element-path.d.ts +8 -0
  188. package/dist/lib/extract-headings.d.ts +13 -0
  189. package/dist/lib/extract-headings.js +79 -0
  190. package/dist/lib/file-size-limit.d.ts +7 -0
  191. package/dist/lib/html-serialize-hast.d.ts +18 -0
  192. package/dist/lib/html-serialize-rules.d.ts +15 -0
  193. package/dist/lib/html-serialize-utils.d.ts +24 -0
  194. package/dist/lib/html-serialize-utils.js +392 -0
  195. package/dist/lib/line-marking-context.d.ts +13 -0
  196. package/dist/lib/line-marking.d.ts +47 -0
  197. package/dist/lib/list-html.d.ts +30 -0
  198. package/dist/lib/markdown-joiner-transform.d.ts +31 -0
  199. package/dist/lib/markdown-utils.d.ts +4 -0
  200. package/dist/lib/markdown-utils.js +25275 -0
  201. package/dist/lib/mdx/mdx-archetype-rules.d.ts +2 -0
  202. package/dist/lib/mdx/mdx-attribute-codec.d.ts +23 -0
  203. package/dist/lib/mdx/mdx-color-rules.d.ts +2 -0
  204. package/dist/lib/mdx/mdx-component-rules.d.ts +2 -0
  205. package/dist/lib/mdx/mdx-mermaid-rules.d.ts +10 -0
  206. package/dist/lib/mdx/mdx-reference-rules.d.ts +11 -0
  207. package/dist/lib/mdx/mdx-round-trip.d.ts +3 -0
  208. package/dist/lib/mdx/mdx-round-trip.js +1397 -0
  209. package/dist/lib/mdx/mdx-rule-builder.d.ts +45 -0
  210. package/dist/lib/mdx/mdx-server-plugins.d.ts +8 -0
  211. package/dist/lib/mdx/mdx-tabbed-code-rules.d.ts +2 -0
  212. package/dist/lib/mdx/mdx-tabs-rules.d.ts +2 -0
  213. package/dist/lib/mdx/mdx-toggle-rules.d.ts +9 -0
  214. package/dist/lib/mdx/mdx-tree-rules.d.ts +2 -0
  215. package/dist/lib/media-html.d.ts +121 -0
  216. package/dist/lib/paragraph-html.d.ts +26 -0
  217. package/dist/lib/server-plugins.d.ts +199 -0
  218. package/dist/lib/utils.d.ts +3 -0
  219. package/dist/lib/utils.js +25 -0
  220. package/dist/lib/video-embeds.d.ts +9 -0
  221. package/dist/styles.css +6726 -0
  222. package/dist/types/editor.d.ts +161 -0
  223. package/dist/types/editor.js +77 -0
  224. package/dist/ui/accordion-group-node-static.d.ts +11 -0
  225. package/dist/ui/accordion-group-node.d.ts +10 -0
  226. package/dist/ui/ai-chat-editor.d.ts +4 -0
  227. package/dist/ui/ai-menu.d.ts +2 -0
  228. package/dist/ui/ai-node.d.ts +3 -0
  229. package/dist/ui/ai-toolbar-button.d.ts +3 -0
  230. package/dist/ui/alert-dialog.d.ts +20 -0
  231. package/dist/ui/api-doc/expandable-node-static.d.ts +4 -0
  232. package/dist/ui/api-doc/expandable-node.d.ts +3 -0
  233. package/dist/ui/api-doc/expandable-settings.d.ts +17 -0
  234. package/dist/ui/api-doc/panel-node-static.d.ts +3 -0
  235. package/dist/ui/api-doc/panel-node.d.ts +3 -0
  236. package/dist/ui/api-doc/response-field-item-node-static.d.ts +3 -0
  237. package/dist/ui/api-doc/response-field-item-node.d.ts +3 -0
  238. package/dist/ui/api-doc/response-field-node-static.d.ts +9 -0
  239. package/dist/ui/api-doc/response-field-node.d.ts +9 -0
  240. package/dist/ui/avatar.d.ts +16 -0
  241. package/dist/ui/badge-node-static.d.ts +3 -0
  242. package/dist/ui/badge-node.d.ts +3 -0
  243. package/dist/ui/badge-settings-options.d.ts +24 -0
  244. package/dist/ui/badge-settings.d.ts +19 -0
  245. package/dist/ui/badge.d.ts +9 -0
  246. package/dist/ui/banner-node-static.d.ts +4 -0
  247. package/dist/ui/banner-node.d.ts +3 -0
  248. package/dist/ui/block-context-menu.d.ts +8 -0
  249. package/dist/ui/block-discussion.d.ts +3 -0
  250. package/dist/ui/block-draggable.d.ts +2 -0
  251. package/dist/ui/block-list-static.d.ts +2 -0
  252. package/dist/ui/block-list.d.ts +2 -0
  253. package/dist/ui/block-menu.d.ts +167 -0
  254. package/dist/ui/block-selection.d.ts +5 -0
  255. package/dist/ui/block-suggestion.d.ts +17 -0
  256. package/dist/ui/blockquote-node-static.d.ts +2 -0
  257. package/dist/ui/blockquote-node.d.ts +2 -0
  258. package/dist/ui/button.d.ts +81 -0
  259. package/dist/ui/calendar.d.ts +5 -0
  260. package/dist/ui/callout-detail-settings.d.ts +15 -0
  261. package/dist/ui/callout-icon.d.ts +9 -0
  262. package/dist/ui/callout-node-static.d.ts +2 -0
  263. package/dist/ui/callout-node.d.ts +3 -0
  264. package/dist/ui/callout-settings.d.ts +19 -0
  265. package/dist/ui/callout-type-button.d.ts +9 -0
  266. package/dist/ui/caption.d.ts +72 -0
  267. package/dist/ui/card-element-actions.d.ts +7 -0
  268. package/dist/ui/card-icon-settings.d.ts +11 -0
  269. package/dist/ui/card-node-static.d.ts +3 -0
  270. package/dist/ui/card-node.d.ts +3 -0
  271. package/dist/ui/card-settings.d.ts +24 -0
  272. package/dist/ui/card-title-row.d.ts +14 -0
  273. package/dist/ui/checkbox.d.ts +4 -0
  274. package/dist/ui/code-block-line-marking-form.d.ts +9 -0
  275. package/dist/ui/code-block-line-marking-input.d.ts +8 -0
  276. package/dist/ui/code-block-line-marking-popover.d.ts +12 -0
  277. package/dist/ui/code-block-line-marking-state.d.ts +11 -0
  278. package/dist/ui/code-block-node-static.d.ts +10 -0
  279. package/dist/ui/code-block-node.d.ts +5 -0
  280. package/dist/ui/code-line-selection-toolbar.d.ts +10 -0
  281. package/dist/ui/code-line-wrapper.d.ts +22 -0
  282. package/dist/ui/code-node-static.d.ts +2 -0
  283. package/dist/ui/code-node.d.ts +2 -0
  284. package/dist/ui/collapsible.d.ts +6 -0
  285. package/dist/ui/color-copy-icon.d.ts +9 -0
  286. package/dist/ui/color-element-actions.d.ts +7 -0
  287. package/dist/ui/color-item-settings.d.ts +11 -0
  288. package/dist/ui/color-node-static.d.ts +3 -0
  289. package/dist/ui/color-node.d.ts +3 -0
  290. package/dist/ui/color-settings.d.ts +18 -0
  291. package/dist/ui/color-swatch-editable.d.ts +12 -0
  292. package/dist/ui/color-table-row-editable.d.ts +10 -0
  293. package/dist/ui/column-node-static.d.ts +4 -0
  294. package/dist/ui/column-node.d.ts +3 -0
  295. package/dist/ui/command.d.ts +25 -0
  296. package/dist/ui/comment-node-static.d.ts +3 -0
  297. package/dist/ui/comment-node.d.ts +3 -0
  298. package/dist/ui/comment-toolbar-button.d.ts +1 -0
  299. package/dist/ui/comment.d.ts +45 -0
  300. package/dist/ui/cursor-overlay.d.ts +4 -0
  301. package/dist/ui/date-node-static.d.ts +2 -0
  302. package/dist/ui/date-node.d.ts +2 -0
  303. package/dist/ui/dialog.d.ts +90 -0
  304. package/dist/ui/dropdown-menu.d.ts +35 -0
  305. package/dist/ui/editor-inspector-panel.d.ts +6 -0
  306. package/dist/ui/editor-static.d.ts +8 -0
  307. package/dist/ui/editor.d.ts +15 -0
  308. package/dist/ui/emoji-node.d.ts +3 -0
  309. package/dist/ui/emoji-toolbar-button.d.ts +16 -0
  310. package/dist/ui/equation-node-static.d.ts +4 -0
  311. package/dist/ui/equation-node.d.ts +5 -0
  312. package/dist/ui/equation-toolbar-button.d.ts +2 -0
  313. package/dist/ui/floating-discussion.d.ts +8 -0
  314. package/dist/ui/floating-toolbar-buttons.d.ts +1 -0
  315. package/dist/ui/floating-toolbar.d.ts +6 -0
  316. package/dist/ui/font-color-toolbar-button.d.ts +15 -0
  317. package/dist/ui/frame-node-static.d.ts +3 -0
  318. package/dist/ui/frame-node.d.ts +3 -0
  319. package/dist/ui/frame-settings.d.ts +19 -0
  320. package/dist/ui/ghost-text.d.ts +1 -0
  321. package/dist/ui/heading-node-static.d.ts +10 -0
  322. package/dist/ui/heading-node.d.ts +14 -0
  323. package/dist/ui/highlight-node-static.d.ts +2 -0
  324. package/dist/ui/highlight-node.d.ts +2 -0
  325. package/dist/ui/hover-card.d.ts +6 -0
  326. package/dist/ui/hr-node-static.d.ts +2 -0
  327. package/dist/ui/hr-node.d.ts +2 -0
  328. package/dist/ui/icon-node-static.d.ts +3 -0
  329. package/dist/ui/icon-node.d.ts +3 -0
  330. package/dist/ui/icon-picker.d.ts +16 -0
  331. package/dist/ui/icon-settings.d.ts +17 -0
  332. package/dist/ui/inline-combobox.d.ts +38 -0
  333. package/dist/ui/input.d.ts +7 -0
  334. package/dist/ui/kbd-node-static.d.ts +2 -0
  335. package/dist/ui/kbd-node.d.ts +2 -0
  336. package/dist/ui/label.d.ts +8 -0
  337. package/dist/ui/link-node-static.d.ts +11 -0
  338. package/dist/ui/link-node.d.ts +11 -0
  339. package/dist/ui/link-reference.d.ts +39 -0
  340. package/dist/ui/link-reference.js +84 -0
  341. package/dist/ui/link-search-panel.d.ts +5 -0
  342. package/dist/ui/link-toolbar-button.d.ts +3 -0
  343. package/dist/ui/link-toolbar-edit-command.d.ts +7 -0
  344. package/dist/ui/link-toolbar-shared.d.ts +18 -0
  345. package/dist/ui/link-toolbar.d.ts +1 -0
  346. package/dist/ui/mark-toolbar-button.d.ts +6 -0
  347. package/dist/ui/media-align-button.d.ts +5 -0
  348. package/dist/ui/media-audio-node-static.d.ts +3 -0
  349. package/dist/ui/media-audio-node.d.ts +2 -0
  350. package/dist/ui/media-card.d.ts +11 -0
  351. package/dist/ui/media-embed-node-static.d.ts +6 -0
  352. package/dist/ui/media-embed-node.d.ts +2 -0
  353. package/dist/ui/media-file-display.d.ts +11 -0
  354. package/dist/ui/media-file-mode-dropdown.d.ts +10 -0
  355. package/dist/ui/media-file-node-static.d.ts +3 -0
  356. package/dist/ui/media-file-node.d.ts +2 -0
  357. package/dist/ui/media-hint-icon-picker.d.ts +5 -0
  358. package/dist/ui/media-hint-settings.d.ts +2 -0
  359. package/dist/ui/media-image-lightbox.d.ts +17 -0
  360. package/dist/ui/media-image-node-static.d.ts +6 -0
  361. package/dist/ui/media-image-node.d.ts +7 -0
  362. package/dist/ui/media-placeholder-node.d.ts +3 -0
  363. package/dist/ui/media-preview-dialog.d.ts +12 -0
  364. package/dist/ui/media-toolbar.d.ts +3 -0
  365. package/dist/ui/media-upload-toast.d.ts +1 -0
  366. package/dist/ui/media-video-node-static.d.ts +6 -0
  367. package/dist/ui/media-video-node.d.ts +2 -0
  368. package/dist/ui/member-profile-card.d.ts +17 -0
  369. package/dist/ui/mention-document-element.d.ts +5 -0
  370. package/dist/ui/mention-document-hover-card.d.ts +17 -0
  371. package/dist/ui/mention-document-link.d.ts +13 -0
  372. package/dist/ui/mention-element.d.ts +5 -0
  373. package/dist/ui/mention-input-element.d.ts +2 -0
  374. package/dist/ui/mention-node-static.d.ts +7 -0
  375. package/dist/ui/mention-page-combobox-group.d.ts +8 -0
  376. package/dist/ui/mention-people-combobox-group.d.ts +8 -0
  377. package/dist/ui/menu.d.ts +103 -0
  378. package/dist/ui/mermaid-node-static.d.ts +4 -0
  379. package/dist/ui/mermaid-node.d.ts +3 -0
  380. package/dist/ui/more-toolbar-button.d.ts +3 -0
  381. package/dist/ui/paragraph-node-static.d.ts +2 -0
  382. package/dist/ui/paragraph-node.d.ts +2 -0
  383. package/dist/ui/popover.d.ts +11 -0
  384. package/dist/ui/progress.d.ts +3 -0
  385. package/dist/ui/resize-handle.d.ts +15 -0
  386. package/dist/ui/select.d.ts +13 -0
  387. package/dist/ui/separator.d.ts +8 -0
  388. package/dist/ui/slash-node.d.ts +20 -0
  389. package/dist/ui/smart-link-clipboard.d.ts +1 -0
  390. package/dist/ui/smart-link-copy-button.d.ts +6 -0
  391. package/dist/ui/smart-link-mode-dropdown.d.ts +9 -0
  392. package/dist/ui/smart-link-toolbar.d.ts +17 -0
  393. package/dist/ui/smart-link-view.d.ts +23 -0
  394. package/dist/ui/smart-link.d.ts +43 -0
  395. package/dist/ui/spinner.d.ts +7 -0
  396. package/dist/ui/step-node-static.d.ts +3 -0
  397. package/dist/ui/step-node.d.ts +3 -0
  398. package/dist/ui/step-settings.d.ts +19 -0
  399. package/dist/ui/steps-node-static.d.ts +10 -0
  400. package/dist/ui/steps-node.d.ts +10 -0
  401. package/dist/ui/suggestion-node-static.d.ts +3 -0
  402. package/dist/ui/suggestion-node.d.ts +6 -0
  403. package/dist/ui/suggestion-toolbar-button.d.ts +1 -0
  404. package/dist/ui/switch.d.ts +4 -0
  405. package/dist/ui/tabbed-code-block-actions.d.ts +24 -0
  406. package/dist/ui/tabbed-code-block-header.d.ts +23 -0
  407. package/dist/ui/tabbed-code-block-language-selector.d.ts +7 -0
  408. package/dist/ui/tabbed-code-block-languages.d.ts +6 -0
  409. package/dist/ui/tabbed-code-block-node-static.d.ts +4 -0
  410. package/dist/ui/tabbed-code-block-node.d.ts +4 -0
  411. package/dist/ui/tabbed-code-block-settings.d.ts +18 -0
  412. package/dist/ui/tabbed-code-block-sync.d.ts +10 -0
  413. package/dist/ui/tabbed-code-block-tab-dropdown.d.ts +10 -0
  414. package/dist/ui/tabbed-code-block-tab-strip.d.ts +27 -0
  415. package/dist/ui/tabbed-code-block-tab-trigger.d.ts +14 -0
  416. package/dist/ui/tabbed-code-block-utils.d.ts +9 -0
  417. package/dist/ui/table-icons.d.ts +7 -0
  418. package/dist/ui/table-node-static.d.ts +9 -0
  419. package/dist/ui/table-node.d.ts +9 -0
  420. package/dist/ui/tabs-node-static.d.ts +4 -0
  421. package/dist/ui/tabs-node.d.ts +3 -0
  422. package/dist/ui/tabs.d.ts +10 -0
  423. package/dist/ui/textarea.d.ts +10 -0
  424. package/dist/ui/tile-node-static.d.ts +3 -0
  425. package/dist/ui/tile-node.d.ts +3 -0
  426. package/dist/ui/tile-settings.d.ts +18 -0
  427. package/dist/ui/tiles-node-static.d.ts +3 -0
  428. package/dist/ui/tiles-node.d.ts +3 -0
  429. package/dist/ui/toc-node-static.d.ts +2 -0
  430. package/dist/ui/toc-node.d.ts +2 -0
  431. package/dist/ui/toc-sidebar.d.ts +6 -0
  432. package/dist/ui/toc-state-sync.d.ts +5 -0
  433. package/dist/ui/toggle-node-static.d.ts +3 -0
  434. package/dist/ui/toggle-node-views.d.ts +35 -0
  435. package/dist/ui/toggle-node.d.ts +3 -0
  436. package/dist/ui/toggle-settings.d.ts +23 -0
  437. package/dist/ui/toggle.d.ts +8 -0
  438. package/dist/ui/toolbar.d.ts +37 -0
  439. package/dist/ui/tooltip-node-static.d.ts +3 -0
  440. package/dist/ui/tooltip-node.d.ts +3 -0
  441. package/dist/ui/tooltip-preview-content.d.ts +6 -0
  442. package/dist/ui/tooltip-settings.d.ts +21 -0
  443. package/dist/ui/tooltip-toolbar-button.d.ts +3 -0
  444. package/dist/ui/tooltip.d.ts +19 -0
  445. package/dist/ui/tree-context-value.d.ts +22 -0
  446. package/dist/ui/tree-context.d.ts +32 -0
  447. package/dist/ui/tree-file-node-static.d.ts +8 -0
  448. package/dist/ui/tree-file-node.d.ts +11 -0
  449. package/dist/ui/tree-folder-node-static.d.ts +9 -0
  450. package/dist/ui/tree-folder-node.d.ts +12 -0
  451. package/dist/ui/tree-item-utils.d.ts +11 -0
  452. package/dist/ui/tree-items-list.d.ts +11 -0
  453. package/dist/ui/tree-node-events.d.ts +19 -0
  454. package/dist/ui/tree-node-state.d.ts +14 -0
  455. package/dist/ui/tree-node-static.d.ts +12 -0
  456. package/dist/ui/tree-node.d.ts +5 -0
  457. package/dist/ui/tree-root-actions.d.ts +11 -0
  458. package/dist/ui/tree-settings.d.ts +18 -0
  459. package/dist/ui/turn-into-toolbar-button.d.ts +129 -0
  460. package/dist/ui/update-display-tags.d.ts +5 -0
  461. package/dist/ui/update-node-static.d.ts +2 -0
  462. package/dist/ui/update-node.d.ts +3 -0
  463. package/dist/ui/update-rss-settings.d.ts +9 -0
  464. package/dist/ui/update-settings.d.ts +21 -0
  465. package/dist/ui/update-tags-settings.d.ts +8 -0
  466. package/dist/ui/updates-node-static.d.ts +2 -0
  467. package/dist/ui/updates-node.d.ts +2 -0
  468. package/dist/ui/use-member-profile.d.ts +22 -0
  469. package/dist/ui/use-placeholder-max-file-size.d.ts +3 -0
  470. package/dist/vendor/slate-yjs-core.d.ts +1 -0
  471. package/dist/vendor/slate-yjs-core.js +2 -0
  472. package/dist/vendor/y-protocols-awareness.d.ts +1 -0
  473. package/dist/vendor/y-protocols-awareness.js +2 -0
  474. package/dist/vendor/yjs.d.ts +1 -0
  475. package/dist/vendor/yjs.js +2 -0
  476. package/package.json +255 -4
@@ -0,0 +1,1397 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/lib/mdx/mdx-round-trip.ts
22
+ import { deserializeMd, MarkdownPlugin, remarkMdx, serializeMd } from "@platejs/markdown";
23
+ import { createSlateEditor, KEYS } from "platejs";
24
+
25
+ // src/lib/mdx/mdx-rule-builder.ts
26
+ import {
27
+ convertChildrenDeserialize,
28
+ convertNodesSerialize
29
+ } from "@platejs/markdown";
30
+
31
+ // src/lib/mdx/mdx-attribute-codec.ts
32
+ var isExpressionValue = (value) => {
33
+ return typeof value === "object" && value !== null && value.type === "mdxJsxAttributeValueExpression" && typeof value.value === "string";
34
+ };
35
+ var propsToMdxAttributes = (props) => {
36
+ const names = Object.keys(props).sort();
37
+ const attributes = [];
38
+ for (const name of names) {
39
+ const value = props[name];
40
+ if (value === void 0 || value === null) {
41
+ continue;
42
+ }
43
+ if (typeof value === "string") {
44
+ attributes.push({ type: "mdxJsxAttribute", name, value });
45
+ continue;
46
+ }
47
+ attributes.push({
48
+ type: "mdxJsxAttribute",
49
+ name,
50
+ value: { type: "mdxJsxAttributeValueExpression", value: JSON.stringify(value) }
51
+ });
52
+ }
53
+ return attributes;
54
+ };
55
+ var mdxAttributesToProps = (attributes, stringFields) => {
56
+ const props = {};
57
+ if (!Array.isArray(attributes)) {
58
+ return props;
59
+ }
60
+ for (const attribute of attributes) {
61
+ if (!attribute || typeof attribute.name !== "string" || attribute.name.length === 0) {
62
+ continue;
63
+ }
64
+ const { value } = attribute;
65
+ if (value === void 0 || value === null) {
66
+ continue;
67
+ }
68
+ const isExpression = isExpressionValue(value);
69
+ const source = isExpression ? value.value : value;
70
+ if (typeof source !== "string") {
71
+ continue;
72
+ }
73
+ if (stringFields == null ? void 0 : stringFields.has(attribute.name)) {
74
+ props[attribute.name] = source;
75
+ continue;
76
+ }
77
+ if (!isExpression) {
78
+ props[attribute.name] = source;
79
+ continue;
80
+ }
81
+ try {
82
+ props[attribute.name] = JSON.parse(source);
83
+ } catch (e) {
84
+ props[attribute.name] = source;
85
+ }
86
+ }
87
+ return props;
88
+ };
89
+
90
+ // src/lib/mdx/mdx-rule-builder.ts
91
+ var ALWAYS_STRIPPED_FIELDS = ["id", "type", "children"];
92
+ var isStringRecord = (value) => {
93
+ return typeof value === "object" && value !== null && !Array.isArray(value);
94
+ };
95
+ var toElementChildren = (node) => {
96
+ return Array.isArray(node.children) ? node.children : [];
97
+ };
98
+ var buildSerializedProps = (node, config) => {
99
+ var _a4, _b2, _c, _d, _e;
100
+ const stripped = /* @__PURE__ */ new Set([
101
+ ...ALWAYS_STRIPPED_FIELDS,
102
+ ...(_a4 = config.strippedFields) != null ? _a4 : [],
103
+ ...(_b2 = config.derivedFields) != null ? _b2 : []
104
+ ]);
105
+ const aliasByField = new Map((_d = (_c = config.aliases) == null ? void 0 : _c.map((alias) => [alias.field, alias.attribute])) != null ? _d : []);
106
+ const props = {};
107
+ for (const [field, value] of Object.entries(node)) {
108
+ if (stripped.has(field)) {
109
+ continue;
110
+ }
111
+ const attribute = (_e = aliasByField.get(field)) != null ? _e : field;
112
+ props[attribute] = value;
113
+ }
114
+ return props;
115
+ };
116
+ var buildStringAttributeSet = (config) => {
117
+ var _a4, _b2;
118
+ if (!config.stringFields || config.stringFields.length === 0) {
119
+ return void 0;
120
+ }
121
+ const aliasByField = new Map((_b2 = (_a4 = config.aliases) == null ? void 0 : _a4.map((alias) => [alias.field, alias.attribute])) != null ? _b2 : []);
122
+ return new Set(config.stringFields.map((field) => {
123
+ var _a5;
124
+ return (_a5 = aliasByField.get(field)) != null ? _a5 : field;
125
+ }));
126
+ };
127
+ var restoreDeserializedProps = (attributes, config) => {
128
+ var _a4, _b2, _c;
129
+ const props = mdxAttributesToProps(attributes, buildStringAttributeSet(config));
130
+ const fieldByAttribute = new Map((_b2 = (_a4 = config.aliases) == null ? void 0 : _a4.map((alias) => [alias.attribute, alias.field])) != null ? _b2 : []);
131
+ const restored = {};
132
+ for (const [attribute, value] of Object.entries(props)) {
133
+ const field = (_c = fieldByAttribute.get(attribute)) != null ? _c : attribute;
134
+ restored[field] = value;
135
+ }
136
+ return restored;
137
+ };
138
+ var defineMdxElementRule = (config) => {
139
+ const mdxType = config.isInline ? "mdxJsxTextElement" : "mdxJsxFlowElement";
140
+ const serializeRule = {
141
+ serialize: (node, options) => {
142
+ const props = buildSerializedProps(node, config);
143
+ const children = config.isVoid ? [] : convertNodesSerialize(toElementChildren(node), options);
144
+ return {
145
+ type: mdxType,
146
+ name: config.tagName,
147
+ attributes: propsToMdxAttributes(props),
148
+ children
149
+ };
150
+ }
151
+ };
152
+ const deserializeRule = {
153
+ deserialize: (node, deco, options) => {
154
+ const attributes = Array.isArray(node.attributes) ? node.attributes : [];
155
+ const props = restoreDeserializedProps(attributes, config);
156
+ const element = {
157
+ type: config.pluginKey,
158
+ children: config.isVoid ? [{ text: "" }] : convertChildrenDeserialize(asMdRootContent(node.children), normalizeDecoration(deco), options)
159
+ };
160
+ for (const [field, value] of Object.entries(props)) {
161
+ element[field] = value;
162
+ }
163
+ if (config.deriveFields) {
164
+ for (const [field, value] of Object.entries(config.deriveFields(element))) {
165
+ if (value !== void 0) {
166
+ element[field] = value;
167
+ }
168
+ }
169
+ }
170
+ return element;
171
+ }
172
+ };
173
+ return {
174
+ [config.pluginKey]: serializeRule,
175
+ [config.tagName]: deserializeRule
176
+ };
177
+ };
178
+ var normalizeDecoration = (deco) => {
179
+ return isStringRecord(deco) ? deco : {};
180
+ };
181
+ var asMdRootContent = (children) => {
182
+ return Array.isArray(children) ? children : [];
183
+ };
184
+
185
+ // src/lib/mdx/mdx-archetype-rules.ts
186
+ var badgeRule = defineMdxElementRule({
187
+ pluginKey: "badge",
188
+ tagName: "Badge",
189
+ isInline: true
190
+ });
191
+ var iconRule = defineMdxElementRule({
192
+ pluginKey: "icon",
193
+ tagName: "Icon",
194
+ isInline: true,
195
+ isVoid: true
196
+ });
197
+ var bannerRule = defineMdxElementRule({
198
+ pluginKey: "banner",
199
+ tagName: "Banner"
200
+ });
201
+ var calloutRule = defineMdxElementRule({
202
+ pluginKey: "callout",
203
+ tagName: "Callout",
204
+ aliases: [{ field: "calloutType", attribute: "type" }]
205
+ });
206
+ var mdxArchetypeRules = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, badgeRule), iconRule), bannerRule), calloutRule);
207
+
208
+ // src/lib/mdx/mdx-color-rules.ts
209
+ var COLOR_TAG = "Color";
210
+ var ITEM_TAG = "ColorItem";
211
+ var MAX_COLORS = 256;
212
+ var COLOR_VARIANTS = /* @__PURE__ */ new Set(["compact", "table"]);
213
+ var ITEM_STRING_FIELDS = /* @__PURE__ */ new Set(["name", "light", "dark"]);
214
+ var CONTAINER_STRING_FIELDS = /* @__PURE__ */ new Set(["variant"]);
215
+ var SHORTHAND_HEX = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i;
216
+ var FULL_HEX = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i;
217
+ var asString = (value) => {
218
+ return typeof value === "string" ? value : "";
219
+ };
220
+ var normalizeColorValue = (value) => {
221
+ const trimmed = value.trim();
222
+ const shorthand = SHORTHAND_HEX.exec(trimmed);
223
+ if (shorthand) {
224
+ const [, r, g, b] = shorthand;
225
+ return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();
226
+ }
227
+ if (FULL_HEX.test(trimmed)) {
228
+ return trimmed.toLowerCase();
229
+ }
230
+ return trimmed;
231
+ };
232
+ var asColorList = (value) => {
233
+ if (!Array.isArray(value)) {
234
+ return [];
235
+ }
236
+ const result = [];
237
+ for (const entry of value.slice(0, MAX_COLORS)) {
238
+ if (typeof entry !== "object" || entry === null) {
239
+ continue;
240
+ }
241
+ const candidate = entry;
242
+ const light = asString(candidate.light);
243
+ if (light.length === 0) {
244
+ continue;
245
+ }
246
+ const name = asString(candidate.name);
247
+ const dark = asString(candidate.dark);
248
+ result.push(__spreadValues(__spreadValues({
249
+ id: asString(candidate.id),
250
+ light
251
+ }, name.length > 0 ? { name } : {}), dark.length > 0 ? { dark } : {}));
252
+ }
253
+ return result;
254
+ };
255
+ var itemToMdx = (item) => {
256
+ const props = { light: normalizeColorValue(item.light) };
257
+ if (item.name && item.name.length > 0) {
258
+ props.name = item.name;
259
+ }
260
+ if (item.dark && item.dark.length > 0) {
261
+ props.dark = normalizeColorValue(item.dark);
262
+ }
263
+ return { type: "mdxJsxFlowElement", name: ITEM_TAG, attributes: propsToMdxAttributes(props), children: [] };
264
+ };
265
+ var containerProps = (node) => {
266
+ const props = {};
267
+ const variant = node.variant;
268
+ if (typeof variant === "string" && COLOR_VARIANTS.has(variant)) {
269
+ props.variant = variant;
270
+ }
271
+ if (typeof node.showLabels === "boolean") {
272
+ props.showLabels = node.showLabels;
273
+ }
274
+ return props;
275
+ };
276
+ var isColorBlock = (node) => {
277
+ return typeof node === "object" && node !== null && node.type === "color";
278
+ };
279
+ var colorSerialize = (node, _options) => {
280
+ if (isColorBlock(node)) {
281
+ return {
282
+ type: "mdxJsxFlowElement",
283
+ name: COLOR_TAG,
284
+ attributes: propsToMdxAttributes(containerProps(node)),
285
+ children: asColorList(node.colors).map(itemToMdx)
286
+ };
287
+ }
288
+ const text = typeof node.text === "string" ? node.text : "";
289
+ return { type: "text", value: text };
290
+ };
291
+ var childElements = (node) => {
292
+ if (!Array.isArray(node.children)) {
293
+ return [];
294
+ }
295
+ return node.children.filter(
296
+ (child) => typeof child === "object" && child !== null && child.name === ITEM_TAG
297
+ );
298
+ };
299
+ var mdxToColors = (node) => {
300
+ const colors = [];
301
+ let position = 0;
302
+ for (const child of childElements(node).slice(0, MAX_COLORS)) {
303
+ const props = mdxAttributesToProps(Array.isArray(child.attributes) ? child.attributes : [], ITEM_STRING_FIELDS);
304
+ const light = normalizeColorValue(asString(props.light));
305
+ if (light.length === 0) {
306
+ continue;
307
+ }
308
+ position += 1;
309
+ const name = asString(props.name);
310
+ const dark = asString(props.dark);
311
+ colors.push(__spreadValues(__spreadValues({
312
+ id: `color-${position}`,
313
+ light
314
+ }, name.length > 0 ? { name } : {}), dark.length > 0 ? { dark: normalizeColorValue(dark) } : {}));
315
+ }
316
+ return colors;
317
+ };
318
+ var colorDeserialize = (node, _deco, _options) => {
319
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], CONTAINER_STRING_FIELDS);
320
+ const element = {
321
+ type: "color",
322
+ variant: typeof props.variant === "string" && COLOR_VARIANTS.has(props.variant) ? props.variant : "compact",
323
+ colors: mdxToColors(node),
324
+ children: [{ text: "" }]
325
+ };
326
+ if (typeof props.showLabels === "boolean") {
327
+ element.showLabels = props.showLabels;
328
+ }
329
+ return element;
330
+ };
331
+ var mdxColorRules = {
332
+ color: { mark: true, serialize: colorSerialize },
333
+ [COLOR_TAG]: { deserialize: colorDeserialize }
334
+ };
335
+
336
+ // src/lib/utils.ts
337
+ import { clsx } from "clsx";
338
+ import { twMerge } from "tailwind-merge";
339
+ var MAX_SLUG_LENGTH = 80;
340
+ var generateSlugFromText = (text) => {
341
+ let slug = text.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
342
+ if (slug.length > MAX_SLUG_LENGTH) {
343
+ slug = slug.substring(0, MAX_SLUG_LENGTH);
344
+ const lastHyphen = slug.lastIndexOf("-");
345
+ if (lastHyphen > MAX_SLUG_LENGTH / 2) {
346
+ slug = slug.substring(0, lastHyphen);
347
+ }
348
+ slug = slug.replace(/-+$/, "");
349
+ }
350
+ return encodeURIComponent(slug);
351
+ };
352
+
353
+ // src/lib/mdx/mdx-component-rules.ts
354
+ var STEP_TYPE = "step";
355
+ var isStepElement = (node) => {
356
+ return typeof node === "object" && node !== null && node.type === STEP_TYPE;
357
+ };
358
+ var numberSteps = (element) => {
359
+ const children = Array.isArray(element.children) ? element.children : [];
360
+ let position = 0;
361
+ const numbered = children.map((child) => {
362
+ if (!isStepElement(child)) {
363
+ return child;
364
+ }
365
+ position += 1;
366
+ return __spreadProps(__spreadValues({}, child), { stepNumber: position });
367
+ });
368
+ return { children: numbered };
369
+ };
370
+ var deriveAnchorId = (element) => {
371
+ const label = typeof element.label === "string" ? element.label : "";
372
+ const anchorId = generateSlugFromText(label);
373
+ return anchorId.length > 0 ? { anchorId } : {};
374
+ };
375
+ var stepRule = defineMdxElementRule({
376
+ pluginKey: "step",
377
+ tagName: "Step",
378
+ stringFields: ["title"],
379
+ derivedFields: ["stepNumber"]
380
+ });
381
+ var stepsRule = defineMdxElementRule({
382
+ pluginKey: "steps",
383
+ tagName: "Steps",
384
+ deriveFields: numberSteps
385
+ });
386
+ var tileRule = defineMdxElementRule({
387
+ pluginKey: "tile",
388
+ tagName: "Tile",
389
+ stringFields: ["title", "description", "href"]
390
+ });
391
+ var tilesRule = defineMdxElementRule({
392
+ pluginKey: "tiles",
393
+ tagName: "Tiles"
394
+ });
395
+ var cardRule = defineMdxElementRule({
396
+ pluginKey: "card",
397
+ tagName: "Card",
398
+ stringFields: ["title", "href", "img", "cta", "color"]
399
+ });
400
+ var frameRule = defineMdxElementRule({
401
+ pluginKey: "frame",
402
+ tagName: "Frame",
403
+ stringFields: ["caption", "hint"]
404
+ });
405
+ var tooltipRule = defineMdxElementRule({
406
+ pluginKey: "tooltip",
407
+ tagName: "Tooltip",
408
+ isInline: true,
409
+ stringFields: ["tip", "headline", "cta", "href"]
410
+ });
411
+ var updateRule = defineMdxElementRule({
412
+ pluginKey: "update",
413
+ tagName: "Update",
414
+ stringFields: ["label", "description"],
415
+ derivedFields: ["anchorId"],
416
+ deriveFields: deriveAnchorId
417
+ });
418
+ var updatesRule = defineMdxElementRule({
419
+ pluginKey: "updates",
420
+ tagName: "Updates"
421
+ });
422
+ var responseFieldItemRule = defineMdxElementRule({
423
+ pluginKey: "response_field_item",
424
+ tagName: "ResponseFieldItem",
425
+ stringFields: ["name", "fieldType", "default"]
426
+ });
427
+ var responseFieldRule = defineMdxElementRule({
428
+ pluginKey: "response_field",
429
+ tagName: "ResponseField"
430
+ });
431
+ var panelRule = defineMdxElementRule({
432
+ pluginKey: "panel",
433
+ tagName: "Panel"
434
+ });
435
+ var expandableRule = defineMdxElementRule({
436
+ pluginKey: "expandable",
437
+ tagName: "Expandable",
438
+ stringFields: ["title"]
439
+ });
440
+ var mdxComponentRules = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, stepRule), stepsRule), tileRule), tilesRule), cardRule), frameRule), tooltipRule), updateRule), updatesRule), responseFieldItemRule), responseFieldRule), panelRule), expandableRule);
441
+
442
+ // src/lib/mdx/mdx-mermaid-rules.ts
443
+ import { defaultRules } from "@platejs/markdown";
444
+ var MERMAID_LANG = "mermaid";
445
+ var isStringRecord2 = (value) => {
446
+ return typeof value === "object" && value !== null && !Array.isArray(value);
447
+ };
448
+ var childTextOf = (child) => {
449
+ if (typeof child !== "object" || child === null) {
450
+ return "";
451
+ }
452
+ const record = child;
453
+ if (typeof record.text === "string") {
454
+ return record.text;
455
+ }
456
+ if (!Array.isArray(record.children)) {
457
+ return "";
458
+ }
459
+ return record.children.map((leaf) => typeof leaf.text === "string" ? leaf.text : "").join("");
460
+ };
461
+ var mermaidCodeValue = (node) => {
462
+ const children = Array.isArray(node.children) ? node.children : [];
463
+ return children.map(childTextOf).join("\n");
464
+ };
465
+ var mermaidSerialize = (node, _options) => {
466
+ return {
467
+ type: "code",
468
+ lang: MERMAID_LANG,
469
+ value: mermaidCodeValue(node)
470
+ };
471
+ };
472
+ var stringToCodeLines = (value) => {
473
+ return value.split("\n").map((line) => ({ type: "code_line", children: [{ text: line }] }));
474
+ };
475
+ var isMermaidFence = (mdastNode) => {
476
+ return mdastNode.type === "code" && mdastNode.lang === MERMAID_LANG;
477
+ };
478
+ var mermaidFromFence = (mdastNode) => {
479
+ const value = typeof mdastNode.value === "string" ? mdastNode.value : "";
480
+ return {
481
+ type: "mermaid",
482
+ children: stringToCodeLines(value)
483
+ };
484
+ };
485
+ var _a;
486
+ var defaultCodeBlockDeserialize = (_a = defaultRules.code_block) == null ? void 0 : _a.deserialize;
487
+ var codeBlockDeserialize = (mdastNode, deco, options) => {
488
+ if (isStringRecord2(mdastNode) && isMermaidFence(mdastNode)) {
489
+ return mermaidFromFence(mdastNode);
490
+ }
491
+ if (defaultCodeBlockDeserialize) {
492
+ return defaultCodeBlockDeserialize(mdastNode, deco, options);
493
+ }
494
+ return { type: "code_block", children: [{ type: "code_line", children: [{ text: "" }] }] };
495
+ };
496
+ var _a2;
497
+ var mdxMermaidRules = {
498
+ mermaid: { serialize: mermaidSerialize },
499
+ code_block: {
500
+ deserialize: codeBlockDeserialize,
501
+ serialize: (_a2 = defaultRules.code_block) == null ? void 0 : _a2.serialize
502
+ }
503
+ };
504
+
505
+ // src/lib/mdx/mdx-reference-rules.ts
506
+ import {
507
+ convertChildrenDeserialize as convertChildrenDeserialize2,
508
+ convertNodesSerialize as convertNodesSerialize2,
509
+ defaultRules as defaultRules2
510
+ } from "@platejs/markdown";
511
+ var LINK_TAG = "Link";
512
+ var MENTION_TAG = "Mention";
513
+ var LINK_STRIPPED_FIELDS = /* @__PURE__ */ new Set(["id", "type", "children"]);
514
+ var MENTION_STRIPPED_FIELDS = /* @__PURE__ */ new Set(["id", "type", "children"]);
515
+ var LINK_STRING_FIELDS = /* @__PURE__ */ new Set(["url", "icon", "displayMode", "title"]);
516
+ var MENTION_STRING_FIELDS = /* @__PURE__ */ new Set(["value", "key", "icon", "displayMode", "coverImage"]);
517
+ var asElementChildren = (node) => {
518
+ return Array.isArray(node.children) ? node.children : [];
519
+ };
520
+ var hasReference = (node) => {
521
+ return typeof node.reference === "object" && node.reference !== null;
522
+ };
523
+ var collectProps = (node, stripped) => {
524
+ const props = {};
525
+ for (const [field, value] of Object.entries(node)) {
526
+ if (stripped.has(field) || value === void 0) {
527
+ continue;
528
+ }
529
+ props[field] = value;
530
+ }
531
+ return props;
532
+ };
533
+ var attributesOf = (node) => {
534
+ return Array.isArray(node.attributes) ? node.attributes : [];
535
+ };
536
+ var childrenOf = (node) => {
537
+ return Array.isArray(node.children) ? node.children : [];
538
+ };
539
+ var linkSerialize = (node, options) => {
540
+ var _a4, _b2;
541
+ if (!hasReference(node)) {
542
+ return (_b2 = (_a4 = defaultRules2.a) == null ? void 0 : _a4.serialize) == null ? void 0 : _b2.call(_a4, node, options);
543
+ }
544
+ const element = {
545
+ type: "mdxJsxTextElement",
546
+ name: LINK_TAG,
547
+ attributes: propsToMdxAttributes(collectProps(node, LINK_STRIPPED_FIELDS)),
548
+ children: convertNodesSerialize2(asElementChildren(node), options)
549
+ };
550
+ return element;
551
+ };
552
+ var linkDeserialize = (node, deco, options) => {
553
+ const props = mdxAttributesToProps(attributesOf(node), LINK_STRING_FIELDS);
554
+ const element = {
555
+ type: "a",
556
+ children: convertChildrenDeserialize2(childrenOf(node), deco, options)
557
+ };
558
+ for (const [field, value] of Object.entries(props)) {
559
+ element[field] = value;
560
+ }
561
+ return element;
562
+ };
563
+ var mentionSerialize = (node) => {
564
+ return {
565
+ type: "mdxJsxTextElement",
566
+ name: MENTION_TAG,
567
+ attributes: propsToMdxAttributes(collectProps(node, MENTION_STRIPPED_FIELDS)),
568
+ children: [{ type: "text", value: "" }]
569
+ };
570
+ };
571
+ var mentionDeserialize = (node) => {
572
+ const props = mdxAttributesToProps(attributesOf(node), MENTION_STRING_FIELDS);
573
+ const element = {
574
+ type: "mention",
575
+ children: [{ text: "" }]
576
+ };
577
+ for (const [field, value] of Object.entries(props)) {
578
+ element[field] = value;
579
+ }
580
+ return element;
581
+ };
582
+ var _a3, _b;
583
+ var mdxReferenceRules = {
584
+ a: {
585
+ deserialize: (_a3 = defaultRules2.a) == null ? void 0 : _a3.deserialize,
586
+ serialize: linkSerialize
587
+ },
588
+ mention: {
589
+ deserialize: (_b = defaultRules2.mention) == null ? void 0 : _b.deserialize,
590
+ serialize: mentionSerialize
591
+ },
592
+ [LINK_TAG]: {
593
+ deserialize: linkDeserialize
594
+ },
595
+ [MENTION_TAG]: {
596
+ deserialize: mentionDeserialize
597
+ }
598
+ };
599
+
600
+ // src/lib/mdx/mdx-server-plugins.ts
601
+ import { createSlatePlugin } from "platejs";
602
+
603
+ // src/lib/server-plugins.ts
604
+ import {
605
+ BaseBlockquotePlugin,
606
+ BaseBoldPlugin,
607
+ BaseCodePlugin,
608
+ BaseH1Plugin,
609
+ BaseH2Plugin,
610
+ BaseH3Plugin,
611
+ BaseHighlightPlugin,
612
+ BaseHorizontalRulePlugin,
613
+ BaseItalicPlugin,
614
+ BaseKbdPlugin,
615
+ BaseStrikethroughPlugin,
616
+ BaseSubscriptPlugin,
617
+ BaseSuperscriptPlugin,
618
+ BaseUnderlinePlugin
619
+ } from "@platejs/basic-nodes";
620
+ import { BaseCalloutPlugin } from "@platejs/callout";
621
+ import { BaseCodeBlockPlugin, BaseCodeLinePlugin } from "@platejs/code-block";
622
+ import { BaseDatePlugin } from "@platejs/date";
623
+ import { BaseIndentPlugin } from "@platejs/indent";
624
+ import { BaseColumnItemPlugin, BaseColumnPlugin } from "@platejs/layout";
625
+ import { BaseLinkPlugin } from "@platejs/link";
626
+ import { BaseListPlugin } from "@platejs/list";
627
+ import { BaseEquationPlugin, BaseInlineEquationPlugin } from "@platejs/math";
628
+ import { BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin } from "@platejs/media";
629
+ import { BaseMentionPlugin } from "@platejs/mention";
630
+ import { BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin } from "@platejs/table";
631
+ import { BaseTocPlugin } from "@platejs/toc";
632
+ import { BaseTogglePlugin } from "@platejs/toggle";
633
+ import { BaseParagraphPlugin } from "platejs";
634
+ var ServerPlugins = [
635
+ // Basic blocks
636
+ BaseParagraphPlugin,
637
+ BaseH1Plugin,
638
+ BaseH2Plugin,
639
+ BaseH3Plugin,
640
+ BaseBlockquotePlugin,
641
+ BaseHorizontalRulePlugin,
642
+ // Basic marks
643
+ BaseBoldPlugin,
644
+ BaseItalicPlugin,
645
+ BaseUnderlinePlugin,
646
+ BaseCodePlugin,
647
+ BaseStrikethroughPlugin,
648
+ BaseSubscriptPlugin,
649
+ BaseSuperscriptPlugin,
650
+ BaseHighlightPlugin,
651
+ BaseKbdPlugin,
652
+ // Code block
653
+ BaseCodeBlockPlugin,
654
+ BaseCodeLinePlugin,
655
+ // Table
656
+ BaseTablePlugin,
657
+ BaseTableRowPlugin,
658
+ BaseTableCellPlugin,
659
+ // Lists and indentation
660
+ BaseIndentPlugin,
661
+ BaseListPlugin,
662
+ // Media
663
+ BaseImagePlugin,
664
+ BaseVideoPlugin,
665
+ BaseAudioPlugin,
666
+ BaseFilePlugin,
667
+ BaseMediaEmbedPlugin,
668
+ // Layout
669
+ BaseColumnPlugin,
670
+ BaseColumnItemPlugin,
671
+ // Other
672
+ BaseLinkPlugin,
673
+ BaseCalloutPlugin,
674
+ BaseTogglePlugin,
675
+ BaseTocPlugin,
676
+ BaseMentionPlugin,
677
+ BaseDatePlugin,
678
+ BaseEquationPlugin,
679
+ BaseInlineEquationPlugin
680
+ ];
681
+
682
+ // src/lib/mdx/mdx-server-plugins.ts
683
+ var MdxBadgePlugin = createSlatePlugin({
684
+ key: "badge",
685
+ node: { isElement: true, isInline: true, isVoid: false, type: "badge" }
686
+ });
687
+ var MdxIconPlugin = createSlatePlugin({
688
+ key: "icon",
689
+ node: { isElement: true, isInline: true, isVoid: true, type: "icon" }
690
+ });
691
+ var MdxBannerPlugin = createSlatePlugin({
692
+ key: "banner",
693
+ node: { isElement: true, isVoid: false, type: "banner" }
694
+ });
695
+ var MdxAccordionGroupPlugin = createSlatePlugin({
696
+ key: "accordion_group",
697
+ node: { isElement: true, isVoid: false, type: "accordion_group" }
698
+ });
699
+ var MdxMermaidPlugin = createSlatePlugin({
700
+ key: "mermaid",
701
+ node: { isElement: true, isVoid: false, type: "mermaid" }
702
+ });
703
+ var SERVER_BLOCK_NODES = [
704
+ { key: "step" },
705
+ { key: "steps" },
706
+ { key: "tile" },
707
+ { key: "tiles" },
708
+ { key: "card" },
709
+ { key: "frame" },
710
+ { key: "update" },
711
+ { key: "updates" },
712
+ { key: "response_field" },
713
+ { key: "response_field_item" },
714
+ { key: "panel" },
715
+ { key: "expandable" },
716
+ { key: "tooltip", isInline: true },
717
+ { key: "tabs" },
718
+ { key: "tab" },
719
+ { key: "tabbed_code_block" },
720
+ { key: "tree" },
721
+ { key: "tree_folder" },
722
+ { key: "tree_file", isVoid: true },
723
+ { key: "color" },
724
+ { key: "color_item", isVoid: true }
725
+ ];
726
+ var buildServerNodePlugin = (definition) => {
727
+ var _a4, _b2;
728
+ return createSlatePlugin({
729
+ key: definition.key,
730
+ node: {
731
+ isElement: true,
732
+ isInline: (_a4 = definition.isInline) != null ? _a4 : false,
733
+ isVoid: (_b2 = definition.isVoid) != null ? _b2 : false,
734
+ type: definition.key
735
+ }
736
+ });
737
+ };
738
+ var MdxComponentPlugins = SERVER_BLOCK_NODES.map(buildServerNodePlugin);
739
+ var MdxServerPlugins = [
740
+ ...ServerPlugins,
741
+ MdxBadgePlugin,
742
+ MdxIconPlugin,
743
+ MdxBannerPlugin,
744
+ MdxAccordionGroupPlugin,
745
+ MdxMermaidPlugin,
746
+ ...MdxComponentPlugins
747
+ ];
748
+
749
+ // src/lib/mdx/mdx-tabbed-code-rules.ts
750
+ var CONTAINER_TAG = "TabbedCodeBlock";
751
+ var MAX_TABS = 64;
752
+ var DISPLAY_MODES = /* @__PURE__ */ new Set(["tabs", "dropdown"]);
753
+ var CONTAINER_STRING_FIELDS2 = /* @__PURE__ */ new Set(["displayMode", "syncKey"]);
754
+ var asTabMetaList = (value) => {
755
+ if (!Array.isArray(value)) {
756
+ return [];
757
+ }
758
+ const result = [];
759
+ for (const entry of value) {
760
+ if (typeof entry !== "object" || entry === null) {
761
+ continue;
762
+ }
763
+ const candidate = entry;
764
+ const id = typeof candidate.id === "string" ? candidate.id : "";
765
+ if (id.length === 0) {
766
+ continue;
767
+ }
768
+ const lineMarkingMeta = typeof candidate.lineMarkingMeta === "string" ? candidate.lineMarkingMeta : void 0;
769
+ result.push(__spreadValues({
770
+ id,
771
+ label: typeof candidate.label === "string" ? candidate.label : "",
772
+ lang: typeof candidate.lang === "string" && candidate.lang.length > 0 ? candidate.lang : "plaintext"
773
+ }, lineMarkingMeta && lineMarkingMeta.length > 0 ? { lineMarkingMeta } : {}));
774
+ }
775
+ return result;
776
+ };
777
+ var lineStringsFor = (node, tab, activeTabId) => {
778
+ if (tab.id === activeTabId) {
779
+ return codeLinesToStrings(node.children);
780
+ }
781
+ if (typeof node.tabContents !== "object" || node.tabContents === null || Array.isArray(node.tabContents)) {
782
+ return [];
783
+ }
784
+ const content = node.tabContents[tab.id];
785
+ if (typeof content !== "object" || content === null) {
786
+ return [];
787
+ }
788
+ const lines = content.lines;
789
+ return Array.isArray(lines) ? lines.filter((line) => typeof line === "string") : [];
790
+ };
791
+ var codeLinesToStrings = (children) => {
792
+ if (!Array.isArray(children)) {
793
+ return [];
794
+ }
795
+ return children.map((line) => {
796
+ if (typeof line !== "object" || line === null) {
797
+ return "";
798
+ }
799
+ const leaves = line.children;
800
+ if (!Array.isArray(leaves)) {
801
+ return "";
802
+ }
803
+ return leaves.map((leaf) => typeof leaf.text === "string" ? leaf.text : "").join("");
804
+ });
805
+ };
806
+ var LABEL_META = /^tab="((?:[^"\\]|\\.)*)"\s*/;
807
+ var escapeLabel = (value) => {
808
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
809
+ };
810
+ var unescapeLabel = (value) => {
811
+ return value.replace(/\\(["\\])/g, "$1");
812
+ };
813
+ var buildFenceMeta = (tab) => {
814
+ const tokens = [`tab="${escapeLabel(tab.label)}"`];
815
+ if (tab.lineMarkingMeta && tab.lineMarkingMeta.length > 0) {
816
+ tokens.push(tab.lineMarkingMeta);
817
+ }
818
+ return tokens.join(" ");
819
+ };
820
+ var parseFenceMeta = (meta) => {
821
+ if (typeof meta !== "string" || meta.trim().length === 0) {
822
+ return { label: "" };
823
+ }
824
+ const match = LABEL_META.exec(meta);
825
+ if (!match) {
826
+ const lineMarkingMeta2 = meta.trim();
827
+ return lineMarkingMeta2.length > 0 ? { label: "", lineMarkingMeta: lineMarkingMeta2 } : { label: "" };
828
+ }
829
+ const label = unescapeLabel(match[1]);
830
+ const lineMarkingMeta = meta.slice(match[0].length).trim();
831
+ return lineMarkingMeta.length > 0 ? { label, lineMarkingMeta } : { label };
832
+ };
833
+ var serializeTabFence = (node, tab, activeTabId) => {
834
+ return {
835
+ type: "code",
836
+ lang: tab.lang,
837
+ meta: buildFenceMeta(tab),
838
+ value: lineStringsFor(node, tab, activeTabId).join("\n")
839
+ };
840
+ };
841
+ var containerProps2 = (node) => {
842
+ const props = {};
843
+ const displayMode = node.displayMode;
844
+ if (typeof displayMode === "string" && DISPLAY_MODES.has(displayMode) && displayMode !== "tabs") {
845
+ props.displayMode = displayMode;
846
+ }
847
+ if (typeof node.syncKey === "string" && node.syncKey.length > 0) {
848
+ props.syncKey = node.syncKey;
849
+ }
850
+ return props;
851
+ };
852
+ var tabbedCodeSerialize = (node, _options) => {
853
+ var _a4, _b2;
854
+ const tabs = asTabMetaList(node.tabs);
855
+ const activeTabId = typeof node.activeTabId === "string" ? node.activeTabId : (_b2 = (_a4 = tabs[0]) == null ? void 0 : _a4.id) != null ? _b2 : "";
856
+ return {
857
+ type: "mdxJsxFlowElement",
858
+ name: CONTAINER_TAG,
859
+ attributes: propsToMdxAttributes(containerProps2(node)),
860
+ children: tabs.map((tab) => serializeTabFence(node, tab, activeTabId))
861
+ };
862
+ };
863
+ var isCodeNode = (node) => {
864
+ return typeof node === "object" && node !== null && node.type === "code";
865
+ };
866
+ var stringToCodeLines2 = (value) => {
867
+ return value.split("\n").map((line) => ({ type: "code_line", children: [{ text: line }] }));
868
+ };
869
+ var tabbedCodeDeserialize = (node, _deco, _options) => {
870
+ var _a4, _b2;
871
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], CONTAINER_STRING_FIELDS2);
872
+ const fences = (Array.isArray(node.children) ? node.children : []).filter(isCodeNode).slice(0, MAX_TABS);
873
+ const tabs = [];
874
+ const tabContents = {};
875
+ let activeChildren = [{ type: "code_line", children: [{ text: "" }] }];
876
+ fences.forEach((fence, index) => {
877
+ const id = `tab-${index + 1}`;
878
+ const value = typeof fence.value === "string" ? fence.value : "";
879
+ const lines = value.split("\n");
880
+ const { label, lineMarkingMeta } = parseFenceMeta(fence.meta);
881
+ tabs.push(__spreadValues({
882
+ id,
883
+ label,
884
+ lang: typeof fence.lang === "string" && fence.lang.length > 0 ? fence.lang : "plaintext"
885
+ }, lineMarkingMeta ? { lineMarkingMeta } : {}));
886
+ if (index === 0) {
887
+ activeChildren = stringToCodeLines2(value);
888
+ } else {
889
+ tabContents[id] = { lines };
890
+ }
891
+ });
892
+ const element = {
893
+ type: "tabbed_code_block",
894
+ activeTabId: (_b2 = (_a4 = tabs[0]) == null ? void 0 : _a4.id) != null ? _b2 : "",
895
+ tabs,
896
+ tabContents,
897
+ children: activeChildren
898
+ };
899
+ const displayMode = props.displayMode;
900
+ if (displayMode === "dropdown") {
901
+ element.displayMode = displayMode;
902
+ }
903
+ const syncKey = props.syncKey;
904
+ if (typeof syncKey === "string" && syncKey.length > 0) {
905
+ element.syncKey = syncKey;
906
+ }
907
+ return element;
908
+ };
909
+ var mdxTabbedCodeRules = {
910
+ tabbed_code_block: { serialize: tabbedCodeSerialize },
911
+ [CONTAINER_TAG]: { deserialize: tabbedCodeDeserialize }
912
+ };
913
+
914
+ // src/lib/mdx/mdx-tabs-rules.ts
915
+ import {
916
+ convertChildrenDeserialize as convertChildrenDeserialize3,
917
+ convertNodesSerialize as convertNodesSerialize3
918
+ } from "@platejs/markdown";
919
+ var TABS_TAG = "Tabs";
920
+ var TAB_TAG = "Tab";
921
+ var MAX_TABS2 = 64;
922
+ var TAB_STRING_FIELDS = /* @__PURE__ */ new Set(["title"]);
923
+ var CONTAINER_STRING_FIELDS3 = /* @__PURE__ */ new Set(["syncKey"]);
924
+ var asElements = (value) => {
925
+ if (!Array.isArray(value)) {
926
+ return [];
927
+ }
928
+ return value.filter((entry) => typeof entry === "object" && entry !== null);
929
+ };
930
+ var asTabMetaList2 = (value) => {
931
+ if (!Array.isArray(value)) {
932
+ return [];
933
+ }
934
+ const result = [];
935
+ for (const entry of value) {
936
+ if (typeof entry !== "object" || entry === null) {
937
+ continue;
938
+ }
939
+ const candidate = entry;
940
+ const id = typeof candidate.id === "string" ? candidate.id : "";
941
+ const label = typeof candidate.label === "string" ? candidate.label : "";
942
+ if (id.length > 0) {
943
+ result.push({ id, label });
944
+ }
945
+ }
946
+ return result;
947
+ };
948
+ var asContentMap = (value) => {
949
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
950
+ return {};
951
+ }
952
+ const map = {};
953
+ for (const [key, entry] of Object.entries(value)) {
954
+ map[key] = asElements(entry);
955
+ }
956
+ return map;
957
+ };
958
+ var tabContentFor = (node, tab, activeTabId) => {
959
+ var _a4;
960
+ if (tab.id === activeTabId) {
961
+ return asElements(node.children);
962
+ }
963
+ const contents = asContentMap(node.tabContents);
964
+ return (_a4 = contents[tab.id]) != null ? _a4 : [];
965
+ };
966
+ var attributesOf2 = (node) => {
967
+ return Array.isArray(node.attributes) ? node.attributes : [];
968
+ };
969
+ var childrenOf2 = (node) => {
970
+ return Array.isArray(node.children) ? node.children : [];
971
+ };
972
+ var containerSyncKey = (node) => {
973
+ return typeof node.syncKey === "string" && node.syncKey.length > 0 ? node.syncKey : void 0;
974
+ };
975
+ var serializeTab = (node, tab, activeTabId, options) => {
976
+ const content = tabContentFor(node, tab, activeTabId);
977
+ const children = content.length > 0 ? convertNodesSerialize3(content, options) : [];
978
+ return {
979
+ type: "mdxJsxFlowElement",
980
+ name: TAB_TAG,
981
+ attributes: propsToMdxAttributes({ title: tab.label }),
982
+ children
983
+ };
984
+ };
985
+ var tabsSerialize = (node, options) => {
986
+ var _a4, _b2;
987
+ const tabs = asTabMetaList2(node.tabs);
988
+ const activeTabId = typeof node.activeTabId === "string" ? node.activeTabId : (_b2 = (_a4 = tabs[0]) == null ? void 0 : _a4.id) != null ? _b2 : "";
989
+ const syncKey = containerSyncKey(node);
990
+ const children = tabs.map((tab) => serializeTab(node, tab, activeTabId, options));
991
+ return {
992
+ type: "mdxJsxFlowElement",
993
+ name: TABS_TAG,
994
+ attributes: propsToMdxAttributes(syncKey ? { syncKey } : {}),
995
+ children
996
+ };
997
+ };
998
+ var isTabElement = (node) => {
999
+ return typeof node === "object" && node !== null && node.name === TAB_TAG;
1000
+ };
1001
+ var tabsDeserialize = (node, deco, options) => {
1002
+ var _a4, _b2;
1003
+ const containerProps3 = mdxAttributesToProps(attributesOf2(node), CONTAINER_STRING_FIELDS3);
1004
+ const rawChildren = Array.isArray(node.children) ? node.children : [];
1005
+ const tabNodes = rawChildren.filter(isTabElement).slice(0, MAX_TABS2);
1006
+ const tabs = [];
1007
+ const tabContents = {};
1008
+ let activeChildren = [];
1009
+ tabNodes.forEach((tabNode, index) => {
1010
+ const tabProps = mdxAttributesToProps(attributesOf2(tabNode), TAB_STRING_FIELDS);
1011
+ const label = typeof tabProps.title === "string" ? tabProps.title : "";
1012
+ const id = `tab-${index + 1}`;
1013
+ const content = asElements(convertChildrenDeserialize3(childrenOf2(tabNode), normalizeDecoration2(deco), options));
1014
+ tabs.push({ id, label });
1015
+ if (index === 0) {
1016
+ activeChildren = content;
1017
+ } else {
1018
+ tabContents[id] = content;
1019
+ }
1020
+ });
1021
+ const element = {
1022
+ type: "tabs",
1023
+ activeTabId: (_b2 = (_a4 = tabs[0]) == null ? void 0 : _a4.id) != null ? _b2 : "",
1024
+ tabs,
1025
+ tabContents,
1026
+ children: activeChildren.length > 0 ? activeChildren : [{ type: "p", children: [{ text: "" }] }]
1027
+ };
1028
+ const syncKey = containerProps3.syncKey;
1029
+ if (typeof syncKey === "string" && syncKey.length > 0) {
1030
+ element.syncKey = syncKey;
1031
+ }
1032
+ return element;
1033
+ };
1034
+ var normalizeDecoration2 = (deco) => {
1035
+ return typeof deco === "object" && deco !== null && !Array.isArray(deco) ? deco : {};
1036
+ };
1037
+ var mdxTabsRules = {
1038
+ tabs: { serialize: tabsSerialize },
1039
+ [TABS_TAG]: { deserialize: tabsDeserialize }
1040
+ };
1041
+
1042
+ // src/lib/mdx/mdx-toggle-rules.ts
1043
+ import {
1044
+ convertChildrenDeserialize as convertChildrenDeserialize4,
1045
+ convertNodesSerialize as convertNodesSerialize4
1046
+ } from "@platejs/markdown";
1047
+ var TOGGLE_TAG = "Toggle";
1048
+ var ACCORDION_GROUP_TAG = "AccordionGroup";
1049
+ var ACCORDION_ITEM_TAG = "Accordion";
1050
+ var MAX_ACCORDION_ITEMS = 256;
1051
+ var TOGGLE_STRING_FIELDS = /* @__PURE__ */ new Set(["title", "description"]);
1052
+ var GROUP_STRIPPED_FIELDS = /* @__PURE__ */ new Set(["id", "type", "children"]);
1053
+ var asElementChildren2 = (node) => {
1054
+ return Array.isArray(node.children) ? node.children : [];
1055
+ };
1056
+ var childrenOf3 = (node) => {
1057
+ return Array.isArray(node.children) ? node.children : [];
1058
+ };
1059
+ var normalizeDecoration3 = (deco) => {
1060
+ return typeof deco === "object" && deco !== null && !Array.isArray(deco) ? deco : {};
1061
+ };
1062
+ var asString2 = (value) => {
1063
+ return typeof value === "string" ? value : "";
1064
+ };
1065
+ var asOptionalBoolean = (value) => {
1066
+ return typeof value === "boolean" ? value : void 0;
1067
+ };
1068
+ var placeholderChildren = () => {
1069
+ return [{ type: "p", children: [{ text: "" }] }];
1070
+ };
1071
+ var titleProps = (node) => {
1072
+ const props = {};
1073
+ const title = asString2(node.title);
1074
+ const description = asString2(node.description);
1075
+ const defaultOpen = asOptionalBoolean(node.defaultOpen);
1076
+ if (title.length > 0) {
1077
+ props.title = title;
1078
+ }
1079
+ if (description.length > 0) {
1080
+ props.description = description;
1081
+ }
1082
+ if (defaultOpen !== void 0) {
1083
+ props.defaultOpen = defaultOpen;
1084
+ }
1085
+ return props;
1086
+ };
1087
+ var toggleSerialize = (node, options) => {
1088
+ return {
1089
+ type: "mdxJsxFlowElement",
1090
+ name: TOGGLE_TAG,
1091
+ attributes: propsToMdxAttributes(titleProps(node)),
1092
+ children: convertNodesSerialize4(asElementChildren2(node), options)
1093
+ };
1094
+ };
1095
+ var toggleDeserialize = (node, deco, options) => {
1096
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], TOGGLE_STRING_FIELDS);
1097
+ const restored = restoreToggleProps(props);
1098
+ const children = convertChildrenDeserialize4(childrenOf3(node), normalizeDecoration3(deco), options);
1099
+ return __spreadProps(__spreadValues({
1100
+ type: "toggle"
1101
+ }, restored), {
1102
+ children: children.length > 0 ? children : placeholderChildren()
1103
+ });
1104
+ };
1105
+ var restoreToggleProps = (props) => {
1106
+ const restored = {};
1107
+ const title = asString2(props.title);
1108
+ const description = asString2(props.description);
1109
+ const defaultOpen = asOptionalBoolean(props.defaultOpen);
1110
+ if (title.length > 0) {
1111
+ restored.title = title;
1112
+ }
1113
+ if (description.length > 0) {
1114
+ restored.description = description;
1115
+ }
1116
+ if (defaultOpen !== void 0) {
1117
+ restored.defaultOpen = defaultOpen;
1118
+ }
1119
+ return restored;
1120
+ };
1121
+ var isToggleElement = (node) => {
1122
+ return typeof node === "object" && node !== null && node.type === "toggle";
1123
+ };
1124
+ var accordionItemSerialize = (item, options) => {
1125
+ return {
1126
+ type: "mdxJsxFlowElement",
1127
+ name: ACCORDION_ITEM_TAG,
1128
+ attributes: propsToMdxAttributes(titleProps(item)),
1129
+ children: convertNodesSerialize4(asElementChildren2(item), options)
1130
+ };
1131
+ };
1132
+ var groupContainerProps = (node) => {
1133
+ const props = {};
1134
+ for (const [field, value] of Object.entries(node)) {
1135
+ if (GROUP_STRIPPED_FIELDS.has(field) || value === void 0) {
1136
+ continue;
1137
+ }
1138
+ props[field] = value;
1139
+ }
1140
+ return props;
1141
+ };
1142
+ var accordionGroupSerialize = (node, options) => {
1143
+ const items = asElementChildren2(node).filter(isToggleElement).slice(0, MAX_ACCORDION_ITEMS);
1144
+ return {
1145
+ type: "mdxJsxFlowElement",
1146
+ name: ACCORDION_GROUP_TAG,
1147
+ attributes: propsToMdxAttributes(groupContainerProps(node)),
1148
+ children: items.map((item) => accordionItemSerialize(item, options))
1149
+ };
1150
+ };
1151
+ var isAccordionItemNode = (node) => {
1152
+ return typeof node === "object" && node !== null && node.name === ACCORDION_ITEM_TAG;
1153
+ };
1154
+ var accordionItemDeserialize = (node, deco, options) => {
1155
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], TOGGLE_STRING_FIELDS);
1156
+ const restored = restoreToggleProps(props);
1157
+ const children = convertChildrenDeserialize4(childrenOf3(node), normalizeDecoration3(deco), options);
1158
+ return __spreadProps(__spreadValues({
1159
+ type: "toggle"
1160
+ }, restored), {
1161
+ children: children.length > 0 ? children : placeholderChildren()
1162
+ });
1163
+ };
1164
+ var accordionGroupDeserialize = (node, deco, options) => {
1165
+ const containerProps3 = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], /* @__PURE__ */ new Set());
1166
+ const itemNodes = (Array.isArray(node.children) ? node.children : []).filter(isAccordionItemNode).slice(0, MAX_ACCORDION_ITEMS);
1167
+ const element = {
1168
+ type: "accordion_group",
1169
+ children: itemNodes.map((item) => accordionItemDeserialize(item, deco, options))
1170
+ };
1171
+ const allowMultiple = asOptionalBoolean(containerProps3.allowMultiple);
1172
+ if (allowMultiple !== void 0) {
1173
+ element.allowMultiple = allowMultiple;
1174
+ }
1175
+ return element;
1176
+ };
1177
+ var mdxToggleRules = {
1178
+ toggle: { serialize: toggleSerialize },
1179
+ accordion_group: { serialize: accordionGroupSerialize },
1180
+ [TOGGLE_TAG]: { deserialize: toggleDeserialize },
1181
+ [ACCORDION_GROUP_TAG]: { deserialize: accordionGroupDeserialize }
1182
+ };
1183
+
1184
+ // src/lib/mdx/mdx-tree-rules.ts
1185
+ var TREE_TAG = "Tree";
1186
+ var FOLDER_TAG = "TreeFolder";
1187
+ var FILE_TAG = "TreeFile";
1188
+ var MAX_DEPTH = 32;
1189
+ var MAX_ITEMS_PER_LEVEL = 512;
1190
+ var FILE_STRING_FIELDS = /* @__PURE__ */ new Set(["name"]);
1191
+ var FOLDER_STRING_FIELDS = /* @__PURE__ */ new Set(["name"]);
1192
+ var isRecord = (value) => {
1193
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1194
+ };
1195
+ var asString3 = (value) => {
1196
+ return typeof value === "string" ? value : "";
1197
+ };
1198
+ var asOptionalBoolean2 = (value) => {
1199
+ return typeof value === "boolean" ? value : void 0;
1200
+ };
1201
+ var fileToMdx = (item) => {
1202
+ const props = { name: asString3(item.name) };
1203
+ const highlighted = asOptionalBoolean2(item.highlighted);
1204
+ if (highlighted) {
1205
+ props.highlighted = highlighted;
1206
+ }
1207
+ return { type: "mdxJsxFlowElement", name: FILE_TAG, attributes: propsToMdxAttributes(props), children: [] };
1208
+ };
1209
+ var folderToMdx = (item, depth) => {
1210
+ const props = { name: asString3(item.name) };
1211
+ const defaultOpen = asOptionalBoolean2(item.defaultOpen);
1212
+ const openable = asOptionalBoolean2(item.openable);
1213
+ if (defaultOpen !== void 0) {
1214
+ props.defaultOpen = defaultOpen;
1215
+ }
1216
+ if (openable !== void 0) {
1217
+ props.openable = openable;
1218
+ }
1219
+ return {
1220
+ type: "mdxJsxFlowElement",
1221
+ name: FOLDER_TAG,
1222
+ attributes: propsToMdxAttributes(props),
1223
+ children: itemsToMdx(item.children, depth + 1)
1224
+ };
1225
+ };
1226
+ var itemsToMdx = (value, depth) => {
1227
+ if (depth > MAX_DEPTH || !Array.isArray(value)) {
1228
+ return [];
1229
+ }
1230
+ const result = [];
1231
+ for (const entry of value.slice(0, MAX_ITEMS_PER_LEVEL)) {
1232
+ if (!isRecord(entry)) {
1233
+ continue;
1234
+ }
1235
+ if (entry.type === "tree_folder") {
1236
+ result.push(folderToMdx(entry, depth));
1237
+ continue;
1238
+ }
1239
+ result.push(fileToMdx(entry));
1240
+ }
1241
+ return result;
1242
+ };
1243
+ var treeContainerProps = (node) => {
1244
+ const props = {};
1245
+ const showLines = asOptionalBoolean2(node.showLines);
1246
+ const coloredIcons = asOptionalBoolean2(node.coloredIcons);
1247
+ if (showLines !== void 0) {
1248
+ props.showLines = showLines;
1249
+ }
1250
+ if (coloredIcons !== void 0) {
1251
+ props.coloredIcons = coloredIcons;
1252
+ }
1253
+ return props;
1254
+ };
1255
+ var treeSerialize = (node, _options) => {
1256
+ return {
1257
+ type: "mdxJsxFlowElement",
1258
+ name: TREE_TAG,
1259
+ attributes: propsToMdxAttributes(treeContainerProps(node)),
1260
+ children: itemsToMdx(node.items, 0)
1261
+ };
1262
+ };
1263
+ var childElements2 = (node) => {
1264
+ if (!Array.isArray(node.children)) {
1265
+ return [];
1266
+ }
1267
+ return node.children.filter(
1268
+ (child) => typeof child === "object" && child !== null && typeof child.name === "string"
1269
+ );
1270
+ };
1271
+ var mdxToFile = (node, path) => {
1272
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], FILE_STRING_FIELDS);
1273
+ const highlighted = asOptionalBoolean2(props.highlighted);
1274
+ return __spreadValues({
1275
+ type: "tree_file",
1276
+ id: path,
1277
+ name: asString3(props.name)
1278
+ }, highlighted ? { highlighted } : {});
1279
+ };
1280
+ var mdxToFolder = (node, depth, path) => {
1281
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], FOLDER_STRING_FIELDS);
1282
+ const defaultOpen = asOptionalBoolean2(props.defaultOpen);
1283
+ const openable = asOptionalBoolean2(props.openable);
1284
+ return __spreadProps(__spreadValues(__spreadValues({
1285
+ type: "tree_folder",
1286
+ id: path,
1287
+ name: asString3(props.name)
1288
+ }, defaultOpen !== void 0 ? { defaultOpen } : {}), openable !== void 0 ? { openable } : {}), {
1289
+ children: mdxToItems(node, depth + 1, path)
1290
+ });
1291
+ };
1292
+ var mdxToItems = (node, depth, parentPath) => {
1293
+ if (depth > MAX_DEPTH) {
1294
+ return [];
1295
+ }
1296
+ const items = [];
1297
+ let position = 0;
1298
+ for (const child of childElements2(node).slice(0, MAX_ITEMS_PER_LEVEL)) {
1299
+ position += 1;
1300
+ const path = parentPath.length > 0 ? `${parentPath}-${position}` : `tree-${position}`;
1301
+ if (child.name === FOLDER_TAG) {
1302
+ items.push(mdxToFolder(child, depth, path));
1303
+ continue;
1304
+ }
1305
+ if (child.name === FILE_TAG) {
1306
+ items.push(mdxToFile(child, path));
1307
+ }
1308
+ }
1309
+ return items;
1310
+ };
1311
+ var treeDeserialize = (node, _deco, _options) => {
1312
+ const props = mdxAttributesToProps(Array.isArray(node.attributes) ? node.attributes : [], /* @__PURE__ */ new Set());
1313
+ const element = {
1314
+ type: "tree",
1315
+ items: mdxToItems(node, 0, ""),
1316
+ children: [{ text: "" }]
1317
+ };
1318
+ const showLines = asOptionalBoolean2(props.showLines);
1319
+ if (showLines !== void 0) {
1320
+ element.showLines = showLines;
1321
+ }
1322
+ const coloredIcons = asOptionalBoolean2(props.coloredIcons);
1323
+ if (coloredIcons !== void 0) {
1324
+ element.coloredIcons = coloredIcons;
1325
+ }
1326
+ return element;
1327
+ };
1328
+ var mdxTreeRules = {
1329
+ tree: { serialize: treeSerialize },
1330
+ [TREE_TAG]: { deserialize: treeDeserialize }
1331
+ };
1332
+
1333
+ // src/lib/mdx/mdx-round-trip.ts
1334
+ var EMPTY_VALUE = [{ type: "p", children: [{ text: "" }] }];
1335
+ var REMARK_STRINGIFY_OPTIONS = {
1336
+ bullet: "-",
1337
+ rule: "-",
1338
+ emphasis: "_",
1339
+ strong: "*",
1340
+ listItemIndent: "one",
1341
+ fences: true,
1342
+ incrementListMarker: true
1343
+ };
1344
+ var asTextValue = (node) => {
1345
+ return { type: "text", value: typeof node.text === "string" ? node.text : "" };
1346
+ };
1347
+ var ANNOTATION_MARK_KEYS = [
1348
+ KEYS.comment,
1349
+ KEYS.suggestion,
1350
+ KEYS.backgroundColor,
1351
+ KEYS.fontFamily,
1352
+ KEYS.fontSize,
1353
+ KEYS.fontWeight
1354
+ ];
1355
+ var buildAnnotationMarkRules = () => {
1356
+ const rules = {};
1357
+ for (const key of ANNOTATION_MARK_KEYS) {
1358
+ rules[key] = { mark: true, serialize: asTextValue };
1359
+ }
1360
+ return rules;
1361
+ };
1362
+ var buildMdRules = () => {
1363
+ return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, mdxArchetypeRules), mdxComponentRules), mdxReferenceRules), mdxTabsRules), mdxTabbedCodeRules), mdxTreeRules), mdxColorRules), mdxToggleRules), mdxMermaidRules), buildAnnotationMarkRules());
1364
+ };
1365
+ var buildMarkdownPlugin = () => {
1366
+ return MarkdownPlugin.configure({
1367
+ options: {
1368
+ remarkPlugins: [remarkMdx],
1369
+ rules: buildMdRules(),
1370
+ remarkStringifyOptions: REMARK_STRINGIFY_OPTIONS
1371
+ }
1372
+ });
1373
+ };
1374
+ var createMdxEditor = () => {
1375
+ return createSlateEditor({
1376
+ plugins: [...MdxServerPlugins, buildMarkdownPlugin()],
1377
+ value: EMPTY_VALUE
1378
+ });
1379
+ };
1380
+ var serializeToMdx = (value) => {
1381
+ if (!Array.isArray(value) || value.length === 0) {
1382
+ return "";
1383
+ }
1384
+ const editor = createMdxEditor();
1385
+ return serializeMd(editor, { value });
1386
+ };
1387
+ var deserializeFromMdx = (markdown) => {
1388
+ if (typeof markdown !== "string" || markdown.trim().length === 0) {
1389
+ return [];
1390
+ }
1391
+ const editor = createMdxEditor();
1392
+ return deserializeMd(editor, markdown);
1393
+ };
1394
+ export {
1395
+ deserializeFromMdx,
1396
+ serializeToMdx
1397
+ };