@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,152 +1,321 @@
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 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/utils/editorUtils.ts
22
- import {
23
- Editor,
24
- Element,
25
- Node,
26
- Path,
27
- Point,
28
- Range,
29
- Text,
30
- Transforms
31
- } from "slate";
32
- import { ReactEditor } from "slate-react";
33
- import { getMediaType } from "./dom";
34
- var _EditorUtils = class {
35
- static get p() {
36
- return { type: "paragraph", children: [{ text: "" }] };
37
- }
38
- static hasPath(editor, path) {
39
- return Editor.hasPath(editor, path);
40
- }
41
- static focus(editor) {
42
- try {
43
- ReactEditor.focus(editor);
44
- } catch (e) {
45
- console.error(e);
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);
46
24
  }
47
- }
48
- static blur(editor) {
49
- try {
50
- ReactEditor.blur(editor);
51
- } catch (e) {
52
- console.error(e);
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;
53
41
  }
54
- }
55
- static isPrevious(firstPath, nextPath) {
56
- return Path.equals(Path.parent(firstPath), Path.parent(nextPath)) && Path.compare(firstPath, nextPath) === -1;
57
- }
58
- static isNextPath(firstPath, nextPath) {
59
- return Path.equals(Path.parent(firstPath), Path.parent(nextPath)) && Path.compare(firstPath, nextPath) === 1;
60
- }
61
- static isDirtLeaf(leaf) {
62
- return leaf.bold || leaf.code || leaf.italic || leaf.strikethrough || !!(leaf == null ? void 0 : leaf.url) || leaf.fnd || leaf.fnc || leaf.html || leaf.highColor;
63
- }
64
- static isTop(editor, path) {
65
- const p = Editor.parent(editor, path);
66
- return Editor.isEditor(p[0]);
67
- }
68
- static findPrev(editor, path) {
69
- var _a;
70
- while (path.length) {
71
- if (Path.hasPrevious(path)) {
72
- if (((_a = Node.get(editor, Path.previous(path))) == null ? void 0 : _a.type) === "hr") {
73
- path = Path.previous(path);
74
- } else {
75
- return Path.previous(path);
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;
76
67
  }
77
- } else {
78
- path = Path.parent(path);
79
- }
80
- }
81
- return [];
82
- }
83
- static findMediaInsertPath(editor) {
84
- var _a, _b, _c;
85
- const [cur] = Editor.nodes(editor, {
86
- match: (n) => Element.isElement(n),
87
- mode: "lowest"
88
- });
89
- if (!cur)
90
- return null;
91
- let path = cur[1];
92
- if (((_a = cur == null ? void 0 : cur[0]) == null ? void 0 : _a.type) === "table-cell") {
93
- path = Path.next(Path.parent(Path.parent(cur[1])));
94
- }
95
- if (((_b = cur == null ? void 0 : cur[0]) == null ? void 0 : _b.type) === "head") {
96
- path = Path.next(path);
97
- }
98
- if (((_c = cur == null ? void 0 : cur[0]) == null ? void 0 : _c.type) === "paragraph" && Node.string(cur[0])) {
99
- path = Path.next(cur[1]);
100
68
  }
101
- return path;
102
- }
103
- static findNext(editor, path) {
104
- while (path.length) {
105
- if (Editor.hasPath(editor, Path.next(path))) {
106
- return Path.next(path);
107
- } else {
108
- path = Path.parent(path);
109
- }
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
+ });
110
89
  }
111
- return void 0;
112
- }
113
- static moveNodes(editor, from, to, index = 1) {
114
- let count = 0;
115
- while (Editor.hasPath(editor, from)) {
116
- if (count > 100)
117
- break;
118
- Transforms.moveNodes(editor, {
119
- at: from,
120
- to: [...to, index]
121
- });
122
- index++;
123
- count++;
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);
124
102
  }
125
- }
126
- static moveAfterSpace(editor, path) {
127
- const next = Editor.next(editor, { at: path });
128
- if (!next || !Text.isText(next[0])) {
129
- Transforms.transform(editor, {
130
- type: "insert_node",
131
- path: Path.next(path),
132
- node: { text: "" }
133
- });
134
- Transforms.select(editor, Path.next(path));
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));
135
109
  } else {
136
- Transforms.move(editor, { unit: "offset" });
110
+ ownKeys(Object(source)).forEach(function(key) {
111
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
112
+ });
137
113
  }
138
- }
139
- static moveBeforeSpace(editor, path) {
140
- if (!Path.hasPrevious(path)) {
141
- Transforms.transform(editor, {
142
- type: "insert_node",
143
- path,
144
- node: { text: "" }
145
- });
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
+ }
130
+ import { Editor, Element, Node, Path, Point, Range, Text, Transforms } from "slate";
131
+ import { ReactEditor } from "slate-react";
132
+ import { getMediaType } from "./dom";
133
+ export var EditorUtils = /*#__PURE__*/ function() {
134
+ "use strict";
135
+ function EditorUtils() {
136
+ _class_call_check(this, EditorUtils);
146
137
  }
147
- Transforms.move(editor, { unit: "offset", reverse: true });
148
- }
149
- /**
138
+ _create_class(EditorUtils, null, [
139
+ {
140
+ key: "p",
141
+ get: function get() {
142
+ return {
143
+ type: 'paragraph',
144
+ children: [
145
+ {
146
+ text: ''
147
+ }
148
+ ]
149
+ };
150
+ }
151
+ },
152
+ {
153
+ key: "hasPath",
154
+ value: function hasPath(editor, path) {
155
+ return Editor.hasPath(editor, path);
156
+ }
157
+ },
158
+ {
159
+ key: "focus",
160
+ value: function focus(editor) {
161
+ try {
162
+ ReactEditor.focus(editor);
163
+ } catch (e) {
164
+ console.error(e);
165
+ }
166
+ }
167
+ },
168
+ {
169
+ key: "blur",
170
+ value: function blur(editor) {
171
+ try {
172
+ ReactEditor.blur(editor);
173
+ } catch (e) {
174
+ console.error(e);
175
+ }
176
+ }
177
+ },
178
+ {
179
+ key: "isPrevious",
180
+ value: function isPrevious(firstPath, nextPath) {
181
+ return Path.equals(Path.parent(firstPath), Path.parent(nextPath)) && Path.compare(firstPath, nextPath) === -1;
182
+ }
183
+ },
184
+ {
185
+ key: "isNextPath",
186
+ value: function isNextPath(firstPath, nextPath) {
187
+ return Path.equals(Path.parent(firstPath), Path.parent(nextPath)) && Path.compare(firstPath, nextPath) === 1;
188
+ }
189
+ },
190
+ {
191
+ key: "isDirtLeaf",
192
+ value: function isDirtLeaf(leaf) {
193
+ return leaf.bold || leaf.code || leaf.italic || leaf.strikethrough || !!(leaf === null || leaf === void 0 ? void 0 : leaf.url) || leaf.fnd || leaf.fnc || leaf.html || leaf.highColor;
194
+ }
195
+ },
196
+ {
197
+ key: "isTop",
198
+ value: function isTop(editor, path) {
199
+ var p = Editor.parent(editor, path);
200
+ return Editor.isEditor(p[0]);
201
+ }
202
+ },
203
+ {
204
+ key: "findPrev",
205
+ value: function findPrev(editor, path) {
206
+ while(path.length){
207
+ if (Path.hasPrevious(path)) {
208
+ var _Node_get;
209
+ if (((_Node_get = Node.get(editor, Path.previous(path))) === null || _Node_get === void 0 ? void 0 : _Node_get.type) === 'hr') {
210
+ path = Path.previous(path);
211
+ } else {
212
+ return Path.previous(path);
213
+ }
214
+ } else {
215
+ path = Path.parent(path);
216
+ }
217
+ }
218
+ return [];
219
+ }
220
+ },
221
+ {
222
+ key: "findMediaInsertPath",
223
+ value: function findMediaInsertPath(editor) {
224
+ var _cur_, _cur_1, _cur_2;
225
+ var _Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
226
+ match: function(n) {
227
+ return Element.isElement(n);
228
+ },
229
+ mode: 'lowest'
230
+ }), 1), cur = _Editor_nodes[0];
231
+ if (!cur) return null;
232
+ var path = cur[1];
233
+ if ((cur === null || cur === void 0 ? void 0 : (_cur_ = cur[0]) === null || _cur_ === void 0 ? void 0 : _cur_.type) === 'table-cell') {
234
+ path = Path.next(Path.parent(Path.parent(cur[1])));
235
+ }
236
+ if ((cur === null || cur === void 0 ? void 0 : (_cur_1 = cur[0]) === null || _cur_1 === void 0 ? void 0 : _cur_1.type) === 'head') {
237
+ path = Path.next(path);
238
+ }
239
+ if ((cur === null || cur === void 0 ? void 0 : (_cur_2 = cur[0]) === null || _cur_2 === void 0 ? void 0 : _cur_2.type) === 'paragraph' && Node.string(cur[0])) {
240
+ path = Path.next(cur[1]);
241
+ }
242
+ return path;
243
+ }
244
+ },
245
+ {
246
+ key: "findNext",
247
+ value: function findNext(editor, path) {
248
+ while(path.length){
249
+ if (Editor.hasPath(editor, Path.next(path))) {
250
+ return Path.next(path);
251
+ } else {
252
+ path = Path.parent(path);
253
+ }
254
+ }
255
+ return undefined;
256
+ }
257
+ },
258
+ {
259
+ key: "moveNodes",
260
+ value: function moveNodes(editor, from, to) {
261
+ var index = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
262
+ var count = 0;
263
+ while(Editor.hasPath(editor, from)){
264
+ if (count > 100) break;
265
+ Transforms.moveNodes(editor, {
266
+ at: from,
267
+ to: _to_consumable_array(to).concat([
268
+ index
269
+ ])
270
+ });
271
+ index++;
272
+ count++;
273
+ }
274
+ }
275
+ },
276
+ {
277
+ key: "moveAfterSpace",
278
+ value: function moveAfterSpace(editor, path) {
279
+ var next = Editor.next(editor, {
280
+ at: path
281
+ });
282
+ if (!next || !Text.isText(next[0])) {
283
+ Transforms.transform(editor, {
284
+ type: 'insert_node',
285
+ path: Path.next(path),
286
+ node: {
287
+ text: ''
288
+ }
289
+ });
290
+ Transforms.select(editor, Path.next(path));
291
+ } else {
292
+ Transforms.move(editor, {
293
+ unit: 'offset'
294
+ });
295
+ }
296
+ }
297
+ },
298
+ {
299
+ key: "moveBeforeSpace",
300
+ value: function moveBeforeSpace(editor, path) {
301
+ if (!Path.hasPrevious(path)) {
302
+ Transforms.transform(editor, {
303
+ type: 'insert_node',
304
+ path: path,
305
+ node: {
306
+ text: ''
307
+ }
308
+ });
309
+ }
310
+ Transforms.move(editor, {
311
+ unit: 'offset',
312
+ reverse: true
313
+ });
314
+ }
315
+ },
316
+ {
317
+ key: "clearMarks",
318
+ value: /**
150
319
  * 清除编辑器中选中的文本的所有标记
151
320
  *
152
321
  * @param editor - 编辑器实例
@@ -160,58 +329,67 @@ var _EditorUtils = class {
160
329
  *
161
330
  * 当 split=true 时,会在不同格式的边界处分割文本节点,
162
331
  * 这允许对部分文本应用/移除格式而不影响相邻文本
163
- */
164
- static clearMarks(editor, split = false) {
165
- if (!editor.selection)
166
- return;
167
- Transforms.unsetNodes(editor, _EditorUtils.CLEARABLE_MARKS, {
168
- split,
169
- match: Text.isText
170
- });
171
- const anchorPath = editor.selection.anchor.path;
172
- const parentPath = Path.parent(anchorPath);
173
- try {
174
- let node = Node.get(editor, parentPath);
175
- if (node.type === "paragraph" && Editor.hasPath(editor, Path.parent(parentPath))) {
176
- node = Node.get(editor, Path.parent(parentPath));
177
- }
178
- if (node.type === "list-item") {
179
- Transforms.liftNodes(editor, {
180
- at: Path.parent(anchorPath),
181
- mode: "highest"
182
- });
183
- }
184
- const nodeEntries = Array.from(
185
- Editor.nodes(editor, {
186
- match: (n) => Element.isElement(n),
187
- mode: "highest"
188
- })
189
- );
190
- if (nodeEntries.length > 0) {
191
- const [selectNodes, selectPath] = nodeEntries[0];
192
- if (selectNodes.type === "list") {
193
- Transforms.removeNodes(editor, {
194
- at: selectPath,
195
- voids: true
196
- });
197
- const paragraphNodes = _EditorUtils.listToParagraph(
198
- editor,
199
- selectNodes
200
- );
201
- if (paragraphNodes.length > 0) {
202
- Transforms.insertNodes(editor, paragraphNodes, {
203
- at: editor.selection
204
- });
205
- }
206
- return;
207
- }
208
- }
209
- Transforms.setNodes(editor, { type: "paragraph" }, { at: parentPath });
210
- } catch (error) {
211
- console.error("Error in clearMarks:", error);
212
- }
213
- }
214
- /**
332
+ */ function clearMarks(editor) {
333
+ var split = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
334
+ if (!editor.selection) return;
335
+ // 移除所有格式标记
336
+ Transforms.unsetNodes(editor, EditorUtils.CLEARABLE_MARKS, {
337
+ split: split,
338
+ match: Text.isText
339
+ });
340
+ var anchorPath = editor.selection.anchor.path;
341
+ var parentPath = Path.parent(anchorPath);
342
+ try {
343
+ var node = Node.get(editor, parentPath);
344
+ // 向上查找非段落的父节点
345
+ if (node.type === 'paragraph' && Editor.hasPath(editor, Path.parent(parentPath))) {
346
+ node = Node.get(editor, Path.parent(parentPath));
347
+ }
348
+ // 处理列表项的提升
349
+ if (node.type === 'list-item') {
350
+ Transforms.liftNodes(editor, {
351
+ at: Path.parent(anchorPath),
352
+ mode: 'highest'
353
+ });
354
+ }
355
+ // 查找最高级别的选中元素节点
356
+ var nodeEntries = Array.from(Editor.nodes(editor, {
357
+ match: function(n) {
358
+ return Element.isElement(n);
359
+ },
360
+ mode: 'highest'
361
+ }));
362
+ if (nodeEntries.length > 0) {
363
+ var _nodeEntries_ = _sliced_to_array(nodeEntries[0], 2), selectNodes = _nodeEntries_[0], selectPath = _nodeEntries_[1];
364
+ // 处理列表转段落的特殊情况
365
+ if (selectNodes.type === 'list') {
366
+ Transforms.removeNodes(editor, {
367
+ at: selectPath,
368
+ voids: true
369
+ });
370
+ var paragraphNodes = EditorUtils.listToParagraph(editor, selectNodes);
371
+ if (paragraphNodes.length > 0) {
372
+ Transforms.insertNodes(editor, paragraphNodes, {
373
+ at: editor.selection
374
+ });
375
+ }
376
+ return;
377
+ }
378
+ }
379
+ // 将选中区域转换为段落
380
+ Transforms.setNodes(editor, {
381
+ type: 'paragraph'
382
+ }, {
383
+ at: parentPath
384
+ });
385
+ } catch (error) {
386
+ console.error('Error in clearMarks:', error);
387
+ }
388
+ }
389
+ },
390
+ {
391
+ key: "listToParagraph",
392
+ value: /**
215
393
  * 将列表节点转换为段落节点数组
216
394
  *
217
395
  * @param editor - 编辑器实例
@@ -221,840 +399,1125 @@ var _EditorUtils = class {
221
399
  * @description
222
400
  * 该方法通过递归遍历列表节点及其子节点,提取所有段落节点,
223
401
  * 并将它们汇集成一个扁平化的数组。支持嵌套列表的处理。
224
- */
225
- static listToParagraph(editor, listNode) {
226
- if (!listNode.children || listNode.children.length === 0) {
227
- return [];
228
- }
229
- const paragraphNodes = [];
230
- const extractParagraphs = (children) => {
231
- children.forEach((item) => {
232
- if (!(item == null ? void 0 : item.children))
233
- return;
234
- item.children.forEach((child) => {
235
- if (child.type === "paragraph") {
236
- paragraphNodes.push(child);
237
- } else if (child.type === "list") {
238
- const nestedParagraphs = _EditorUtils.listToParagraph(editor, child);
239
- paragraphNodes.push(...nestedParagraphs);
240
- }
241
- });
242
- });
243
- };
244
- extractParagraphs(listNode.children);
245
- return paragraphNodes.flat();
246
- }
247
- /**
402
+ */ function listToParagraph(editor, listNode) {
403
+ if (!listNode.children || listNode.children.length === 0) {
404
+ return [];
405
+ }
406
+ var paragraphNodes = [];
407
+ var extractParagraphs = function(children) {
408
+ children.forEach(function(item) {
409
+ if (!(item === null || item === void 0 ? void 0 : item.children)) return;
410
+ item.children.forEach(function(child) {
411
+ if (child.type === 'paragraph') {
412
+ paragraphNodes.push(child);
413
+ } else if (child.type === 'list') {
414
+ var _paragraphNodes;
415
+ // 递归处理嵌套列表
416
+ var nestedParagraphs = EditorUtils.listToParagraph(editor, child);
417
+ (_paragraphNodes = paragraphNodes).push.apply(_paragraphNodes, _to_consumable_array(nestedParagraphs));
418
+ }
419
+ });
420
+ });
421
+ };
422
+ extractParagraphs(listNode.children);
423
+ return paragraphNodes.flat();
424
+ }
425
+ },
426
+ {
427
+ key: "deleteAll",
428
+ value: /**
248
429
  * 删除编辑器中的所有内容,并插入新的节点
249
430
  *
250
431
  * @param editor - 编辑器实例
251
432
  * @param insertNodes - 要插入的新节点数组。如果未提供,将插入默认段落节点
252
- */
253
- static deleteAll(editor, insertNodes) {
254
- const allNodes = Array.from(
255
- Editor.nodes(editor, {
256
- at: [],
257
- match: (n) => Element.isElement(n),
258
- mode: "highest",
259
- reverse: true
260
- })
261
- );
262
- if (allNodes.length > 0) {
263
- const firstNode = allNodes[allNodes.length - 1];
264
- const lastNode = allNodes[0];
265
- Transforms.delete(editor, {
266
- at: {
267
- anchor: Editor.start(editor, firstNode[1]),
268
- focus: Editor.end(editor, lastNode[1])
269
- }
270
- });
271
- if (Editor.hasPath(editor, [0])) {
272
- Transforms.delete(editor, { at: [0] });
273
- }
274
- }
275
- const nodesToInsert = insertNodes || [_EditorUtils.p];
276
- Transforms.insertNodes(editor, nodesToInsert, { at: [0] });
277
- }
278
- /**
433
+ */ function deleteAll(editor, insertNodes) {
434
+ var allNodes = Array.from(Editor.nodes(editor, {
435
+ at: [],
436
+ match: function(n) {
437
+ return Element.isElement(n);
438
+ },
439
+ mode: 'highest',
440
+ reverse: true
441
+ }));
442
+ if (allNodes.length > 0) {
443
+ var firstNode = allNodes[allNodes.length - 1];
444
+ var lastNode = allNodes[0];
445
+ Transforms.delete(editor, {
446
+ at: {
447
+ anchor: Editor.start(editor, firstNode[1]),
448
+ focus: Editor.end(editor, lastNode[1])
449
+ }
450
+ });
451
+ // 删除剩余的第一个节点
452
+ if (Editor.hasPath(editor, [
453
+ 0
454
+ ])) {
455
+ Transforms.delete(editor, {
456
+ at: [
457
+ 0
458
+ ]
459
+ });
460
+ }
461
+ }
462
+ var nodesToInsert = insertNodes || [
463
+ EditorUtils.p
464
+ ];
465
+ Transforms.insertNodes(editor, nodesToInsert, {
466
+ at: [
467
+ 0
468
+ ]
469
+ });
470
+ }
471
+ },
472
+ {
473
+ key: "reset",
474
+ value: /**
279
475
  * 重置编辑器的内容,并可选地插入新的节点和重置历史记录
280
476
  *
281
477
  * @param editor - 要重置的编辑器实例
282
478
  * @param insertNodes - 可选的插入节点数组。如果未提供,则使用默认段落节点
283
479
  * @param force - 可选的布尔值或历史记录对象。如果为布尔值,则强制重置历史记录;如果为历史记录对象,则使用提供的历史记录
284
- */
285
- static reset(editor, insertNodes, force) {
286
- const nodesToInsert = insertNodes || [_EditorUtils.p];
287
- editor.children = JSON.parse(JSON.stringify(nodesToInsert));
288
- if (force) {
289
- editor.history = typeof force === "boolean" ? { redos: [], undos: [] } : force;
290
- }
291
- editor.onChange();
292
- }
293
- /**
480
+ */ function reset(editor, insertNodes, force) {
481
+ var nodesToInsert = insertNodes || [
482
+ EditorUtils.p
483
+ ];
484
+ // 深克隆节点以避免引用问题
485
+ editor.children = JSON.parse(JSON.stringify(nodesToInsert));
486
+ if (force) {
487
+ editor.history = typeof force === 'boolean' ? {
488
+ redos: [],
489
+ undos: []
490
+ } : force;
491
+ }
492
+ editor.onChange();
493
+ }
494
+ },
495
+ {
496
+ key: "includeAll",
497
+ value: /**
294
498
  * 检查选区是否完全包含在指定节点路径中。
295
499
  *
296
500
  * @param editor - 编辑器实例。
297
501
  * @param sel - 选区范围。
298
502
  * @param nodePath - 节点路径。
299
503
  * @returns 如果选区完全包含在节点路径中,则返回 true,否则返回 false。
300
- */
301
- static includeAll(editor, sel, nodePath) {
302
- const [start, end] = Range.edges(sel);
303
- return Point.compare(start, Editor.start(editor, nodePath)) !== 1 && Point.compare(end, Editor.end(editor, nodePath)) !== -1;
304
- }
305
- static copy(data) {
306
- return JSON.parse(JSON.stringify(data));
307
- }
308
- /**
504
+ */ function includeAll(editor, sel, nodePath) {
505
+ var _Range_edges = _sliced_to_array(Range.edges(sel), 2), start = _Range_edges[0], end = _Range_edges[1];
506
+ return Point.compare(start, Editor.start(editor, nodePath)) !== 1 && Point.compare(end, Editor.end(editor, nodePath)) !== -1;
507
+ }
508
+ },
509
+ {
510
+ key: "copy",
511
+ value: function copy(data) {
512
+ return JSON.parse(JSON.stringify(data));
513
+ }
514
+ },
515
+ {
516
+ key: "copyText",
517
+ value: /**
309
518
  * 复制指定范围内的文本内容。
310
519
  *
311
520
  * @param editor - 编辑器实例。
312
521
  * @param start - 文本复制的起始位置。
313
522
  * @param end - (可选)文本复制的结束位置。如果未提供,则复制从起始位置到文档末尾的所有文本。
314
523
  * @returns 返回指定范围内的文本内容。
315
- */
316
- static copyText(editor, start, end) {
317
- var _a, _b;
318
- let leaf = Node.leaf(editor, start.path);
319
- let text = "";
320
- text += ((_a = leaf.text) == null ? void 0 : _a.slice(start.offset)) || "";
321
- let next = Editor.next(editor, { at: start.path });
322
- while (next) {
323
- if (end && Path.equals(next[1], end.path)) {
324
- text += ((_b = next[0].text) == null ? void 0 : _b.slice(0, end.offset)) || "";
325
- break;
326
- } else {
327
- text += next[0].text || "";
328
- next = Editor.next(editor, { at: next[1] });
329
- }
330
- }
331
- return text;
332
- }
333
- /**
524
+ */ function copyText(editor, start, end) {
525
+ var _leaf_text;
526
+ var leaf = Node.leaf(editor, start.path);
527
+ var text = '';
528
+ // Handle first leaf node from start offset
529
+ text += ((_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.slice(start.offset)) || '';
530
+ // Get next nodes until we reach the end point
531
+ var next = Editor.next(editor, {
532
+ at: start.path
533
+ });
534
+ while(next){
535
+ if (end && Path.equals(next[1], end.path)) {
536
+ var _next__text;
537
+ // If we reach the end path, slice until end offset
538
+ text += ((_next__text = next[0].text) === null || _next__text === void 0 ? void 0 : _next__text.slice(0, end.offset)) || '';
539
+ break;
540
+ } else {
541
+ // Add full text content of intermediate nodes
542
+ text += next[0].text || '';
543
+ next = Editor.next(editor, {
544
+ at: next[1]
545
+ });
546
+ }
547
+ }
548
+ return text;
549
+ }
550
+ },
551
+ {
552
+ key: "cutText",
553
+ value: /**
334
554
  * 从编辑器中剪切文本。
335
555
  *
336
556
  * @param editor - 编辑器实例。
337
557
  * @param start - 开始位置的点。
338
558
  * @param end - 结束位置的点(可选)。
339
559
  * @returns 剪切的文本数组,每个元素为一个 CustomLeaf 对象。
340
- */
341
- static cutText(editor, start, end) {
342
- var _a, _b;
343
- let leaf = Node.leaf(editor, start.path);
344
- let texts = [
345
- __spreadProps(__spreadValues({}, leaf), { text: ((_a = leaf.text) == null ? void 0 : _a.slice(start.offset)) || "" })
346
- ];
347
- let next = Editor.next(editor, { at: start.path });
348
- while (next) {
349
- if (end && Path.equals(next[1], end.path)) {
350
- texts.push(__spreadProps(__spreadValues({}, next[0]), {
351
- text: ((_b = next[0].text) == null ? void 0 : _b.slice(0, end.offset)) || ""
352
- }));
353
- break;
354
- } else {
355
- texts.push(next[0]);
356
- next = Editor.next(editor, { at: next[1] });
357
- }
358
- }
359
- return texts;
360
- }
361
- /**
560
+ */ function cutText(editor, start, end) {
561
+ var _leaf_text;
562
+ var leaf = Node.leaf(editor, start.path);
563
+ var texts = [
564
+ _object_spread_props(_object_spread({}, leaf), {
565
+ text: ((_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.slice(start.offset)) || ''
566
+ })
567
+ ];
568
+ var next = Editor.next(editor, {
569
+ at: start.path
570
+ });
571
+ while(next){
572
+ if (end && Path.equals(next[1], end.path)) {
573
+ var _next__text;
574
+ texts.push(_object_spread_props(_object_spread({}, next[0]), {
575
+ text: ((_next__text = next[0].text) === null || _next__text === void 0 ? void 0 : _next__text.slice(0, end.offset)) || ''
576
+ }));
577
+ break;
578
+ } else {
579
+ texts.push(next[0]);
580
+ next = Editor.next(editor, {
581
+ at: next[1]
582
+ });
583
+ }
584
+ }
585
+ return texts;
586
+ }
587
+ },
588
+ {
589
+ key: "isFormatActive",
590
+ value: /**
362
591
  * 检查编辑器中是否有指定格式的活动节点
363
592
  *
364
593
  * @param editor - 编辑器实例
365
594
  * @param format - 要检查的格式名称
366
595
  * @param value - 可选的值,用于进一步验证格式是否匹配
367
596
  * @returns 如果存在匹配的格式节点,则返回 true;否则返回 false
368
- */
369
- static isFormatActive(editor, format, value) {
370
- try {
371
- const nodeEntries = Array.from(
372
- Editor.nodes(editor, {
373
- match: (n) => !!n[format],
374
- mode: "lowest"
375
- })
376
- );
377
- if (nodeEntries.length === 0)
378
- return false;
379
- const [node] = nodeEntries[0];
380
- return value ? node[format] === value : !!node[format];
381
- } catch (error) {
382
- console.error("Error checking format active:", error);
383
- return false;
384
- }
385
- }
386
- /**
597
+ */ function isFormatActive(editor, format, value) {
598
+ try {
599
+ var nodeEntries = Array.from(Editor.nodes(editor, {
600
+ match: function(n) {
601
+ return !!n[format];
602
+ },
603
+ mode: 'lowest'
604
+ }));
605
+ if (nodeEntries.length === 0) return false;
606
+ var _nodeEntries_ = _sliced_to_array(nodeEntries[0], 1), node = _nodeEntries_[0];
607
+ return value ? node[format] === value : !!node[format];
608
+ } catch (error) {
609
+ console.error('Error checking format active:', error);
610
+ return false;
611
+ }
612
+ }
613
+ },
614
+ {
615
+ key: "getUrl",
616
+ value: /**
387
617
  * 获取编辑器中选中文本的URL
388
618
  *
389
619
  * @param editor - 编辑器实例
390
620
  * @returns 返回选中文本的URL,如果没有则返回空字符串
391
- */
392
- static getUrl(editor) {
393
- var _a;
394
- try {
395
- const nodeEntries = Array.from(
396
- Editor.nodes(editor, {
397
- match: (n) => Text.isText(n) && !!(n == null ? void 0 : n.url),
398
- mode: "lowest"
399
- })
400
- );
401
- return nodeEntries.length > 0 ? ((_a = nodeEntries[0][0]) == null ? void 0 : _a.url) || "" : "";
402
- } catch (error) {
403
- console.error("Error getting URL:", error);
404
- return "";
405
- }
406
- }
407
- /**
621
+ */ function getUrl(editor) {
622
+ try {
623
+ var _nodeEntries__;
624
+ var nodeEntries = Array.from(Editor.nodes(editor, {
625
+ match: function(n) {
626
+ return Text.isText(n) && !!(n === null || n === void 0 ? void 0 : n.url);
627
+ },
628
+ mode: 'lowest'
629
+ }));
630
+ return nodeEntries.length > 0 ? ((_nodeEntries__ = nodeEntries[0][0]) === null || _nodeEntries__ === void 0 ? void 0 : _nodeEntries__.url) || '' : '';
631
+ } catch (error) {
632
+ console.error('Error getting URL:', error);
633
+ return '';
634
+ }
635
+ }
636
+ },
637
+ {
638
+ key: "toggleFormat",
639
+ value: /**
408
640
  * 切换文本格式(加粗、斜体等)
409
641
  *
410
642
  * @param editor - 编辑器实例
411
643
  * @param format - 要切换的格式类型
412
- */
413
- static toggleFormat(editor, format) {
414
- if (!editor.selection)
415
- return;
416
- const selectedText = Editor.string(editor, editor.selection);
417
- if (!selectedText)
418
- return;
419
- const isActive = _EditorUtils.isFormatActive(editor, format);
420
- Transforms.setNodes(
421
- editor,
422
- { [format]: isActive ? null : true },
423
- { match: Text.isText, split: true }
424
- );
425
- }
426
- /**
644
+ */ function toggleFormat(editor, format) {
645
+ if (!editor.selection) return;
646
+ var selectedText = Editor.string(editor, editor.selection);
647
+ if (!selectedText) return;
648
+ var isActive = EditorUtils.isFormatActive(editor, format);
649
+ Transforms.setNodes(editor, _define_property({}, format, isActive ? null : true), {
650
+ match: Text.isText,
651
+ split: true
652
+ });
653
+ }
654
+ },
655
+ {
656
+ key: "highColor",
657
+ value: /**
427
658
  * 为编辑器中的文本节点设置高亮颜色
428
659
  *
429
660
  * @param editor - 编辑器实例
430
661
  * @param color - 可选的高亮颜色字符串。如果未提供,则移除高亮颜色
431
- */
432
- static highColor(editor, color) {
433
- if (!editor.selection)
434
- return;
435
- Transforms.setNodes(
436
- editor,
437
- { highColor: color },
438
- { match: Text.isText, split: true }
439
- );
440
- }
441
- /**
662
+ */ function highColor(editor, color) {
663
+ if (!editor.selection) return;
664
+ Transforms.setNodes(editor, {
665
+ highColor: color
666
+ }, {
667
+ match: Text.isText,
668
+ split: true
669
+ });
670
+ }
671
+ },
672
+ {
673
+ key: "setAlignment",
674
+ value: /**
442
675
  * 设置文本对齐方式
443
676
  *
444
677
  * @param editor - 编辑器实例
445
678
  * @param alignment - 对齐方式:'left', 'center', 或 'right'
446
- */
447
- static setAlignment(editor, alignment) {
448
- if (!editor.selection)
449
- return;
450
- Transforms.setNodes(
451
- editor,
452
- { align: alignment },
453
- { match: (n) => Element.isElement(n) && !Editor.isEditor(n) }
454
- );
455
- }
456
- /**
679
+ */ function setAlignment(editor, alignment) {
680
+ if (!editor.selection) return;
681
+ Transforms.setNodes(editor, {
682
+ align: alignment
683
+ }, {
684
+ match: function(n) {
685
+ return Element.isElement(n) && !Editor.isEditor(n);
686
+ }
687
+ });
688
+ }
689
+ },
690
+ {
691
+ key: "isAlignmentActive",
692
+ value: /**
457
693
  * 检查当前选中块的对齐方式
458
694
  *
459
695
  * @param editor - 编辑器实例
460
696
  * @param alignment - 要检查的对齐方式
461
697
  * @returns 是否处于指定的对齐方式
462
- */
463
- static isAlignmentActive(editor, alignment) {
464
- try {
465
- const nodeEntries = Array.from(
466
- Editor.nodes(editor, {
467
- match: (n) => Element.isElement(n) && n.align === alignment
468
- })
469
- );
470
- return nodeEntries.length > 0;
471
- } catch (error) {
472
- console.error("Error checking alignment active:", error);
473
- return false;
474
- }
475
- }
476
- /**
698
+ */ function isAlignmentActive(editor, alignment) {
699
+ try {
700
+ var nodeEntries = Array.from(Editor.nodes(editor, {
701
+ match: function(n) {
702
+ return Element.isElement(n) && n.align === alignment;
703
+ }
704
+ }));
705
+ return nodeEntries.length > 0;
706
+ } catch (error) {
707
+ console.error('Error checking alignment active:', error);
708
+ return false;
709
+ }
710
+ }
711
+ },
712
+ {
713
+ key: "checkEnd",
714
+ value: /**
477
715
  * 检查编辑器末尾是否需要添加段落节点
478
716
  *
479
717
  * @param editor - 编辑器实例
480
718
  * @returns 如果添加了段落节点则返回 true,否则返回 false
481
- */
482
- static checkEnd(editor) {
483
- var _a, _b;
484
- try {
485
- const nodeEntries = Array.from(
486
- Editor.nodes(editor, {
487
- at: [],
488
- mode: "highest",
489
- match: (n) => Element.isElement(n),
490
- reverse: true
491
- })
492
- );
493
- if (nodeEntries.length === 0)
494
- return false;
495
- const [node, path] = nodeEntries[0];
496
- const nodeString = Node.string(node);
497
- const hasMediaChild = ((_a = node == null ? void 0 : node.children) == null ? void 0 : _a.length) === 1 && ((_b = node == null ? void 0 : node.children[0]) == null ? void 0 : _b.type) === "media";
498
- if ((node == null ? void 0 : node.type) !== "paragraph" || nodeString || hasMediaChild) {
499
- Transforms.insertNodes(editor, _EditorUtils.p, {
500
- at: Path.next(path)
501
- });
502
- return true;
503
- }
504
- return false;
505
- } catch (error) {
506
- console.error("Error in checkEnd:", error);
507
- return false;
508
- }
509
- }
510
- /**
719
+ */ function checkEnd(editor) {
720
+ try {
721
+ var _node_children, _node_children_;
722
+ var nodeEntries = Array.from(Editor.nodes(editor, {
723
+ at: [],
724
+ mode: 'highest',
725
+ match: function(n) {
726
+ return Element.isElement(n);
727
+ },
728
+ reverse: true
729
+ }));
730
+ if (nodeEntries.length === 0) return false;
731
+ var _nodeEntries_ = _sliced_to_array(nodeEntries[0], 2), node = _nodeEntries_[0], path = _nodeEntries_[1];
732
+ var nodeString = Node.string(node);
733
+ var hasMediaChild = (node === null || node === void 0 ? void 0 : (_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.length) === 1 && (node === null || node === void 0 ? void 0 : (_node_children_ = node.children[0]) === null || _node_children_ === void 0 ? void 0 : _node_children_.type) === 'media';
734
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'paragraph' || nodeString || hasMediaChild) {
735
+ Transforms.insertNodes(editor, EditorUtils.p, {
736
+ at: Path.next(path)
737
+ });
738
+ return true;
739
+ }
740
+ return false;
741
+ } catch (error) {
742
+ console.error('Error in checkEnd:', error);
743
+ return false;
744
+ }
745
+ }
746
+ },
747
+ {
748
+ key: "checkSelEnd",
749
+ value: /**
511
750
  * 检查指定路径是否在编辑器末尾
512
751
  *
513
752
  * @param editor - 编辑器实例
514
753
  * @param path - 要检查的路径
515
754
  * @returns 如果路径在末尾则返回 true,否则返回 false
516
- */
517
- static checkSelEnd(editor, path) {
518
- try {
519
- let currentNode = Editor.node(editor, path);
520
- while (!Editor.isEditor(currentNode[0])) {
521
- if (Editor.hasPath(editor, Path.next(currentNode[1]))) {
522
- return false;
523
- }
524
- currentNode = Editor.node(editor, Path.parent(currentNode[1]));
525
- }
526
- return true;
527
- } catch (error) {
528
- console.error("Error in checkSelEnd:", error);
529
- return false;
530
- }
531
- }
532
- /**
755
+ */ function checkSelEnd(editor, path) {
756
+ try {
757
+ var currentNode = Editor.node(editor, path);
758
+ while(!Editor.isEditor(currentNode[0])){
759
+ if (Editor.hasPath(editor, Path.next(currentNode[1]))) {
760
+ return false;
761
+ }
762
+ currentNode = Editor.node(editor, Path.parent(currentNode[1]));
763
+ }
764
+ return true;
765
+ } catch (error) {
766
+ console.error('Error in checkSelEnd:', error);
767
+ return false;
768
+ }
769
+ }
770
+ },
771
+ {
772
+ key: "findPath",
773
+ value: /**
533
774
  * 安全地查找元素对应的Slate路径
534
775
  *
535
776
  * @param editor - 编辑器实例
536
777
  * @param el - DOM元素
537
778
  * @returns 元素对应的路径,如果查找失败则返回编辑器起始路径
538
- */
539
- static findPath(editor, el) {
540
- try {
541
- return ReactEditor.findPath(editor, el);
542
- } catch (error) {
543
- console.error("find path error", error);
544
- return Editor.start(editor, []).path;
545
- }
546
- }
547
- /**
779
+ */ function findPath(editor, el) {
780
+ try {
781
+ return ReactEditor.findPath(editor, el);
782
+ } catch (error) {
783
+ console.error('find path error', error);
784
+ return Editor.start(editor, []).path;
785
+ }
786
+ }
787
+ },
788
+ {
789
+ key: "createMediaNode",
790
+ value: /**
548
791
  * 创建媒体节点(图片、视频等)
549
792
  *
550
793
  * @param src - 媒体资源URL
551
794
  * @param type - 媒体类型
552
795
  * @param extraPros - 额外属性
553
796
  * @returns 创建的媒体节点
554
- */
555
- static createMediaNode(src, type, extraPros) {
556
- if (!src) {
557
- return { text: "" };
558
- }
559
- try {
560
- const fullSrc = _EditorUtils.normalizeUrl(src);
561
- const urlParams = _EditorUtils.parseUrlParams(fullSrc);
562
- const altText = (extraPros == null ? void 0 : extraPros.alt) || urlParams.get("alt") || "";
563
- if (type === "image" && _EditorUtils.isImageType(src, (extraPros == null ? void 0 : extraPros.alt) || type)) {
564
- return _EditorUtils.createImageNode(src, altText, urlParams, extraPros);
565
- }
566
- return _EditorUtils.createGenericMediaNode(src, type, extraPros);
567
- } catch (error) {
568
- console.error("Error creating media node:", error, src);
569
- return _EditorUtils.createGenericMediaNode(src, type, extraPros);
570
- }
571
- }
572
- /**
797
+ */ function createMediaNode(src, type, extraPros) {
798
+ if (!src) {
799
+ return {
800
+ text: ''
801
+ };
802
+ }
803
+ try {
804
+ var fullSrc = EditorUtils.normalizeUrl(src);
805
+ var urlParams = EditorUtils.parseUrlParams(fullSrc);
806
+ var altText = (extraPros === null || extraPros === void 0 ? void 0 : extraPros.alt) || urlParams.get('alt') || '';
807
+ if (type === 'image' && EditorUtils.isImageType(src, (extraPros === null || extraPros === void 0 ? void 0 : extraPros.alt) || type)) {
808
+ return EditorUtils.createImageNode(src, altText, urlParams, extraPros);
809
+ }
810
+ return EditorUtils.createGenericMediaNode(src, type, extraPros);
811
+ } catch (error) {
812
+ console.error('Error creating media node:', error, src);
813
+ return EditorUtils.createGenericMediaNode(src, type, extraPros);
814
+ }
815
+ }
816
+ },
817
+ {
818
+ key: "normalizeUrl",
819
+ value: /**
573
820
  * 标准化URL,添加协议前缀
574
- */
575
- static normalizeUrl(src) {
576
- if (src.match(/^(https?:\/\/|data:|file:)/)) {
577
- return src;
578
- }
579
- const origin = window.location.origin || "";
580
- return src.startsWith("/") ? `${origin}${src}` : `${origin}/${src}`;
581
- }
582
- /**
821
+ */ function normalizeUrl(src) {
822
+ if (src.match(/^(https?:\/\/|data:|file:)/)) {
823
+ return src;
824
+ }
825
+ var origin = window.location.origin || '';
826
+ return src.startsWith('/') ? "".concat(origin).concat(src) : "".concat(origin, "/").concat(src);
827
+ }
828
+ },
829
+ {
830
+ key: "parseUrlParams",
831
+ value: /**
583
832
  * 解析URL参数
584
- */
585
- static parseUrlParams(url) {
586
- try {
587
- return new URL(url).searchParams;
588
- } catch (e) {
589
- return new URLSearchParams();
590
- }
591
- }
592
- /**
833
+ */ function parseUrlParams(url) {
834
+ try {
835
+ return new URL(url).searchParams;
836
+ } catch (e) {
837
+ return new URLSearchParams();
838
+ }
839
+ }
840
+ },
841
+ {
842
+ key: "isImageType",
843
+ value: /**
593
844
  * 检查是否为图片类型
594
- */
595
- static isImageType(src, alt) {
596
- return ["image"].includes(getMediaType(src, alt));
597
- }
598
- /**
599
- * 创建图片节点
600
- */
601
- static createImageNode(src, altText, urlParams, extraPros) {
602
- return {
603
- type: "card",
604
- block: urlParams.get("block") || false,
605
- children: [
845
+ */ function isImageType(src, alt) {
846
+ return [
847
+ 'image'
848
+ ].includes(getMediaType(src, alt));
849
+ }
850
+ },
606
851
  {
607
- type: "card-before",
608
- children: [{ text: "" }]
852
+ key: "createImageNode",
853
+ value: /**
854
+ * 创建图片节点
855
+ */ function createImageNode(src, altText, urlParams, extraPros) {
856
+ return {
857
+ type: 'card',
858
+ block: urlParams.get('block') || false,
859
+ children: [
860
+ {
861
+ type: 'card-before',
862
+ children: [
863
+ {
864
+ text: ''
865
+ }
866
+ ]
867
+ },
868
+ _object_spread_props(_object_spread({}, extraPros || {}), {
869
+ block: urlParams.get('block') || false,
870
+ type: 'image',
871
+ url: src,
872
+ mediaType: 'image',
873
+ alt: altText,
874
+ width: urlParams.get('width') || undefined,
875
+ height: urlParams.get('height') || undefined,
876
+ children: [
877
+ {
878
+ text: ''
879
+ }
880
+ ]
881
+ }),
882
+ {
883
+ type: 'card-after',
884
+ children: [
885
+ {
886
+ text: ''
887
+ }
888
+ ]
889
+ }
890
+ ]
891
+ };
892
+ }
609
893
  },
610
- __spreadProps(__spreadValues({}, extraPros || {}), {
611
- block: urlParams.get("block") || false,
612
- type: "image",
613
- url: src,
614
- mediaType: "image",
615
- alt: altText,
616
- width: urlParams.get("width") || void 0,
617
- height: urlParams.get("height") || void 0,
618
- children: [{ text: "" }]
619
- }),
620
894
  {
621
- type: "card-after",
622
- children: [{ text: "" }]
623
- }
624
- ]
625
- };
626
- }
627
- /**
895
+ key: "createGenericMediaNode",
896
+ value: /**
628
897
  * 创建通用媒体节点
629
- */
630
- static createGenericMediaNode(src, type, extraPros) {
631
- return {
632
- type: "card",
633
- children: [
634
- {
635
- type: "card-before",
636
- children: [{ text: "" }]
898
+ */ function createGenericMediaNode(src, type, extraPros) {
899
+ return {
900
+ type: 'card',
901
+ children: [
902
+ {
903
+ type: 'card-before',
904
+ children: [
905
+ {
906
+ text: ''
907
+ }
908
+ ]
909
+ },
910
+ _object_spread_props(_object_spread({}, extraPros || {}), {
911
+ type: 'media',
912
+ url: src,
913
+ children: [
914
+ {
915
+ text: ''
916
+ }
917
+ ],
918
+ mediaType: type
919
+ }),
920
+ {
921
+ type: 'card-after',
922
+ children: [
923
+ {
924
+ text: ''
925
+ }
926
+ ]
927
+ }
928
+ ]
929
+ };
930
+ }
637
931
  },
638
- __spreadProps(__spreadValues({}, extraPros || {}), {
639
- type: "media",
640
- url: src,
641
- children: [{ text: "" }],
642
- mediaType: type
643
- }),
644
932
  {
645
- type: "card-after",
646
- children: [{ text: "" }]
647
- }
648
- ]
649
- };
650
- }
651
- /**
933
+ key: "wrapperCardNode",
934
+ value: /**
652
935
  * 用卡片节点包装普通节点
653
936
  *
654
937
  * @param node - 要包装的节点
655
938
  * @param props - 额外属性
656
939
  * @returns 包装后的卡片节点
657
- */
658
- static wrapperCardNode(node, props = {}) {
659
- return __spreadProps(__spreadValues({
660
- type: "card"
661
- }, props), {
662
- children: [
663
- {
664
- type: "card-before",
665
- children: [{ text: "" }]
666
- },
667
- node,
668
- {
669
- type: "card-after",
670
- children: [{ text: "" }]
940
+ */ function wrapperCardNode(node) {
941
+ var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
942
+ return _object_spread_props(_object_spread({
943
+ type: 'card'
944
+ }, props), {
945
+ children: [
946
+ {
947
+ type: 'card-before',
948
+ children: [
949
+ {
950
+ text: ''
951
+ }
952
+ ]
953
+ },
954
+ node,
955
+ {
956
+ type: 'card-after',
957
+ children: [
958
+ {
959
+ text: ''
960
+ }
961
+ ]
962
+ }
963
+ ]
964
+ });
965
+ }
671
966
  }
672
- ]
673
- });
674
- }
675
- };
676
- var EditorUtils = _EditorUtils;
967
+ ]);
968
+ return EditorUtils;
969
+ }();
677
970
  // 可清除的文本格式属性
678
- EditorUtils.CLEARABLE_MARKS = [
679
- "url",
680
- "strikethrough",
681
- "italic",
682
- "code",
683
- "bold",
684
- "color",
685
- "textColor",
686
- "highColor"
687
- ];
971
+ _define_property(EditorUtils, "CLEARABLE_MARKS", [
972
+ 'url',
973
+ 'strikethrough',
974
+ 'italic',
975
+ 'code',
976
+ 'bold',
977
+ 'color',
978
+ 'textColor',
979
+ 'highColor'
980
+ ]);
688
981
  /**
689
- * 替换编辑器中当前选中的节点
690
- *
691
- * @param editor - 编辑器实例
692
- * @param newNode - 要插入的新节点数组
693
- *
694
- * @description
695
- * 该方法会查找当前选区中的最低块级节点,然后用新的节点替换它。
696
- * 替换过程包括:查找最低块级节点,选中整个节点,插入新节点来替换原内容。
697
- */
698
- EditorUtils.replaceSelectedNode = (editor, newNode) => {
699
- const nodeEntries = Array.from(
700
- Editor.nodes(editor, {
701
- mode: "lowest"
702
- })
703
- );
704
- if (nodeEntries.length === 0) {
705
- Transforms.insertNodes(editor, newNode);
706
- return;
707
- }
708
- const [node, path] = nodeEntries[0];
709
- if (Text.isText(node) && node.text === "") {
710
- const parentPath = Path.parent(path);
711
- Transforms.removeNodes(editor, { at: parentPath });
712
- Transforms.insertNodes(editor, newNode, {
713
- at: parentPath,
714
- select: true
715
- });
716
- } else {
717
- Transforms.insertNodes(editor, newNode, {
718
- select: true
719
- });
720
- }
721
- };
722
- var getDefaultView = (value) => {
723
- return value && value.ownerDocument && value.ownerDocument.defaultView || null;
982
+ * 替换编辑器中当前选中的节点
983
+ *
984
+ * @param editor - 编辑器实例
985
+ * @param newNode - 要插入的新节点数组
986
+ *
987
+ * @description
988
+ * 该方法会查找当前选区中的最低块级节点,然后用新的节点替换它。
989
+ * 替换过程包括:查找最低块级节点,选中整个节点,插入新节点来替换原内容。
990
+ */ _define_property(EditorUtils, "replaceSelectedNode", function(editor, newNode) {
991
+ var nodeEntries = Array.from(Editor.nodes(editor, {
992
+ mode: 'lowest'
993
+ }));
994
+ if (nodeEntries.length === 0) {
995
+ // 如果没有选中节点,则直接插入新节点
996
+ Transforms.insertNodes(editor, newNode);
997
+ return;
998
+ }
999
+ var _nodeEntries_ = _sliced_to_array(nodeEntries[0], 2), node = _nodeEntries_[0], path = _nodeEntries_[1];
1000
+ if (Text.isText(node) && node.text === '') {
1001
+ // 如果是空文本节点,则操作其父节点
1002
+ var parentPath = Path.parent(path);
1003
+ Transforms.removeNodes(editor, {
1004
+ at: parentPath
1005
+ });
1006
+ Transforms.insertNodes(editor, newNode, {
1007
+ at: parentPath,
1008
+ select: true
1009
+ });
1010
+ } else {
1011
+ // 直接插入新节点
1012
+ Transforms.insertNodes(editor, newNode, {
1013
+ select: true
1014
+ });
1015
+ }
1016
+ });
1017
+ export var getDefaultView = function(value) {
1018
+ return value && value.ownerDocument && value.ownerDocument.defaultView || null;
724
1019
  };
725
- var isDOMNode = (value) => {
726
- const window2 = getDefaultView(value);
727
- return !!window2 && value instanceof window2.Node;
1020
+ export var isDOMNode = function(value) {
1021
+ var window1 = getDefaultView(value);
1022
+ return !!window1 && value instanceof window1.Node;
728
1023
  };
729
- var isEventHandled = (event, handler) => {
730
- if (!handler) {
731
- return false;
732
- }
733
- handler(event);
734
- return event.isDefaultPrevented() || event.isPropagationStopped();
1024
+ export var isEventHandled = function(event, handler) {
1025
+ if (!handler) {
1026
+ return false;
1027
+ }
1028
+ handler(event);
1029
+ return event.isDefaultPrevented() || event.isPropagationStopped();
735
1030
  };
736
- var hasTarget = (editor, target) => {
737
- return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target);
1031
+ export var hasTarget = function(editor, target) {
1032
+ return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target);
738
1033
  };
739
1034
  function checkText(domPoint) {
740
- var _a;
741
- if (!isDOMNode(domPoint)) {
742
- return false;
743
- }
744
- let leafNode = (_a = domPoint == null ? void 0 : domPoint.parentElement) == null ? void 0 : _a.closest("[data-slate-leaf]");
745
- if (!leafNode) {
746
- return false;
747
- }
748
- const textNode = leafNode.closest('[data-slate-node="text"]');
749
- return !!textNode;
1035
+ var _domPoint_parentElement;
1036
+ if (!isDOMNode(domPoint)) {
1037
+ return false;
1038
+ }
1039
+ var leafNode = domPoint === null || domPoint === void 0 ? void 0 : (_domPoint_parentElement = domPoint.parentElement) === null || _domPoint_parentElement === void 0 ? void 0 : _domPoint_parentElement.closest('[data-slate-leaf]');
1040
+ if (!leafNode) {
1041
+ return false;
1042
+ }
1043
+ var textNode = leafNode.closest('[data-slate-node="text"]');
1044
+ return !!textNode;
750
1045
  }
751
- var isTargetInsideVoid = (editor, target) => {
752
- const slateNode = hasTarget(editor, target) && ReactEditor.toSlateNode(editor, target);
753
- return Editor.isVoid(editor, slateNode);
1046
+ export var isTargetInsideVoid = function(editor, target) {
1047
+ var slateNode = hasTarget(editor, target) && ReactEditor.toSlateNode(editor, target);
1048
+ // @ts-ignore
1049
+ return Editor.isVoid(editor, slateNode);
754
1050
  };
755
- function createSelectionFromNodes(anchorNode, anchorOffset, focusNode, focusOffset) {
756
- if (typeof window === "undefined") {
757
- return null;
758
- }
759
- if (!anchorNode || !focusNode) {
760
- return null;
761
- }
762
- try {
763
- const selection = window.getSelection();
764
- if (!selection) {
765
- return null;
1051
+ /**
1052
+ * 基于 anchorNode focusNode 创建新的 DOM Selection 对象
1053
+ *
1054
+ * @param anchorNode - 选区起始节点
1055
+ * @param anchorOffset - 起始节点中的偏移量
1056
+ * @param focusNode - 选区结束节点
1057
+ * @param focusOffset - 结束节点中的偏移量
1058
+ * @returns 新创建的 Selection 对象,如果创建失败则返回 null
1059
+ */ export function createSelectionFromNodes(anchorNode, anchorOffset, focusNode, focusOffset) {
1060
+ if (typeof window === 'undefined') {
1061
+ return null;
1062
+ }
1063
+ if (!anchorNode || !focusNode) {
1064
+ return null;
1065
+ }
1066
+ try {
1067
+ var selection = window.getSelection();
1068
+ if (!selection) {
1069
+ return null;
1070
+ }
1071
+ // 清除当前选区
1072
+ selection.removeAllRanges();
1073
+ // 使用 setBaseAndExtent 方法创建新的选区
1074
+ selection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
1075
+ return selection;
1076
+ } catch (error) {
1077
+ console.error('创建 Selection 对象失败:', error);
1078
+ return null;
766
1079
  }
767
- selection.removeAllRanges();
768
- selection.setBaseAndExtent(
769
- anchorNode,
770
- anchorOffset,
771
- focusNode,
772
- focusOffset
773
- );
774
- return selection;
775
- } catch (error) {
776
- console.error("创建 Selection 对象失败:", error);
777
- return null;
778
- }
779
- }
780
- function createDomRangeFromNodes(anchorNode, anchorOffset, focusNode, focusOffset) {
781
- if (typeof window === "undefined") {
782
- return null;
783
- }
784
- if (!anchorNode || !focusNode) {
785
- return null;
786
- }
787
- try {
788
- const range = document.createRange();
789
- range.setStart(anchorNode, anchorOffset);
790
- range.setEnd(focusNode, focusOffset);
791
- return range;
792
- } catch (error) {
793
- console.error("创建 DOM Range 对象失败:", error);
794
- return null;
795
- }
796
1080
  }
797
- function isNodeSelectable(editor, node) {
798
- if (!node)
799
- return false;
800
- return hasTarget(editor, node) || isTargetInsideVoid(editor, node);
1081
+ /**
1082
+ * 基于 anchorNode 和 focusNode 创建 DOM Range 对象
1083
+ *
1084
+ * @param anchorNode - 选区起始节点
1085
+ * @param anchorOffset - 起始节点中的偏移量
1086
+ * @param focusNode - 选区结束节点
1087
+ * @param focusOffset - 结束节点中的偏移量
1088
+ * @returns 新创建的 DOM Range 对象,如果创建失败则返回 null
1089
+ */ export function createDomRangeFromNodes(anchorNode, anchorOffset, focusNode, focusOffset) {
1090
+ if (typeof window === 'undefined') {
1091
+ return null;
1092
+ }
1093
+ if (!anchorNode || !focusNode) {
1094
+ return null;
1095
+ }
1096
+ try {
1097
+ var range = document.createRange();
1098
+ range.setStart(anchorNode, anchorOffset);
1099
+ range.setEnd(focusNode, focusOffset);
1100
+ return range;
1101
+ } catch (error) {
1102
+ console.error('创建 DOM Range 对象失败:', error);
1103
+ return null;
1104
+ }
801
1105
  }
802
- function createAndConvertRange(editor, anchorNode, focusNode, originalRange) {
803
- try {
804
- const domRange = document.createRange();
805
- domRange.setStart(anchorNode, originalRange.startOffset);
806
- domRange.setEnd(focusNode, originalRange.endOffset);
807
- return ReactEditor.toSlateRange(editor, domRange, {
808
- exactMatch: true,
809
- suppressThrow: false
810
- });
811
- } catch (error) {
812
- console.error("创建并转换 Range 失败:", error);
813
- return null;
814
- }
1106
+ /**
1107
+ * 检查节点是否可选择
1108
+ *
1109
+ * @param editor - React 编辑器实例
1110
+ * @param node - 待检查的节点
1111
+ * @returns 节点是否可选择
1112
+ */ function isNodeSelectable(editor, node) {
1113
+ if (!node) return false;
1114
+ return hasTarget(editor, node) || isTargetInsideVoid(editor, node);
815
1115
  }
816
- function getSelectionFromDomSelection(editor, domSelection) {
817
- if (!domSelection.rangeCount || domSelection.rangeCount === 0) {
818
- return null;
819
- }
820
- try {
821
- const range = domSelection.getRangeAt(0);
822
- if (!range) {
823
- return null;
1116
+ /**
1117
+ * 创建并转换 Range 对象
1118
+ *
1119
+ * @param editor - React 编辑器实例
1120
+ * @param anchorNode - 起始节点
1121
+ * @param focusNode - 结束节点
1122
+ * @param originalRange - 原始 Range 对象
1123
+ * @returns 转换后的 Slate Range
1124
+ */ function createAndConvertRange(editor, anchorNode, focusNode, originalRange) {
1125
+ try {
1126
+ // 创建新的 DOM Range
1127
+ var domRange = document.createRange();
1128
+ // 使用原始 Range 的偏移量,确保精确性
1129
+ domRange.setStart(anchorNode, originalRange.startOffset);
1130
+ domRange.setEnd(focusNode, originalRange.endOffset);
1131
+ // 转换为 Slate Range
1132
+ return ReactEditor.toSlateRange(editor, domRange, {
1133
+ exactMatch: true,
1134
+ suppressThrow: false
1135
+ });
1136
+ } catch (error) {
1137
+ console.error('创建并转换 Range 失败:', error);
1138
+ return null;
824
1139
  }
825
- const anchorNode = range.startContainer;
826
- const focusNode = range.endContainer;
827
- if (!isNodeSelectable(editor, anchorNode) || !isNodeSelectable(editor, focusNode)) {
828
- return null;
1140
+ }
1141
+ /**
1142
+ * DOM Selection 对象中提取并转换为 Slate Range
1143
+ *
1144
+ * @param editor - React 编辑器实例
1145
+ * @param domSelection - DOM Selection 对象
1146
+ * @returns 转换后的 Slate Range 对象,如果转换失败则返回 null
1147
+ */ export function getSelectionFromDomSelection(editor, domSelection) {
1148
+ // 检查 Selection 是否有有效的 Range
1149
+ if (!domSelection.rangeCount || domSelection.rangeCount === 0) {
1150
+ return null;
829
1151
  }
830
- if (!checkText(anchorNode) || !checkText(focusNode)) {
831
- return null;
1152
+ try {
1153
+ var range = domSelection.getRangeAt(0);
1154
+ if (!range) {
1155
+ return null;
1156
+ }
1157
+ // 获取起始和结束容器节点
1158
+ var anchorNode = range.startContainer;
1159
+ var focusNode = range.endContainer;
1160
+ // 验证节点是否可选择
1161
+ if (!isNodeSelectable(editor, anchorNode) || !isNodeSelectable(editor, focusNode)) {
1162
+ return null;
1163
+ }
1164
+ // 验证文本节点
1165
+ if (!checkText(anchorNode) || !checkText(focusNode)) {
1166
+ return null;
1167
+ }
1168
+ // 创建新的 Range 并转换
1169
+ return createAndConvertRange(editor, anchorNode, focusNode, range);
1170
+ } catch (error) {
1171
+ console.error('getSelectionFromDomSelection error:', error);
1172
+ return null;
832
1173
  }
833
- return createAndConvertRange(editor, anchorNode, focusNode, range);
834
- } catch (error) {
835
- console.error("getSelectionFromDomSelection error:", error);
836
- return null;
837
- }
838
1174
  }
839
- var hasEditableTarget = (editor, target) => {
840
- return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target, { editable: true });
1175
+ /**
1176
+ * 检查目标是否为可编辑的 DOM 节点。
1177
+ *
1178
+ * @param editor - React 编辑器实例。
1179
+ * @param target - 事件目标,可能为 null。
1180
+ * @returns 如果目标是可编辑的 DOM 节点,则返回 true。
1181
+ */ export var hasEditableTarget = function(editor, target) {
1182
+ return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target, {
1183
+ editable: true
1184
+ });
841
1185
  };
842
- function getPointStrOffset(editor, point) {
843
- const nodes = Node.fragment(editor, {
844
- anchor: { path: Node.first(editor, point.path)[1], offset: 0 },
845
- focus: point
846
- });
847
- const str = Node.string({
848
- type: "",
849
- children: nodes
850
- });
851
- return str.length;
1186
+ export function getPointStrOffset(editor, point) {
1187
+ var nodes = Node.fragment(editor, {
1188
+ anchor: {
1189
+ path: Node.first(editor, point.path)[1],
1190
+ offset: 0
1191
+ },
1192
+ focus: point
1193
+ });
1194
+ var str = Node.string({
1195
+ type: '',
1196
+ children: nodes
1197
+ });
1198
+ return str.length;
852
1199
  }
853
- function getRelativePath(path, anther) {
854
- const newPath = [...path];
855
- const newAnther = [...anther];
856
- const relativeLen = path.length - anther.length;
857
- if (relativeLen > 0) {
858
- newAnther.unshift(new Array(relativeLen).fill(0));
859
- } else if (relativeLen < 0) {
860
- return new Array(anther.length).fill(0);
861
- newPath.unshift(new Array(-relativeLen).fill(0));
862
- }
863
- const relativePath = [];
864
- for (let i = 0; i < newPath.length; i++) {
865
- if (newPath[i] !== newAnther[i]) {
866
- relativePath.push(newPath[i] - newAnther[i]);
867
- } else {
868
- relativePath.push(0);
1200
+ export function getRelativePath(path, anther) {
1201
+ var newPath = _to_consumable_array(path);
1202
+ var newAnther = _to_consumable_array(anther);
1203
+ var relativeLen = path.length - anther.length;
1204
+ if (relativeLen > 0) {
1205
+ newAnther.unshift(new Array(relativeLen).fill(0));
1206
+ } else if (relativeLen < 0) {
1207
+ return new Array(anther.length).fill(0);
1208
+ newPath.unshift(new Array(-relativeLen).fill(0));
869
1209
  }
870
- }
871
- return relativePath;
1210
+ var relativePath = [];
1211
+ for(var i = 0; i < newPath.length; i++){
1212
+ if (newPath[i] !== newAnther[i]) {
1213
+ relativePath.push(newPath[i] - newAnther[i]);
1214
+ } else {
1215
+ relativePath.push(0);
1216
+ }
1217
+ }
1218
+ return relativePath;
872
1219
  }
873
- function calcPath(path, anther) {
874
- const newPath = [...path];
875
- const newAnther = [...anther];
876
- const relativeLen = path.length - anther.length;
877
- if (relativeLen > 0) {
878
- newAnther.unshift(new Array(relativeLen).fill(0));
879
- } else if (relativeLen < 0) {
880
- newPath.unshift(new Array(-relativeLen).fill(0));
881
- }
882
- const relativePath = [];
883
- for (let i = 0; i < newPath.length; i++) {
884
- relativePath.push(newPath[i] + newAnther[i]);
885
- }
886
- return relativePath;
1220
+ export function calcPath(path, anther) {
1221
+ var newPath = _to_consumable_array(path);
1222
+ var newAnther = _to_consumable_array(anther);
1223
+ var relativeLen = path.length - anther.length;
1224
+ if (relativeLen > 0) {
1225
+ newAnther.unshift(new Array(relativeLen).fill(0));
1226
+ } else if (relativeLen < 0) {
1227
+ newPath.unshift(new Array(-relativeLen).fill(0));
1228
+ }
1229
+ var relativePath = [];
1230
+ for(var i = 0; i < newPath.length; i++){
1231
+ relativePath.push(newPath[i] + newAnther[i]);
1232
+ }
1233
+ return relativePath;
887
1234
  }
888
- function isPath(path) {
889
- for (let i = 0; i < path.length; i++) {
890
- const num = path[i];
891
- if (!(isFinite(num) && num >= 0)) {
892
- return false;
1235
+ export function isPath(path) {
1236
+ for(var i = 0; i < path.length; i++){
1237
+ var num = path[i];
1238
+ if (!(isFinite(num) && num >= 0)) {
1239
+ return false;
1240
+ }
893
1241
  }
894
- }
895
- return true;
1242
+ return true;
896
1243
  }
897
- function findLeafPath(editor, path) {
898
- const node = Editor.leaf(editor, path, {
899
- edge: "end"
900
- });
901
- if (!node)
902
- return path;
903
- return node[1];
1244
+ export function findLeafPath(editor, path) {
1245
+ var node = Editor.leaf(editor, path, {
1246
+ edge: 'end'
1247
+ });
1248
+ if (!node) return path;
1249
+ return node[1];
904
1250
  }
905
- function escapeRegExp(string) {
906
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1251
+ /**
1252
+ * 转义正则表达式特殊字符
1253
+ *
1254
+ * @param string - 需要转义的字符串
1255
+ * @returns 转义后的字符串
1256
+ * @private
1257
+ */ export function escapeRegExp(string) {
1258
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
907
1259
  }
908
- function normalizeMarkdownSearchText(searchText) {
909
- if (!searchText.trim())
910
- return [];
911
- const searchVariants = /* @__PURE__ */ new Set();
912
- searchVariants.add(searchText.trim());
913
- let cleanText = searchText.replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/\*\*(.*?)\*\*/g, "$1").replace(/__(.*?)__/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/_(.*?)_/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/~~(.*?)~~/g, "$1").replace(/^#+\s+(.*)$/gm, "$1").replace(/^>\s*(.*)$/gm, "$1").replace(/^[\s]*[-*+]\s+(.*)$/gm, "$1").replace(/^\s*\d+\.\s+(.*)$/gm, "$1").trim();
914
- if (cleanText && cleanText !== searchText.trim()) {
915
- searchVariants.add(cleanText);
916
- }
917
- const words = cleanText.split(/\s+/).filter((word) => word.length > 1);
918
- if (words.length > 1) {
919
- words.forEach((word) => searchVariants.add(word));
920
- }
921
- return Array.from(searchVariants).filter((text) => text.length > 0);
1260
+ /**
1261
+ * 清理和标准化 Markdown 搜索文本
1262
+ *
1263
+ * @param searchText - 原始搜索文本,可能包含 Markdown 语法
1264
+ * @returns 包含原文本和清理后文本的数组
1265
+ * @public
1266
+ */ export function normalizeMarkdownSearchText(searchText) {
1267
+ if (!searchText.trim()) return [];
1268
+ var searchVariants = new Set();
1269
+ // 添加原始文本
1270
+ searchVariants.add(searchText.trim());
1271
+ // 移除常见的 Markdown 语法
1272
+ var cleanText = searchText// 移除图片语法 ![alt](url) -> alt (必须在链接语法之前处理)
1273
+ .replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')// 移除链接语法 [text](url) -> text
1274
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')// 移除粗体语法 **text** 或 __text__ -> text
1275
+ .replace(/\*\*(.*?)\*\*/g, '$1').replace(/__(.*?)__/g, '$1')// 移除斜体语法 *text* 或 _text_ -> text
1276
+ .replace(/\*(.*?)\*/g, '$1').replace(/_(.*?)_/g, '$1')// 移除行内代码语法 `code` -> code
1277
+ .replace(/`([^`]+)`/g, '$1')// 移除删除线语法 ~~text~~ -> text
1278
+ .replace(/~~(.*?)~~/g, '$1')// 移除标题语法 # text -> text
1279
+ .replace(/^#+\s+(.*)$/gm, '$1')// 移除引用语法 > text -> text
1280
+ .replace(/^>\s*(.*)$/gm, '$1')// 移除列表标记 - text 或 * text 或 + text -> text
1281
+ .replace(/^[\s]*[-*+]\s+(.*)$/gm, '$1')// 移除有序列表标记 1. text -> text
1282
+ .replace(/^\s*\d+\.\s+(.*)$/gm, '$1').trim();
1283
+ if (cleanText && cleanText !== searchText.trim()) {
1284
+ searchVariants.add(cleanText);
1285
+ }
1286
+ // 如果清理后的文本包含多个单词,也添加每个单词
1287
+ var words = cleanText.split(/\s+/).filter(function(word) {
1288
+ return word.length > 1;
1289
+ });
1290
+ if (words.length > 1) {
1291
+ words.forEach(function(word) {
1292
+ return searchVariants.add(word);
1293
+ });
1294
+ }
1295
+ // 移除空字符串
1296
+ return Array.from(searchVariants).filter(function(text) {
1297
+ return text.length > 0;
1298
+ });
922
1299
  }
923
- function findByPathAndText(editor, pathDescription, searchText, options = {}) {
924
- const {
925
- caseSensitive = false,
926
- wholeWord = false,
927
- maxResults = 2,
928
- includeMarkdownVariants = true
929
- } = options;
930
- if (!searchText.trim())
931
- return [];
932
- const results = [];
933
- const searchVariants = includeMarkdownVariants ? normalizeMarkdownSearchText(searchText) : [searchText.trim()];
934
- if (searchVariants.length === 0)
935
- return [];
936
- const flags = caseSensitive ? "g" : "gi";
937
- const patterns = searchVariants.map((variant) => ({
938
- variant,
939
- pattern: wholeWord ? new RegExp(`\\b${escapeRegExp(variant)}\\b`, flags) : new RegExp(escapeRegExp(variant), flags)
940
- }));
941
- try {
942
- let searchRange;
943
- if (pathDescription && pathDescription.length > 0) {
944
- try {
945
- if (Editor.hasPath(editor, pathDescription)) {
946
- searchRange = [pathDescription];
1300
+ /**
1301
+ * 在编辑器中按路径和文本搜索内容,支持 Markdown 文本的智能处理
1302
+ *
1303
+ * @param editor - 编辑器实例
1304
+ * @param pathDescription - 搜索范围的路径描述
1305
+ * @param searchText - 搜索文本,支持 Markdown 语法
1306
+ * @param options - 搜索选项
1307
+ * @param options.caseSensitive - 是否区分大小写,默认 false
1308
+ * @param options.wholeWord - 是否全词匹配,默认 false
1309
+ * @param options.maxResults - 最大结果数量,默认 2
1310
+ * @param options.includeMarkdownVariants - 是否包含 Markdown 语法的清理变体,默认 true
1311
+ * @returns 搜索结果数组,包含路径、范围、节点、链接信息等
1312
+ *
1313
+ * @description
1314
+ * 该函数支持以下功能:
1315
+ * - 自动清理 Markdown 语法(链接、粗体、斜体、代码等)
1316
+ * - 生成多个搜索变体以提高匹配率
1317
+ * - 避免重复匹配同一位置的文本
1318
+ * - 记录匹配的搜索变体信息
1319
+ * - 支持识别链接(a 标签):返回结果包含 isLink 和 linkUrl 字段
1320
+ *
1321
+ * @example
1322
+ * // 搜索包含 Markdown 语法的文本
1323
+ * const results = findByPathAndText(editor, [0], "**粗体文本**");
1324
+ * // 将同时匹配 "**粗体文本**" 和 "粗体文本"
1325
+ *
1326
+ * @example
1327
+ * // 搜索链接文本
1328
+ * const results = findByPathAndText(editor, [0], "点击这里");
1329
+ * // 如果匹配到的是链接,results[0].isLink === true 且 results[0].linkUrl 包含 URL
1330
+ */ export function findByPathAndText(editor, pathDescription, searchText) {
1331
+ var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
1332
+ 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 ? 2 : _options_maxResults, _options_includeMarkdownVariants = options.includeMarkdownVariants, includeMarkdownVariants = _options_includeMarkdownVariants === void 0 ? true : _options_includeMarkdownVariants;
1333
+ if (!searchText.trim()) return [];
1334
+ var results = [];
1335
+ // 获取所有搜索变体
1336
+ var searchVariants = includeMarkdownVariants ? normalizeMarkdownSearchText(searchText) : [
1337
+ searchText.trim()
1338
+ ];
1339
+ if (searchVariants.length === 0) return [];
1340
+ // 为每个搜索变体创建正则表达式
1341
+ var flags = caseSensitive ? 'g' : 'gi';
1342
+ var patterns = searchVariants.map(function(variant) {
1343
+ return {
1344
+ variant: variant,
1345
+ pattern: wholeWord ? new RegExp("\\b".concat(escapeRegExp(variant), "\\b"), flags) : new RegExp(escapeRegExp(variant), flags)
1346
+ };
1347
+ });
1348
+ try {
1349
+ // 根据 pathDescription 确定搜索范围
1350
+ var searchRange;
1351
+ if (pathDescription && pathDescription.length > 0) {
1352
+ // 路径数组模式:直接在指定路径中搜索
1353
+ try {
1354
+ if (Editor.hasPath(editor, pathDescription)) {
1355
+ searchRange = [
1356
+ pathDescription
1357
+ ];
1358
+ }
1359
+ } catch (e) {
1360
+ console.debug('无效的搜索路径:', pathDescription, e);
1361
+ searchRange = undefined;
1362
+ }
947
1363
  }
948
- } catch (e) {
949
- console.debug("无效的搜索路径:", pathDescription, e);
950
- searchRange = void 0;
951
- }
952
- }
953
- let textNodesGenerator;
954
- if (searchRange && searchRange.length > 0) {
955
- const allTextNodes = [];
956
- for (const rangePath of searchRange) {
957
- try {
958
- const rangeNodes = Array.from(
959
- Editor.nodes(editor, {
960
- at: rangePath,
961
- match: (n) => Text.isText(n) && typeof n.text === "string" && n.text.length > 0
962
- })
963
- );
964
- allTextNodes.push(...rangeNodes);
965
- } catch (e) {
966
- continue;
1364
+ // 获取文本节点
1365
+ var textNodesGenerator;
1366
+ if (searchRange && searchRange.length > 0) {
1367
+ // 在指定路径范围内搜索
1368
+ var allTextNodes = [];
1369
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1370
+ try {
1371
+ for(var _iterator = searchRange[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1372
+ var rangePath = _step.value;
1373
+ try {
1374
+ var _allTextNodes;
1375
+ var rangeNodes = Array.from(Editor.nodes(editor, {
1376
+ at: rangePath,
1377
+ match: function(n) {
1378
+ return Text.isText(n) && typeof n.text === 'string' && n.text.length > 0;
1379
+ }
1380
+ }));
1381
+ (_allTextNodes = allTextNodes).push.apply(_allTextNodes, _to_consumable_array(rangeNodes));
1382
+ } catch (e) {
1383
+ continue;
1384
+ }
1385
+ }
1386
+ } catch (err) {
1387
+ _didIteratorError = true;
1388
+ _iteratorError = err;
1389
+ } finally{
1390
+ try {
1391
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1392
+ _iterator.return();
1393
+ }
1394
+ } finally{
1395
+ if (_didIteratorError) {
1396
+ throw _iteratorError;
1397
+ }
1398
+ }
1399
+ }
1400
+ textNodesGenerator = allTextNodes;
1401
+ } else {
1402
+ // 在整个编辑器中搜索
1403
+ textNodesGenerator = Array.from(Editor.nodes(editor, {
1404
+ at: [],
1405
+ match: function(n) {
1406
+ return Text.isText(n) && typeof n.text === 'string' && n.text.length > 0;
1407
+ }
1408
+ }));
967
1409
  }
968
- }
969
- textNodesGenerator = allTextNodes;
970
- } else {
971
- textNodesGenerator = Array.from(
972
- Editor.nodes(editor, {
973
- at: [],
974
- match: (n) => Text.isText(n) && typeof n.text === "string" && n.text.length > 0
975
- })
976
- );
977
- }
978
- for (const [node, path] of textNodesGenerator) {
979
- if (!Text.isText(node) || !node.text)
980
- continue;
981
- for (const { variant, pattern } of patterns) {
982
- let match;
983
- pattern.lastIndex = 0;
984
- while ((match = pattern.exec(node.text)) !== null) {
985
- let lineContent = node.text;
986
- let nodeType = "text";
987
- try {
988
- const parentPath = Path.parent(path);
989
- if (Editor.hasPath(editor, parentPath)) {
990
- const parent = Node.get(editor, parentPath);
991
- if (Element.isElement(parent)) {
992
- lineContent = Node.string(parent);
993
- nodeType = parent.type || "unknown";
994
- }
1410
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1411
+ try {
1412
+ var _loop = function() {
1413
+ var _step_value = _sliced_to_array(_step1.value, 2), node = _step_value[0], path = _step_value[1];
1414
+ if (!Text.isText(node) || !node.text) return "continue";
1415
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1416
+ try {
1417
+ // 对每个搜索变体进行匹配
1418
+ for(var _iterator = patterns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1419
+ var _loop = function() {
1420
+ // 获取父节点信息
1421
+ var lineContent = node.text;
1422
+ var nodeType = 'text';
1423
+ try {
1424
+ var parentPath = Path.parent(path);
1425
+ if (Editor.hasPath(editor, parentPath)) {
1426
+ var parent = Node.get(editor, parentPath);
1427
+ if (Element.isElement(parent)) {
1428
+ lineContent = Node.string(parent);
1429
+ nodeType = parent.type || 'unknown';
1430
+ }
1431
+ }
1432
+ } catch (e) {
1433
+ // 如果获取父节点失败,使用原始文本
1434
+ }
1435
+ var matchIndex = match.index;
1436
+ var matchLength = match[0].length;
1437
+ var matchText = match[0];
1438
+ var range = {
1439
+ anchor: {
1440
+ path: path,
1441
+ offset: matchIndex
1442
+ },
1443
+ focus: {
1444
+ path: path,
1445
+ offset: matchIndex + matchLength
1446
+ }
1447
+ };
1448
+ // 检查是否已经有相同位置的匹配结果,避免重复
1449
+ var isDuplicate = results.some(function(result) {
1450
+ return Path.equals(result.path, path) && result.offset.start === matchIndex && result.offset.end === matchIndex + matchLength;
1451
+ });
1452
+ if (!isDuplicate) {
1453
+ // 检查是否为链接节点(带有 url 属性的文本节点)
1454
+ var isLink = Text.isText(node) && !!node.url;
1455
+ var linkUrl = isLink ? node.url : undefined;
1456
+ results.push({
1457
+ path: path,
1458
+ range: range,
1459
+ node: node,
1460
+ matchedText: matchText,
1461
+ offset: {
1462
+ start: matchIndex,
1463
+ end: matchIndex + matchLength
1464
+ },
1465
+ lineContent: lineContent.trim(),
1466
+ nodeType: nodeType,
1467
+ searchVariant: variant !== searchText.trim() ? variant : undefined,
1468
+ isLink: isLink,
1469
+ linkUrl: linkUrl
1470
+ });
1471
+ }
1472
+ // 限制结果数量避免性能问题
1473
+ if (results.length >= maxResults) return "break";
1474
+ };
1475
+ var _step_value1 = _step.value, variant = _step_value1.variant, pattern = _step_value1.pattern;
1476
+ var match = void 0;
1477
+ pattern.lastIndex = 0;
1478
+ while((match = pattern.exec(node.text)) !== null){
1479
+ var _ret = _loop();
1480
+ if (_ret === "break") break;
1481
+ }
1482
+ if (results.length >= maxResults) break;
1483
+ }
1484
+ } catch (err) {
1485
+ _didIteratorError = true;
1486
+ _iteratorError = err;
1487
+ } finally{
1488
+ try {
1489
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1490
+ _iterator.return();
1491
+ }
1492
+ } finally{
1493
+ if (_didIteratorError) {
1494
+ throw _iteratorError;
1495
+ }
1496
+ }
1497
+ }
1498
+ if (results.length >= maxResults) return "break";
1499
+ };
1500
+ // 遍历文本节点查找匹配
1501
+ for(var _iterator1 = textNodesGenerator[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1502
+ var _ret = _loop();
1503
+ if (_ret === "break") break;
1504
+ }
1505
+ } catch (err) {
1506
+ _didIteratorError1 = true;
1507
+ _iteratorError1 = err;
1508
+ } finally{
1509
+ try {
1510
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1511
+ _iterator1.return();
1512
+ }
1513
+ } finally{
1514
+ if (_didIteratorError1) {
1515
+ throw _iteratorError1;
1516
+ }
995
1517
  }
996
- } catch (e) {
997
- }
998
- const matchIndex = match.index;
999
- const matchLength = match[0].length;
1000
- const matchText = match[0];
1001
- const range = {
1002
- anchor: { path, offset: matchIndex },
1003
- focus: { path, offset: matchIndex + matchLength }
1004
- };
1005
- const isDuplicate = results.some(
1006
- (result) => Path.equals(result.path, path) && result.offset.start === matchIndex && result.offset.end === matchIndex + matchLength
1007
- );
1008
- if (!isDuplicate) {
1009
- const isLink = Text.isText(node) && !!node.url;
1010
- const linkUrl = isLink ? node.url : void 0;
1011
- results.push({
1012
- path,
1013
- range,
1014
- node,
1015
- matchedText: matchText,
1016
- offset: {
1017
- start: matchIndex,
1018
- end: matchIndex + matchLength
1019
- },
1020
- lineContent: lineContent.trim(),
1021
- nodeType,
1022
- searchVariant: variant !== searchText.trim() ? variant : void 0,
1023
- isLink,
1024
- linkUrl
1025
- });
1026
- }
1027
- if (results.length >= maxResults)
1028
- break;
1029
1518
  }
1030
- if (results.length >= maxResults)
1031
- break;
1032
- }
1033
- if (results.length >= maxResults)
1034
- break;
1519
+ } catch (error) {
1520
+ console.error('查找过程中出错:', error);
1035
1521
  }
1036
- } catch (error) {
1037
- console.error("查找过程中出错:", error);
1038
- }
1039
- return results;
1522
+ return results;
1040
1523
  }
1041
- export {
1042
- EditorUtils,
1043
- calcPath,
1044
- createDomRangeFromNodes,
1045
- createSelectionFromNodes,
1046
- escapeRegExp,
1047
- findByPathAndText,
1048
- findLeafPath,
1049
- getDefaultView,
1050
- getPointStrOffset,
1051
- getRelativePath,
1052
- getSelectionFromDomSelection,
1053
- hasEditableTarget,
1054
- hasTarget,
1055
- isDOMNode,
1056
- isEventHandled,
1057
- isPath,
1058
- isTargetInsideVoid,
1059
- normalizeMarkdownSearchText
1060
- };