@fuma-content/studio 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/dist/bin.d.mts +1 -0
  2. package/dist/bin.mjs +90 -0
  3. package/dist/index.d.mts +13 -0
  4. package/dist/index.mjs +66 -0
  5. package/dist/mdx/actions.mjs +34 -0
  6. package/dist/mdx/client.mjs +167 -0
  7. package/dist/package.mjs +6 -0
  8. package/dist/src/components/code-editor/mdx.lazy.mjs +19 -0
  9. package/dist/src/components/code-editor/mdx.mjs +44 -0
  10. package/dist/src/components/code-editor/yaml.lazy.mjs +22 -0
  11. package/dist/src/components/code-editor/yaml.mjs +63 -0
  12. package/dist/src/components/editor/editor-base-kit.mjs +41 -0
  13. package/dist/src/components/editor/editor-kit.mjs +73 -0
  14. package/dist/src/components/editor/md.mjs +42 -0
  15. package/dist/src/components/editor/plugins/ai-kit.mjs +68 -0
  16. package/dist/src/components/editor/plugins/align-base-kit.mjs +28 -0
  17. package/dist/src/components/editor/plugins/align-kit.mjs +30 -0
  18. package/dist/src/components/editor/plugins/autoformat-kit.mjs +214 -0
  19. package/dist/src/components/editor/plugins/basic-blocks-base-kit.mjs +22 -0
  20. package/dist/src/components/editor/plugins/basic-blocks-kit.mjs +51 -0
  21. package/dist/src/components/editor/plugins/basic-marks-base-kit.mjs +20 -0
  22. package/dist/src/components/editor/plugins/basic-marks-kit.mjs +28 -0
  23. package/dist/src/components/editor/plugins/block-menu-kit.mjs +11 -0
  24. package/dist/src/components/editor/plugins/block-placeholder-kit.mjs +14 -0
  25. package/dist/src/components/editor/plugins/block-selection-kit.mjs +48 -0
  26. package/dist/src/components/editor/plugins/callout-base-kit.mjs +8 -0
  27. package/dist/src/components/editor/plugins/callout-kit.mjs +10 -0
  28. package/dist/src/components/editor/plugins/code-block-base-kit.mjs +16 -0
  29. package/dist/src/components/editor/plugins/code-block-kit.mjs +19 -0
  30. package/dist/src/components/editor/plugins/column-base-kit.mjs +8 -0
  31. package/dist/src/components/editor/plugins/column-kit.mjs +10 -0
  32. package/dist/src/components/editor/plugins/comment-base-kit.mjs +8 -0
  33. package/dist/src/components/editor/plugins/comment-kit.mjs +53 -0
  34. package/dist/src/components/editor/plugins/copilot-kit.mjs +49 -0
  35. package/dist/src/components/editor/plugins/cursor-overlay-kit.mjs +11 -0
  36. package/dist/src/components/editor/plugins/date-base-kit.mjs +8 -0
  37. package/dist/src/components/editor/plugins/date-kit.mjs +10 -0
  38. package/dist/src/components/editor/plugins/discussion-kit.mjs +94 -0
  39. package/dist/src/components/editor/plugins/dnd-kit.mjs +31 -0
  40. package/dist/src/components/editor/plugins/emoji-kit.mjs +11 -0
  41. package/dist/src/components/editor/plugins/exit-break-kit.mjs +12 -0
  42. package/dist/src/components/editor/plugins/fixed-toolbar-kit.mjs +15 -0
  43. package/dist/src/components/editor/plugins/floating-toolbar-kit.mjs +15 -0
  44. package/dist/src/components/editor/plugins/font-base-kit.mjs +14 -0
  45. package/dist/src/components/editor/plugins/font-kit.mjs +19 -0
  46. package/dist/src/components/editor/plugins/indent-base-kit.mjs +17 -0
  47. package/dist/src/components/editor/plugins/indent-kit.mjs +20 -0
  48. package/dist/src/components/editor/plugins/line-height-base-kit.mjs +20 -0
  49. package/dist/src/components/editor/plugins/line-height-kit.mjs +22 -0
  50. package/dist/src/components/editor/plugins/link-base-kit.mjs +8 -0
  51. package/dist/src/components/editor/plugins/link-kit.mjs +15 -0
  52. package/dist/src/components/editor/plugins/list-base-kit.mjs +19 -0
  53. package/dist/src/components/editor/plugins/list-kit.mjs +22 -0
  54. package/dist/src/components/editor/plugins/markdown-kit.mjs +17 -0
  55. package/dist/src/components/editor/plugins/math-base-kit.mjs +8 -0
  56. package/dist/src/components/editor/plugins/math-kit.mjs +10 -0
  57. package/dist/src/components/editor/plugins/media-base-kit.mjs +23 -0
  58. package/dist/src/components/editor/plugins/media-kit.mjs +37 -0
  59. package/dist/src/components/editor/plugins/slash-kit.mjs +11 -0
  60. package/dist/src/components/editor/plugins/suggestion-base-kit.mjs +8 -0
  61. package/dist/src/components/editor/plugins/suggestion-kit.mjs +50 -0
  62. package/dist/src/components/editor/plugins/table-base-kit.mjs +13 -0
  63. package/dist/src/components/editor/plugins/table-kit.mjs +15 -0
  64. package/dist/src/components/editor/transforms.mjs +125 -0
  65. package/dist/src/components/editor/ui/ai-chat-editor.mjs +21 -0
  66. package/dist/src/components/editor/ui/ai-menu.mjs +488 -0
  67. package/dist/src/components/editor/ui/ai-node.mjs +24 -0
  68. package/dist/src/components/editor/ui/ai-toolbar-button.mjs +23 -0
  69. package/dist/src/components/editor/ui/align-toolbar-button.mjs +71 -0
  70. package/dist/src/components/editor/ui/block-context-menu.mjs +130 -0
  71. package/dist/src/components/editor/ui/block-discussion.mjs +200 -0
  72. package/dist/src/components/editor/ui/block-draggable.mjs +265 -0
  73. package/dist/src/components/editor/ui/block-list-static.mjs +48 -0
  74. package/dist/src/components/editor/ui/block-list.mjs +47 -0
  75. package/dist/src/components/editor/ui/block-selection.mjs +28 -0
  76. package/dist/src/components/editor/ui/block-suggestion.mjs +319 -0
  77. package/dist/src/components/editor/ui/blockquote-node-static.mjs +14 -0
  78. package/dist/src/components/editor/ui/blockquote-node.mjs +16 -0
  79. package/dist/src/components/editor/ui/callout-node-static.mjs +29 -0
  80. package/dist/src/components/editor/ui/callout-node.mjs +50 -0
  81. package/dist/src/components/editor/ui/caption.mjs +39 -0
  82. package/dist/src/components/editor/ui/code-block-node-static.mjs +30 -0
  83. package/dist/src/components/editor/ui/code-block-node.mjs +121 -0
  84. package/dist/src/components/editor/ui/code-node-static.mjs +15 -0
  85. package/dist/src/components/editor/ui/code-node.mjs +17 -0
  86. package/dist/src/components/editor/ui/column-node-static.mjs +32 -0
  87. package/dist/src/components/editor/ui/column-node.mjs +229 -0
  88. package/dist/src/components/editor/ui/comment-node-static.mjs +14 -0
  89. package/dist/src/components/editor/ui/comment-node.mjs +33 -0
  90. package/dist/src/components/editor/ui/comment-toolbar-button.mjs +23 -0
  91. package/dist/src/components/editor/ui/comment.mjs +422 -0
  92. package/dist/src/components/editor/ui/cursor-overlay.mjs +36 -0
  93. package/dist/src/components/editor/ui/date-node-static.mjs +32 -0
  94. package/dist/src/components/editor/ui/date-node.mjs +60 -0
  95. package/dist/src/components/editor/ui/editor-static.mjs +31 -0
  96. package/dist/src/components/editor/ui/editor.mjs +60 -0
  97. package/dist/src/components/editor/ui/emoji-node.mjs +46 -0
  98. package/dist/src/components/editor/ui/emoji-toolbar-button.mjs +415 -0
  99. package/dist/src/components/editor/ui/equation-node-static.mjs +65 -0
  100. package/dist/src/components/editor/ui/equation-node.mjs +159 -0
  101. package/dist/src/components/editor/ui/equation-toolbar-button.mjs +23 -0
  102. package/dist/src/components/editor/ui/fixed-toolbar-buttons.mjs +109 -0
  103. package/dist/src/components/editor/ui/fixed-toolbar.mjs +16 -0
  104. package/dist/src/components/editor/ui/floating-toolbar-buttons.mjs +54 -0
  105. package/dist/src/components/editor/ui/floating-toolbar.mjs +51 -0
  106. package/dist/src/components/editor/ui/font-color-toolbar-button.mjs +637 -0
  107. package/dist/src/components/editor/ui/font-size-toolbar-button.mjs +83 -0
  108. package/dist/src/components/editor/ui/ghost-text.mjs +22 -0
  109. package/dist/src/components/editor/ui/heading-node-static.mjs +60 -0
  110. package/dist/src/components/editor/ui/heading-node.mjs +62 -0
  111. package/dist/src/components/editor/ui/highlight-node-static.mjs +15 -0
  112. package/dist/src/components/editor/ui/highlight-node.mjs +17 -0
  113. package/dist/src/components/editor/ui/history-toolbar-button.mjs +35 -0
  114. package/dist/src/components/editor/ui/hr-node-static.mjs +18 -0
  115. package/dist/src/components/editor/ui/hr-node.mjs +23 -0
  116. package/dist/src/components/editor/ui/indent-toolbar-button.mjs +29 -0
  117. package/dist/src/components/editor/ui/inline-combobox.mjs +148 -0
  118. package/dist/src/components/editor/ui/insert-toolbar-button.mjs +199 -0
  119. package/dist/src/components/editor/ui/kbd-node-static.mjs +15 -0
  120. package/dist/src/components/editor/ui/kbd-node.mjs +17 -0
  121. package/dist/src/components/editor/ui/line-height-toolbar-button.mjs +56 -0
  122. package/dist/src/components/editor/ui/link-node-static.mjs +20 -0
  123. package/dist/src/components/editor/ui/link-node.mjs +28 -0
  124. package/dist/src/components/editor/ui/link-toolbar-button.mjs +21 -0
  125. package/dist/src/components/editor/ui/link-toolbar.mjs +141 -0
  126. package/dist/src/components/editor/ui/list-toolbar-button.mjs +131 -0
  127. package/dist/src/components/editor/ui/mark-toolbar-button.mjs +20 -0
  128. package/dist/src/components/editor/ui/media-image-node-static.mjs +32 -0
  129. package/dist/src/components/editor/ui/media-image-node.mjs +64 -0
  130. package/dist/src/components/editor/ui/media-placeholder-node.mjs +184 -0
  131. package/dist/src/components/editor/ui/media-preview-dialog.mjs +113 -0
  132. package/dist/src/components/editor/ui/media-toolbar-button.mjs +156 -0
  133. package/dist/src/components/editor/ui/media-toolbar.mjs +80 -0
  134. package/dist/src/components/editor/ui/media-upload-toast.mjs +39 -0
  135. package/dist/src/components/editor/ui/media-video-node-static.mjs +27 -0
  136. package/dist/src/components/editor/ui/mode-toolbar-button.mjs +112 -0
  137. package/dist/src/components/editor/ui/paragraph-node-static.mjs +15 -0
  138. package/dist/src/components/editor/ui/paragraph-node.mjs +17 -0
  139. package/dist/src/components/editor/ui/resize-handle.mjs +43 -0
  140. package/dist/src/components/editor/ui/slash-node.mjs +228 -0
  141. package/dist/src/components/editor/ui/suggestion-node-static.mjs +24 -0
  142. package/dist/src/components/editor/ui/suggestion-node.mjs +111 -0
  143. package/dist/src/components/editor/ui/suggestion-toolbar-button.mjs +24 -0
  144. package/dist/src/components/editor/ui/table-icons.mjs +1310 -0
  145. package/dist/src/components/editor/ui/table-node-static.mjs +68 -0
  146. package/dist/src/components/editor/ui/table-node.mjs +375 -0
  147. package/dist/src/components/editor/ui/table-toolbar-button.mjs +190 -0
  148. package/dist/src/components/editor/ui/turn-into-toolbar-button.mjs +168 -0
  149. package/dist/src/components/editor/use-chat.mjs +80 -0
  150. package/dist/src/components/json-schema-editor/client.mjs +46 -0
  151. package/dist/src/components/json-schema-editor/components/inputs.mjs +438 -0
  152. package/dist/src/components/json-schema-editor/get-default-values.mjs +23 -0
  153. package/dist/src/components/json-schema-editor/schema.mjs +131 -0
  154. package/dist/src/components/json-schema-editor/utils/merge-schema.mjs +134 -0
  155. package/dist/src/components/json-schema-editor/utils/schema-to-string.mjs +53 -0
  156. package/dist/src/components/ui/alert-dialog.mjs +90 -0
  157. package/dist/src/components/ui/avatar.mjs +32 -0
  158. package/dist/src/components/ui/button.mjs +48 -0
  159. package/dist/src/components/ui/calendar.mjs +108 -0
  160. package/dist/src/components/ui/checkbox.mjs +23 -0
  161. package/dist/src/components/ui/combobox.mjs +53 -0
  162. package/dist/src/components/ui/command.mjs +42 -0
  163. package/dist/src/components/ui/context-menu.mjs +67 -0
  164. package/dist/src/components/ui/dialog.mjs +9 -0
  165. package/dist/src/components/ui/dropdown-menu.mjs +122 -0
  166. package/dist/src/components/ui/input-group.mjs +31 -0
  167. package/dist/src/components/ui/input.mjs +15 -0
  168. package/dist/src/components/ui/label.mjs +19 -0
  169. package/dist/src/components/ui/popover.mjs +37 -0
  170. package/dist/src/components/ui/select.mjs +80 -0
  171. package/dist/src/components/ui/separator.mjs +19 -0
  172. package/dist/src/components/ui/spinner.mjs +16 -0
  173. package/dist/src/components/ui/tabs.mjs +39 -0
  174. package/dist/src/components/ui/textarea.mjs +14 -0
  175. package/dist/src/components/ui/toolbar.mjs +183 -0
  176. package/dist/src/components/ui/tooltip.mjs +38 -0
  177. package/dist/src/hooks/editor/use-is-creator.mjs +19 -0
  178. package/dist/src/hooks/use-upload-file.mjs +73 -0
  179. package/dist/src/lib/config.mjs +38 -0
  180. package/dist/src/lib/data/store.d.mts +15 -0
  181. package/dist/src/lib/lowlight.mjs +7 -0
  182. package/dist/src/lib/utils/deep-equal.mjs +18 -0
  183. package/dist/src/lib/utils/remove-undefined.mjs +18 -0
  184. package/dist/src/lib/utils.mjs +10 -0
  185. package/dist/types.d.mts +50 -0
  186. package/next.config.ts +23 -0
  187. package/package.json +131 -0
  188. package/postcss.config.mjs +7 -0
  189. package/src/app/(dashboard)/collection/[name]/[...slug]/page.client.tsx +26 -0
  190. package/src/app/(dashboard)/collection/[name]/[...slug]/page.tsx +17 -0
  191. package/src/app/(dashboard)/collection/[name]/page.client.tsx +82 -0
  192. package/src/app/(dashboard)/collection/[name]/page.tsx +11 -0
  193. package/src/app/(dashboard)/layout.tsx +34 -0
  194. package/src/app/(dashboard)/page.tsx +38 -0
  195. package/src/app/api/ai/command/prompts.ts +313 -0
  196. package/src/app/api/ai/command/route.ts +203 -0
  197. package/src/app/api/ai/command/utils.ts +242 -0
  198. package/src/app/api/ai/copilot/route.ts +33 -0
  199. package/src/app/api/uploadthing/route.ts +5 -0
  200. package/src/app/codeblock/LICENSE +21 -0
  201. package/src/app/codeblock/styles.css +289 -0
  202. package/src/app/favicon.ico +0 -0
  203. package/src/app/globals.css +223 -0
  204. package/src/app/layout.client.tsx +15 -0
  205. package/src/app/layout.tsx +30 -0
  206. package/src/components/app-sidebar.tsx +162 -0
  207. package/src/components/code-editor/mdx.lazy.tsx +18 -0
  208. package/src/components/code-editor/mdx.tsx +48 -0
  209. package/src/components/code-editor/yaml.lazy.tsx +20 -0
  210. package/src/components/code-editor/yaml.tsx +71 -0
  211. package/src/components/collection/actions.tsx +41 -0
  212. package/src/components/collection/client.tsx +63 -0
  213. package/src/components/collection/context.tsx +24 -0
  214. package/src/components/collection/document/actions.tsx +83 -0
  215. package/src/components/editor/editor-base-kit.tsx +37 -0
  216. package/src/components/editor/editor-kit.tsx +87 -0
  217. package/src/components/editor/md.tsx +60 -0
  218. package/src/components/editor/plugins/ai-kit.tsx +102 -0
  219. package/src/components/editor/plugins/align-base-kit.tsx +16 -0
  220. package/src/components/editor/plugins/align-kit.tsx +18 -0
  221. package/src/components/editor/plugins/autoformat-kit.tsx +236 -0
  222. package/src/components/editor/plugins/basic-blocks-base-kit.tsx +34 -0
  223. package/src/components/editor/plugins/basic-blocks-kit.tsx +87 -0
  224. package/src/components/editor/plugins/basic-marks-base-kit.tsx +26 -0
  225. package/src/components/editor/plugins/basic-marks-kit.tsx +40 -0
  226. package/src/components/editor/plugins/basic-nodes-kit.tsx +6 -0
  227. package/src/components/editor/plugins/block-menu-kit.tsx +14 -0
  228. package/src/components/editor/plugins/block-placeholder-kit.tsx +17 -0
  229. package/src/components/editor/plugins/block-selection-kit.tsx +54 -0
  230. package/src/components/editor/plugins/callout-base-kit.tsx +5 -0
  231. package/src/components/editor/plugins/callout-kit.tsx +7 -0
  232. package/src/components/editor/plugins/code-block-base-kit.tsx +16 -0
  233. package/src/components/editor/plugins/code-block-kit.tsx +19 -0
  234. package/src/components/editor/plugins/column-base-kit.tsx +11 -0
  235. package/src/components/editor/plugins/column-kit.tsx +10 -0
  236. package/src/components/editor/plugins/comment-base-kit.tsx +5 -0
  237. package/src/components/editor/plugins/comment-kit.tsx +92 -0
  238. package/src/components/editor/plugins/copilot-kit.tsx +70 -0
  239. package/src/components/editor/plugins/cursor-overlay-kit.tsx +13 -0
  240. package/src/components/editor/plugins/date-base-kit.tsx +5 -0
  241. package/src/components/editor/plugins/date-kit.tsx +7 -0
  242. package/src/components/editor/plugins/discussion-kit.tsx +142 -0
  243. package/src/components/editor/plugins/dnd-kit.tsx +25 -0
  244. package/src/components/editor/plugins/emoji-kit.tsx +13 -0
  245. package/src/components/editor/plugins/exit-break-kit.tsx +12 -0
  246. package/src/components/editor/plugins/fixed-toolbar-kit.tsx +19 -0
  247. package/src/components/editor/plugins/floating-toolbar-kit.tsx +19 -0
  248. package/src/components/editor/plugins/font-base-kit.tsx +20 -0
  249. package/src/components/editor/plugins/font-kit.tsx +29 -0
  250. package/src/components/editor/plugins/indent-base-kit.tsx +13 -0
  251. package/src/components/editor/plugins/indent-kit.tsx +22 -0
  252. package/src/components/editor/plugins/line-height-base-kit.tsx +14 -0
  253. package/src/components/editor/plugins/line-height-kit.tsx +16 -0
  254. package/src/components/editor/plugins/link-base-kit.tsx +5 -0
  255. package/src/components/editor/plugins/link-kit.tsx +15 -0
  256. package/src/components/editor/plugins/list-base-kit.tsx +17 -0
  257. package/src/components/editor/plugins/list-kit.tsx +26 -0
  258. package/src/components/editor/plugins/markdown-kit.tsx +13 -0
  259. package/src/components/editor/plugins/math-base-kit.tsx +11 -0
  260. package/src/components/editor/plugins/math-kit.tsx +10 -0
  261. package/src/components/editor/plugins/media-base-kit.tsx +25 -0
  262. package/src/components/editor/plugins/media-kit.tsx +28 -0
  263. package/src/components/editor/plugins/slash-kit.tsx +18 -0
  264. package/src/components/editor/plugins/suggestion-base-kit.tsx +5 -0
  265. package/src/components/editor/plugins/suggestion-kit.tsx +83 -0
  266. package/src/components/editor/plugins/table-base-kit.tsx +20 -0
  267. package/src/components/editor/plugins/table-kit.tsx +22 -0
  268. package/src/components/editor/settings-dialog.tsx +418 -0
  269. package/src/components/editor/transforms.ts +193 -0
  270. package/src/components/editor/types.ts +149 -0
  271. package/src/components/editor/ui/ai-chat-editor.tsx +20 -0
  272. package/src/components/editor/ui/ai-menu.tsx +663 -0
  273. package/src/components/editor/ui/ai-node.tsx +40 -0
  274. package/src/components/editor/ui/ai-toolbar-button.tsx +23 -0
  275. package/src/components/editor/ui/align-toolbar-button.tsx +78 -0
  276. package/src/components/editor/ui/block-context-menu.tsx +154 -0
  277. package/src/components/editor/ui/block-discussion.tsx +318 -0
  278. package/src/components/editor/ui/block-draggable.tsx +464 -0
  279. package/src/components/editor/ui/block-list-static.tsx +75 -0
  280. package/src/components/editor/ui/block-list.tsx +72 -0
  281. package/src/components/editor/ui/block-selection.tsx +37 -0
  282. package/src/components/editor/ui/block-suggestion.tsx +438 -0
  283. package/src/components/editor/ui/blockquote-node-static.tsx +5 -0
  284. package/src/components/editor/ui/blockquote-node.tsx +7 -0
  285. package/src/components/editor/ui/callout-node-static.tsx +30 -0
  286. package/src/components/editor/ui/callout-node.tsx +64 -0
  287. package/src/components/editor/ui/caption.tsx +55 -0
  288. package/src/components/editor/ui/code-block-node-static.tsx +33 -0
  289. package/src/components/editor/ui/code-block-node.tsx +161 -0
  290. package/src/components/editor/ui/code-node-static.tsx +15 -0
  291. package/src/components/editor/ui/code-node.tsx +17 -0
  292. package/src/components/editor/ui/column-node-static.tsx +27 -0
  293. package/src/components/editor/ui/column-node.tsx +285 -0
  294. package/src/components/editor/ui/comment-node-static.tsx +12 -0
  295. package/src/components/editor/ui/comment-node.tsx +43 -0
  296. package/src/components/editor/ui/comment-toolbar-button.tsx +24 -0
  297. package/src/components/editor/ui/comment.tsx +577 -0
  298. package/src/components/editor/ui/cursor-overlay.tsx +66 -0
  299. package/src/components/editor/ui/date-node-static.tsx +45 -0
  300. package/src/components/editor/ui/date-node.tsx +86 -0
  301. package/src/components/editor/ui/editor-static.tsx +47 -0
  302. package/src/components/editor/ui/editor.tsx +120 -0
  303. package/src/components/editor/ui/emoji-node.tsx +65 -0
  304. package/src/components/editor/ui/emoji-toolbar-button.tsx +582 -0
  305. package/src/components/editor/ui/equation-node-static.tsx +94 -0
  306. package/src/components/editor/ui/equation-node.tsx +218 -0
  307. package/src/components/editor/ui/equation-toolbar-button.tsx +24 -0
  308. package/src/components/editor/ui/fixed-toolbar-buttons.tsx +135 -0
  309. package/src/components/editor/ui/fixed-toolbar.tsx +17 -0
  310. package/src/components/editor/ui/floating-toolbar-buttons.tsx +72 -0
  311. package/src/components/editor/ui/floating-toolbar.tsx +76 -0
  312. package/src/components/editor/ui/font-color-toolbar-button.tsx +804 -0
  313. package/src/components/editor/ui/font-size-toolbar-button.tsx +102 -0
  314. package/src/components/editor/ui/ghost-text.tsx +27 -0
  315. package/src/components/editor/ui/heading-node-static.tsx +54 -0
  316. package/src/components/editor/ui/heading-node.tsx +54 -0
  317. package/src/components/editor/ui/highlight-node-static.tsx +11 -0
  318. package/src/components/editor/ui/highlight-node.tsx +13 -0
  319. package/src/components/editor/ui/history-toolbar-button.tsx +41 -0
  320. package/src/components/editor/ui/hr-node-static.tsx +16 -0
  321. package/src/components/editor/ui/hr-node.tsx +28 -0
  322. package/src/components/editor/ui/indent-toolbar-button.tsx +27 -0
  323. package/src/components/editor/ui/inline-combobox.tsx +251 -0
  324. package/src/components/editor/ui/insert-toolbar-button.tsx +242 -0
  325. package/src/components/editor/ui/kbd-node-static.tsx +15 -0
  326. package/src/components/editor/ui/kbd-node.tsx +17 -0
  327. package/src/components/editor/ui/line-height-toolbar-button.tsx +66 -0
  328. package/src/components/editor/ui/link-node-static.tsx +21 -0
  329. package/src/components/editor/ui/link-node.tsx +37 -0
  330. package/src/components/editor/ui/link-toolbar-button.tsx +18 -0
  331. package/src/components/editor/ui/link-toolbar.tsx +196 -0
  332. package/src/components/editor/ui/list-toolbar-button.tsx +195 -0
  333. package/src/components/editor/ui/mark-toolbar-button.tsx +20 -0
  334. package/src/components/editor/ui/media-image-node-static.tsx +33 -0
  335. package/src/components/editor/ui/media-image-node.tsx +75 -0
  336. package/src/components/editor/ui/media-placeholder-node.tsx +235 -0
  337. package/src/components/editor/ui/media-preview-dialog.tsx +145 -0
  338. package/src/components/editor/ui/media-toolbar-button.tsx +202 -0
  339. package/src/components/editor/ui/media-toolbar.tsx +100 -0
  340. package/src/components/editor/ui/media-upload-toast.tsx +59 -0
  341. package/src/components/editor/ui/media-video-node-static.tsx +23 -0
  342. package/src/components/editor/ui/mode-toolbar-button.tsx +121 -0
  343. package/src/components/editor/ui/paragraph-node-static.tsx +13 -0
  344. package/src/components/editor/ui/paragraph-node.tsx +15 -0
  345. package/src/components/editor/ui/resize-handle.tsx +79 -0
  346. package/src/components/editor/ui/slash-node.tsx +274 -0
  347. package/src/components/editor/ui/suggestion-node-static.tsx +30 -0
  348. package/src/components/editor/ui/suggestion-node.tsx +157 -0
  349. package/src/components/editor/ui/suggestion-toolbar-button.tsx +25 -0
  350. package/src/components/editor/ui/table-icons.tsx +685 -0
  351. package/src/components/editor/ui/table-node-static.tsx +86 -0
  352. package/src/components/editor/ui/table-node.tsx +569 -0
  353. package/src/components/editor/ui/table-toolbar-button.tsx +260 -0
  354. package/src/components/editor/ui/turn-into-toolbar-button.tsx +176 -0
  355. package/src/components/editor/use-chat.ts +120 -0
  356. package/src/components/icons/logo.tsx +37 -0
  357. package/src/components/json-schema-editor/client.tsx +55 -0
  358. package/src/components/json-schema-editor/components/inputs.tsx +612 -0
  359. package/src/components/json-schema-editor/get-default-values.ts +29 -0
  360. package/src/components/json-schema-editor/schema.tsx +206 -0
  361. package/src/components/json-schema-editor/utils/merge-schema.ts +167 -0
  362. package/src/components/json-schema-editor/utils/schema-to-string.ts +87 -0
  363. package/src/components/nav-user.tsx +102 -0
  364. package/src/components/site-header.tsx +13 -0
  365. package/src/components/ui/alert-dialog.tsx +182 -0
  366. package/src/components/ui/avatar.tsx +96 -0
  367. package/src/components/ui/badge.tsx +46 -0
  368. package/src/components/ui/button.tsx +65 -0
  369. package/src/components/ui/calendar.tsx +186 -0
  370. package/src/components/ui/checkbox.tsx +29 -0
  371. package/src/components/ui/combobox.tsx +267 -0
  372. package/src/components/ui/command.tsx +180 -0
  373. package/src/components/ui/context-menu.tsx +161 -0
  374. package/src/components/ui/dialog.tsx +142 -0
  375. package/src/components/ui/drawer.tsx +120 -0
  376. package/src/components/ui/dropdown-menu.tsx +239 -0
  377. package/src/components/ui/field.tsx +224 -0
  378. package/src/components/ui/input-group.tsx +144 -0
  379. package/src/components/ui/input.tsx +19 -0
  380. package/src/components/ui/label.tsx +18 -0
  381. package/src/components/ui/popover.tsx +76 -0
  382. package/src/components/ui/select.tsx +182 -0
  383. package/src/components/ui/separator.tsx +28 -0
  384. package/src/components/ui/sheet.tsx +130 -0
  385. package/src/components/ui/sidebar.tsx +608 -0
  386. package/src/components/ui/sonner.tsx +45 -0
  387. package/src/components/ui/spinner.tsx +15 -0
  388. package/src/components/ui/table.tsx +89 -0
  389. package/src/components/ui/tabs.tsx +60 -0
  390. package/src/components/ui/textarea.tsx +18 -0
  391. package/src/components/ui/toggle-group.tsx +86 -0
  392. package/src/components/ui/toggle.tsx +45 -0
  393. package/src/components/ui/toolbar.tsx +365 -0
  394. package/src/components/ui/tooltip.tsx +57 -0
  395. package/src/hooks/editor/use-is-creator.ts +21 -0
  396. package/src/hooks/use-mobile.ts +19 -0
  397. package/src/hooks/use-mounted.ts +11 -0
  398. package/src/hooks/use-upload-file.ts +121 -0
  399. package/src/lib/ai/markdown-joiner-transform.ts +235 -0
  400. package/src/lib/config.ts +60 -0
  401. package/src/lib/data/actions.ts +51 -0
  402. package/src/lib/data/boundary.client.tsx +22 -0
  403. package/src/lib/data/boundary.tsx +22 -0
  404. package/src/lib/data/query.ts +9 -0
  405. package/src/lib/data/store.ts +52 -0
  406. package/src/lib/lowlight.ts +3 -0
  407. package/src/lib/uploadthing.ts +19 -0
  408. package/src/lib/utils/deep-equal.ts +37 -0
  409. package/src/lib/utils/remove-undefined.ts +21 -0
  410. package/src/lib/utils/urls.ts +6 -0
  411. package/src/lib/utils.ts +6 -0
  412. package/tsconfig.build.json +24 -0
  413. package/tsconfig.json +37 -0
@@ -0,0 +1,184 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../../lib/utils.mjs";
4
+ import { useUploadFile } from "../../../hooks/use-upload-file.mjs";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { PlateElement, useEditorPlugin, withHOC } from "platejs/react";
7
+ import * as React$1 from "react";
8
+ import { KEYS } from "platejs";
9
+ import { AudioLines, FileUp, Film, ImageIcon, Loader2Icon } from "lucide-react";
10
+ import { PlaceholderPlugin, PlaceholderProvider, updateUploadHistory } from "@platejs/media/react";
11
+
12
+ //#region src/components/editor/ui/media-placeholder-node.tsx
13
+ const CONTENT = {
14
+ [KEYS.audio]: {
15
+ accept: ["audio/*"],
16
+ content: "Add an audio file",
17
+ icon: /* @__PURE__ */ jsx(AudioLines, {})
18
+ },
19
+ [KEYS.file]: {
20
+ accept: ["*"],
21
+ content: "Add a file",
22
+ icon: /* @__PURE__ */ jsx(FileUp, {})
23
+ },
24
+ [KEYS.img]: {
25
+ accept: ["image/*"],
26
+ content: "Add an image",
27
+ icon: /* @__PURE__ */ jsx(ImageIcon, {})
28
+ },
29
+ [KEYS.video]: {
30
+ accept: ["video/*"],
31
+ content: "Add a video",
32
+ icon: /* @__PURE__ */ jsx(Film, {})
33
+ }
34
+ };
35
+ const PlaceholderElement = withHOC(PlaceholderProvider, function PlaceholderElement$1(props) {
36
+ const { editor, element } = props;
37
+ const { api } = useEditorPlugin(PlaceholderPlugin);
38
+ const { isUploading, progress, uploadedFile, uploadFile, uploadingFile } = useUploadFile();
39
+ const loading = isUploading && uploadingFile !== void 0;
40
+ const currentContent = CONTENT[element.mediaType];
41
+ const isImage = element.mediaType === KEYS.img;
42
+ const imageRef = React$1.useRef(null);
43
+ const inputId = React$1.useId();
44
+ const replaceCurrentPlaceholder = React$1.useCallback((file) => {
45
+ uploadFile(file);
46
+ api.placeholder.addUploadingFile(element.id, file);
47
+ }, [
48
+ api.placeholder,
49
+ element.id,
50
+ uploadFile
51
+ ]);
52
+ React$1.useEffect(() => {
53
+ if (!uploadedFile) return;
54
+ const path = editor.api.findPath(element);
55
+ editor.tf.withoutSaving(() => {
56
+ editor.tf.removeNodes({ at: path });
57
+ const node = {
58
+ children: [{ text: "" }],
59
+ initialHeight: imageRef.current?.height,
60
+ initialWidth: imageRef.current?.width,
61
+ isUpload: true,
62
+ name: element.mediaType === KEYS.file ? uploadedFile.name : "",
63
+ placeholderId: element.id,
64
+ type: element.mediaType,
65
+ url: uploadedFile.url
66
+ };
67
+ editor.tf.insertNodes(node, { at: path });
68
+ updateUploadHistory(editor, node);
69
+ });
70
+ api.placeholder.removeUploadingFile(element.id);
71
+ }, [uploadedFile, element.id]);
72
+ const isReplaced = React$1.useRef(false);
73
+ /** Paste and drop */
74
+ React$1.useEffect(() => {
75
+ if (isReplaced.current) return;
76
+ isReplaced.current = true;
77
+ const currentFiles = api.placeholder.getUploadingFile(element.id);
78
+ if (!currentFiles) return;
79
+ replaceCurrentPlaceholder(currentFiles);
80
+ }, [isReplaced]);
81
+ return /* @__PURE__ */ jsxs(PlateElement, {
82
+ className: "my-1",
83
+ ...props,
84
+ children: [
85
+ /* @__PURE__ */ jsx("input", {
86
+ id: inputId,
87
+ type: "file",
88
+ hidden: true,
89
+ onChange: (e) => {
90
+ const updatedFiles = e.target.files;
91
+ if (!updatedFiles) return;
92
+ const [firstFile, ...restFiles] = Array.from(updatedFiles);
93
+ replaceCurrentPlaceholder(firstFile);
94
+ if (restFiles.length > 0) editor.getTransforms(PlaceholderPlugin).insert.media(restFiles);
95
+ },
96
+ accept: currentContent.accept.join(", "),
97
+ multiple: true,
98
+ disabled: loading
99
+ }),
100
+ (!loading || !isImage) && /* @__PURE__ */ jsxs("label", {
101
+ htmlFor: inputId,
102
+ className: "flex cursor-pointer select-none items-center rounded-sm bg-muted p-3 pr-9 hover:bg-primary/10",
103
+ contentEditable: false,
104
+ children: [/* @__PURE__ */ jsx("div", {
105
+ className: "relative mr-3 flex text-muted-foreground/80 [&_svg]:size-6",
106
+ children: currentContent.icon
107
+ }), /* @__PURE__ */ jsxs("div", {
108
+ className: "whitespace-nowrap text-muted-foreground text-sm",
109
+ children: [/* @__PURE__ */ jsx("div", { children: loading ? uploadingFile?.name : currentContent.content }), loading && !isImage && /* @__PURE__ */ jsxs("div", {
110
+ className: "mt-1 flex items-center gap-1.5",
111
+ children: [
112
+ /* @__PURE__ */ jsx("div", { children: formatBytes(uploadingFile?.size ?? 0) }),
113
+ /* @__PURE__ */ jsx("div", { children: "–" }),
114
+ /* @__PURE__ */ jsxs("div", {
115
+ className: "flex items-center",
116
+ children: [
117
+ /* @__PURE__ */ jsx(Loader2Icon, { className: "mr-1 size-3.5 animate-spin text-muted-foreground" }),
118
+ progress ?? 0,
119
+ "%"
120
+ ]
121
+ })
122
+ ]
123
+ })]
124
+ })]
125
+ }),
126
+ isImage && loading && /* @__PURE__ */ jsx(ImageProgress, {
127
+ file: uploadingFile,
128
+ imageRef,
129
+ progress
130
+ }),
131
+ props.children
132
+ ]
133
+ });
134
+ });
135
+ function ImageProgress({ className, file, imageRef, progress = 0 }) {
136
+ const [objectUrl, setObjectUrl] = React$1.useState(null);
137
+ React$1.useEffect(() => {
138
+ const url = URL.createObjectURL(file);
139
+ setObjectUrl(url);
140
+ return () => {
141
+ URL.revokeObjectURL(url);
142
+ };
143
+ }, [file]);
144
+ if (!objectUrl) return null;
145
+ return /* @__PURE__ */ jsxs("div", {
146
+ className: cn("relative", className),
147
+ contentEditable: false,
148
+ children: [/* @__PURE__ */ jsx("img", {
149
+ ref: imageRef,
150
+ className: "h-auto w-full rounded-sm object-cover",
151
+ alt: file.name,
152
+ src: objectUrl
153
+ }), progress < 100 && /* @__PURE__ */ jsxs("div", {
154
+ className: "absolute right-1 bottom-1 flex items-center space-x-2 rounded-full bg-black/50 px-1 py-0.5",
155
+ children: [/* @__PURE__ */ jsx(Loader2Icon, { className: "size-3.5 animate-spin text-muted-foreground" }), /* @__PURE__ */ jsxs("span", {
156
+ className: "font-medium text-white text-xs",
157
+ children: [Math.round(progress), "%"]
158
+ })]
159
+ })]
160
+ });
161
+ }
162
+ function formatBytes(bytes, opts = {}) {
163
+ const { decimals = 0, sizeType = "normal" } = opts;
164
+ const sizes = [
165
+ "Bytes",
166
+ "KB",
167
+ "MB",
168
+ "GB",
169
+ "TB"
170
+ ];
171
+ const accurateSizes = [
172
+ "Bytes",
173
+ "KiB",
174
+ "MiB",
175
+ "GiB",
176
+ "TiB"
177
+ ];
178
+ if (bytes === 0) return "0 Byte";
179
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
180
+ return `${(bytes / 1024 ** i).toFixed(decimals)} ${sizeType === "accurate" ? accurateSizes[i] ?? "Bytest" : sizes[i] ?? "Bytes"}`;
181
+ }
182
+
183
+ //#endregion
184
+ export { PlaceholderElement };
@@ -0,0 +1,113 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../../lib/utils.mjs";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { useEditorRef } from "platejs/react";
6
+ import { ArrowLeft, ArrowRight, Download, Minus, Plus, X } from "lucide-react";
7
+ import { cva } from "class-variance-authority";
8
+ import { PreviewImage, useImagePreview, useImagePreviewValue, useScaleInput } from "@platejs/media/react";
9
+
10
+ //#region src/components/editor/ui/media-preview-dialog.tsx
11
+ const buttonVariants = cva("rounded bg-[rgba(0,0,0,0.5)] px-1", {
12
+ defaultVariants: { variant: "default" },
13
+ variants: { variant: {
14
+ default: "text-white",
15
+ disabled: "cursor-not-allowed text-gray-400"
16
+ } }
17
+ });
18
+ const SCROLL_SPEED = 4;
19
+ function MediaPreviewDialog() {
20
+ const isOpen = useImagePreviewValue("isOpen", useEditorRef().id);
21
+ const scale = useImagePreviewValue("scale");
22
+ const isEditingScale = useImagePreviewValue("isEditingScale");
23
+ const { closeProps, currentUrlIndex, maskLayerProps, nextDisabled, nextProps, prevDisabled, prevProps, scaleTextProps, zommOutProps, zoomInDisabled, zoomInProps, zoomOutDisabled } = useImagePreview({ scrollSpeed: SCROLL_SPEED });
24
+ return /* @__PURE__ */ jsxs("div", {
25
+ className: cn("fixed inset-0 z-50 select-none", !isOpen && "hidden"),
26
+ onContextMenu: (e) => e.stopPropagation(),
27
+ ...maskLayerProps,
28
+ children: [
29
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 size-full bg-black opacity-30" }),
30
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 size-full bg-black opacity-30" }),
31
+ /* @__PURE__ */ jsx("div", {
32
+ className: "absolute inset-0 flex items-center justify-center",
33
+ children: /* @__PURE__ */ jsxs("div", {
34
+ className: "relative flex max-h-screen w-full items-center",
35
+ children: [/* @__PURE__ */ jsx(PreviewImage, { className: cn("mx-auto block max-h-[calc(100vh-4rem)] w-auto object-contain transition-transform") }), /* @__PURE__ */ jsxs("div", {
36
+ className: "-translate-x-1/2 absolute bottom-0 left-1/2 z-40 flex w-fit justify-center gap-4 p-2 text-center text-white",
37
+ onClick: (e) => e.stopPropagation(),
38
+ children: [
39
+ /* @__PURE__ */ jsxs("div", {
40
+ className: "flex gap-1",
41
+ children: [
42
+ /* @__PURE__ */ jsx("button", {
43
+ ...prevProps,
44
+ className: cn(buttonVariants({ variant: prevDisabled ? "disabled" : "default" })),
45
+ type: "button",
46
+ children: /* @__PURE__ */ jsx(ArrowLeft, {})
47
+ }),
48
+ (currentUrlIndex ?? 0) + 1,
49
+ /* @__PURE__ */ jsx("button", {
50
+ ...nextProps,
51
+ className: cn(buttonVariants({ variant: nextDisabled ? "disabled" : "default" })),
52
+ type: "button",
53
+ children: /* @__PURE__ */ jsx(ArrowRight, {})
54
+ })
55
+ ]
56
+ }),
57
+ /* @__PURE__ */ jsxs("div", {
58
+ className: "flex",
59
+ children: [
60
+ /* @__PURE__ */ jsx("button", {
61
+ className: cn(buttonVariants({ variant: zoomOutDisabled ? "disabled" : "default" })),
62
+ ...zommOutProps,
63
+ type: "button",
64
+ children: /* @__PURE__ */ jsx(Minus, { className: "size-4" })
65
+ }),
66
+ /* @__PURE__ */ jsx("div", {
67
+ className: "mx-px",
68
+ children: isEditingScale ? /* @__PURE__ */ jsxs(Fragment, { children: [
69
+ /* @__PURE__ */ jsx(ScaleInput, { className: "w-10 rounded px-1 text-slate-500 outline" }),
70
+ " ",
71
+ /* @__PURE__ */ jsx("span", { children: "%" })
72
+ ] }) : /* @__PURE__ */ jsx("span", {
73
+ ...scaleTextProps,
74
+ children: `${scale * 100}%`
75
+ })
76
+ }),
77
+ /* @__PURE__ */ jsx("button", {
78
+ className: cn(buttonVariants({ variant: zoomInDisabled ? "disabled" : "default" })),
79
+ ...zoomInProps,
80
+ type: "button",
81
+ children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
82
+ })
83
+ ]
84
+ }),
85
+ /* @__PURE__ */ jsx("button", {
86
+ className: cn(buttonVariants()),
87
+ type: "button",
88
+ children: /* @__PURE__ */ jsx(Download, { className: "size-4" })
89
+ }),
90
+ /* @__PURE__ */ jsx("button", {
91
+ ...closeProps,
92
+ className: cn(buttonVariants()),
93
+ type: "button",
94
+ children: /* @__PURE__ */ jsx(X, { className: "size-4" })
95
+ })
96
+ ]
97
+ })]
98
+ })
99
+ })
100
+ ]
101
+ });
102
+ }
103
+ function ScaleInput(props) {
104
+ const { props: scaleInputProps, ref } = useScaleInput();
105
+ return /* @__PURE__ */ jsx("input", {
106
+ ...scaleInputProps,
107
+ ...props,
108
+ ref
109
+ });
110
+ }
111
+
112
+ //#endregion
113
+ export { MediaPreviewDialog };
@@ -0,0 +1,156 @@
1
+ "use client";
2
+
3
+ import { Input } from "../../ui/input.mjs";
4
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger } from "../../ui/dropdown-menu.mjs";
5
+ import { ToolbarSplitButton, ToolbarSplitButtonPrimary, ToolbarSplitButtonSecondary } from "../../ui/toolbar.mjs";
6
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "../../ui/alert-dialog.mjs";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { useEditorRef } from "platejs/react";
9
+ import * as React$1 from "react";
10
+ import { KEYS, isUrl } from "platejs";
11
+ import { FilmIcon, ImageIcon, LinkIcon } from "lucide-react";
12
+ import { PlaceholderPlugin } from "@platejs/media/react";
13
+ import { toast } from "sonner";
14
+
15
+ //#region src/components/editor/ui/media-toolbar-button.tsx
16
+ const MEDIA_CONFIG = {
17
+ [KEYS.img]: {
18
+ accept: ["image/*"],
19
+ icon: /* @__PURE__ */ jsx(ImageIcon, { className: "size-4" }),
20
+ title: "Insert Image",
21
+ tooltip: "Image"
22
+ },
23
+ [KEYS.video]: {
24
+ accept: ["video/*"],
25
+ icon: /* @__PURE__ */ jsx(FilmIcon, { className: "size-4" }),
26
+ title: "Insert Video",
27
+ tooltip: "Video"
28
+ }
29
+ };
30
+ function MediaToolbarButton({ nodeType, ...props }) {
31
+ const currentConfig = MEDIA_CONFIG[nodeType];
32
+ const editor = useEditorRef();
33
+ const [open, setOpen] = React$1.useState(false);
34
+ const [dialogOpen, setDialogOpen] = React$1.useState(false);
35
+ const inputId = React$1.useId();
36
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ /* @__PURE__ */ jsxs(ToolbarSplitButton, {
38
+ onKeyDown: (e) => {
39
+ if (e.key === "ArrowDown") {
40
+ e.preventDefault();
41
+ setOpen(true);
42
+ }
43
+ },
44
+ pressed: open,
45
+ children: [/* @__PURE__ */ jsx("label", {
46
+ htmlFor: inputId,
47
+ children: /* @__PURE__ */ jsx(ToolbarSplitButtonPrimary, { children: currentConfig.icon })
48
+ }), /* @__PURE__ */ jsxs(DropdownMenu, {
49
+ open,
50
+ onOpenChange: setOpen,
51
+ modal: false,
52
+ ...props,
53
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
54
+ asChild: true,
55
+ children: /* @__PURE__ */ jsx(ToolbarSplitButtonSecondary, {})
56
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, {
57
+ onClick: (e) => e.stopPropagation(),
58
+ align: "start",
59
+ alignOffset: -32,
60
+ children: /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
61
+ onSelect: (e) => e.preventDefault(),
62
+ asChild: true,
63
+ children: /* @__PURE__ */ jsxs("label", {
64
+ htmlFor: inputId,
65
+ children: [currentConfig.icon, "Upload from computer"]
66
+ })
67
+ }), /* @__PURE__ */ jsxs(DropdownMenuItem, {
68
+ onSelect: () => setDialogOpen(true),
69
+ children: [/* @__PURE__ */ jsx(LinkIcon, {}), "Insert via URL"]
70
+ })] })
71
+ })]
72
+ })]
73
+ }),
74
+ /* @__PURE__ */ jsx("input", {
75
+ id: inputId,
76
+ type: "file",
77
+ hidden: true,
78
+ multiple: true,
79
+ accept: currentConfig.accept.join(", "),
80
+ onChange: (e) => {
81
+ const files = e.target.files;
82
+ if (!files) return;
83
+ editor.getTransforms(PlaceholderPlugin).insert.media(files);
84
+ setOpen(false);
85
+ }
86
+ }),
87
+ /* @__PURE__ */ jsx(AlertDialog, {
88
+ open: dialogOpen,
89
+ onOpenChange: (value) => {
90
+ setDialogOpen(value);
91
+ },
92
+ children: /* @__PURE__ */ jsx(AlertDialogContent, {
93
+ className: "gap-6",
94
+ children: /* @__PURE__ */ jsx(MediaUrlDialogContent, {
95
+ currentConfig,
96
+ nodeType,
97
+ setOpen: setDialogOpen
98
+ })
99
+ })
100
+ })
101
+ ] });
102
+ }
103
+ function MediaUrlDialogContent({ currentConfig, nodeType, setOpen }) {
104
+ const editor = useEditorRef();
105
+ const [url, setUrl] = React$1.useState("");
106
+ const embedMedia = React$1.useCallback(() => {
107
+ if (!isUrl(url)) return toast.error("Invalid URL");
108
+ setOpen(false);
109
+ editor.tf.insertNodes({
110
+ children: [{ text: "" }],
111
+ name: nodeType === KEYS.file ? url.split("/").pop() : void 0,
112
+ type: nodeType,
113
+ url
114
+ });
115
+ }, [
116
+ url,
117
+ editor,
118
+ nodeType,
119
+ setOpen
120
+ ]);
121
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
122
+ /* @__PURE__ */ jsx(AlertDialogHeader, { children: /* @__PURE__ */ jsx(AlertDialogTitle, { children: currentConfig.title }) }),
123
+ /* @__PURE__ */ jsxs(AlertDialogDescription, {
124
+ className: "group relative w-full",
125
+ children: [/* @__PURE__ */ jsx("label", {
126
+ className: "-translate-y-1/2 absolute top-1/2 block cursor-text px-1 text-muted-foreground/70 text-sm transition-all group-focus-within:pointer-events-none group-focus-within:top-0 group-focus-within:cursor-default group-focus-within:font-medium group-focus-within:text-foreground group-focus-within:text-xs has-[+input:not(:placeholder-shown)]:pointer-events-none has-[+input:not(:placeholder-shown)]:top-0 has-[+input:not(:placeholder-shown)]:cursor-default has-[+input:not(:placeholder-shown)]:font-medium has-[+input:not(:placeholder-shown)]:text-foreground has-[+input:not(:placeholder-shown)]:text-xs",
127
+ htmlFor: "url",
128
+ children: /* @__PURE__ */ jsx("span", {
129
+ className: "inline-flex bg-background px-2",
130
+ children: "URL"
131
+ })
132
+ }), /* @__PURE__ */ jsx(Input, {
133
+ id: "url",
134
+ className: "w-full",
135
+ value: url,
136
+ onChange: (e) => setUrl(e.target.value),
137
+ onKeyDown: (e) => {
138
+ if (e.key === "Enter") embedMedia();
139
+ },
140
+ placeholder: "",
141
+ type: "url",
142
+ autoFocus: true
143
+ })]
144
+ }),
145
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, { children: "Cancel" }), /* @__PURE__ */ jsx(AlertDialogAction, {
146
+ onClick: (e) => {
147
+ e.preventDefault();
148
+ embedMedia();
149
+ },
150
+ children: "Accept"
151
+ })] })
152
+ ] });
153
+ }
154
+
155
+ //#endregion
156
+ export { MEDIA_CONFIG, MediaToolbarButton };
@@ -0,0 +1,80 @@
1
+ "use client";
2
+
3
+ import { Button, buttonVariants } from "../../ui/button.mjs";
4
+ import { Popover, PopoverAnchor, PopoverContent } from "../../ui/popover.mjs";
5
+ import { Separator } from "../../ui/separator.mjs";
6
+ import { CaptionButton } from "./caption.mjs";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { useEditorRef, useEditorSelector, useElement, useFocusedLast, useReadOnly, useRemoveNodeButton, useSelected } from "platejs/react";
9
+ import * as React$1 from "react";
10
+ import { Link, Trash2Icon } from "lucide-react";
11
+ import { cva } from "class-variance-authority";
12
+ import { FloatingMedia, FloatingMediaStore, useFloatingMediaValue, useImagePreviewValue } from "@platejs/media/react";
13
+
14
+ //#region src/components/editor/ui/media-toolbar.tsx
15
+ const inputVariants = cva("flex h-[28px] w-full rounded-md border-none bg-transparent px-1.5 py-1 text-base placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-transparent md:text-sm");
16
+ function MediaToolbar({ children, plugin }) {
17
+ const editor = useEditorRef();
18
+ const readOnly = useReadOnly();
19
+ const selected = useSelected();
20
+ const isFocusedLast = useFocusedLast();
21
+ const selectionCollapsed = useEditorSelector((editor$1) => !editor$1.api.isExpanded(), []);
22
+ const isImagePreviewOpen = useImagePreviewValue("isOpen", editor.id);
23
+ const open = isFocusedLast && !readOnly && selected && selectionCollapsed && !isImagePreviewOpen;
24
+ const isEditing = useFloatingMediaValue("isEditing");
25
+ React$1.useEffect(() => {
26
+ if (!open && isEditing) FloatingMediaStore.set("isEditing", false);
27
+ }, [open]);
28
+ const { props: buttonProps } = useRemoveNodeButton({ element: useElement() });
29
+ return /* @__PURE__ */ jsxs(Popover, {
30
+ open,
31
+ modal: false,
32
+ children: [/* @__PURE__ */ jsx(PopoverAnchor, { children }), /* @__PURE__ */ jsx(PopoverContent, {
33
+ className: "w-auto p-1",
34
+ onOpenAutoFocus: (e) => e.preventDefault(),
35
+ children: isEditing ? /* @__PURE__ */ jsx("div", {
36
+ className: "flex w-[330px] flex-col",
37
+ children: /* @__PURE__ */ jsxs("div", {
38
+ className: "flex items-center",
39
+ children: [/* @__PURE__ */ jsx("div", {
40
+ className: "flex items-center pr-1 pl-2 text-muted-foreground",
41
+ children: /* @__PURE__ */ jsx(Link, { className: "size-4" })
42
+ }), /* @__PURE__ */ jsx(FloatingMedia.UrlInput, {
43
+ className: inputVariants(),
44
+ placeholder: "Paste the embed link...",
45
+ options: { plugin }
46
+ })]
47
+ })
48
+ }) : /* @__PURE__ */ jsxs("div", {
49
+ className: "box-content flex items-center",
50
+ children: [
51
+ /* @__PURE__ */ jsx(FloatingMedia.EditButton, {
52
+ className: buttonVariants({
53
+ size: "sm",
54
+ variant: "ghost"
55
+ }),
56
+ children: "Edit link"
57
+ }),
58
+ /* @__PURE__ */ jsx(CaptionButton, {
59
+ size: "sm",
60
+ variant: "ghost",
61
+ children: "Caption"
62
+ }),
63
+ /* @__PURE__ */ jsx(Separator, {
64
+ orientation: "vertical",
65
+ className: "mx-1 h-6"
66
+ }),
67
+ /* @__PURE__ */ jsx(Button, {
68
+ size: "sm",
69
+ variant: "ghost",
70
+ ...buttonProps,
71
+ children: /* @__PURE__ */ jsx(Trash2Icon, {})
72
+ })
73
+ ]
74
+ })
75
+ })]
76
+ });
77
+ }
78
+
79
+ //#endregion
80
+ export { MediaToolbar };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+
3
+ import { usePluginOption } from "platejs/react";
4
+ import * as React$1 from "react";
5
+ import { PlaceholderPlugin, UploadErrorCode } from "@platejs/media/react";
6
+ import { toast } from "sonner";
7
+
8
+ //#region src/components/editor/ui/media-upload-toast.tsx
9
+ function MediaUploadToast() {
10
+ useUploadErrorToast();
11
+ return null;
12
+ }
13
+ const useUploadErrorToast = () => {
14
+ const uploadError = usePluginOption(PlaceholderPlugin, "error");
15
+ React$1.useEffect(() => {
16
+ if (!uploadError) return;
17
+ const { code, data } = uploadError;
18
+ switch (code) {
19
+ case UploadErrorCode.INVALID_FILE_SIZE:
20
+ toast.error(`The size of files ${data.files.map((f) => f.name).join(", ")} is invalid`);
21
+ break;
22
+ case UploadErrorCode.INVALID_FILE_TYPE:
23
+ toast.error(`The type of files ${data.files.map((f) => f.name).join(", ")} is invalid`);
24
+ break;
25
+ case UploadErrorCode.TOO_LARGE:
26
+ toast.error(`The size of files ${data.files.map((f) => f.name).join(", ")} is too large than ${data.maxFileSize}`);
27
+ break;
28
+ case UploadErrorCode.TOO_LESS_FILES:
29
+ toast.error(`The mini um number of files is ${data.minFileCount} for ${data.fileType}`);
30
+ break;
31
+ case UploadErrorCode.TOO_MANY_FILES:
32
+ toast.error(`The maximum number of files is ${data.maxFileCount} ${data.fileType ? `for ${data.fileType}` : ""}`);
33
+ break;
34
+ }
35
+ }, [uploadError]);
36
+ };
37
+
38
+ //#endregion
39
+ export { MediaUploadToast };
@@ -0,0 +1,27 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { NodeApi } from "platejs";
3
+ import { SlateElement } from "platejs/static";
4
+
5
+ //#region src/components/editor/ui/media-video-node-static.tsx
6
+ function VideoElementStatic(props) {
7
+ const { align = "center", caption, url, width } = props.element;
8
+ return /* @__PURE__ */ jsxs(SlateElement, {
9
+ className: "py-2.5",
10
+ ...props,
11
+ children: [/* @__PURE__ */ jsx("div", {
12
+ style: { textAlign: align },
13
+ children: /* @__PURE__ */ jsxs("figure", {
14
+ className: "group relative m-0 inline-block cursor-default",
15
+ style: { width },
16
+ children: [/* @__PURE__ */ jsx("video", {
17
+ className: "w-full max-w-full rounded-sm object-cover px-0",
18
+ src: url,
19
+ controls: true
20
+ }), caption && /* @__PURE__ */ jsx("figcaption", { children: NodeApi.string(caption[0]) })]
21
+ })
22
+ }), props.children]
23
+ });
24
+ }
25
+
26
+ //#endregion
27
+ export { VideoElementStatic };