@ant-design/agentic-ui 2.8.0 → 2.9.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 (581) hide show
  1. package/dist/AgentRunBar/Robot.js +105 -57
  2. package/dist/AgentRunBar/icons/PauseIcon.js +38 -38
  3. package/dist/AgentRunBar/icons/PlayIcon.js +38 -38
  4. package/dist/AgentRunBar/icons/SimplePauseIcon.js +38 -38
  5. package/dist/AgentRunBar/icons/SimplePlayIcon.js +38 -38
  6. package/dist/AgentRunBar/icons/SimpleStopIcon.js +38 -38
  7. package/dist/AgentRunBar/icons/StopIcon.js +41 -50
  8. package/dist/AgentRunBar/icons/index.js +0 -1
  9. package/dist/AgentRunBar/index.js +270 -237
  10. package/dist/AgentRunBar/style.js +273 -239
  11. package/dist/AgenticLayout/index.js +140 -85
  12. package/dist/AgenticLayout/style.js +126 -107
  13. package/dist/AnswerAlert/components/CloseIcon.js +12 -21
  14. package/dist/AnswerAlert/components/ErrorIcon.js +42 -38
  15. package/dist/AnswerAlert/components/InfoIcon.js +42 -38
  16. package/dist/AnswerAlert/components/LoaderIcon.js +12 -21
  17. package/dist/AnswerAlert/components/SuccessIcon.js +42 -38
  18. package/dist/AnswerAlert/components/WarningIcon.js +42 -38
  19. package/dist/AnswerAlert/index.js +155 -75
  20. package/dist/AnswerAlert/style.js +159 -147
  21. package/dist/BackTo/BackBottom.js +154 -70
  22. package/dist/BackTo/BackTop.js +148 -68
  23. package/dist/BackTo/ScrollVisibleButton.js +124 -98
  24. package/dist/BackTo/hooks/useScrollVisible.js +79 -33
  25. package/dist/BackTo/icons/BottomIcon.js +37 -37
  26. package/dist/BackTo/icons/TopIcon.js +37 -37
  27. package/dist/BackTo/index.js +22 -7
  28. package/dist/BackTo/style.js +93 -70
  29. package/dist/Bubble/AIBubble.js +469 -406
  30. package/dist/Bubble/Avatar/index.js +139 -85
  31. package/dist/Bubble/Avatar/isEmoji.js +2 -6
  32. package/dist/Bubble/Bubble.js +114 -38
  33. package/dist/Bubble/BubbleBeforeNode.js +104 -74
  34. package/dist/Bubble/BubbleConfigProvide.js +3 -7
  35. package/dist/Bubble/FileView.js +63 -69
  36. package/dist/Bubble/List/PureBubbleList.js +130 -131
  37. package/dist/Bubble/List/SkeletonList.js +33 -24
  38. package/dist/Bubble/List/index.js +187 -124
  39. package/dist/Bubble/List/style.js +76 -47
  40. package/dist/Bubble/MessagesContent/BubbleContext.js +6 -12
  41. package/dist/Bubble/MessagesContent/BubbleExtra.js +663 -355
  42. package/dist/Bubble/MessagesContent/CopyButton/index.js +326 -96
  43. package/dist/Bubble/MessagesContent/DocInfo.js +351 -386
  44. package/dist/Bubble/MessagesContent/EXCEPTION.js +42 -22
  45. package/dist/Bubble/MessagesContent/MarkdownPreview.js +206 -156
  46. package/dist/Bubble/MessagesContent/VoiceButton/index.js +213 -115
  47. package/dist/Bubble/MessagesContent/VoiceButton/style.js +129 -105
  48. package/dist/Bubble/MessagesContent/VoiceButton/types.js +9 -0
  49. package/dist/Bubble/MessagesContent/docInfoStyle.js +118 -88
  50. package/dist/Bubble/MessagesContent/icons.js +157 -57
  51. package/dist/Bubble/MessagesContent/index.js +609 -368
  52. package/dist/Bubble/PureBubble.js +439 -326
  53. package/dist/Bubble/Title.js +110 -87
  54. package/dist/Bubble/UserBubble.js +218 -279
  55. package/dist/Bubble/index.js +10 -16
  56. package/dist/Bubble/style.js +248 -227
  57. package/dist/Bubble/type.js +3 -0
  58. package/dist/Bubble/types/BubbleExtra.js +1 -0
  59. package/dist/Bubble/types/DocInfo.js +1 -0
  60. package/dist/ChatBootPage/ButtonTab.js +25 -45
  61. package/dist/ChatBootPage/ButtonTabGroup.js +74 -47
  62. package/dist/ChatBootPage/ButtonTabGroupStyle.js +73 -45
  63. package/dist/ChatBootPage/ButtonTabStyle.js +121 -98
  64. package/dist/ChatBootPage/CaseReply.js +119 -113
  65. package/dist/ChatBootPage/CaseReplyStyle.js +217 -189
  66. package/dist/ChatBootPage/Title.js +19 -23
  67. package/dist/ChatBootPage/index.js +9 -11
  68. package/dist/ChatBootPage/style.js +80 -50
  69. package/dist/ChatLayout/index.js +93 -57
  70. package/dist/ChatLayout/style.js +206 -176
  71. package/dist/ChatLayout/types.js +1 -0
  72. package/dist/Components/ActionIconBox/index.js +571 -197
  73. package/dist/Components/ActionIconBox/style.js +141 -111
  74. package/dist/Components/ActionItemBox/ActionItemBox.js +95 -149
  75. package/dist/Components/ActionItemBox/index.js +7 -7
  76. package/dist/Components/ActionItemBox/style.js +353 -361
  77. package/dist/Components/Button/IconButton/index.js +35 -43
  78. package/dist/Components/Button/IconButton/style.js +357 -331
  79. package/dist/Components/Button/SwitchButton/index.js +243 -87
  80. package/dist/Components/Button/SwitchButton/style.js +160 -146
  81. package/dist/Components/Button/ToggleButton/index.js +46 -57
  82. package/dist/Components/Button/ToggleButton/style.js +283 -258
  83. package/dist/Components/Button/index.js +6 -2
  84. package/dist/Components/GradientText/index.js +21 -27
  85. package/dist/Components/GradientText/style.js +88 -63
  86. package/dist/Components/ImageList.js +111 -133
  87. package/dist/Components/LayoutHeader/index.js +145 -81
  88. package/dist/Components/LayoutHeader/style.js +89 -64
  89. package/dist/Components/LayoutHeader/types.js +3 -0
  90. package/dist/Components/Loading/index.js +53 -22
  91. package/dist/Components/Robot/index.js +90 -56
  92. package/dist/Components/Robot/lotties/DazingLottie/index.js +78 -47
  93. package/dist/Components/Robot/lotties/ThinkingLottie/index.js +78 -47
  94. package/dist/Components/Robot/lotties/index.js +0 -1
  95. package/dist/Components/SuggestionList/index.js +354 -182
  96. package/dist/Components/SuggestionList/style.js +204 -186
  97. package/dist/Components/TextAnimate/index.js +494 -362
  98. package/dist/Components/TextAnimate/style.js +72 -48
  99. package/dist/Components/TypingAnimation/index.js +214 -169
  100. package/dist/Components/TypingAnimation/style.js +76 -52
  101. package/dist/Components/VisualList/index.js +267 -180
  102. package/dist/Components/VisualList/style.js +140 -124
  103. package/dist/Components/icons/LoadingSpinnerIcon.js +124 -73
  104. package/dist/Components/lotties/DazingLottie/index.js +78 -47
  105. package/dist/Components/lotties/LoadingLottie/index.js +82 -48
  106. package/dist/Components/lotties/TextLoading/index.js +73 -49
  107. package/dist/Components/lotties/TextLoading/style.js +95 -78
  108. package/dist/Components/lotties/ThinkingLottie/index.js +78 -47
  109. package/dist/Components/lotties/index.js +0 -1
  110. package/dist/Constants/colors.js +71 -97
  111. package/dist/History/components/HistoryActionsBox.js +407 -180
  112. package/dist/History/components/HistoryEmpty.js +38 -42
  113. package/dist/History/components/HistoryEmptyIcon.js +682 -964
  114. package/dist/History/components/HistoryItem.js +683 -471
  115. package/dist/History/components/HistoryList.js +170 -87
  116. package/dist/History/components/HistoryRunningIcon.js +160 -111
  117. package/dist/History/components/LoadMoreComponent.js +308 -103
  118. package/dist/History/components/NewChatComponent.js +261 -69
  119. package/dist/History/components/NewChatComponent.style.js +79 -53
  120. package/dist/History/components/SearchComponent.js +367 -156
  121. package/dist/History/components/index.js +11 -23
  122. package/dist/History/hooks/useHistory.js +404 -129
  123. package/dist/History/index.js +301 -186
  124. package/dist/History/menu.js +158 -212
  125. package/dist/History/style.js +282 -276
  126. package/dist/History/types/HistoryData.js +6 -10
  127. package/dist/History/types/HistoryList.js +3 -0
  128. package/dist/History/types/index.js +3 -0
  129. package/dist/History/utils/index.js +35 -32
  130. package/dist/Hooks/useAutoScroll.js +262 -84
  131. package/dist/Hooks/useClickAway.js +60 -21
  132. package/dist/Hooks/useCopied.js +72 -20
  133. package/dist/Hooks/useDebounceFn/index.js +213 -55
  134. package/dist/Hooks/useIntersectionOnce.js +163 -74
  135. package/dist/Hooks/useLanguage.js +67 -26
  136. package/dist/Hooks/useRefFunction/index.js +76 -11
  137. package/dist/Hooks/useSpeechSynthesis.js +143 -99
  138. package/dist/Hooks/useStyle/index.js +95 -60
  139. package/dist/Hooks/useThrottleFn/index.js +41 -41
  140. package/dist/I18n/index.js +246 -109
  141. package/dist/I18n/locales.js +718 -711
  142. package/dist/Icons/animated/VoicePlayLottie/index.js +75 -46
  143. package/dist/Icons/animated/VoicingLottie/index.js +78 -47
  144. package/dist/MarkdownEditor/BaseMarkdownEditor.js +421 -349
  145. package/dist/MarkdownEditor/editor/Editor.js +1160 -843
  146. package/dist/MarkdownEditor/editor/components/CommentList/index.js +407 -239
  147. package/dist/MarkdownEditor/editor/components/CommentList/style.js +119 -89
  148. package/dist/MarkdownEditor/editor/components/ContributorAvatar/index.js +61 -63
  149. package/dist/MarkdownEditor/editor/components/ContributorAvatar/style.js +82 -52
  150. package/dist/MarkdownEditor/editor/components/LazyElement/index.js +208 -106
  151. package/dist/MarkdownEditor/editor/components/LazyElement/style.js +69 -42
  152. package/dist/MarkdownEditor/editor/components/fntTag/index.js +7 -11
  153. package/dist/MarkdownEditor/editor/components/fntTag/style.js +66 -36
  154. package/dist/MarkdownEditor/editor/components/index.js +0 -1
  155. package/dist/MarkdownEditor/editor/elements/Blockquote.js +95 -37
  156. package/dist/MarkdownEditor/editor/elements/Break.js +56 -25
  157. package/dist/MarkdownEditor/editor/elements/Card/index.js +131 -52
  158. package/dist/MarkdownEditor/editor/elements/Code.js +89 -67
  159. package/dist/MarkdownEditor/editor/elements/Comment/index.js +79 -50
  160. package/dist/MarkdownEditor/editor/elements/ErrorBoundary.js +117 -21
  161. package/dist/MarkdownEditor/editor/elements/FootnoteDefinition.js +83 -64
  162. package/dist/MarkdownEditor/editor/elements/FootnoteReference.js +115 -41
  163. package/dist/MarkdownEditor/editor/elements/Head.js +131 -67
  164. package/dist/MarkdownEditor/editor/elements/Hr.js +63 -38
  165. package/dist/MarkdownEditor/editor/elements/Image/index.js +636 -494
  166. package/dist/MarkdownEditor/editor/elements/InlineKatex.js +60 -44
  167. package/dist/MarkdownEditor/editor/elements/Katex.js +71 -55
  168. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +79 -175
  169. package/dist/MarkdownEditor/editor/elements/LinkCard/style.js +130 -100
  170. package/dist/MarkdownEditor/editor/elements/List/List.js +96 -69
  171. package/dist/MarkdownEditor/editor/elements/List/ListItem.js +422 -247
  172. package/dist/MarkdownEditor/editor/elements/List/index.js +1 -5
  173. package/dist/MarkdownEditor/editor/elements/List/style.js +131 -117
  174. package/dist/MarkdownEditor/editor/elements/Media.js +637 -519
  175. package/dist/MarkdownEditor/editor/elements/Mermaid.js +79 -54
  176. package/dist/MarkdownEditor/editor/elements/Paragraph.js +144 -83
  177. package/dist/MarkdownEditor/editor/elements/Schema.js +167 -128
  178. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +211 -178
  179. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +73 -49
  180. package/dist/MarkdownEditor/editor/elements/Table/Table.js +285 -204
  181. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +397 -280
  182. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.js +126 -101
  183. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +381 -276
  184. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.js +120 -98
  185. package/dist/MarkdownEditor/editor/elements/Table/TableContext.js +64 -21
  186. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +52 -42
  187. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.js +69 -39
  188. package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +126 -72
  189. package/dist/MarkdownEditor/editor/elements/Table/Td/style.js +85 -55
  190. package/dist/MarkdownEditor/editor/elements/Table/index.js +204 -105
  191. package/dist/MarkdownEditor/editor/elements/Table/style.js +244 -233
  192. package/dist/MarkdownEditor/editor/elements/Table/useScrollShadow.js +119 -62
  193. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +438 -276
  194. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +103 -77
  195. package/dist/MarkdownEditor/editor/elements/index.js +437 -424
  196. package/dist/MarkdownEditor/editor/parser/json-parse.js +38 -9
  197. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1753 -1168
  198. package/dist/MarkdownEditor/editor/parser/parserMdToSchema.js +16 -20
  199. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1021 -606
  200. package/dist/MarkdownEditor/editor/parser/remarkParse.js +158 -102
  201. package/dist/MarkdownEditor/editor/plugins/catchError.js +78 -17
  202. package/dist/MarkdownEditor/editor/plugins/elements.js +458 -342
  203. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +752 -300
  204. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +215 -129
  205. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +325 -180
  206. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +576 -418
  207. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +157 -47
  208. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +331 -209
  209. package/dist/MarkdownEditor/editor/plugins/index.js +0 -1
  210. package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +1245 -507
  211. package/dist/MarkdownEditor/editor/plugins/parseMarkdownToNodesAndInsert.js +36 -24
  212. package/dist/MarkdownEditor/editor/plugins/useHighlight.js +267 -116
  213. package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +234 -160
  214. package/dist/MarkdownEditor/editor/plugins/useOnchange.js +253 -92
  215. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +728 -439
  216. package/dist/MarkdownEditor/editor/store.js +1819 -1389
  217. package/dist/MarkdownEditor/editor/style.js +551 -506
  218. package/dist/MarkdownEditor/editor/tagStyles.js +43 -43
  219. package/dist/MarkdownEditor/editor/tools/DragHandle.js +56 -54
  220. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1049 -732
  221. package/dist/MarkdownEditor/editor/tools/InsertLink.js +232 -181
  222. package/dist/MarkdownEditor/editor/tools/Leading.js +566 -303
  223. package/dist/MarkdownEditor/editor/tools/ToolBar/BaseBar.js +415 -377
  224. package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +162 -125
  225. package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +480 -258
  226. package/dist/MarkdownEditor/editor/tools/ToolBar/ToolBar.js +44 -44
  227. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ClearFormatButton.js +20 -35
  228. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ColorPickerButton.js +69 -73
  229. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormatButton.js +13 -19
  230. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormattingTools.js +34 -41
  231. package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +53 -47
  232. package/dist/MarkdownEditor/editor/tools/ToolBar/components/LinkButton.js +11 -19
  233. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ToolBarItem.js +23 -43
  234. package/dist/MarkdownEditor/editor/tools/ToolBar/components/UndoRedoButtons.js +14 -25
  235. package/dist/MarkdownEditor/editor/tools/ToolBar/config/toolsConfig.js +139 -102
  236. package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.js +95 -65
  237. package/dist/MarkdownEditor/editor/tools/ToolBar/hooks/useToolBarLogic.js +252 -161
  238. package/dist/MarkdownEditor/editor/tools/ToolBar/index.js +14 -24
  239. package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.js +95 -65
  240. package/dist/MarkdownEditor/editor/tools/insertAutocompleteStyle.js +82 -52
  241. package/dist/MarkdownEditor/editor/types/Table.js +1 -0
  242. package/dist/MarkdownEditor/editor/utils/InlineChromiumBugfix.js +11 -16
  243. package/dist/MarkdownEditor/editor/utils/ace.js +136 -40
  244. package/dist/MarkdownEditor/editor/utils/docx/docxDeserializer.js +29 -32
  245. package/dist/MarkdownEditor/editor/utils/docx/index.js +0 -1
  246. package/dist/MarkdownEditor/editor/utils/docx/module.js +193 -164
  247. package/dist/MarkdownEditor/editor/utils/docx/utils.js +113 -98
  248. package/dist/MarkdownEditor/editor/utils/dom.js +119 -90
  249. package/dist/MarkdownEditor/editor/utils/editorUtils.js +1369 -906
  250. package/dist/MarkdownEditor/editor/utils/htmlToMarkdown.js +196 -184
  251. package/dist/MarkdownEditor/editor/utils/index.js +354 -215
  252. package/dist/MarkdownEditor/editor/utils/isMarkdown.js +56 -44
  253. package/dist/MarkdownEditor/editor/utils/keyboard.js +1229 -664
  254. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +294 -76
  255. package/dist/MarkdownEditor/editor/utils/media.js +274 -99
  256. package/dist/MarkdownEditor/editor/utils/path.js +22 -16
  257. package/dist/MarkdownEditor/editor/utils/performanceMonitor.js +370 -168
  258. package/dist/MarkdownEditor/editor/utils/useLocalState.js +96 -37
  259. package/dist/MarkdownEditor/el.js +1 -0
  260. package/dist/MarkdownEditor/hooks/editor.js +123 -41
  261. package/dist/MarkdownEditor/hooks/subscribe.js +18 -15
  262. package/dist/MarkdownEditor/index.js +118 -30
  263. package/dist/MarkdownEditor/plugin.js +2 -5
  264. package/dist/MarkdownEditor/style.js +96 -66
  265. package/dist/MarkdownEditor/types.js +1 -0
  266. package/dist/MarkdownEditor/utils/exportHtml.js +42 -83
  267. package/dist/MarkdownEditor/utils/native-table/index.js +0 -1
  268. package/dist/MarkdownEditor/utils/native-table/native-table-editor.js +337 -222
  269. package/dist/MarkdownEditor/utils/native-table/native-table-keyboard.js +201 -113
  270. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +86 -79
  271. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +62 -33
  272. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +147 -125
  273. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +174 -129
  274. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +263 -237
  275. package/dist/MarkdownInputField/AttachmentButton/index.js +465 -205
  276. package/dist/MarkdownInputField/AttachmentButton/style.js +143 -114
  277. package/dist/MarkdownInputField/AttachmentButton/types.js +3 -0
  278. package/dist/MarkdownInputField/AttachmentButton/utils.js +64 -34
  279. package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +438 -404
  280. package/dist/MarkdownInputField/Enlargement/index.js +7 -17
  281. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +193 -216
  282. package/dist/MarkdownInputField/FileMapView/index.js +387 -174
  283. package/dist/MarkdownInputField/FileMapView/style.js +281 -259
  284. package/dist/MarkdownInputField/FilePaste/index.js +239 -65
  285. package/dist/MarkdownInputField/FileUploadManager/index.js +460 -170
  286. package/dist/MarkdownInputField/MarkdownInputField.js +819 -549
  287. package/dist/MarkdownInputField/QuickActions/index.js +304 -134
  288. package/dist/MarkdownInputField/RefinePromptButton/index.js +24 -33
  289. package/dist/MarkdownInputField/RefinePromptButton/style.js +99 -73
  290. package/dist/MarkdownInputField/SendActions/index.js +179 -197
  291. package/dist/MarkdownInputField/SendButton/index.js +150 -110
  292. package/dist/MarkdownInputField/SendButton/style.js +95 -64
  293. package/dist/MarkdownInputField/SkillModeBar/hooks/index.js +3 -5
  294. package/dist/MarkdownInputField/SkillModeBar/hooks/useSkillModeState.js +51 -26
  295. package/dist/MarkdownInputField/SkillModeBar/index.js +119 -106
  296. package/dist/MarkdownInputField/SkillModeBar/style.js +124 -98
  297. package/dist/MarkdownInputField/Suggestion/index.js +391 -154
  298. package/dist/MarkdownInputField/TopOperatingArea/index.js +37 -44
  299. package/dist/MarkdownInputField/TopOperatingArea/style.js +98 -81
  300. package/dist/MarkdownInputField/VoiceInput/index.js +210 -82
  301. package/dist/MarkdownInputField/VoiceInput/style.js +85 -59
  302. package/dist/MarkdownInputField/VoiceInputManager/index.js +321 -94
  303. package/dist/MarkdownInputField/style.js +296 -233
  304. package/dist/Plugins/chart/AreaChart/index.js +541 -393
  305. package/dist/Plugins/chart/AreaChart/style.js +114 -90
  306. package/dist/Plugins/chart/BarChart/index.d.ts +4 -0
  307. package/dist/Plugins/chart/BarChart/index.js +865 -697
  308. package/dist/Plugins/chart/BarChart/style.js +114 -90
  309. package/dist/Plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.js +82 -52
  310. package/dist/Plugins/chart/ChartAttrToolBar/index.js +94 -65
  311. package/dist/Plugins/chart/ChartMark/Area.js +176 -150
  312. package/dist/Plugins/chart/ChartMark/Bar.js +181 -152
  313. package/dist/Plugins/chart/ChartMark/Column.js +181 -151
  314. package/dist/Plugins/chart/ChartMark/Container.js +116 -75
  315. package/dist/Plugins/chart/ChartMark/Line.js +179 -151
  316. package/dist/Plugins/chart/ChartMark/Pie.js +79 -63
  317. package/dist/Plugins/chart/ChartMark/index.js +6 -13
  318. package/dist/Plugins/chart/ChartMark/useChart.js +1 -0
  319. package/dist/Plugins/chart/ChartRender.js +981 -696
  320. package/dist/Plugins/chart/ChartStatistic/index.js +47 -62
  321. package/dist/Plugins/chart/ChartStatistic/style.js +142 -143
  322. package/dist/Plugins/chart/ChartStatistic/utils.js +37 -27
  323. package/dist/Plugins/chart/DonutChart/Legend.js +94 -124
  324. package/dist/Plugins/chart/DonutChart/constants.js +4 -11
  325. package/dist/Plugins/chart/DonutChart/hooks.js +183 -112
  326. package/dist/Plugins/chart/DonutChart/index.js +588 -516
  327. package/dist/Plugins/chart/DonutChart/plugins.js +47 -44
  328. package/dist/Plugins/chart/DonutChart/style.js +186 -175
  329. package/dist/Plugins/chart/DonutChart/types.js +1 -0
  330. package/dist/Plugins/chart/FunnelChart/index.js +844 -647
  331. package/dist/Plugins/chart/FunnelChart/style.js +97 -71
  332. package/dist/Plugins/chart/LineChart/index.js +516 -393
  333. package/dist/Plugins/chart/LineChart/style.js +114 -90
  334. package/dist/Plugins/chart/RadarChart/index.js +580 -582
  335. package/dist/Plugins/chart/RadarChart/style.js +122 -112
  336. package/dist/Plugins/chart/ScatterChart/index.js +633 -640
  337. package/dist/Plugins/chart/ScatterChart/style.js +108 -94
  338. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +151 -80
  339. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +160 -41
  340. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundaryExample.js +80 -62
  341. package/dist/Plugins/chart/components/ChartContainer/index.js +2 -7
  342. package/dist/Plugins/chart/components/ChartContainer/style.js +121 -91
  343. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +58 -90
  344. package/dist/Plugins/chart/components/ChartFilter/style.js +169 -154
  345. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +54 -59
  346. package/dist/Plugins/chart/components/ChartToolBar/style.js +132 -117
  347. package/dist/Plugins/chart/components/icons/TimeIcon.js +20 -26
  348. package/dist/Plugins/chart/components/index.js +32 -34
  349. package/dist/Plugins/chart/const.js +34 -25
  350. package/dist/Plugins/chart/hooks/useChartStatistic.js +1 -0
  351. package/dist/Plugins/chart/index.js +436 -339
  352. package/dist/Plugins/chart/loadChartRuntime.js +209 -110
  353. package/dist/Plugins/chart/utils.js +311 -87
  354. package/dist/Plugins/code/CodeUI/Katex/Katex.js +112 -66
  355. package/dist/Plugins/code/components/AceEditor.js +334 -237
  356. package/dist/Plugins/code/components/AceEditorContainer.js +23 -32
  357. package/dist/Plugins/code/components/CodeContainer.js +41 -56
  358. package/dist/Plugins/code/components/CodeRenderer.js +202 -155
  359. package/dist/Plugins/code/components/CodeToolbar.js +137 -181
  360. package/dist/Plugins/code/components/HtmlPreview.js +19 -22
  361. package/dist/Plugins/code/components/LanguageSelector.js +162 -96
  362. package/dist/Plugins/code/components/LoadImage.js +145 -46
  363. package/dist/Plugins/code/components/ThinkBlock.js +38 -42
  364. package/dist/Plugins/code/components/index.js +13 -23
  365. package/dist/Plugins/code/hooks/index.js +7 -9
  366. package/dist/Plugins/code/hooks/useCodeEditorState.js +139 -62
  367. package/dist/Plugins/code/hooks/useRenderConditions.js +31 -23
  368. package/dist/Plugins/code/hooks/useToolbarConfig.js +44 -46
  369. package/dist/Plugins/code/index.js +141 -89
  370. package/dist/Plugins/code/langIconMap.js +400 -108
  371. package/dist/Plugins/code/langIcons/AbapIcon.js +90 -57
  372. package/dist/Plugins/code/langIcons/ActionscriptIcon.js +89 -56
  373. package/dist/Plugins/code/langIcons/AdaIcon.js +89 -52
  374. package/dist/Plugins/code/langIcons/ApacheIcon.js +205 -254
  375. package/dist/Plugins/code/langIcons/ApexIcon.js +108 -82
  376. package/dist/Plugins/code/langIcons/AplIcon.js +90 -54
  377. package/dist/Plugins/code/langIcons/ApplescriptIcon.js +89 -56
  378. package/dist/Plugins/code/langIcons/AstroIcon.js +91 -58
  379. package/dist/Plugins/code/langIcons/AwkIcon.js +98 -68
  380. package/dist/Plugins/code/langIcons/BallerinaIcon.js +92 -59
  381. package/dist/Plugins/code/langIcons/BatIcon.js +158 -229
  382. package/dist/Plugins/code/langIcons/BicepIcon.js +91 -58
  383. package/dist/Plugins/code/langIcons/BladeIcon.js +90 -58
  384. package/dist/Plugins/code/langIcons/CIcon.js +90 -55
  385. package/dist/Plugins/code/langIcons/CadenceIcon.js +89 -56
  386. package/dist/Plugins/code/langIcons/ClojureIcon.js +96 -75
  387. package/dist/Plugins/code/langIcons/CmakeIcon.js +93 -62
  388. package/dist/Plugins/code/langIcons/CobolIcon.js +99 -70
  389. package/dist/Plugins/code/langIcons/CodeqlIcon.js +96 -76
  390. package/dist/Plugins/code/langIcons/CoffeeIcon.js +89 -56
  391. package/dist/Plugins/code/langIcons/ConsoleIcon.js +89 -56
  392. package/dist/Plugins/code/langIcons/CppIcon.js +90 -55
  393. package/dist/Plugins/code/langIcons/CrystalIcon.js +90 -57
  394. package/dist/Plugins/code/langIcons/CsharpIcon.js +90 -59
  395. package/dist/Plugins/code/langIcons/CssIcon.js +89 -52
  396. package/dist/Plugins/code/langIcons/DIcon.js +90 -53
  397. package/dist/Plugins/code/langIcons/DartIcon.js +92 -71
  398. package/dist/Plugins/code/langIcons/DatabaseIcon.js +90 -57
  399. package/dist/Plugins/code/langIcons/DiffIcon.js +90 -57
  400. package/dist/Plugins/code/langIcons/DockerIcon.js +89 -56
  401. package/dist/Plugins/code/langIcons/DotenvIcon.js +94 -56
  402. package/dist/Plugins/code/langIcons/ElixirIcon.js +91 -58
  403. package/dist/Plugins/code/langIcons/ElmIcon.js +105 -58
  404. package/dist/Plugins/code/langIcons/ErbIcon.js +90 -54
  405. package/dist/Plugins/code/langIcons/ErlangIcon.js +89 -56
  406. package/dist/Plugins/code/langIcons/FsharpIcon.js +93 -62
  407. package/dist/Plugins/code/langIcons/GdscriptIcon.js +96 -88
  408. package/dist/Plugins/code/langIcons/GlslIcon.js +90 -58
  409. package/dist/Plugins/code/langIcons/GnuplotIcon.js +98 -77
  410. package/dist/Plugins/code/langIcons/GoIcon.js +114 -93
  411. package/dist/Plugins/code/langIcons/GraphqlIcon.js +106 -66
  412. package/dist/Plugins/code/langIcons/GroovyIcon.js +89 -56
  413. package/dist/Plugins/code/langIcons/HackIcon.js +97 -64
  414. package/dist/Plugins/code/langIcons/HamlIcon.js +89 -56
  415. package/dist/Plugins/code/langIcons/HandlebarsIcon.js +89 -56
  416. package/dist/Plugins/code/langIcons/HaskellIcon.js +93 -64
  417. package/dist/Plugins/code/langIcons/HclIcon.js +118 -93
  418. package/dist/Plugins/code/langIcons/HclLightIcon.js +118 -97
  419. package/dist/Plugins/code/langIcons/HjsonIcon.js +94 -62
  420. package/dist/Plugins/code/langIcons/HlslIcon.js +96 -76
  421. package/dist/Plugins/code/langIcons/HtmlIcon.js +89 -56
  422. package/dist/Plugins/code/langIcons/HttpIcon.js +89 -56
  423. package/dist/Plugins/code/langIcons/ImbaIcon.js +98 -65
  424. package/dist/Plugins/code/langIcons/IniIcon.js +90 -54
  425. package/dist/Plugins/code/langIcons/JavaIcon.js +89 -56
  426. package/dist/Plugins/code/langIcons/JavascriptIcon.js +89 -56
  427. package/dist/Plugins/code/langIcons/JinjaIcon.js +100 -68
  428. package/dist/Plugins/code/langIcons/Json5Icon.js +100 -82
  429. package/dist/Plugins/code/langIcons/JsonIcon.js +89 -56
  430. package/dist/Plugins/code/langIcons/JsonnetIcon.js +102 -86
  431. package/dist/Plugins/code/langIcons/JuliaIcon.js +105 -52
  432. package/dist/Plugins/code/langIcons/KotlinIcon.js +104 -74
  433. package/dist/Plugins/code/langIcons/KustoIcon.js +90 -57
  434. package/dist/Plugins/code/langIcons/LessIcon.js +90 -57
  435. package/dist/Plugins/code/langIcons/LiquidIcon.js +91 -58
  436. package/dist/Plugins/code/langIcons/LispIcon.js +89 -56
  437. package/dist/Plugins/code/langIcons/LuaIcon.js +93 -60
  438. package/dist/Plugins/code/langIcons/MakefileIcon.js +91 -58
  439. package/dist/Plugins/code/langIcons/MarkdownIcon.js +89 -56
  440. package/dist/Plugins/code/langIcons/MarkojsIcon.js +96 -73
  441. package/dist/Plugins/code/langIcons/MatlabIcon.js +93 -64
  442. package/dist/Plugins/code/langIcons/MdxIcon.js +90 -53
  443. package/dist/Plugins/code/langIcons/MermaidIcon.js +95 -64
  444. package/dist/Plugins/code/langIcons/MojoIcon.js +95 -62
  445. package/dist/Plugins/code/langIcons/NginxIcon.js +94 -61
  446. package/dist/Plugins/code/langIcons/NimIcon.js +91 -54
  447. package/dist/Plugins/code/langIcons/NixIcon.js +92 -56
  448. package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +90 -59
  449. package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +90 -57
  450. package/dist/Plugins/code/langIcons/OcamlIcon.js +90 -61
  451. package/dist/Plugins/code/langIcons/PascalIcon.js +95 -55
  452. package/dist/Plugins/code/langIcons/Perl6Icon.js +299 -320
  453. package/dist/Plugins/code/langIcons/PerlIcon.js +89 -56
  454. package/dist/Plugins/code/langIcons/PhpIcon.js +89 -52
  455. package/dist/Plugins/code/langIcons/PostcssIcon.js +130 -113
  456. package/dist/Plugins/code/langIcons/PowershellIcon.js +91 -58
  457. package/dist/Plugins/code/langIcons/PrismaIcon.js +97 -68
  458. package/dist/Plugins/code/langIcons/PrologIcon.js +91 -58
  459. package/dist/Plugins/code/langIcons/ProtoIcon.js +94 -68
  460. package/dist/Plugins/code/langIcons/PugIcon.js +177 -145
  461. package/dist/Plugins/code/langIcons/PuppetIcon.js +96 -52
  462. package/dist/Plugins/code/langIcons/PurescriptIcon.js +93 -61
  463. package/dist/Plugins/code/langIcons/PythonIcon.js +90 -61
  464. package/dist/Plugins/code/langIcons/RIcon.js +89 -52
  465. package/dist/Plugins/code/langIcons/RazorIcon.js +90 -57
  466. package/dist/Plugins/code/langIcons/ReactIcon.js +89 -56
  467. package/dist/Plugins/code/langIcons/ReactTsIcon.js +90 -57
  468. package/dist/Plugins/code/langIcons/RubyIcon.js +91 -58
  469. package/dist/Plugins/code/langIcons/RustIcon.js +89 -56
  470. package/dist/Plugins/code/langIcons/SasIcon.js +89 -52
  471. package/dist/Plugins/code/langIcons/SassIcon.js +90 -57
  472. package/dist/Plugins/code/langIcons/ScalaIcon.js +96 -53
  473. package/dist/Plugins/code/langIcons/SchemeIcon.js +91 -58
  474. package/dist/Plugins/code/langIcons/ShaderlabIcon.js +89 -56
  475. package/dist/Plugins/code/langIcons/SolidityIcon.js +94 -52
  476. package/dist/Plugins/code/langIcons/SparqlIcon.js +94 -64
  477. package/dist/Plugins/code/langIcons/StataIcon.js +126 -108
  478. package/dist/Plugins/code/langIcons/StylusIcon.js +92 -59
  479. package/dist/Plugins/code/langIcons/SvelteIcon.js +91 -58
  480. package/dist/Plugins/code/langIcons/SwiftIcon.js +90 -57
  481. package/dist/Plugins/code/langIcons/SystemverilogIcon.js +115 -102
  482. package/dist/Plugins/code/langIcons/TclIcon.js +89 -52
  483. package/dist/Plugins/code/langIcons/TexIcon.js +99 -65
  484. package/dist/Plugins/code/langIcons/TomlIcon.js +94 -70
  485. package/dist/Plugins/code/langIcons/TwigIcon.js +89 -56
  486. package/dist/Plugins/code/langIcons/TypescriptIcon.js +93 -60
  487. package/dist/Plugins/code/langIcons/VerilogIcon.js +89 -56
  488. package/dist/Plugins/code/langIcons/VhdlIcon.js +94 -64
  489. package/dist/Plugins/code/langIcons/VimIcon.js +278 -420
  490. package/dist/Plugins/code/langIcons/VueIcon.js +92 -59
  491. package/dist/Plugins/code/langIcons/WebassemblyIcon.js +103 -76
  492. package/dist/Plugins/code/langIcons/WenyanIcon.js +104 -100
  493. package/dist/Plugins/code/langIcons/WgslIcon.js +93 -77
  494. package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +100 -71
  495. package/dist/Plugins/code/langIcons/XmlIcon.js +89 -52
  496. package/dist/Plugins/code/langIcons/XslIcon.js +94 -66
  497. package/dist/Plugins/code/langIcons/YamlIcon.js +89 -56
  498. package/dist/Plugins/code/langIcons/ZigIcon.js +106 -81
  499. package/dist/Plugins/code/langIcons/index.js +128 -259
  500. package/dist/Plugins/code/utils/index.js +5 -5
  501. package/dist/Plugins/code/utils/langOptions.js +86 -11
  502. package/dist/Plugins/defaultPlugins.js +9 -13
  503. package/dist/Plugins/formatter/index.js +205 -105
  504. package/dist/Plugins/index.js +6 -2
  505. package/dist/Plugins/katex/InlineKatex.js +196 -107
  506. package/dist/Plugins/katex/Katex.js +139 -65
  507. package/dist/Plugins/katex/index.js +163 -103
  508. package/dist/Plugins/mermaid/Mermaid.js +472 -197
  509. package/dist/Plugins/mermaid/index.js +237 -142
  510. package/dist/Quote/index.js +112 -73
  511. package/dist/Quote/style.js +176 -160
  512. package/dist/Schema/SchemaEditor/AceEditorWrapper.js +163 -119
  513. package/dist/Schema/SchemaEditor/index.js +385 -275
  514. package/dist/Schema/SchemaEditor/style.js +261 -269
  515. package/dist/Schema/SchemaForm/index.js +443 -268
  516. package/dist/Schema/SchemaForm/types.js +1 -0
  517. package/dist/Schema/SchemaRenderer/index.js +973 -588
  518. package/dist/Schema/SchemaRenderer/templateEngine.js +106 -26
  519. package/dist/Schema/index.js +7 -11
  520. package/dist/Schema/types.js +1 -0
  521. package/dist/Schema/validator.js +74 -36
  522. package/dist/TaskList/index.js +197 -142
  523. package/dist/TaskList/style.js +143 -122
  524. package/dist/ThoughtChainList/CostMillis.js +88 -54
  525. package/dist/ThoughtChainList/DeepThink.js +187 -152
  526. package/dist/ThoughtChainList/DotAni/index.js +29 -14
  527. package/dist/ThoughtChainList/DotAni/style.js +82 -50
  528. package/dist/ThoughtChainList/FlipText/index.js +74 -30
  529. package/dist/ThoughtChainList/MarkdownEditor.js +126 -72
  530. package/dist/ThoughtChainList/RagRetrievalInfo.js +113 -145
  531. package/dist/ThoughtChainList/TableSql.js +413 -459
  532. package/dist/ThoughtChainList/ThoughtChainListItem.js +388 -222
  533. package/dist/ThoughtChainList/TitleInfo.js +189 -185
  534. package/dist/ThoughtChainList/ToolCall.js +429 -463
  535. package/dist/ThoughtChainList/WebSearch.js +192 -162
  536. package/dist/ThoughtChainList/index.js +449 -410
  537. package/dist/ThoughtChainList/style.js +253 -232
  538. package/dist/ThoughtChainList/types.js +1 -0
  539. package/dist/ToolUseBar/ToolUseBarItem.js +183 -139
  540. package/dist/ToolUseBar/ToolUseBarItemComponents.js +345 -276
  541. package/dist/ToolUseBar/ToolUseBarThink.js +335 -396
  542. package/dist/ToolUseBar/index.js +226 -113
  543. package/dist/ToolUseBar/style.js +334 -308
  544. package/dist/ToolUseBar/thinkStyle.js +350 -328
  545. package/dist/Types/common.js +1 -0
  546. package/dist/Types/index.js +4 -2
  547. package/dist/Types/message.js +1 -0
  548. package/dist/Utils/easings.js +9 -12
  549. package/dist/Utils/formatTime.js +41 -17
  550. package/dist/Utils/getScroll.js +41 -41
  551. package/dist/Utils/language.js +355 -150
  552. package/dist/Utils/proxySandbox/ProxySandbox.js +1637 -1076
  553. package/dist/Utils/proxySandbox/SecurityContextManager.js +607 -343
  554. package/dist/Utils/proxySandbox/index.js +554 -267
  555. package/dist/Utils/proxySandbox/types.js +187 -52
  556. package/dist/Utils/scrollTo.js +48 -56
  557. package/dist/Utils/throttleByAnimationFrame.js +46 -20
  558. package/dist/WelcomeMessage/index.js +106 -58
  559. package/dist/WelcomeMessage/style.js +80 -55
  560. package/dist/Workspace/Browser/index.js +102 -40
  561. package/dist/Workspace/Browser/style.js +62 -33
  562. package/dist/Workspace/File/DataSourceStrategy.js +419 -217
  563. package/dist/Workspace/File/FileComponent.js +1004 -791
  564. package/dist/Workspace/File/FileTypeProcessor.js +337 -184
  565. package/dist/Workspace/File/PreviewComponent.js +472 -532
  566. package/dist/Workspace/File/index.js +3 -10
  567. package/dist/Workspace/File/style.js +397 -424
  568. package/dist/Workspace/File/utils.js +160 -106
  569. package/dist/Workspace/HtmlPreview/index.js +238 -137
  570. package/dist/Workspace/HtmlPreview/style.js +99 -77
  571. package/dist/Workspace/RealtimeFollow/index.js +411 -413
  572. package/dist/Workspace/RealtimeFollow/style.js +299 -303
  573. package/dist/Workspace/Task/index.js +53 -35
  574. package/dist/Workspace/Task/style.js +99 -73
  575. package/dist/Workspace/index.js +332 -254
  576. package/dist/Workspace/style.js +165 -146
  577. package/dist/Workspace/types.js +471 -252
  578. package/dist/Workspace/utils/codeLanguageUtils.js +148 -129
  579. package/dist/Workspace/utils.js +28 -20
  580. package/dist/index.js +27 -17
  581. package/package.json +3 -2
@@ -1,63 +1,242 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
16
19
  }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __async = (__this, __arguments, generator) => {
21
- return new Promise((resolve, reject) => {
22
- var fulfilled = (value) => {
23
- try {
24
- step(generator.next(value));
25
- } catch (e) {
26
- reject(e);
27
- }
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+ function _async_to_generator(fn) {
27
+ return function() {
28
+ var self = this, args = arguments;
29
+ return new Promise(function(resolve, reject) {
30
+ var gen = fn.apply(self, args);
31
+ function _next(value) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
28
39
  };
29
- var rejected = (value) => {
30
- try {
31
- step(generator.throw(value));
32
- } catch (e) {
33
- reject(e);
34
- }
40
+ }
41
+ function _define_property(obj, key, value) {
42
+ if (key in obj) {
43
+ Object.defineProperty(obj, key, {
44
+ value: value,
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true
48
+ });
49
+ } else {
50
+ obj[key] = value;
51
+ }
52
+ return obj;
53
+ }
54
+ function _iterable_to_array(iter) {
55
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
56
+ }
57
+ function _iterable_to_array_limit(arr, i) {
58
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
59
+ if (_i == null) return;
60
+ var _arr = [];
61
+ var _n = true;
62
+ var _d = false;
63
+ var _s, _e;
64
+ try {
65
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
66
+ _arr.push(_s.value);
67
+ if (i && _arr.length === i) break;
68
+ }
69
+ } catch (err) {
70
+ _d = true;
71
+ _e = err;
72
+ } finally{
73
+ try {
74
+ if (!_n && _i["return"] != null) _i["return"]();
75
+ } finally{
76
+ if (_d) throw _e;
77
+ }
78
+ }
79
+ return _arr;
80
+ }
81
+ function _non_iterable_rest() {
82
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
+ }
84
+ function _non_iterable_spread() {
85
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
86
+ }
87
+ function _object_spread(target) {
88
+ for(var i = 1; i < arguments.length; i++){
89
+ var source = arguments[i] != null ? arguments[i] : {};
90
+ var ownKeys = Object.keys(source);
91
+ if (typeof Object.getOwnPropertySymbols === "function") {
92
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
93
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
94
+ }));
95
+ }
96
+ ownKeys.forEach(function(key) {
97
+ _define_property(target, key, source[key]);
98
+ });
99
+ }
100
+ return target;
101
+ }
102
+ function ownKeys(object, enumerableOnly) {
103
+ var keys = Object.keys(object);
104
+ if (Object.getOwnPropertySymbols) {
105
+ var symbols = Object.getOwnPropertySymbols(object);
106
+ if (enumerableOnly) {
107
+ symbols = symbols.filter(function(sym) {
108
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
109
+ });
110
+ }
111
+ keys.push.apply(keys, symbols);
112
+ }
113
+ return keys;
114
+ }
115
+ function _object_spread_props(target, source) {
116
+ source = source != null ? source : {};
117
+ if (Object.getOwnPropertyDescriptors) {
118
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
119
+ } else {
120
+ ownKeys(Object(source)).forEach(function(key) {
121
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
122
+ });
123
+ }
124
+ return target;
125
+ }
126
+ function _sliced_to_array(arr, i) {
127
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
128
+ }
129
+ function _to_consumable_array(arr) {
130
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
131
+ }
132
+ function _unsupported_iterable_to_array(o, minLen) {
133
+ if (!o) return;
134
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
135
+ var n = Object.prototype.toString.call(o).slice(8, -1);
136
+ if (n === "Object" && o.constructor) n = o.constructor.name;
137
+ if (n === "Map" || n === "Set") return Array.from(n);
138
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
139
+ }
140
+ function _ts_generator(thisArg, body) {
141
+ var f, y, t, g, _ = {
142
+ label: 0,
143
+ sent: function() {
144
+ if (t[0] & 1) throw t[1];
145
+ return t[1];
146
+ },
147
+ trys: [],
148
+ ops: []
35
149
  };
36
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
- step((generator = generator.apply(__this, __arguments)).next());
38
- });
39
- };
40
-
41
- // src/MarkdownEditor/editor/tools/InsertAutocomplete.tsx
42
- import {
43
- CheckSquareOutlined,
44
- CodeOutlined,
45
- FontSizeOutlined,
46
- OrderedListOutlined,
47
- PlayCircleOutlined,
48
- TableOutlined,
49
- UnorderedListOutlined
50
- } from "@ant-design/icons";
150
+ return g = {
151
+ next: verb(0),
152
+ "throw": verb(1),
153
+ "return": verb(2)
154
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
155
+ return this;
156
+ }), g;
157
+ function verb(n) {
158
+ return function(v) {
159
+ return step([
160
+ n,
161
+ v
162
+ ]);
163
+ };
164
+ }
165
+ function step(op) {
166
+ if (f) throw new TypeError("Generator is already executing.");
167
+ while(_)try {
168
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
169
+ if (y = 0, t) op = [
170
+ op[0] & 2,
171
+ t.value
172
+ ];
173
+ switch(op[0]){
174
+ case 0:
175
+ case 1:
176
+ t = op;
177
+ break;
178
+ case 4:
179
+ _.label++;
180
+ return {
181
+ value: op[1],
182
+ done: false
183
+ };
184
+ case 5:
185
+ _.label++;
186
+ y = op[1];
187
+ op = [
188
+ 0
189
+ ];
190
+ continue;
191
+ case 7:
192
+ op = _.ops.pop();
193
+ _.trys.pop();
194
+ continue;
195
+ default:
196
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
197
+ _ = 0;
198
+ continue;
199
+ }
200
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
201
+ _.label = op[1];
202
+ break;
203
+ }
204
+ if (op[0] === 6 && _.label < t[1]) {
205
+ _.label = t[1];
206
+ t = op;
207
+ break;
208
+ }
209
+ if (t && _.label < t[2]) {
210
+ _.label = t[2];
211
+ _.ops.push(op);
212
+ break;
213
+ }
214
+ if (t[2]) _.ops.pop();
215
+ _.trys.pop();
216
+ continue;
217
+ }
218
+ op = body.call(thisArg, _);
219
+ } catch (e) {
220
+ op = [
221
+ 6,
222
+ e
223
+ ];
224
+ y = 0;
225
+ } finally{
226
+ f = t = 0;
227
+ }
228
+ if (op[0] & 5) throw op[1];
229
+ return {
230
+ value: op[0] ? op[1] : void 0,
231
+ done: true
232
+ };
233
+ }
234
+ }
235
+ import { CheckSquareOutlined, CodeOutlined, FontSizeOutlined, OrderedListOutlined, PlayCircleOutlined, TableOutlined, UnorderedListOutlined } from "@ant-design/icons";
51
236
  import { Button, ConfigProvider, Input, Menu, Tabs } from "antd";
52
237
  import classNames from "classnames";
53
238
  import isHotkey from "is-hotkey";
54
- import React, {
55
- useCallback,
56
- useContext,
57
- useEffect,
58
- useMemo,
59
- useRef
60
- } from "react";
239
+ import React, { useCallback, useContext, useEffect, useMemo, useRef } from "react";
61
240
  import ReactDOM from "react-dom";
62
241
  import { Editor, Element, Node, Transforms } from "slate";
63
242
  import { ReactEditor } from "slate-react";
@@ -70,742 +249,880 @@ import { EditorUtils } from "../utils/editorUtils";
70
249
  import { getRemoteMediaType } from "../utils/media";
71
250
  import { useLocalState } from "../utils/useLocalState";
72
251
  import { useStyle } from "./insertAutocompleteStyle";
73
- var ImageIcon = () => {
74
- return /* @__PURE__ */ React.createElement(
75
- "svg",
76
- {
77
- className: "ant-menu-item-icon",
78
- viewBox: "0 0 1024 1024",
79
- version: "1.1",
80
- width: "1em",
81
- height: "1em"
82
- },
83
- /* @__PURE__ */ React.createElement(
84
- "path",
85
- {
252
+ var ImageIcon = function() {
253
+ return /*#__PURE__*/ React.createElement("svg", {
254
+ className: "ant-menu-item-icon",
255
+ viewBox: "0 0 1024 1024",
256
+ version: "1.1",
257
+ width: "1em",
258
+ height: "1em"
259
+ }, /*#__PURE__*/ React.createElement("path", {
86
260
  fill: "currentColor",
87
261
  d: "M0 128l0 768 1024 0L1024 128 0 128zM944 816 80 816 80 208l864 0L944 816zM704 368c0 53.024 42.976 96 96 96 53.024 0 96-42.976 96-96 0-53.024-42.976-96-96-96C746.976 272 704 314.976 704 368M888 760l-192-288-128 96-240-304-192 496L888 760z"
88
- }
89
- )
90
- );
262
+ }));
91
263
  };
92
- var Quote = () => {
93
- return /* @__PURE__ */ React.createElement(
94
- "svg",
95
- {
96
- className: "ant-menu-item-icon",
97
- viewBox: "0 0 1024 1024",
98
- version: "1.1",
99
- width: "1em",
100
- height: "1em"
101
- },
102
- /* @__PURE__ */ React.createElement(
103
- "path",
104
- {
264
+ var Quote = function() {
265
+ return /*#__PURE__*/ React.createElement("svg", {
266
+ className: "ant-menu-item-icon",
267
+ viewBox: "0 0 1024 1024",
268
+ version: "1.1",
269
+ width: "1em",
270
+ height: "1em"
271
+ }, /*#__PURE__*/ React.createElement("path", {
105
272
  d: "M128 472.896h341.344v341.344H128zM128 472.896L272.096 192h110.08l-144.128 280.896z",
106
273
  fill: "currentColor"
107
- }
108
- ),
109
- /* @__PURE__ */ React.createElement(
110
- "path",
111
- {
274
+ }), /*#__PURE__*/ React.createElement("path", {
112
275
  d: "M544 472.896h341.344v341.344H544zM544 472.896L688.096 192h110.08l-144.128 280.896z",
113
276
  fill: "currentColor"
114
- }
115
- )
116
- );
277
+ }));
117
278
  };
118
279
  var replaceUrl = [
119
- {
120
- reg: /https?:\/\/youtu.be\/([\w-]+)(\?si=\w+)?/i,
121
- replace: (match) => {
122
- return `https://www.youtube.com/embed/${match[1]}${match[2] || ""}`;
123
- }
124
- },
125
- {
126
- reg: /https?:\/\/www.bilibili.com\/video\/([\w-]+)\/?/,
127
- replace: (match) => {
128
- return `https://player.bilibili.com/player.html?isOutside=true&bvid=${match[1]}`;
129
- }
130
- },
131
- {
132
- reg: /src=["']([^"\n]+)["']/i,
133
- replace: (match) => {
134
- return match[1];
135
- }
136
- }
137
- ];
138
- var getInsertOptions = (ctx, locale) => {
139
- const options = [
140
280
  {
141
- label: ["元素", "Elements"],
142
- key: "element",
143
- children: [
144
- {
145
- label: [(locale == null ? void 0 : locale.table) || "表格"],
146
- key: "table",
147
- task: "insertTable",
148
- icon: /* @__PURE__ */ React.createElement(TableOutlined, null)
149
- },
150
- {
151
- label: [(locale == null ? void 0 : locale.quote) || "引用"],
152
- key: "quote",
153
- task: "insertQuote",
154
- icon: /* @__PURE__ */ React.createElement(Quote, null)
155
- },
156
- {
157
- label: [(locale == null ? void 0 : locale.code) || "代码"],
158
- key: "code",
159
- task: "insertCode",
160
- icon: /* @__PURE__ */ React.createElement(CodeOutlined, null)
281
+ reg: /https?:\/\/youtu.be\/([\w-]+)(\?si=\w+)?/i,
282
+ replace: function(match) {
283
+ return "https://www.youtube.com/embed/".concat(match[1]).concat(match[2] || '');
161
284
  }
162
- ]
163
285
  },
164
286
  {
165
- label: ["媒体", "media"],
166
- key: "media",
167
- children: [
168
- {
169
- label: [(locale == null ? void 0 : locale.localeImage) || "本地图片"],
170
- task: "uploadImage",
171
- key: "localeImage",
172
- args: ["", true],
173
- icon: /* @__PURE__ */ React.createElement(ImageIcon, null)
287
+ reg: /https?:\/\/www.bilibili.com\/video\/([\w-]+)\/?/,
288
+ replace: function(match) {
289
+ return "https://player.bilibili.com/player.html?isOutside=true&bvid=".concat(match[1]);
174
290
  }
175
- ]
176
291
  },
177
292
  {
178
- label: ["列表", "List"],
179
- key: "list",
180
- children: [
181
- {
182
- label: [locale["b-list"] || "无序列表"],
183
- task: "list",
184
- key: "b-list",
185
- args: ["unordered"],
186
- icon: /* @__PURE__ */ React.createElement(UnorderedListOutlined, null)
187
- },
188
- {
189
- label: [locale["n-list"] || "有序列表"],
190
- task: "list",
191
- key: "n-list",
192
- args: ["ordered"],
193
- icon: /* @__PURE__ */ React.createElement(OrderedListOutlined, null)
194
- },
195
- {
196
- label: [locale["t-list"] || "任务列表"],
197
- task: "list",
198
- key: "t-list",
199
- args: ["task"],
200
- icon: /* @__PURE__ */ React.createElement(CheckSquareOutlined, null)
293
+ reg: /src=["']([^"\n]+)["']/i,
294
+ replace: function(match) {
295
+ return match[1];
201
296
  }
202
- ]
203
297
  }
204
- ];
205
- if (ctx.isTop) {
206
- options.splice(2, 0, {
207
- label: ["标题", "Heading"],
208
- key: "head",
209
- children: [
298
+ ];
299
+ export var getInsertOptions = function(ctx, locale) {
300
+ var options = [
210
301
  {
211
- label: [(locale == null ? void 0 : locale.head1) || "主标题"],
212
- task: "head",
213
- key: "head1",
214
- args: [1],
215
- icon: /* @__PURE__ */ React.createElement(FontSizeOutlined, null)
302
+ label: [
303
+ '元素',
304
+ 'Elements'
305
+ ],
306
+ key: 'element',
307
+ children: [
308
+ {
309
+ label: [
310
+ (locale === null || locale === void 0 ? void 0 : locale.table) || '表格'
311
+ ],
312
+ key: 'table',
313
+ task: 'insertTable',
314
+ icon: /*#__PURE__*/ React.createElement(TableOutlined, null)
315
+ },
316
+ {
317
+ label: [
318
+ (locale === null || locale === void 0 ? void 0 : locale.quote) || '引用'
319
+ ],
320
+ key: 'quote',
321
+ task: 'insertQuote',
322
+ icon: /*#__PURE__*/ React.createElement(Quote, null)
323
+ },
324
+ {
325
+ label: [
326
+ (locale === null || locale === void 0 ? void 0 : locale.code) || '代码'
327
+ ],
328
+ key: 'code',
329
+ task: 'insertCode',
330
+ icon: /*#__PURE__*/ React.createElement(CodeOutlined, null)
331
+ }
332
+ ]
216
333
  },
217
334
  {
218
- label: [(locale == null ? void 0 : locale.head2) || "段标题"],
219
- task: "head",
220
- key: "head2",
221
- icon: /* @__PURE__ */ React.createElement(FontSizeOutlined, null),
222
- args: [2]
335
+ label: [
336
+ '媒体',
337
+ 'media'
338
+ ],
339
+ key: 'media',
340
+ children: [
341
+ {
342
+ label: [
343
+ (locale === null || locale === void 0 ? void 0 : locale.localeImage) || '本地图片'
344
+ ],
345
+ task: 'uploadImage',
346
+ key: 'localeImage',
347
+ args: [
348
+ '',
349
+ true
350
+ ],
351
+ icon: /*#__PURE__*/ React.createElement(ImageIcon, null)
352
+ }
353
+ ]
223
354
  },
224
355
  {
225
- label: [(locale == null ? void 0 : locale.head3) || "小标题"],
226
- task: "head",
227
- key: "head3",
228
- icon: /* @__PURE__ */ React.createElement(FontSizeOutlined, null),
229
- args: [3]
356
+ label: [
357
+ '列表',
358
+ 'List'
359
+ ],
360
+ key: 'list',
361
+ children: [
362
+ {
363
+ label: [
364
+ locale['b-list'] || '无序列表'
365
+ ],
366
+ task: 'list',
367
+ key: 'b-list',
368
+ args: [
369
+ 'unordered'
370
+ ],
371
+ icon: /*#__PURE__*/ React.createElement(UnorderedListOutlined, null)
372
+ },
373
+ {
374
+ label: [
375
+ locale['n-list'] || '有序列表'
376
+ ],
377
+ task: 'list',
378
+ key: 'n-list',
379
+ args: [
380
+ 'ordered'
381
+ ],
382
+ icon: /*#__PURE__*/ React.createElement(OrderedListOutlined, null)
383
+ },
384
+ {
385
+ label: [
386
+ locale['t-list'] || '任务列表'
387
+ ],
388
+ task: 'list',
389
+ key: 't-list',
390
+ args: [
391
+ 'task'
392
+ ],
393
+ icon: /*#__PURE__*/ React.createElement(CheckSquareOutlined, null)
394
+ }
395
+ ]
230
396
  }
231
- ]
232
- });
233
- }
234
- return options;
235
- };
236
- var InsertAutocomplete = (props) => {
237
- var _a;
238
- const {
239
- markdownEditorRef,
240
- markdownContainerRef,
241
- openInsertCompletion,
242
- setOpenInsertCompletion,
243
- keyTask$,
244
- insertCompletionText$
245
- } = useEditorStore();
246
- const dom = useRef(null);
247
- const ctx = useRef({ path: [], isTop: true });
248
- const [state, setState] = useLocalState({
249
- index: 0,
250
- filterOptions: [],
251
- options: [],
252
- left: 0,
253
- insertLink: false,
254
- insertAttachment: false,
255
- loading: false,
256
- insertUrl: "",
257
- top: 0,
258
- bottom: 0,
259
- text: ""
260
- });
261
- const clickClose = useCallback((e) => {
262
- var _a2;
263
- if (!((_a2 = dom.current) == null ? void 0 : _a2.contains(e.target))) {
264
- close();
397
+ ];
398
+ if (ctx.isTop) {
399
+ options.splice(2, 0, {
400
+ label: [
401
+ '标题',
402
+ 'Heading'
403
+ ],
404
+ key: 'head',
405
+ children: [
406
+ {
407
+ label: [
408
+ (locale === null || locale === void 0 ? void 0 : locale.head1) || '主标题'
409
+ ],
410
+ task: 'head',
411
+ key: 'head1',
412
+ args: [
413
+ 1
414
+ ],
415
+ icon: /*#__PURE__*/ React.createElement(FontSizeOutlined, null)
416
+ },
417
+ {
418
+ label: [
419
+ (locale === null || locale === void 0 ? void 0 : locale.head2) || '段标题'
420
+ ],
421
+ task: 'head',
422
+ key: 'head2',
423
+ icon: /*#__PURE__*/ React.createElement(FontSizeOutlined, null),
424
+ args: [
425
+ 2
426
+ ]
427
+ },
428
+ {
429
+ label: [
430
+ (locale === null || locale === void 0 ? void 0 : locale.head3) || '小标题'
431
+ ],
432
+ task: 'head',
433
+ key: 'head3',
434
+ icon: /*#__PURE__*/ React.createElement(FontSizeOutlined, null),
435
+ args: [
436
+ 3
437
+ ]
438
+ }
439
+ ]
440
+ });
265
441
  }
266
- }, []);
267
- const close = useCallback(() => {
268
- setState({
269
- filterOptions: [],
270
- options: [],
271
- index: 0,
272
- text: "",
273
- insertLink: false,
274
- insertAttachment: false,
275
- insertUrl: ""
442
+ return options;
443
+ };
444
+ export var InsertAutocomplete = function(props) {
445
+ var _props_optionsRender;
446
+ var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, openInsertCompletion = _useEditorStore.openInsertCompletion, setOpenInsertCompletion = _useEditorStore.setOpenInsertCompletion, keyTask$ = _useEditorStore.keyTask$, insertCompletionText$ = _useEditorStore.insertCompletionText$;
447
+ var dom = useRef(null);
448
+ var ctx = useRef({
449
+ path: [],
450
+ isTop: true
276
451
  });
277
- if (typeof window === "undefined")
278
- return;
279
- window.removeEventListener("click", clickClose);
280
- }, []);
281
- const runInsertTask = useCallback(
282
- (op, params) => __async(void 0, null, function* () {
283
- var _a2;
284
- if (params == null ? void 0 : params.isCustom) {
285
- Transforms.delete(markdownEditorRef.current, {
286
- at: ctx.current.path
287
- });
288
- yield (_a2 = props.runInsertTask) == null ? void 0 : _a2.call(props, op, {
289
- x: state.left,
290
- y: state.top || state.bottom || 0
291
- });
292
- if (typeof window === "undefined")
293
- return;
294
- if (typeof window.matchMedia === "undefined")
295
- return;
296
- setOpenInsertCompletion == null ? void 0 : setOpenInsertCompletion(false);
297
- close();
298
- return;
299
- }
300
- if (op.task === "image" || op.task === "attachment") {
301
- if (op.task === "image") {
302
- setState({ insertLink: true });
303
- setTimeout(() => {
304
- var _a3, _b;
305
- (_b = (_a3 = dom.current) == null ? void 0 : _a3.querySelector("input")) == null ? void 0 : _b.focus();
306
- }, 30);
307
- } else {
308
- setState({ insertAttachment: true });
452
+ var _useLocalState = _sliced_to_array(useLocalState({
453
+ index: 0,
454
+ filterOptions: [],
455
+ options: [],
456
+ left: 0,
457
+ insertLink: false,
458
+ insertAttachment: false,
459
+ loading: false,
460
+ insertUrl: '',
461
+ top: 0,
462
+ bottom: 0,
463
+ text: ''
464
+ }), 2), state = _useLocalState[0], setState = _useLocalState[1];
465
+ var clickClose = useCallback(function(e) {
466
+ var _dom_current;
467
+ if (!((_dom_current = dom.current) === null || _dom_current === void 0 ? void 0 : _dom_current.contains(e.target))) {
468
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
469
+ close();
309
470
  }
310
- } else if (op) {
311
- Transforms.insertText(markdownEditorRef.current, "", {
312
- at: {
313
- anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
314
- focus: Editor.end(markdownEditorRef.current, ctx.current.path)
315
- }
471
+ }, []);
472
+ var close = useCallback(function() {
473
+ setState({
474
+ filterOptions: [],
475
+ options: [],
476
+ index: 0,
477
+ text: '',
478
+ insertLink: false,
479
+ insertAttachment: false,
480
+ insertUrl: ''
316
481
  });
317
- keyTask$.next({
318
- key: op.task,
319
- args: op.args
482
+ if (typeof window === 'undefined') return;
483
+ window.removeEventListener('click', clickClose);
484
+ }, []);
485
+ var runInsertTask = useCallback(/*#__PURE__*/ function() {
486
+ var _ref = _async_to_generator(function(op, params) {
487
+ var _props_runInsertTask;
488
+ return _ts_generator(this, function(_state) {
489
+ switch(_state.label){
490
+ case 0:
491
+ if (!(params === null || params === void 0 ? void 0 : params.isCustom)) return [
492
+ 3,
493
+ 2
494
+ ];
495
+ Transforms.delete(markdownEditorRef.current, {
496
+ at: ctx.current.path
497
+ });
498
+ return [
499
+ 4,
500
+ (_props_runInsertTask = props.runInsertTask) === null || _props_runInsertTask === void 0 ? void 0 : _props_runInsertTask.call(props, op, {
501
+ x: state.left,
502
+ y: state.top || state.bottom || 0
503
+ })
504
+ ];
505
+ case 1:
506
+ _state.sent();
507
+ if (typeof window === 'undefined') return [
508
+ 2
509
+ ];
510
+ if (typeof window.matchMedia === 'undefined') return [
511
+ 2
512
+ ];
513
+ setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(false);
514
+ close();
515
+ return [
516
+ 2
517
+ ];
518
+ case 2:
519
+ //@ts-ignore
520
+ if (op.task === 'image' || op.task === 'attachment') {
521
+ //@ts-ignore
522
+ if (op.task === 'image') {
523
+ setState({
524
+ insertLink: true
525
+ });
526
+ setTimeout(function() {
527
+ var _dom_current_querySelector, _dom_current;
528
+ (_dom_current = dom.current) === null || _dom_current === void 0 ? void 0 : (_dom_current_querySelector = _dom_current.querySelector('input')) === null || _dom_current_querySelector === void 0 ? void 0 : _dom_current_querySelector.focus();
529
+ }, 30);
530
+ } else {
531
+ setState({
532
+ insertAttachment: true
533
+ });
534
+ }
535
+ } else if (op) {
536
+ Transforms.insertText(markdownEditorRef.current, '', {
537
+ at: {
538
+ anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
539
+ focus: Editor.end(markdownEditorRef.current, ctx.current.path)
540
+ }
541
+ });
542
+ keyTask$.next({
543
+ key: op.task,
544
+ args: op.args
545
+ });
546
+ if (typeof window === 'undefined') return [
547
+ 2
548
+ ];
549
+ if (typeof window.matchMedia === 'undefined') return [
550
+ 2
551
+ ];
552
+ setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(false);
553
+ close();
554
+ }
555
+ return [
556
+ 2
557
+ ];
558
+ }
559
+ });
320
560
  });
321
- if (typeof window === "undefined")
322
- return;
323
- if (typeof window.matchMedia === "undefined")
324
- return;
325
- setOpenInsertCompletion == null ? void 0 : setOpenInsertCompletion(false);
326
- close();
327
- }
328
- }),
329
- []
330
- );
331
- const insertAttachByLink = useCallback(() => __async(void 0, null, function* () {
332
- setState({ loading: true });
333
- try {
334
- let url = state.insertUrl;
335
- let size = 0;
336
- let name = url;
337
- if (/^https?:\/\//.test(url)) {
338
- const res = yield fetch(url);
339
- if (!res.ok) {
340
- throw new Error();
341
- }
342
- size = Number(res.headers.get("content-length") || 0);
343
- const match = url.match(/([\w_-]+)\.\w+$/);
344
- if (match) {
345
- name = match[1];
561
+ return function(op, params) {
562
+ return _ref.apply(this, arguments);
563
+ };
564
+ }(), []);
565
+ var insertAttachByLink = useCallback(/*#__PURE__*/ _async_to_generator(function() {
566
+ var url, size, name, res, match, node, next, _Editor_nodes, m;
567
+ return _ts_generator(this, function(_state) {
568
+ switch(_state.label){
569
+ case 0:
570
+ setState({
571
+ loading: true
572
+ });
573
+ _state.label = 1;
574
+ case 1:
575
+ _state.trys.push([
576
+ 1,
577
+ ,
578
+ 4,
579
+ 5
580
+ ]);
581
+ url = state.insertUrl;
582
+ size = 0;
583
+ name = url;
584
+ if (!/^https?:\/\//.test(url)) return [
585
+ 3,
586
+ 3
587
+ ];
588
+ return [
589
+ 4,
590
+ fetch(url)
591
+ ];
592
+ case 2:
593
+ res = _state.sent();
594
+ if (!res.ok) {
595
+ throw new Error();
596
+ }
597
+ size = Number(res.headers.get('content-length') || 0);
598
+ match = url.match(/([\w_-]+)\.\w+$/);
599
+ if (match) {
600
+ name = match[1];
601
+ }
602
+ _state.label = 3;
603
+ case 3:
604
+ Transforms.insertText(markdownEditorRef.current, '', {
605
+ at: {
606
+ anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
607
+ focus: Editor.end(markdownEditorRef.current, ctx.current.path)
608
+ }
609
+ });
610
+ node = {
611
+ type: 'attach',
612
+ name: name,
613
+ url: url,
614
+ size: size,
615
+ children: [
616
+ {
617
+ text: ''
618
+ }
619
+ ]
620
+ };
621
+ Transforms.setNodes(markdownEditorRef.current, node, {
622
+ at: ctx.current.path
623
+ });
624
+ EditorUtils.focus(markdownEditorRef.current);
625
+ next = Editor.next(markdownEditorRef.current, {
626
+ at: ctx.current.path
627
+ });
628
+ if ((next === null || next === void 0 ? void 0 : next[0].type) === 'paragraph' && !Node.string(next[0])) {
629
+ Transforms.delete(markdownEditorRef.current, {
630
+ at: next[1]
631
+ });
632
+ }
633
+ _Editor_nodes = _sliced_to_array(Editor.nodes(markdownEditorRef.current, {
634
+ match: function(n) {
635
+ return !!n.type;
636
+ },
637
+ mode: 'lowest'
638
+ }), 1), m = _Editor_nodes[0];
639
+ selChange$.next({
640
+ node: m,
641
+ sel: markdownEditorRef.current.selection
642
+ });
643
+ close();
644
+ return [
645
+ 3,
646
+ 5
647
+ ];
648
+ case 4:
649
+ setState({
650
+ loading: false
651
+ });
652
+ return [
653
+ 7
654
+ ];
655
+ case 5:
656
+ return [
657
+ 2
658
+ ];
659
+ }
660
+ });
661
+ }), []);
662
+ var keydown = useCallback(function(e) {
663
+ if (state.options.length && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
664
+ e.preventDefault();
665
+ if (e.key === 'ArrowUp' && state.index > 0) {
666
+ setState({
667
+ index: state.index - 1
668
+ });
669
+ var key = state.options[state.index].key;
670
+ var target = document.querySelector('[data-action="'.concat(key, '"]'));
671
+ if (target && dom.current.scrollTop > target.offsetTop) {
672
+ dom.current.scroll({
673
+ top: dom.current.scrollTop - 160 + 30
674
+ });
675
+ }
676
+ }
677
+ if (e.key === 'ArrowDown' && state.index < state.options.length - 1) {
678
+ setState({
679
+ index: state.index + 1
680
+ });
681
+ var key1 = state.options[state.index].key;
682
+ var target1 = document.querySelector('[data-action="'.concat(key1, '"]'));
683
+ if (target1 && target1.offsetTop > dom.current.scrollTop + dom.current.clientHeight - 30) {
684
+ dom.current.scroll({
685
+ top: target1.offsetTop - 30
686
+ });
687
+ }
688
+ }
346
689
  }
347
- }
348
- Transforms.insertText(markdownEditorRef.current, "", {
349
- at: {
350
- anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
351
- focus: Editor.end(markdownEditorRef.current, ctx.current.path)
690
+ if (e.key === 'Enter' && openInsertCompletion) {
691
+ var op = state.options[state.index];
692
+ if (op) {
693
+ e.preventDefault();
694
+ e.stopPropagation();
695
+ runInsertTask(op);
696
+ }
352
697
  }
353
- });
354
- const node = {
355
- type: "attach",
356
- name,
357
- url,
358
- size,
359
- children: [{ text: "" }]
360
- };
361
- Transforms.setNodes(markdownEditorRef.current, node, {
362
- at: ctx.current.path
363
- });
364
- EditorUtils.focus(markdownEditorRef.current);
365
- const next = Editor.next(markdownEditorRef.current, {
366
- at: ctx.current.path
367
- });
368
- if ((next == null ? void 0 : next[0].type) === "paragraph" && !Node.string(next[0])) {
369
- Transforms.delete(markdownEditorRef.current, { at: next[1] });
370
- }
371
- const [m] = Editor.nodes(markdownEditorRef.current, {
372
- match: (n) => !!n.type,
373
- mode: "lowest"
374
- });
375
- selChange$.next({ node: m, sel: markdownEditorRef.current.selection });
376
- close();
377
- } finally {
378
- setState({ loading: false });
379
- }
380
- }), []);
381
- const keydown = useCallback((e) => {
382
- if (state.options.length && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
383
- e.preventDefault();
384
- if (e.key === "ArrowUp" && state.index > 0) {
385
- setState({ index: state.index - 1 });
386
- const key = state.options[state.index].key;
387
- const target = document.querySelector(
388
- `[data-action="${key}"]`
389
- );
390
- if (target && dom.current.scrollTop > target.offsetTop) {
391
- dom.current.scroll({
392
- top: dom.current.scrollTop - 160 + 30
393
- });
698
+ if (isHotkey('esc', e)) {
699
+ setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(false);
700
+ EditorUtils.focus(markdownEditorRef.current);
394
701
  }
395
- }
396
- if (e.key === "ArrowDown" && state.index < state.options.length - 1) {
397
- setState({ index: state.index + 1 });
398
- const key = state.options[state.index].key;
399
- const target = document.querySelector(
400
- `[data-action="${key}"]`
401
- );
402
- if (target && target.offsetTop > dom.current.scrollTop + dom.current.clientHeight - 30) {
403
- dom.current.scroll({
404
- top: target.offsetTop - 30
405
- });
702
+ if (isHotkey('backspace', e)) {
703
+ setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(false);
704
+ EditorUtils.focus(markdownEditorRef.current);
406
705
  }
407
- }
408
- }
409
- if (e.key === "Enter" && openInsertCompletion) {
410
- const op = state.options[state.index];
411
- if (op) {
412
- e.preventDefault();
413
- e.stopPropagation();
414
- runInsertTask(op);
415
- }
416
- }
417
- if (isHotkey("esc", e)) {
418
- setOpenInsertCompletion == null ? void 0 : setOpenInsertCompletion(false);
419
- EditorUtils.focus(markdownEditorRef.current);
420
- }
421
- if (isHotkey("backspace", e)) {
422
- setOpenInsertCompletion == null ? void 0 : setOpenInsertCompletion(false);
423
- EditorUtils.focus(markdownEditorRef.current);
424
- }
425
- }, []);
426
- const i18n = useContext(I18nContext);
427
- const insertOptions = useMemo(() => {
428
- return getInsertOptions(
429
- {
430
- isTop: ctx.current.isTop
431
- },
432
- i18n.locale
433
- );
434
- }, [i18n.locale, ctx.current.isTop]);
435
- const insertMedia = useCallback(() => __async(void 0, null, function* () {
436
- setState({ loading: true });
437
- try {
438
- let url = state.insertUrl;
439
- for (const r of replaceUrl) {
440
- const m = url.match(r.reg);
441
- if (m) {
442
- url = r.replace(m);
443
- break;
706
+ }, []);
707
+ var i18n = useContext(I18nContext);
708
+ var insertOptions = useMemo(function() {
709
+ return getInsertOptions({
710
+ isTop: ctx.current.isTop
711
+ }, i18n.locale);
712
+ }, [
713
+ i18n.locale,
714
+ ctx.current.isTop
715
+ ]);
716
+ /**
717
+ * 插入媒体
718
+ */ var insertMedia = useCallback(/*#__PURE__*/ _async_to_generator(function() {
719
+ var url, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, r, m, type, node, _Editor_nodes, n;
720
+ return _ts_generator(this, function(_state) {
721
+ switch(_state.label){
722
+ case 0:
723
+ setState({
724
+ loading: true
725
+ });
726
+ _state.label = 1;
727
+ case 1:
728
+ _state.trys.push([
729
+ 1,
730
+ ,
731
+ 3,
732
+ 4
733
+ ]);
734
+ url = state.insertUrl;
735
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
736
+ try {
737
+ for(_iterator = replaceUrl[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
738
+ r = _step.value;
739
+ m = url.match(r.reg);
740
+ if (m) {
741
+ url = r.replace(m);
742
+ break;
743
+ }
744
+ }
745
+ } catch (err) {
746
+ _didIteratorError = true;
747
+ _iteratorError = err;
748
+ } finally{
749
+ try {
750
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
751
+ _iterator.return();
752
+ }
753
+ } finally{
754
+ if (_didIteratorError) {
755
+ throw _iteratorError;
756
+ }
757
+ }
758
+ }
759
+ if (!/^(\w+:)?\/\//.test(url)) {
760
+ throw new Error();
761
+ }
762
+ return [
763
+ 4,
764
+ getRemoteMediaType(url)
765
+ ];
766
+ case 2:
767
+ type = _state.sent();
768
+ if (!type) {
769
+ throw new Error();
770
+ }
771
+ Transforms.insertText(markdownEditorRef.current, '', {
772
+ at: {
773
+ anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
774
+ focus: Editor.end(markdownEditorRef.current, ctx.current.path)
775
+ }
776
+ });
777
+ node = EditorUtils.createMediaNode(url, 'image', {});
778
+ Transforms.setNodes(markdownEditorRef.current, node, {
779
+ at: ctx.current.path
780
+ });
781
+ EditorUtils.focus(markdownEditorRef.current);
782
+ _Editor_nodes = _sliced_to_array(Editor.nodes(markdownEditorRef.current, {
783
+ match: function(n) {
784
+ return !!n.type;
785
+ },
786
+ mode: 'lowest'
787
+ }), 1), n = _Editor_nodes[0];
788
+ selChange$.next({
789
+ sel: markdownEditorRef.current.selection,
790
+ node: n
791
+ });
792
+ close();
793
+ return [
794
+ 3,
795
+ 4
796
+ ];
797
+ case 3:
798
+ setState({
799
+ loading: false
800
+ });
801
+ return [
802
+ 7
803
+ ];
804
+ case 4:
805
+ return [
806
+ 2
807
+ ];
808
+ }
809
+ });
810
+ }), []);
811
+ useSubject(insertCompletionText$, function(text) {
812
+ var _props_insertOptions;
813
+ var tempText = text || '';
814
+ var filterOptions = [];
815
+ var options = [];
816
+ if (tempText) {
817
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
818
+ try {
819
+ for(var _iterator = insertOptions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
820
+ var item = _step.value;
821
+ var _options;
822
+ var ops = item.children.filter(function(op) {
823
+ return op.label.some(function(l) {
824
+ return l.toLowerCase().includes(tempText.toLowerCase());
825
+ });
826
+ });
827
+ (_options = options).push.apply(_options, _to_consumable_array(ops));
828
+ if (ops.length) {
829
+ filterOptions.push(_object_spread_props(_object_spread({}, item), {
830
+ children: ops
831
+ }));
832
+ }
833
+ }
834
+ } catch (err) {
835
+ _didIteratorError = true;
836
+ _iteratorError = err;
837
+ } finally{
838
+ try {
839
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
840
+ _iterator.return();
841
+ }
842
+ } finally{
843
+ if (_didIteratorError) {
844
+ throw _iteratorError;
845
+ }
846
+ }
847
+ }
848
+ } else {
849
+ filterOptions = insertOptions;
850
+ options = insertOptions.reduce(function(a, b) {
851
+ return a.concat(b.children);
852
+ }, []);
444
853
  }
445
- }
446
- if (!/^(\w+:)?\/\//.test(url)) {
447
- throw new Error();
448
- }
449
- const type = yield getRemoteMediaType(url);
450
- if (!type) {
451
- throw new Error();
452
- }
453
- Transforms.insertText(markdownEditorRef.current, "", {
454
- at: {
455
- anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
456
- focus: Editor.end(markdownEditorRef.current, ctx.current.path)
854
+ if (props.insertOptions && (props === null || props === void 0 ? void 0 : (_props_insertOptions = props.insertOptions) === null || _props_insertOptions === void 0 ? void 0 : _props_insertOptions.length)) {
855
+ filterOptions.unshift({
856
+ label: [
857
+ '快捷设置',
858
+ 'My Quick'
859
+ ],
860
+ key: 'quick',
861
+ children: _to_consumable_array(props.insertOptions)
862
+ });
457
863
  }
458
- });
459
- const node = EditorUtils.createMediaNode(url, "image", {});
460
- Transforms.setNodes(markdownEditorRef.current, node, {
461
- at: ctx.current.path
462
- });
463
- EditorUtils.focus(markdownEditorRef.current);
464
- const [n] = Editor.nodes(markdownEditorRef.current, {
465
- match: (n2) => !!n2.type,
466
- mode: "lowest"
467
- });
468
- selChange$.next({
469
- sel: markdownEditorRef.current.selection,
470
- node: n
471
- });
472
- close();
473
- } finally {
474
- setState({ loading: false });
475
- }
476
- }), []);
477
- useSubject(insertCompletionText$, (text) => {
478
- var _a2;
479
- let tempText = text || "";
480
- let filterOptions = [];
481
- let options = [];
482
- if (tempText) {
483
- for (let item of insertOptions) {
484
- const ops = item.children.filter((op) => {
485
- return op.label.some(
486
- (l) => l.toLowerCase().includes(tempText.toLowerCase())
487
- );
864
+ setState({
865
+ index: 0,
866
+ text: tempText,
867
+ options: options,
868
+ filterOptions: filterOptions
488
869
  });
489
- options.push(...ops);
490
- if (ops.length) {
491
- filterOptions.push(__spreadProps(__spreadValues({}, item), {
492
- children: ops
493
- }));
494
- }
495
- }
496
- } else {
497
- filterOptions = insertOptions;
498
- options = insertOptions.reduce(
499
- (a, b) => a.concat(b.children),
500
- []
501
- );
502
- }
503
- if (props.insertOptions && ((_a2 = props == null ? void 0 : props.insertOptions) == null ? void 0 : _a2.length)) {
504
- filterOptions.unshift({
505
- label: ["快捷设置", "My Quick"],
506
- key: "quick",
507
- children: [...props.insertOptions]
508
- });
509
- }
510
- setState({
511
- index: 0,
512
- text: tempText,
513
- options,
514
- filterOptions
515
870
  });
516
- });
517
- useEffect(() => {
518
- var _a2;
519
- const calculatePosition = (nodeEl, containerEl) => {
520
- const top = nodeEl.getBoundingClientRect().top;
521
- const left = getOffsetLeft(nodeEl, containerEl) + 24;
522
- const containerScrollTop = containerEl.scrollTop;
523
- const containerHeight = document.documentElement.clientHeight;
524
- const nodeHeight = nodeEl.clientHeight;
525
- const nodeTopRelativeToContainer = top - containerScrollTop;
526
- const nodeBottomRelativeToContainer = nodeTopRelativeToContainer + nodeHeight;
527
- const spaceAbove = nodeTopRelativeToContainer;
528
- const spaceBelow = containerHeight - nodeBottomRelativeToContainer;
529
- if (spaceBelow < 212 && spaceAbove < 212) {
530
- return {
531
- top: void 0,
532
- bottom: 0,
533
- left
534
- };
535
- }
536
- if (spaceBelow < 212 && spaceAbove >= 212) {
537
- return {
538
- top: void 0,
539
- bottom: containerHeight - nodeTopRelativeToContainer,
540
- left
871
+ useEffect(function() {
872
+ var calculatePosition = function(nodeEl, containerEl) {
873
+ var top = nodeEl.getBoundingClientRect().top;
874
+ var left = getOffsetLeft(nodeEl, containerEl) + 24;
875
+ var containerScrollTop = containerEl.scrollTop;
876
+ var containerHeight = document.documentElement.clientHeight;
877
+ var nodeHeight = nodeEl.clientHeight;
878
+ var nodeTopRelativeToContainer = top - containerScrollTop;
879
+ var nodeBottomRelativeToContainer = nodeTopRelativeToContainer + nodeHeight;
880
+ var spaceAbove = nodeTopRelativeToContainer;
881
+ var spaceBelow = containerHeight - nodeBottomRelativeToContainer;
882
+ // 当节点上方空间不足,且下方空间不足时,触底显示
883
+ if (spaceBelow < 212 && spaceAbove < 212) {
884
+ return {
885
+ top: undefined,
886
+ bottom: 0,
887
+ left: left
888
+ };
889
+ }
890
+ // 如果节点下方空间不足但上方有足够空间,显示在上方
891
+ if (spaceBelow < 212 && spaceAbove >= 212) {
892
+ return {
893
+ top: undefined,
894
+ bottom: containerHeight - nodeTopRelativeToContainer,
895
+ left: left
896
+ };
897
+ }
898
+ // 默认逻辑,优先显示在下方
899
+ if (spaceBelow >= 212) {
900
+ return {
901
+ top: nodeBottomRelativeToContainer,
902
+ bottom: undefined,
903
+ left: left
904
+ };
905
+ }
906
+ return undefined;
541
907
  };
542
- }
543
- if (spaceBelow >= 212) {
544
- return {
545
- top: nodeBottomRelativeToContainer,
546
- bottom: void 0,
547
- left
908
+ var setupEventListeners = function() {
909
+ var _markdownContainerRef_current, _markdownContainerRef_current1;
910
+ if (typeof window === 'undefined') return;
911
+ markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.addEventListener('keydown', keydown);
912
+ markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current1 = markdownContainerRef.current) === null || _markdownContainerRef_current1 === void 0 ? void 0 : _markdownContainerRef_current1.addEventListener('click', clickClose);
548
913
  };
549
- }
550
- return void 0;
551
- };
552
- const setupEventListeners = () => {
553
- var _a3, _b;
554
- if (typeof window === "undefined")
555
- return;
556
- (_a3 = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _a3.addEventListener("keydown", keydown);
557
- (_b = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _b.addEventListener("click", clickClose);
558
- };
559
- const removeEventListeners = () => {
560
- var _a3, _b;
561
- if (typeof window === "undefined")
562
- return;
563
- (_a3 = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _a3.removeEventListener("keydown", keydown);
564
- (_b = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _b.removeEventListener("click", clickClose);
565
- };
566
- if (openInsertCompletion) {
567
- const [node] = Editor.nodes(markdownEditorRef.current, {
568
- match: (n) => Element.isElement(n),
569
- mode: "lowest"
570
- });
571
- if (node) {
572
- ctx.current = {
573
- path: node[1],
574
- isTop: EditorUtils.isTop(markdownEditorRef.current, node[1])
914
+ var removeEventListeners = function() {
915
+ var _markdownContainerRef_current, _markdownContainerRef_current1;
916
+ if (typeof window === 'undefined') return;
917
+ markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.removeEventListener('keydown', keydown);
918
+ markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current1 = markdownContainerRef.current) === null || _markdownContainerRef_current1 === void 0 ? void 0 : _markdownContainerRef_current1.removeEventListener('click', clickClose);
575
919
  };
576
- if (((_a2 = node == null ? void 0 : node[0]) == null ? void 0 : _a2.type) === "paragraph") {
577
- const el = ReactEditor.toDOMNode(markdownEditorRef.current, node[0]);
578
- if (el) {
579
- const position = calculatePosition(el, document.body);
580
- if (position) {
581
- setState(position);
582
- } else {
583
- setState({ top: 0, left: 0, bottom: void 0 });
920
+ if (openInsertCompletion) {
921
+ var _Editor_nodes = _sliced_to_array(Editor.nodes(markdownEditorRef.current, {
922
+ match: function(n) {
923
+ return Element.isElement(n);
924
+ },
925
+ mode: 'lowest'
926
+ }), 1), node = _Editor_nodes[0];
927
+ if (node) {
928
+ var _node_;
929
+ ctx.current = {
930
+ path: node[1],
931
+ isTop: EditorUtils.isTop(markdownEditorRef.current, node[1])
932
+ };
933
+ if ((node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type) === 'paragraph') {
934
+ var el = ReactEditor.toDOMNode(markdownEditorRef.current, node[0]);
935
+ if (el) {
936
+ var position = calculatePosition(el, document.body);
937
+ if (position) {
938
+ setState(position);
939
+ } else {
940
+ setState({
941
+ top: 0,
942
+ left: 0,
943
+ bottom: undefined
944
+ });
945
+ }
946
+ }
947
+ }
948
+ setupEventListeners();
949
+ setTimeout(function() {
950
+ var _dom_current;
951
+ (_dom_current = dom.current) === null || _dom_current === void 0 ? void 0 : _dom_current.scroll({
952
+ top: 0
953
+ });
954
+ });
584
955
  }
585
- }
956
+ } else {
957
+ removeEventListeners();
958
+ close();
586
959
  }
587
- setupEventListeners();
588
- setTimeout(() => {
589
- var _a3;
590
- (_a3 = dom.current) == null ? void 0 : _a3.scroll({ top: 0 });
591
- });
592
- }
593
- } else {
594
- removeEventListeners();
595
- close();
596
- }
597
- return () => {
598
- removeEventListeners();
599
- };
600
- }, [openInsertCompletion]);
601
- const context = useContext(ConfigProvider.ConfigContext);
602
- const baseClassName = context == null ? void 0 : context.getPrefixCls(`md-editor-insert-autocomplete`);
603
- const { wrapSSR, hashId } = useStyle(baseClassName);
604
- return ReactDOM.createPortal(
605
- wrapSSR(
606
- /* @__PURE__ */ React.createElement(
607
- "div",
608
- {
609
- ref: dom,
610
- className: classNames(baseClassName, hashId),
611
- style: {
612
- position: "absolute",
960
+ return function() {
961
+ removeEventListeners();
962
+ };
963
+ }, [
964
+ openInsertCompletion
965
+ ]);
966
+ var context = useContext(ConfigProvider.ConfigContext);
967
+ var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls("md-editor-insert-autocomplete");
968
+ var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
969
+ return /*#__PURE__*/ ReactDOM.createPortal(wrapSSR(/*#__PURE__*/ React.createElement("div", {
970
+ ref: dom,
971
+ className: classNames(baseClassName, hashId),
972
+ style: {
973
+ position: 'absolute',
613
974
  zIndex: 9999,
614
- display: !openInsertCompletion || !state.filterOptions.length ? "none" : "flex",
615
- width: state.insertLink || state.insertAttachment ? 320 : void 0,
975
+ display: !openInsertCompletion || !state.filterOptions.length ? 'none' : 'flex',
976
+ width: state.insertLink || state.insertAttachment ? 320 : undefined,
616
977
  maxHeight: 212,
617
- overflowY: "auto",
978
+ overflowY: 'auto',
618
979
  left: state.left,
619
980
  top: state.top,
620
981
  bottom: state.bottom
621
- },
622
- onMouseDown: (e) => {
623
- e.preventDefault();
624
- }
625
982
  },
626
- !state.insertLink && !state.insertAttachment && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
627
- Menu,
628
- {
629
- items: (_a = props.optionsRender) == null ? void 0 : _a.call(
630
- props,
631
- state.filterOptions.map((l) => {
632
- var _a2, _b, _c, _d;
633
- return {
634
- label: (_a2 = l == null ? void 0 : l.label) == null ? void 0 : _a2[1],
635
- key: l == null ? void 0 : l.key,
636
- icon: (_c = (_b = l == null ? void 0 : l.children) == null ? void 0 : _b[0]) == null ? void 0 : _c.icon,
637
- children: (_d = l == null ? void 0 : l.children) == null ? void 0 : _d.map((el) => {
638
- var _a3;
983
+ onMouseDown: function(e) {
984
+ e.preventDefault();
985
+ }
986
+ }, !state.insertLink && !state.insertAttachment && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Menu, {
987
+ items: (_props_optionsRender = props.optionsRender) === null || _props_optionsRender === void 0 ? void 0 : _props_optionsRender.call(props, state.filterOptions.map(function(l) {
988
+ var _l_label, _l_children_, _l_children, _l_children1;
989
+ return {
990
+ label: l === null || l === void 0 ? void 0 : (_l_label = l.label) === null || _l_label === void 0 ? void 0 : _l_label[1],
991
+ key: l === null || l === void 0 ? void 0 : l.key,
992
+ icon: l === null || l === void 0 ? void 0 : (_l_children = l.children) === null || _l_children === void 0 ? void 0 : (_l_children_ = _l_children[0]) === null || _l_children_ === void 0 ? void 0 : _l_children_.icon,
993
+ children: l === null || l === void 0 ? void 0 : (_l_children1 = l.children) === null || _l_children1 === void 0 ? void 0 : _l_children1.map(function(el) {
994
+ var _el_label;
639
995
  return {
640
- label: (_a3 = el.label) == null ? void 0 : _a3[1],
641
- key: el.key,
642
- icon: el.icon,
643
- onClick: (_) => {
644
- var _a4, _b2;
645
- _.domEvent.stopPropagation();
646
- _.domEvent.preventDefault();
647
- const task = insertOptions.map((o) => o == null ? void 0 : o.children).flat(1).find((o) => {
648
- return o.key === el.key;
649
- });
650
- const myInsertOptions = (_b2 = (_a4 = props == null ? void 0 : props.insertOptions) == null ? void 0 : _a4.find) == null ? void 0 : _b2.call(
651
- _a4,
652
- (o) => o.key === el.key
653
- );
654
- if (myInsertOptions) {
655
- runInsertTask(myInsertOptions, {
656
- isCustom: true
657
- });
658
- return;
659
- }
660
- if (task) {
661
- runInsertTask(task);
996
+ label: (_el_label = el.label) === null || _el_label === void 0 ? void 0 : _el_label[1],
997
+ key: el.key,
998
+ icon: el.icon,
999
+ onClick: function(_) {
1000
+ var _props_insertOptions_find, _props_insertOptions;
1001
+ _.domEvent.stopPropagation();
1002
+ _.domEvent.preventDefault();
1003
+ var task = insertOptions.map(function(o) {
1004
+ return o === null || o === void 0 ? void 0 : o.children;
1005
+ }).flat(1).find(function(o) {
1006
+ return o.key === el.key;
1007
+ });
1008
+ var myInsertOptions = props === null || props === void 0 ? void 0 : (_props_insertOptions = props.insertOptions) === null || _props_insertOptions === void 0 ? void 0 : (_props_insertOptions_find = _props_insertOptions.find) === null || _props_insertOptions_find === void 0 ? void 0 : _props_insertOptions_find.call(_props_insertOptions, function(o) {
1009
+ return o.key === el.key;
1010
+ });
1011
+ if (myInsertOptions) {
1012
+ runInsertTask(myInsertOptions, {
1013
+ isCustom: true
1014
+ });
1015
+ return;
1016
+ }
1017
+ if (task) {
1018
+ runInsertTask(task);
1019
+ }
662
1020
  }
663
- }
664
1021
  };
665
- })
666
- };
667
- }).map((l) => {
668
- return l == null ? void 0 : l.children;
669
- }).flat(1) || []
670
- )
671
- }
672
- )),
673
- state.insertLink && /* @__PURE__ */ React.createElement(
674
- "div",
675
- {
676
- style: {
677
- padding: 8
678
- }
679
- },
680
- /* @__PURE__ */ React.createElement(
681
- "div",
682
- {
683
- style: {
684
- fontSize: "1em",
685
- color: "rgba(0,0,0,0.8)",
686
- marginBottom: 4,
687
- display: "flex",
688
- alignContent: "center",
689
- gap: 4
690
- }
691
- },
692
- /* @__PURE__ */ React.createElement(PlayCircleOutlined, null),
693
- /* @__PURE__ */ React.createElement("span", null, "Embed media links")
694
- ),
695
- /* @__PURE__ */ React.createElement(
696
- Input,
697
- {
698
- placeholder: "Paste media link",
699
- onMouseDown: (e) => e.stopPropagation(),
700
- value: state.insertUrl,
701
- onKeyDown: (e) => {
702
- if (isHotkey("enter", e)) {
703
- insertMedia();
704
- }
705
- },
706
- onChange: (e) => setState({ insertUrl: e.target.value })
707
- }
708
- ),
709
- /* @__PURE__ */ React.createElement(
710
- Button,
711
- {
712
- block: true,
713
- loading: state.loading,
714
- type: "primary",
715
- size: "small",
716
- style: {
717
- marginTop: "1em"
718
- },
719
- onClick: insertMedia,
720
- disabled: !state.insertUrl
721
- },
722
- "Embed"
723
- )
724
- ),
725
- state.insertAttachment && /* @__PURE__ */ React.createElement(
726
- "div",
727
- {
728
- style: {
729
- width: 320,
730
- padding: 8
1022
+ })
1023
+ };
1024
+ }).map(function(l) {
1025
+ return l === null || l === void 0 ? void 0 : l.children;
1026
+ }).flat(1) || [])
1027
+ })), state.insertLink && /*#__PURE__*/ React.createElement("div", {
1028
+ style: {
1029
+ padding: 8
1030
+ }
1031
+ }, /*#__PURE__*/ React.createElement("div", {
1032
+ style: {
1033
+ fontSize: '1em',
1034
+ color: 'rgba(0,0,0,0.8)',
1035
+ marginBottom: 4,
1036
+ display: 'flex',
1037
+ alignContent: 'center',
1038
+ gap: 4
1039
+ }
1040
+ }, /*#__PURE__*/ React.createElement(PlayCircleOutlined, null), /*#__PURE__*/ React.createElement("span", null, "Embed media links")), /*#__PURE__*/ React.createElement(Input, {
1041
+ placeholder: 'Paste media link',
1042
+ onMouseDown: function(e) {
1043
+ return e.stopPropagation();
1044
+ },
1045
+ value: state.insertUrl,
1046
+ onKeyDown: function(e) {
1047
+ if (isHotkey('enter', e)) {
1048
+ insertMedia();
731
1049
  }
732
- },
733
- /* @__PURE__ */ React.createElement(
734
- Tabs,
1050
+ },
1051
+ onChange: function(e) {
1052
+ return setState({
1053
+ insertUrl: e.target.value
1054
+ });
1055
+ }
1056
+ }), /*#__PURE__*/ React.createElement(Button, {
1057
+ block: true,
1058
+ loading: state.loading,
1059
+ type: 'primary',
1060
+ size: 'small',
1061
+ style: {
1062
+ marginTop: '1em'
1063
+ },
1064
+ onClick: insertMedia,
1065
+ disabled: !state.insertUrl
1066
+ }, "Embed")), state.insertAttachment && /*#__PURE__*/ React.createElement("div", {
1067
+ style: {
1068
+ width: 320,
1069
+ padding: 8
1070
+ }
1071
+ }, /*#__PURE__*/ React.createElement(Tabs, {
1072
+ size: 'small',
1073
+ items: [
735
1074
  {
736
- size: "small",
737
- items: [
738
- {
739
- label: "Local",
740
- key: "local",
741
- children: /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
742
- Button,
743
- {
744
- block: true,
745
- size: "small",
746
- type: "primary",
747
- onClick: () => {
748
- Transforms.insertText(markdownEditorRef.current, "", {
749
- at: {
750
- anchor: Editor.start(
751
- markdownEditorRef.current,
752
- ctx.current.path
753
- ),
754
- focus: Editor.end(
755
- markdownEditorRef.current,
756
- ctx.current.path
757
- )
758
- }
1075
+ label: 'Local',
1076
+ key: 'local',
1077
+ children: /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(Button, {
1078
+ block: true,
1079
+ size: 'small',
1080
+ type: 'primary',
1081
+ onClick: function() {
1082
+ Transforms.insertText(markdownEditorRef.current, '', {
1083
+ at: {
1084
+ anchor: Editor.start(markdownEditorRef.current, ctx.current.path),
1085
+ focus: Editor.end(markdownEditorRef.current, ctx.current.path)
1086
+ }
1087
+ });
1088
+ setState({
1089
+ insertUrl: ''
759
1090
  });
760
- setState({ insertUrl: "" });
761
1091
  insertAttachByLink();
762
- }
1092
+ }
1093
+ }, "Choose a file"))
1094
+ },
1095
+ {
1096
+ label: 'Embed Link',
1097
+ key: 'embed',
1098
+ children: /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(Input, {
1099
+ placeholder: 'Paste attachment link',
1100
+ onMouseDown: function(e) {
1101
+ return e.stopPropagation();
763
1102
  },
764
- "Choose a file"
765
- ))
766
- },
767
- {
768
- label: "Embed Link",
769
- key: "embed",
770
- children: /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
771
- Input,
772
- {
773
- placeholder: "Paste attachment link",
774
- onMouseDown: (e) => e.stopPropagation(),
775
- value: state.insertUrl,
776
- onKeyDown: (e) => {
777
- if (isHotkey("enter", e)) {
778
- insertAttachByLink();
1103
+ value: state.insertUrl,
1104
+ onKeyDown: function(e) {
1105
+ if (isHotkey('enter', e)) {
1106
+ insertAttachByLink();
779
1107
  }
780
- },
781
- onChange: (e) => setState({ insertUrl: e.target.value })
1108
+ },
1109
+ onChange: function(e) {
1110
+ return setState({
1111
+ insertUrl: e.target.value
1112
+ });
782
1113
  }
783
- ), /* @__PURE__ */ React.createElement(
784
- Button,
785
- {
786
- block: true,
787
- loading: state.loading,
788
- type: "primary",
789
- style: {
790
- marginTop: "1em"
791
- },
792
- size: "small",
793
- onClick: insertAttachByLink,
794
- disabled: !state.insertUrl
1114
+ }), /*#__PURE__*/ React.createElement(Button, {
1115
+ block: true,
1116
+ loading: state.loading,
1117
+ type: 'primary',
1118
+ style: {
1119
+ marginTop: '1em'
795
1120
  },
796
- "Embed"
797
- ))
798
- }
799
- ]
1121
+ size: 'small',
1122
+ onClick: insertAttachByLink,
1123
+ disabled: !state.insertUrl
1124
+ }, "Embed"))
800
1125
  }
801
- )
802
- )
803
- )
804
- ),
805
- document.body
806
- );
807
- };
808
- export {
809
- InsertAutocomplete,
810
- getInsertOptions
1126
+ ]
1127
+ })))), document.body);
811
1128
  };