@ant-design/agentic-ui 2.7.1 → 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 (583) 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 -268
  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.d.ts +2 -0
  320. package/dist/Plugins/chart/ChartRender.js +981 -705
  321. package/dist/Plugins/chart/ChartStatistic/index.js +47 -62
  322. package/dist/Plugins/chart/ChartStatistic/style.js +142 -143
  323. package/dist/Plugins/chart/ChartStatistic/utils.js +37 -27
  324. package/dist/Plugins/chart/DonutChart/Legend.js +94 -124
  325. package/dist/Plugins/chart/DonutChart/constants.js +4 -11
  326. package/dist/Plugins/chart/DonutChart/hooks.js +183 -112
  327. package/dist/Plugins/chart/DonutChart/index.js +588 -516
  328. package/dist/Plugins/chart/DonutChart/plugins.js +47 -44
  329. package/dist/Plugins/chart/DonutChart/style.js +186 -175
  330. package/dist/Plugins/chart/DonutChart/types.js +1 -0
  331. package/dist/Plugins/chart/FunnelChart/index.js +844 -647
  332. package/dist/Plugins/chart/FunnelChart/style.js +97 -71
  333. package/dist/Plugins/chart/LineChart/index.js +516 -393
  334. package/dist/Plugins/chart/LineChart/style.js +114 -90
  335. package/dist/Plugins/chart/RadarChart/index.js +580 -582
  336. package/dist/Plugins/chart/RadarChart/style.js +122 -112
  337. package/dist/Plugins/chart/ScatterChart/index.js +633 -640
  338. package/dist/Plugins/chart/ScatterChart/style.js +108 -94
  339. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +151 -80
  340. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +160 -41
  341. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundaryExample.js +80 -62
  342. package/dist/Plugins/chart/components/ChartContainer/index.js +2 -7
  343. package/dist/Plugins/chart/components/ChartContainer/style.js +121 -91
  344. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +58 -90
  345. package/dist/Plugins/chart/components/ChartFilter/style.js +169 -154
  346. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +54 -59
  347. package/dist/Plugins/chart/components/ChartToolBar/style.js +132 -117
  348. package/dist/Plugins/chart/components/icons/TimeIcon.js +20 -26
  349. package/dist/Plugins/chart/components/index.js +32 -34
  350. package/dist/Plugins/chart/const.js +34 -25
  351. package/dist/Plugins/chart/hooks/useChartStatistic.js +1 -0
  352. package/dist/Plugins/chart/index.js +436 -339
  353. package/dist/Plugins/chart/loadChartRuntime.js +209 -87
  354. package/dist/Plugins/chart/utils.js +311 -87
  355. package/dist/Plugins/code/CodeUI/Katex/Katex.js +112 -66
  356. package/dist/Plugins/code/components/AceEditor.js +334 -237
  357. package/dist/Plugins/code/components/AceEditorContainer.js +23 -32
  358. package/dist/Plugins/code/components/CodeContainer.js +41 -56
  359. package/dist/Plugins/code/components/CodeRenderer.js +202 -155
  360. package/dist/Plugins/code/components/CodeToolbar.js +137 -181
  361. package/dist/Plugins/code/components/HtmlPreview.js +19 -22
  362. package/dist/Plugins/code/components/LanguageSelector.js +162 -96
  363. package/dist/Plugins/code/components/LoadImage.js +145 -46
  364. package/dist/Plugins/code/components/ThinkBlock.js +38 -42
  365. package/dist/Plugins/code/components/index.js +13 -23
  366. package/dist/Plugins/code/hooks/index.js +7 -9
  367. package/dist/Plugins/code/hooks/useCodeEditorState.js +139 -62
  368. package/dist/Plugins/code/hooks/useRenderConditions.js +31 -23
  369. package/dist/Plugins/code/hooks/useToolbarConfig.js +44 -46
  370. package/dist/Plugins/code/index.js +141 -89
  371. package/dist/Plugins/code/langIconMap.js +400 -108
  372. package/dist/Plugins/code/langIcons/AbapIcon.js +90 -57
  373. package/dist/Plugins/code/langIcons/ActionscriptIcon.js +89 -56
  374. package/dist/Plugins/code/langIcons/AdaIcon.js +89 -52
  375. package/dist/Plugins/code/langIcons/ApacheIcon.js +205 -254
  376. package/dist/Plugins/code/langIcons/ApexIcon.js +108 -82
  377. package/dist/Plugins/code/langIcons/AplIcon.js +90 -54
  378. package/dist/Plugins/code/langIcons/ApplescriptIcon.js +89 -56
  379. package/dist/Plugins/code/langIcons/AstroIcon.js +91 -58
  380. package/dist/Plugins/code/langIcons/AwkIcon.js +98 -68
  381. package/dist/Plugins/code/langIcons/BallerinaIcon.js +92 -59
  382. package/dist/Plugins/code/langIcons/BatIcon.js +158 -229
  383. package/dist/Plugins/code/langIcons/BicepIcon.js +91 -58
  384. package/dist/Plugins/code/langIcons/BladeIcon.js +90 -58
  385. package/dist/Plugins/code/langIcons/CIcon.js +90 -55
  386. package/dist/Plugins/code/langIcons/CadenceIcon.js +89 -56
  387. package/dist/Plugins/code/langIcons/ClojureIcon.js +96 -75
  388. package/dist/Plugins/code/langIcons/CmakeIcon.js +93 -62
  389. package/dist/Plugins/code/langIcons/CobolIcon.js +99 -70
  390. package/dist/Plugins/code/langIcons/CodeqlIcon.js +96 -76
  391. package/dist/Plugins/code/langIcons/CoffeeIcon.js +89 -56
  392. package/dist/Plugins/code/langIcons/ConsoleIcon.js +89 -56
  393. package/dist/Plugins/code/langIcons/CppIcon.js +90 -55
  394. package/dist/Plugins/code/langIcons/CrystalIcon.js +90 -57
  395. package/dist/Plugins/code/langIcons/CsharpIcon.js +90 -59
  396. package/dist/Plugins/code/langIcons/CssIcon.js +89 -52
  397. package/dist/Plugins/code/langIcons/DIcon.js +90 -53
  398. package/dist/Plugins/code/langIcons/DartIcon.js +92 -71
  399. package/dist/Plugins/code/langIcons/DatabaseIcon.js +90 -57
  400. package/dist/Plugins/code/langIcons/DiffIcon.js +90 -57
  401. package/dist/Plugins/code/langIcons/DockerIcon.js +89 -56
  402. package/dist/Plugins/code/langIcons/DotenvIcon.js +94 -56
  403. package/dist/Plugins/code/langIcons/ElixirIcon.js +91 -58
  404. package/dist/Plugins/code/langIcons/ElmIcon.js +105 -58
  405. package/dist/Plugins/code/langIcons/ErbIcon.js +90 -54
  406. package/dist/Plugins/code/langIcons/ErlangIcon.js +89 -56
  407. package/dist/Plugins/code/langIcons/FsharpIcon.js +93 -62
  408. package/dist/Plugins/code/langIcons/GdscriptIcon.js +96 -88
  409. package/dist/Plugins/code/langIcons/GlslIcon.js +90 -58
  410. package/dist/Plugins/code/langIcons/GnuplotIcon.js +98 -77
  411. package/dist/Plugins/code/langIcons/GoIcon.js +114 -93
  412. package/dist/Plugins/code/langIcons/GraphqlIcon.js +106 -66
  413. package/dist/Plugins/code/langIcons/GroovyIcon.js +89 -56
  414. package/dist/Plugins/code/langIcons/HackIcon.js +97 -64
  415. package/dist/Plugins/code/langIcons/HamlIcon.js +89 -56
  416. package/dist/Plugins/code/langIcons/HandlebarsIcon.js +89 -56
  417. package/dist/Plugins/code/langIcons/HaskellIcon.js +93 -64
  418. package/dist/Plugins/code/langIcons/HclIcon.js +118 -93
  419. package/dist/Plugins/code/langIcons/HclLightIcon.js +118 -97
  420. package/dist/Plugins/code/langIcons/HjsonIcon.js +94 -62
  421. package/dist/Plugins/code/langIcons/HlslIcon.js +96 -76
  422. package/dist/Plugins/code/langIcons/HtmlIcon.js +89 -56
  423. package/dist/Plugins/code/langIcons/HttpIcon.js +89 -56
  424. package/dist/Plugins/code/langIcons/ImbaIcon.js +98 -65
  425. package/dist/Plugins/code/langIcons/IniIcon.js +90 -54
  426. package/dist/Plugins/code/langIcons/JavaIcon.js +89 -56
  427. package/dist/Plugins/code/langIcons/JavascriptIcon.js +89 -56
  428. package/dist/Plugins/code/langIcons/JinjaIcon.js +100 -68
  429. package/dist/Plugins/code/langIcons/Json5Icon.js +100 -82
  430. package/dist/Plugins/code/langIcons/JsonIcon.js +89 -56
  431. package/dist/Plugins/code/langIcons/JsonnetIcon.js +102 -86
  432. package/dist/Plugins/code/langIcons/JuliaIcon.js +105 -52
  433. package/dist/Plugins/code/langIcons/KotlinIcon.js +104 -74
  434. package/dist/Plugins/code/langIcons/KustoIcon.js +90 -57
  435. package/dist/Plugins/code/langIcons/LessIcon.js +90 -57
  436. package/dist/Plugins/code/langIcons/LiquidIcon.js +91 -58
  437. package/dist/Plugins/code/langIcons/LispIcon.js +89 -56
  438. package/dist/Plugins/code/langIcons/LuaIcon.js +93 -60
  439. package/dist/Plugins/code/langIcons/MakefileIcon.js +91 -58
  440. package/dist/Plugins/code/langIcons/MarkdownIcon.js +89 -56
  441. package/dist/Plugins/code/langIcons/MarkojsIcon.js +96 -73
  442. package/dist/Plugins/code/langIcons/MatlabIcon.js +93 -64
  443. package/dist/Plugins/code/langIcons/MdxIcon.js +90 -53
  444. package/dist/Plugins/code/langIcons/MermaidIcon.js +95 -64
  445. package/dist/Plugins/code/langIcons/MojoIcon.js +95 -62
  446. package/dist/Plugins/code/langIcons/NginxIcon.js +94 -61
  447. package/dist/Plugins/code/langIcons/NimIcon.js +91 -54
  448. package/dist/Plugins/code/langIcons/NixIcon.js +92 -56
  449. package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +90 -59
  450. package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +90 -57
  451. package/dist/Plugins/code/langIcons/OcamlIcon.js +90 -61
  452. package/dist/Plugins/code/langIcons/PascalIcon.js +95 -55
  453. package/dist/Plugins/code/langIcons/Perl6Icon.js +299 -320
  454. package/dist/Plugins/code/langIcons/PerlIcon.js +89 -56
  455. package/dist/Plugins/code/langIcons/PhpIcon.js +89 -52
  456. package/dist/Plugins/code/langIcons/PostcssIcon.js +130 -113
  457. package/dist/Plugins/code/langIcons/PowershellIcon.js +91 -58
  458. package/dist/Plugins/code/langIcons/PrismaIcon.js +97 -68
  459. package/dist/Plugins/code/langIcons/PrologIcon.js +91 -58
  460. package/dist/Plugins/code/langIcons/ProtoIcon.js +94 -68
  461. package/dist/Plugins/code/langIcons/PugIcon.js +177 -145
  462. package/dist/Plugins/code/langIcons/PuppetIcon.js +96 -52
  463. package/dist/Plugins/code/langIcons/PurescriptIcon.js +93 -61
  464. package/dist/Plugins/code/langIcons/PythonIcon.js +90 -61
  465. package/dist/Plugins/code/langIcons/RIcon.js +89 -52
  466. package/dist/Plugins/code/langIcons/RazorIcon.js +90 -57
  467. package/dist/Plugins/code/langIcons/ReactIcon.js +89 -56
  468. package/dist/Plugins/code/langIcons/ReactTsIcon.js +90 -57
  469. package/dist/Plugins/code/langIcons/RubyIcon.js +91 -58
  470. package/dist/Plugins/code/langIcons/RustIcon.js +89 -56
  471. package/dist/Plugins/code/langIcons/SasIcon.js +89 -52
  472. package/dist/Plugins/code/langIcons/SassIcon.js +90 -57
  473. package/dist/Plugins/code/langIcons/ScalaIcon.js +96 -53
  474. package/dist/Plugins/code/langIcons/SchemeIcon.js +91 -58
  475. package/dist/Plugins/code/langIcons/ShaderlabIcon.js +89 -56
  476. package/dist/Plugins/code/langIcons/SolidityIcon.js +94 -52
  477. package/dist/Plugins/code/langIcons/SparqlIcon.js +94 -64
  478. package/dist/Plugins/code/langIcons/StataIcon.js +126 -108
  479. package/dist/Plugins/code/langIcons/StylusIcon.js +92 -59
  480. package/dist/Plugins/code/langIcons/SvelteIcon.js +91 -58
  481. package/dist/Plugins/code/langIcons/SwiftIcon.js +90 -57
  482. package/dist/Plugins/code/langIcons/SystemverilogIcon.js +115 -102
  483. package/dist/Plugins/code/langIcons/TclIcon.js +89 -52
  484. package/dist/Plugins/code/langIcons/TexIcon.js +99 -65
  485. package/dist/Plugins/code/langIcons/TomlIcon.js +94 -70
  486. package/dist/Plugins/code/langIcons/TwigIcon.js +89 -56
  487. package/dist/Plugins/code/langIcons/TypescriptIcon.js +93 -60
  488. package/dist/Plugins/code/langIcons/VerilogIcon.js +89 -56
  489. package/dist/Plugins/code/langIcons/VhdlIcon.js +94 -64
  490. package/dist/Plugins/code/langIcons/VimIcon.js +278 -420
  491. package/dist/Plugins/code/langIcons/VueIcon.js +92 -59
  492. package/dist/Plugins/code/langIcons/WebassemblyIcon.js +103 -76
  493. package/dist/Plugins/code/langIcons/WenyanIcon.js +104 -100
  494. package/dist/Plugins/code/langIcons/WgslIcon.js +93 -77
  495. package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +100 -71
  496. package/dist/Plugins/code/langIcons/XmlIcon.js +89 -52
  497. package/dist/Plugins/code/langIcons/XslIcon.js +94 -66
  498. package/dist/Plugins/code/langIcons/YamlIcon.js +89 -56
  499. package/dist/Plugins/code/langIcons/ZigIcon.js +106 -81
  500. package/dist/Plugins/code/langIcons/index.js +128 -259
  501. package/dist/Plugins/code/utils/index.js +5 -5
  502. package/dist/Plugins/code/utils/langOptions.js +86 -11
  503. package/dist/Plugins/defaultPlugins.js +9 -13
  504. package/dist/Plugins/formatter/index.js +205 -105
  505. package/dist/Plugins/index.js +6 -2
  506. package/dist/Plugins/katex/InlineKatex.js +196 -107
  507. package/dist/Plugins/katex/Katex.js +139 -65
  508. package/dist/Plugins/katex/index.js +163 -103
  509. package/dist/Plugins/mermaid/Mermaid.d.ts +9 -4
  510. package/dist/Plugins/mermaid/Mermaid.js +475 -178
  511. package/dist/Plugins/mermaid/index.js +237 -142
  512. package/dist/Quote/index.js +112 -73
  513. package/dist/Quote/style.js +176 -160
  514. package/dist/Schema/SchemaEditor/AceEditorWrapper.js +163 -119
  515. package/dist/Schema/SchemaEditor/index.js +385 -275
  516. package/dist/Schema/SchemaEditor/style.js +261 -269
  517. package/dist/Schema/SchemaForm/index.js +443 -268
  518. package/dist/Schema/SchemaForm/types.js +1 -0
  519. package/dist/Schema/SchemaRenderer/index.js +973 -588
  520. package/dist/Schema/SchemaRenderer/templateEngine.js +106 -26
  521. package/dist/Schema/index.js +7 -11
  522. package/dist/Schema/types.js +1 -0
  523. package/dist/Schema/validator.js +74 -36
  524. package/dist/TaskList/index.js +197 -142
  525. package/dist/TaskList/style.js +143 -122
  526. package/dist/ThoughtChainList/CostMillis.js +88 -54
  527. package/dist/ThoughtChainList/DeepThink.js +187 -152
  528. package/dist/ThoughtChainList/DotAni/index.js +29 -14
  529. package/dist/ThoughtChainList/DotAni/style.js +82 -50
  530. package/dist/ThoughtChainList/FlipText/index.js +74 -30
  531. package/dist/ThoughtChainList/MarkdownEditor.js +126 -72
  532. package/dist/ThoughtChainList/RagRetrievalInfo.js +113 -145
  533. package/dist/ThoughtChainList/TableSql.js +413 -459
  534. package/dist/ThoughtChainList/ThoughtChainListItem.js +388 -222
  535. package/dist/ThoughtChainList/TitleInfo.js +189 -185
  536. package/dist/ThoughtChainList/ToolCall.js +429 -463
  537. package/dist/ThoughtChainList/WebSearch.js +192 -162
  538. package/dist/ThoughtChainList/index.js +449 -410
  539. package/dist/ThoughtChainList/style.js +253 -232
  540. package/dist/ThoughtChainList/types.js +1 -0
  541. package/dist/ToolUseBar/ToolUseBarItem.js +183 -139
  542. package/dist/ToolUseBar/ToolUseBarItemComponents.js +345 -276
  543. package/dist/ToolUseBar/ToolUseBarThink.js +335 -396
  544. package/dist/ToolUseBar/index.js +226 -113
  545. package/dist/ToolUseBar/style.js +334 -308
  546. package/dist/ToolUseBar/thinkStyle.js +350 -328
  547. package/dist/Types/common.js +1 -0
  548. package/dist/Types/index.js +4 -2
  549. package/dist/Types/message.js +1 -0
  550. package/dist/Utils/easings.js +9 -12
  551. package/dist/Utils/formatTime.js +41 -17
  552. package/dist/Utils/getScroll.js +41 -41
  553. package/dist/Utils/language.js +355 -150
  554. package/dist/Utils/proxySandbox/ProxySandbox.js +1637 -1076
  555. package/dist/Utils/proxySandbox/SecurityContextManager.js +607 -343
  556. package/dist/Utils/proxySandbox/index.js +554 -267
  557. package/dist/Utils/proxySandbox/types.js +187 -52
  558. package/dist/Utils/scrollTo.js +48 -56
  559. package/dist/Utils/throttleByAnimationFrame.js +46 -20
  560. package/dist/WelcomeMessage/index.js +106 -58
  561. package/dist/WelcomeMessage/style.js +80 -55
  562. package/dist/Workspace/Browser/index.js +102 -40
  563. package/dist/Workspace/Browser/style.js +62 -33
  564. package/dist/Workspace/File/DataSourceStrategy.js +419 -217
  565. package/dist/Workspace/File/FileComponent.js +1004 -791
  566. package/dist/Workspace/File/FileTypeProcessor.js +337 -184
  567. package/dist/Workspace/File/PreviewComponent.js +472 -532
  568. package/dist/Workspace/File/index.js +3 -10
  569. package/dist/Workspace/File/style.js +397 -424
  570. package/dist/Workspace/File/utils.js +160 -106
  571. package/dist/Workspace/HtmlPreview/index.js +238 -137
  572. package/dist/Workspace/HtmlPreview/style.js +99 -77
  573. package/dist/Workspace/RealtimeFollow/index.js +411 -413
  574. package/dist/Workspace/RealtimeFollow/style.js +299 -303
  575. package/dist/Workspace/Task/index.js +53 -35
  576. package/dist/Workspace/Task/style.js +99 -73
  577. package/dist/Workspace/index.js +332 -254
  578. package/dist/Workspace/style.js +165 -146
  579. package/dist/Workspace/types.js +471 -252
  580. package/dist/Workspace/utils/codeLanguageUtils.js +148 -129
  581. package/dist/Workspace/utils.js +28 -20
  582. package/dist/index.js +27 -17
  583. package/package.json +3 -2
@@ -1,153 +1,300 @@
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-this-alias */ /* 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 _class_call_check(instance, Constructor) {
13
+ if (!(instance instanceof Constructor)) {
14
+ throw new TypeError("Cannot call a class as a function");
16
15
  }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
- // src/MarkdownEditor/editor/store.ts
16
+ }
17
+ function _defineProperties(target, props) {
18
+ for(var i = 0; i < props.length; i++){
19
+ var descriptor = props[i];
20
+ descriptor.enumerable = descriptor.enumerable || false;
21
+ descriptor.configurable = true;
22
+ if ("value" in descriptor) descriptor.writable = true;
23
+ Object.defineProperty(target, descriptor.key, descriptor);
24
+ }
25
+ }
26
+ function _create_class(Constructor, protoProps, staticProps) {
27
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
28
+ if (staticProps) _defineProperties(Constructor, staticProps);
29
+ return Constructor;
30
+ }
31
+ function _define_property(obj, key, value) {
32
+ if (key in obj) {
33
+ Object.defineProperty(obj, key, {
34
+ value: value,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ } else {
40
+ obj[key] = value;
41
+ }
42
+ return obj;
43
+ }
44
+ function _iterable_to_array(iter) {
45
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
46
+ }
47
+ function _iterable_to_array_limit(arr, i) {
48
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
49
+ if (_i == null) return;
50
+ var _arr = [];
51
+ var _n = true;
52
+ var _d = false;
53
+ var _s, _e;
54
+ try {
55
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
56
+ _arr.push(_s.value);
57
+ if (i && _arr.length === i) break;
58
+ }
59
+ } catch (err) {
60
+ _d = true;
61
+ _e = err;
62
+ } finally{
63
+ try {
64
+ if (!_n && _i["return"] != null) _i["return"]();
65
+ } finally{
66
+ if (_d) throw _e;
67
+ }
68
+ }
69
+ return _arr;
70
+ }
71
+ function _non_iterable_rest() {
72
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
+ }
74
+ function _non_iterable_spread() {
75
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
76
+ }
77
+ function _object_spread(target) {
78
+ for(var i = 1; i < arguments.length; i++){
79
+ var source = arguments[i] != null ? arguments[i] : {};
80
+ var ownKeys = Object.keys(source);
81
+ if (typeof Object.getOwnPropertySymbols === "function") {
82
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
83
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
84
+ }));
85
+ }
86
+ ownKeys.forEach(function(key) {
87
+ _define_property(target, key, source[key]);
88
+ });
89
+ }
90
+ return target;
91
+ }
92
+ function ownKeys(object, enumerableOnly) {
93
+ var keys = Object.keys(object);
94
+ if (Object.getOwnPropertySymbols) {
95
+ var symbols = Object.getOwnPropertySymbols(object);
96
+ if (enumerableOnly) {
97
+ symbols = symbols.filter(function(sym) {
98
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
99
+ });
100
+ }
101
+ keys.push.apply(keys, symbols);
102
+ }
103
+ return keys;
104
+ }
105
+ function _object_spread_props(target, source) {
106
+ source = source != null ? source : {};
107
+ if (Object.getOwnPropertyDescriptors) {
108
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
109
+ } else {
110
+ ownKeys(Object(source)).forEach(function(key) {
111
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
112
+ });
113
+ }
114
+ return target;
115
+ }
116
+ function _sliced_to_array(arr, i) {
117
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
118
+ }
119
+ function _to_consumable_array(arr) {
120
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
121
+ }
122
+ function _unsupported_iterable_to_array(o, minLen) {
123
+ if (!o) return;
124
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
125
+ var n = Object.prototype.toString.call(o).slice(8, -1);
126
+ if (n === "Object" && o.constructor) n = o.constructor.name;
127
+ if (n === "Map" || n === "Set") return Array.from(n);
128
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
129
+ }
22
130
  import isEqual from "lodash-es/isEqual";
23
131
  import { parse } from "querystring";
24
132
  import * as React from "react";
25
- import {
26
- Editor,
27
- Element,
28
- Node,
29
- Path,
30
- Range,
31
- Text,
32
- Transforms
33
- } from "slate";
133
+ import { Editor, Element, Node, Path, Range, Text, Transforms } from "slate";
34
134
  import { ReactEditor } from "slate-react";
35
135
  import { parserMdToSchema } from "./parser/parserMdToSchema";
36
136
  import { parserSlateNodeToMarkdown } from "./utils";
37
137
  import { getOffsetLeft, getOffsetTop } from "./utils/dom";
38
138
  import { EditorUtils, findByPathAndText } from "./utils/editorUtils";
39
139
  import { markdownToHtmlSync } from "./utils/markdownToHtml";
40
- var { createContext, useContext } = React;
41
- var EditorStoreContext = createContext(
42
- null
43
- );
44
- var useEditorStore = () => {
45
- return useContext(EditorStoreContext) || {
46
- store: {},
47
- readonly: true,
48
- typewriter: false,
49
- editorProps: {},
50
- markdownEditorRef: {}
51
- };
52
- };
53
- var SUPPORT_TYPING_TAG = ["table-cell", "paragraph", "head"];
54
- var EditorStore = class {
55
- constructor(_editor, plugins, markdownToHtmlOptions) {
56
- /** 高亮缓存映射表 */
57
- this.highlightCache = /* @__PURE__ */ new Map();
58
- /** 允许进入的元素类型集合 */
59
- this.ableToEnter = /* @__PURE__ */ new Set([
60
- "paragraph",
61
- "head",
62
- "blockquote",
63
- "code",
64
- "table",
65
- "list",
66
- "media",
67
- "attach"
68
- ]);
69
- /** 当前拖拽的元素 */
70
- this.draggedElement = null;
71
- this.footnoteDefinitionMap = /* @__PURE__ */ new Map();
72
- this.inputComposition = false;
73
- this.domRect = null;
74
- /** 当前 setMDContent 操作的 AbortController */
75
- this._currentAbortController = null;
76
- /**
77
- * 移除节点
78
- * @param options
79
- */
80
- this.removeNodes = (options) => {
81
- Transforms.removeNodes(this._editor.current, options);
140
+ var createContext = React.createContext, useContext = React.useContext;
141
+ export var EditorStoreContext = createContext(null);
142
+ /**
143
+ * 获取编辑器存储上下文的Hook
144
+ *
145
+ * 提供安全的上下文访问,包含默认值处理
146
+ *
147
+ * @returns 编辑器存储上下文对象
148
+ *
149
+ * @example
150
+ * ```tsx
151
+ * const { store, readonly, typewriter } = useEditorStore();
152
+ * ```
153
+ */ export var useEditorStore = function() {
154
+ return useContext(EditorStoreContext) || {
155
+ store: {},
156
+ readonly: true,
157
+ typewriter: false,
158
+ editorProps: {},
159
+ markdownEditorRef: {}
82
160
  };
83
- this.dragStart = this.dragStart.bind(this);
84
- this._editor = _editor;
85
- this.plugins = plugins;
86
- this.markdownToHtmlOptions = markdownToHtmlOptions;
87
- }
88
- /**
161
+ };
162
+ /** 支持键入操作的标签类型列表 */ var SUPPORT_TYPING_TAG = [
163
+ 'table-cell',
164
+ 'paragraph',
165
+ 'head'
166
+ ];
167
+ /**
168
+ * 编辑器核心状态管理类
169
+ *
170
+ * 负责管理编辑器的所有状态、操作和事件处理
171
+ * 包括文档结构、选择状态、高亮、拖拽、历史记录等
172
+ *
173
+ * @class
174
+ */ export var EditorStore = /*#__PURE__*/ function() {
175
+ "use strict";
176
+ function EditorStore(_editor, plugins, markdownToHtmlOptions) {
177
+ var _this = this;
178
+ _class_call_check(this, EditorStore);
179
+ /** 高亮缓存映射表 */ _define_property(this, "highlightCache", new Map());
180
+ /** 允许进入的元素类型集合 */ _define_property(this, "ableToEnter", new Set([
181
+ 'paragraph',
182
+ 'head',
183
+ 'blockquote',
184
+ 'code',
185
+ 'table',
186
+ 'list',
187
+ 'media',
188
+ 'attach'
189
+ ]));
190
+ /** 当前拖拽的元素 */ _define_property(this, "draggedElement", null);
191
+ _define_property(this, "footnoteDefinitionMap", new Map());
192
+ _define_property(this, "inputComposition", false);
193
+ _define_property(this, "plugins", void 0);
194
+ _define_property(this, "domRect", null);
195
+ _define_property(this, "_editor", void 0);
196
+ /** 当前 setMDContent 操作的 AbortController */ _define_property(this, "_currentAbortController", null);
197
+ _define_property(this, "markdownToHtmlOptions", void 0);
198
+ /**
199
+ * 移除节点
200
+ * @param options
201
+ */ _define_property(this, "removeNodes", function(options) {
202
+ Transforms.removeNodes(_this._editor.current, options);
203
+ });
204
+ this.dragStart = this.dragStart.bind(this);
205
+ this._editor = _editor;
206
+ this.plugins = plugins;
207
+ this.markdownToHtmlOptions = markdownToHtmlOptions;
208
+ }
209
+ _create_class(EditorStore, [
210
+ {
211
+ key: "editor",
212
+ get: /**
89
213
  * 获取当前编辑器实例。
90
214
  *
91
215
  * @returns 当前的 Slate 编辑器实例。
92
- */
93
- get editor() {
94
- return this._editor.current;
95
- }
96
- /**
216
+ */ function get() {
217
+ return this._editor.current;
218
+ }
219
+ },
220
+ {
221
+ /**
97
222
  * 聚焦到编辑器
98
- */
99
- focus() {
100
- const editor = this._editor.current;
101
- try {
102
- setTimeout(() => ReactEditor.focus(editor), 0);
103
- if (editor.children.length === 0) {
104
- const defaultNode = { type: "paragraph", children: [{ text: "" }] };
105
- Transforms.insertNodes(editor, defaultNode, { at: [0] });
106
- }
107
- const end = Editor.end(editor, []);
108
- Transforms.select(editor, {
109
- anchor: end,
110
- focus: end
111
- });
112
- } catch (error) {
113
- console.error("移动光标失败:", error);
114
- }
115
- }
116
- /**
223
+ */ key: "focus",
224
+ value: function focus() {
225
+ var editor = this._editor.current;
226
+ try {
227
+ // 1. 确保编辑器获得焦点
228
+ setTimeout(function() {
229
+ return ReactEditor.focus(editor);
230
+ }, 0);
231
+ // 2. 处理空文档情况
232
+ if (editor.children.length === 0) {
233
+ var defaultNode = {
234
+ type: 'paragraph',
235
+ children: [
236
+ {
237
+ text: ''
238
+ }
239
+ ]
240
+ };
241
+ Transforms.insertNodes(editor, defaultNode, {
242
+ at: [
243
+ 0
244
+ ]
245
+ });
246
+ }
247
+ // 3. 获取文档末尾位置
248
+ var end = Editor.end(editor, []);
249
+ // 4. 设置光标位置
250
+ Transforms.select(editor, {
251
+ anchor: end,
252
+ focus: end
253
+ });
254
+ } catch (error) {
255
+ console.error('移动光标失败:', error);
256
+ }
257
+ }
258
+ },
259
+ {
260
+ key: "findLatest",
261
+ value: /**
117
262
  * 查找最新的节点索引。
118
263
  *
119
264
  * @param node - 当前节点。
120
265
  * @param index - 当前索引路径。
121
266
  * @returns 最新节点的索引路径。
122
- */
123
- findLatest(node, index) {
124
- if (Array.isArray(node.children)) {
125
- if (node.children.length === 1 && (SUPPORT_TYPING_TAG.includes(node.type) || !node.children[0].type)) {
126
- return index;
127
- }
128
- return this.findLatest(
129
- node.children[node.children.length - 1],
130
- [...index, node.children.length - 1]
131
- );
132
- }
133
- return index;
134
- }
135
- /**
267
+ */ function findLatest(node, index) {
268
+ if (Array.isArray(node.children)) {
269
+ if (node.children.length === 1 && (SUPPORT_TYPING_TAG.includes(node.type) || !node.children[0].type)) {
270
+ return index;
271
+ }
272
+ return this.findLatest(node.children[node.children.length - 1], _to_consumable_array(index).concat([
273
+ node.children.length - 1
274
+ ]));
275
+ }
276
+ return index;
277
+ }
278
+ },
279
+ {
280
+ /**
136
281
  * 检查给定节点是否是最新节点。用于展示 闪动光标
137
282
  *
138
283
  * @param node - 要检查的节点。
139
284
  * @returns 如果节点是最新节点,则返回 true;否则返回 false。
140
- */
141
- isLatestNode(node) {
142
- try {
143
- return this.findLatest(this._editor.current.children.at(-1), [
144
- this._editor.current.children.length - 1
145
- ]).join("-").startsWith(ReactEditor.findPath(this._editor.current, node).join("-"));
146
- } catch (error) {
147
- return false;
148
- }
149
- }
150
- /**
285
+ */ key: "isLatestNode",
286
+ value: function isLatestNode(node) {
287
+ try {
288
+ return this.findLatest(this._editor.current.children.at(-1), [
289
+ this._editor.current.children.length - 1
290
+ ]).join('-').startsWith(ReactEditor.findPath(this._editor.current, node).join('-'));
291
+ } catch (error) {
292
+ return false;
293
+ }
294
+ }
295
+ },
296
+ {
297
+ /**
151
298
  * 插入一个链接到编辑器中。
152
299
  *
153
300
  * @param filePath - 要插入的文件路径。如果路径以 'http' 开头,则链接文本为路径本身,否则为文件名。
@@ -160,71 +307,101 @@ var EditorStore = class {
160
307
  *
161
308
  * 如果当前选区所在的元素节点类型不是 'table-cell' 或 'paragraph',则查找包含当前选区的父级元素节点,
162
309
  * 并在其后插入一个包含链接节点的新段落。
163
- */
164
- insertLink(filePath) {
165
- const p = parse(filePath);
166
- const insertPath = filePath;
167
- let node = {
168
- text: filePath.startsWith("http") ? filePath : p.name,
169
- url: insertPath
170
- };
171
- const sel = this._editor.current.selection;
172
- if (!sel || !Range.isCollapsed(sel))
173
- return;
174
- const [cur] = Editor.nodes(this._editor.current, {
175
- match: (n) => Element.isElement(n),
176
- mode: "lowest"
177
- });
178
- if (node.text && ["table-cell", "paragraph"].includes(cur[0].type)) {
179
- Transforms.insertNodes(this._editor.current, node, { select: true });
180
- } else {
181
- const [par] = Editor.nodes(this._editor.current, {
182
- match: (n) => Element.isElement(n) && ["table", "code", "head"].includes(n.type)
183
- });
184
- Transforms.insertNodes(
185
- this._editor.current,
186
- {
187
- type: "paragraph",
188
- children: [node]
310
+ */ key: "insertLink",
311
+ value: function insertLink(filePath) {
312
+ var p = parse(filePath);
313
+ var insertPath = filePath;
314
+ var node = {
315
+ text: filePath.startsWith('http') ? filePath : p.name,
316
+ url: insertPath
317
+ };
318
+ var sel = this._editor.current.selection;
319
+ if (!sel || !Range.isCollapsed(sel)) return;
320
+ // @ts-ignore
321
+ var _Editor_nodes = _sliced_to_array(Editor.nodes(this._editor.current, {
322
+ match: function(n) {
323
+ return Element.isElement(n);
324
+ },
325
+ mode: 'lowest'
326
+ }), 1), cur = _Editor_nodes[0];
327
+ if (node.text && [
328
+ 'table-cell',
329
+ 'paragraph'
330
+ ].includes(cur[0].type)) {
331
+ Transforms.insertNodes(this._editor.current, node, {
332
+ select: true
333
+ });
334
+ } else {
335
+ // @ts-ignore
336
+ var _Editor_nodes1 = _sliced_to_array(Editor.nodes(this._editor.current, {
337
+ match: function(n) {
338
+ return Element.isElement(n) && [
339
+ 'table',
340
+ 'code',
341
+ 'head'
342
+ ].includes(n.type);
343
+ }
344
+ }), 1), par = _Editor_nodes1[0];
345
+ Transforms.insertNodes(this._editor.current, {
346
+ type: 'paragraph',
347
+ children: [
348
+ node
349
+ ]
350
+ }, {
351
+ select: true,
352
+ at: Path.next(par[1])
353
+ });
354
+ }
355
+ }
189
356
  },
190
- { select: true, at: Path.next(par[1]) }
191
- );
192
- }
193
- }
194
- /**
357
+ {
358
+ /**
195
359
  * 插入节点到编辑器中。
196
360
  *
197
361
  * @param nodes - 要插入的节点,可以是单个节点或节点数组。
198
362
  * @param options - 可选参数,用于指定插入节点的选项。
199
- */
200
- insertNodes(nodes, options) {
201
- Transforms.insertNodes(this._editor.current, nodes, options);
202
- }
203
- /**
363
+ */ key: "insertNodes",
364
+ value: function insertNodes(nodes, options) {
365
+ Transforms.insertNodes(this._editor.current, nodes, options);
366
+ }
367
+ },
368
+ {
369
+ key: "toPath",
370
+ value: /**
204
371
  * Converts an HTML element to a Slate path and node.
205
372
  *
206
373
  * @param el - The HTML element to convert.
207
374
  * @returns A tuple containing the path and the corresponding Slate node.
208
375
  * @private
209
- */
210
- toPath(el) {
211
- const node = ReactEditor.toSlateNode(this._editor.current, el);
212
- const path = ReactEditor.findPath(this._editor.current, node);
213
- return [path, node];
214
- }
215
- /**
376
+ */ function toPath(el) {
377
+ var node = ReactEditor.toSlateNode(this._editor.current, el);
378
+ var path = ReactEditor.findPath(this._editor.current, node);
379
+ return [
380
+ path,
381
+ node
382
+ ];
383
+ }
384
+ },
385
+ {
386
+ /**
216
387
  * Clears all content from the editor, replacing it with an empty paragraph.
217
- */
218
- clearContent() {
219
- this._editor.current.selection = null;
220
- this._editor.current.children = [
221
- {
222
- type: "paragraph",
223
- children: [{ text: "" }]
224
- }
225
- ];
226
- }
227
- /**
388
+ */ key: "clearContent",
389
+ value: function clearContent() {
390
+ this._editor.current.selection = null;
391
+ this._editor.current.children = [
392
+ {
393
+ type: 'paragraph',
394
+ children: [
395
+ {
396
+ text: ''
397
+ }
398
+ ]
399
+ }
400
+ ];
401
+ }
402
+ },
403
+ {
404
+ /**
228
405
  * 从 markdown 文本设置编辑器内容
229
406
  *
230
407
  * @param md - 要设置为编辑器内容的 Markdown 字符串
@@ -238,109 +415,153 @@ var EditorStore = class {
238
415
  * - batchSize: 每帧处理的节点数量,默认 50,仅在 useRAF=true 时生效
239
416
  * - onProgress: 进度回调函数,接收当前进度 (0-1) 作为参数
240
417
  * @returns 如果使用 RAF,返回 Promise;否则同步执行
241
- */
242
- setMDContent(md, plugins, options) {
243
- var _a, _b, _c, _d;
244
- if (md === void 0)
245
- return;
246
- try {
247
- const currentMD = parserSlateNodeToMarkdown(
248
- this._editor.current.children
249
- );
250
- if (md.trim() === currentMD.trim())
251
- return;
252
- } catch (error) {
253
- console.warn(
254
- "Failed to compare current content, proceeding with setMDContent:",
255
- error
256
- );
257
- }
258
- this.cancelSetMDContent();
259
- const chunkSize = (_a = options == null ? void 0 : options.chunkSize) != null ? _a : 5e3;
260
- const separator = (_b = options == null ? void 0 : options.separator) != null ? _b : /\n\n/;
261
- const useRAF = (_c = options == null ? void 0 : options.useRAF) != null ? _c : true;
262
- const batchSize = (_d = options == null ? void 0 : options.batchSize) != null ? _d : 50;
263
- const targetPlugins = plugins || this.plugins;
264
- if (md.length <= chunkSize) {
265
- try {
266
- const nodeList = parserMdToSchema(md, targetPlugins).schema;
267
- this.setContent(nodeList);
268
- this._editor.current.children = nodeList;
269
- ReactEditor.deselect(this._editor.current);
270
- if (options == null ? void 0 : options.onProgress) {
271
- options.onProgress(1);
272
- }
273
- } catch (error) {
274
- console.error("Failed to set MD content:", error);
275
- throw error;
276
- }
277
- return;
278
- }
279
- const chunks = this._splitMarkdown(md, separator);
280
- if (!useRAF) {
281
- try {
282
- const allNodes = [];
283
- for (const chunk of chunks) {
284
- if (chunk.trim()) {
285
- const { schema } = parserMdToSchema(chunk, targetPlugins);
286
- allNodes.push(...schema);
287
- }
288
- }
289
- if (allNodes.length > 0) {
290
- this.setContent(allNodes);
291
- this._editor.current.children = allNodes;
292
- ReactEditor.deselect(this._editor.current);
293
- }
294
- if (options == null ? void 0 : options.onProgress) {
295
- options.onProgress(1);
296
- }
297
- } catch (error) {
298
- console.error("Failed to set MD content synchronously:", error);
299
- throw error;
300
- }
301
- return;
302
- }
303
- if (chunks.length > 10) {
304
- this._currentAbortController = new AbortController();
305
- return this._parseAndSetContentWithRAF(
306
- chunks,
307
- targetPlugins || [],
308
- batchSize,
309
- options == null ? void 0 : options.onProgress,
310
- this._currentAbortController.signal
311
- );
312
- }
313
- try {
314
- const allNodes = [];
315
- for (const chunk of chunks) {
316
- if (chunk.trim()) {
317
- const { schema } = parserMdToSchema(chunk, targetPlugins);
318
- allNodes.push(...schema);
319
- }
320
- }
321
- if (allNodes.length > 0) {
322
- this.setContent(allNodes);
323
- this._editor.current.children = allNodes;
324
- ReactEditor.deselect(this._editor.current);
325
- }
326
- if (options == null ? void 0 : options.onProgress) {
327
- options.onProgress(1);
328
- }
329
- } catch (error) {
330
- console.error("Failed to set MD content with small chunks:", error);
331
- throw error;
332
- }
333
- }
334
- /**
418
+ */ key: "setMDContent",
419
+ value: function setMDContent(md, plugins, options) {
420
+ if (md === undefined) return;
421
+ // 安全地比较当前内容,避免解析异常导致失效
422
+ try {
423
+ var currentMD = parserSlateNodeToMarkdown(this._editor.current.children);
424
+ // 使用 trim 和规范化比较,避免空白字符差异
425
+ if (md.trim() === currentMD.trim()) return;
426
+ } catch (error) {
427
+ // 如果解析当前内容失败,继续执行设置新内容
428
+ console.warn('Failed to compare current content, proceeding with setMDContent:', error);
429
+ }
430
+ // 取消之前的操作,避免竞态条件
431
+ this.cancelSetMDContent();
432
+ var _options_chunkSize;
433
+ var chunkSize = (_options_chunkSize = options === null || options === void 0 ? void 0 : options.chunkSize) !== null && _options_chunkSize !== void 0 ? _options_chunkSize : 5000;
434
+ var _options_separator;
435
+ var separator = (_options_separator = options === null || options === void 0 ? void 0 : options.separator) !== null && _options_separator !== void 0 ? _options_separator : /\n\n/;
436
+ var _options_useRAF;
437
+ var useRAF = (_options_useRAF = options === null || options === void 0 ? void 0 : options.useRAF) !== null && _options_useRAF !== void 0 ? _options_useRAF : true;
438
+ var _options_batchSize;
439
+ var batchSize = (_options_batchSize = options === null || options === void 0 ? void 0 : options.batchSize) !== null && _options_batchSize !== void 0 ? _options_batchSize : 50;
440
+ var targetPlugins = plugins || this.plugins;
441
+ // 如果内容较短,直接处理
442
+ if (md.length <= chunkSize) {
443
+ try {
444
+ var nodeList = parserMdToSchema(md, targetPlugins).schema;
445
+ this.setContent(nodeList);
446
+ this._editor.current.children = nodeList;
447
+ ReactEditor.deselect(this._editor.current);
448
+ // 调用进度回调
449
+ if (options === null || options === void 0 ? void 0 : options.onProgress) {
450
+ options.onProgress(1);
451
+ }
452
+ } catch (error) {
453
+ console.error('Failed to set MD content:', error);
454
+ throw error;
455
+ }
456
+ return;
457
+ }
458
+ // 内容较长时,按指定分隔符拆分并分批处理
459
+ var chunks = this._splitMarkdown(md, separator);
460
+ // 如果禁用 RAF,使用同步模式处理长内容
461
+ if (!useRAF) {
462
+ try {
463
+ var allNodes = [];
464
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
465
+ try {
466
+ for(var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
467
+ var chunk = _step.value;
468
+ if (chunk.trim()) {
469
+ var _allNodes;
470
+ var schema = parserMdToSchema(chunk, targetPlugins).schema;
471
+ (_allNodes = allNodes).push.apply(_allNodes, _to_consumable_array(schema));
472
+ }
473
+ }
474
+ } catch (err) {
475
+ _didIteratorError = true;
476
+ _iteratorError = err;
477
+ } finally{
478
+ try {
479
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
480
+ _iterator.return();
481
+ }
482
+ } finally{
483
+ if (_didIteratorError) {
484
+ throw _iteratorError;
485
+ }
486
+ }
487
+ }
488
+ if (allNodes.length > 0) {
489
+ this.setContent(allNodes);
490
+ this._editor.current.children = allNodes;
491
+ ReactEditor.deselect(this._editor.current);
492
+ }
493
+ // 调用进度回调
494
+ if (options === null || options === void 0 ? void 0 : options.onProgress) {
495
+ options.onProgress(1);
496
+ }
497
+ } catch (error) {
498
+ console.error('Failed to set MD content synchronously:', error);
499
+ throw error;
500
+ }
501
+ return;
502
+ }
503
+ // 如果使用 RAF 且分块数量较多,异步解析和插入
504
+ if (chunks.length > 10) {
505
+ // 创建新的 AbortController
506
+ this._currentAbortController = new AbortController();
507
+ return this._parseAndSetContentWithRAF(chunks, targetPlugins || [], batchSize, options === null || options === void 0 ? void 0 : options.onProgress, this._currentAbortController.signal);
508
+ }
509
+ // 如果分块数量 <= 10,使用同步模式处理(修复:之前这里直接返回 undefined)
510
+ try {
511
+ var allNodes1 = [];
512
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
513
+ try {
514
+ for(var _iterator1 = chunks[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
515
+ var chunk1 = _step1.value;
516
+ if (chunk1.trim()) {
517
+ var _allNodes1;
518
+ var schema1 = parserMdToSchema(chunk1, targetPlugins).schema;
519
+ (_allNodes1 = allNodes1).push.apply(_allNodes1, _to_consumable_array(schema1));
520
+ }
521
+ }
522
+ } catch (err) {
523
+ _didIteratorError1 = true;
524
+ _iteratorError1 = err;
525
+ } finally{
526
+ try {
527
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
528
+ _iterator1.return();
529
+ }
530
+ } finally{
531
+ if (_didIteratorError1) {
532
+ throw _iteratorError1;
533
+ }
534
+ }
535
+ }
536
+ if (allNodes1.length > 0) {
537
+ this.setContent(allNodes1);
538
+ this._editor.current.children = allNodes1;
539
+ ReactEditor.deselect(this._editor.current);
540
+ }
541
+ // 调用进度回调
542
+ if (options === null || options === void 0 ? void 0 : options.onProgress) {
543
+ options.onProgress(1);
544
+ }
545
+ } catch (error) {
546
+ console.error('Failed to set MD content with small chunks:', error);
547
+ throw error;
548
+ }
549
+ }
550
+ },
551
+ {
552
+ /**
335
553
  * 取消当前正在进行的 setMDContent 操作
336
- */
337
- cancelSetMDContent() {
338
- if (this._currentAbortController) {
339
- this._currentAbortController.abort();
340
- this._currentAbortController = null;
341
- }
342
- }
343
- /**
554
+ */ key: "cancelSetMDContent",
555
+ value: function cancelSetMDContent() {
556
+ if (this._currentAbortController) {
557
+ this._currentAbortController.abort();
558
+ this._currentAbortController = null;
559
+ }
560
+ }
561
+ },
562
+ {
563
+ key: "_parseAndSetContentWithRAF",
564
+ value: /**
344
565
  * 使用 requestAnimationFrame 分批解析和设置内容
345
566
  * 边解析边插入,实时显示内容
346
567
  *
@@ -350,89 +571,104 @@ var EditorStore = class {
350
571
  * @param onProgress - 进度回调函数
351
572
  * @returns Promise,在所有内容处理完成后 resolve
352
573
  * @private
353
- */
354
- _parseAndSetContentWithRAF(chunks, plugins, batchSize, onProgress, signal) {
355
- return new Promise((resolve, reject) => {
356
- let currentChunkIndex = 0;
357
- const totalChunks = chunks.length;
358
- const parseChunksPerFrame = Math.max(1, Math.floor(batchSize / 10));
359
- let isFirstBatch = true;
360
- let rafId = null;
361
- const parseAndInsertNextBatch = () => {
362
- try {
363
- if (signal == null ? void 0 : signal.aborted) {
364
- if (rafId) {
365
- cancelAnimationFrame(rafId);
366
- rafId = null;
367
- }
368
- this._currentAbortController = null;
369
- reject(new Error("Operation was cancelled"));
370
- return;
371
- }
372
- if (!this._editor.current) {
373
- if (rafId) {
374
- cancelAnimationFrame(rafId);
375
- rafId = null;
376
- }
377
- this._currentAbortController = null;
378
- reject(new Error("Editor instance is no longer available"));
379
- return;
380
- }
381
- const endIndex = Math.min(
382
- currentChunkIndex + parseChunksPerFrame,
383
- totalChunks
384
- );
385
- for (let i = currentChunkIndex; i < endIndex; i++) {
386
- const chunk = chunks[i];
387
- if (chunk.trim()) {
388
- try {
389
- const { schema } = parserMdToSchema(chunk, plugins);
390
- if (schema.length > 0) {
391
- if (isFirstBatch) {
392
- this._editor.current.children = schema;
393
- this._editor.current.onChange();
394
- isFirstBatch = false;
395
- } else {
396
- Transforms.insertNodes(this._editor.current, schema, {
397
- at: [this._editor.current.children.length]
398
- });
399
- }
400
- }
401
- } catch (chunkError) {
402
- console.warn(`Failed to parse chunk ${i}:`, chunkError);
403
- }
404
- }
405
- }
406
- currentChunkIndex = endIndex;
407
- const progress = currentChunkIndex / totalChunks;
408
- if (onProgress) {
409
- try {
410
- onProgress(progress);
411
- } catch (progressError) {
412
- console.warn("Progress callback failed:", progressError);
574
+ */ function _parseAndSetContentWithRAF(chunks, plugins, batchSize, onProgress, signal) {
575
+ var _this = this;
576
+ return new Promise(function(resolve, reject) {
577
+ var currentChunkIndex = 0;
578
+ var totalChunks = chunks.length;
579
+ var parseChunksPerFrame = Math.max(1, Math.floor(batchSize / 10)); // 每帧解析的 chunk 数
580
+ var isFirstBatch = true;
581
+ var rafId = null;
582
+ // 边解析边插入
583
+ var parseAndInsertNextBatch = function() {
584
+ try {
585
+ // 检查是否被取消
586
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
587
+ if (rafId) {
588
+ cancelAnimationFrame(rafId);
589
+ rafId = null;
590
+ }
591
+ _this._currentAbortController = null;
592
+ reject(new Error('Operation was cancelled'));
593
+ return;
594
+ }
595
+ // 检查编辑器是否仍然有效
596
+ if (!_this._editor.current) {
597
+ if (rafId) {
598
+ cancelAnimationFrame(rafId);
599
+ rafId = null;
600
+ }
601
+ _this._currentAbortController = null;
602
+ reject(new Error('Editor instance is no longer available'));
603
+ return;
604
+ }
605
+ var endIndex = Math.min(currentChunkIndex + parseChunksPerFrame, totalChunks);
606
+ // 解析当前批次的 chunks 并立即插入
607
+ for(var i = currentChunkIndex; i < endIndex; i++){
608
+ var chunk = chunks[i];
609
+ if (chunk.trim()) {
610
+ try {
611
+ var schema = parserMdToSchema(chunk, plugins).schema;
612
+ if (schema.length > 0) {
613
+ if (isFirstBatch) {
614
+ // 第一批:清空并插入
615
+ _this._editor.current.children = schema;
616
+ _this._editor.current.onChange();
617
+ isFirstBatch = false;
618
+ } else {
619
+ // 后续批次:追加节点
620
+ Transforms.insertNodes(_this._editor.current, schema, {
621
+ at: [
622
+ _this._editor.current.children.length
623
+ ]
624
+ });
625
+ }
626
+ }
627
+ } catch (chunkError) {
628
+ // 单个 chunk 解析失败,记录但继续处理其他 chunks
629
+ console.warn("Failed to parse chunk ".concat(i, ":"), chunkError);
630
+ }
631
+ }
632
+ }
633
+ currentChunkIndex = endIndex;
634
+ // 更新进度
635
+ var progress = currentChunkIndex / totalChunks;
636
+ if (onProgress) {
637
+ try {
638
+ onProgress(progress);
639
+ } catch (progressError) {
640
+ // 进度回调失败不应该中断整个流程
641
+ console.warn('Progress callback failed:', progressError);
642
+ }
643
+ }
644
+ if (currentChunkIndex < totalChunks) {
645
+ // 还有 chunks 未处理,继续下一帧
646
+ rafId = requestAnimationFrame(parseAndInsertNextBatch);
647
+ } else {
648
+ // 所有内容处理完成
649
+ ReactEditor.deselect(_this._editor.current);
650
+ rafId = null;
651
+ _this._currentAbortController = null;
652
+ resolve();
653
+ }
654
+ } catch (error) {
655
+ // 清理资源并拒绝 Promise
656
+ if (rafId) {
657
+ cancelAnimationFrame(rafId);
658
+ rafId = null;
659
+ }
660
+ _this._currentAbortController = null;
661
+ reject(error);
662
+ }
663
+ };
664
+ // 开始处理
665
+ rafId = requestAnimationFrame(parseAndInsertNextBatch);
666
+ });
413
667
  }
414
- }
415
- if (currentChunkIndex < totalChunks) {
416
- rafId = requestAnimationFrame(parseAndInsertNextBatch);
417
- } else {
418
- ReactEditor.deselect(this._editor.current);
419
- rafId = null;
420
- this._currentAbortController = null;
421
- resolve();
422
- }
423
- } catch (error) {
424
- if (rafId) {
425
- cancelAnimationFrame(rafId);
426
- rafId = null;
427
- }
428
- this._currentAbortController = null;
429
- reject(error);
430
- }
431
- };
432
- rafId = requestAnimationFrame(parseAndInsertNextBatch);
433
- });
434
- }
435
- /**
668
+ },
669
+ {
670
+ key: "_setContentWithRAF",
671
+ value: /**
436
672
  * 使用 requestAnimationFrame 分批设置内容
437
673
  * 每帧插入一批节点,避免长时间阻塞主线程
438
674
  *
@@ -441,45 +677,56 @@ var EditorStore = class {
441
677
  * @param onProgress - 进度回调函数
442
678
  * @returns Promise,在所有节点插入完成后 resolve
443
679
  * @private
444
- */
445
- _setContentWithRAF(allNodes, batchSize, onProgress) {
446
- return new Promise((resolve, reject) => {
447
- let currentIndex = 0;
448
- const totalNodes = allNodes.length;
449
- let rafId = null;
450
- const insertBatch = () => {
451
- try {
452
- const endIndex = Math.min(currentIndex + batchSize, totalNodes);
453
- const batch = allNodes.slice(currentIndex, endIndex);
454
- if (currentIndex === 0) {
455
- this._editor.current.children = batch;
456
- this._editor.current.onChange();
457
- } else {
458
- this._editor.current.children.push(...batch);
459
- this._editor.current.onChange();
460
- }
461
- currentIndex = endIndex;
462
- const progress = currentIndex / totalNodes;
463
- onProgress == null ? void 0 : onProgress(progress);
464
- if (currentIndex < totalNodes) {
465
- rafId = requestAnimationFrame(insertBatch);
466
- } else {
467
- ReactEditor.deselect(this._editor.current);
468
- rafId = null;
469
- resolve();
470
- }
471
- } catch (error) {
472
- if (rafId) {
473
- cancelAnimationFrame(rafId);
474
- rafId = null;
475
- }
476
- reject(error);
477
- }
478
- };
479
- rafId = requestAnimationFrame(insertBatch);
480
- });
481
- }
482
- /**
680
+ */ function _setContentWithRAF(allNodes, batchSize, onProgress) {
681
+ var _this = this;
682
+ return new Promise(function(resolve, reject) {
683
+ var currentIndex = 0;
684
+ var totalNodes = allNodes.length;
685
+ var rafId = null;
686
+ var insertBatch = function() {
687
+ try {
688
+ var endIndex = Math.min(currentIndex + batchSize, totalNodes);
689
+ var batch = allNodes.slice(currentIndex, endIndex);
690
+ if (currentIndex === 0) {
691
+ // 第一批:清空并插入
692
+ _this._editor.current.children = batch;
693
+ _this._editor.current.onChange();
694
+ } else {
695
+ var // 后续批次:追加节点
696
+ _this__editor_current_children;
697
+ (_this__editor_current_children = _this._editor.current.children).push.apply(_this__editor_current_children, _to_consumable_array(batch));
698
+ _this._editor.current.onChange();
699
+ }
700
+ currentIndex = endIndex;
701
+ var progress = currentIndex / totalNodes;
702
+ // 直接调用进度回调,避免嵌套 requestAnimationFrame
703
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
704
+ if (currentIndex < totalNodes) {
705
+ // 还有节点未处理,继续下一帧
706
+ rafId = requestAnimationFrame(insertBatch);
707
+ } else {
708
+ // 所有节点处理完成
709
+ ReactEditor.deselect(_this._editor.current);
710
+ rafId = null;
711
+ resolve();
712
+ }
713
+ } catch (error) {
714
+ // 清理资源并拒绝 Promise
715
+ if (rafId) {
716
+ cancelAnimationFrame(rafId);
717
+ rafId = null;
718
+ }
719
+ reject(error);
720
+ }
721
+ };
722
+ // 开始第一帧
723
+ rafId = requestAnimationFrame(insertBatch);
724
+ });
725
+ }
726
+ },
727
+ {
728
+ key: "_splitMarkdown",
729
+ value: /**
483
730
  * 按指定分隔符拆分 markdown 内容
484
731
  * 保持内容结构的完整性
485
732
  *
@@ -487,176 +734,212 @@ var EditorStore = class {
487
734
  * @param separator - 分隔符,可以是字符串或正则表达式
488
735
  * @returns 拆分后的字符串数组
489
736
  * @private
490
- */
491
- _splitMarkdown(md, separator) {
492
- if (!md) {
493
- return [];
494
- }
495
- const separatorMatches = this._collectSeparatorMatches(md, separator);
496
- if (separatorMatches.length === 0) {
497
- return [md];
498
- }
499
- const chunks = [];
500
- let start = 0;
501
- let currentMatchIndex = 0;
502
- let insideFence = false;
503
- let activeFence = null;
504
- let index = 0;
505
- while (index < md.length) {
506
- if (this._isLineStart(md, index)) {
507
- const fence = this._matchFence(md, index);
508
- if (fence) {
509
- if (!insideFence) {
510
- insideFence = true;
511
- activeFence = fence.marker;
512
- } else if (activeFence === fence.marker) {
513
- insideFence = false;
514
- activeFence = null;
515
- }
516
- index = fence.end;
517
- continue;
518
- }
519
- }
520
- const match = separatorMatches[currentMatchIndex];
521
- if (!insideFence && match && index === match.index) {
522
- const chunk = md.slice(start, index);
523
- if (chunk.length > 0) {
524
- chunks.push(chunk);
525
- }
526
- start = index + match.length;
527
- currentMatchIndex += 1;
528
- index = start;
529
- continue;
530
- }
531
- index += 1;
532
- }
533
- const tail = md.slice(start);
534
- if (tail.length > 0) {
535
- chunks.push(tail);
536
- }
537
- return chunks.length > 0 ? chunks : [md];
538
- }
539
- _collectSeparatorMatches(md, separator) {
540
- if (typeof separator === "string") {
541
- const matches2 = [];
542
- let searchIndex = md.indexOf(separator);
543
- while (searchIndex !== -1) {
544
- matches2.push({ index: searchIndex, length: separator.length });
545
- searchIndex = md.indexOf(separator, searchIndex + separator.length);
546
- }
547
- return matches2;
548
- }
549
- const flags = separator.flags.includes("g") ? separator.flags : `${separator.flags}g`;
550
- const globalRegex = new RegExp(separator.source, flags);
551
- const matches = [];
552
- let match;
553
- while ((match = globalRegex.exec(md)) !== null) {
554
- const matchedText = match[0];
555
- matches.push({ index: match.index, length: matchedText.length });
556
- if (matchedText.length === 0) {
557
- globalRegex.lastIndex += 1;
558
- }
559
- }
560
- return matches;
561
- }
562
- _isLineStart(content, position) {
563
- if (position === 0) {
564
- return true;
565
- }
566
- return content[position - 1] === "\n";
567
- }
568
- _matchFence(content, position) {
569
- let cursor = position;
570
- let spaces = 0;
571
- while (cursor < content.length && content[cursor] === " " && spaces < 3) {
572
- cursor += 1;
573
- spaces += 1;
574
- }
575
- if (cursor >= content.length) {
576
- return null;
577
- }
578
- const char = content[cursor];
579
- if (char !== "`" && char !== "~") {
580
- return null;
581
- }
582
- let fenceLength = 0;
583
- while (cursor < content.length && content[cursor] === char) {
584
- cursor += 1;
585
- fenceLength += 1;
586
- }
587
- if (fenceLength < 3) {
588
- return null;
589
- }
590
- const lineEnd = this._findLineEnd(content, cursor);
591
- return { marker: char, end: lineEnd };
592
- }
593
- _findLineEnd(content, position) {
594
- let cursor = position;
595
- while (cursor < content.length && content[cursor] !== "\n") {
596
- cursor += 1;
597
- }
598
- if (cursor < content.length && content[cursor] === "\n") {
599
- return cursor + 1;
600
- }
601
- return cursor;
602
- }
603
- /**
737
+ */ function _splitMarkdown(md, separator) {
738
+ if (!md) {
739
+ return [];
740
+ }
741
+ var separatorMatches = this._collectSeparatorMatches(md, separator);
742
+ if (separatorMatches.length === 0) {
743
+ return [
744
+ md
745
+ ];
746
+ }
747
+ var chunks = [];
748
+ var start = 0;
749
+ var currentMatchIndex = 0;
750
+ var insideFence = false;
751
+ var activeFence = null;
752
+ var index = 0;
753
+ while(index < md.length){
754
+ if (this._isLineStart(md, index)) {
755
+ var fence = this._matchFence(md, index);
756
+ if (fence) {
757
+ if (!insideFence) {
758
+ insideFence = true;
759
+ activeFence = fence.marker;
760
+ } else if (activeFence === fence.marker) {
761
+ insideFence = false;
762
+ activeFence = null;
763
+ }
764
+ index = fence.end;
765
+ continue;
766
+ }
767
+ }
768
+ var match = separatorMatches[currentMatchIndex];
769
+ if (!insideFence && match && index === match.index) {
770
+ var chunk = md.slice(start, index);
771
+ if (chunk.length > 0) {
772
+ chunks.push(chunk);
773
+ }
774
+ start = index + match.length;
775
+ currentMatchIndex += 1;
776
+ index = start;
777
+ continue;
778
+ }
779
+ index += 1;
780
+ }
781
+ var tail = md.slice(start);
782
+ if (tail.length > 0) {
783
+ chunks.push(tail);
784
+ }
785
+ return chunks.length > 0 ? chunks : [
786
+ md
787
+ ];
788
+ }
789
+ },
790
+ {
791
+ key: "_collectSeparatorMatches",
792
+ value: function _collectSeparatorMatches(md, separator) {
793
+ if (typeof separator === 'string') {
794
+ var matches = [];
795
+ var searchIndex = md.indexOf(separator);
796
+ while(searchIndex !== -1){
797
+ matches.push({
798
+ index: searchIndex,
799
+ length: separator.length
800
+ });
801
+ searchIndex = md.indexOf(separator, searchIndex + separator.length);
802
+ }
803
+ return matches;
804
+ }
805
+ var flags = separator.flags.includes('g') ? separator.flags : "".concat(separator.flags, "g");
806
+ var globalRegex = new RegExp(separator.source, flags);
807
+ var matches1 = [];
808
+ var match;
809
+ while((match = globalRegex.exec(md)) !== null){
810
+ var matchedText = match[0];
811
+ matches1.push({
812
+ index: match.index,
813
+ length: matchedText.length
814
+ });
815
+ if (matchedText.length === 0) {
816
+ globalRegex.lastIndex += 1;
817
+ }
818
+ }
819
+ return matches1;
820
+ }
821
+ },
822
+ {
823
+ key: "_isLineStart",
824
+ value: function _isLineStart(content, position) {
825
+ if (position === 0) {
826
+ return true;
827
+ }
828
+ return content[position - 1] === '\n';
829
+ }
830
+ },
831
+ {
832
+ key: "_matchFence",
833
+ value: function _matchFence(content, position) {
834
+ var cursor = position;
835
+ var spaces = 0;
836
+ while(cursor < content.length && content[cursor] === ' ' && spaces < 3){
837
+ cursor += 1;
838
+ spaces += 1;
839
+ }
840
+ if (cursor >= content.length) {
841
+ return null;
842
+ }
843
+ var char = content[cursor];
844
+ if (char !== '`' && char !== '~') {
845
+ return null;
846
+ }
847
+ var fenceLength = 0;
848
+ while(cursor < content.length && content[cursor] === char){
849
+ cursor += 1;
850
+ fenceLength += 1;
851
+ }
852
+ if (fenceLength < 3) {
853
+ return null;
854
+ }
855
+ var lineEnd = this._findLineEnd(content, cursor);
856
+ return {
857
+ marker: char,
858
+ end: lineEnd
859
+ };
860
+ }
861
+ },
862
+ {
863
+ key: "_findLineEnd",
864
+ value: function _findLineEnd(content, position) {
865
+ var cursor = position;
866
+ while(cursor < content.length && content[cursor] !== '\n'){
867
+ cursor += 1;
868
+ }
869
+ if (cursor < content.length && content[cursor] === '\n') {
870
+ return cursor + 1;
871
+ }
872
+ return cursor;
873
+ }
874
+ },
875
+ {
876
+ /**
604
877
  * 获取当前编辑器内容作为节点列表
605
878
  *
606
879
  * @returns 当前编辑器内容的节点列表
607
- */
608
- getContent() {
609
- const nodeList = this._editor.current.children;
610
- return nodeList;
611
- }
612
- /**
880
+ */ key: "getContent",
881
+ value: function getContent() {
882
+ var nodeList = this._editor.current.children;
883
+ return nodeList;
884
+ }
885
+ },
886
+ {
887
+ /**
613
888
  * 获取当前编辑器内容作为 markdown 字符串
614
889
  *
615
890
  * @param plugins - 可选的自定义 markdown 转换插件
616
891
  * @returns 转换为 markdown 的当前编辑器内容
617
- */
618
- getMDContent(plugins) {
619
- const nodeList = this._editor.current.children;
620
- const md = parserSlateNodeToMarkdown(
621
- nodeList,
622
- "",
623
- [{ root: true }],
624
- plugins || this.plugins
625
- );
626
- return md;
627
- }
628
- /**
892
+ */ key: "getMDContent",
893
+ value: function getMDContent(plugins) {
894
+ var nodeList = this._editor.current.children;
895
+ var md = parserSlateNodeToMarkdown(nodeList, '', [
896
+ {
897
+ root: true
898
+ }
899
+ ], plugins || this.plugins);
900
+ return md;
901
+ }
902
+ },
903
+ {
904
+ /**
629
905
  * 获取当前编辑器内容作为 HTML 字符串
630
906
  *
631
907
  * @returns 转换为 HTML 的当前编辑器内容
632
- */
633
- getHtmlContent(options) {
634
- const markdown = this.getMDContent();
635
- const appliedOptions = options != null ? options : this.markdownToHtmlOptions;
636
- if (options) {
637
- this.markdownToHtmlOptions = options;
638
- }
639
- return markdownToHtmlSync(markdown, appliedOptions);
640
- }
641
- /**
908
+ */ key: "getHtmlContent",
909
+ value: function getHtmlContent(options) {
910
+ var markdown = this.getMDContent();
911
+ var appliedOptions = options !== null && options !== void 0 ? options : this.markdownToHtmlOptions;
912
+ if (options) {
913
+ this.markdownToHtmlOptions = options;
914
+ }
915
+ return markdownToHtmlSync(markdown, appliedOptions);
916
+ }
917
+ },
918
+ {
919
+ /**
642
920
  * 使用节点列表设置编辑器内容
643
921
  *
644
922
  * @param nodeList - 要设置为编辑器内容的节点列表
645
- */
646
- setContent(nodeList) {
647
- this._editor.current.children = nodeList;
648
- this._editor.current.onChange();
649
- const lastNode = nodeList[nodeList.length - 1];
650
- if (lastNode && Text.isText(lastNode)) {
651
- const text = Node.string(lastNode);
652
- if (!text.endsWith("\n")) {
653
- this._editor.current.insertText("\n", {
654
- at: [nodeList.length - 1]
655
- });
656
- }
657
- }
658
- }
659
- /**
923
+ */ key: "setContent",
924
+ value: function setContent(nodeList) {
925
+ this._editor.current.children = nodeList;
926
+ this._editor.current.onChange();
927
+ // 检查最后一个节点是否以换行符结尾
928
+ var lastNode = nodeList[nodeList.length - 1];
929
+ if (lastNode && Text.isText(lastNode)) {
930
+ var text = Node.string(lastNode);
931
+ if (!text.endsWith('\n')) {
932
+ this._editor.current.insertText('\n', {
933
+ at: [
934
+ nodeList.length - 1
935
+ ]
936
+ });
937
+ }
938
+ }
939
+ }
940
+ },
941
+ {
942
+ /**
660
943
  * 使用差异检测和操作队列优化更新节点列表。
661
944
  *
662
945
  * @param nodeList - 新的节点列表
@@ -677,39 +960,36 @@ var EditorStore = class {
677
960
  * 错误处理:
678
961
  * - 如果优化更新失败,会回退到直接替换整个节点列表
679
962
  * - 错误信息会被记录到控制台
680
- */
681
- updateNodeList(nodeList) {
682
- if (!nodeList || !Array.isArray(nodeList))
683
- return;
684
- const filteredNodes = nodeList.filter((item) => {
685
- if (!item)
686
- return false;
687
- if (item.type === "p" && (!item.children || item.children.length === 0))
688
- return false;
689
- if (item.type === "list" && (!item.children || item.children.length === 0))
690
- return false;
691
- if (item.type === "listItem" && (!item.children || item.children.length === 0))
692
- return false;
693
- if (item.type === "code" && item.language === "code" && (!item.otherProps || item.otherProps.length === 0))
694
- return false;
695
- if (item.type === "image" && !item.src)
696
- return false;
697
- return true;
698
- });
699
- try {
700
- const operations = this.generateDiffOperations(
701
- filteredNodes,
702
- this._editor.current.children
703
- );
704
- if (operations.length > 0) {
705
- this.executeOperations(operations);
706
- }
707
- } catch (error) {
708
- console.error("Failed to update nodes with optimized method:", error);
709
- this._editor.current.children = nodeList;
710
- }
711
- }
712
- /**
963
+ */ key: "updateNodeList",
964
+ value: function updateNodeList(nodeList) {
965
+ if (!nodeList || !Array.isArray(nodeList)) return;
966
+ // 过滤无效节点
967
+ var filteredNodes = nodeList.filter(function(item) {
968
+ if (!item) return false;
969
+ if (item.type === 'p' && (!item.children || item.children.length === 0)) return false;
970
+ if (item.type === 'list' && (!item.children || item.children.length === 0)) return false;
971
+ if (item.type === 'listItem' && (!item.children || item.children.length === 0)) return false;
972
+ if (item.type === 'code' && item.language === 'code' && (!item.otherProps || item.otherProps.length === 0)) return false;
973
+ if (item.type === 'image' && !item.src) return false;
974
+ return true;
975
+ });
976
+ try {
977
+ // 生成差异操作
978
+ var operations = this.generateDiffOperations(filteredNodes, this._editor.current.children);
979
+ // 执行差异操作
980
+ if (operations.length > 0) {
981
+ this.executeOperations(operations);
982
+ }
983
+ } catch (error) {
984
+ console.error('Failed to update nodes with optimized method:', error);
985
+ // 回退:如果优化方法失败,使用直接替换
986
+ this._editor.current.children = nodeList;
987
+ }
988
+ }
989
+ },
990
+ {
991
+ key: "generateDiffOperations",
992
+ value: /**
713
993
  * 生成两个节点列表之间的差异操作队列。
714
994
  *
715
995
  * @param newNodes - 新的节点列表
@@ -721,41 +1001,54 @@ var EditorStore = class {
721
1001
  * 2. 对共有节点进行深度比较
722
1002
  * 3. 生成最小化的操作序列
723
1003
  * 4. 根据优先级排序操作
724
- */
725
- generateDiffOperations(newNodes, oldNodes) {
726
- if (!newNodes || !oldNodes)
727
- return [];
728
- const operations = [];
729
- const lengthDiff = newNodes.length - oldNodes.length;
730
- if (lengthDiff > 0) {
731
- for (let i = oldNodes.length; i < newNodes.length; i++) {
732
- operations.push({
733
- type: "insert",
734
- path: [i],
735
- node: newNodes[i],
736
- priority: 10
737
- // 新增节点优先级较低
738
- });
739
- }
740
- } else if (lengthDiff < 0) {
741
- for (let i = oldNodes.length - 1; i >= newNodes.length; i--) {
742
- operations.push({
743
- type: "remove",
744
- path: [i],
745
- priority: 0
746
- // 删除操作优先级最高
747
- });
748
- }
749
- }
750
- const minLength = Math.min(newNodes.length, oldNodes.length);
751
- for (let i = 0; i < minLength; i++) {
752
- const newNode = newNodes[i];
753
- const oldNode = oldNodes[i];
754
- this.compareNodes(newNode, oldNode, [i], operations);
755
- }
756
- return operations.sort((a, b) => a.priority - b.priority);
757
- }
758
- /**
1004
+ */ function generateDiffOperations(newNodes, oldNodes) {
1005
+ if (!newNodes || !oldNodes) return [];
1006
+ var operations = [];
1007
+ // 第一阶段:处理节点数量不同的情况
1008
+ var lengthDiff = newNodes.length - oldNodes.length;
1009
+ if (lengthDiff > 0) {
1010
+ // 新列表比旧列表长,添加新节点
1011
+ for(var i = oldNodes.length; i < newNodes.length; i++){
1012
+ operations.push({
1013
+ type: 'insert',
1014
+ path: [
1015
+ i
1016
+ ],
1017
+ node: newNodes[i],
1018
+ priority: 10
1019
+ });
1020
+ }
1021
+ } else if (lengthDiff < 0) {
1022
+ // 旧列表比新列表长,需要删除节点
1023
+ // 从后往前删除,以避免索引问题
1024
+ for(var i1 = oldNodes.length - 1; i1 >= newNodes.length; i1--){
1025
+ operations.push({
1026
+ type: 'remove',
1027
+ path: [
1028
+ i1
1029
+ ],
1030
+ priority: 0
1031
+ });
1032
+ }
1033
+ }
1034
+ // 第二阶段:深度比较共有的节点
1035
+ var minLength = Math.min(newNodes.length, oldNodes.length);
1036
+ for(var i2 = 0; i2 < minLength; i2++){
1037
+ var newNode = newNodes[i2];
1038
+ var oldNode = oldNodes[i2];
1039
+ this.compareNodes(newNode, oldNode, [
1040
+ i2
1041
+ ], operations);
1042
+ }
1043
+ // 按优先级排序操作队列
1044
+ return operations.sort(function(a, b) {
1045
+ return a.priority - b.priority;
1046
+ });
1047
+ }
1048
+ },
1049
+ {
1050
+ key: "compareNodes",
1051
+ value: /**
759
1052
  * 递归比较两个节点及其子节点的差异。
760
1053
  *
761
1054
  * @param newNode - 新节点
@@ -770,67 +1063,78 @@ var EditorStore = class {
770
1063
  * 4. 比较节点属性
771
1064
  * 5. 递归比较子节点
772
1065
  * @private
773
- */
774
- compareNodes(newNode, oldNode, path, operations) {
775
- if (newNode.type !== oldNode.type) {
776
- operations.push({
777
- type: "replace",
778
- path,
779
- node: newNode,
780
- priority: 5
781
- });
782
- return;
783
- }
784
- if (newNode.type === "table") {
785
- this.compareTableNodes(newNode, oldNode, path, operations);
786
- return;
787
- }
788
- if (typeof newNode.text === "string" && typeof oldNode.text === "string") {
789
- if (newNode.text !== oldNode.text) {
790
- operations.push({
791
- type: "text",
792
- path,
793
- text: newNode.text,
794
- priority: 8
795
- });
796
- }
797
- const newProps2 = __spreadValues({}, newNode);
798
- const oldProps2 = __spreadValues({}, oldNode);
799
- delete newProps2.text;
800
- delete oldProps2.text;
801
- if (!isEqual(newProps2, oldProps2)) {
802
- operations.push({
803
- type: "update",
804
- path,
805
- properties: newProps2,
806
- priority: 7
807
- });
808
- }
809
- return;
810
- }
811
- const newProps = __spreadProps(__spreadValues({}, newNode), { children: void 0 });
812
- const oldProps = __spreadProps(__spreadValues({}, oldNode), { children: void 0 });
813
- if (!isEqual(newProps, oldProps)) {
814
- operations.push({
815
- type: "update",
816
- path,
817
- properties: newProps,
818
- priority: 7
819
- });
820
- }
821
- if (newNode.children && oldNode.children) {
822
- const childrenOps = this.generateDiffOperations(
823
- newNode.children,
824
- oldNode.children
825
- );
826
- childrenOps.forEach((op) => {
827
- operations.push(__spreadProps(__spreadValues({}, op), {
828
- path: [...path, ...op.path]
829
- }));
830
- });
831
- }
832
- }
833
- /**
1066
+ */ function compareNodes(newNode, oldNode, path, operations) {
1067
+ // 如果节点类型不同,直接替换整个节点
1068
+ if (newNode.type !== oldNode.type) {
1069
+ operations.push({
1070
+ type: 'replace',
1071
+ path: path,
1072
+ node: newNode,
1073
+ priority: 5
1074
+ });
1075
+ return;
1076
+ }
1077
+ // 特殊处理表格节点
1078
+ if (newNode.type === 'table') {
1079
+ this.compareTableNodes(newNode, oldNode, path, operations);
1080
+ return;
1081
+ }
1082
+ // 如果两个节点是文本节点
1083
+ if (typeof newNode.text === 'string' && typeof oldNode.text === 'string') {
1084
+ if (newNode.text !== oldNode.text) {
1085
+ operations.push({
1086
+ type: 'text',
1087
+ path: path,
1088
+ text: newNode.text,
1089
+ priority: 8
1090
+ });
1091
+ }
1092
+ // 比较文本节点的其他属性(如加粗、斜体等)
1093
+ var newProps = _object_spread({}, newNode);
1094
+ var oldProps = _object_spread({}, oldNode);
1095
+ delete newProps.text;
1096
+ delete oldProps.text;
1097
+ if (!isEqual(newProps, oldProps)) {
1098
+ operations.push({
1099
+ type: 'update',
1100
+ path: path,
1101
+ properties: newProps,
1102
+ priority: 7
1103
+ });
1104
+ }
1105
+ return;
1106
+ }
1107
+ // 处理其他类型的节点属性更新
1108
+ var newProps1 = _object_spread_props(_object_spread({}, newNode), {
1109
+ children: undefined
1110
+ });
1111
+ var oldProps1 = _object_spread_props(_object_spread({}, oldNode), {
1112
+ children: undefined
1113
+ });
1114
+ if (!isEqual(newProps1, oldProps1)) {
1115
+ operations.push({
1116
+ type: 'update',
1117
+ path: path,
1118
+ properties: newProps1,
1119
+ priority: 7
1120
+ });
1121
+ }
1122
+ // 递归比较子节点
1123
+ if (newNode.children && oldNode.children) {
1124
+ // 特殊处理列表、引用等可能有嵌套结构的节点
1125
+ var childrenOps = this.generateDiffOperations(newNode.children, oldNode.children);
1126
+ // 将子节点的操作添加到队列中,调整路径
1127
+ childrenOps.forEach(function(op) {
1128
+ operations.push(_object_spread_props(_object_spread({}, op), {
1129
+ path: _to_consumable_array(path).concat(_to_consumable_array(op.path))
1130
+ }));
1131
+ });
1132
+ }
1133
+ }
1134
+ },
1135
+ {
1136
+ key: "compareTableNodes",
1137
+ value: /**
834
1138
  * 特殊处理表格节点的比较。
835
1139
  *
836
1140
  * @param newTable - 新的表格节点
@@ -845,134 +1149,176 @@ var EditorStore = class {
845
1149
  * 4. 处理行数变化
846
1150
  * 5. 必要时进行整表替换
847
1151
  * @private
848
- */
849
- compareTableNodes(newTable, oldTable, path, operations) {
850
- const newRows = newTable.children || [];
851
- const oldRows = oldTable.children || [];
852
- const isSameTableStructure = () => {
853
- if (newTable.id && oldTable.id) {
854
- return newTable.id === oldTable.id;
855
- }
856
- if (newRows.length === oldRows.length) {
857
- for (let i = 0; i < newRows.length; i++) {
858
- const newRow = newRows[i];
859
- const oldRow = oldRows[i];
860
- if (!newRow.children || !oldRow.children || newRow.children.length !== oldRow.children.length) {
861
- return false;
862
- }
863
- }
864
- return true;
865
- }
866
- return false;
867
- };
868
- const tablePropsChanged = () => {
869
- const newProps = __spreadValues({}, newTable);
870
- const oldProps = __spreadValues({}, oldTable);
871
- delete newProps.children;
872
- delete oldProps.children;
873
- return !isEqual(newProps, oldProps);
874
- };
875
- if (isSameTableStructure()) {
876
- if (tablePropsChanged()) {
877
- const newTableProps = __spreadProps(__spreadValues({}, newTable), { children: void 0 });
878
- operations.push({
879
- type: "update",
880
- path,
881
- properties: newTableProps,
882
- priority: 7
883
- });
884
- }
885
- for (let rowIdx = 0; rowIdx < newRows.length; rowIdx++) {
886
- const rowPath = [...path, rowIdx];
887
- const newRow = newRows[rowIdx];
888
- const oldRow = oldRows[rowIdx];
889
- const newRowProps = __spreadProps(__spreadValues({}, newRow), { children: void 0 });
890
- const oldRowProps = __spreadProps(__spreadValues({}, oldRow), { children: void 0 });
891
- if (!isEqual(newRowProps, oldRowProps)) {
892
- operations.push({
893
- type: "update",
894
- path: rowPath,
895
- properties: newRowProps,
896
- priority: 7
897
- });
898
- }
899
- const newCells = newRow.children || [];
900
- const oldCells = oldRow.children || [];
901
- const minCellCount = Math.min(newCells.length, oldCells.length);
902
- for (let cellIdx = 0; cellIdx < minCellCount; cellIdx++) {
903
- const cellPath = [...rowPath, cellIdx];
904
- const newCell = newCells[cellIdx];
905
- const oldCell = oldCells[cellIdx];
906
- this.compareCells(newCell, oldCell, cellPath, operations);
907
- }
908
- if (newCells.length > oldCells.length) {
909
- for (let cellIdx = oldCells.length; cellIdx < newCells.length; cellIdx++) {
910
- operations.push({
911
- type: "insert",
912
- path: [...rowPath, cellIdx],
913
- node: newCells[cellIdx],
914
- priority: 6
915
- });
916
- }
917
- } else if (newCells.length < oldCells.length) {
918
- for (let cellIdx = oldCells.length - 1; cellIdx >= newCells.length; cellIdx--) {
919
- operations.push({
920
- type: "remove",
921
- path: [...rowPath, cellIdx],
922
- priority: 1
923
- });
924
- }
925
- }
926
- }
927
- } else {
928
- if (Math.abs(newRows.length - oldRows.length) <= 2) {
929
- if (tablePropsChanged()) {
930
- operations.push({
931
- type: "update",
932
- path,
933
- properties: __spreadProps(__spreadValues({}, newTable), { children: void 0 }),
934
- priority: 7
935
- });
936
- }
937
- const minRowCount = Math.min(newRows.length, oldRows.length);
938
- for (let rowIdx = 0; rowIdx < minRowCount; rowIdx++) {
939
- const rowPath = [...path, rowIdx];
940
- this.compareNodes(
941
- newRows[rowIdx],
942
- oldRows[rowIdx],
943
- rowPath,
944
- operations
945
- );
946
- }
947
- if (newRows.length > oldRows.length) {
948
- for (let rowIdx = oldRows.length; rowIdx < newRows.length; rowIdx++) {
949
- operations.push({
950
- type: "insert",
951
- path: [...path, rowIdx],
952
- node: newRows[rowIdx],
953
- priority: 5
954
- });
955
- }
956
- } else if (newRows.length < oldRows.length) {
957
- for (let rowIdx = oldRows.length - 1; rowIdx >= newRows.length; rowIdx--) {
958
- operations.push({
959
- type: "remove",
960
- path: [...path, rowIdx],
961
- priority: 1
962
- });
963
- }
964
- }
965
- } else {
966
- operations.push({
967
- type: "replace",
968
- path,
969
- node: newTable,
970
- priority: 5
971
- });
972
- }
973
- }
974
- }
975
- /**
1152
+ */ function compareTableNodes(newTable, oldTable, path, operations) {
1153
+ var newRows = newTable.children || [];
1154
+ var oldRows = oldTable.children || [];
1155
+ // 检查是否是同一个表格的更新(检查表格的关键属性)
1156
+ var isSameTableStructure = function() {
1157
+ // 如果有表格ID或其他唯一标识符,优先比较这些
1158
+ if (newTable.id && oldTable.id) {
1159
+ return newTable.id === oldTable.id;
1160
+ }
1161
+ // 表格结构基本一致的情况(行数相同)
1162
+ if (newRows.length === oldRows.length) {
1163
+ // 检查每行的单元格数量
1164
+ for(var i = 0; i < newRows.length; i++){
1165
+ var newRow = newRows[i];
1166
+ var oldRow = oldRows[i];
1167
+ if (!newRow.children || !oldRow.children || newRow.children.length !== oldRow.children.length) {
1168
+ return false;
1169
+ }
1170
+ }
1171
+ return true;
1172
+ }
1173
+ return false;
1174
+ };
1175
+ // 非结构化属性对比(排除children
1176
+ var tablePropsChanged = function() {
1177
+ var newProps = _object_spread({}, newTable);
1178
+ var oldProps = _object_spread({}, oldTable);
1179
+ delete newProps.children;
1180
+ delete oldProps.children;
1181
+ return !isEqual(newProps, oldProps);
1182
+ };
1183
+ // 检查表格是否只有内容变化而结构相同
1184
+ if (isSameTableStructure()) {
1185
+ // 只更新表格属性(不包括子节点)
1186
+ if (tablePropsChanged()) {
1187
+ var newTableProps = _object_spread_props(_object_spread({}, newTable), {
1188
+ children: undefined
1189
+ });
1190
+ operations.push({
1191
+ type: 'update',
1192
+ path: path,
1193
+ properties: newTableProps,
1194
+ priority: 7
1195
+ });
1196
+ }
1197
+ // 逐行比较和更新
1198
+ for(var rowIdx = 0; rowIdx < newRows.length; rowIdx++){
1199
+ var rowPath = _to_consumable_array(path).concat([
1200
+ rowIdx
1201
+ ]);
1202
+ var newRow = newRows[rowIdx];
1203
+ var oldRow = oldRows[rowIdx];
1204
+ // 更新行属性(不包括子节点)
1205
+ var newRowProps = _object_spread_props(_object_spread({}, newRow), {
1206
+ children: undefined
1207
+ });
1208
+ var oldRowProps = _object_spread_props(_object_spread({}, oldRow), {
1209
+ children: undefined
1210
+ });
1211
+ if (!isEqual(newRowProps, oldRowProps)) {
1212
+ operations.push({
1213
+ type: 'update',
1214
+ path: rowPath,
1215
+ properties: newRowProps,
1216
+ priority: 7
1217
+ });
1218
+ }
1219
+ // 单元格比较和更新
1220
+ var newCells = newRow.children || [];
1221
+ var oldCells = oldRow.children || [];
1222
+ var minCellCount = Math.min(newCells.length, oldCells.length);
1223
+ // 更新共有的单元格
1224
+ for(var cellIdx = 0; cellIdx < minCellCount; cellIdx++){
1225
+ var cellPath = _to_consumable_array(rowPath).concat([
1226
+ cellIdx
1227
+ ]);
1228
+ var newCell = newCells[cellIdx];
1229
+ var oldCell = oldCells[cellIdx];
1230
+ this.compareCells(newCell, oldCell, cellPath, operations);
1231
+ }
1232
+ // 处理单元格数量变化
1233
+ if (newCells.length > oldCells.length) {
1234
+ // 添加新单元格
1235
+ for(var cellIdx1 = oldCells.length; cellIdx1 < newCells.length; cellIdx1++){
1236
+ operations.push({
1237
+ type: 'insert',
1238
+ path: _to_consumable_array(rowPath).concat([
1239
+ cellIdx1
1240
+ ]),
1241
+ node: newCells[cellIdx1],
1242
+ priority: 6
1243
+ });
1244
+ }
1245
+ } else if (newCells.length < oldCells.length) {
1246
+ // 删除多余单元格(从后向前删除)
1247
+ for(var cellIdx2 = oldCells.length - 1; cellIdx2 >= newCells.length; cellIdx2--){
1248
+ operations.push({
1249
+ type: 'remove',
1250
+ path: _to_consumable_array(rowPath).concat([
1251
+ cellIdx2
1252
+ ]),
1253
+ priority: 1
1254
+ });
1255
+ }
1256
+ }
1257
+ }
1258
+ } else {
1259
+ // 表格结构发生了变化,检查变化情况决定更新策略
1260
+ // 如果是简单的行增减,采用行级更新而非整表替换
1261
+ if (Math.abs(newRows.length - oldRows.length) <= 2) {
1262
+ // 行数量变化较小,尝试行级别更新
1263
+ // 先更新表格属性
1264
+ if (tablePropsChanged()) {
1265
+ operations.push({
1266
+ type: 'update',
1267
+ path: path,
1268
+ properties: _object_spread_props(_object_spread({}, newTable), {
1269
+ children: undefined
1270
+ }),
1271
+ priority: 7
1272
+ });
1273
+ }
1274
+ // 更新共有的行
1275
+ var minRowCount = Math.min(newRows.length, oldRows.length);
1276
+ for(var rowIdx1 = 0; rowIdx1 < minRowCount; rowIdx1++){
1277
+ var rowPath1 = _to_consumable_array(path).concat([
1278
+ rowIdx1
1279
+ ]);
1280
+ this.compareNodes(newRows[rowIdx1], oldRows[rowIdx1], rowPath1, operations);
1281
+ }
1282
+ // 处理行数变化
1283
+ if (newRows.length > oldRows.length) {
1284
+ // 添加新行
1285
+ for(var rowIdx2 = oldRows.length; rowIdx2 < newRows.length; rowIdx2++){
1286
+ operations.push({
1287
+ type: 'insert',
1288
+ path: _to_consumable_array(path).concat([
1289
+ rowIdx2
1290
+ ]),
1291
+ node: newRows[rowIdx2],
1292
+ priority: 5
1293
+ });
1294
+ }
1295
+ } else if (newRows.length < oldRows.length) {
1296
+ // 从后向前删除多余的行
1297
+ for(var rowIdx3 = oldRows.length - 1; rowIdx3 >= newRows.length; rowIdx3--){
1298
+ operations.push({
1299
+ type: 'remove',
1300
+ path: _to_consumable_array(path).concat([
1301
+ rowIdx3
1302
+ ]),
1303
+ priority: 1
1304
+ });
1305
+ }
1306
+ }
1307
+ } else {
1308
+ // 结构变化较大,整表替换可能更高效
1309
+ operations.push({
1310
+ type: 'replace',
1311
+ path: path,
1312
+ node: newTable,
1313
+ priority: 5
1314
+ });
1315
+ }
1316
+ }
1317
+ }
1318
+ },
1319
+ {
1320
+ key: "compareCells",
1321
+ value: /**
976
1322
  * 比较和更新表格单元格。
977
1323
  *
978
1324
  * @param newCell - 新的单元格节点
@@ -986,140 +1332,155 @@ var EditorStore = class {
986
1332
  * 3. 处理复杂单元格内容
987
1333
  * 4. 生成适当的更新操作
988
1334
  * @private
989
- */
990
- compareCells(newCell, oldCell, path, operations) {
991
- this.compareCellProperties(newCell, oldCell, path, operations);
992
- const newChildren = newCell.children || [];
993
- const oldChildren = oldCell.children || [];
994
- this.compareCellChildren(newChildren, oldChildren, path, operations);
995
- }
996
- /**
1335
+ */ function compareCells(newCell, oldCell, path, operations) {
1336
+ // 检查单元格属性是否变化
1337
+ this.compareCellProperties(newCell, oldCell, path, operations);
1338
+ // 处理单元格内容
1339
+ var newChildren = newCell.children || [];
1340
+ var oldChildren = oldCell.children || [];
1341
+ this.compareCellChildren(newChildren, oldChildren, path, operations);
1342
+ }
1343
+ },
1344
+ {
1345
+ key: "compareCellProperties",
1346
+ value: /**
997
1347
  * 比较单元格属性
998
- */
999
- compareCellProperties(newCell, oldCell, path, operations) {
1000
- const newCellProps = __spreadProps(__spreadValues({}, newCell), { children: void 0 });
1001
- const oldCellProps = __spreadProps(__spreadValues({}, oldCell), { children: void 0 });
1002
- if (!isEqual(newCellProps, oldCellProps)) {
1003
- operations.push({
1004
- type: "update",
1005
- path,
1006
- properties: newCellProps,
1007
- priority: 7
1008
- });
1009
- }
1010
- }
1011
- /**
1348
+ */ function compareCellProperties(newCell, oldCell, path, operations) {
1349
+ var newCellProps = _object_spread_props(_object_spread({}, newCell), {
1350
+ children: undefined
1351
+ });
1352
+ var oldCellProps = _object_spread_props(_object_spread({}, oldCell), {
1353
+ children: undefined
1354
+ });
1355
+ if (!isEqual(newCellProps, oldCellProps)) {
1356
+ operations.push({
1357
+ type: 'update',
1358
+ path: path,
1359
+ properties: newCellProps,
1360
+ priority: 7
1361
+ });
1362
+ }
1363
+ }
1364
+ },
1365
+ {
1366
+ key: "compareCellChildren",
1367
+ value: /**
1012
1368
  * 比较单元格子节点
1013
- */
1014
- compareCellChildren(newChildren, oldChildren, path, operations) {
1015
- if (this.isSimpleTextCell(newChildren, oldChildren)) {
1016
- this.compareSimpleTextCell(newChildren, oldChildren, path, operations);
1017
- return;
1018
- }
1019
- this.compareComplexCellChildren(newChildren, oldChildren, path, operations);
1020
- }
1021
- /**
1369
+ */ function compareCellChildren(newChildren, oldChildren, path, operations) {
1370
+ // 简单文本单元格的优化处理
1371
+ if (this.isSimpleTextCell(newChildren, oldChildren)) {
1372
+ this.compareSimpleTextCell(newChildren, oldChildren, path, operations);
1373
+ return;
1374
+ }
1375
+ // 复杂单元格内容
1376
+ this.compareComplexCellChildren(newChildren, oldChildren, path, operations);
1377
+ }
1378
+ },
1379
+ {
1380
+ key: "isSimpleTextCell",
1381
+ value: /**
1022
1382
  * 判断是否是简单文本单元格
1023
- */
1024
- isSimpleTextCell(newChildren, oldChildren) {
1025
- return newChildren.length === 1 && oldChildren.length === 1 && typeof newChildren[0].text === "string" && typeof oldChildren[0].text === "string";
1026
- }
1027
- /**
1383
+ */ function isSimpleTextCell(newChildren, oldChildren) {
1384
+ return newChildren.length === 1 && oldChildren.length === 1 && typeof newChildren[0].text === 'string' && typeof oldChildren[0].text === 'string';
1385
+ }
1386
+ },
1387
+ {
1388
+ key: "compareSimpleTextCell",
1389
+ value: /**
1028
1390
  * 比较简单文本单元格
1029
- */
1030
- compareSimpleTextCell(newChildren, oldChildren, path, operations) {
1031
- if (newChildren[0].text !== oldChildren[0].text) {
1032
- operations.push({
1033
- type: "text",
1034
- path: [...path, 0],
1035
- text: newChildren[0].text,
1036
- priority: 8
1037
- });
1038
- }
1039
- this.compareTextNodeProperties(
1040
- newChildren[0],
1041
- oldChildren[0],
1042
- path,
1043
- operations
1044
- );
1045
- }
1046
- /**
1391
+ */ function compareSimpleTextCell(newChildren, oldChildren, path, operations) {
1392
+ // 只有文本内容变化
1393
+ if (newChildren[0].text !== oldChildren[0].text) {
1394
+ operations.push({
1395
+ type: 'text',
1396
+ path: _to_consumable_array(path).concat([
1397
+ 0
1398
+ ]),
1399
+ text: newChildren[0].text,
1400
+ priority: 8
1401
+ });
1402
+ }
1403
+ // 检查文本节点的属性变化(加粗、斜体等)
1404
+ this.compareTextNodeProperties(newChildren[0], oldChildren[0], path, operations);
1405
+ }
1406
+ },
1407
+ {
1408
+ key: "compareTextNodeProperties",
1409
+ value: /**
1047
1410
  * 比较文本节点属性
1048
- */
1049
- compareTextNodeProperties(newChild, oldChild, path, operations) {
1050
- const newTextProps = __spreadValues({}, newChild);
1051
- const oldTextProps = __spreadValues({}, oldChild);
1052
- delete newTextProps.text;
1053
- delete oldTextProps.text;
1054
- if (!isEqual(newTextProps, oldTextProps)) {
1055
- operations.push({
1056
- type: "update",
1057
- path: [...path, 0],
1058
- properties: newTextProps,
1059
- priority: 7
1060
- });
1061
- }
1062
- }
1063
- /**
1411
+ */ function compareTextNodeProperties(newChild, oldChild, path, operations) {
1412
+ var newTextProps = _object_spread({}, newChild);
1413
+ var oldTextProps = _object_spread({}, oldChild);
1414
+ delete newTextProps.text;
1415
+ delete oldTextProps.text;
1416
+ if (!isEqual(newTextProps, oldTextProps)) {
1417
+ operations.push({
1418
+ type: 'update',
1419
+ path: _to_consumable_array(path).concat([
1420
+ 0
1421
+ ]),
1422
+ properties: newTextProps,
1423
+ priority: 7
1424
+ });
1425
+ }
1426
+ }
1427
+ },
1428
+ {
1429
+ key: "compareComplexCellChildren",
1430
+ value: /**
1064
1431
  * 比较复杂单元格子节点
1065
- */
1066
- compareComplexCellChildren(newChildren, oldChildren, path, operations) {
1067
- const structurallyDifferent = this.isStructurallyDifferent(
1068
- newChildren,
1069
- oldChildren
1070
- );
1071
- if (structurallyDifferent) {
1072
- this.replaceComplexCellChildren(
1073
- newChildren,
1074
- oldChildren,
1075
- path,
1076
- operations
1077
- );
1078
- return;
1079
- }
1080
- this.compareChildrenSequentially(
1081
- newChildren,
1082
- oldChildren,
1083
- path,
1084
- operations
1085
- );
1086
- }
1087
- /**
1432
+ */ function compareComplexCellChildren(newChildren, oldChildren, path, operations) {
1433
+ // 检查是否结构完全不同
1434
+ var structurallyDifferent = this.isStructurallyDifferent(newChildren, oldChildren);
1435
+ if (structurallyDifferent) {
1436
+ this.replaceComplexCellChildren(newChildren, oldChildren, path, operations);
1437
+ return;
1438
+ }
1439
+ // 逐个比较并更新子节点
1440
+ this.compareChildrenSequentially(newChildren, oldChildren, path, operations);
1441
+ }
1442
+ },
1443
+ {
1444
+ key: "isStructurallyDifferent",
1445
+ value: /**
1088
1446
  * 判断结构是否不同
1089
- */
1090
- isStructurallyDifferent(newChildren, oldChildren) {
1091
- if (newChildren.length !== oldChildren.length)
1092
- return true;
1093
- return newChildren.some(
1094
- (n, i) => oldChildren[i] && n.type !== oldChildren[i].type
1095
- );
1096
- }
1097
- /**
1447
+ */ function isStructurallyDifferent(newChildren, oldChildren) {
1448
+ if (newChildren.length !== oldChildren.length) return true;
1449
+ return newChildren.some(function(n, i) {
1450
+ return oldChildren[i] && n.type !== oldChildren[i].type;
1451
+ });
1452
+ }
1453
+ },
1454
+ {
1455
+ key: "replaceComplexCellChildren",
1456
+ value: /**
1098
1457
  * 替换复杂单元格子节点
1099
- */
1100
- replaceComplexCellChildren(newChildren, oldChildren, path, operations) {
1101
- const childOps = this.generateDiffOperations(newChildren, oldChildren);
1102
- childOps.forEach((op) => {
1103
- operations.push(__spreadProps(__spreadValues({}, op), {
1104
- path: [...path, ...op.path]
1105
- }));
1106
- });
1107
- }
1108
- /**
1458
+ */ function replaceComplexCellChildren(newChildren, oldChildren, path, operations) {
1459
+ var childOps = this.generateDiffOperations(newChildren, oldChildren);
1460
+ // 调整子操作的路径
1461
+ childOps.forEach(function(op) {
1462
+ operations.push(_object_spread_props(_object_spread({}, op), {
1463
+ path: _to_consumable_array(path).concat(_to_consumable_array(op.path))
1464
+ }));
1465
+ });
1466
+ }
1467
+ },
1468
+ {
1469
+ key: "compareChildrenSequentially",
1470
+ value: /**
1109
1471
  * 逐个比较子节点
1110
- */
1111
- compareChildrenSequentially(newChildren, oldChildren, path, operations) {
1112
- const length = Math.min(newChildren.length, oldChildren.length);
1113
- for (let i = 0; i < length; i++) {
1114
- this.compareNodes(
1115
- newChildren[i],
1116
- oldChildren[i],
1117
- [...path, i],
1118
- operations
1119
- );
1120
- }
1121
- }
1122
- /**
1472
+ */ function compareChildrenSequentially(newChildren, oldChildren, path, operations) {
1473
+ var length = Math.min(newChildren.length, oldChildren.length);
1474
+ for(var i = 0; i < length; i++){
1475
+ this.compareNodes(newChildren[i], oldChildren[i], _to_consumable_array(path).concat([
1476
+ i
1477
+ ]), operations);
1478
+ }
1479
+ }
1480
+ },
1481
+ {
1482
+ key: "executeOperations",
1483
+ value: /**
1123
1484
  * 执行操作队列中的所有操作。
1124
1485
  *
1125
1486
  * @param operations - 要执行的操作队列
@@ -1129,55 +1490,80 @@ var EditorStore = class {
1129
1490
  * 2. 按照操作类型分别处理
1130
1491
  * 3. 处理可能的错误情况
1131
1492
  * 4. 保证操作的原子性
1132
- */
1133
- executeOperations(operations) {
1134
- const editor = this._editor.current;
1135
- if (!editor)
1136
- return;
1137
- Editor.withoutNormalizing(editor, () => {
1138
- for (const op of operations) {
1139
- try {
1140
- switch (op.type) {
1141
- case "insert":
1142
- if (op.node && editor.hasPath(Path.parent(op.path))) {
1143
- Transforms.insertNodes(editor, op.node, { at: op.path });
1144
- }
1145
- break;
1146
- case "remove":
1147
- if (editor.hasPath(op.path)) {
1148
- Transforms.removeNodes(editor, { at: op.path });
1149
- }
1150
- break;
1151
- case "update":
1152
- if (op.properties && editor.hasPath(op.path)) {
1153
- Transforms.setNodes(editor, op.properties, { at: op.path });
1154
- }
1155
- break;
1156
- case "replace":
1157
- if (op.node && editor.hasPath(op.path)) {
1158
- Transforms.removeNodes(editor, { at: op.path });
1159
- Transforms.insertNodes(editor, op.node, { at: op.path });
1160
- }
1161
- break;
1162
- case "text":
1163
- if (op.text !== void 0 && editor.hasPath(op.path)) {
1164
- Transforms.insertText(editor, op.text, {
1165
- at: op.path,
1166
- voids: true
1493
+ */ function executeOperations(operations) {
1494
+ var editor = this._editor.current;
1495
+ if (!editor) return;
1496
+ // 使用批处理模式执行所有操作
1497
+ Editor.withoutNormalizing(editor, function() {
1498
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1499
+ try {
1500
+ for(var _iterator = operations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1501
+ var op = _step.value;
1502
+ try {
1503
+ switch(op.type){
1504
+ case 'insert':
1505
+ if (op.node && editor.hasPath(Path.parent(op.path))) {
1506
+ Transforms.insertNodes(editor, op.node, {
1507
+ at: op.path
1508
+ });
1509
+ }
1510
+ break;
1511
+ case 'remove':
1512
+ if (editor.hasPath(op.path)) {
1513
+ Transforms.removeNodes(editor, {
1514
+ at: op.path
1515
+ });
1516
+ }
1517
+ break;
1518
+ case 'update':
1519
+ if (op.properties && editor.hasPath(op.path)) {
1520
+ Transforms.setNodes(editor, op.properties, {
1521
+ at: op.path
1522
+ });
1523
+ }
1524
+ break;
1525
+ case 'replace':
1526
+ if (op.node && editor.hasPath(op.path)) {
1527
+ Transforms.removeNodes(editor, {
1528
+ at: op.path
1529
+ });
1530
+ Transforms.insertNodes(editor, op.node, {
1531
+ at: op.path
1532
+ });
1533
+ }
1534
+ break;
1535
+ case 'text':
1536
+ if (op.text !== undefined && editor.hasPath(op.path)) {
1537
+ Transforms.insertText(editor, op.text, {
1538
+ at: op.path,
1539
+ voids: true
1540
+ });
1541
+ }
1542
+ break;
1543
+ }
1544
+ } catch (err) {
1545
+ console.error("Error executing operation ".concat(op.type, " at path ").concat(op.path, ":"), err);
1546
+ }
1547
+ }
1548
+ } catch (err) {
1549
+ _didIteratorError = true;
1550
+ _iteratorError = err;
1551
+ } finally{
1552
+ try {
1553
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1554
+ _iterator.return();
1555
+ }
1556
+ } finally{
1557
+ if (_didIteratorError) {
1558
+ throw _iteratorError;
1559
+ }
1560
+ }
1561
+ }
1167
1562
  });
1168
- }
1169
- break;
1170
- }
1171
- } catch (err) {
1172
- console.error(
1173
- `Error executing operation ${op.type} at path ${op.path}:`,
1174
- err
1175
- );
1176
- }
1177
- }
1178
- });
1179
- }
1180
- /**
1563
+ }
1564
+ },
1565
+ {
1566
+ /**
1181
1567
  * 处理拖拽开始事件。
1182
1568
  *
1183
1569
  * @param e - React 拖拽事件对象
@@ -1191,153 +1577,191 @@ var EditorStore = class {
1191
1577
  * 5. 计算可拖拽目标的位置
1192
1578
  * 6. 处理拖拽过程中的视觉反馈
1193
1579
  * 7. 在拖拽结束时更新编辑器内容
1194
- */
1195
- dragStart(e, container) {
1196
- var _a, _b, _c;
1197
- e.stopPropagation();
1198
- const img = document.createElement("img");
1199
- img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
1200
- e.dataTransfer.setDragImage(img, 1, 1);
1201
- const ableToEnter = ((_b = (_a = this.draggedElement) == null ? void 0 : _a.dataset) == null ? void 0 : _b.be) === "list-item" ? /* @__PURE__ */ new Set([
1202
- "paragraph",
1203
- "head",
1204
- "blockquote",
1205
- "code",
1206
- "table",
1207
- "list",
1208
- "list-item",
1209
- "media",
1210
- "attach"
1211
- ]) : this.ableToEnter;
1212
- let mark = null;
1213
- const els = document.querySelectorAll("[data-be]");
1214
- const points = [];
1215
- for (let el of els) {
1216
- if (!ableToEnter.has(el.dataset.be))
1217
- continue;
1218
- if (el.classList.contains("frontmatter"))
1219
- continue;
1220
- const pre = el.previousSibling;
1221
- if (el.dataset.be === "paragraph" && ((_c = this.draggedElement) == null ? void 0 : _c.dataset.be) === "list-item" && (!pre || pre.classList.contains("check-item"))) {
1222
- continue;
1223
- }
1224
- if (el === this.draggedElement)
1225
- continue;
1226
- const top = getOffsetTop(el, container);
1227
- const left = getOffsetLeft(el, container);
1228
- points.push({
1229
- el,
1230
- direction: "top",
1231
- left,
1232
- top
1233
- });
1234
- points.push({
1235
- el,
1236
- left,
1237
- direction: "bottom",
1238
- top: top + el.clientHeight + 2
1239
- });
1240
- }
1241
- let last = null;
1242
- const dragover = (e2) => {
1243
- e2.preventDefault();
1244
- const top = e2.clientY - 40 + container.scrollTop;
1245
- let distance = 1e6;
1246
- let cur = null;
1247
- for (let p of points) {
1248
- let curDistance = Math.abs(p.top - top);
1249
- if (curDistance < distance) {
1250
- cur = p;
1251
- distance = curDistance;
1252
- }
1253
- }
1254
- if (cur) {
1255
- const rect = container.getBoundingClientRect();
1256
- const scrollTop = container.scrollTop;
1257
- const scrollLeft = container.scrollLeft;
1258
- last = cur;
1259
- const width = last.el.dataset.be === "list-item" ? last.el.clientWidth + 20 + "px" : last.el.clientWidth + "px";
1260
- if (!mark) {
1261
- mark = document.createElement("div");
1262
- mark.classList.add("move-mark");
1263
- mark.style.width = width;
1264
- mark.style.height = "2px";
1265
- mark.style.transform = `translate(${last.left - rect.left - scrollLeft}px, ${last.top - rect.top - scrollTop}px)`;
1266
- container == null ? void 0 : container.parentElement.append(mark);
1267
- } else {
1268
- mark.style.width = width;
1269
- mark.style.transform = `translate(${last.left - rect.left - scrollLeft}px, ${last.top - rect.top - scrollTop}px)`;
1270
- }
1271
- }
1272
- };
1273
- window.addEventListener("dragover", dragover);
1274
- window.addEventListener(
1275
- "dragend",
1276
- () => {
1277
- var _a2, _b2;
1278
- try {
1279
- window.removeEventListener("dragover", dragover);
1280
- if (mark)
1281
- container == null ? void 0 : container.parentElement.removeChild(mark);
1282
- if (last && this.draggedElement) {
1283
- let [dragPath, dragNode] = this.toPath(this.draggedElement);
1284
- let [targetPath] = this.toPath(last.el);
1285
- let toPath = last.direction === "top" ? targetPath : Path.next(targetPath);
1286
- if (!Path.equals(targetPath, dragPath)) {
1287
- const parent = Node.parent(this._editor.current, dragPath);
1288
- if (Path.equals(Path.parent(targetPath), Path.parent(dragPath)) && Path.compare(dragPath, targetPath) === -1) {
1289
- toPath = Path.previous(toPath);
1290
- }
1291
- let delPath = Path.parent(dragPath);
1292
- const targetNode = Node.get(this._editor.current, targetPath);
1293
- if (dragNode.type === "list-item") {
1294
- if (targetNode.type !== "list-item") {
1295
- Transforms.delete(this._editor.current, { at: dragPath });
1296
- Transforms.insertNodes(
1297
- this._editor.current,
1298
- __spreadProps(__spreadValues({}, parent), {
1299
- children: [EditorUtils.copy(dragNode)]
1300
- }),
1301
- { at: toPath, select: true }
1302
- );
1303
- if (((_a2 = parent.children) == null ? void 0 : _a2.length) === 1) {
1304
- if (EditorUtils.isNextPath(Path.parent(dragPath), targetPath)) {
1305
- delPath = Path.next(Path.parent(dragPath));
1306
- } else {
1307
- delPath = Path.parent(dragPath);
1580
+ */ key: "dragStart",
1581
+ value: function dragStart(e, container) {
1582
+ var _this = this;
1583
+ var _this_draggedElement_dataset, _this_draggedElement;
1584
+ e.stopPropagation();
1585
+ var img = document.createElement('img');
1586
+ img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
1587
+ e.dataTransfer.setDragImage(img, 1, 1);
1588
+ var ableToEnter = ((_this_draggedElement = this.draggedElement) === null || _this_draggedElement === void 0 ? void 0 : (_this_draggedElement_dataset = _this_draggedElement.dataset) === null || _this_draggedElement_dataset === void 0 ? void 0 : _this_draggedElement_dataset.be) === 'list-item' ? new Set([
1589
+ 'paragraph',
1590
+ 'head',
1591
+ 'blockquote',
1592
+ 'code',
1593
+ 'table',
1594
+ 'list',
1595
+ 'list-item',
1596
+ 'media',
1597
+ 'attach'
1598
+ ]) : this.ableToEnter;
1599
+ var mark = null;
1600
+ var els = document.querySelectorAll('[data-be]');
1601
+ var points = [];
1602
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1603
+ try {
1604
+ // @ts-ignore
1605
+ for(var _iterator = els[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1606
+ var el = _step.value;
1607
+ var _this_draggedElement1;
1608
+ if (!ableToEnter.has(el.dataset.be)) continue;
1609
+ if (el.classList.contains('frontmatter')) continue;
1610
+ var pre = el.previousSibling;
1611
+ if (el.dataset.be === 'paragraph' && ((_this_draggedElement1 = this.draggedElement) === null || _this_draggedElement1 === void 0 ? void 0 : _this_draggedElement1.dataset.be) === 'list-item' && (!pre || pre.classList.contains('check-item'))) {
1612
+ continue;
1613
+ }
1614
+ if (el === this.draggedElement) continue;
1615
+ var top = getOffsetTop(el, container);
1616
+ var left = getOffsetLeft(el, container);
1617
+ points.push({
1618
+ el: el,
1619
+ direction: 'top',
1620
+ left: left,
1621
+ top: top
1622
+ });
1623
+ points.push({
1624
+ el: el,
1625
+ left: left,
1626
+ direction: 'bottom',
1627
+ top: top + el.clientHeight + 2
1628
+ });
1629
+ }
1630
+ } catch (err) {
1631
+ _didIteratorError = true;
1632
+ _iteratorError = err;
1633
+ } finally{
1634
+ try {
1635
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1636
+ _iterator.return();
1637
+ }
1638
+ } finally{
1639
+ if (_didIteratorError) {
1640
+ throw _iteratorError;
1641
+ }
1308
1642
  }
1309
- }
1310
- } else {
1311
- Transforms.moveNodes(this._editor.current, {
1312
- at: dragPath,
1313
- to: toPath
1314
- });
1315
1643
  }
1316
- } else {
1317
- Transforms.moveNodes(this._editor.current, {
1318
- at: dragPath,
1319
- to: toPath
1644
+ var last = null;
1645
+ var dragover = function(e) {
1646
+ e.preventDefault();
1647
+ var top = e.clientY - 40 + container.scrollTop;
1648
+ var distance = 1000000;
1649
+ var cur = null;
1650
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1651
+ try {
1652
+ for(var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1653
+ var p = _step.value;
1654
+ var curDistance = Math.abs(p.top - top);
1655
+ if (curDistance < distance) {
1656
+ cur = p;
1657
+ distance = curDistance;
1658
+ }
1659
+ }
1660
+ } catch (err) {
1661
+ _didIteratorError = true;
1662
+ _iteratorError = err;
1663
+ } finally{
1664
+ try {
1665
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1666
+ _iterator.return();
1667
+ }
1668
+ } finally{
1669
+ if (_didIteratorError) {
1670
+ throw _iteratorError;
1671
+ }
1672
+ }
1673
+ }
1674
+ if (cur) {
1675
+ var rect = container.getBoundingClientRect();
1676
+ var scrollTop = container.scrollTop;
1677
+ var scrollLeft = container.scrollLeft;
1678
+ last = cur;
1679
+ var width = last.el.dataset.be === 'list-item' ? last.el.clientWidth + 20 + 'px' : last.el.clientWidth + 'px';
1680
+ if (!mark) {
1681
+ mark = document.createElement('div');
1682
+ mark.classList.add('move-mark');
1683
+ mark.style.width = width;
1684
+ mark.style.height = '2px';
1685
+ mark.style.transform = "translate(".concat(last.left - rect.left - scrollLeft, "px, ").concat(last.top - rect.top - scrollTop, "px)");
1686
+ container === null || container === void 0 ? void 0 : container.parentElement.append(mark);
1687
+ } else {
1688
+ mark.style.width = width;
1689
+ mark.style.transform = "translate(".concat(last.left - rect.left - scrollLeft, "px, ").concat(last.top - rect.top - scrollTop, "px)");
1690
+ }
1691
+ }
1692
+ };
1693
+ window.addEventListener('dragover', dragover);
1694
+ window.addEventListener('dragend', function() {
1695
+ try {
1696
+ window.removeEventListener('dragover', dragover);
1697
+ if (mark) container === null || container === void 0 ? void 0 : container.parentElement.removeChild(mark);
1698
+ if (last && _this.draggedElement) {
1699
+ var _this_toPath = _sliced_to_array(_this.toPath(_this.draggedElement), 2), dragPath = _this_toPath[0], dragNode = _this_toPath[1];
1700
+ var _this_toPath1 = _sliced_to_array(_this.toPath(last.el), 1), targetPath = _this_toPath1[0];
1701
+ var toPath = last.direction === 'top' ? targetPath : Path.next(targetPath);
1702
+ if (!Path.equals(targetPath, dragPath)) {
1703
+ var _parent_children;
1704
+ var parent = Node.parent(_this._editor.current, dragPath);
1705
+ if (Path.equals(Path.parent(targetPath), Path.parent(dragPath)) && Path.compare(dragPath, targetPath) === -1) {
1706
+ toPath = Path.previous(toPath);
1707
+ }
1708
+ var delPath = Path.parent(dragPath);
1709
+ var targetNode = Node.get(_this._editor.current, targetPath);
1710
+ if (dragNode.type === 'list-item') {
1711
+ if (targetNode.type !== 'list-item') {
1712
+ var _parent_children1;
1713
+ Transforms.delete(_this._editor.current, {
1714
+ at: dragPath
1715
+ });
1716
+ Transforms.insertNodes(_this._editor.current, _object_spread_props(_object_spread({}, parent), {
1717
+ children: [
1718
+ EditorUtils.copy(dragNode)
1719
+ ]
1720
+ }), {
1721
+ at: toPath,
1722
+ select: true
1723
+ });
1724
+ if (((_parent_children1 = parent.children) === null || _parent_children1 === void 0 ? void 0 : _parent_children1.length) === 1) {
1725
+ if (EditorUtils.isNextPath(Path.parent(dragPath), targetPath)) {
1726
+ delPath = Path.next(Path.parent(dragPath));
1727
+ } else {
1728
+ delPath = Path.parent(dragPath);
1729
+ }
1730
+ }
1731
+ } else {
1732
+ Transforms.moveNodes(_this._editor.current, {
1733
+ at: dragPath,
1734
+ to: toPath
1735
+ });
1736
+ }
1737
+ } else {
1738
+ Transforms.moveNodes(_this._editor.current, {
1739
+ at: dragPath,
1740
+ to: toPath
1741
+ });
1742
+ }
1743
+ if (((_parent_children = parent.children) === null || _parent_children === void 0 ? void 0 : _parent_children.length) === 1) {
1744
+ if (Path.equals(Path.parent(toPath), Path.parent(delPath)) && Path.compare(toPath, delPath) !== 1) {
1745
+ delPath = Path.next(delPath);
1746
+ }
1747
+ Transforms.delete(_this._editor.current, {
1748
+ at: delPath
1749
+ });
1750
+ }
1751
+ }
1752
+ if ((dragNode === null || dragNode === void 0 ? void 0 : dragNode.type) !== 'media') _this.draggedElement.draggable = false;
1753
+ }
1754
+ _this.draggedElement = null;
1755
+ } catch (error) {
1756
+ console.error(error);
1757
+ }
1758
+ }, {
1759
+ once: true
1320
1760
  });
1321
- }
1322
- if (((_b2 = parent.children) == null ? void 0 : _b2.length) === 1) {
1323
- if (Path.equals(Path.parent(toPath), Path.parent(delPath)) && Path.compare(toPath, delPath) !== 1) {
1324
- delPath = Path.next(delPath);
1325
- }
1326
- Transforms.delete(this._editor.current, { at: delPath });
1327
- }
1328
1761
  }
1329
- if ((dragNode == null ? void 0 : dragNode.type) !== "media")
1330
- this.draggedElement.draggable = false;
1331
- }
1332
- this.draggedElement = null;
1333
- } catch (error) {
1334
- console.error(error);
1335
- }
1336
- },
1337
- { once: true }
1338
- );
1339
- }
1340
- /**
1762
+ },
1763
+ {
1764
+ /**
1341
1765
  * 替换编辑器中的文本内容
1342
1766
  *
1343
1767
  * @param searchText - 要查找和替换的原始文本
@@ -1360,136 +1784,130 @@ var EditorStore = class {
1360
1784
  * replaceAll: false
1361
1785
  * });
1362
1786
  * ```
1363
- */
1364
- replaceText(searchText, replaceText, options = {}) {
1365
- const {
1366
- caseSensitive = false,
1367
- wholeWord = false,
1368
- replaceAll = true
1369
- } = options;
1370
- if (!searchText)
1371
- return 0;
1372
- const editor = this._editor.current;
1373
- let replaceCount = 0;
1374
- const textNodes = Array.from(
1375
- Editor.nodes(editor, {
1376
- at: [],
1377
- match: (n) => Text.isText(n) && typeof n.text === "string"
1378
- })
1379
- );
1380
- Editor.withoutNormalizing(editor, () => {
1381
- if (replaceAll) {
1382
- for (let i = textNodes.length - 1; i >= 0; i--) {
1383
- const [node, path] = textNodes[i];
1384
- const originalText = node.text;
1385
- let newText = originalText;
1386
- let nodeReplaceCount = 0;
1387
- if (caseSensitive) {
1388
- if (wholeWord) {
1389
- const regex = new RegExp(
1390
- `\\b${this.escapeRegExp(searchText)}\\b`,
1391
- "g"
1392
- );
1393
- newText = originalText.replace(regex, () => {
1394
- nodeReplaceCount++;
1395
- return replaceText;
1396
- });
1397
- } else {
1398
- newText = originalText.replace(
1399
- new RegExp(this.escapeRegExp(searchText), "g"),
1400
- () => {
1401
- nodeReplaceCount++;
1402
- return replaceText;
1403
- }
1404
- );
1405
- }
1406
- } else {
1407
- if (wholeWord) {
1408
- const regex = new RegExp(
1409
- `\\b${this.escapeRegExp(searchText)}\\b`,
1410
- "gi"
1411
- );
1412
- newText = originalText.replace(regex, () => {
1413
- nodeReplaceCount++;
1414
- return replaceText;
1415
- });
1416
- } else {
1417
- newText = originalText.replace(
1418
- new RegExp(this.escapeRegExp(searchText), "gi"),
1419
- () => {
1420
- nodeReplaceCount++;
1421
- return replaceText;
1422
- }
1423
- );
1424
- }
1425
- }
1426
- if (newText !== originalText) {
1427
- Transforms.insertText(editor, newText, {
1428
- at: path,
1429
- voids: true
1430
- });
1431
- replaceCount += nodeReplaceCount;
1432
- }
1433
- }
1434
- } else {
1435
- for (let i = 0; i < textNodes.length; i++) {
1436
- const [node, path] = textNodes[i];
1437
- const originalText = node.text;
1438
- let newText = originalText;
1439
- let nodeReplaceCount = 0;
1440
- if (caseSensitive) {
1441
- if (wholeWord) {
1442
- const regex = new RegExp(
1443
- `\\b${this.escapeRegExp(searchText)}\\b`,
1444
- ""
1445
- );
1446
- newText = originalText.replace(regex, () => {
1447
- nodeReplaceCount++;
1448
- return replaceText;
1449
- });
1450
- } else {
1451
- newText = originalText.replace(
1452
- new RegExp(this.escapeRegExp(searchText), ""),
1453
- () => {
1454
- nodeReplaceCount++;
1455
- return replaceText;
1456
- }
1457
- );
1458
- }
1459
- } else {
1460
- if (wholeWord) {
1461
- const regex = new RegExp(
1462
- `\\b${this.escapeRegExp(searchText)}\\b`,
1463
- "i"
1464
- );
1465
- newText = originalText.replace(regex, () => {
1466
- nodeReplaceCount++;
1467
- return replaceText;
1468
- });
1469
- } else {
1470
- newText = originalText.replace(
1471
- new RegExp(this.escapeRegExp(searchText), "i"),
1472
- () => {
1473
- nodeReplaceCount++;
1474
- return replaceText;
1475
- }
1476
- );
1787
+ */ key: "replaceText",
1788
+ value: function replaceText(searchText, replaceText) {
1789
+ var _this = this;
1790
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1791
+ var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_replaceAll = options.replaceAll, replaceAll = _options_replaceAll === void 0 ? true : _options_replaceAll;
1792
+ if (!searchText) return 0;
1793
+ var editor = this._editor.current;
1794
+ var replaceCount = 0;
1795
+ // 遍历所有文本节点进行替换
1796
+ var textNodes = Array.from(Editor.nodes(editor, {
1797
+ at: [],
1798
+ match: function(n) {
1799
+ return Text.isText(n) && typeof n.text === 'string';
1800
+ }
1801
+ }));
1802
+ Editor.withoutNormalizing(editor, function() {
1803
+ if (replaceAll) {
1804
+ var _loop = function(i) {
1805
+ var _textNodes_i = _sliced_to_array(textNodes[i], 2), node = _textNodes_i[0], path = _textNodes_i[1];
1806
+ var originalText = node.text;
1807
+ var newText = originalText;
1808
+ var nodeReplaceCount = 0;
1809
+ if (caseSensitive) {
1810
+ if (wholeWord) {
1811
+ // 匹配完整单词
1812
+ var regex = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), 'g');
1813
+ newText = originalText.replace(regex, function() {
1814
+ nodeReplaceCount++;
1815
+ return replaceText;
1816
+ });
1817
+ } else {
1818
+ // 普通字符串替换
1819
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), 'g'), function() {
1820
+ nodeReplaceCount++;
1821
+ return replaceText;
1822
+ });
1823
+ }
1824
+ } else {
1825
+ if (wholeWord) {
1826
+ // 匹配完整单词,不区分大小写
1827
+ var regex1 = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), 'gi');
1828
+ newText = originalText.replace(regex1, function() {
1829
+ nodeReplaceCount++;
1830
+ return replaceText;
1831
+ });
1832
+ } else {
1833
+ // 普通字符串替换,不区分大小写
1834
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), 'gi'), function() {
1835
+ nodeReplaceCount++;
1836
+ return replaceText;
1837
+ });
1838
+ }
1839
+ }
1840
+ // 如果文本发生了变化,更新节点
1841
+ if (newText !== originalText) {
1842
+ Transforms.insertText(editor, newText, {
1843
+ at: path,
1844
+ voids: true
1845
+ });
1846
+ replaceCount += nodeReplaceCount;
1847
+ }
1848
+ };
1849
+ // 替换所有:从后往前处理,避免路径变化影响前面的操作
1850
+ for(var i = textNodes.length - 1; i >= 0; i--)_loop(i);
1851
+ } else {
1852
+ var _loop1 = function(i1) {
1853
+ var _textNodes_i = _sliced_to_array(textNodes[i1], 2), node = _textNodes_i[0], path = _textNodes_i[1];
1854
+ var originalText = node.text;
1855
+ var newText = originalText;
1856
+ var nodeReplaceCount = 0;
1857
+ if (caseSensitive) {
1858
+ if (wholeWord) {
1859
+ // 匹配完整单词
1860
+ var regex = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), '');
1861
+ newText = originalText.replace(regex, function() {
1862
+ nodeReplaceCount++;
1863
+ return replaceText;
1864
+ });
1865
+ } else {
1866
+ // 普通字符串替换
1867
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), ''), function() {
1868
+ nodeReplaceCount++;
1869
+ return replaceText;
1870
+ });
1871
+ }
1872
+ } else {
1873
+ if (wholeWord) {
1874
+ // 匹配完整单词,不区分大小写
1875
+ var regex1 = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), 'i');
1876
+ newText = originalText.replace(regex1, function() {
1877
+ nodeReplaceCount++;
1878
+ return replaceText;
1879
+ });
1880
+ } else {
1881
+ // 普通字符串替换,不区分大小写
1882
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), 'i'), function() {
1883
+ nodeReplaceCount++;
1884
+ return replaceText;
1885
+ });
1886
+ }
1887
+ }
1888
+ // 如果文本发生了变化,更新节点并停止
1889
+ if (newText !== originalText) {
1890
+ Transforms.insertText(editor, newText, {
1891
+ at: path,
1892
+ voids: true
1893
+ });
1894
+ replaceCount += nodeReplaceCount;
1895
+ return "break" // 只替换第一个匹配项
1896
+ ;
1897
+ }
1898
+ };
1899
+ // 只替换第一个:从前往后处理,找到第一个匹配就停止
1900
+ for(var i1 = 0; i1 < textNodes.length; i1++){
1901
+ var _ret = _loop1(i1);
1902
+ if (_ret === "break") break;
1903
+ }
1904
+ }
1905
+ });
1906
+ return replaceCount;
1477
1907
  }
1478
- }
1479
- if (newText !== originalText) {
1480
- Transforms.insertText(editor, newText, {
1481
- at: path,
1482
- voids: true
1483
- });
1484
- replaceCount += nodeReplaceCount;
1485
- break;
1486
- }
1487
- }
1488
- }
1489
- });
1490
- return replaceCount;
1491
- }
1492
- /**
1908
+ },
1909
+ {
1910
+ /**
1493
1911
  * 在选中的区域内替换文本
1494
1912
  *
1495
1913
  * @param searchText - 要查找和替换的原始文本
@@ -1506,87 +1924,80 @@ var EditorStore = class {
1506
1924
  * // 在选中区域内替换文本
1507
1925
  * const count = store.replaceTextInSelection("old", "new");
1508
1926
  * ```
1509
- */
1510
- replaceTextInSelection(searchText, replaceText, options = {}) {
1511
- const editor = this._editor.current;
1512
- const selection = editor.selection;
1513
- if (!selection || Range.isCollapsed(selection)) {
1514
- return 0;
1515
- }
1516
- const {
1517
- caseSensitive = false,
1518
- wholeWord = false,
1519
- replaceAll = true
1520
- } = options;
1521
- if (!searchText)
1522
- return 0;
1523
- let replaceCount = 0;
1524
- const textNodes = Array.from(
1525
- Editor.nodes(editor, {
1526
- at: selection,
1527
- match: (n) => Text.isText(n) && typeof n.text === "string"
1528
- })
1529
- );
1530
- Editor.withoutNormalizing(editor, () => {
1531
- for (let i = textNodes.length - 1; i >= 0; i--) {
1532
- const [node, path] = textNodes[i];
1533
- const originalText = node.text;
1534
- let newText = originalText;
1535
- let nodeReplaceCount = 0;
1536
- if (caseSensitive) {
1537
- if (wholeWord) {
1538
- const regex = new RegExp(
1539
- `\\b${this.escapeRegExp(searchText)}\\b`,
1540
- "g"
1541
- );
1542
- newText = originalText.replace(regex, () => {
1543
- nodeReplaceCount++;
1544
- return replaceText;
1545
- });
1546
- } else {
1547
- newText = originalText.replace(
1548
- new RegExp(this.escapeRegExp(searchText), "g"),
1549
- () => {
1550
- nodeReplaceCount++;
1551
- return replaceText;
1552
- }
1553
- );
1554
- }
1555
- } else {
1556
- if (wholeWord) {
1557
- const regex = new RegExp(
1558
- `\\b${this.escapeRegExp(searchText)}\\b`,
1559
- "gi"
1560
- );
1561
- newText = originalText.replace(regex, () => {
1562
- nodeReplaceCount++;
1563
- return replaceText;
1564
- });
1565
- } else {
1566
- newText = originalText.replace(
1567
- new RegExp(this.escapeRegExp(searchText), "gi"),
1568
- () => {
1569
- nodeReplaceCount++;
1570
- return replaceText;
1571
- }
1572
- );
1573
- }
1574
- }
1575
- if (newText !== originalText) {
1576
- Transforms.insertText(editor, newText, {
1577
- at: path,
1578
- voids: true
1579
- });
1580
- replaceCount += nodeReplaceCount;
1581
- if (!replaceAll && nodeReplaceCount > 0) {
1582
- break;
1583
- }
1584
- }
1585
- }
1586
- });
1587
- return replaceCount;
1588
- }
1589
- /**
1927
+ */ key: "replaceTextInSelection",
1928
+ value: function replaceTextInSelection(searchText, replaceText) {
1929
+ var _this = this;
1930
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1931
+ var editor = this._editor.current;
1932
+ var selection = editor.selection;
1933
+ if (!selection || Range.isCollapsed(selection)) {
1934
+ return 0;
1935
+ }
1936
+ var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_replaceAll = options.replaceAll, replaceAll = _options_replaceAll === void 0 ? true : _options_replaceAll;
1937
+ if (!searchText) return 0;
1938
+ var replaceCount = 0;
1939
+ // 获取选中区域的文本节点
1940
+ var textNodes = Array.from(Editor.nodes(editor, {
1941
+ at: selection,
1942
+ match: function(n) {
1943
+ return Text.isText(n) && typeof n.text === 'string';
1944
+ }
1945
+ }));
1946
+ Editor.withoutNormalizing(editor, function() {
1947
+ var _loop = function(i) {
1948
+ var _textNodes_i = _sliced_to_array(textNodes[i], 2), node = _textNodes_i[0], path = _textNodes_i[1];
1949
+ var originalText = node.text;
1950
+ var newText = originalText;
1951
+ var nodeReplaceCount = 0;
1952
+ if (caseSensitive) {
1953
+ if (wholeWord) {
1954
+ var regex = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), 'g');
1955
+ newText = originalText.replace(regex, function() {
1956
+ nodeReplaceCount++;
1957
+ return replaceText;
1958
+ });
1959
+ } else {
1960
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), 'g'), function() {
1961
+ nodeReplaceCount++;
1962
+ return replaceText;
1963
+ });
1964
+ }
1965
+ } else {
1966
+ if (wholeWord) {
1967
+ var regex1 = new RegExp("\\b".concat(_this.escapeRegExp(searchText), "\\b"), 'gi');
1968
+ newText = originalText.replace(regex1, function() {
1969
+ nodeReplaceCount++;
1970
+ return replaceText;
1971
+ });
1972
+ } else {
1973
+ newText = originalText.replace(new RegExp(_this.escapeRegExp(searchText), 'gi'), function() {
1974
+ nodeReplaceCount++;
1975
+ return replaceText;
1976
+ });
1977
+ }
1978
+ }
1979
+ if (newText !== originalText) {
1980
+ Transforms.insertText(editor, newText, {
1981
+ at: path,
1982
+ voids: true
1983
+ });
1984
+ replaceCount += nodeReplaceCount;
1985
+ if (!replaceAll && nodeReplaceCount > 0) {
1986
+ return "break";
1987
+ }
1988
+ }
1989
+ };
1990
+ // 从后往前处理,避免路径变化影响前面的操作
1991
+ for(var i = textNodes.length - 1; i >= 0; i--){
1992
+ var _ret = _loop(i);
1993
+ if (_ret === "break") break;
1994
+ }
1995
+ });
1996
+ return replaceCount;
1997
+ }
1998
+ },
1999
+ {
2000
+ /**
1590
2001
  * 替换所有匹配的文本(replaceText 的简化版本)
1591
2002
  *
1592
2003
  * @param searchText - 要查找和替换的原始文本
@@ -1603,24 +2014,29 @@ var EditorStore = class {
1603
2014
  * // 区分大小写替换
1604
2015
  * const count = store.replaceAll("Old", "New", true);
1605
2016
  * ```
1606
- */
1607
- replaceAll(searchText, replaceText, caseSensitive = false) {
1608
- return this.replaceText(searchText, replaceText, {
1609
- caseSensitive,
1610
- replaceAll: true
1611
- });
1612
- }
1613
- /**
2017
+ */ key: "replaceAll",
2018
+ value: function replaceAll(searchText, replaceText) {
2019
+ var caseSensitive = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
2020
+ return this.replaceText(searchText, replaceText, {
2021
+ caseSensitive: caseSensitive,
2022
+ replaceAll: true
2023
+ });
2024
+ }
2025
+ },
2026
+ {
2027
+ key: "escapeRegExp",
2028
+ value: /**
1614
2029
  * 转义正则表达式特殊字符
1615
2030
  *
1616
2031
  * @param string - 需要转义的字符串
1617
2032
  * @returns 转义后的字符串
1618
2033
  * @private
1619
- */
1620
- escapeRegExp(string) {
1621
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1622
- }
1623
- /**
2034
+ */ function escapeRegExp(string) {
2035
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2036
+ }
2037
+ },
2038
+ {
2039
+ /**
1624
2040
  * 在编辑器中根据路径描述和文本内容查找并选择匹配位置
1625
2041
  *
1626
2042
  * @param pathDescription - 路径描述,用于限制搜索范围。可以是:
@@ -1635,23 +2051,21 @@ var EditorStore = class {
1635
2051
  * ```ts
1636
2052
  * // 查找所有包含 "focus" 的位置
1637
2053
  * const results = store.findByPathAndText("", "focus");
1638
- */
1639
- findByPathAndText(pathDescription, searchText, options = {}) {
1640
- const {
1641
- caseSensitive = false,
1642
- wholeWord = false,
1643
- maxResults = 50
1644
- } = options;
1645
- if (!searchText.trim())
1646
- return [];
1647
- const editor = this._editor.current;
1648
- return findByPathAndText(editor, pathDescription, searchText, {
1649
- caseSensitive,
1650
- wholeWord,
1651
- maxResults
1652
- });
1653
- }
1654
- /**
2054
+ */ key: "findByPathAndText",
2055
+ value: function findByPathAndText1(pathDescription, searchText) {
2056
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2057
+ var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_maxResults = options.maxResults, maxResults = _options_maxResults === void 0 ? 50 : _options_maxResults;
2058
+ if (!searchText.trim()) return [];
2059
+ var editor = this._editor.current;
2060
+ return findByPathAndText(editor, pathDescription, searchText, {
2061
+ caseSensitive: caseSensitive,
2062
+ wholeWord: wholeWord,
2063
+ maxResults: maxResults
2064
+ });
2065
+ }
2066
+ },
2067
+ {
2068
+ /**
1655
2069
  * 更新编辑器的状态数据
1656
2070
  *
1657
2071
  * @param value - 状态更新器,可以是函数或对象
@@ -1674,19 +2088,35 @@ var EditorStore = class {
1674
2088
  * manual: false
1675
2089
  * });
1676
2090
  * ```
1677
- */
1678
- setState(value) {
1679
- if (value instanceof Function) {
1680
- value(this);
1681
- } else {
1682
- for (let key of Object.keys(value)) {
1683
- this[key] = value[key];
1684
- }
1685
- }
1686
- }
1687
- };
1688
- export {
1689
- EditorStore,
1690
- EditorStoreContext,
1691
- useEditorStore
1692
- };
2091
+ */ key: "setState",
2092
+ value: function setState(value) {
2093
+ if (value instanceof Function) {
2094
+ value(this);
2095
+ } else {
2096
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2097
+ try {
2098
+ for(var _iterator = Object.keys(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2099
+ var key = _step.value;
2100
+ // @ts-ignore
2101
+ this[key] = value[key];
2102
+ }
2103
+ } catch (err) {
2104
+ _didIteratorError = true;
2105
+ _iteratorError = err;
2106
+ } finally{
2107
+ try {
2108
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2109
+ _iterator.return();
2110
+ }
2111
+ } finally{
2112
+ if (_didIteratorError) {
2113
+ throw _iteratorError;
2114
+ }
2115
+ }
2116
+ }
2117
+ }
2118
+ }
2119
+ }
2120
+ ]);
2121
+ return EditorStore;
2122
+ }();