@lobehub/editor 4.15.1 → 4.16.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 (537) hide show
  1. package/es/_virtual/_rolldown/runtime.js +28 -0
  2. package/es/codemirror/components/CopyButton.d.ts +7 -0
  3. package/es/codemirror/components/CopyButton.js +24 -0
  4. package/es/codemirror/components/LanguageSelect.d.ts +7 -0
  5. package/es/codemirror/components/LanguageSelect.js +59 -0
  6. package/es/codemirror/components/MoreOptions.d.ts +7 -0
  7. package/es/codemirror/components/MoreOptions.js +66 -0
  8. package/es/codemirror/components/Toolbar.d.ts +7 -0
  9. package/es/codemirror/components/Toolbar.js +51 -0
  10. package/es/codemirror/components/style.js +7 -0
  11. package/es/codemirror/constants.d.ts +6 -0
  12. package/es/codemirror/constants.js +512 -0
  13. package/es/codemirror/loader.d.ts +61 -0
  14. package/es/codemirror/loader.js +77 -0
  15. package/es/codemirror/style.d.ts +4 -0
  16. package/es/codemirror/style.js +82 -0
  17. package/es/codemirror/theme.d.ts +132 -0
  18. package/es/codemirror/theme.js +75 -0
  19. package/es/codemirror/types.d.ts +53 -0
  20. package/es/codemirror.d.ts +9 -263
  21. package/es/codemirror.js +8 -1
  22. package/es/common/canUseDOM.js +11 -0
  23. package/es/common/sys.js +27 -0
  24. package/es/const/hotkey.js +100 -0
  25. package/es/editor-kernel/data-source.d.ts +15 -0
  26. package/es/editor-kernel/data-source.js +15 -0
  27. package/es/editor-kernel/event.d.ts +7 -0
  28. package/es/editor-kernel/event.js +19 -0
  29. package/es/editor-kernel/index.d.ts +5 -0
  30. package/es/editor-kernel/index.js +17 -0
  31. package/es/editor-kernel/inode/helper.js +87 -0
  32. package/es/editor-kernel/inode/i-element-node.d.ts +6 -0
  33. package/es/editor-kernel/inode/i-node.d.ts +6 -0
  34. package/es/editor-kernel/inode/index.d.ts +4 -0
  35. package/es/editor-kernel/inode/paragraph-node.d.ts +1 -0
  36. package/es/editor-kernel/inode/root-node.d.ts +9 -0
  37. package/es/editor-kernel/inode/text-node.d.ts +9 -0
  38. package/es/editor-kernel/kernel.d.ts +122 -0
  39. package/es/editor-kernel/kernel.js +661 -0
  40. package/es/editor-kernel/plugin.js +59 -0
  41. package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
  42. package/es/editor-kernel/react/LexicalErrorBoundary.js +19 -0
  43. package/es/editor-kernel/react/PortalAnchor.js +12 -0
  44. package/es/editor-kernel/react/PortalContainer.d.ts +14 -0
  45. package/es/editor-kernel/react/PortalContainer.js +25 -0
  46. package/es/editor-kernel/react/index.d.ts +5 -0
  47. package/es/editor-kernel/react/react-context.d.ts +11 -0
  48. package/es/editor-kernel/react/react-context.js +21 -0
  49. package/es/editor-kernel/react/react-editor.d.ts +16 -0
  50. package/es/editor-kernel/react/react-editor.js +32 -0
  51. package/es/editor-kernel/react/useAnchor.js +17 -0
  52. package/es/editor-kernel/react/useDecorators.js +60 -0
  53. package/es/editor-kernel/react/useEditable.js +25 -0
  54. package/es/editor-kernel/react/useLexicalEditor.d.ts +6 -0
  55. package/es/editor-kernel/react/useLexicalEditor.js +23 -0
  56. package/es/editor-kernel/react/useLexicalNodeSelection.js +86 -0
  57. package/es/editor-kernel/react/useTranslation.js +9 -0
  58. package/es/editor-kernel/utils.d.ts +46 -0
  59. package/es/editor-kernel/utils.js +138 -0
  60. package/es/headless/extract-media-from-editor-state.d.ts +22 -0
  61. package/es/headless/extract-media-from-editor-state.js +49 -0
  62. package/es/headless/index.d.ts +69 -0
  63. package/es/headless/index.js +189 -0
  64. package/es/headless/plugins/codeblock.js +82 -0
  65. package/es/headless.d.ts +2 -0
  66. package/es/headless.js +782 -20254
  67. package/es/index.d.ts +113 -3059
  68. package/es/index.js +102 -8485
  69. package/es/locale/index.d.ts +63 -0
  70. package/es/locale/index.js +66 -0
  71. package/es/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +953 -0
  72. package/es/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +83 -0
  73. package/es/plugins/auto-complete/index.d.ts +2 -0
  74. package/es/plugins/auto-complete/node/placeholderNode.js +89 -0
  75. package/es/plugins/auto-complete/plugin/index.d.ts +31 -0
  76. package/es/plugins/auto-complete/plugin/index.js +395 -0
  77. package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.d.ts +7 -0
  78. package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +60 -0
  79. package/es/plugins/auto-complete/react/index.d.ts +1 -0
  80. package/es/plugins/auto-complete/react/style.js +12 -0
  81. package/es/plugins/auto-complete/react/type.d.ts +25 -0
  82. package/es/plugins/block/command/index.d.ts +13 -0
  83. package/es/plugins/block/command/index.js +161 -0
  84. package/es/plugins/block/index.d.ts +5 -0
  85. package/es/plugins/block/plugin/index.d.ts +9 -0
  86. package/es/plugins/block/plugin/index.js +162 -0
  87. package/es/plugins/block/react/ReactBlockPlugin.d.ts +18 -0
  88. package/es/plugins/block/react/ReactBlockPlugin.js +613 -0
  89. package/es/plugins/block/react/core/runtime-context.js +19 -0
  90. package/es/plugins/block/react/core/types.d.ts +6 -0
  91. package/es/plugins/block/react/drag/drag-session.js +264 -0
  92. package/es/plugins/block/react/drag/drag-utils.js +122 -0
  93. package/es/plugins/block/react/index.d.ts +2 -0
  94. package/es/plugins/block/react/style.js +66 -0
  95. package/es/plugins/block/service/i-block-menu-service.d.ts +61 -0
  96. package/es/plugins/block/service/i-block-menu-service.js +67 -0
  97. package/es/plugins/block/service/index.d.ts +1 -0
  98. package/es/plugins/code/command/index.d.ts +7 -0
  99. package/es/plugins/code/command/index.js +30 -0
  100. package/es/plugins/code/index.d.ts +3 -0
  101. package/es/plugins/code/node/code.js +91 -0
  102. package/es/plugins/code/plugin/index.d.ts +9 -0
  103. package/es/plugins/code/plugin/index.js +74 -0
  104. package/es/plugins/code/plugin/registry.js +33 -0
  105. package/es/plugins/code/react/CodeReactPlugin.d.ts +7 -0
  106. package/es/plugins/code/react/CodeReactPlugin.js +27 -0
  107. package/es/plugins/code/react/index.d.ts +1 -0
  108. package/es/plugins/code/react/style.js +21 -0
  109. package/es/plugins/code/react/type.d.ts +7 -0
  110. package/es/plugins/codeblock/command/index.d.ts +8 -0
  111. package/es/plugins/codeblock/command/index.js +40 -0
  112. package/es/plugins/codeblock/index.d.ts +6 -0
  113. package/es/plugins/codeblock/index.js +5 -0
  114. package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +415 -0
  115. package/es/plugins/codeblock/plugin/FacadeShiki.js +193 -0
  116. package/es/plugins/codeblock/plugin/index.d.ts +16 -0
  117. package/es/plugins/codeblock/plugin/index.js +181 -0
  118. package/es/plugins/codeblock/plugin/invariant.js +14 -0
  119. package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +7 -0
  120. package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +27 -0
  121. package/es/plugins/codeblock/react/index.d.ts +2 -0
  122. package/es/plugins/codeblock/react/style.js +58 -0
  123. package/es/plugins/codeblock/react/type.d.ts +8 -0
  124. package/es/plugins/codeblock/utils/language.js +9 -0
  125. package/es/plugins/codemirror-block/command/index.d.ts +13 -0
  126. package/es/plugins/codemirror-block/command/index.js +67 -0
  127. package/es/plugins/codemirror-block/index.d.ts +3 -0
  128. package/es/plugins/codemirror-block/lib/mode.js +8 -0
  129. package/es/plugins/codemirror-block/node/CodeMirrorNode.d.ts +48 -0
  130. package/es/plugins/codemirror-block/node/CodeMirrorNode.js +205 -0
  131. package/es/plugins/codemirror-block/plugin/index.d.ts +12 -0
  132. package/es/plugins/codemirror-block/plugin/index.js +80 -0
  133. package/es/plugins/codemirror-block/react/CodemirrorNode.js +219 -0
  134. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.d.ts +7 -0
  135. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.js +26 -0
  136. package/es/plugins/codemirror-block/react/index.d.ts +1 -0
  137. package/es/plugins/codemirror-block/react/type.d.ts +6 -0
  138. package/es/plugins/common/command/index.d.ts +11 -0
  139. package/es/plugins/common/command/index.js +24 -0
  140. package/es/plugins/common/data-source/json-data-source.js +133 -0
  141. package/es/plugins/common/data-source/text-data-source.js +32 -0
  142. package/es/plugins/common/index.d.ts +6 -0
  143. package/es/plugins/common/node/ElementDOMSlot.js +30 -0
  144. package/es/plugins/common/node/cursor.d.ts +16 -0
  145. package/es/plugins/common/node/cursor.js +189 -0
  146. package/es/plugins/common/plugin/index.d.ts +43 -0
  147. package/es/plugins/common/plugin/index.js +338 -0
  148. package/es/plugins/common/plugin/mdReader.js +62 -0
  149. package/es/plugins/common/plugin/paste-handler.d.ts +11 -0
  150. package/es/plugins/common/plugin/paste-handler.js +61 -0
  151. package/es/plugins/common/plugin/register.js +306 -0
  152. package/es/plugins/common/react/Placeholder/index.js +65 -0
  153. package/es/plugins/common/react/Placeholder/style.js +22 -0
  154. package/es/plugins/common/react/ReactEditorContent.d.ts +7 -0
  155. package/es/plugins/common/react/ReactEditorContent.js +8 -0
  156. package/es/plugins/common/react/ReactPlainText.d.ts +7 -0
  157. package/es/plugins/common/react/ReactPlainText.js +192 -0
  158. package/es/plugins/common/react/index.d.ts +3 -0
  159. package/es/plugins/common/react/style.js +206 -0
  160. package/es/plugins/common/react/type.d.ts +94 -0
  161. package/es/plugins/common/utils/index.js +135 -0
  162. package/es/plugins/content-blocks/data-source/content-blocks-data-source.d.ts +15 -0
  163. package/es/plugins/content-blocks/data-source/content-blocks-data-source.js +21 -0
  164. package/es/plugins/content-blocks/index.d.ts +6 -0
  165. package/es/plugins/content-blocks/plugin/index.d.ts +10 -0
  166. package/es/plugins/content-blocks/plugin/index.js +24 -0
  167. package/es/plugins/content-blocks/types.d.ts +33 -0
  168. package/es/plugins/content-blocks/types.js +4 -0
  169. package/es/plugins/content-blocks/utils/extract-media-lists.d.ts +7 -0
  170. package/es/plugins/content-blocks/utils/extract-media-lists.js +32 -0
  171. package/es/plugins/content-blocks/utils/extract.d.ts +8 -0
  172. package/es/plugins/content-blocks/utils/extract.js +188 -0
  173. package/es/plugins/file/command/index.d.ts +9 -0
  174. package/es/plugins/file/command/index.js +31 -0
  175. package/es/plugins/file/index.d.ts +4 -0
  176. package/es/plugins/file/node/FileNode.d.ts +38 -0
  177. package/es/plugins/file/node/FileNode.js +106 -0
  178. package/es/plugins/file/plugin/index.d.ts +18 -0
  179. package/es/plugins/file/plugin/index.js +103 -0
  180. package/es/plugins/file/react/ReactFilePlugin.d.ts +7 -0
  181. package/es/plugins/file/react/ReactFilePlugin.js +35 -0
  182. package/es/plugins/file/react/components/ReactFile.js +50 -0
  183. package/es/plugins/file/react/index.d.ts +2 -0
  184. package/es/plugins/file/react/style.js +32 -0
  185. package/es/plugins/file/react/type.d.ts +17 -0
  186. package/es/plugins/file/utils/index.js +29 -0
  187. package/es/plugins/hr/command/index.d.ts +7 -0
  188. package/es/plugins/hr/command/index.js +14 -0
  189. package/es/plugins/hr/index.d.ts +4 -0
  190. package/es/plugins/hr/node/HorizontalRuleNode.d.ts +18 -0
  191. package/es/plugins/hr/node/HorizontalRuleNode.js +59 -0
  192. package/es/plugins/hr/plugin/index.d.ts +12 -0
  193. package/es/plugins/hr/plugin/index.js +60 -0
  194. package/es/plugins/hr/react/ReactHRPlugin.d.ts +7 -0
  195. package/es/plugins/hr/react/ReactHRPlugin.js +28 -0
  196. package/es/plugins/hr/react/components/HRNode.js +36 -0
  197. package/es/plugins/hr/react/index.d.ts +2 -0
  198. package/es/plugins/hr/react/style.js +32 -0
  199. package/es/plugins/hr/react/type.d.ts +6 -0
  200. package/es/plugins/image/command/index.d.ts +12 -0
  201. package/es/plugins/image/command/index.js +53 -0
  202. package/es/plugins/image/index.d.ts +4 -0
  203. package/es/plugins/image/node/basie-image-node.d.ts +33 -0
  204. package/es/plugins/image/node/basie-image-node.js +68 -0
  205. package/es/plugins/image/node/block-image-node.d.ts +43 -0
  206. package/es/plugins/image/node/block-image-node.js +137 -0
  207. package/es/plugins/image/node/image-node.d.ts +41 -0
  208. package/es/plugins/image/node/image-node.js +128 -0
  209. package/es/plugins/image/plugin/index.d.ts +24 -0
  210. package/es/plugins/image/plugin/index.js +183 -0
  211. package/es/plugins/image/react/ReactImagePlugin.d.ts +7 -0
  212. package/es/plugins/image/react/ReactImagePlugin.js +41 -0
  213. package/es/plugins/image/react/components/BrokenImage.js +16 -0
  214. package/es/plugins/image/react/components/Image.js +190 -0
  215. package/es/plugins/image/react/components/ImageEditPopover.js +160 -0
  216. package/es/plugins/image/react/components/LazyImage.js +73 -0
  217. package/es/plugins/image/react/components/ResizeHandle.js +62 -0
  218. package/es/plugins/image/react/components/style.js +135 -0
  219. package/es/plugins/image/react/components/useSupenseImage.js +22 -0
  220. package/es/plugins/image/react/index.d.ts +2 -0
  221. package/es/plugins/image/react/style.js +31 -0
  222. package/es/plugins/image/react/type.d.ts +23 -0
  223. package/es/plugins/inode/index.d.ts +3 -0
  224. package/es/plugins/inode/plugin/index.d.ts +19 -0
  225. package/es/plugins/inode/plugin/index.js +23 -0
  226. package/es/plugins/inode/react/index.d.ts +6 -0
  227. package/es/plugins/inode/react/index.js +15 -0
  228. package/es/plugins/inode/service/index.d.ts +17 -0
  229. package/es/plugins/inode/service/index.js +22 -0
  230. package/es/plugins/link/command/index.d.ts +10 -0
  231. package/es/plugins/link/command/index.js +33 -0
  232. package/es/plugins/link/index.d.ts +5 -0
  233. package/es/plugins/link/node/LinkNode.d.ts +10 -0
  234. package/es/plugins/link/node/LinkNode.js +448 -0
  235. package/es/plugins/link/plugin/index.d.ts +16 -0
  236. package/es/plugins/link/plugin/index.js +106 -0
  237. package/es/plugins/link/plugin/registry.js +82 -0
  238. package/es/plugins/link/react/ReactLinkPlugin.d.ts +7 -0
  239. package/es/plugins/link/react/ReactLinkPlugin.js +50 -0
  240. package/es/plugins/link/react/components/LinkEdit.js +204 -0
  241. package/es/plugins/link/react/components/LinkToolbar.js +148 -0
  242. package/es/plugins/link/react/index.d.ts +2 -0
  243. package/es/plugins/link/react/style.js +34 -0
  244. package/es/plugins/link/react/type.d.ts +14 -0
  245. package/es/plugins/link/service/i-link-service.d.ts +10 -0
  246. package/es/plugins/link/service/i-link-service.js +19 -0
  247. package/es/plugins/link/utils/index.js +45 -0
  248. package/es/plugins/link-highlight/command/index.d.ts +8 -0
  249. package/es/plugins/link-highlight/command/index.js +30 -0
  250. package/es/plugins/link-highlight/index.d.ts +3 -0
  251. package/es/plugins/link-highlight/node/link-highlight.js +80 -0
  252. package/es/plugins/link-highlight/plugin/index.d.ts +18 -0
  253. package/es/plugins/link-highlight/plugin/index.js +109 -0
  254. package/es/plugins/link-highlight/plugin/registry.js +33 -0
  255. package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.d.ts +7 -0
  256. package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +29 -0
  257. package/es/plugins/link-highlight/react/index.d.ts +1 -0
  258. package/es/plugins/link-highlight/react/style.js +14 -0
  259. package/es/plugins/link-highlight/react/type.d.ts +16 -0
  260. package/es/plugins/list/command/index.d.ts +3 -0
  261. package/es/plugins/list/command/index.js +3 -0
  262. package/es/plugins/list/index.d.ts +5 -0
  263. package/es/plugins/list/plugin/checkList.d.ts +6 -0
  264. package/es/plugins/list/plugin/checkList.js +140 -0
  265. package/es/plugins/list/plugin/index.d.ts +9 -0
  266. package/es/plugins/list/plugin/index.js +195 -0
  267. package/es/plugins/list/plugin/registry.js +68 -0
  268. package/es/plugins/list/react/ReactListPlugin.d.ts +7 -0
  269. package/es/plugins/list/react/ReactListPlugin.js +21 -0
  270. package/es/plugins/list/react/index.d.ts +2 -0
  271. package/es/plugins/list/react/style.js +123 -0
  272. package/es/plugins/list/react/type.d.ts +7 -0
  273. package/es/plugins/list/utils/index.js +58 -0
  274. package/es/plugins/litexml/command/diffCommand.d.ts +17 -0
  275. package/es/plugins/litexml/command/diffCommand.js +97 -0
  276. package/es/plugins/litexml/command/index.d.ts +38 -0
  277. package/es/plugins/litexml/command/index.js +333 -0
  278. package/es/plugins/litexml/data-source/litexml-data-source.d.ts +65 -0
  279. package/es/plugins/litexml/data-source/litexml-data-source.js +286 -0
  280. package/es/plugins/litexml/index.d.ts +7 -0
  281. package/es/plugins/litexml/node/DiffNode.d.ts +29 -0
  282. package/es/plugins/litexml/node/DiffNode.js +95 -0
  283. package/es/plugins/litexml/plugin/index.d.ts +24 -0
  284. package/es/plugins/litexml/plugin/index.js +106 -0
  285. package/es/plugins/litexml/react/DiffNodeToolbar/index.js +60 -0
  286. package/es/plugins/litexml/react/DiffNodeToolbar/style.js +24 -0
  287. package/es/plugins/litexml/react/hooks/useHasDiffNode.d.ts +7 -0
  288. package/es/plugins/litexml/react/hooks/useHasDiffNode.js +35 -0
  289. package/es/plugins/litexml/react/index.d.ts +6 -0
  290. package/es/plugins/litexml/react/index.js +26 -0
  291. package/es/plugins/litexml/react/style.js +124 -0
  292. package/es/plugins/litexml/service/litexml-service.d.ts +93 -0
  293. package/es/plugins/litexml/service/litexml-service.js +42 -0
  294. package/es/plugins/litexml/utils/index.js +59 -0
  295. package/es/plugins/markdown/command/index.d.ts +14 -0
  296. package/es/plugins/markdown/command/index.js +74 -0
  297. package/es/plugins/markdown/data-source/markdown/parse.d.ts +14 -0
  298. package/es/plugins/markdown/data-source/markdown/parse.js +195 -0
  299. package/es/plugins/markdown/data-source/markdown-data-source.js +148 -0
  300. package/es/plugins/markdown/data-source/markdown-writer-context.js +40 -0
  301. package/es/plugins/markdown/index.d.ts +7 -0
  302. package/es/plugins/markdown/plugin/index.d.ts +22 -0
  303. package/es/plugins/markdown/plugin/index.js +285 -0
  304. package/es/plugins/markdown/react/index.d.ts +6 -0
  305. package/es/plugins/markdown/react/index.js +31 -0
  306. package/es/plugins/markdown/service/shortcut.d.ts +57 -0
  307. package/es/plugins/markdown/service/shortcut.js +101 -0
  308. package/es/plugins/markdown/service/transformers.d.ts +61 -0
  309. package/es/plugins/markdown/service/transformers.js +119 -0
  310. package/es/plugins/markdown/utils/detectLanguage.d.ts +22 -0
  311. package/es/plugins/markdown/utils/detectLanguage.js +251 -0
  312. package/es/plugins/markdown/utils/index.d.ts +11 -0
  313. package/es/plugins/markdown/utils/index.js +143 -0
  314. package/es/plugins/markdown/utils/logger.js +6 -0
  315. package/es/plugins/math/command/index.d.ts +9 -0
  316. package/es/plugins/math/command/index.js +38 -0
  317. package/es/plugins/math/index.d.ts +3 -0
  318. package/es/plugins/math/node/index.d.ts +44 -0
  319. package/es/plugins/math/node/index.js +161 -0
  320. package/es/plugins/math/plugin/index.d.ts +15 -0
  321. package/es/plugins/math/plugin/index.js +119 -0
  322. package/es/plugins/math/react/components/MathEditor.js +198 -0
  323. package/es/plugins/math/react/components/MathEditorContainer.js +101 -0
  324. package/es/plugins/math/react/components/MathEditorContent.js +133 -0
  325. package/es/plugins/math/react/components/MathInline.js +86 -0
  326. package/es/plugins/math/react/components/Placeholder.js +24 -0
  327. package/es/plugins/math/react/index.d.ts +7 -0
  328. package/es/plugins/math/react/index.js +35 -0
  329. package/es/plugins/math/react/style.js +96 -0
  330. package/es/plugins/math/react/type.d.ts +17 -0
  331. package/es/plugins/math/utils/index.js +23 -0
  332. package/es/plugins/mention/command/index.d.ts +10 -0
  333. package/es/plugins/mention/command/index.js +18 -0
  334. package/es/plugins/mention/index.d.ts +5 -0
  335. package/es/plugins/mention/node/MentionNode.d.ts +28 -0
  336. package/es/plugins/mention/node/MentionNode.js +86 -0
  337. package/es/plugins/mention/plugin/index.d.ts +18 -0
  338. package/es/plugins/mention/plugin/index.js +63 -0
  339. package/es/plugins/mention/plugin/register.js +30 -0
  340. package/es/plugins/mention/react/ReactMentionPlugin.d.ts +7 -0
  341. package/es/plugins/mention/react/ReactMentionPlugin.js +36 -0
  342. package/es/plugins/mention/react/components/Mention.js +33 -0
  343. package/es/plugins/mention/react/index.d.ts +2 -0
  344. package/es/plugins/mention/react/style.js +34 -0
  345. package/es/plugins/mention/react/type.d.ts +12 -0
  346. package/es/plugins/slash/index.d.ts +6 -0
  347. package/es/plugins/slash/plugin/index.d.ts +27 -0
  348. package/es/plugins/slash/plugin/index.js +160 -0
  349. package/es/plugins/slash/react/ReactSlashOption.d.ts +7 -0
  350. package/es/plugins/slash/react/ReactSlashOption.js +8 -0
  351. package/es/plugins/slash/react/ReactSlashPlugin.d.ts +7 -0
  352. package/es/plugins/slash/react/ReactSlashPlugin.js +190 -0
  353. package/es/plugins/slash/react/components/DefaultSlashMenu.js +168 -0
  354. package/es/plugins/slash/react/components/SlashMenu.d.ts +11 -0
  355. package/es/plugins/slash/react/components/SlashMenu.js +40 -0
  356. package/es/plugins/slash/react/index.d.ts +4 -0
  357. package/es/plugins/slash/react/type.d.ts +114 -0
  358. package/es/plugins/slash/react/utils.js +18 -0
  359. package/es/plugins/slash/service/i-slash-service.d.ts +50 -0
  360. package/es/plugins/slash/service/i-slash-service.js +55 -0
  361. package/es/plugins/slash/utils/utils.d.ts +1 -0
  362. package/es/plugins/slash/utils/utils.js +97 -0
  363. package/es/plugins/table/command/index.d.ts +29 -0
  364. package/es/plugins/table/command/index.js +238 -0
  365. package/es/plugins/table/index.d.ts +4 -0
  366. package/es/plugins/table/node/index.d.ts +2 -0
  367. package/es/plugins/table/node/index.js +146 -0
  368. package/es/plugins/table/plugin/index.d.ts +14 -0
  369. package/es/plugins/table/plugin/index.js +361 -0
  370. package/es/plugins/table/react/TableActionMenu/ActionMenu.js +296 -0
  371. package/es/plugins/table/react/TableActionMenu/index.js +133 -0
  372. package/es/plugins/table/react/TableActionMenu/style.js +20 -0
  373. package/es/plugins/table/react/TableActionMenu/utils.js +34 -0
  374. package/es/plugins/table/react/TableColController.js +354 -0
  375. package/es/plugins/table/react/TableController/hooks.js +201 -0
  376. package/es/plugins/table/react/TableController/style.js +264 -0
  377. package/es/plugins/table/react/TableController/utils.js +25 -0
  378. package/es/plugins/table/react/TableControllerButton.js +81 -0
  379. package/es/plugins/table/react/TableControllerMenu.js +123 -0
  380. package/es/plugins/table/react/TableHoverActions/index.js +147 -0
  381. package/es/plugins/table/react/TableHoverActions/style.js +14 -0
  382. package/es/plugins/table/react/TableHoverActions/utils.js +32 -0
  383. package/es/plugins/table/react/TableInsertButton.js +25 -0
  384. package/es/plugins/table/react/TableResize/index.js +328 -0
  385. package/es/plugins/table/react/TableResize/style.js +16 -0
  386. package/es/plugins/table/react/TableResize/utils.js +9 -0
  387. package/es/plugins/table/react/TableRowController.js +349 -0
  388. package/es/plugins/table/react/hooks.js +77 -0
  389. package/es/plugins/table/react/index.d.ts +7 -0
  390. package/es/plugins/table/react/index.js +172 -0
  391. package/es/plugins/table/react/style.js +144 -0
  392. package/es/plugins/table/react/type.d.ts +10 -0
  393. package/es/plugins/table/react/useAutoFitPastedTable.js +189 -0
  394. package/es/plugins/table/service/i-table-controller-menu-service.d.ts +44 -0
  395. package/es/plugins/table/service/i-table-controller-menu-service.js +31 -0
  396. package/es/plugins/table/service/index.d.ts +1 -0
  397. package/es/plugins/table/utils/autoFitColumnWidth.js +87 -0
  398. package/es/plugins/table/utils/distributeColumnWidth.js +37 -0
  399. package/es/plugins/table/utils/index.js +148 -0
  400. package/es/plugins/toolbar/command/index.d.ts +12 -0
  401. package/es/plugins/toolbar/command/index.js +17 -0
  402. package/es/plugins/toolbar/index.d.ts +2 -0
  403. package/es/plugins/toolbar/react/index.d.ts +7 -0
  404. package/es/plugins/toolbar/react/index.js +109 -0
  405. package/es/plugins/toolbar/react/style.js +55 -0
  406. package/es/plugins/toolbar/react/type.d.ts +9 -0
  407. package/es/plugins/toolbar/utils/getDOMRangeRect.js +20 -0
  408. package/es/plugins/toolbar/utils/setFloatingElemPosition.js +50 -0
  409. package/es/plugins/upload/index.d.ts +2 -0
  410. package/es/plugins/upload/plugin/index.d.ts +6 -0
  411. package/es/plugins/upload/plugin/index.js +47 -0
  412. package/es/plugins/upload/service/i-upload-service.d.ts +13 -0
  413. package/es/plugins/upload/service/i-upload-service.js +30 -0
  414. package/es/plugins/upload/utils/index.js +15 -0
  415. package/es/plugins/virtual-block/index.d.ts +2 -0
  416. package/es/plugins/virtual-block/plugin/index.d.ts +8 -0
  417. package/es/plugins/virtual-block/plugin/index.js +19 -0
  418. package/es/plugins/virtual-block/plugin/register.js +150 -0
  419. package/es/plugins/virtual-block/react/ReactVirtualBlock.d.ts +6 -0
  420. package/es/plugins/virtual-block/react/ReactVirtualBlock.js +15 -0
  421. package/es/plugins/virtual-block/react/index.d.ts +1 -0
  422. package/es/react/ChatInput/ChatInput.d.ts +7 -0
  423. package/es/react/ChatInput/ChatInput.js +91 -0
  424. package/es/react/ChatInput/index.d.ts +2 -0
  425. package/es/react/ChatInput/style.js +115 -0
  426. package/es/react/ChatInput/type.d.ts +32 -0
  427. package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +7 -0
  428. package/es/react/ChatInputActionBar/ChatInputActionBar.js +22 -0
  429. package/es/react/ChatInputActionBar/index.d.ts +2 -0
  430. package/es/react/ChatInputActionBar/style.js +7 -0
  431. package/es/react/ChatInputActionBar/type.d.ts +10 -0
  432. package/es/react/ChatInputActions/ChatInputActions.d.ts +7 -0
  433. package/es/react/ChatInputActions/ChatInputActions.js +65 -0
  434. package/es/react/ChatInputActions/components/ActionItem.js +46 -0
  435. package/es/react/ChatInputActions/components/ActionRender.js +45 -0
  436. package/es/react/ChatInputActions/components/CollapsedActions.js +60 -0
  437. package/es/react/ChatInputActions/components/useDisplayActionCount.js +45 -0
  438. package/es/react/ChatInputActions/index.d.ts +2 -0
  439. package/es/react/ChatInputActions/style.js +20 -0
  440. package/es/react/ChatInputActions/type.d.ts +36 -0
  441. package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +7 -0
  442. package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +67 -0
  443. package/es/react/CodeLanguageSelect/index.d.ts +2 -0
  444. package/es/react/CodeLanguageSelect/style.js +7 -0
  445. package/es/react/CodeLanguageSelect/type.d.ts +6 -0
  446. package/es/react/Editor/Editor.js +108 -0
  447. package/es/react/Editor/index.d.ts +16 -0
  448. package/es/react/Editor/index.js +11 -0
  449. package/es/react/Editor/type.d.ts +64 -0
  450. package/es/react/Editor/utils.d.ts +6 -0
  451. package/es/react/Editor/utils.js +6 -0
  452. package/es/react/EditorProvider/index.d.ts +28 -0
  453. package/es/react/EditorProvider/index.js +18 -0
  454. package/es/react/FloatActions/FloatActions.d.ts +7 -0
  455. package/es/react/FloatActions/FloatActions.js +34 -0
  456. package/es/react/FloatActions/components/ActionItem.js +46 -0
  457. package/es/react/FloatActions/components/ActionRender.js +45 -0
  458. package/es/react/FloatActions/components/CollapsedActions.js +60 -0
  459. package/es/react/FloatActions/index.d.ts +2 -0
  460. package/es/react/FloatActions/style.js +19 -0
  461. package/es/react/FloatActions/type.d.ts +33 -0
  462. package/es/react/FloatMenu/FloatMenu.d.ts +7 -0
  463. package/es/react/FloatMenu/FloatMenu.js +32 -0
  464. package/es/react/FloatMenu/index.d.ts +2 -0
  465. package/es/react/FloatMenu/style.js +28 -0
  466. package/es/react/FloatMenu/type.d.ts +25 -0
  467. package/es/react/SendButton/SendButton.d.ts +7 -0
  468. package/es/react/SendButton/SendButton.js +107 -0
  469. package/es/react/SendButton/components/SendIcon.js +23 -0
  470. package/es/react/SendButton/components/StopIcon.js +56 -0
  471. package/es/react/SendButton/index.d.ts +2 -0
  472. package/es/react/SendButton/style.js +68 -0
  473. package/es/react/SendButton/type.d.ts +12 -0
  474. package/es/react/SlashMenu/SlashMenu.d.ts +7 -0
  475. package/es/react/SlashMenu/SlashMenu.js +40 -0
  476. package/es/react/SlashMenu/index.d.ts +2 -0
  477. package/es/react/SlashMenu/type.d.ts +17 -0
  478. package/es/react/hooks/useEditor.d.ts +5 -0
  479. package/es/react/hooks/useEditor.js +8 -0
  480. package/es/react/hooks/useEditorState/index.d.ts +71 -0
  481. package/es/react/hooks/useEditorState/index.js +347 -0
  482. package/es/react/hooks/useEditorState/utils.js +28 -0
  483. package/es/react/hooks/useSize.js +61 -0
  484. package/es/react.d.ts +22 -334
  485. package/es/react.js +13 -1573
  486. package/es/renderer/LexicalDiff.d.ts +41 -0
  487. package/es/renderer/LexicalDiff.js +96 -0
  488. package/es/renderer/LexicalRenderer.d.ts +16 -0
  489. package/es/renderer/LexicalRenderer.js +48 -0
  490. package/es/renderer/diff/compute.js +396 -0
  491. package/es/renderer/diff/style.d.ts +4 -0
  492. package/es/renderer/diff/style.js +104 -0
  493. package/es/renderer/diff/types.d.ts +32 -0
  494. package/es/renderer/engine/render-builtin-node.js +196 -0
  495. package/es/renderer/engine/render-text-node.js +33 -0
  496. package/es/renderer/engine/render-tree.js +35 -0
  497. package/es/renderer/engine/shiki.d.ts +4 -0
  498. package/es/renderer/engine/shiki.js +24 -0
  499. package/es/renderer/engine/utils.js +16 -0
  500. package/es/renderer/nodes/index.d.ts +6 -0
  501. package/es/renderer/nodes/index.js +44 -0
  502. package/es/renderer/renderers/codeblock.js +21 -0
  503. package/es/renderer/renderers/file.js +29 -0
  504. package/es/renderer/renderers/horizontalrule.js +29 -0
  505. package/es/renderer/renderers/image.js +35 -0
  506. package/es/renderer/renderers/index.d.ts +6 -0
  507. package/es/renderer/renderers/index.js +21 -0
  508. package/es/renderer/renderers/math.js +19 -0
  509. package/es/renderer/renderers/mention.js +15 -0
  510. package/es/renderer/renderers/mermaid.js +17 -0
  511. package/es/renderer/style.js +52 -0
  512. package/es/renderer/types.d.ts +29 -0
  513. package/es/renderer.d.ts +8 -114
  514. package/es/renderer.js +5 -1153
  515. package/es/types/hotkey.d.ts +76 -0
  516. package/es/types/hotkey.js +65 -0
  517. package/es/types/index.d.ts +2 -0
  518. package/es/types/kernel.d.ts +359 -0
  519. package/es/types/locale.d.ts +11 -0
  520. package/es/utils/cx.js +4 -0
  521. package/es/utils/debug.d.ts +425 -0
  522. package/es/{debug-CIvbNHJu.js → utils/debug.js} +3 -35
  523. package/es/utils/hotkey/isHotkeyMatch.js +17 -0
  524. package/es/utils/hotkey/parseHotkeys.js +53 -0
  525. package/es/utils/hotkey/registerHotkey.d.ts +18 -0
  526. package/es/utils/hotkey/registerHotkey.js +35 -0
  527. package/es/utils/scrollIntoView.d.ts +8 -0
  528. package/es/utils/scrollIntoView.js +29 -0
  529. package/es/utils/updatePosition.js +26 -0
  530. package/es/utils/url.d.ts +18 -0
  531. package/es/utils/url.js +34 -0
  532. package/package.json +4 -1
  533. package/es/ReactSlashPlugin-BiVy_Iwf.js +0 -23072
  534. package/es/codemirror-3POv7f__.js +0 -923
  535. package/es/index-DHGp94p0.d.ts +0 -916
  536. package/es/style-DADgHVA1.js +0 -2889
  537. package/es/style-DMdPzCo-.js +0 -999
package/es/react.js CHANGED
@@ -1,1574 +1,14 @@
1
- import { A as $createCodeMirrorNode, B as Editor$2, Ft as init_utils, Mt as $isRootTextContentEmpty, S as formatUrl, T as $isSelectionInCodeInline, a as $createMathBlockNode, d as $isLinkHighlightNode, h as $isLinkNode, j as $isCodeMirrorNode, mt as noop, o as $createMathInlineNode, x as TOGGLE_LINK_COMMAND } from "./style-DADgHVA1.js";
2
- import { C as INSERT_CODEINLINE_COMMAND, E as ReactEditorContent, O as ReactMarkdownPlugin, Q as ReactEditor, S as validateUrl, T as ReactPlainText, _ as INSERT_CHECK_LIST_COMMAND, a as ReactMentionPlugin, c as INSERT_LINK_HIGHLIGHT_COMMAND, n as ReactSlashOption, p as UPDATE_CODEBLOCK_LANG, t as ReactSlashPlugin, x as sanitizeUrl, y as extractUrlFromText } from "./ReactSlashPlugin-BiVy_Iwf.js";
3
- import { ActionIcon, Block, Button, Dropdown, Flexbox, Icon, MaterialFileTypeIcon, Menu, Popover, Select, Text, TooltipGroup, useMotionComponent } from "@lobehub/ui";
4
- import { ChevronDownIcon, CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
5
- import { createContext, createElement, isValidElement, memo, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- import { createStaticStyles, cssVar, cx, useThemeMode } from "antd-style";
8
- import { Divider, Dropdown as Dropdown$1, Space } from "antd";
9
- import { $createNodeSelection, $createParagraphNode, $getSelection, $isParagraphNode, $isRangeSelection, $isRootOrShadowRoot, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from "lexical";
10
- import { $createQuoteNode, $isHeadingNode, $isQuoteNode } from "@lexical/rich-text";
11
- import { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from "@lexical/utils";
12
- import { $isAtNodeEnd, $setBlocksType } from "@lexical/selection";
13
- import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode } from "@lexical/list";
14
- import { $createCodeNode, $isCodeNode } from "@lexical/code-core";
15
- import { createPortal } from "react-dom";
16
- import { bundledLanguagesInfo } from "shiki";
17
- import { Resizable } from "re-resizable";
18
- import useMergeState from "use-merge-value";
19
- import { debounce } from "es-toolkit";
20
- //#region src/react/hooks/useSize.ts
21
- const useWidth = (options = {}) => {
22
- const { debounceMs = 100 } = options;
23
- const ref = useRef(null);
24
- const [size, setSize] = useState();
25
- const resizeObserverRef = useRef(null);
26
- const updateSize = useCallback(debounce((entries) => {
27
- if (entries[0]) {
28
- const { width } = entries[0].contentRect;
29
- setSize(Math.floor(width));
30
- }
31
- }, debounceMs), [debounceMs]);
32
- useEffect(() => {
33
- const element = ref.current;
34
- if (!element) return;
35
- resizeObserverRef.current = new ResizeObserver(updateSize);
36
- resizeObserverRef.current.observe(element);
37
- return () => {
38
- if (resizeObserverRef.current) {
39
- resizeObserverRef.current.disconnect();
40
- updateSize.cancel?.();
41
- }
42
- };
43
- }, [updateSize]);
44
- return {
45
- ref,
46
- width: size
47
- };
48
- };
49
- const useHeight = (options = {}) => {
50
- const { debounceMs = 100 } = options;
51
- const ref = useRef(null);
52
- const [size, setSize] = useState();
53
- const resizeObserverRef = useRef(null);
54
- const updateSize = useCallback(debounce((entries) => {
55
- if (entries[0]) {
56
- const { height } = entries[0].contentRect;
57
- setSize(Math.floor(height));
58
- }
59
- }, debounceMs), [debounceMs]);
60
- useEffect(() => {
61
- const element = ref.current;
62
- if (!element) return;
63
- resizeObserverRef.current = new ResizeObserver(updateSize);
64
- resizeObserverRef.current.observe(element);
65
- return () => {
66
- if (resizeObserverRef.current) {
67
- resizeObserverRef.current.disconnect();
68
- updateSize.cancel?.();
69
- }
70
- };
71
- }, [updateSize]);
72
- return {
73
- height: size,
74
- ref
75
- };
76
- };
77
- //#endregion
78
- //#region src/react/ChatInput/style.ts
79
- const styles$8 = createStaticStyles(({ css, cssVar }) => ({
80
- bodyEditor: css`
81
- z-index: 0;
82
- flex: 1;
83
- `,
84
- containerDark: css`
85
- position: relative;
86
-
87
- display: flex;
88
- flex-direction: column;
89
-
90
- height: 100%;
91
- border: 1px solid ${cssVar.colorFillSecondary};
92
- border-radius: ${cssVar.borderRadiusLG};
93
-
94
- background-color: ${cssVar.colorBgElevated};
95
- box-shadow: 0 4px 4px color-mix(in srgb, #000 40%, transparent);
96
- `,
97
- containerLight: css`
98
- position: relative;
99
-
100
- display: flex;
101
- flex-direction: column;
102
-
103
- height: 100%;
104
- border: 1px solid ${cssVar.colorFill};
105
- border-radius: ${cssVar.borderRadiusLG};
106
-
107
- background-color: ${cssVar.colorBgElevated};
108
- box-shadow: 0 4px 4px color-mix(in srgb, #000 4%, transparent);
109
- `,
110
- editor: css`
111
- cursor: text;
112
-
113
- overflow: hidden auto;
114
- flex: 1;
115
-
116
- width: 100%;
117
- padding-block: 8px 0;
118
- padding-inline: 12px;
119
- `,
120
- footer: css`
121
- z-index: 1;
122
- width: 100%;
123
- `,
124
- header: css`
125
- z-index: 1;
126
- width: 100%;
127
- `,
128
- resizableContainer: css`
129
- position: relative;
130
-
131
- display: flex;
132
- flex: 1 1 auto;
133
- flex-direction: column;
134
- align-self: flex-end;
135
-
136
- width: 100%;
137
-
138
- &:hover .resize-handle {
139
- opacity: 1;
140
- }
141
- `,
142
- resizeHandle: css`
143
- position: absolute;
144
- inset-block-start: -4px;
145
- inset-inline-start: 50%;
146
- transform: translateX(-50%);
147
-
148
- width: 100%;
149
- height: 8px;
150
-
151
- opacity: 0;
152
-
153
- transition: opacity 0.2s ease-in-out;
154
-
155
- &::before {
156
- content: '';
157
-
158
- position: absolute;
159
- inset-block-start: 0;
160
- inset-inline-start: 50%;
161
- transform: translateX(-50%);
162
-
163
- width: 32px;
164
- height: 4px;
165
- border-radius: 4px;
166
-
167
- background-color: ${cssVar.colorPrimary};
168
- box-shadow: 0 1px 2px color-mix(in srgb, ${cssVar.colorTextSecondary} 12.5%, transparent);
169
- }
170
-
171
- &:hover {
172
- opacity: 1 !important;
173
-
174
- &::before {
175
- background-color: ${cssVar.colorPrimaryHover};
176
- box-shadow: 0 2px 4px color-mix(in srgb, ${cssVar.colorTextSecondary} 25%, transparent);
177
- }
178
- }
179
-
180
- &:active {
181
- &::before {
182
- background-color: ${cssVar.colorPrimaryActive};
183
- }
184
- }
185
- `,
186
- root: css`
187
- position: relative;
188
- `
189
- }));
190
- //#endregion
191
- //#region src/react/ChatInput/ChatInput.tsx
192
- const ChatInput = (props) => {
193
- const { defaultHeight = props.defaultHeight || props.minHeight || 64, height, maxHeight = 320, minHeight = 64, resizeMaxHeightOffset = 120, resize = true, onSizeChange, onSizeDragging, className, children, footer, header, style, slashMenuRef, classNames, fullscreen, showResizeHandle, onBodyClick, styles: customStyles, ...rest } = props;
194
- const { isDarkMode } = useThemeMode();
195
- const { ref: headerRef, height: headerHeight = 0 } = useHeight();
196
- const [currentHeight, setCurrentHeight] = useMergeState(defaultHeight, {
197
- defaultValue: defaultHeight,
198
- onChange: onSizeChange,
199
- value: height
200
- });
201
- const handleResizeStop = useCallback((e, direction, ref) => {
202
- setCurrentHeight(ref.style.height ? parseInt(ref.style.height) : defaultHeight);
203
- }, [setCurrentHeight, defaultHeight]);
204
- const handleResize = useCallback((e, direction, ref) => {
205
- const newHeight = ref.style.height ? parseInt(ref.style.height) : defaultHeight;
206
- onSizeDragging?.(newHeight);
207
- }, [onSizeDragging, defaultHeight]);
208
- const bodyNode = /* @__PURE__ */ jsx("div", {
209
- className: cx(styles$8.editor, styles$8.bodyEditor, classNames?.body),
210
- draggable: false,
211
- onClick: onBodyClick,
212
- style: {
213
- ...customStyles?.body,
214
- maxHeight: fullscreen ? "100%" : maxHeight,
215
- minHeight: resize ? currentHeight : minHeight
216
- },
217
- children
218
- });
219
- return /* @__PURE__ */ jsxs(Flexbox, {
220
- className: cx(isDarkMode ? styles$8.containerDark : styles$8.containerLight, styles$8.root, className),
221
- height: fullscreen ? "100%" : void 0,
222
- style,
223
- width: "100%",
224
- ...rest,
225
- children: [
226
- slashMenuRef && /* @__PURE__ */ jsx("div", { ref: slashMenuRef }),
227
- /* @__PURE__ */ jsx("div", {
228
- className: cx(styles$8.header, classNames?.header),
229
- ref: headerRef,
230
- style: customStyles?.header,
231
- children: header
232
- }),
233
- resize ? /* @__PURE__ */ jsx(Resizable, {
234
- className: styles$8.resizableContainer,
235
- enable: fullscreen ? false : { top: true },
236
- handleClasses: { top: showResizeHandle ? styles$8.resizeHandle : void 0 },
237
- handleStyles: { top: {
238
- backgroundColor: "transparent",
239
- borderRadius: "4px",
240
- cursor: "ns-resize",
241
- height: "8px",
242
- left: "50%",
243
- top: !!header ? -3 - headerHeight : -3,
244
- transform: "translateX(-50%)",
245
- width: "100%"
246
- } },
247
- maxHeight: fullscreen ? void 0 : maxHeight + resizeMaxHeightOffset,
248
- minHeight: fullscreen ? void 0 : minHeight,
249
- onResize: handleResize,
250
- onResizeStop: handleResizeStop,
251
- size: {
252
- height: fullscreen ? void 0 : "auto",
253
- width: "100%"
254
- },
255
- style: fullscreen ? {
256
- flex: 1,
257
- overflow: "hidden",
258
- position: "relative"
259
- } : void 0,
260
- children: bodyNode
261
- }) : bodyNode,
262
- /* @__PURE__ */ jsx("div", {
263
- className: cx(styles$8.footer, classNames?.footer),
264
- style: customStyles?.footer,
265
- children: footer
266
- })
267
- ]
268
- });
269
- };
270
- ChatInput.displayName = "ChatInput";
271
- //#endregion
272
- //#region src/react/ChatInputActionBar/style.ts
273
- const styles$7 = createStaticStyles(({ css }) => ({ container: css`
274
- overflow: hidden;
275
- ` }));
276
- //#endregion
277
- //#region src/react/ChatInputActionBar/ChatInputActionBar.tsx
278
- const ChatInputActionBar = ({ className, style, left, right, ...rest }) => {
279
- return /* @__PURE__ */ jsxs(Flexbox, {
280
- align: "center",
281
- className: cx(styles$7.container, className),
282
- gap: 4,
283
- horizontal: true,
284
- justify: "space-between",
285
- padding: 4,
286
- style,
287
- ...rest,
288
- children: [left, right]
289
- });
290
- };
291
- ChatInputActionBar.displayName = "ChatInputActionBar";
292
- //#endregion
293
- //#region src/react/ChatInputActions/style.ts
294
- const styles$6 = createStaticStyles(({ css }) => ({
295
- collapsedContainer: css`
296
- overflow: hidden;
297
- display: flex;
298
- align-items: center;
299
- `,
300
- container: css`
301
- position: relative;
302
- overflow: hidden;
303
- width: 100%;
304
- `,
305
- divider: css`
306
- height: 20px;
307
- margin-inline: 4px;
308
- `
309
- }));
310
- //#endregion
311
- //#region src/react/ChatInputActions/components/ActionRender.tsx
312
- const ActionRender$1 = ({ item, onActionClick, disabled }) => {
313
- if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
314
- className: styles$6.divider,
315
- orientation: "vertical"
316
- });
317
- const { wrapper, icon, key, label, onClick, danger, loading, active, tooltipProps, ...itemRest } = item;
318
- if (item.children && isValidElement(item.children)) {
319
- if (!wrapper) return item.children;
320
- return wrapper(item.children);
321
- }
322
- const action = /* @__PURE__ */ jsx(ActionIcon, {
323
- active,
324
- danger,
325
- disabled: disabled || loading || itemRest?.disabled,
326
- icon,
327
- loading,
328
- onClick: (e) => {
329
- onActionClick?.({
330
- domEvent: e,
331
- key: String(key),
332
- keyPath: [String(key)]
333
- });
334
- onClick?.(e);
335
- },
336
- size: {
337
- blockSize: 36,
338
- size: 20
339
- },
340
- title: label,
341
- tooltipProps: {
342
- placement: "top",
343
- ...tooltipProps
344
- }
345
- });
346
- if (!wrapper) return action;
347
- return wrapper(action);
348
- };
349
- //#endregion
350
- //#region src/react/ChatInputActions/components/CollapsedActions.tsx
351
- const CollapsedActions$1 = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
352
- const Motion = useMotionComponent();
353
- if (mode === "popup") return /* @__PURE__ */ jsx(Popover, {
354
- arrow: false,
355
- content: /* @__PURE__ */ jsx(Flexbox, {
356
- align: "center",
357
- gap,
358
- horizontal: true,
359
- children
360
- }),
361
- styles: { content: { padding: 4 } },
362
- children: /* @__PURE__ */ jsx(ActionIcon, {
363
- icon: CircleChevronUpIcon,
364
- size: {
365
- blockSize: 36,
366
- size: 20
367
- }
368
- })
369
- });
370
- return /* @__PURE__ */ jsxs(Flexbox, {
371
- align: "center",
372
- flex: "none",
373
- gap,
374
- horizontal: true,
375
- children: [/* @__PURE__ */ jsx(Motion.div, {
376
- animate: groupCollapse ? "closed" : "open",
377
- className: styles$6.collapsedContainer,
378
- initial: groupCollapse ? "closed" : "open",
379
- style: { gap },
380
- transition: { duration: .2 },
381
- variants: {
382
- closed: {
383
- opacity: 0,
384
- width: 0
385
- },
386
- open: {
387
- opacity: 1,
388
- width: "auto"
389
- }
390
- },
391
- children
392
- }), /* @__PURE__ */ jsx(ActionIcon, {
393
- icon: groupCollapse ? CircleChevronRightIcon : CircleChevronLeftIcon,
394
- onClick: () => onGroupCollapseChange?.(!groupCollapse),
395
- size: {
396
- blockSize: 36,
397
- size: 20
398
- }
399
- })]
400
- });
401
- };
402
- CollapsedActions$1.displayName = "ChatInputActionsCollapse";
403
- //#endregion
404
- //#region src/react/ChatInputActions/components/ActionItem.tsx
405
- const ActionItem$1 = ({ item, disabled, onActionClick, groupCollapsed, collapsed, gap, setGroupCollapsed }) => {
406
- if (item.type === "collapse") return /* @__PURE__ */ jsx(CollapsedActions$1, {
407
- gap,
408
- groupCollapse: groupCollapsed,
409
- mode: collapsed ? "popup" : "default",
410
- onGroupCollapseChange: setGroupCollapsed,
411
- children: item.children.map((child, childIndex) => /* @__PURE__ */ jsx(ActionRender$1, {
412
- disabled,
413
- item: child,
414
- onActionClick
415
- }, child?.key || `action-${childIndex}`))
416
- });
417
- if (item.type === "dropdown") return /* @__PURE__ */ jsx(Dropdown, {
418
- menu: { items: item.children },
419
- children: /* @__PURE__ */ jsx(ActionIcon, {
420
- active: item.active,
421
- danger: item.danger,
422
- disabled: disabled || item.loading || item?.disabled,
423
- icon: item.icon,
424
- loading: item.loading,
425
- size: {
426
- blockSize: 36,
427
- size: 20
428
- },
429
- title: item.label,
430
- tooltipProps: {
431
- placement: "top",
432
- ...item.tooltipProps
433
- }
434
- })
435
- }, item.key);
436
- return /* @__PURE__ */ jsx(ActionRender$1, {
437
- disabled,
438
- item,
439
- onActionClick
440
- });
441
- };
442
- ActionItem$1.displayName = "ChatInputActionItem";
443
- //#endregion
444
- //#region src/react/ChatInputActions/components/useDisplayActionCount.ts
445
- const useDisplayActionCount = ({ items = [], collapseOffset = 0, autoCollapse } = {}) => {
446
- const { ref, width } = useWidth();
447
- const [collapsed, setCollapsed] = useState(false);
448
- const flatItems = useMemo(() => items.flatMap((item) => {
449
- if (item.type === "collapse" && item.children) return item.children;
450
- return item;
451
- }).filter((item) => item.type !== "divider"), [items]);
452
- const alwaysDisplayCount = useMemo(() => items.filter((item) => item.alwaysDisplay).length, [items]);
453
- const rawMaxCount = useMemo(() => flatItems.length + 1, [flatItems.length]);
454
- const [maxCount, setMaxCount] = useState(rawMaxCount);
455
- useEffect(() => {
456
- if (!autoCollapse) {
457
- setCollapsed(false);
458
- setMaxCount(rawMaxCount);
459
- return;
460
- }
461
- if (!width) return;
462
- const atLeastCount = 1 + alwaysDisplayCount;
463
- let calcMaxCount = Math.floor((width - collapseOffset) / 38);
464
- if (calcMaxCount < atLeastCount) calcMaxCount = atLeastCount;
465
- setCollapsed(calcMaxCount < rawMaxCount);
466
- if (calcMaxCount >= rawMaxCount) return;
467
- setMaxCount(calcMaxCount);
468
- }, [
469
- autoCollapse,
470
- width,
471
- rawMaxCount,
472
- collapseOffset,
473
- alwaysDisplayCount
474
- ]);
475
- return useMemo(() => ({
476
- collapsed,
477
- maxCount,
478
- ref
479
- }), [
480
- collapsed,
481
- maxCount,
482
- ref
483
- ]);
484
- };
485
- //#endregion
486
- //#region src/react/ChatInputActions/ChatInputActions.tsx
487
- const ChatInputActions = memo(({ gap = 2, disabled, items = [], onActionClick, className, collapseOffset = 0, autoCollapse = true, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
488
- const [groupCollapsed, setGroupCollapsed] = useMergeState(defaultGroupCollapse, {
489
- defaultValue: defaultGroupCollapse,
490
- onChange: onGroupCollapseChange,
491
- value: groupCollapse
492
- });
493
- const { ref, maxCount, collapsed } = useDisplayActionCount({
494
- autoCollapse,
495
- collapseOffset,
496
- items
497
- });
498
- const calcItem = useMemo(() => {
499
- if (!collapsed) return items;
500
- const alwaysDisplayItems = items.filter((item) => item.alwaysDisplay);
501
- const normalItems = items.filter((item) => item.type !== "collapse" && !item.alwaysDisplay);
502
- const collapseItems = items.find((item) => item.type === "collapse" && item.children) || {
503
- children: [],
504
- type: "collapse"
505
- };
506
- const sliceCount = maxCount - alwaysDisplayItems.length - 1;
507
- return [
508
- ...normalItems.slice(0, sliceCount),
509
- {
510
- ...collapseItems,
511
- children: [...normalItems.filter((item) => item.type !== "divider").slice(sliceCount), ...collapseItems.children]
512
- },
513
- ...alwaysDisplayItems
514
- ].filter(Boolean);
515
- }, [
516
- collapsed,
517
- items,
518
- maxCount
519
- ]);
520
- return /* @__PURE__ */ jsx(TooltipGroup, { children: /* @__PURE__ */ jsx(Flexbox, {
521
- align: "center",
522
- className: cx(styles$6.container, className),
523
- flex: 1,
524
- gap,
525
- horizontal: true,
526
- ref,
527
- ...rest,
528
- children: calcItem.map((item, index) => /* @__PURE__ */ jsx(ActionItem$1, {
529
- collapsed,
530
- disabled,
531
- gap,
532
- groupCollapsed,
533
- item,
534
- onActionClick,
535
- setGroupCollapsed
536
- }, item.key || index))
537
- }) });
538
- });
539
- ChatInputActions.displayName = "ChatInputActions";
540
- //#endregion
541
- //#region src/react/CodeLanguageSelect/style.ts
542
- const styles$5 = createStaticStyles(({ css }) => ({ container: css`
543
- width: 160px;
544
- ` }));
545
- //#endregion
546
- //#region src/react/CodeLanguageSelect/CodeLanguageSelect.tsx
547
- const CodeLanguageSelect = ({ className, ...rest }) => {
548
- const options = useMemo(() => [{
549
- aliases: ["text", "txt"],
550
- label: /* @__PURE__ */ jsxs(Flexbox, {
551
- align: "center",
552
- gap: 4,
553
- horizontal: true,
554
- children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
555
- fallbackUnknownType: false,
556
- filename: `*.txt`,
557
- size: 18,
558
- type: "file",
559
- variant: "raw"
560
- }), /* @__PURE__ */ jsx(Text, {
561
- ellipsis: true,
562
- fontSize: 13,
563
- children: "Plaintext"
564
- })]
565
- }),
566
- value: "plaintext"
567
- }, ...bundledLanguagesInfo.map((item) => ({
568
- aliases: item.aliases,
569
- label: /* @__PURE__ */ jsxs(Flexbox, {
570
- align: "center",
571
- gap: 4,
572
- horizontal: true,
573
- children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
574
- fallbackUnknownType: false,
575
- filename: `*.${item?.aliases?.[0] || item.id}`,
576
- size: 18,
577
- type: "file",
578
- variant: "raw"
579
- }), /* @__PURE__ */ jsx(Text, {
580
- ellipsis: true,
581
- fontSize: 13,
582
- children: item.name
583
- })]
584
- }),
585
- title: (item.aliases || [item.id]).filter(Boolean).map((item) => `*.${item}`).join(","),
586
- value: item.id
587
- }))], []);
588
- return /* @__PURE__ */ jsx(Select, {
589
- className: cx(styles$5.container, className),
590
- defaultValue: "plaintext",
591
- filterOption: (input, option) => {
592
- const lang = input.toLowerCase();
593
- if ((option?.value)?.startsWith(lang)) return true;
594
- if (option?.aliases?.some((item) => item.startsWith(lang))) return true;
595
- return false;
596
- },
597
- options,
598
- showSearch: true,
599
- variant: "filled",
600
- ...rest
601
- });
602
- };
603
- CodeLanguageSelect.displayName = "CodeLanguageSelect";
604
- //#endregion
605
- //#region src/react/hooks/useEditor.ts
606
- const useEditor = () => {
607
- return useMemo(() => Editor$2.createEditor(), []);
608
- };
609
- //#endregion
610
- //#region src/react/hooks/useEditorState/utils.ts
611
- init_utils();
612
- const $findTopLevelElement = (node) => {
613
- let topLevelElement = node.getKey() === "root" ? node : $findMatchingParent(node, (e) => {
614
- const parent = e.getParent();
615
- return parent !== null && $isRootOrShadowRoot(parent);
616
- });
617
- if (topLevelElement === null) topLevelElement = node.getTopLevelElementOrThrow();
618
- return topLevelElement;
619
- };
620
- const formatParagraph = (editor) => {
621
- editor?.update(() => {
622
- $setBlocksType($getSelection(), () => $createParagraphNode());
623
- });
624
- };
625
- const getSelectedNode = (selection) => {
626
- const anchor = selection.anchor;
627
- const focus = selection.focus;
628
- const anchorNode = selection.anchor.getNode();
629
- const focusNode = selection.focus.getNode();
630
- if (anchorNode === focusNode) return anchorNode;
631
- if (selection.isBackward()) return $isAtNodeEnd(focus) ? anchorNode : focusNode;
632
- else return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
633
- };
634
- //#endregion
635
- //#region src/react/hooks/useEditorState/index.ts
636
- /**
637
- * Provide toolbar state and toolbar methods
638
- * @param editor - Editor instance
639
- * @returns Editor state and methods for toolbar functionality
640
- */
641
- function useEditorState(editor) {
642
- const [canUndo, setCanUndo] = useState(false);
643
- const [canRedo, setCanRedo] = useState(false);
644
- const [editable, setEditable] = useState(editor?.isEditable() ?? true);
645
- const [isBold, setIsBold] = useState(false);
646
- const [isItalic, setIsItalic] = useState(false);
647
- const [isUnderline, setIsUnderline] = useState(false);
648
- const [isStrikethrough, setIsStrikethrough] = useState(false);
649
- const [isSubscript, setIsSubscript] = useState(false);
650
- const [isSuperscript, setIsSuperscript] = useState(false);
651
- const [isCode, setIsCode] = useState(false);
652
- const [isLink, setIsLink] = useState(false);
653
- const [isCodeblock, setIsInCodeblok] = useState(false);
654
- const [isBlockquote, setIsInBlockquote] = useState(false);
655
- const [codeblockLang, setCodeblockLang] = useState(null);
656
- const [isEmpty, setIsEmpty] = useState(true);
657
- const [isSelected, setIsSelected] = useState(false);
658
- const [blockType, setBlockType] = useState(null);
659
- const $handleHeadingNode = useCallback((selectedElement) => {
660
- setBlockType($isHeadingNode(selectedElement) ? selectedElement.getTag() : selectedElement.getType());
661
- }, [setBlockType]);
662
- const $updateToolbar = useCallback(() => {
663
- const selection = $getSelection();
664
- const lexicalEditor = editor?.getLexicalEditor();
665
- setIsSelected(false);
666
- setEditable(editor?.isEditable() ?? true);
667
- if (lexicalEditor) setIsEmpty($isRootTextContentEmpty(lexicalEditor.isComposing(), false));
668
- if ($isRangeSelection(selection)) {
669
- setIsSelected(!!selection._cachedNodes);
670
- setIsBold(selection.hasFormat("bold"));
671
- setIsItalic(selection.hasFormat("italic"));
672
- setIsUnderline(selection.hasFormat("underline"));
673
- setIsStrikethrough(selection.hasFormat("strikethrough"));
674
- setIsSubscript(selection.hasFormat("subscript"));
675
- setIsSuperscript(selection.hasFormat("superscript"));
676
- setIsCode($isSelectionInCodeInline(lexicalEditor));
677
- const anchorNode = selection.anchor.getNode();
678
- const focusNode = selection.focus.getNode();
679
- const element = $findTopLevelElement(anchorNode);
680
- const focusElement = $findTopLevelElement(focusNode);
681
- const elementKey = element.getKey();
682
- const elementDOM = editor?.getLexicalEditor()?.getElementByKey(elementKey);
683
- const node = getSelectedNode(selection);
684
- const parent = node.getParent();
685
- setIsLink($isLinkNode(parent) || $isLinkNode(node) || $isLinkHighlightNode(parent) || $isLinkHighlightNode(node));
686
- const isLexicalCodeBlock = $isCodeNode(element) && $isCodeNode(focusElement) && elementKey === focusElement.getKey();
687
- const isCodeMirrorBlock = $isCodeMirrorNode(element) && $isCodeMirrorNode(focusElement) && elementKey === focusElement.getKey();
688
- setIsInCodeblok(isLexicalCodeBlock || isCodeMirrorBlock);
689
- if (isLexicalCodeBlock) setCodeblockLang(element.getLanguage());
690
- else if (isCodeMirrorBlock) setCodeblockLang(element.lang);
691
- else setCodeblockLang("");
692
- setIsInBlockquote($isQuoteNode(element) && $isQuoteNode(focusElement) && elementKey === focusElement.getKey());
693
- if (elementDOM !== null) if ($isListNode(element)) {
694
- const parentList = $getNearestNodeOfType(anchorNode, ListNode);
695
- setBlockType(parentList ? parentList.getListType() : element.getListType());
696
- } else $handleHeadingNode(element);
697
- } else if (!selection) {
698
- setIsSelected(false);
699
- setIsBold(false);
700
- setIsItalic(false);
701
- setIsUnderline(false);
702
- setIsStrikethrough(false);
703
- setIsSubscript(false);
704
- setIsSuperscript(false);
705
- setIsCode(false);
706
- setIsLink(false);
707
- setIsInCodeblok(false);
708
- setIsInBlockquote(false);
709
- setCodeblockLang(null);
710
- setBlockType(null);
711
- }
712
- }, [editor]);
713
- const undo = useCallback(() => {
714
- editor?.dispatchCommand(UNDO_COMMAND, void 0);
715
- }, [editor]);
716
- const redo = useCallback(() => {
717
- editor?.dispatchCommand(REDO_COMMAND, void 0);
718
- }, [editor]);
719
- const formatText = useCallback((type) => {
720
- editor?.dispatchCommand(FORMAT_TEXT_COMMAND, type);
721
- }, [editor]);
722
- const bold = useCallback(() => {
723
- formatText("bold");
724
- }, [formatText]);
725
- const underline = useCallback(() => {
726
- formatText("underline");
727
- }, [formatText]);
728
- const strikethrough = useCallback(() => {
729
- formatText("strikethrough");
730
- }, [formatText]);
731
- const italic = useCallback(() => {
732
- formatText("italic");
733
- }, [formatText]);
734
- const subscript = useCallback(() => {
735
- formatText("subscript");
736
- }, [formatText]);
737
- const superscript = useCallback(() => {
738
- formatText("superscript");
739
- }, [formatText]);
740
- const code = useCallback(() => {
741
- editor?.dispatchCommand(INSERT_CODEINLINE_COMMAND, void 0);
742
- }, [formatText]);
743
- const bulletList = useCallback(() => {
744
- if (blockType !== "bullet") editor?.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
745
- else formatParagraph(editor?.getLexicalEditor());
746
- }, [blockType, editor]);
747
- const numberList = useCallback(() => {
748
- if (blockType !== "number") editor?.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
749
- else formatParagraph(editor?.getLexicalEditor());
750
- }, [blockType, editor]);
751
- const checkList = useCallback(() => {
752
- if (blockType !== "check") editor?.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0);
753
- else formatParagraph(editor?.getLexicalEditor());
754
- }, [blockType, editor]);
755
- const codeblock = useCallback(() => {
756
- if (blockType !== "code") editor?.getLexicalEditor()?.update(() => {
757
- let selection = $getSelection();
758
- if (!selection) return;
759
- const lexicalEditor = editor?.getLexicalEditor();
760
- if (lexicalEditor ? lexicalEditor._nodes.has("code") && lexicalEditor._nodes.get("code")?.klass.name === "CodeMirrorNode" : false) if (!$isRangeSelection(selection) || selection.isCollapsed()) {
761
- const codeMirrorNode = $createCodeMirrorNode("plain", selection.getTextContent());
762
- const nodeSelection = $createNodeSelection();
763
- nodeSelection.add(codeMirrorNode.getKey());
764
- selection.insertNodes([codeMirrorNode]);
765
- $setSelection(nodeSelection);
766
- } else {
767
- const codeMirrorNode = $createCodeMirrorNode("plain", selection.getTextContent());
768
- selection.insertNodes([codeMirrorNode]);
769
- const nodeSelection = $createNodeSelection();
770
- nodeSelection.add(codeMirrorNode.getKey());
771
- $setSelection(nodeSelection);
772
- }
773
- else if (!$isRangeSelection(selection) || selection.isCollapsed()) $setBlocksType(selection, () => $createCodeNode());
774
- else {
775
- const textContent = selection.getTextContent();
776
- const codeNode = $createCodeNode();
777
- selection.insertNodes([codeNode]);
778
- selection = $getSelection();
779
- if ($isRangeSelection(selection)) selection.insertRawText(textContent);
780
- }
781
- });
782
- else formatParagraph(editor?.getLexicalEditor());
783
- }, [blockType, editor]);
784
- const blockquote = useCallback(() => {
785
- if (blockType !== "quote") editor?.getLexicalEditor()?.update(() => {
786
- const selection = $getSelection();
787
- if ($isRangeSelection(selection)) $setBlocksType(selection, () => $createQuoteNode());
788
- });
789
- else formatParagraph(editor?.getLexicalEditor());
790
- }, [blockType, editor]);
791
- const updateCodeblockLang = useCallback((lang) => {
792
- if (!isCodeblock) return;
793
- editor?.dispatchCommand(UPDATE_CODEBLOCK_LANG, { lang });
794
- }, [editor, isCodeblock]);
795
- const insertLink = useCallback(() => {
796
- const lexical = editor?.getLexicalEditor();
797
- if (!lexical) return;
798
- let inLinkNode = false;
799
- let inLinkHighlightNode = false;
800
- lexical.getEditorState().read(() => {
801
- const selection = $getSelection();
802
- if ($isRangeSelection(selection)) {
803
- const node = getSelectedNode(selection);
804
- const parent = node.getParent();
805
- if ($isLinkNode(parent) || $isLinkNode(node)) inLinkNode = true;
806
- if ($isLinkHighlightNode(parent) || $isLinkHighlightNode(node)) inLinkHighlightNode = true;
807
- }
808
- });
809
- if (inLinkHighlightNode) {
810
- lexical.dispatchCommand(INSERT_LINK_HIGHLIGHT_COMMAND, void 0);
811
- setIsLink(false);
812
- return;
813
- }
814
- if (inLinkNode) {
815
- setIsLink(false);
816
- lexical.dispatchCommand(TOGGLE_LINK_COMMAND, null);
817
- return;
818
- }
819
- if (!isLink) {
820
- if (lexical.dispatchCommand(INSERT_LINK_HIGHLIGHT_COMMAND, void 0)) {
821
- setIsLink(true);
822
- return;
823
- }
824
- let nextUrl = sanitizeUrl("https://");
825
- let expandTo = null;
826
- lexical.getEditorState().read(() => {
827
- const selection = $getSelection();
828
- if ($isRangeSelection(selection)) {
829
- const text = selection.getTextContent();
830
- if (!selection.isCollapsed()) {
831
- const maybeUrl = formatUrl(text.trim());
832
- if (validateUrl(maybeUrl)) nextUrl = maybeUrl;
833
- } else {
834
- const found = extractUrlFromText(selection.anchor.getNode().getTextContent());
835
- if (found && validateUrl(formatUrl(found.url))) expandTo = {
836
- index: found.index,
837
- length: found.length
838
- };
839
- }
840
- }
841
- });
842
- setIsLink(true);
843
- lexical.update(() => {
844
- if (expandTo) {
845
- const selection = $getSelection();
846
- if ($isRangeSelection(selection)) {
847
- const anchorNode = selection.anchor.getNode();
848
- selection.anchor.set(anchorNode.getKey(), expandTo.index, "text");
849
- selection.focus.set(anchorNode.getKey(), expandTo.index + expandTo.length, "text");
850
- }
851
- }
852
- lexical.dispatchCommand(TOGGLE_LINK_COMMAND, validateUrl(nextUrl) ? nextUrl : sanitizeUrl("https://"));
853
- });
854
- }
855
- }, [editor, isLink]);
856
- const insertMath = useCallback(() => {
857
- editor?.getLexicalEditor()?.update(() => {
858
- const selection = $getSelection();
859
- if ($isRangeSelection(selection)) {
860
- const element = $findTopLevelElement(selection.anchor.getNode());
861
- const mathNode = $isParagraphNode(element) && selection.isCollapsed() && selection.anchor.offset === 0 && element.getTextContentSize() === 0 || !selection.isCollapsed() && selection.anchor.offset === 0 && selection.focus.offset === element.getTextContentSize() ? $createMathBlockNode("") : $createMathInlineNode("");
862
- selection.insertNodes([mathNode]);
863
- const nodeSelection = $createNodeSelection();
864
- nodeSelection.add(mathNode.getKey());
865
- $setSelection(nodeSelection);
866
- }
867
- });
868
- }, [editor]);
869
- useEffect(() => {
870
- if (!editor) return;
871
- const lexicalEditor = editor.getLexicalEditor();
872
- let cleanup = noop;
873
- const debounceUpdate = debounce(() => {
874
- lexicalEditor?.read(() => {
875
- $updateToolbar();
876
- });
877
- }, 500);
878
- const handleLexicalEditor = (lexicalEditor) => {
879
- cleanup = mergeRegister(lexicalEditor.registerUpdateListener(debounce(({ editorState }) => {
880
- editorState.read(() => {
881
- $updateToolbar();
882
- });
883
- }, 500)), lexicalEditor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
884
- if (lexicalEditor.isComposing()) return false;
885
- debounceUpdate();
886
- return false;
887
- }, COMMAND_PRIORITY_LOW), lexicalEditor.registerCommand(CAN_UNDO_COMMAND, (payload) => {
888
- setCanUndo(payload);
889
- return false;
890
- }, COMMAND_PRIORITY_LOW), lexicalEditor.registerCommand(CAN_REDO_COMMAND, (payload) => {
891
- setCanRedo(payload);
892
- return false;
893
- }, COMMAND_PRIORITY_LOW));
894
- return cleanup;
895
- };
896
- if (!lexicalEditor) {
897
- editor.on("initialized", handleLexicalEditor);
898
- return () => {
899
- cleanup();
900
- editor.off("initialized", handleLexicalEditor);
901
- };
902
- }
903
- return handleLexicalEditor(lexicalEditor);
904
- }, [editor, $updateToolbar]);
905
- return useMemo(() => ({
906
- blockType,
907
- blockquote,
908
- bold,
909
- bulletList,
910
- canRedo,
911
- canUndo,
912
- checkList,
913
- code,
914
- codeblock,
915
- codeblockLang,
916
- editable,
917
- insertLink,
918
- insertMath,
919
- isBlockquote,
920
- isBold,
921
- isCode,
922
- isCodeblock,
923
- isEmpty,
924
- isItalic,
925
- isSelected,
926
- isStrikethrough,
927
- isSubscript,
928
- isSuperscript,
929
- isUnderline,
930
- italic,
931
- numberList,
932
- redo,
933
- strikethrough,
934
- subscript,
935
- superscript,
936
- underline,
937
- undo,
938
- updateCodeblockLang
939
- }), [
940
- blockType,
941
- canRedo,
942
- canUndo,
943
- codeblockLang,
944
- isBold,
945
- isCode,
946
- isEmpty,
947
- isBlockquote,
948
- isCodeblock,
949
- isItalic,
950
- isSelected,
951
- isStrikethrough,
952
- isUnderline,
953
- isSubscript,
954
- isSuperscript,
955
- italic
956
- ]);
957
- }
958
- //#endregion
959
- //#region src/react/EditorProvider/index.tsx
960
- const EditorContext = createContext({ config: {} });
961
- const EditorProvider = ({ children, config = {} }) => {
962
- const value = useMemo(() => ({ config }), [config]);
963
- return /* @__PURE__ */ jsx(EditorContext.Provider, {
964
- value,
965
- children
966
- });
967
- };
968
- const useEditorContent = () => {
969
- return use(EditorContext);
970
- };
971
- EditorProvider.displayName = "EditorProvider";
972
- //#endregion
973
- //#region src/react/Editor/Editor.tsx
974
- const Editor$1 = memo(({ content, style, className, debounceWait = 100, editable, editor, onInit, onChange, placeholder, lineEmptyPlaceholder, plugins = [], slashOption = {}, slashPlacement, getPopupContainer, mentionOption = {}, variant, onKeyDown, children, type = "json", onPressEnter, onFocus, onBlur, autoFocus, enablePasteMarkdown = true, autoFormatMarkdown = true, markdownOption = true, pasteMarkdownAutoConvertThreshold, pasteAsPlainText = false, pasteVSCodeAsCodeBlock = true, onCompositionStart, onCompositionEnd, onContextMenu, onTextChange }) => {
975
- const { config } = useEditorContent();
976
- const enableSlash = Boolean(slashOption?.items && slashOption.items.length > 0);
977
- const enableMention = Boolean(mentionOption?.items && mentionOption.items.length > 0);
978
- const { markdownWriter, ...restMentionOption } = mentionOption;
979
- const debouncedOnChange = useMemo(() => onChange ? debounce(onChange, debounceWait) : void 0, [onChange, debounceWait]);
980
- const debouncedOnTextChange = useMemo(() => onTextChange ? debounce(onTextChange, debounceWait) : void 0, [onTextChange, debounceWait]);
981
- const memoPlugins = useMemo(() => [enablePasteMarkdown && autoFormatMarkdown && ReactMarkdownPlugin, ...plugins].filter(Boolean).map((plugin, index) => {
982
- if (typeof plugin === "function") return createElement(plugin, { key: index });
983
- return createElement(plugin[0], {
984
- key: index,
985
- ...plugin[1]
986
- });
987
- }), [
988
- plugins,
989
- enablePasteMarkdown,
990
- autoFormatMarkdown,
991
- ReactMarkdownPlugin
992
- ]);
993
- const memoMention = useMemo(() => {
994
- if (!enableMention) return;
995
- return /* @__PURE__ */ jsx(ReactMentionPlugin, {
996
- className,
997
- markdownWriter
998
- });
999
- }, [
1000
- enableMention,
1001
- markdownWriter,
1002
- className
1003
- ]);
1004
- return /* @__PURE__ */ jsxs(ReactEditor, {
1005
- config,
1006
- editor,
1007
- onInit,
1008
- children: [
1009
- memoPlugins,
1010
- useMemo(() => {
1011
- if (!enableSlash && !enableMention) return null;
1012
- return /* @__PURE__ */ jsxs(ReactSlashPlugin, {
1013
- getPopupContainer,
1014
- placement: slashPlacement,
1015
- children: [enableSlash ? /* @__PURE__ */ jsx(ReactSlashOption, {
1016
- maxLength: 8,
1017
- trigger: "/",
1018
- ...slashOption
1019
- }) : void 0, enableMention ? /* @__PURE__ */ jsx(ReactSlashOption, {
1020
- maxLength: 8,
1021
- trigger: "@",
1022
- ...restMentionOption
1023
- }) : void 0]
1024
- });
1025
- }, [
1026
- enableSlash,
1027
- enableMention,
1028
- slashOption,
1029
- slashPlacement,
1030
- getPopupContainer,
1031
- restMentionOption
1032
- ]),
1033
- memoMention,
1034
- /* @__PURE__ */ jsx(ReactPlainText, {
1035
- autoFocus,
1036
- autoFormatMarkdown,
1037
- className,
1038
- editable,
1039
- enablePasteMarkdown,
1040
- markdownOption,
1041
- onBlur,
1042
- onChange: debouncedOnChange,
1043
- onCompositionEnd,
1044
- onCompositionStart,
1045
- onContextMenu,
1046
- onFocus,
1047
- onKeyDown,
1048
- onPressEnter,
1049
- onTextChange: debouncedOnTextChange,
1050
- pasteAsPlainText,
1051
- pasteMarkdownAutoConvertThreshold,
1052
- pasteVSCodeAsCodeBlock,
1053
- style,
1054
- variant,
1055
- children: /* @__PURE__ */ jsx(ReactEditorContent, {
1056
- content,
1057
- lineEmptyPlaceholder,
1058
- placeholder,
1059
- type
1060
- })
1061
- }),
1062
- children
1063
- ]
1064
- });
1065
- });
1066
- Editor$1.displayName = "Editor";
1067
- //#endregion
1068
- //#region src/react/Editor/utils.ts
1069
- function withProps(plugin, props) {
1070
- return [plugin, props];
1071
- }
1072
- //#endregion
1073
- //#region src/react/Editor/index.ts
1074
- const Editor = Editor$1;
1075
- Editor.useEditor = useEditor;
1076
- Editor.useEditorState = useEditorState;
1077
- Editor.withProps = withProps;
1078
- //#endregion
1079
- //#region src/react/FloatActions/style.ts
1080
- const styles$4 = createStaticStyles(({ css }) => ({
1081
- collapsedContainer: css`
1082
- overflow: hidden;
1083
- display: flex;
1084
- align-items: center;
1085
- `,
1086
- container: css`
1087
- position: relative;
1088
- width: 100%;
1089
- `,
1090
- divider: css`
1091
- height: 20px;
1092
- margin-inline: 4px;
1093
- `
1094
- }));
1095
- //#endregion
1096
- //#region src/react/FloatActions/components/ActionRender.tsx
1097
- const ActionRender = ({ item, onActionClick, disabled }) => {
1098
- if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
1099
- className: styles$4.divider,
1100
- orientation: "vertical"
1101
- });
1102
- const { wrapper, icon, key, label, onClick, danger, loading, active, tooltipProps, ...itemRest } = item;
1103
- if (item.children && isValidElement(item.children)) {
1104
- if (!wrapper) return item.children;
1105
- return wrapper(item.children);
1106
- }
1107
- const action = /* @__PURE__ */ jsx(ActionIcon, {
1108
- active,
1109
- danger,
1110
- disabled: disabled || loading || itemRest?.disabled,
1111
- icon,
1112
- loading,
1113
- onClick: (e) => {
1114
- onActionClick?.({
1115
- domEvent: e,
1116
- key: String(key),
1117
- keyPath: [String(key)]
1118
- });
1119
- onClick?.(e);
1120
- },
1121
- size: {
1122
- blockSize: 36,
1123
- size: 20
1124
- },
1125
- title: label,
1126
- tooltipProps: {
1127
- placement: "top",
1128
- ...tooltipProps
1129
- }
1130
- });
1131
- if (!wrapper) return action;
1132
- return wrapper(action);
1133
- };
1134
- //#endregion
1135
- //#region src/react/FloatActions/components/CollapsedActions.tsx
1136
- const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
1137
- const Motion = useMotionComponent();
1138
- if (mode === "popup") return /* @__PURE__ */ jsx(Popover, {
1139
- arrow: false,
1140
- content: /* @__PURE__ */ jsx(Flexbox, {
1141
- align: "center",
1142
- gap,
1143
- horizontal: true,
1144
- children
1145
- }),
1146
- styles: { content: { padding: 4 } },
1147
- children: /* @__PURE__ */ jsx(ActionIcon, {
1148
- icon: CircleChevronUpIcon,
1149
- size: {
1150
- blockSize: 36,
1151
- size: 20
1152
- }
1153
- })
1154
- });
1155
- return /* @__PURE__ */ jsxs(Flexbox, {
1156
- align: "center",
1157
- flex: "none",
1158
- gap,
1159
- horizontal: true,
1160
- children: [/* @__PURE__ */ jsx(Motion.div, {
1161
- animate: groupCollapse ? "closed" : "open",
1162
- className: styles$4.collapsedContainer,
1163
- initial: groupCollapse ? "closed" : "open",
1164
- style: { gap },
1165
- transition: { duration: .2 },
1166
- variants: {
1167
- closed: {
1168
- opacity: 0,
1169
- width: 0
1170
- },
1171
- open: {
1172
- opacity: 1,
1173
- width: "auto"
1174
- }
1175
- },
1176
- children
1177
- }), /* @__PURE__ */ jsx(ActionIcon, {
1178
- icon: groupCollapse ? CircleChevronRightIcon : CircleChevronLeftIcon,
1179
- onClick: () => onGroupCollapseChange?.(!groupCollapse),
1180
- size: {
1181
- blockSize: 36,
1182
- size: 20
1183
- }
1184
- })]
1185
- });
1186
- };
1187
- CollapsedActions.displayName = "FloatActionsCollapse";
1188
- //#endregion
1189
- //#region src/react/FloatActions/components/ActionItem.tsx
1190
- const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, gap, setGroupCollapsed }) => {
1191
- if (item.type === "collapse") return /* @__PURE__ */ jsx(CollapsedActions, {
1192
- gap,
1193
- groupCollapse: groupCollapsed,
1194
- mode: "default",
1195
- onGroupCollapseChange: setGroupCollapsed,
1196
- children: item.children.map((child, childIndex) => /* @__PURE__ */ jsx(ActionRender, {
1197
- disabled,
1198
- item: child,
1199
- onActionClick
1200
- }, child?.key || `action-${childIndex}`))
1201
- });
1202
- if (item.type === "dropdown") return /* @__PURE__ */ jsx(Dropdown, {
1203
- menu: { items: item.children },
1204
- children: /* @__PURE__ */ jsx(ActionIcon, {
1205
- active: item.active,
1206
- danger: item.danger,
1207
- disabled: disabled || item.loading || item?.disabled,
1208
- icon: item.icon,
1209
- loading: item.loading,
1210
- size: {
1211
- blockSize: 36,
1212
- size: 20
1213
- },
1214
- title: item.label,
1215
- tooltipProps: {
1216
- placement: "top",
1217
- ...item.tooltipProps
1218
- }
1219
- })
1220
- }, item.key);
1221
- return /* @__PURE__ */ jsx(ActionRender, {
1222
- disabled,
1223
- item,
1224
- onActionClick
1225
- });
1226
- };
1227
- ActionItem.displayName = "FloatActionsItem";
1228
- //#endregion
1229
- //#region src/react/FloatActions/FloatActions.tsx
1230
- const FloatActions = ({ gap = 2, disabled, items = [], onActionClick, className, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
1231
- const [groupCollapsed, setGroupCollapsed] = useMergeState(defaultGroupCollapse, {
1232
- defaultValue: defaultGroupCollapse,
1233
- onChange: onGroupCollapseChange,
1234
- value: groupCollapse
1235
- });
1236
- return /* @__PURE__ */ jsx(Flexbox, {
1237
- align: "center",
1238
- className: cx(styles$4.container, className),
1239
- flex: 1,
1240
- gap,
1241
- horizontal: true,
1242
- ...rest,
1243
- children: items.map((item, index) => /* @__PURE__ */ jsx(ActionItem, {
1244
- disabled,
1245
- gap,
1246
- groupCollapsed,
1247
- item,
1248
- onActionClick,
1249
- setGroupCollapsed
1250
- }, item.key || index))
1251
- });
1252
- };
1253
- FloatActions.displayName = "FloatActions";
1254
- //#endregion
1255
- //#region src/react/FloatMenu/style.ts
1256
- const styles$3 = createStaticStyles(({ css, cssVar }) => ({
1257
- container: css`
1258
- position: relative;
1259
- overflow: hidden auto;
1260
- background: ${cssVar.colorBgElevated};
1261
- `,
1262
- containerWithMaxHeight: css`
1263
- /* maxHeight is set via inline style as it's dynamic */
1264
- `,
1265
- rootBottom: css`
1266
- position: absolute;
1267
- z-index: 9999;
1268
- inset-block-start: 100%;
1269
- inset-inline-start: 0;
1270
-
1271
- padding-block-start: 8px;
1272
- `,
1273
- rootTop: css`
1274
- position: absolute;
1275
- inset-block-start: -8px;
1276
- inset-inline-start: 0;
1277
- transform: translateY(-100%);
1278
- `
1279
- }));
1280
- //#endregion
1281
- //#region src/react/FloatMenu/FloatMenu.tsx
1282
- const FloatMenu = ({ className, style, getPopupContainer, children, maxHeight = "min(50vh, 640px)", open, placement = "top", styles: customStyles, classNames }) => {
1283
- const parent = getPopupContainer();
1284
- if (!parent) return;
1285
- if (!open) return;
1286
- return createPortal(/* @__PURE__ */ jsx(Flexbox, {
1287
- className: cx(placement === "bottom" ? styles$3.rootBottom : styles$3.rootTop, classNames?.root),
1288
- paddingInline: 8,
1289
- style: customStyles?.root,
1290
- width: "100%",
1291
- children: /* @__PURE__ */ jsx(Block, {
1292
- className: cx(styles$3.container, className, classNames?.container),
1293
- shadow: true,
1294
- style: {
1295
- maxHeight,
1296
- ...style,
1297
- ...customStyles?.container
1298
- },
1299
- variant: "outlined",
1300
- children
1301
- })
1302
- }), parent);
1303
- };
1304
- FloatMenu.displayName = "FloatMenu";
1305
- //#endregion
1306
- //#region src/react/SendButton/components/SendIcon.tsx
1307
- const styles$2 = createStaticStyles(({ css }) => ({ icon: css`
1308
- flex: none;
1309
- line-height: 1;
1310
- ` }));
1311
- const SendIcon = ({ size = "1em", style }) => {
1312
- return /* @__PURE__ */ jsx("svg", {
1313
- className: cx("anticon", styles$2.icon),
1314
- fill: "currentColor",
1315
- fillRule: "evenodd",
1316
- height: size,
1317
- style,
1318
- viewBox: "0 0 14 14",
1319
- width: size,
1320
- xmlns: "http://www.w3.org/2000/svg",
1321
- children: /* @__PURE__ */ jsx("path", { d: "M.743 3.773c-.818-.555-.422-1.834.567-1.828l11.496.074a1 1 0 01.837 1.538l-6.189 9.689c-.532.833-1.822.47-1.842-.518L5.525 8.51a1 1 0 01.522-.9l1.263-.686a.808.808 0 00-.772-1.42l-1.263.686a1 1 0 01-1.039-.051L.743 3.773z" })
1322
- });
1323
- };
1324
- //#endregion
1325
- //#region src/react/SendButton/components/StopIcon.tsx
1326
- const styles$1 = createStaticStyles(({ css }) => ({ icon: css`
1327
- flex: none;
1328
- line-height: 1;
1329
- ` }));
1330
- const StopIcon = ({ size = "1.5em", style }) => {
1331
- return /* @__PURE__ */ jsx("svg", {
1332
- className: cx("anticon", styles$1.icon),
1333
- color: "currentColor",
1334
- height: size,
1335
- style,
1336
- viewBox: "0 0 1024 1024",
1337
- width: size,
1338
- xmlns: "http://www.w3.org/2000/svg",
1339
- children: /* @__PURE__ */ jsxs("g", {
1340
- fill: "none",
1341
- children: [
1342
- /* @__PURE__ */ jsx("circle", {
1343
- cx: "512",
1344
- cy: "512",
1345
- fill: "none",
1346
- r: "426",
1347
- stroke: cssVar.colorBorder,
1348
- strokeWidth: "72"
1349
- }),
1350
- /* @__PURE__ */ jsx("rect", {
1351
- fill: "currentColor",
1352
- height: "252",
1353
- rx: "24",
1354
- ry: "24",
1355
- width: "252",
1356
- x: "386",
1357
- y: "386"
1358
- }),
1359
- /* @__PURE__ */ jsx("path", {
1360
- d: "M938.667 512C938.667 276.359 747.64 85.333 512 85.333",
1361
- stroke: "currentColor",
1362
- strokeLinecap: "round",
1363
- strokeWidth: "73",
1364
- children: /* @__PURE__ */ jsx("animateTransform", {
1365
- attributeName: "transform",
1366
- dur: "1s",
1367
- from: "0 512 512",
1368
- repeatCount: "indefinite",
1369
- to: "360 512 512",
1370
- type: "rotate"
1371
- })
1372
- })
1373
- ]
1374
- })
1375
- });
1376
- };
1377
- //#endregion
1378
- //#region src/react/SendButton/style.ts
1379
- const prefixCls = "ant";
1380
- const styles = createStaticStyles(({ css, cssVar }) => ({
1381
- button: css`
1382
- &.${prefixCls}-btn {
1383
- flex: none;
1384
- width: var(--send-button-size, 32px) !important;
1385
- height: var(--send-button-size, 32px);
1386
- padding-inline: 0 !important;
1387
- }
1388
- `,
1389
- disabled: css`
1390
- &.${prefixCls}-btn {
1391
- cursor: default;
1392
- border-color: ${cssVar.colorBorderSecondary};
1393
- background: transparent;
1394
- }
1395
-
1396
- .${prefixCls}-btn-compact-first-item {
1397
- cursor: default;
1398
- border-color: ${cssVar.colorBorderSecondary};
1399
- background: transparent;
1400
- }
1401
- .${prefixCls}-dropdown-trigger {
1402
- cursor: default;
1403
- border-color: ${cssVar.colorBorderSecondary};
1404
- border-inline-start-color: transparent;
1405
- background: transparent;
1406
- }
1407
- `,
1408
- dropdownButton: css`
1409
- flex: none;
1410
- width: fit-content;
1411
- .${prefixCls}-btn {
1412
- width: calc(var(--send-button-size, 32px) * 1.2);
1413
- height: var(--send-button-size, 32px);
1414
- }
1415
- .${prefixCls}-dropdown-trigger {
1416
- width: calc(var(--send-button-size, 32px) * 0.8);
1417
- &.${prefixCls}-btn-primary {
1418
- &::before {
1419
- background-color: color-mix(in srgb, ${cssVar.colorBgLayout} 10%, transparent) !important;
1420
- }
1421
- }
1422
- }
1423
- `,
1424
- dropdownButtonRound: css`
1425
- .${prefixCls}-btn-compact-first-item {
1426
- border-start-start-radius: calc(var(--send-button-size, 32px) / 2);
1427
- border-end-start-radius: calc(var(--send-button-size, 32px) / 2);
1428
- }
1429
- .${prefixCls}-dropdown-trigger {
1430
- width: var(--send-button-size, 32px);
1431
- border-start-end-radius: calc(var(--send-button-size, 32px) / 2);
1432
- border-end-end-radius: calc(var(--send-button-size, 32px) / 2);
1433
- }
1434
- `,
1435
- loadingButton: css`
1436
- &.${prefixCls}-btn {
1437
- flex: none;
1438
- height: var(--send-button-size, 32px);
1439
- padding-inline: 0 !important;
1440
- }
1441
- `
1442
- }));
1443
- //#endregion
1444
- //#region src/react/SendButton/SendButton.tsx
1445
- const SendButton = ({ type = "primary", menu, className, style, loading, generating, size = 32, shape, onSend, onStop, disabled, onClick, styles: _styles, classNames: _classNames, ...rest }) => {
1446
- const cssVariables = useMemo(() => ({ "--send-button-size": `${size}px` }), [size]);
1447
- if (generating) return /* @__PURE__ */ jsx(Button, {
1448
- className: cx(styles.loadingButton, className),
1449
- onClick: (e) => {
1450
- e.stopPropagation();
1451
- e.preventDefault();
1452
- if (onStop) onStop(e);
1453
- if (onClick) onClick(e);
1454
- },
1455
- shape,
1456
- style: {
1457
- ...cssVariables,
1458
- ...style,
1459
- width: menu ? size * 2 : size
1460
- },
1461
- variant: "filled",
1462
- ...rest,
1463
- children: /* @__PURE__ */ jsx(StopIcon, { size: size * .75 })
1464
- });
1465
- if (loading) return /* @__PURE__ */ jsx(Button, {
1466
- className: cx(styles.loadingButton, className),
1467
- disabled: true,
1468
- loading,
1469
- shape,
1470
- style: {
1471
- ...cssVariables,
1472
- ...style,
1473
- width: menu ? size * 2 : size
1474
- },
1475
- type,
1476
- ...rest
1477
- });
1478
- if (!menu) return /* @__PURE__ */ jsx(Button, {
1479
- className: cx(styles.button, disabled && styles.disabled, className),
1480
- disabled,
1481
- icon: /* @__PURE__ */ jsx(SendIcon, {}),
1482
- onClick: (e) => {
1483
- e.stopPropagation();
1484
- e.preventDefault();
1485
- if (onSend) onSend(e);
1486
- if (onClick) onClick(e);
1487
- },
1488
- shape,
1489
- style: {
1490
- ...cssVariables,
1491
- ...style
1492
- },
1493
- type,
1494
- ...rest
1495
- });
1496
- return /* @__PURE__ */ jsxs(Space.Compact, {
1497
- className: cx(styles.dropdownButton, disabled && styles.disabled, shape === "round" && styles.dropdownButtonRound, className),
1498
- style: {
1499
- ...cssVariables,
1500
- ...style
1501
- },
1502
- ...rest,
1503
- children: [/* @__PURE__ */ jsx(Button, {
1504
- className: cx(styles.button, disabled && styles.disabled, className),
1505
- disabled,
1506
- icon: /* @__PURE__ */ jsx(SendIcon, {}),
1507
- onClick: (e) => {
1508
- e.stopPropagation();
1509
- e.preventDefault();
1510
- if (onSend) onSend(e);
1511
- if (onClick) onClick(e);
1512
- },
1513
- shape,
1514
- style: {
1515
- ...cssVariables,
1516
- ...style
1517
- },
1518
- type,
1519
- ...rest
1520
- }), /* @__PURE__ */ jsx(Dropdown$1, {
1521
- menu,
1522
- placement: "topRight",
1523
- ...rest,
1524
- children: /* @__PURE__ */ jsx(Button, {
1525
- className: cx(styles.button, disabled && styles.disabled, className),
1526
- disabled,
1527
- icon: /* @__PURE__ */ jsx(Icon, { icon: ChevronDownIcon }),
1528
- shape,
1529
- style: {
1530
- ...cssVariables,
1531
- cursor: "pointer"
1532
- },
1533
- type
1534
- })
1535
- })]
1536
- });
1537
- };
1538
- SendButton.displayName = "SendButton";
1539
- //#endregion
1540
- //#region src/react/SlashMenu/SlashMenu.tsx
1541
- const SlashMenu = ({ options, activeKey, loading, onSelect, classNames, styles: customStyles, menuProps, ...floatMenuProps }) => {
1542
- const handleMenuClick = useCallback(({ key }) => {
1543
- if (!onSelect) return;
1544
- const option = options.find((item) => "key" in item && item.key === key);
1545
- if (option) onSelect?.(option);
1546
- }, [options, onSelect]);
1547
- return /* @__PURE__ */ jsx(FloatMenu, {
1548
- classNames: {
1549
- container: classNames?.container,
1550
- root: classNames?.root
1551
- },
1552
- styles: {
1553
- container: customStyles?.container,
1554
- root: customStyles?.root
1555
- },
1556
- ...floatMenuProps,
1557
- children: /* @__PURE__ */ jsx(Menu, {
1558
- className: classNames?.menu,
1559
- items: loading ? [{
1560
- disabled: true,
1561
- key: "loading",
1562
- label: "Loading..."
1563
- }] : options,
1564
- mode: "inline",
1565
- onClick: handleMenuClick,
1566
- selectedKeys: activeKey ? [activeKey] : void 0,
1567
- style: customStyles?.menu,
1568
- ...menuProps
1569
- })
1570
- });
1571
- };
1572
- SlashMenu.displayName = "SlashMenu";
1573
- //#endregion
1
+ import ChatInput from "./react/ChatInput/ChatInput.js";
2
+ import ChatInputActionBar from "./react/ChatInputActionBar/ChatInputActionBar.js";
3
+ import ChatInputActions from "./react/ChatInputActions/ChatInputActions.js";
4
+ import CodeLanguageSelect from "./react/CodeLanguageSelect/CodeLanguageSelect.js";
5
+ import { useEditor } from "./react/hooks/useEditor.js";
6
+ import { useEditorState } from "./react/hooks/useEditorState/index.js";
7
+ import { EditorProvider, useEditorContent } from "./react/EditorProvider/index.js";
8
+ import { withProps } from "./react/Editor/utils.js";
9
+ import Editor from "./react/Editor/index.js";
10
+ import FloatActions from "./react/FloatActions/FloatActions.js";
11
+ import FloatMenu from "./react/FloatMenu/FloatMenu.js";
12
+ import SendButton from "./react/SendButton/SendButton.js";
13
+ import SlashMenu from "./react/SlashMenu/SlashMenu.js";
1574
14
  export { ChatInput, ChatInputActionBar, ChatInputActions, CodeLanguageSelect, Editor, EditorProvider, FloatActions, FloatMenu, SendButton, SlashMenu, useEditor, useEditorContent, useEditorState, withProps };