@ant-design/agentic-ui 2.8.0 → 2.10.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 (585) 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.d.ts +3 -0
  136. package/dist/Hooks/useLanguage.js +67 -26
  137. package/dist/Hooks/useRefFunction/index.js +76 -11
  138. package/dist/Hooks/useSpeechSynthesis.js +143 -99
  139. package/dist/Hooks/useStyle/index.js +95 -60
  140. package/dist/Hooks/useThrottleFn/index.js +41 -41
  141. package/dist/I18n/index.js +246 -109
  142. package/dist/I18n/locales.d.ts +3 -0
  143. package/dist/I18n/locales.js +724 -711
  144. package/dist/Icons/animated/VoicePlayLottie/index.js +75 -46
  145. package/dist/Icons/animated/VoicingLottie/index.js +78 -47
  146. package/dist/MarkdownEditor/BaseMarkdownEditor.js +421 -349
  147. package/dist/MarkdownEditor/editor/Editor.js +1160 -843
  148. package/dist/MarkdownEditor/editor/components/CommentList/index.js +407 -239
  149. package/dist/MarkdownEditor/editor/components/CommentList/style.js +119 -89
  150. package/dist/MarkdownEditor/editor/components/ContributorAvatar/index.js +61 -63
  151. package/dist/MarkdownEditor/editor/components/ContributorAvatar/style.js +82 -52
  152. package/dist/MarkdownEditor/editor/components/LazyElement/index.js +208 -106
  153. package/dist/MarkdownEditor/editor/components/LazyElement/style.js +69 -42
  154. package/dist/MarkdownEditor/editor/components/fntTag/index.js +7 -11
  155. package/dist/MarkdownEditor/editor/components/fntTag/style.js +66 -36
  156. package/dist/MarkdownEditor/editor/components/index.js +0 -1
  157. package/dist/MarkdownEditor/editor/elements/Blockquote.js +95 -37
  158. package/dist/MarkdownEditor/editor/elements/Break.js +56 -25
  159. package/dist/MarkdownEditor/editor/elements/Card/index.js +131 -52
  160. package/dist/MarkdownEditor/editor/elements/Code.js +89 -67
  161. package/dist/MarkdownEditor/editor/elements/Comment/index.js +79 -50
  162. package/dist/MarkdownEditor/editor/elements/ErrorBoundary.js +117 -21
  163. package/dist/MarkdownEditor/editor/elements/FootnoteDefinition.js +83 -64
  164. package/dist/MarkdownEditor/editor/elements/FootnoteReference.js +115 -41
  165. package/dist/MarkdownEditor/editor/elements/Head.js +131 -67
  166. package/dist/MarkdownEditor/editor/elements/Hr.js +63 -38
  167. package/dist/MarkdownEditor/editor/elements/Image/index.js +636 -494
  168. package/dist/MarkdownEditor/editor/elements/InlineKatex.js +60 -44
  169. package/dist/MarkdownEditor/editor/elements/Katex.js +71 -55
  170. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +79 -175
  171. package/dist/MarkdownEditor/editor/elements/LinkCard/style.js +130 -100
  172. package/dist/MarkdownEditor/editor/elements/List/List.js +96 -69
  173. package/dist/MarkdownEditor/editor/elements/List/ListItem.js +422 -247
  174. package/dist/MarkdownEditor/editor/elements/List/index.js +1 -5
  175. package/dist/MarkdownEditor/editor/elements/List/style.js +131 -117
  176. package/dist/MarkdownEditor/editor/elements/Media.js +637 -519
  177. package/dist/MarkdownEditor/editor/elements/Mermaid.js +79 -54
  178. package/dist/MarkdownEditor/editor/elements/Paragraph.js +144 -83
  179. package/dist/MarkdownEditor/editor/elements/Schema.js +167 -128
  180. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +211 -178
  181. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +73 -49
  182. package/dist/MarkdownEditor/editor/elements/Table/Table.js +285 -204
  183. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +397 -280
  184. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.js +126 -101
  185. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +381 -276
  186. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.js +120 -98
  187. package/dist/MarkdownEditor/editor/elements/Table/TableContext.js +64 -21
  188. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +52 -42
  189. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.js +69 -39
  190. package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +126 -72
  191. package/dist/MarkdownEditor/editor/elements/Table/Td/style.js +85 -55
  192. package/dist/MarkdownEditor/editor/elements/Table/index.js +204 -105
  193. package/dist/MarkdownEditor/editor/elements/Table/style.js +244 -233
  194. package/dist/MarkdownEditor/editor/elements/Table/useScrollShadow.js +119 -62
  195. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +438 -276
  196. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +103 -77
  197. package/dist/MarkdownEditor/editor/elements/index.js +437 -424
  198. package/dist/MarkdownEditor/editor/parser/json-parse.js +38 -9
  199. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1753 -1168
  200. package/dist/MarkdownEditor/editor/parser/parserMdToSchema.js +16 -20
  201. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1021 -606
  202. package/dist/MarkdownEditor/editor/parser/remarkParse.js +158 -102
  203. package/dist/MarkdownEditor/editor/plugins/catchError.js +78 -17
  204. package/dist/MarkdownEditor/editor/plugins/elements.js +458 -342
  205. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +752 -300
  206. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +215 -129
  207. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +325 -180
  208. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +576 -418
  209. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +157 -47
  210. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +331 -209
  211. package/dist/MarkdownEditor/editor/plugins/index.js +0 -1
  212. package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +1245 -507
  213. package/dist/MarkdownEditor/editor/plugins/parseMarkdownToNodesAndInsert.js +36 -24
  214. package/dist/MarkdownEditor/editor/plugins/useHighlight.js +267 -116
  215. package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +234 -160
  216. package/dist/MarkdownEditor/editor/plugins/useOnchange.js +253 -92
  217. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +728 -439
  218. package/dist/MarkdownEditor/editor/store.js +1819 -1389
  219. package/dist/MarkdownEditor/editor/style.js +551 -506
  220. package/dist/MarkdownEditor/editor/tagStyles.js +43 -43
  221. package/dist/MarkdownEditor/editor/tools/DragHandle.js +56 -54
  222. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1049 -732
  223. package/dist/MarkdownEditor/editor/tools/InsertLink.js +232 -181
  224. package/dist/MarkdownEditor/editor/tools/Leading.js +566 -303
  225. package/dist/MarkdownEditor/editor/tools/ToolBar/BaseBar.js +415 -377
  226. package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +162 -125
  227. package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +480 -258
  228. package/dist/MarkdownEditor/editor/tools/ToolBar/ToolBar.js +44 -44
  229. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ClearFormatButton.js +20 -35
  230. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ColorPickerButton.js +69 -73
  231. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormatButton.js +13 -19
  232. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormattingTools.js +34 -41
  233. package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +53 -47
  234. package/dist/MarkdownEditor/editor/tools/ToolBar/components/LinkButton.js +11 -19
  235. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ToolBarItem.js +23 -43
  236. package/dist/MarkdownEditor/editor/tools/ToolBar/components/UndoRedoButtons.js +14 -25
  237. package/dist/MarkdownEditor/editor/tools/ToolBar/config/toolsConfig.js +139 -102
  238. package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.js +95 -65
  239. package/dist/MarkdownEditor/editor/tools/ToolBar/hooks/useToolBarLogic.js +252 -161
  240. package/dist/MarkdownEditor/editor/tools/ToolBar/index.js +14 -24
  241. package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.js +95 -65
  242. package/dist/MarkdownEditor/editor/tools/insertAutocompleteStyle.js +82 -52
  243. package/dist/MarkdownEditor/editor/types/Table.js +1 -0
  244. package/dist/MarkdownEditor/editor/utils/InlineChromiumBugfix.js +11 -16
  245. package/dist/MarkdownEditor/editor/utils/ace.js +136 -40
  246. package/dist/MarkdownEditor/editor/utils/docx/docxDeserializer.js +29 -32
  247. package/dist/MarkdownEditor/editor/utils/docx/index.js +0 -1
  248. package/dist/MarkdownEditor/editor/utils/docx/module.js +193 -164
  249. package/dist/MarkdownEditor/editor/utils/docx/utils.js +113 -98
  250. package/dist/MarkdownEditor/editor/utils/dom.js +119 -90
  251. package/dist/MarkdownEditor/editor/utils/editorUtils.js +1369 -906
  252. package/dist/MarkdownEditor/editor/utils/htmlToMarkdown.js +196 -184
  253. package/dist/MarkdownEditor/editor/utils/index.js +354 -215
  254. package/dist/MarkdownEditor/editor/utils/isMarkdown.js +56 -44
  255. package/dist/MarkdownEditor/editor/utils/keyboard.js +1229 -664
  256. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +294 -76
  257. package/dist/MarkdownEditor/editor/utils/media.js +274 -99
  258. package/dist/MarkdownEditor/editor/utils/path.js +22 -16
  259. package/dist/MarkdownEditor/editor/utils/performanceMonitor.js +370 -168
  260. package/dist/MarkdownEditor/editor/utils/useLocalState.js +96 -37
  261. package/dist/MarkdownEditor/el.js +1 -0
  262. package/dist/MarkdownEditor/hooks/editor.js +123 -41
  263. package/dist/MarkdownEditor/hooks/subscribe.js +18 -15
  264. package/dist/MarkdownEditor/index.js +118 -30
  265. package/dist/MarkdownEditor/plugin.js +2 -5
  266. package/dist/MarkdownEditor/style.js +96 -66
  267. package/dist/MarkdownEditor/types.js +1 -0
  268. package/dist/MarkdownEditor/utils/exportHtml.js +42 -83
  269. package/dist/MarkdownEditor/utils/native-table/index.js +0 -1
  270. package/dist/MarkdownEditor/utils/native-table/native-table-editor.js +337 -222
  271. package/dist/MarkdownEditor/utils/native-table/native-table-keyboard.js +201 -113
  272. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +4 -0
  273. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +277 -82
  274. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +62 -33
  275. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +147 -125
  276. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +174 -129
  277. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +263 -237
  278. package/dist/MarkdownInputField/AttachmentButton/index.js +480 -205
  279. package/dist/MarkdownInputField/AttachmentButton/style.js +143 -114
  280. package/dist/MarkdownInputField/AttachmentButton/types.js +3 -0
  281. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +60 -0
  282. package/dist/MarkdownInputField/AttachmentButton/utils.js +365 -33
  283. package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +438 -404
  284. package/dist/MarkdownInputField/Enlargement/index.js +7 -17
  285. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +193 -216
  286. package/dist/MarkdownInputField/FileMapView/index.js +387 -174
  287. package/dist/MarkdownInputField/FileMapView/style.js +281 -259
  288. package/dist/MarkdownInputField/FilePaste/index.js +239 -65
  289. package/dist/MarkdownInputField/FileUploadManager/index.js +504 -170
  290. package/dist/MarkdownInputField/MarkdownInputField.js +819 -549
  291. package/dist/MarkdownInputField/QuickActions/index.js +304 -134
  292. package/dist/MarkdownInputField/RefinePromptButton/index.js +24 -33
  293. package/dist/MarkdownInputField/RefinePromptButton/style.js +99 -73
  294. package/dist/MarkdownInputField/SendActions/index.js +179 -197
  295. package/dist/MarkdownInputField/SendButton/index.js +150 -110
  296. package/dist/MarkdownInputField/SendButton/style.js +95 -64
  297. package/dist/MarkdownInputField/SkillModeBar/hooks/index.js +3 -5
  298. package/dist/MarkdownInputField/SkillModeBar/hooks/useSkillModeState.js +51 -26
  299. package/dist/MarkdownInputField/SkillModeBar/index.js +119 -106
  300. package/dist/MarkdownInputField/SkillModeBar/style.js +124 -98
  301. package/dist/MarkdownInputField/Suggestion/index.js +391 -154
  302. package/dist/MarkdownInputField/TopOperatingArea/index.js +37 -44
  303. package/dist/MarkdownInputField/TopOperatingArea/style.js +98 -81
  304. package/dist/MarkdownInputField/VoiceInput/index.js +210 -82
  305. package/dist/MarkdownInputField/VoiceInput/style.js +85 -59
  306. package/dist/MarkdownInputField/VoiceInputManager/index.js +321 -94
  307. package/dist/MarkdownInputField/style.js +296 -233
  308. package/dist/Plugins/chart/AreaChart/index.js +541 -393
  309. package/dist/Plugins/chart/AreaChart/style.js +114 -90
  310. package/dist/Plugins/chart/BarChart/index.d.ts +4 -0
  311. package/dist/Plugins/chart/BarChart/index.js +865 -697
  312. package/dist/Plugins/chart/BarChart/style.js +114 -90
  313. package/dist/Plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.js +82 -52
  314. package/dist/Plugins/chart/ChartAttrToolBar/index.js +94 -65
  315. package/dist/Plugins/chart/ChartMark/Area.js +176 -150
  316. package/dist/Plugins/chart/ChartMark/Bar.js +181 -152
  317. package/dist/Plugins/chart/ChartMark/Column.js +181 -151
  318. package/dist/Plugins/chart/ChartMark/Container.js +116 -75
  319. package/dist/Plugins/chart/ChartMark/Line.js +179 -151
  320. package/dist/Plugins/chart/ChartMark/Pie.js +79 -63
  321. package/dist/Plugins/chart/ChartMark/index.js +6 -13
  322. package/dist/Plugins/chart/ChartMark/useChart.js +1 -0
  323. package/dist/Plugins/chart/ChartRender.js +981 -696
  324. package/dist/Plugins/chart/ChartStatistic/index.js +47 -62
  325. package/dist/Plugins/chart/ChartStatistic/style.js +142 -143
  326. package/dist/Plugins/chart/ChartStatistic/utils.js +37 -27
  327. package/dist/Plugins/chart/DonutChart/Legend.js +94 -124
  328. package/dist/Plugins/chart/DonutChart/constants.js +4 -11
  329. package/dist/Plugins/chart/DonutChart/hooks.js +183 -112
  330. package/dist/Plugins/chart/DonutChart/index.js +588 -516
  331. package/dist/Plugins/chart/DonutChart/plugins.js +47 -44
  332. package/dist/Plugins/chart/DonutChart/style.js +186 -175
  333. package/dist/Plugins/chart/DonutChart/types.js +1 -0
  334. package/dist/Plugins/chart/FunnelChart/index.js +844 -647
  335. package/dist/Plugins/chart/FunnelChart/style.js +97 -71
  336. package/dist/Plugins/chart/LineChart/index.js +516 -393
  337. package/dist/Plugins/chart/LineChart/style.js +114 -90
  338. package/dist/Plugins/chart/RadarChart/index.js +580 -582
  339. package/dist/Plugins/chart/RadarChart/style.js +122 -112
  340. package/dist/Plugins/chart/ScatterChart/index.js +633 -640
  341. package/dist/Plugins/chart/ScatterChart/style.js +108 -94
  342. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +151 -80
  343. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +160 -41
  344. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundaryExample.js +80 -62
  345. package/dist/Plugins/chart/components/ChartContainer/index.js +2 -7
  346. package/dist/Plugins/chart/components/ChartContainer/style.js +121 -91
  347. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +58 -90
  348. package/dist/Plugins/chart/components/ChartFilter/style.js +169 -154
  349. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +54 -59
  350. package/dist/Plugins/chart/components/ChartToolBar/style.js +132 -117
  351. package/dist/Plugins/chart/components/icons/TimeIcon.js +20 -26
  352. package/dist/Plugins/chart/components/index.js +32 -34
  353. package/dist/Plugins/chart/const.js +34 -25
  354. package/dist/Plugins/chart/hooks/useChartStatistic.js +1 -0
  355. package/dist/Plugins/chart/index.js +436 -339
  356. package/dist/Plugins/chart/loadChartRuntime.js +209 -110
  357. package/dist/Plugins/chart/utils.js +311 -87
  358. package/dist/Plugins/code/CodeUI/Katex/Katex.js +112 -66
  359. package/dist/Plugins/code/components/AceEditor.js +334 -237
  360. package/dist/Plugins/code/components/AceEditorContainer.js +23 -32
  361. package/dist/Plugins/code/components/CodeContainer.js +41 -56
  362. package/dist/Plugins/code/components/CodeRenderer.js +202 -155
  363. package/dist/Plugins/code/components/CodeToolbar.js +137 -181
  364. package/dist/Plugins/code/components/HtmlPreview.js +19 -22
  365. package/dist/Plugins/code/components/LanguageSelector.js +162 -96
  366. package/dist/Plugins/code/components/LoadImage.js +145 -46
  367. package/dist/Plugins/code/components/ThinkBlock.js +38 -42
  368. package/dist/Plugins/code/components/index.js +13 -23
  369. package/dist/Plugins/code/hooks/index.js +7 -9
  370. package/dist/Plugins/code/hooks/useCodeEditorState.js +139 -62
  371. package/dist/Plugins/code/hooks/useRenderConditions.js +31 -23
  372. package/dist/Plugins/code/hooks/useToolbarConfig.js +44 -46
  373. package/dist/Plugins/code/index.js +141 -89
  374. package/dist/Plugins/code/langIconMap.js +400 -108
  375. package/dist/Plugins/code/langIcons/AbapIcon.js +90 -57
  376. package/dist/Plugins/code/langIcons/ActionscriptIcon.js +89 -56
  377. package/dist/Plugins/code/langIcons/AdaIcon.js +89 -52
  378. package/dist/Plugins/code/langIcons/ApacheIcon.js +205 -254
  379. package/dist/Plugins/code/langIcons/ApexIcon.js +108 -82
  380. package/dist/Plugins/code/langIcons/AplIcon.js +90 -54
  381. package/dist/Plugins/code/langIcons/ApplescriptIcon.js +89 -56
  382. package/dist/Plugins/code/langIcons/AstroIcon.js +91 -58
  383. package/dist/Plugins/code/langIcons/AwkIcon.js +98 -68
  384. package/dist/Plugins/code/langIcons/BallerinaIcon.js +92 -59
  385. package/dist/Plugins/code/langIcons/BatIcon.js +158 -229
  386. package/dist/Plugins/code/langIcons/BicepIcon.js +91 -58
  387. package/dist/Plugins/code/langIcons/BladeIcon.js +90 -58
  388. package/dist/Plugins/code/langIcons/CIcon.js +90 -55
  389. package/dist/Plugins/code/langIcons/CadenceIcon.js +89 -56
  390. package/dist/Plugins/code/langIcons/ClojureIcon.js +96 -75
  391. package/dist/Plugins/code/langIcons/CmakeIcon.js +93 -62
  392. package/dist/Plugins/code/langIcons/CobolIcon.js +99 -70
  393. package/dist/Plugins/code/langIcons/CodeqlIcon.js +96 -76
  394. package/dist/Plugins/code/langIcons/CoffeeIcon.js +89 -56
  395. package/dist/Plugins/code/langIcons/ConsoleIcon.js +89 -56
  396. package/dist/Plugins/code/langIcons/CppIcon.js +90 -55
  397. package/dist/Plugins/code/langIcons/CrystalIcon.js +90 -57
  398. package/dist/Plugins/code/langIcons/CsharpIcon.js +90 -59
  399. package/dist/Plugins/code/langIcons/CssIcon.js +89 -52
  400. package/dist/Plugins/code/langIcons/DIcon.js +90 -53
  401. package/dist/Plugins/code/langIcons/DartIcon.js +92 -71
  402. package/dist/Plugins/code/langIcons/DatabaseIcon.js +90 -57
  403. package/dist/Plugins/code/langIcons/DiffIcon.js +90 -57
  404. package/dist/Plugins/code/langIcons/DockerIcon.js +89 -56
  405. package/dist/Plugins/code/langIcons/DotenvIcon.js +94 -56
  406. package/dist/Plugins/code/langIcons/ElixirIcon.js +91 -58
  407. package/dist/Plugins/code/langIcons/ElmIcon.js +105 -58
  408. package/dist/Plugins/code/langIcons/ErbIcon.js +90 -54
  409. package/dist/Plugins/code/langIcons/ErlangIcon.js +89 -56
  410. package/dist/Plugins/code/langIcons/FsharpIcon.js +93 -62
  411. package/dist/Plugins/code/langIcons/GdscriptIcon.js +96 -88
  412. package/dist/Plugins/code/langIcons/GlslIcon.js +90 -58
  413. package/dist/Plugins/code/langIcons/GnuplotIcon.js +98 -77
  414. package/dist/Plugins/code/langIcons/GoIcon.js +114 -93
  415. package/dist/Plugins/code/langIcons/GraphqlIcon.js +106 -66
  416. package/dist/Plugins/code/langIcons/GroovyIcon.js +89 -56
  417. package/dist/Plugins/code/langIcons/HackIcon.js +97 -64
  418. package/dist/Plugins/code/langIcons/HamlIcon.js +89 -56
  419. package/dist/Plugins/code/langIcons/HandlebarsIcon.js +89 -56
  420. package/dist/Plugins/code/langIcons/HaskellIcon.js +93 -64
  421. package/dist/Plugins/code/langIcons/HclIcon.js +118 -93
  422. package/dist/Plugins/code/langIcons/HclLightIcon.js +118 -97
  423. package/dist/Plugins/code/langIcons/HjsonIcon.js +94 -62
  424. package/dist/Plugins/code/langIcons/HlslIcon.js +96 -76
  425. package/dist/Plugins/code/langIcons/HtmlIcon.js +89 -56
  426. package/dist/Plugins/code/langIcons/HttpIcon.js +89 -56
  427. package/dist/Plugins/code/langIcons/ImbaIcon.js +98 -65
  428. package/dist/Plugins/code/langIcons/IniIcon.js +90 -54
  429. package/dist/Plugins/code/langIcons/JavaIcon.js +89 -56
  430. package/dist/Plugins/code/langIcons/JavascriptIcon.js +89 -56
  431. package/dist/Plugins/code/langIcons/JinjaIcon.js +100 -68
  432. package/dist/Plugins/code/langIcons/Json5Icon.js +100 -82
  433. package/dist/Plugins/code/langIcons/JsonIcon.js +89 -56
  434. package/dist/Plugins/code/langIcons/JsonnetIcon.js +102 -86
  435. package/dist/Plugins/code/langIcons/JuliaIcon.js +105 -52
  436. package/dist/Plugins/code/langIcons/KotlinIcon.js +104 -74
  437. package/dist/Plugins/code/langIcons/KustoIcon.js +90 -57
  438. package/dist/Plugins/code/langIcons/LessIcon.js +90 -57
  439. package/dist/Plugins/code/langIcons/LiquidIcon.js +91 -58
  440. package/dist/Plugins/code/langIcons/LispIcon.js +89 -56
  441. package/dist/Plugins/code/langIcons/LuaIcon.js +93 -60
  442. package/dist/Plugins/code/langIcons/MakefileIcon.js +91 -58
  443. package/dist/Plugins/code/langIcons/MarkdownIcon.js +89 -56
  444. package/dist/Plugins/code/langIcons/MarkojsIcon.js +96 -73
  445. package/dist/Plugins/code/langIcons/MatlabIcon.js +93 -64
  446. package/dist/Plugins/code/langIcons/MdxIcon.js +90 -53
  447. package/dist/Plugins/code/langIcons/MermaidIcon.js +95 -64
  448. package/dist/Plugins/code/langIcons/MojoIcon.js +95 -62
  449. package/dist/Plugins/code/langIcons/NginxIcon.js +94 -61
  450. package/dist/Plugins/code/langIcons/NimIcon.js +91 -54
  451. package/dist/Plugins/code/langIcons/NixIcon.js +92 -56
  452. package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +90 -59
  453. package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +90 -57
  454. package/dist/Plugins/code/langIcons/OcamlIcon.js +90 -61
  455. package/dist/Plugins/code/langIcons/PascalIcon.js +95 -55
  456. package/dist/Plugins/code/langIcons/Perl6Icon.js +299 -320
  457. package/dist/Plugins/code/langIcons/PerlIcon.js +89 -56
  458. package/dist/Plugins/code/langIcons/PhpIcon.js +89 -52
  459. package/dist/Plugins/code/langIcons/PostcssIcon.js +130 -113
  460. package/dist/Plugins/code/langIcons/PowershellIcon.js +91 -58
  461. package/dist/Plugins/code/langIcons/PrismaIcon.js +97 -68
  462. package/dist/Plugins/code/langIcons/PrologIcon.js +91 -58
  463. package/dist/Plugins/code/langIcons/ProtoIcon.js +94 -68
  464. package/dist/Plugins/code/langIcons/PugIcon.js +177 -145
  465. package/dist/Plugins/code/langIcons/PuppetIcon.js +96 -52
  466. package/dist/Plugins/code/langIcons/PurescriptIcon.js +93 -61
  467. package/dist/Plugins/code/langIcons/PythonIcon.js +90 -61
  468. package/dist/Plugins/code/langIcons/RIcon.js +89 -52
  469. package/dist/Plugins/code/langIcons/RazorIcon.js +90 -57
  470. package/dist/Plugins/code/langIcons/ReactIcon.js +89 -56
  471. package/dist/Plugins/code/langIcons/ReactTsIcon.js +90 -57
  472. package/dist/Plugins/code/langIcons/RubyIcon.js +91 -58
  473. package/dist/Plugins/code/langIcons/RustIcon.js +89 -56
  474. package/dist/Plugins/code/langIcons/SasIcon.js +89 -52
  475. package/dist/Plugins/code/langIcons/SassIcon.js +90 -57
  476. package/dist/Plugins/code/langIcons/ScalaIcon.js +96 -53
  477. package/dist/Plugins/code/langIcons/SchemeIcon.js +91 -58
  478. package/dist/Plugins/code/langIcons/ShaderlabIcon.js +89 -56
  479. package/dist/Plugins/code/langIcons/SolidityIcon.js +94 -52
  480. package/dist/Plugins/code/langIcons/SparqlIcon.js +94 -64
  481. package/dist/Plugins/code/langIcons/StataIcon.js +126 -108
  482. package/dist/Plugins/code/langIcons/StylusIcon.js +92 -59
  483. package/dist/Plugins/code/langIcons/SvelteIcon.js +91 -58
  484. package/dist/Plugins/code/langIcons/SwiftIcon.js +90 -57
  485. package/dist/Plugins/code/langIcons/SystemverilogIcon.js +115 -102
  486. package/dist/Plugins/code/langIcons/TclIcon.js +89 -52
  487. package/dist/Plugins/code/langIcons/TexIcon.js +99 -65
  488. package/dist/Plugins/code/langIcons/TomlIcon.js +94 -70
  489. package/dist/Plugins/code/langIcons/TwigIcon.js +89 -56
  490. package/dist/Plugins/code/langIcons/TypescriptIcon.js +93 -60
  491. package/dist/Plugins/code/langIcons/VerilogIcon.js +89 -56
  492. package/dist/Plugins/code/langIcons/VhdlIcon.js +94 -64
  493. package/dist/Plugins/code/langIcons/VimIcon.js +278 -420
  494. package/dist/Plugins/code/langIcons/VueIcon.js +92 -59
  495. package/dist/Plugins/code/langIcons/WebassemblyIcon.js +103 -76
  496. package/dist/Plugins/code/langIcons/WenyanIcon.js +104 -100
  497. package/dist/Plugins/code/langIcons/WgslIcon.js +93 -77
  498. package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +100 -71
  499. package/dist/Plugins/code/langIcons/XmlIcon.js +89 -52
  500. package/dist/Plugins/code/langIcons/XslIcon.js +94 -66
  501. package/dist/Plugins/code/langIcons/YamlIcon.js +89 -56
  502. package/dist/Plugins/code/langIcons/ZigIcon.js +106 -81
  503. package/dist/Plugins/code/langIcons/index.js +128 -259
  504. package/dist/Plugins/code/utils/index.js +5 -5
  505. package/dist/Plugins/code/utils/langOptions.js +86 -11
  506. package/dist/Plugins/defaultPlugins.js +9 -13
  507. package/dist/Plugins/formatter/index.js +205 -105
  508. package/dist/Plugins/index.js +6 -2
  509. package/dist/Plugins/katex/InlineKatex.js +196 -107
  510. package/dist/Plugins/katex/Katex.js +139 -65
  511. package/dist/Plugins/katex/index.js +163 -103
  512. package/dist/Plugins/mermaid/Mermaid.js +472 -197
  513. package/dist/Plugins/mermaid/index.js +237 -142
  514. package/dist/Quote/index.js +112 -73
  515. package/dist/Quote/style.js +176 -160
  516. package/dist/Schema/SchemaEditor/AceEditorWrapper.js +163 -119
  517. package/dist/Schema/SchemaEditor/index.js +385 -275
  518. package/dist/Schema/SchemaEditor/style.js +261 -269
  519. package/dist/Schema/SchemaForm/index.js +443 -268
  520. package/dist/Schema/SchemaForm/types.js +1 -0
  521. package/dist/Schema/SchemaRenderer/index.js +973 -588
  522. package/dist/Schema/SchemaRenderer/templateEngine.js +106 -26
  523. package/dist/Schema/index.js +7 -11
  524. package/dist/Schema/types.js +1 -0
  525. package/dist/Schema/validator.js +74 -36
  526. package/dist/TaskList/index.js +197 -142
  527. package/dist/TaskList/style.js +143 -122
  528. package/dist/ThoughtChainList/CostMillis.js +88 -54
  529. package/dist/ThoughtChainList/DeepThink.js +187 -152
  530. package/dist/ThoughtChainList/DotAni/index.js +29 -14
  531. package/dist/ThoughtChainList/DotAni/style.js +82 -50
  532. package/dist/ThoughtChainList/FlipText/index.js +74 -30
  533. package/dist/ThoughtChainList/MarkdownEditor.js +126 -72
  534. package/dist/ThoughtChainList/RagRetrievalInfo.js +113 -145
  535. package/dist/ThoughtChainList/TableSql.js +413 -459
  536. package/dist/ThoughtChainList/ThoughtChainListItem.js +388 -222
  537. package/dist/ThoughtChainList/TitleInfo.js +189 -185
  538. package/dist/ThoughtChainList/ToolCall.js +429 -463
  539. package/dist/ThoughtChainList/WebSearch.js +192 -162
  540. package/dist/ThoughtChainList/index.js +449 -410
  541. package/dist/ThoughtChainList/style.js +253 -232
  542. package/dist/ThoughtChainList/types.js +1 -0
  543. package/dist/ToolUseBar/ToolUseBarItem.js +183 -139
  544. package/dist/ToolUseBar/ToolUseBarItemComponents.js +345 -276
  545. package/dist/ToolUseBar/ToolUseBarThink.js +335 -396
  546. package/dist/ToolUseBar/index.js +226 -113
  547. package/dist/ToolUseBar/style.js +334 -308
  548. package/dist/ToolUseBar/thinkStyle.js +350 -328
  549. package/dist/Types/common.js +1 -0
  550. package/dist/Types/index.js +4 -2
  551. package/dist/Types/message.js +1 -0
  552. package/dist/Utils/easings.js +9 -12
  553. package/dist/Utils/formatTime.js +41 -17
  554. package/dist/Utils/getScroll.js +41 -41
  555. package/dist/Utils/language.js +355 -150
  556. package/dist/Utils/proxySandbox/ProxySandbox.js +1637 -1076
  557. package/dist/Utils/proxySandbox/SecurityContextManager.js +607 -343
  558. package/dist/Utils/proxySandbox/index.js +554 -267
  559. package/dist/Utils/proxySandbox/types.js +187 -52
  560. package/dist/Utils/scrollTo.js +48 -56
  561. package/dist/Utils/throttleByAnimationFrame.js +46 -20
  562. package/dist/WelcomeMessage/index.js +106 -58
  563. package/dist/WelcomeMessage/style.js +80 -55
  564. package/dist/Workspace/Browser/index.js +102 -40
  565. package/dist/Workspace/Browser/style.js +62 -33
  566. package/dist/Workspace/File/DataSourceStrategy.js +419 -217
  567. package/dist/Workspace/File/FileComponent.js +1004 -791
  568. package/dist/Workspace/File/FileTypeProcessor.js +337 -184
  569. package/dist/Workspace/File/PreviewComponent.js +472 -532
  570. package/dist/Workspace/File/index.js +3 -10
  571. package/dist/Workspace/File/style.js +397 -424
  572. package/dist/Workspace/File/utils.js +160 -106
  573. package/dist/Workspace/HtmlPreview/index.js +238 -137
  574. package/dist/Workspace/HtmlPreview/style.js +99 -77
  575. package/dist/Workspace/RealtimeFollow/index.js +411 -413
  576. package/dist/Workspace/RealtimeFollow/style.js +299 -303
  577. package/dist/Workspace/Task/index.js +53 -35
  578. package/dist/Workspace/Task/style.js +99 -73
  579. package/dist/Workspace/index.js +332 -254
  580. package/dist/Workspace/style.js +165 -146
  581. package/dist/Workspace/types.js +471 -252
  582. package/dist/Workspace/utils/codeLanguageUtils.js +148 -129
  583. package/dist/Workspace/utils.js +28 -20
  584. package/dist/index.js +27 -17
  585. package/package.json +3 -2
@@ -1,540 +1,1278 @@
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
+ /* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable no-param-reassign */ 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/plugins/insertParsedHtmlNodes.ts
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
+ }
42
235
  import { message } from "antd";
43
236
  import { Editor, Element, Node, Path, Range, Transforms } from "slate";
44
237
  import { jsx } from "slate-hyperscript";
45
238
  import { debugLog, EditorUtils } from "../utils";
46
239
  import { docxDeserializer } from "../utils/docx/docxDeserializer";
47
240
  import { BackspaceKey } from "./hotKeyCommands/backspace";
48
- var BATCH_SIZE = 10;
49
- var BATCH_DELAY = 16;
50
- var MAX_SYNC_SIZE = 1e3;
51
- var findElementByNode = (node) => {
52
- const index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
53
- return node.parentElement.children[index];
54
- };
55
- var fragment = /* @__PURE__ */ new Set(["body", "figure", "div"]);
56
- var ELEMENT_TAGS = {
57
- BLOCKQUOTE: () => ({ type: "blockquote" }),
58
- H1: () => ({ type: "head", level: 1 }),
59
- H2: () => ({ type: "head", level: 2 }),
60
- H3: () => ({ type: "head", level: 3 }),
61
- H4: () => ({ type: "head", level: 4 }),
62
- H5: () => ({ type: "head", level: 5 }),
63
- TABLE: () => ({ type: "table" }),
64
- IMG: (el) => {
65
- const src = el.src;
66
- const alt = el.alt;
67
- const isValidImageUrl = (url) => {
68
- if (!url)
69
- return false;
70
- if (url.startsWith("blob:") || url.startsWith("data:")) {
71
- return true;
72
- }
73
- if (!url.startsWith("http://") && !url.startsWith("https://")) {
74
- return false;
75
- }
76
- const imageExtensions = [
77
- ".jpg",
78
- ".jpeg",
79
- ".png",
80
- ".gif",
81
- ".svg",
82
- ".webp",
83
- ".bmp",
84
- ".ico"
85
- ];
86
- const hasImageExtension = imageExtensions.some(
87
- (ext) => url.toLowerCase().includes(ext)
88
- );
89
- const imagePaths = [
90
- "/image",
91
- "/img",
92
- "/photo",
93
- "/picture",
94
- "/avatar",
95
- "/icon"
96
- ];
97
- const hasImagePath = imagePaths.some(
98
- (path) => url.toLowerCase().includes(path)
99
- );
100
- const hasImageContentType = url.includes("image/") || url.includes("img/");
101
- return hasImageExtension || hasImagePath || hasImageContentType;
102
- };
103
- if (!isValidImageUrl(src)) {
104
- return {
105
- type: "paragraph",
106
- children: [{ text: src || alt || "图片链接" }]
107
- };
108
- }
109
- return EditorUtils.createMediaNode(src, "image", {
110
- alt,
111
- downloadUrl: src && /^https?:/.test(src) ? src : void 0
112
- });
113
- },
114
- TR: () => ({ type: "table-row" }),
115
- TH: () => ({ type: "table-cell", title: true }),
116
- TD: () => ({ type: "table-cell" }),
117
- LI: () => ({ type: "list-item" }),
118
- OL: () => ({ type: "list", order: true }),
119
- P: () => ({ type: "paragraph" }),
120
- PRE: () => ({ type: "code" }),
121
- UL: () => ({ type: "list" })
241
+ // 性能优化常量
242
+ var BATCH_SIZE = 10; // 每批处理的节点数量
243
+ var BATCH_DELAY = 16; // 每批之间的延迟时间(ms),约60fps
244
+ var MAX_SYNC_SIZE = 1000; // 同步处理的最大字符数
245
+ var findElementByNode = function(node) {
246
+ var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
247
+ return node.parentElement.children[index];
122
248
  };
123
- var TEXT_TAGS = {
124
- A: (el) => ({ url: el.getAttribute("href") }),
125
- CODE: () => ({ code: true }),
126
- KBD: () => ({ code: true }),
127
- SPAN: (el) => ({ text: el.textContent }),
128
- DEL: () => ({ strikethrough: true }),
129
- EM: () => ({ italic: true }),
130
- I: () => ({ italic: true }),
131
- S: () => ({ strikethrough: true }),
132
- STRONG: () => ({ bold: true }),
133
- B: () => ({ bold: true })
134
- };
135
- var deserialize = (el, parentTag = "") => {
136
- if (el.nodeName.toLowerCase() === "script")
137
- return [];
138
- if (el.nodeName.toLowerCase() === "style")
139
- return [];
140
- if (el.nodeName.toLowerCase() === "meta")
141
- return [];
142
- if (el.nodeName.toLowerCase() === "link")
143
- return [];
144
- if (el.nodeName.toLowerCase() === "head")
145
- return [];
146
- if (el.nodeName.toLowerCase() === "colgroup")
147
- return [];
148
- if (el.nodeName.toLowerCase() === "noscript")
149
- return [];
150
- if (el.nodeType === 3) {
151
- return el.textContent;
152
- } else if (el.nodeType !== 1) {
153
- return null;
154
- } else if (el.nodeName === "BR") {
155
- return "\n";
156
- }
157
- const { nodeName } = el;
158
- let target = el;
159
- if (nodeName === "PRE" && el.childNodes[0] && el.childNodes[0].nodeName === "CODE") {
160
- target = el.childNodes[0];
161
- }
162
- let children = Array.from(target.childNodes).map((n) => {
163
- return deserialize(n, target.nodeName.toLowerCase().toLowerCase());
164
- }).flat();
165
- if (children.length === 0) {
166
- children = [{ text: el.textContent || "" }];
167
- }
168
- if (fragment.has(el.nodeName.toLowerCase())) {
169
- return jsx("fragment", {}, children);
170
- }
171
- if (TEXT_TAGS[nodeName] && Array.from(el.childNodes).some(
172
- (e) => e.nodeType !== 3 && !TEXT_TAGS[e.nodeName]
173
- )) {
174
- return jsx("fragment", {}, children);
175
- }
176
- if (ELEMENT_TAGS[nodeName]) {
177
- if (!parentTag || !["h1", "h2", "code", "h3", "h4", "h5", "th", "td"].includes(parentTag)) {
178
- if (nodeName === "PRE") {
179
- const dom = findElementByNode(el);
180
- const dataset = dom.dataset;
181
- const inner = (dataset == null ? void 0 : dataset.blType) === "code";
182
- if (inner) {
183
- const value = Array.from(target.childNodes.values()).map((n) => {
184
- var _a, _b;
185
- return (_b = (_a = n.textContent) == null ? void 0 : _a.replace(/\n/g, "")) == null ? void 0 : _b.replace(/\t/g, " ");
186
- });
187
- return {
188
- type: "code",
189
- language: dataset == null ? void 0 : dataset.blLang,
190
- value,
191
- children: [
192
- {
193
- text: value
194
- }
195
- ]
196
- };
197
- } else {
198
- const text = parserCodeText(findElementByNode(target));
199
- if (text) {
249
+ var fragment = new Set([
250
+ 'body',
251
+ 'figure',
252
+ 'div'
253
+ ]);
254
+ export var ELEMENT_TAGS = {
255
+ BLOCKQUOTE: function() {
256
+ return {
257
+ type: 'blockquote'
258
+ };
259
+ },
260
+ H1: function() {
261
+ return {
262
+ type: 'head',
263
+ level: 1
264
+ };
265
+ },
266
+ H2: function() {
267
+ return {
268
+ type: 'head',
269
+ level: 2
270
+ };
271
+ },
272
+ H3: function() {
273
+ return {
274
+ type: 'head',
275
+ level: 3
276
+ };
277
+ },
278
+ H4: function() {
279
+ return {
280
+ type: 'head',
281
+ level: 4
282
+ };
283
+ },
284
+ H5: function() {
285
+ return {
286
+ type: 'head',
287
+ level: 5
288
+ };
289
+ },
290
+ TABLE: function() {
291
+ return {
292
+ type: 'table'
293
+ };
294
+ },
295
+ IMG: function(el) {
296
+ // 添加更严格的图片URL验证,避免将普通URL误识别为图片
297
+ var src = el.src;
298
+ var alt = el.alt;
299
+ // 检查是否为有效的图片URL
300
+ var isValidImageUrl = function(url) {
301
+ if (!url) return false;
302
+ // 检查是否为blob URL或data URL
303
+ if (url.startsWith('blob:') || url.startsWith('data:')) {
304
+ return true;
305
+ }
306
+ // 检查是否为有效的HTTP/HTTPS URL
307
+ if (!url.startsWith('http://') && !url.startsWith('https://')) {
308
+ return false;
309
+ }
310
+ // 检查URL是否包含图片文件扩展名
311
+ var imageExtensions = [
312
+ '.jpg',
313
+ '.jpeg',
314
+ '.png',
315
+ '.gif',
316
+ '.svg',
317
+ '.webp',
318
+ '.bmp',
319
+ '.ico'
320
+ ];
321
+ var hasImageExtension = imageExtensions.some(function(ext) {
322
+ return url.toLowerCase().includes(ext);
323
+ });
324
+ // 检查URL是否包含图片相关的路径
325
+ var imagePaths = [
326
+ '/image',
327
+ '/img',
328
+ '/photo',
329
+ '/picture',
330
+ '/avatar',
331
+ '/icon'
332
+ ];
333
+ var hasImagePath = imagePaths.some(function(path) {
334
+ return url.toLowerCase().includes(path);
335
+ });
336
+ // 检查Content-Type(如果可能的话)
337
+ var hasImageContentType = url.includes('image/') || url.includes('img/');
338
+ // 如果URL看起来像图片,或者是明确的图片URL,则认为是有效的
339
+ return hasImageExtension || hasImagePath || hasImageContentType;
340
+ };
341
+ // 如果URL不是有效的图片URL,则作为普通文本处理
342
+ if (!isValidImageUrl(src)) {
200
343
  return {
201
- type: "code",
202
- value: text,
203
- children: [
204
- {
205
- text
206
- }
207
- ]
344
+ type: 'paragraph',
345
+ children: [
346
+ {
347
+ text: src || alt || '图片链接'
348
+ }
349
+ ]
208
350
  };
209
- }
210
351
  }
211
- return null;
212
- }
213
- const attrs = ELEMENT_TAGS[nodeName](el);
214
- return jsx("element", attrs, children);
352
+ return EditorUtils.createMediaNode(src, 'image', {
353
+ alt: alt,
354
+ downloadUrl: src && /^https?:/.test(src) ? src : undefined
355
+ });
356
+ },
357
+ TR: function() {
358
+ return {
359
+ type: 'table-row'
360
+ };
361
+ },
362
+ TH: function() {
363
+ return {
364
+ type: 'table-cell',
365
+ title: true
366
+ };
367
+ },
368
+ TD: function() {
369
+ return {
370
+ type: 'table-cell'
371
+ };
372
+ },
373
+ LI: function() {
374
+ return {
375
+ type: 'list-item'
376
+ };
377
+ },
378
+ OL: function() {
379
+ return {
380
+ type: 'list',
381
+ order: true
382
+ };
383
+ },
384
+ P: function() {
385
+ return {
386
+ type: 'paragraph'
387
+ };
388
+ },
389
+ PRE: function() {
390
+ return {
391
+ type: 'code'
392
+ };
393
+ },
394
+ UL: function() {
395
+ return {
396
+ type: 'list'
397
+ };
215
398
  }
216
- }
217
- if (TEXT_TAGS[nodeName]) {
218
- const attrs = TEXT_TAGS[nodeName](el);
219
- return children.map((child) => {
220
- return jsx("text", attrs, child);
221
- }).filter((c) => !!c.text);
222
- }
223
- return children;
224
- };
225
- var parserCodeText = (el) => {
226
- el.innerHTML = el.innerHTML.replace(/<br\/?>|<\/div>(?=\S)/g, "\n");
227
- return el.innerText;
228
399
  };
229
- var getTextsNode = (nodes) => {
230
- let text = [];
231
- for (let n of nodes) {
232
- if (n.text) {
233
- text.push(n);
400
+ export var TEXT_TAGS = {
401
+ A: function(el) {
402
+ return {
403
+ url: el.getAttribute('href')
404
+ };
405
+ },
406
+ CODE: function() {
407
+ return {
408
+ code: true
409
+ };
410
+ },
411
+ KBD: function() {
412
+ return {
413
+ code: true
414
+ };
415
+ },
416
+ SPAN: function(el) {
417
+ return {
418
+ text: el.textContent
419
+ };
420
+ },
421
+ DEL: function() {
422
+ return {
423
+ strikethrough: true
424
+ };
425
+ },
426
+ EM: function() {
427
+ return {
428
+ italic: true
429
+ };
430
+ },
431
+ I: function() {
432
+ return {
433
+ italic: true
434
+ };
435
+ },
436
+ S: function() {
437
+ return {
438
+ strikethrough: true
439
+ };
440
+ },
441
+ STRONG: function() {
442
+ return {
443
+ bold: true
444
+ };
445
+ },
446
+ B: function() {
447
+ return {
448
+ bold: true
449
+ };
234
450
  }
235
- if (n == null ? void 0 : n.children) {
236
- text.push(...getTextsNode(n.children));
237
- }
238
- }
239
- return text;
240
451
  };
241
- var blobToFile = (blobUrl, fileName) => __async(void 0, null, function* () {
242
- const blob = yield fetch(blobUrl).then((r) => r.blob());
243
- const file = new File([blob], fileName);
244
- return file;
245
- });
246
- var upLoadFileBatch = (fragmentList, editorProps) => __async(void 0, null, function* () {
247
- const mediaFragments = [];
248
- const collectMediaFragments = (fragments) => {
249
- for (const fragment2 of fragments) {
250
- if (fragment2.type === "media") {
251
- mediaFragments.push(fragment2);
252
- }
253
- if (fragment2 == null ? void 0 : fragment2.children) {
254
- collectMediaFragments(fragment2.children);
255
- }
452
+ export var deserialize = function(el) {
453
+ var parentTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
454
+ if (el.nodeName.toLowerCase() === 'script') return [];
455
+ if (el.nodeName.toLowerCase() === 'style') return [];
456
+ if (el.nodeName.toLowerCase() === 'meta') return [];
457
+ if (el.nodeName.toLowerCase() === 'link') return [];
458
+ if (el.nodeName.toLowerCase() === 'head') return [];
459
+ if (el.nodeName.toLowerCase() === 'colgroup') return [];
460
+ if (el.nodeName.toLowerCase() === 'noscript') return [];
461
+ if (el.nodeType === 3) {
462
+ return el.textContent;
463
+ } else if (el.nodeType !== 1) {
464
+ return null;
465
+ } else if (el.nodeName === 'BR') {
466
+ return '\n';
256
467
  }
257
- };
258
- collectMediaFragments(fragmentList);
259
- if (mediaFragments.length === 0) {
260
- return;
261
- }
262
- const hideLoading = message.loading(
263
- `Uploading ${mediaFragments.length} files...`,
264
- 0
265
- );
266
- try {
267
- for (let i = 0; i < mediaFragments.length; i += BATCH_SIZE) {
268
- const batch = mediaFragments.slice(i, i + BATCH_SIZE);
269
- yield Promise.all(
270
- batch.map((fragment2) => __async(void 0, null, function* () {
271
- var _a, _b;
272
- const url = fragment2.url;
273
- if (url == null ? void 0 : url.startsWith("blob:")) {
274
- const file = yield blobToFile(fragment2 == null ? void 0 : fragment2.url, "image.png");
275
- if ((_a = editorProps.image) == null ? void 0 : _a.upload) {
276
- const serverUrl = [yield editorProps.image.upload([file])].flat(
277
- 1
278
- );
279
- fragment2.url = serverUrl == null ? void 0 : serverUrl[0];
280
- fragment2.downloadUrl = serverUrl == null ? void 0 : serverUrl[0];
281
- }
282
- } else {
283
- if ((_b = editorProps.image) == null ? void 0 : _b.upload) {
284
- const serverUrl = [
285
- yield editorProps.image.upload([fragment2 == null ? void 0 : fragment2.url])
286
- ].flat(1);
287
- fragment2.url = serverUrl == null ? void 0 : serverUrl[0];
288
- fragment2.downloadUrl = serverUrl == null ? void 0 : serverUrl[0];
468
+ var nodeName = el.nodeName;
469
+ var target = el;
470
+ if (nodeName === 'PRE' && el.childNodes[0] && el.childNodes[0].nodeName === 'CODE') {
471
+ target = el.childNodes[0];
472
+ }
473
+ var children = Array.from(target.childNodes).map(function(n) {
474
+ return deserialize(n, target.nodeName.toLowerCase().toLowerCase());
475
+ }).flat();
476
+ if (children.length === 0) {
477
+ children = [
478
+ {
479
+ text: el.textContent || ''
289
480
  }
290
- }
291
- }))
292
- );
293
- const progress = Math.min(
294
- (i + BATCH_SIZE) / mediaFragments.length * 100,
295
- 100
296
- );
297
- hideLoading();
298
- message.loading(
299
- `Uploading ${mediaFragments.length} files... ${Math.round(progress)}%`,
300
- 0
301
- );
302
- if (i + BATCH_SIZE < mediaFragments.length) {
303
- yield new Promise((resolve) => setTimeout(resolve, BATCH_DELAY));
304
- }
481
+ ];
305
482
  }
306
- message.success("Upload completed");
307
- } catch (error) {
308
- console.error("文件上传失败:", error);
309
- message.error("Some files failed to upload");
310
- } finally {
311
- hideLoading();
312
- }
313
- });
314
- var insertNodesBatch = (editor, nodes, at, options) => __async(void 0, null, function* () {
315
- if (nodes.length <= BATCH_SIZE) {
316
- Transforms.insertNodes(editor, nodes, __spreadValues({ at }, options));
317
- return;
318
- }
319
- for (let i = 0; i < nodes.length; i += BATCH_SIZE) {
320
- const batch = nodes.slice(i, i + BATCH_SIZE);
321
- const insertAt = at ? [...at.slice(0, -1), at[at.length - 1] + i] : void 0;
322
- Transforms.insertNodes(editor, batch, {
323
- at: insertAt,
324
- select: (options == null ? void 0 : options.select) && i + BATCH_SIZE >= nodes.length
325
- });
326
- if (i + BATCH_SIZE < nodes.length) {
327
- yield new Promise((resolve) => setTimeout(resolve, BATCH_DELAY));
483
+ if (fragment.has(el.nodeName.toLowerCase())) {
484
+ return jsx('fragment', {}, children);
328
485
  }
329
- }
330
- });
331
- var parseHtmlOptimized = (html, rtf) => __async(void 0, null, function* () {
332
- if (html.length < MAX_SYNC_SIZE) {
333
- return docxDeserializer(rtf, html.trim());
334
- }
335
- return new Promise((resolve) => {
336
- const processInIdle = () => {
337
- try {
338
- const result = docxDeserializer(rtf, html.trim());
339
- resolve(result);
340
- } catch (error) {
341
- console.error("HTML解析失败:", error);
342
- resolve([]);
343
- }
344
- };
345
- if ("requestIdleCallback" in window) {
346
- requestIdleCallback(processInIdle, { timeout: 1e3 });
347
- } else {
348
- setTimeout(processInIdle, 0);
486
+ if (TEXT_TAGS[nodeName] && Array.from(el.childNodes).some(function(e) {
487
+ return e.nodeType !== 3 && !TEXT_TAGS[e.nodeName];
488
+ })) {
489
+ return jsx('fragment', {}, children);
349
490
  }
350
- });
351
- });
352
- var htmlToFragmentList = (html, rtl) => {
353
- let fragmentList = docxDeserializer(rtl, html.trim());
354
- return fragmentList.map((fragment2) => {
355
- if (fragment2.type === "table") {
356
- return EditorUtils.wrapperCardNode(fragment2);
491
+ if (ELEMENT_TAGS[nodeName]) {
492
+ if (!parentTag || ![
493
+ 'h1',
494
+ 'h2',
495
+ 'code',
496
+ 'h3',
497
+ 'h4',
498
+ 'h5',
499
+ 'th',
500
+ 'td'
501
+ ].includes(parentTag)) {
502
+ if (nodeName === 'PRE') {
503
+ var dom = findElementByNode(el);
504
+ var dataset = dom.dataset;
505
+ var inner = (dataset === null || dataset === void 0 ? void 0 : dataset.blType) === 'code';
506
+ if (inner) {
507
+ var value = Array.from(target.childNodes.values()).map(function(n) {
508
+ var _n_textContent_replace, _n_textContent;
509
+ return (_n_textContent = n.textContent) === null || _n_textContent === void 0 ? void 0 : (_n_textContent_replace = _n_textContent.replace(/\n/g, '')) === null || _n_textContent_replace === void 0 ? void 0 : _n_textContent_replace.replace(/\t/g, ' ');
510
+ });
511
+ return {
512
+ type: 'code',
513
+ language: dataset === null || dataset === void 0 ? void 0 : dataset.blLang,
514
+ value: value,
515
+ children: [
516
+ {
517
+ text: value
518
+ }
519
+ ]
520
+ };
521
+ } else {
522
+ var text = parserCodeText(findElementByNode(target));
523
+ if (text) {
524
+ return {
525
+ type: 'code',
526
+ value: text,
527
+ children: [
528
+ {
529
+ text: text
530
+ }
531
+ ]
532
+ };
533
+ }
534
+ }
535
+ return null;
536
+ }
537
+ // @ts-ignore
538
+ var attrs = ELEMENT_TAGS[nodeName](el);
539
+ return jsx('element', attrs, children);
540
+ }
357
541
  }
358
- if (fragment2.type === '"paragraph"' && fragment2.children.length === 1) {
359
- return {
360
- type: "paragraph",
361
- children: fragment2.children
362
- };
542
+ if (TEXT_TAGS[nodeName]) {
543
+ // @ts-ignore
544
+ var attrs1 = TEXT_TAGS[nodeName](el);
545
+ return children.map(function(child) {
546
+ return jsx('text', attrs1, child);
547
+ }).filter(function(c) {
548
+ return !!c.text;
549
+ });
363
550
  }
364
- return fragment2;
365
- });
551
+ return children;
366
552
  };
367
- var insertParsedHtmlNodes = (editor, html, editorProps, rtl) => __async(void 0, null, function* () {
368
- if (html.startsWith('<html>\r\n<body>\r\n<!--StartFragment--><img src="')) {
369
- return false;
370
- }
371
- const hideLoading = message.loading("parsing...", 0);
372
- try {
373
- const fragmentList = yield parseHtmlOptimized(html, rtl);
374
- if (!(fragmentList == null ? void 0 : fragmentList.length)) {
375
- hideLoading();
376
- return false;
377
- }
378
- yield upLoadFileBatch(fragmentList, editorProps);
379
- debugLog("wordFragmentList", fragmentList);
380
- hideLoading();
381
- let [node] = Editor.nodes(editor, {
382
- match: (n) => Element.isElement(n)
383
- });
384
- const selection = editor.selection;
385
- if (!selection || !Editor.hasPath(editor, selection.anchor.path)) {
386
- const processedNodes2 = fragmentList == null ? void 0 : fragmentList.map((item) => {
387
- if (!item.type) {
388
- return { type: "paragraph", children: [item] };
553
+ var parserCodeText = function(el) {
554
+ el.innerHTML = el.innerHTML.replace(/<br\/?>|<\/div>(?=\S)/g, '\n');
555
+ return el.innerText;
556
+ };
557
+ var getTextsNode = function(nodes) {
558
+ var text = [];
559
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
560
+ try {
561
+ for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
562
+ var n = _step.value;
563
+ if (n.text) {
564
+ text.push(n);
565
+ }
566
+ if (n === null || n === void 0 ? void 0 : n.children) {
567
+ var _text;
568
+ (_text = text).push.apply(_text, _to_consumable_array(getTextsNode(n.children)));
569
+ }
389
570
  }
390
- return item;
391
- });
392
- yield insertNodesBatch(editor, processedNodes2);
393
- return true;
394
- }
395
- if (!Range.isCollapsed(selection)) {
396
- const back = new BackspaceKey(editor);
397
- back.range();
398
- Transforms.select(editor, Range.start(selection));
399
- setTimeout(() => {
400
- var _a, _b;
401
- const node2 = (_a = Editor) == null ? void 0 : _a.node(editor, [0]);
402
- if (editor.children.length > 1 && ((_b = node2 == null ? void 0 : node2[0]) == null ? void 0 : _b.type) === "paragraph" && !Node.string(node2[0])) {
403
- Transforms.delete(editor, { at: [0] });
571
+ } catch (err) {
572
+ _didIteratorError = true;
573
+ _iteratorError = err;
574
+ } finally{
575
+ try {
576
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
577
+ _iterator.return();
578
+ }
579
+ } finally{
580
+ if (_didIteratorError) {
581
+ throw _iteratorError;
582
+ }
404
583
  }
405
- });
406
584
  }
407
- const [specialNode] = Editor.nodes(editor, {
408
- match: (n) => Element.isElement(n) && ["code", "table-cell", "head", "list-item"].includes(n.type),
409
- at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
585
+ return text;
586
+ };
587
+ var blobToFile = /*#__PURE__*/ function() {
588
+ var _ref = _async_to_generator(function(blobUrl, fileName) {
589
+ var blob, file;
590
+ return _ts_generator(this, function(_state) {
591
+ switch(_state.label){
592
+ case 0:
593
+ return [
594
+ 4,
595
+ fetch(blobUrl).then(function(r) {
596
+ return r.blob();
597
+ })
598
+ ];
599
+ case 1:
600
+ blob = _state.sent();
601
+ file = new File([
602
+ blob
603
+ ], fileName);
604
+ return [
605
+ 2,
606
+ file
607
+ ];
608
+ }
609
+ });
410
610
  });
411
- if (specialNode) {
412
- node = specialNode;
413
- }
414
- const parsed = new DOMParser().parseFromString(html, "text/html").body;
415
- const inner = !!parsed.querySelector("[data-be]");
416
- if ((node == null ? void 0 : node[0].type) === "code") {
417
- const hasCodeTags = html.includes("<pre>") || html.includes("<code>") || inner;
418
- if (hasCodeTags) {
419
- const textContent = parsed.textContent || "";
420
- if (textContent.trim()) {
421
- Transforms.insertText(editor, textContent.trim(), { at: selection });
422
- return true;
423
- }
424
- }
425
- }
426
- if (inner && (node == null ? void 0 : node[0].type) === "table-cell") {
427
- return true;
428
- }
429
- if ((node == null ? void 0 : node[0].type) === "list-item" && fragmentList[0].type === "list") {
430
- const children = fragmentList[0].children || [];
431
- if (!children.length) {
432
- return false;
433
- }
434
- const [p] = Editor.nodes(editor, {
435
- match: (n) => Element.isElement(n) && n.type === "paragraph",
436
- at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
437
- });
438
- if (specialNode && !Path.hasPrevious(p[1])) {
439
- if (!Node.string(p[0])) {
440
- yield insertNodesBatch(editor, children, Path.next(specialNode[1]));
441
- const parent = Node.parent(editor, p[1]);
442
- const nextPath = [
443
- ...specialNode[1].slice(0, -1),
444
- specialNode[1][specialNode[1].length - 1] + children.length
445
- ];
446
- if (parent.children.length > 1) {
447
- Transforms.moveNodes(editor, {
448
- at: {
449
- anchor: { path: Path.next(p[1]), offset: 0 },
450
- focus: {
451
- path: [...p[1].slice(0, -1), parent.children.length - 1],
452
- offset: 0
453
- }
454
- },
455
- to: [...nextPath, 1]
456
- });
457
- }
458
- Transforms.delete(editor, { at: selection });
459
- } else {
460
- yield insertNodesBatch(editor, children, selection.anchor.path, {
461
- select: true
462
- });
463
- }
464
- if (fragmentList.length > 1) {
465
- yield insertNodesBatch(
466
- editor,
467
- fragmentList.slice(1),
468
- selection.anchor.path,
469
- { select: true }
470
- );
471
- }
472
- return true;
473
- }
474
- }
475
- if ((node == null ? void 0 : node[0].type) === "table-cell") {
476
- Transforms.insertFragment(editor, getTextsNode(fragmentList), {
477
- at: selection
478
- });
479
- return true;
480
- }
481
- if ((node == null ? void 0 : node[0].type) === "head") {
482
- if (fragmentList[0].type) {
483
- if (fragmentList[0].type !== "paragraph") {
484
- Transforms.insertNodes(
485
- editor,
486
- {
487
- type: "paragraph",
488
- children: [{ text: "" }]
489
- },
490
- { at: selection, select: true }
491
- );
492
- return true;
493
- }
494
- return false;
495
- }
496
- const texts = fragmentList.filter((c) => c.text);
497
- if (texts.length) {
498
- yield insertNodesBatch(editor, texts, selection.anchor.path);
499
- return true;
500
- }
501
- return false;
502
- }
503
- if (fragmentList.length === 1 && (fragmentList[0].type === "paragraph" || !fragmentList[0].type) && node) {
504
- const text = Node.string(fragmentList[0]);
505
- if (text) {
506
- Transforms.insertText(editor, text, {
507
- at: selection
611
+ return function blobToFile(blobUrl, fileName) {
612
+ return _ref.apply(this, arguments);
613
+ };
614
+ }();
615
+ /**
616
+ * 分段处理文件上传,避免阻塞主线程
617
+ */ var upLoadFileBatch = /*#__PURE__*/ function() {
618
+ var _ref = _async_to_generator(function(fragmentList, editorProps) {
619
+ var mediaFragments, collectMediaFragments, hideLoading, i, batch, progress, error;
620
+ return _ts_generator(this, function(_state) {
621
+ switch(_state.label){
622
+ case 0:
623
+ mediaFragments = [];
624
+ // 收集所有需要上传的媒体文件
625
+ collectMediaFragments = function(fragments) {
626
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
627
+ try {
628
+ for(var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
629
+ var fragment = _step.value;
630
+ if (fragment.type === 'media') {
631
+ mediaFragments.push(fragment);
632
+ }
633
+ if (fragment === null || fragment === void 0 ? void 0 : fragment.children) {
634
+ collectMediaFragments(fragment.children);
635
+ }
636
+ }
637
+ } catch (err) {
638
+ _didIteratorError = true;
639
+ _iteratorError = err;
640
+ } finally{
641
+ try {
642
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
643
+ _iterator.return();
644
+ }
645
+ } finally{
646
+ if (_didIteratorError) {
647
+ throw _iteratorError;
648
+ }
649
+ }
650
+ }
651
+ };
652
+ collectMediaFragments(fragmentList);
653
+ if (mediaFragments.length === 0) {
654
+ return [
655
+ 2
656
+ ];
657
+ }
658
+ // 显示上传进度
659
+ hideLoading = message.loading("Uploading ".concat(mediaFragments.length, " files..."), 0);
660
+ _state.label = 1;
661
+ case 1:
662
+ _state.trys.push([
663
+ 1,
664
+ 7,
665
+ 8,
666
+ 9
667
+ ]);
668
+ i = 0;
669
+ _state.label = 2;
670
+ case 2:
671
+ if (!(i < mediaFragments.length)) return [
672
+ 3,
673
+ 6
674
+ ];
675
+ batch = mediaFragments.slice(i, i + BATCH_SIZE);
676
+ return [
677
+ 4,
678
+ Promise.all(batch.map(/*#__PURE__*/ function() {
679
+ var _ref = _async_to_generator(function(fragment) {
680
+ var url, _editorProps_image, file, serverUrl, _editorProps_image1, serverUrl1;
681
+ return _ts_generator(this, function(_state) {
682
+ switch(_state.label){
683
+ case 0:
684
+ url = fragment.url;
685
+ if (!(url === null || url === void 0 ? void 0 : url.startsWith('blob:'))) return [
686
+ 3,
687
+ 4
688
+ ];
689
+ return [
690
+ 4,
691
+ blobToFile(fragment === null || fragment === void 0 ? void 0 : fragment.url, 'image.png')
692
+ ];
693
+ case 1:
694
+ file = _state.sent();
695
+ if (!((_editorProps_image = editorProps.image) === null || _editorProps_image === void 0 ? void 0 : _editorProps_image.upload)) return [
696
+ 3,
697
+ 3
698
+ ];
699
+ return [
700
+ 4,
701
+ editorProps.image.upload([
702
+ file
703
+ ])
704
+ ];
705
+ case 2:
706
+ serverUrl = [
707
+ _state.sent()
708
+ ].flat(1);
709
+ fragment.url = serverUrl === null || serverUrl === void 0 ? void 0 : serverUrl[0];
710
+ fragment.downloadUrl = serverUrl === null || serverUrl === void 0 ? void 0 : serverUrl[0];
711
+ _state.label = 3;
712
+ case 3:
713
+ return [
714
+ 3,
715
+ 6
716
+ ];
717
+ case 4:
718
+ if (!((_editorProps_image1 = editorProps.image) === null || _editorProps_image1 === void 0 ? void 0 : _editorProps_image1.upload)) return [
719
+ 3,
720
+ 6
721
+ ];
722
+ return [
723
+ 4,
724
+ editorProps.image.upload([
725
+ fragment === null || fragment === void 0 ? void 0 : fragment.url
726
+ ])
727
+ ];
728
+ case 5:
729
+ serverUrl1 = [
730
+ _state.sent()
731
+ ].flat(1);
732
+ fragment.url = serverUrl1 === null || serverUrl1 === void 0 ? void 0 : serverUrl1[0];
733
+ fragment.downloadUrl = serverUrl1 === null || serverUrl1 === void 0 ? void 0 : serverUrl1[0];
734
+ _state.label = 6;
735
+ case 6:
736
+ return [
737
+ 2
738
+ ];
739
+ }
740
+ });
741
+ });
742
+ return function(fragment) {
743
+ return _ref.apply(this, arguments);
744
+ };
745
+ }()))
746
+ ];
747
+ case 3:
748
+ _state.sent();
749
+ // 更新进度
750
+ progress = Math.min((i + BATCH_SIZE) / mediaFragments.length * 100, 100);
751
+ hideLoading();
752
+ message.loading("Uploading ".concat(mediaFragments.length, " files... ").concat(Math.round(progress), "%"), 0);
753
+ if (!(i + BATCH_SIZE < mediaFragments.length)) return [
754
+ 3,
755
+ 5
756
+ ];
757
+ return [
758
+ 4,
759
+ new Promise(function(resolve) {
760
+ return setTimeout(resolve, BATCH_DELAY);
761
+ })
762
+ ];
763
+ case 4:
764
+ _state.sent();
765
+ _state.label = 5;
766
+ case 5:
767
+ i += BATCH_SIZE;
768
+ return [
769
+ 3,
770
+ 2
771
+ ];
772
+ case 6:
773
+ message.success('Upload completed');
774
+ return [
775
+ 3,
776
+ 9
777
+ ];
778
+ case 7:
779
+ error = _state.sent();
780
+ console.error('文件上传失败:', error);
781
+ message.error('Some files failed to upload');
782
+ return [
783
+ 3,
784
+ 9
785
+ ];
786
+ case 8:
787
+ hideLoading();
788
+ return [
789
+ 7
790
+ ];
791
+ case 9:
792
+ return [
793
+ 2
794
+ ];
795
+ }
508
796
  });
509
- return true;
510
- }
511
- }
512
- const processedNodes = fragmentList == null ? void 0 : fragmentList.map((item) => {
513
- if (!item.type) {
514
- return { type: "paragraph", children: [item] };
515
- }
516
- if (item.type === "code") {
517
- return __spreadProps(__spreadValues({}, item), {
518
- type: "code",
519
- value: Node.string(item),
520
- language: item.language || "txt"
797
+ });
798
+ return function upLoadFileBatch(fragmentList, editorProps) {
799
+ return _ref.apply(this, arguments);
800
+ };
801
+ }();
802
+ /**
803
+ * 分段插入节点,避免一次性插入大量内容导致卡顿
804
+ */ var insertNodesBatch = /*#__PURE__*/ function() {
805
+ var _ref = _async_to_generator(function(editor, nodes, at, options) {
806
+ var i, batch, insertAt;
807
+ return _ts_generator(this, function(_state) {
808
+ switch(_state.label){
809
+ case 0:
810
+ if (nodes.length <= BATCH_SIZE) {
811
+ // 小批量直接插入
812
+ Transforms.insertNodes(editor, nodes, _object_spread({
813
+ at: at
814
+ }, options));
815
+ return [
816
+ 2
817
+ ];
818
+ }
819
+ i = 0;
820
+ _state.label = 1;
821
+ case 1:
822
+ if (!(i < nodes.length)) return [
823
+ 3,
824
+ 4
825
+ ];
826
+ batch = nodes.slice(i, i + BATCH_SIZE);
827
+ // 计算插入位置
828
+ insertAt = at ? _to_consumable_array(at.slice(0, -1)).concat([
829
+ at[at.length - 1] + i
830
+ ]) : undefined;
831
+ Transforms.insertNodes(editor, batch, {
832
+ at: insertAt,
833
+ select: (options === null || options === void 0 ? void 0 : options.select) && i + BATCH_SIZE >= nodes.length
834
+ });
835
+ if (!(i + BATCH_SIZE < nodes.length)) return [
836
+ 3,
837
+ 3
838
+ ];
839
+ return [
840
+ 4,
841
+ new Promise(function(resolve) {
842
+ return setTimeout(resolve, BATCH_DELAY);
843
+ })
844
+ ];
845
+ case 2:
846
+ _state.sent();
847
+ _state.label = 3;
848
+ case 3:
849
+ i += BATCH_SIZE;
850
+ return [
851
+ 3,
852
+ 1
853
+ ];
854
+ case 4:
855
+ return [
856
+ 2
857
+ ];
858
+ }
521
859
  });
522
- }
523
- return item;
524
860
  });
525
- yield insertNodesBatch(editor, processedNodes);
526
- return true;
527
- } catch (error) {
528
- console.error("插入HTML节点失败:", error);
529
- hideLoading();
530
- message.error("Content parsing failed, please try again");
531
- return false;
532
- }
533
- });
534
- export {
535
- ELEMENT_TAGS,
536
- TEXT_TAGS,
537
- deserialize,
538
- htmlToFragmentList,
539
- insertParsedHtmlNodes
861
+ return function insertNodesBatch(editor, nodes, at, options) {
862
+ return _ref.apply(this, arguments);
863
+ };
864
+ }();
865
+ /**
866
+ * 优化的HTML解析函数,支持分段处理
867
+ */ var parseHtmlOptimized = /*#__PURE__*/ function() {
868
+ var _ref = _async_to_generator(function(html, rtf) {
869
+ return _ts_generator(this, function(_state) {
870
+ // 对于小内容,使用同步处理
871
+ if (html.length < MAX_SYNC_SIZE) {
872
+ return [
873
+ 2,
874
+ docxDeserializer(rtf, html.trim())
875
+ ];
876
+ }
877
+ // 对于大内容,使用异步处理
878
+ return [
879
+ 2,
880
+ new Promise(function(resolve) {
881
+ // 使用 requestIdleCallback 在空闲时间处理
882
+ var processInIdle = function() {
883
+ try {
884
+ var result = docxDeserializer(rtf, html.trim());
885
+ resolve(result);
886
+ } catch (error) {
887
+ console.error('HTML解析失败:', error);
888
+ resolve([]);
889
+ }
890
+ };
891
+ if ('requestIdleCallback' in window) {
892
+ requestIdleCallback(processInIdle, {
893
+ timeout: 1000
894
+ });
895
+ } else {
896
+ // 降级到 setTimeout
897
+ setTimeout(processInIdle, 0);
898
+ }
899
+ })
900
+ ];
901
+ });
902
+ });
903
+ return function parseHtmlOptimized(html, rtf) {
904
+ return _ref.apply(this, arguments);
905
+ };
906
+ }();
907
+ /**
908
+ * 转化 html 到 slate - 性能优化版本
909
+ * @param editor
910
+ * @param html
911
+ * @returns
912
+ */ export var htmlToFragmentList = function(html, rtl) {
913
+ var fragmentList = docxDeserializer(rtl, html.trim());
914
+ return fragmentList.map(function(fragment) {
915
+ if (fragment.type === 'table') {
916
+ return EditorUtils.wrapperCardNode(fragment);
917
+ }
918
+ if (fragment.type === '"paragraph"' && fragment.children.length === 1) {
919
+ return {
920
+ type: 'paragraph',
921
+ children: fragment.children
922
+ };
923
+ }
924
+ return fragment;
925
+ });
540
926
  };
927
+ export var insertParsedHtmlNodes = /*#__PURE__*/ function() {
928
+ var _ref = _async_to_generator(function(editor, html, editorProps, rtl) {
929
+ var hideLoading, fragmentList, _Editor_nodes, node, selection, processedNodes, back, _Editor_nodes1, specialNode, parsed, inner, hasCodeTags, textContent, children, _Editor_nodes2, p, parent, nextPath, texts, text, processedNodes1, error;
930
+ return _ts_generator(this, function(_state) {
931
+ switch(_state.label){
932
+ case 0:
933
+ // 1. 基础检查
934
+ if (html.startsWith('<html>\r\n<body>\r\n\x3C!--StartFragment--><img src="')) {
935
+ return [
936
+ 2,
937
+ false
938
+ ];
939
+ }
940
+ // 2. 显示解析提示
941
+ hideLoading = message.loading('parsing...', 0);
942
+ _state.label = 1;
943
+ case 1:
944
+ _state.trys.push([
945
+ 1,
946
+ 17,
947
+ ,
948
+ 18
949
+ ]);
950
+ return [
951
+ 4,
952
+ parseHtmlOptimized(html, rtl)
953
+ ];
954
+ case 2:
955
+ fragmentList = _state.sent();
956
+ if (!(fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length)) {
957
+ hideLoading();
958
+ return [
959
+ 2,
960
+ false
961
+ ];
962
+ }
963
+ // 4. 异步处理文件上传
964
+ return [
965
+ 4,
966
+ upLoadFileBatch(fragmentList, editorProps)
967
+ ];
968
+ case 3:
969
+ _state.sent();
970
+ debugLog('wordFragmentList', fragmentList);
971
+ hideLoading();
972
+ // 5. 获取当前节点
973
+ _Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
974
+ match: function(n) {
975
+ return Element.isElement(n);
976
+ }
977
+ }), 1), node = _Editor_nodes[0];
978
+ selection = editor.selection;
979
+ if (!(!selection || !Editor.hasPath(editor, selection.anchor.path))) return [
980
+ 3,
981
+ 5
982
+ ];
983
+ processedNodes = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
984
+ if (!item.type) {
985
+ return {
986
+ type: 'paragraph',
987
+ children: [
988
+ item
989
+ ]
990
+ };
991
+ }
992
+ return item;
993
+ });
994
+ return [
995
+ 4,
996
+ insertNodesBatch(editor, processedNodes)
997
+ ];
998
+ case 4:
999
+ _state.sent();
1000
+ return [
1001
+ 2,
1002
+ true
1003
+ ];
1004
+ case 5:
1005
+ // 7. 处理非折叠选区
1006
+ if (!Range.isCollapsed(selection)) {
1007
+ back = new BackspaceKey(editor);
1008
+ back.range();
1009
+ Transforms.select(editor, Range.start(selection));
1010
+ setTimeout(function() {
1011
+ var _node_;
1012
+ var node = Editor === null || Editor === void 0 ? void 0 : Editor.node(editor, [
1013
+ 0
1014
+ ]);
1015
+ if (editor.children.length > 1 && (node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type) === 'paragraph' && !Node.string(node[0])) {
1016
+ Transforms.delete(editor, {
1017
+ at: [
1018
+ 0
1019
+ ]
1020
+ });
1021
+ }
1022
+ });
1023
+ }
1024
+ // 8. 获取特殊节点类型
1025
+ _Editor_nodes1 = _sliced_to_array(Editor.nodes(editor, {
1026
+ match: function(n) {
1027
+ return Element.isElement(n) && [
1028
+ 'code',
1029
+ 'table-cell',
1030
+ 'head',
1031
+ 'list-item'
1032
+ ].includes(n.type);
1033
+ },
1034
+ at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
1035
+ }), 1), specialNode = _Editor_nodes1[0];
1036
+ if (specialNode) {
1037
+ node = specialNode;
1038
+ }
1039
+ // 9. 处理代码块和表格单元格
1040
+ parsed = new DOMParser().parseFromString(html, 'text/html').body;
1041
+ inner = !!parsed.querySelector('[data-be]');
1042
+ // 对于代码块,检查是否包含代码相关的标签
1043
+ if ((node === null || node === void 0 ? void 0 : node[0].type) === 'code') {
1044
+ hasCodeTags = html.includes('<pre>') || html.includes('<code>') || inner;
1045
+ if (hasCodeTags) {
1046
+ // 从 HTML 中提取纯文本内容
1047
+ textContent = parsed.textContent || '';
1048
+ if (textContent.trim()) {
1049
+ Transforms.insertText(editor, textContent.trim(), {
1050
+ at: selection
1051
+ });
1052
+ return [
1053
+ 2,
1054
+ true
1055
+ ];
1056
+ }
1057
+ }
1058
+ }
1059
+ // 处理表格单元格
1060
+ if (inner && (node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
1061
+ return [
1062
+ 2,
1063
+ true
1064
+ ];
1065
+ }
1066
+ if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && fragmentList[0].type === 'list')) return [
1067
+ 3,
1068
+ 12
1069
+ ];
1070
+ children = fragmentList[0].children || [];
1071
+ if (!children.length) {
1072
+ return [
1073
+ 2,
1074
+ false
1075
+ ];
1076
+ }
1077
+ _Editor_nodes2 = _sliced_to_array(Editor.nodes(editor, {
1078
+ match: function(n) {
1079
+ return Element.isElement(n) && n.type === 'paragraph';
1080
+ },
1081
+ at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
1082
+ }), 1), p = _Editor_nodes2[0];
1083
+ if (!(specialNode && !Path.hasPrevious(p[1]))) return [
1084
+ 3,
1085
+ 12
1086
+ ];
1087
+ if (!!Node.string(p[0])) return [
1088
+ 3,
1089
+ 7
1090
+ ];
1091
+ return [
1092
+ 4,
1093
+ insertNodesBatch(editor, children, Path.next(specialNode[1]))
1094
+ ];
1095
+ case 6:
1096
+ _state.sent();
1097
+ parent = Node.parent(editor, p[1]);
1098
+ nextPath = _to_consumable_array(specialNode[1].slice(0, -1)).concat([
1099
+ specialNode[1][specialNode[1].length - 1] + children.length
1100
+ ]);
1101
+ if (parent.children.length > 1) {
1102
+ Transforms.moveNodes(editor, {
1103
+ at: {
1104
+ anchor: {
1105
+ path: Path.next(p[1]),
1106
+ offset: 0
1107
+ },
1108
+ focus: {
1109
+ path: _to_consumable_array(p[1].slice(0, -1)).concat([
1110
+ parent.children.length - 1
1111
+ ]),
1112
+ offset: 0
1113
+ }
1114
+ },
1115
+ to: _to_consumable_array(nextPath).concat([
1116
+ 1
1117
+ ])
1118
+ });
1119
+ }
1120
+ Transforms.delete(editor, {
1121
+ at: selection
1122
+ });
1123
+ return [
1124
+ 3,
1125
+ 9
1126
+ ];
1127
+ case 7:
1128
+ return [
1129
+ 4,
1130
+ insertNodesBatch(editor, children, selection.anchor.path, {
1131
+ select: true
1132
+ })
1133
+ ];
1134
+ case 8:
1135
+ _state.sent();
1136
+ _state.label = 9;
1137
+ case 9:
1138
+ if (!(fragmentList.length > 1)) return [
1139
+ 3,
1140
+ 11
1141
+ ];
1142
+ return [
1143
+ 4,
1144
+ insertNodesBatch(editor, fragmentList.slice(1), selection.anchor.path, {
1145
+ select: true
1146
+ })
1147
+ ];
1148
+ case 10:
1149
+ _state.sent();
1150
+ _state.label = 11;
1151
+ case 11:
1152
+ return [
1153
+ 2,
1154
+ true
1155
+ ];
1156
+ case 12:
1157
+ // 11. 处理表格单元格
1158
+ if ((node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
1159
+ Transforms.insertFragment(editor, getTextsNode(fragmentList), {
1160
+ at: selection
1161
+ });
1162
+ return [
1163
+ 2,
1164
+ true
1165
+ ];
1166
+ }
1167
+ if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'head')) return [
1168
+ 3,
1169
+ 15
1170
+ ];
1171
+ if (fragmentList[0].type) {
1172
+ if (fragmentList[0].type !== 'paragraph') {
1173
+ Transforms.insertNodes(editor, {
1174
+ type: 'paragraph',
1175
+ children: [
1176
+ {
1177
+ text: ''
1178
+ }
1179
+ ]
1180
+ }, {
1181
+ at: selection,
1182
+ select: true
1183
+ });
1184
+ return [
1185
+ 2,
1186
+ true
1187
+ ];
1188
+ }
1189
+ return [
1190
+ 2,
1191
+ false
1192
+ ];
1193
+ }
1194
+ texts = fragmentList.filter(function(c) {
1195
+ return c.text;
1196
+ });
1197
+ if (!texts.length) return [
1198
+ 3,
1199
+ 14
1200
+ ];
1201
+ return [
1202
+ 4,
1203
+ insertNodesBatch(editor, texts, selection.anchor.path)
1204
+ ];
1205
+ case 13:
1206
+ _state.sent();
1207
+ return [
1208
+ 2,
1209
+ true
1210
+ ];
1211
+ case 14:
1212
+ return [
1213
+ 2,
1214
+ false
1215
+ ];
1216
+ case 15:
1217
+ // 13. 处理单个段落的特殊情况
1218
+ if (fragmentList.length === 1 && (fragmentList[0].type === 'paragraph' || !fragmentList[0].type) && node) {
1219
+ text = Node.string(fragmentList[0]);
1220
+ if (text) {
1221
+ Transforms.insertText(editor, text, {
1222
+ at: selection
1223
+ });
1224
+ return [
1225
+ 2,
1226
+ true
1227
+ ];
1228
+ }
1229
+ }
1230
+ // 14. 默认情况:替换选中节点
1231
+ processedNodes1 = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
1232
+ if (!item.type) {
1233
+ return {
1234
+ type: 'paragraph',
1235
+ children: [
1236
+ item
1237
+ ]
1238
+ };
1239
+ }
1240
+ if (item.type === 'code') {
1241
+ return _object_spread_props(_object_spread({}, item), {
1242
+ type: 'code',
1243
+ value: Node.string(item),
1244
+ language: item.language || 'txt'
1245
+ });
1246
+ }
1247
+ return item;
1248
+ });
1249
+ return [
1250
+ 4,
1251
+ insertNodesBatch(editor, processedNodes1)
1252
+ ];
1253
+ case 16:
1254
+ _state.sent();
1255
+ return [
1256
+ 2,
1257
+ true
1258
+ ];
1259
+ case 17:
1260
+ error = _state.sent();
1261
+ console.error('插入HTML节点失败:', error);
1262
+ hideLoading();
1263
+ message.error('Content parsing failed, please try again');
1264
+ return [
1265
+ 2,
1266
+ false
1267
+ ];
1268
+ case 18:
1269
+ return [
1270
+ 2
1271
+ ];
1272
+ }
1273
+ });
1274
+ });
1275
+ return function insertParsedHtmlNodes(editor, html, editorProps, rtl) {
1276
+ return _ref.apply(this, arguments);
1277
+ };
1278
+ }();