@ant-design/agentic-ui 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (585) hide show
  1. package/dist/AgentRunBar/Robot.js +105 -57
  2. package/dist/AgentRunBar/icons/PauseIcon.js +38 -38
  3. package/dist/AgentRunBar/icons/PlayIcon.js +38 -38
  4. package/dist/AgentRunBar/icons/SimplePauseIcon.js +38 -38
  5. package/dist/AgentRunBar/icons/SimplePlayIcon.js +38 -38
  6. package/dist/AgentRunBar/icons/SimpleStopIcon.js +38 -38
  7. package/dist/AgentRunBar/icons/StopIcon.js +41 -50
  8. package/dist/AgentRunBar/icons/index.js +0 -1
  9. package/dist/AgentRunBar/index.js +270 -237
  10. package/dist/AgentRunBar/style.js +273 -239
  11. package/dist/AgenticLayout/index.js +140 -85
  12. package/dist/AgenticLayout/style.js +126 -107
  13. package/dist/AnswerAlert/components/CloseIcon.js +12 -21
  14. package/dist/AnswerAlert/components/ErrorIcon.js +42 -38
  15. package/dist/AnswerAlert/components/InfoIcon.js +42 -38
  16. package/dist/AnswerAlert/components/LoaderIcon.js +12 -21
  17. package/dist/AnswerAlert/components/SuccessIcon.js +42 -38
  18. package/dist/AnswerAlert/components/WarningIcon.js +42 -38
  19. package/dist/AnswerAlert/index.js +155 -75
  20. package/dist/AnswerAlert/style.js +159 -147
  21. package/dist/BackTo/BackBottom.js +154 -70
  22. package/dist/BackTo/BackTop.js +148 -68
  23. package/dist/BackTo/ScrollVisibleButton.js +124 -98
  24. package/dist/BackTo/hooks/useScrollVisible.js +79 -33
  25. package/dist/BackTo/icons/BottomIcon.js +37 -37
  26. package/dist/BackTo/icons/TopIcon.js +37 -37
  27. package/dist/BackTo/index.js +22 -7
  28. package/dist/BackTo/style.js +93 -70
  29. package/dist/Bubble/AIBubble.js +469 -406
  30. package/dist/Bubble/Avatar/index.js +139 -85
  31. package/dist/Bubble/Avatar/isEmoji.js +2 -6
  32. package/dist/Bubble/Bubble.js +114 -38
  33. package/dist/Bubble/BubbleBeforeNode.js +104 -74
  34. package/dist/Bubble/BubbleConfigProvide.js +3 -7
  35. package/dist/Bubble/FileView.js +63 -69
  36. package/dist/Bubble/List/PureBubbleList.js +130 -131
  37. package/dist/Bubble/List/SkeletonList.js +33 -24
  38. package/dist/Bubble/List/index.js +187 -124
  39. package/dist/Bubble/List/style.js +76 -47
  40. package/dist/Bubble/MessagesContent/BubbleContext.js +6 -12
  41. package/dist/Bubble/MessagesContent/BubbleExtra.js +663 -355
  42. package/dist/Bubble/MessagesContent/CopyButton/index.js +326 -96
  43. package/dist/Bubble/MessagesContent/DocInfo.js +351 -386
  44. package/dist/Bubble/MessagesContent/EXCEPTION.js +42 -22
  45. package/dist/Bubble/MessagesContent/MarkdownPreview.js +206 -156
  46. package/dist/Bubble/MessagesContent/VoiceButton/index.js +213 -115
  47. package/dist/Bubble/MessagesContent/VoiceButton/style.js +129 -105
  48. package/dist/Bubble/MessagesContent/VoiceButton/types.js +9 -0
  49. package/dist/Bubble/MessagesContent/docInfoStyle.js +118 -88
  50. package/dist/Bubble/MessagesContent/icons.js +157 -57
  51. package/dist/Bubble/MessagesContent/index.js +609 -368
  52. package/dist/Bubble/PureBubble.js +439 -326
  53. package/dist/Bubble/Title.js +110 -87
  54. package/dist/Bubble/UserBubble.js +218 -279
  55. package/dist/Bubble/index.js +10 -16
  56. package/dist/Bubble/style.js +248 -227
  57. package/dist/Bubble/type.js +3 -0
  58. package/dist/Bubble/types/BubbleExtra.js +1 -0
  59. package/dist/Bubble/types/DocInfo.js +1 -0
  60. package/dist/ChatBootPage/ButtonTab.js +25 -45
  61. package/dist/ChatBootPage/ButtonTabGroup.js +74 -47
  62. package/dist/ChatBootPage/ButtonTabGroupStyle.js +73 -45
  63. package/dist/ChatBootPage/ButtonTabStyle.js +121 -98
  64. package/dist/ChatBootPage/CaseReply.js +119 -113
  65. package/dist/ChatBootPage/CaseReplyStyle.js +217 -189
  66. package/dist/ChatBootPage/Title.js +19 -23
  67. package/dist/ChatBootPage/index.js +9 -11
  68. package/dist/ChatBootPage/style.js +80 -50
  69. package/dist/ChatLayout/index.js +93 -57
  70. package/dist/ChatLayout/style.js +206 -176
  71. package/dist/ChatLayout/types.js +1 -0
  72. package/dist/Components/ActionIconBox/index.js +571 -197
  73. package/dist/Components/ActionIconBox/style.js +141 -111
  74. package/dist/Components/ActionItemBox/ActionItemBox.js +95 -149
  75. package/dist/Components/ActionItemBox/index.js +7 -7
  76. package/dist/Components/ActionItemBox/style.js +353 -361
  77. package/dist/Components/Button/IconButton/index.js +35 -43
  78. package/dist/Components/Button/IconButton/style.js +357 -331
  79. package/dist/Components/Button/SwitchButton/index.js +243 -87
  80. package/dist/Components/Button/SwitchButton/style.js +160 -146
  81. package/dist/Components/Button/ToggleButton/index.js +46 -57
  82. package/dist/Components/Button/ToggleButton/style.js +283 -258
  83. package/dist/Components/Button/index.js +6 -2
  84. package/dist/Components/GradientText/index.js +21 -27
  85. package/dist/Components/GradientText/style.js +88 -63
  86. package/dist/Components/ImageList.js +111 -133
  87. package/dist/Components/LayoutHeader/index.js +145 -81
  88. package/dist/Components/LayoutHeader/style.js +89 -64
  89. package/dist/Components/LayoutHeader/types.js +3 -0
  90. package/dist/Components/Loading/index.js +53 -22
  91. package/dist/Components/Robot/index.js +90 -56
  92. package/dist/Components/Robot/lotties/DazingLottie/index.js +78 -47
  93. package/dist/Components/Robot/lotties/ThinkingLottie/index.js +78 -47
  94. package/dist/Components/Robot/lotties/index.js +0 -1
  95. package/dist/Components/SuggestionList/index.js +354 -182
  96. package/dist/Components/SuggestionList/style.js +204 -186
  97. package/dist/Components/TextAnimate/index.js +494 -362
  98. package/dist/Components/TextAnimate/style.js +72 -48
  99. package/dist/Components/TypingAnimation/index.js +214 -169
  100. package/dist/Components/TypingAnimation/style.js +76 -52
  101. package/dist/Components/VisualList/index.js +267 -180
  102. package/dist/Components/VisualList/style.js +140 -124
  103. package/dist/Components/icons/LoadingSpinnerIcon.js +124 -73
  104. package/dist/Components/lotties/DazingLottie/index.js +78 -47
  105. package/dist/Components/lotties/LoadingLottie/index.js +82 -48
  106. package/dist/Components/lotties/TextLoading/index.js +73 -49
  107. package/dist/Components/lotties/TextLoading/style.js +95 -78
  108. package/dist/Components/lotties/ThinkingLottie/index.js +78 -47
  109. package/dist/Components/lotties/index.js +0 -1
  110. package/dist/Constants/colors.js +71 -97
  111. package/dist/History/components/HistoryActionsBox.js +407 -180
  112. package/dist/History/components/HistoryEmpty.js +38 -42
  113. package/dist/History/components/HistoryEmptyIcon.js +682 -964
  114. package/dist/History/components/HistoryItem.js +683 -471
  115. package/dist/History/components/HistoryList.js +170 -87
  116. package/dist/History/components/HistoryRunningIcon.js +160 -111
  117. package/dist/History/components/LoadMoreComponent.js +308 -103
  118. package/dist/History/components/NewChatComponent.js +261 -69
  119. package/dist/History/components/NewChatComponent.style.js +79 -53
  120. package/dist/History/components/SearchComponent.js +367 -156
  121. package/dist/History/components/index.js +11 -23
  122. package/dist/History/hooks/useHistory.js +404 -129
  123. package/dist/History/index.js +301 -186
  124. package/dist/History/menu.js +158 -212
  125. package/dist/History/style.js +282 -276
  126. package/dist/History/types/HistoryData.js +6 -10
  127. package/dist/History/types/HistoryList.js +3 -0
  128. package/dist/History/types/index.js +3 -0
  129. package/dist/History/utils/index.js +35 -32
  130. package/dist/Hooks/useAutoScroll.js +262 -84
  131. package/dist/Hooks/useClickAway.js +60 -21
  132. package/dist/Hooks/useCopied.js +72 -20
  133. package/dist/Hooks/useDebounceFn/index.js +213 -55
  134. package/dist/Hooks/useIntersectionOnce.js +163 -74
  135. package/dist/Hooks/useLanguage.d.ts +3 -0
  136. package/dist/Hooks/useLanguage.js +67 -26
  137. package/dist/Hooks/useRefFunction/index.js +76 -11
  138. package/dist/Hooks/useSpeechSynthesis.js +143 -99
  139. package/dist/Hooks/useStyle/index.js +95 -60
  140. package/dist/Hooks/useThrottleFn/index.js +41 -41
  141. package/dist/I18n/index.js +246 -109
  142. package/dist/I18n/locales.d.ts +3 -0
  143. package/dist/I18n/locales.js +724 -711
  144. package/dist/Icons/animated/VoicePlayLottie/index.js +75 -46
  145. package/dist/Icons/animated/VoicingLottie/index.js +78 -47
  146. package/dist/MarkdownEditor/BaseMarkdownEditor.js +421 -349
  147. package/dist/MarkdownEditor/editor/Editor.js +1160 -843
  148. package/dist/MarkdownEditor/editor/components/CommentList/index.js +407 -239
  149. package/dist/MarkdownEditor/editor/components/CommentList/style.js +119 -89
  150. package/dist/MarkdownEditor/editor/components/ContributorAvatar/index.js +61 -63
  151. package/dist/MarkdownEditor/editor/components/ContributorAvatar/style.js +82 -52
  152. package/dist/MarkdownEditor/editor/components/LazyElement/index.js +208 -106
  153. package/dist/MarkdownEditor/editor/components/LazyElement/style.js +69 -42
  154. package/dist/MarkdownEditor/editor/components/fntTag/index.js +7 -11
  155. package/dist/MarkdownEditor/editor/components/fntTag/style.js +66 -36
  156. package/dist/MarkdownEditor/editor/components/index.js +0 -1
  157. package/dist/MarkdownEditor/editor/elements/Blockquote.js +95 -37
  158. package/dist/MarkdownEditor/editor/elements/Break.js +56 -25
  159. package/dist/MarkdownEditor/editor/elements/Card/index.js +131 -52
  160. package/dist/MarkdownEditor/editor/elements/Code.js +89 -67
  161. package/dist/MarkdownEditor/editor/elements/Comment/index.js +79 -50
  162. package/dist/MarkdownEditor/editor/elements/ErrorBoundary.js +117 -21
  163. package/dist/MarkdownEditor/editor/elements/FootnoteDefinition.js +83 -64
  164. package/dist/MarkdownEditor/editor/elements/FootnoteReference.js +115 -41
  165. package/dist/MarkdownEditor/editor/elements/Head.js +131 -67
  166. package/dist/MarkdownEditor/editor/elements/Hr.js +63 -38
  167. package/dist/MarkdownEditor/editor/elements/Image/index.js +636 -494
  168. package/dist/MarkdownEditor/editor/elements/InlineKatex.js +60 -44
  169. package/dist/MarkdownEditor/editor/elements/Katex.js +71 -55
  170. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +79 -175
  171. package/dist/MarkdownEditor/editor/elements/LinkCard/style.js +130 -100
  172. package/dist/MarkdownEditor/editor/elements/List/List.js +96 -69
  173. package/dist/MarkdownEditor/editor/elements/List/ListItem.js +422 -247
  174. package/dist/MarkdownEditor/editor/elements/List/index.js +1 -5
  175. package/dist/MarkdownEditor/editor/elements/List/style.js +131 -117
  176. package/dist/MarkdownEditor/editor/elements/Media.js +637 -519
  177. package/dist/MarkdownEditor/editor/elements/Mermaid.js +79 -54
  178. package/dist/MarkdownEditor/editor/elements/Paragraph.js +144 -83
  179. package/dist/MarkdownEditor/editor/elements/Schema.js +167 -128
  180. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +211 -178
  181. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +73 -49
  182. package/dist/MarkdownEditor/editor/elements/Table/Table.js +285 -204
  183. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +397 -280
  184. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.js +126 -101
  185. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +381 -276
  186. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.js +120 -98
  187. package/dist/MarkdownEditor/editor/elements/Table/TableContext.js +64 -21
  188. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +52 -42
  189. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.js +69 -39
  190. package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +126 -72
  191. package/dist/MarkdownEditor/editor/elements/Table/Td/style.js +85 -55
  192. package/dist/MarkdownEditor/editor/elements/Table/index.js +204 -105
  193. package/dist/MarkdownEditor/editor/elements/Table/style.js +244 -233
  194. package/dist/MarkdownEditor/editor/elements/Table/useScrollShadow.js +119 -62
  195. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +438 -276
  196. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +103 -77
  197. package/dist/MarkdownEditor/editor/elements/index.js +437 -424
  198. package/dist/MarkdownEditor/editor/parser/json-parse.js +38 -9
  199. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1753 -1168
  200. package/dist/MarkdownEditor/editor/parser/parserMdToSchema.js +16 -20
  201. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1021 -606
  202. package/dist/MarkdownEditor/editor/parser/remarkParse.js +158 -102
  203. package/dist/MarkdownEditor/editor/plugins/catchError.js +78 -17
  204. package/dist/MarkdownEditor/editor/plugins/elements.js +458 -342
  205. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +752 -300
  206. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +215 -129
  207. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +325 -180
  208. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +576 -418
  209. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +157 -47
  210. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +331 -209
  211. package/dist/MarkdownEditor/editor/plugins/index.js +0 -1
  212. package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +1245 -507
  213. package/dist/MarkdownEditor/editor/plugins/parseMarkdownToNodesAndInsert.js +36 -24
  214. package/dist/MarkdownEditor/editor/plugins/useHighlight.js +267 -116
  215. package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +234 -160
  216. package/dist/MarkdownEditor/editor/plugins/useOnchange.js +253 -92
  217. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +728 -439
  218. package/dist/MarkdownEditor/editor/store.js +1819 -1389
  219. package/dist/MarkdownEditor/editor/style.js +551 -506
  220. package/dist/MarkdownEditor/editor/tagStyles.js +43 -43
  221. package/dist/MarkdownEditor/editor/tools/DragHandle.js +56 -54
  222. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1049 -732
  223. package/dist/MarkdownEditor/editor/tools/InsertLink.js +232 -181
  224. package/dist/MarkdownEditor/editor/tools/Leading.js +566 -303
  225. package/dist/MarkdownEditor/editor/tools/ToolBar/BaseBar.js +415 -377
  226. package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +162 -125
  227. package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +480 -258
  228. package/dist/MarkdownEditor/editor/tools/ToolBar/ToolBar.js +44 -44
  229. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ClearFormatButton.js +20 -35
  230. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ColorPickerButton.js +69 -73
  231. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormatButton.js +13 -19
  232. package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormattingTools.js +34 -41
  233. package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +53 -47
  234. package/dist/MarkdownEditor/editor/tools/ToolBar/components/LinkButton.js +11 -19
  235. package/dist/MarkdownEditor/editor/tools/ToolBar/components/ToolBarItem.js +23 -43
  236. package/dist/MarkdownEditor/editor/tools/ToolBar/components/UndoRedoButtons.js +14 -25
  237. package/dist/MarkdownEditor/editor/tools/ToolBar/config/toolsConfig.js +139 -102
  238. package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.js +95 -65
  239. package/dist/MarkdownEditor/editor/tools/ToolBar/hooks/useToolBarLogic.js +252 -161
  240. package/dist/MarkdownEditor/editor/tools/ToolBar/index.js +14 -24
  241. package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.js +95 -65
  242. package/dist/MarkdownEditor/editor/tools/insertAutocompleteStyle.js +82 -52
  243. package/dist/MarkdownEditor/editor/types/Table.js +1 -0
  244. package/dist/MarkdownEditor/editor/utils/InlineChromiumBugfix.js +11 -16
  245. package/dist/MarkdownEditor/editor/utils/ace.js +136 -40
  246. package/dist/MarkdownEditor/editor/utils/docx/docxDeserializer.js +29 -32
  247. package/dist/MarkdownEditor/editor/utils/docx/index.js +0 -1
  248. package/dist/MarkdownEditor/editor/utils/docx/module.js +193 -164
  249. package/dist/MarkdownEditor/editor/utils/docx/utils.js +113 -98
  250. package/dist/MarkdownEditor/editor/utils/dom.js +119 -90
  251. package/dist/MarkdownEditor/editor/utils/editorUtils.js +1369 -906
  252. package/dist/MarkdownEditor/editor/utils/htmlToMarkdown.js +196 -184
  253. package/dist/MarkdownEditor/editor/utils/index.js +354 -215
  254. package/dist/MarkdownEditor/editor/utils/isMarkdown.js +56 -44
  255. package/dist/MarkdownEditor/editor/utils/keyboard.js +1229 -664
  256. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +294 -76
  257. package/dist/MarkdownEditor/editor/utils/media.js +274 -99
  258. package/dist/MarkdownEditor/editor/utils/path.js +22 -16
  259. package/dist/MarkdownEditor/editor/utils/performanceMonitor.js +370 -168
  260. package/dist/MarkdownEditor/editor/utils/useLocalState.js +96 -37
  261. package/dist/MarkdownEditor/el.js +1 -0
  262. package/dist/MarkdownEditor/hooks/editor.js +123 -41
  263. package/dist/MarkdownEditor/hooks/subscribe.js +18 -15
  264. package/dist/MarkdownEditor/index.js +118 -30
  265. package/dist/MarkdownEditor/plugin.js +2 -5
  266. package/dist/MarkdownEditor/style.js +96 -66
  267. package/dist/MarkdownEditor/types.js +1 -0
  268. package/dist/MarkdownEditor/utils/exportHtml.js +42 -83
  269. package/dist/MarkdownEditor/utils/native-table/index.js +0 -1
  270. package/dist/MarkdownEditor/utils/native-table/native-table-editor.js +337 -222
  271. package/dist/MarkdownEditor/utils/native-table/native-table-keyboard.js +201 -113
  272. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +4 -0
  273. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +277 -82
  274. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +62 -33
  275. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +147 -125
  276. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +174 -129
  277. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +263 -237
  278. package/dist/MarkdownInputField/AttachmentButton/index.js +480 -205
  279. package/dist/MarkdownInputField/AttachmentButton/style.js +143 -114
  280. package/dist/MarkdownInputField/AttachmentButton/types.js +3 -0
  281. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +60 -0
  282. package/dist/MarkdownInputField/AttachmentButton/utils.js +365 -33
  283. package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +438 -404
  284. package/dist/MarkdownInputField/Enlargement/index.js +7 -17
  285. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +193 -216
  286. package/dist/MarkdownInputField/FileMapView/index.js +387 -174
  287. package/dist/MarkdownInputField/FileMapView/style.js +281 -259
  288. package/dist/MarkdownInputField/FilePaste/index.js +239 -65
  289. package/dist/MarkdownInputField/FileUploadManager/index.js +504 -170
  290. package/dist/MarkdownInputField/MarkdownInputField.js +819 -549
  291. package/dist/MarkdownInputField/QuickActions/index.js +304 -134
  292. package/dist/MarkdownInputField/RefinePromptButton/index.js +24 -33
  293. package/dist/MarkdownInputField/RefinePromptButton/style.js +99 -73
  294. package/dist/MarkdownInputField/SendActions/index.js +179 -197
  295. package/dist/MarkdownInputField/SendButton/index.js +150 -110
  296. package/dist/MarkdownInputField/SendButton/style.js +95 -64
  297. package/dist/MarkdownInputField/SkillModeBar/hooks/index.js +3 -5
  298. package/dist/MarkdownInputField/SkillModeBar/hooks/useSkillModeState.js +51 -26
  299. package/dist/MarkdownInputField/SkillModeBar/index.js +119 -106
  300. package/dist/MarkdownInputField/SkillModeBar/style.js +124 -98
  301. package/dist/MarkdownInputField/Suggestion/index.js +391 -154
  302. package/dist/MarkdownInputField/TopOperatingArea/index.js +37 -44
  303. package/dist/MarkdownInputField/TopOperatingArea/style.js +98 -81
  304. package/dist/MarkdownInputField/VoiceInput/index.js +210 -82
  305. package/dist/MarkdownInputField/VoiceInput/style.js +85 -59
  306. package/dist/MarkdownInputField/VoiceInputManager/index.js +321 -94
  307. package/dist/MarkdownInputField/style.js +296 -233
  308. package/dist/Plugins/chart/AreaChart/index.js +541 -393
  309. package/dist/Plugins/chart/AreaChart/style.js +114 -90
  310. package/dist/Plugins/chart/BarChart/index.d.ts +4 -0
  311. package/dist/Plugins/chart/BarChart/index.js +865 -697
  312. package/dist/Plugins/chart/BarChart/style.js +114 -90
  313. package/dist/Plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.js +82 -52
  314. package/dist/Plugins/chart/ChartAttrToolBar/index.js +94 -65
  315. package/dist/Plugins/chart/ChartMark/Area.js +176 -150
  316. package/dist/Plugins/chart/ChartMark/Bar.js +181 -152
  317. package/dist/Plugins/chart/ChartMark/Column.js +181 -151
  318. package/dist/Plugins/chart/ChartMark/Container.js +116 -75
  319. package/dist/Plugins/chart/ChartMark/Line.js +179 -151
  320. package/dist/Plugins/chart/ChartMark/Pie.js +79 -63
  321. package/dist/Plugins/chart/ChartMark/index.js +6 -13
  322. package/dist/Plugins/chart/ChartMark/useChart.js +1 -0
  323. package/dist/Plugins/chart/ChartRender.js +981 -696
  324. package/dist/Plugins/chart/ChartStatistic/index.js +47 -62
  325. package/dist/Plugins/chart/ChartStatistic/style.js +142 -143
  326. package/dist/Plugins/chart/ChartStatistic/utils.js +37 -27
  327. package/dist/Plugins/chart/DonutChart/Legend.js +94 -124
  328. package/dist/Plugins/chart/DonutChart/constants.js +4 -11
  329. package/dist/Plugins/chart/DonutChart/hooks.js +183 -112
  330. package/dist/Plugins/chart/DonutChart/index.js +588 -516
  331. package/dist/Plugins/chart/DonutChart/plugins.js +47 -44
  332. package/dist/Plugins/chart/DonutChart/style.js +186 -175
  333. package/dist/Plugins/chart/DonutChart/types.js +1 -0
  334. package/dist/Plugins/chart/FunnelChart/index.js +844 -647
  335. package/dist/Plugins/chart/FunnelChart/style.js +97 -71
  336. package/dist/Plugins/chart/LineChart/index.js +516 -393
  337. package/dist/Plugins/chart/LineChart/style.js +114 -90
  338. package/dist/Plugins/chart/RadarChart/index.js +580 -582
  339. package/dist/Plugins/chart/RadarChart/style.js +122 -112
  340. package/dist/Plugins/chart/ScatterChart/index.js +633 -640
  341. package/dist/Plugins/chart/ScatterChart/style.js +108 -94
  342. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +151 -80
  343. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +160 -41
  344. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundaryExample.js +80 -62
  345. package/dist/Plugins/chart/components/ChartContainer/index.js +2 -7
  346. package/dist/Plugins/chart/components/ChartContainer/style.js +121 -91
  347. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +58 -90
  348. package/dist/Plugins/chart/components/ChartFilter/style.js +169 -154
  349. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +54 -59
  350. package/dist/Plugins/chart/components/ChartToolBar/style.js +132 -117
  351. package/dist/Plugins/chart/components/icons/TimeIcon.js +20 -26
  352. package/dist/Plugins/chart/components/index.js +32 -34
  353. package/dist/Plugins/chart/const.js +34 -25
  354. package/dist/Plugins/chart/hooks/useChartStatistic.js +1 -0
  355. package/dist/Plugins/chart/index.js +436 -339
  356. package/dist/Plugins/chart/loadChartRuntime.js +209 -110
  357. package/dist/Plugins/chart/utils.js +311 -87
  358. package/dist/Plugins/code/CodeUI/Katex/Katex.js +112 -66
  359. package/dist/Plugins/code/components/AceEditor.js +334 -237
  360. package/dist/Plugins/code/components/AceEditorContainer.js +23 -32
  361. package/dist/Plugins/code/components/CodeContainer.js +41 -56
  362. package/dist/Plugins/code/components/CodeRenderer.js +202 -155
  363. package/dist/Plugins/code/components/CodeToolbar.js +137 -181
  364. package/dist/Plugins/code/components/HtmlPreview.js +19 -22
  365. package/dist/Plugins/code/components/LanguageSelector.js +162 -96
  366. package/dist/Plugins/code/components/LoadImage.js +145 -46
  367. package/dist/Plugins/code/components/ThinkBlock.js +38 -42
  368. package/dist/Plugins/code/components/index.js +13 -23
  369. package/dist/Plugins/code/hooks/index.js +7 -9
  370. package/dist/Plugins/code/hooks/useCodeEditorState.js +139 -62
  371. package/dist/Plugins/code/hooks/useRenderConditions.js +31 -23
  372. package/dist/Plugins/code/hooks/useToolbarConfig.js +44 -46
  373. package/dist/Plugins/code/index.js +141 -89
  374. package/dist/Plugins/code/langIconMap.js +400 -108
  375. package/dist/Plugins/code/langIcons/AbapIcon.js +90 -57
  376. package/dist/Plugins/code/langIcons/ActionscriptIcon.js +89 -56
  377. package/dist/Plugins/code/langIcons/AdaIcon.js +89 -52
  378. package/dist/Plugins/code/langIcons/ApacheIcon.js +205 -254
  379. package/dist/Plugins/code/langIcons/ApexIcon.js +108 -82
  380. package/dist/Plugins/code/langIcons/AplIcon.js +90 -54
  381. package/dist/Plugins/code/langIcons/ApplescriptIcon.js +89 -56
  382. package/dist/Plugins/code/langIcons/AstroIcon.js +91 -58
  383. package/dist/Plugins/code/langIcons/AwkIcon.js +98 -68
  384. package/dist/Plugins/code/langIcons/BallerinaIcon.js +92 -59
  385. package/dist/Plugins/code/langIcons/BatIcon.js +158 -229
  386. package/dist/Plugins/code/langIcons/BicepIcon.js +91 -58
  387. package/dist/Plugins/code/langIcons/BladeIcon.js +90 -58
  388. package/dist/Plugins/code/langIcons/CIcon.js +90 -55
  389. package/dist/Plugins/code/langIcons/CadenceIcon.js +89 -56
  390. package/dist/Plugins/code/langIcons/ClojureIcon.js +96 -75
  391. package/dist/Plugins/code/langIcons/CmakeIcon.js +93 -62
  392. package/dist/Plugins/code/langIcons/CobolIcon.js +99 -70
  393. package/dist/Plugins/code/langIcons/CodeqlIcon.js +96 -76
  394. package/dist/Plugins/code/langIcons/CoffeeIcon.js +89 -56
  395. package/dist/Plugins/code/langIcons/ConsoleIcon.js +89 -56
  396. package/dist/Plugins/code/langIcons/CppIcon.js +90 -55
  397. package/dist/Plugins/code/langIcons/CrystalIcon.js +90 -57
  398. package/dist/Plugins/code/langIcons/CsharpIcon.js +90 -59
  399. package/dist/Plugins/code/langIcons/CssIcon.js +89 -52
  400. package/dist/Plugins/code/langIcons/DIcon.js +90 -53
  401. package/dist/Plugins/code/langIcons/DartIcon.js +92 -71
  402. package/dist/Plugins/code/langIcons/DatabaseIcon.js +90 -57
  403. package/dist/Plugins/code/langIcons/DiffIcon.js +90 -57
  404. package/dist/Plugins/code/langIcons/DockerIcon.js +89 -56
  405. package/dist/Plugins/code/langIcons/DotenvIcon.js +94 -56
  406. package/dist/Plugins/code/langIcons/ElixirIcon.js +91 -58
  407. package/dist/Plugins/code/langIcons/ElmIcon.js +105 -58
  408. package/dist/Plugins/code/langIcons/ErbIcon.js +90 -54
  409. package/dist/Plugins/code/langIcons/ErlangIcon.js +89 -56
  410. package/dist/Plugins/code/langIcons/FsharpIcon.js +93 -62
  411. package/dist/Plugins/code/langIcons/GdscriptIcon.js +96 -88
  412. package/dist/Plugins/code/langIcons/GlslIcon.js +90 -58
  413. package/dist/Plugins/code/langIcons/GnuplotIcon.js +98 -77
  414. package/dist/Plugins/code/langIcons/GoIcon.js +114 -93
  415. package/dist/Plugins/code/langIcons/GraphqlIcon.js +106 -66
  416. package/dist/Plugins/code/langIcons/GroovyIcon.js +89 -56
  417. package/dist/Plugins/code/langIcons/HackIcon.js +97 -64
  418. package/dist/Plugins/code/langIcons/HamlIcon.js +89 -56
  419. package/dist/Plugins/code/langIcons/HandlebarsIcon.js +89 -56
  420. package/dist/Plugins/code/langIcons/HaskellIcon.js +93 -64
  421. package/dist/Plugins/code/langIcons/HclIcon.js +118 -93
  422. package/dist/Plugins/code/langIcons/HclLightIcon.js +118 -97
  423. package/dist/Plugins/code/langIcons/HjsonIcon.js +94 -62
  424. package/dist/Plugins/code/langIcons/HlslIcon.js +96 -76
  425. package/dist/Plugins/code/langIcons/HtmlIcon.js +89 -56
  426. package/dist/Plugins/code/langIcons/HttpIcon.js +89 -56
  427. package/dist/Plugins/code/langIcons/ImbaIcon.js +98 -65
  428. package/dist/Plugins/code/langIcons/IniIcon.js +90 -54
  429. package/dist/Plugins/code/langIcons/JavaIcon.js +89 -56
  430. package/dist/Plugins/code/langIcons/JavascriptIcon.js +89 -56
  431. package/dist/Plugins/code/langIcons/JinjaIcon.js +100 -68
  432. package/dist/Plugins/code/langIcons/Json5Icon.js +100 -82
  433. package/dist/Plugins/code/langIcons/JsonIcon.js +89 -56
  434. package/dist/Plugins/code/langIcons/JsonnetIcon.js +102 -86
  435. package/dist/Plugins/code/langIcons/JuliaIcon.js +105 -52
  436. package/dist/Plugins/code/langIcons/KotlinIcon.js +104 -74
  437. package/dist/Plugins/code/langIcons/KustoIcon.js +90 -57
  438. package/dist/Plugins/code/langIcons/LessIcon.js +90 -57
  439. package/dist/Plugins/code/langIcons/LiquidIcon.js +91 -58
  440. package/dist/Plugins/code/langIcons/LispIcon.js +89 -56
  441. package/dist/Plugins/code/langIcons/LuaIcon.js +93 -60
  442. package/dist/Plugins/code/langIcons/MakefileIcon.js +91 -58
  443. package/dist/Plugins/code/langIcons/MarkdownIcon.js +89 -56
  444. package/dist/Plugins/code/langIcons/MarkojsIcon.js +96 -73
  445. package/dist/Plugins/code/langIcons/MatlabIcon.js +93 -64
  446. package/dist/Plugins/code/langIcons/MdxIcon.js +90 -53
  447. package/dist/Plugins/code/langIcons/MermaidIcon.js +95 -64
  448. package/dist/Plugins/code/langIcons/MojoIcon.js +95 -62
  449. package/dist/Plugins/code/langIcons/NginxIcon.js +94 -61
  450. package/dist/Plugins/code/langIcons/NimIcon.js +91 -54
  451. package/dist/Plugins/code/langIcons/NixIcon.js +92 -56
  452. package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +90 -59
  453. package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +90 -57
  454. package/dist/Plugins/code/langIcons/OcamlIcon.js +90 -61
  455. package/dist/Plugins/code/langIcons/PascalIcon.js +95 -55
  456. package/dist/Plugins/code/langIcons/Perl6Icon.js +299 -320
  457. package/dist/Plugins/code/langIcons/PerlIcon.js +89 -56
  458. package/dist/Plugins/code/langIcons/PhpIcon.js +89 -52
  459. package/dist/Plugins/code/langIcons/PostcssIcon.js +130 -113
  460. package/dist/Plugins/code/langIcons/PowershellIcon.js +91 -58
  461. package/dist/Plugins/code/langIcons/PrismaIcon.js +97 -68
  462. package/dist/Plugins/code/langIcons/PrologIcon.js +91 -58
  463. package/dist/Plugins/code/langIcons/ProtoIcon.js +94 -68
  464. package/dist/Plugins/code/langIcons/PugIcon.js +177 -145
  465. package/dist/Plugins/code/langIcons/PuppetIcon.js +96 -52
  466. package/dist/Plugins/code/langIcons/PurescriptIcon.js +93 -61
  467. package/dist/Plugins/code/langIcons/PythonIcon.js +90 -61
  468. package/dist/Plugins/code/langIcons/RIcon.js +89 -52
  469. package/dist/Plugins/code/langIcons/RazorIcon.js +90 -57
  470. package/dist/Plugins/code/langIcons/ReactIcon.js +89 -56
  471. package/dist/Plugins/code/langIcons/ReactTsIcon.js +90 -57
  472. package/dist/Plugins/code/langIcons/RubyIcon.js +91 -58
  473. package/dist/Plugins/code/langIcons/RustIcon.js +89 -56
  474. package/dist/Plugins/code/langIcons/SasIcon.js +89 -52
  475. package/dist/Plugins/code/langIcons/SassIcon.js +90 -57
  476. package/dist/Plugins/code/langIcons/ScalaIcon.js +96 -53
  477. package/dist/Plugins/code/langIcons/SchemeIcon.js +91 -58
  478. package/dist/Plugins/code/langIcons/ShaderlabIcon.js +89 -56
  479. package/dist/Plugins/code/langIcons/SolidityIcon.js +94 -52
  480. package/dist/Plugins/code/langIcons/SparqlIcon.js +94 -64
  481. package/dist/Plugins/code/langIcons/StataIcon.js +126 -108
  482. package/dist/Plugins/code/langIcons/StylusIcon.js +92 -59
  483. package/dist/Plugins/code/langIcons/SvelteIcon.js +91 -58
  484. package/dist/Plugins/code/langIcons/SwiftIcon.js +90 -57
  485. package/dist/Plugins/code/langIcons/SystemverilogIcon.js +115 -102
  486. package/dist/Plugins/code/langIcons/TclIcon.js +89 -52
  487. package/dist/Plugins/code/langIcons/TexIcon.js +99 -65
  488. package/dist/Plugins/code/langIcons/TomlIcon.js +94 -70
  489. package/dist/Plugins/code/langIcons/TwigIcon.js +89 -56
  490. package/dist/Plugins/code/langIcons/TypescriptIcon.js +93 -60
  491. package/dist/Plugins/code/langIcons/VerilogIcon.js +89 -56
  492. package/dist/Plugins/code/langIcons/VhdlIcon.js +94 -64
  493. package/dist/Plugins/code/langIcons/VimIcon.js +278 -420
  494. package/dist/Plugins/code/langIcons/VueIcon.js +92 -59
  495. package/dist/Plugins/code/langIcons/WebassemblyIcon.js +103 -76
  496. package/dist/Plugins/code/langIcons/WenyanIcon.js +104 -100
  497. package/dist/Plugins/code/langIcons/WgslIcon.js +93 -77
  498. package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +100 -71
  499. package/dist/Plugins/code/langIcons/XmlIcon.js +89 -52
  500. package/dist/Plugins/code/langIcons/XslIcon.js +94 -66
  501. package/dist/Plugins/code/langIcons/YamlIcon.js +89 -56
  502. package/dist/Plugins/code/langIcons/ZigIcon.js +106 -81
  503. package/dist/Plugins/code/langIcons/index.js +128 -259
  504. package/dist/Plugins/code/utils/index.js +5 -5
  505. package/dist/Plugins/code/utils/langOptions.js +86 -11
  506. package/dist/Plugins/defaultPlugins.js +9 -13
  507. package/dist/Plugins/formatter/index.js +205 -105
  508. package/dist/Plugins/index.js +6 -2
  509. package/dist/Plugins/katex/InlineKatex.js +196 -107
  510. package/dist/Plugins/katex/Katex.js +139 -65
  511. package/dist/Plugins/katex/index.js +163 -103
  512. package/dist/Plugins/mermaid/Mermaid.js +472 -197
  513. package/dist/Plugins/mermaid/index.js +237 -142
  514. package/dist/Quote/index.js +112 -73
  515. package/dist/Quote/style.js +176 -160
  516. package/dist/Schema/SchemaEditor/AceEditorWrapper.js +163 -119
  517. package/dist/Schema/SchemaEditor/index.js +385 -275
  518. package/dist/Schema/SchemaEditor/style.js +261 -269
  519. package/dist/Schema/SchemaForm/index.js +443 -268
  520. package/dist/Schema/SchemaForm/types.js +1 -0
  521. package/dist/Schema/SchemaRenderer/index.js +973 -588
  522. package/dist/Schema/SchemaRenderer/templateEngine.js +106 -26
  523. package/dist/Schema/index.js +7 -11
  524. package/dist/Schema/types.js +1 -0
  525. package/dist/Schema/validator.js +74 -36
  526. package/dist/TaskList/index.js +197 -142
  527. package/dist/TaskList/style.js +143 -122
  528. package/dist/ThoughtChainList/CostMillis.js +88 -54
  529. package/dist/ThoughtChainList/DeepThink.js +187 -152
  530. package/dist/ThoughtChainList/DotAni/index.js +29 -14
  531. package/dist/ThoughtChainList/DotAni/style.js +82 -50
  532. package/dist/ThoughtChainList/FlipText/index.js +74 -30
  533. package/dist/ThoughtChainList/MarkdownEditor.js +126 -72
  534. package/dist/ThoughtChainList/RagRetrievalInfo.js +113 -145
  535. package/dist/ThoughtChainList/TableSql.js +413 -459
  536. package/dist/ThoughtChainList/ThoughtChainListItem.js +388 -222
  537. package/dist/ThoughtChainList/TitleInfo.js +189 -185
  538. package/dist/ThoughtChainList/ToolCall.js +429 -463
  539. package/dist/ThoughtChainList/WebSearch.js +192 -162
  540. package/dist/ThoughtChainList/index.js +449 -410
  541. package/dist/ThoughtChainList/style.js +253 -232
  542. package/dist/ThoughtChainList/types.js +1 -0
  543. package/dist/ToolUseBar/ToolUseBarItem.js +183 -139
  544. package/dist/ToolUseBar/ToolUseBarItemComponents.js +345 -276
  545. package/dist/ToolUseBar/ToolUseBarThink.js +335 -396
  546. package/dist/ToolUseBar/index.js +226 -113
  547. package/dist/ToolUseBar/style.js +334 -308
  548. package/dist/ToolUseBar/thinkStyle.js +350 -328
  549. package/dist/Types/common.js +1 -0
  550. package/dist/Types/index.js +4 -2
  551. package/dist/Types/message.js +1 -0
  552. package/dist/Utils/easings.js +9 -12
  553. package/dist/Utils/formatTime.js +41 -17
  554. package/dist/Utils/getScroll.js +41 -41
  555. package/dist/Utils/language.js +355 -150
  556. package/dist/Utils/proxySandbox/ProxySandbox.js +1637 -1076
  557. package/dist/Utils/proxySandbox/SecurityContextManager.js +607 -343
  558. package/dist/Utils/proxySandbox/index.js +554 -267
  559. package/dist/Utils/proxySandbox/types.js +187 -52
  560. package/dist/Utils/scrollTo.js +48 -56
  561. package/dist/Utils/throttleByAnimationFrame.js +46 -20
  562. package/dist/WelcomeMessage/index.js +106 -58
  563. package/dist/WelcomeMessage/style.js +80 -55
  564. package/dist/Workspace/Browser/index.js +102 -40
  565. package/dist/Workspace/Browser/style.js +62 -33
  566. package/dist/Workspace/File/DataSourceStrategy.js +419 -217
  567. package/dist/Workspace/File/FileComponent.js +1004 -791
  568. package/dist/Workspace/File/FileTypeProcessor.js +337 -184
  569. package/dist/Workspace/File/PreviewComponent.js +472 -532
  570. package/dist/Workspace/File/index.js +3 -10
  571. package/dist/Workspace/File/style.js +397 -424
  572. package/dist/Workspace/File/utils.js +160 -106
  573. package/dist/Workspace/HtmlPreview/index.js +238 -137
  574. package/dist/Workspace/HtmlPreview/style.js +99 -77
  575. package/dist/Workspace/RealtimeFollow/index.js +411 -413
  576. package/dist/Workspace/RealtimeFollow/style.js +299 -303
  577. package/dist/Workspace/Task/index.js +53 -35
  578. package/dist/Workspace/Task/style.js +99 -73
  579. package/dist/Workspace/index.js +332 -254
  580. package/dist/Workspace/style.js +165 -146
  581. package/dist/Workspace/types.js +471 -252
  582. package/dist/Workspace/utils/codeLanguageUtils.js +148 -129
  583. package/dist/Workspace/utils.js +28 -20
  584. package/dist/index.js +27 -17
  585. package/package.json +3 -2
@@ -1,661 +1,1076 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
1
+ /* eslint-disable @typescript-eslint/no-loop-func */ /* eslint-disable no-case-declarations */ /* eslint-disable no-param-reassign */ /* eslint-disable @typescript-eslint/no-use-before-define */ 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_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function _define_property(obj, key, value) {
10
+ if (key in obj) {
11
+ Object.defineProperty(obj, key, {
12
+ value: value,
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true
16
+ });
17
+ } else {
18
+ obj[key] = value;
16
19
  }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
- // src/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.ts
20
+ return obj;
21
+ }
22
+ function _iterable_to_array(iter) {
23
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
24
+ }
25
+ function _non_iterable_spread() {
26
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27
+ }
28
+ function _object_spread(target) {
29
+ for(var i = 1; i < arguments.length; i++){
30
+ var source = arguments[i] != null ? arguments[i] : {};
31
+ var ownKeys = Object.keys(source);
32
+ if (typeof Object.getOwnPropertySymbols === "function") {
33
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
34
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35
+ }));
36
+ }
37
+ ownKeys.forEach(function(key) {
38
+ _define_property(target, key, source[key]);
39
+ });
40
+ }
41
+ return target;
42
+ }
43
+ function ownKeys(object, enumerableOnly) {
44
+ var keys = Object.keys(object);
45
+ if (Object.getOwnPropertySymbols) {
46
+ var symbols = Object.getOwnPropertySymbols(object);
47
+ if (enumerableOnly) {
48
+ symbols = symbols.filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
50
+ });
51
+ }
52
+ keys.push.apply(keys, symbols);
53
+ }
54
+ return keys;
55
+ }
56
+ function _object_spread_props(target, source) {
57
+ source = source != null ? source : {};
58
+ if (Object.getOwnPropertyDescriptors) {
59
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
60
+ } else {
61
+ ownKeys(Object(source)).forEach(function(key) {
62
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
63
+ });
64
+ }
65
+ return target;
66
+ }
67
+ function _to_consumable_array(arr) {
68
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
69
+ }
70
+ function _type_of(obj) {
71
+ "@swc/helpers - typeof";
72
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
73
+ }
74
+ function _unsupported_iterable_to_array(o, minLen) {
75
+ if (!o) return;
76
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
77
+ var n = Object.prototype.toString.call(o).slice(8, -1);
78
+ if (n === "Object" && o.constructor) n = o.constructor.name;
79
+ if (n === "Map" || n === "Set") return Array.from(n);
80
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
81
+ }
22
82
  import { Node } from "slate";
23
83
  import stringWidth from "string-width";
24
84
  import { getMediaType } from "../utils/dom";
25
- var inlineNode = /* @__PURE__ */ new Set(["break"]);
26
- var tryPluginConversion = (node, preString, parent, plugins) => {
27
- var _a;
28
- if (!(plugins == null ? void 0 : plugins.length))
85
+ var inlineNode = new Set([
86
+ 'break'
87
+ ]);
88
+ /**
89
+ * 尝试使用插件转换节点
90
+ */ var tryPluginConversion = function(node, preString, parent, plugins) {
91
+ if (!(plugins === null || plugins === void 0 ? void 0 : plugins.length)) return null;
92
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
93
+ try {
94
+ for(var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
95
+ var plugin = _step.value;
96
+ var _plugin_toMarkdown;
97
+ var rule = (_plugin_toMarkdown = plugin.toMarkdown) === null || _plugin_toMarkdown === void 0 ? void 0 : _plugin_toMarkdown.find(function(r) {
98
+ return r.match(node);
99
+ });
100
+ if (!rule) continue;
101
+ var converted = rule.convert(node);
102
+ return convertPluginNode(converted, preString, parent, plugins);
103
+ }
104
+ } catch (err) {
105
+ _didIteratorError = true;
106
+ _iteratorError = err;
107
+ } finally{
108
+ try {
109
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
110
+ _iterator.return();
111
+ }
112
+ } finally{
113
+ if (_didIteratorError) {
114
+ throw _iteratorError;
115
+ }
116
+ }
117
+ }
29
118
  return null;
30
- for (const plugin of plugins) {
31
- const rule = (_a = plugin.toMarkdown) == null ? void 0 : _a.find((r) => r.match(node));
32
- if (!rule)
33
- continue;
34
- const converted = rule.convert(node);
35
- return convertPluginNode(converted, preString, parent, plugins);
36
- }
37
- return null;
38
119
  };
39
- var convertPluginNode = (converted, preString, parent, plugins) => {
40
- switch (converted.type) {
41
- case "code":
42
- return convertCodeNode(converted, preString);
43
- case "blockquote":
44
- return convertBlockquoteNode(converted, preString, parent, plugins);
45
- case "paragraph":
46
- return convertParagraphNode(converted, preString, parent, plugins);
47
- case "heading":
48
- return convertHeadingNode(converted, preString, parent, plugins);
49
- case "text":
50
- return converted.value || "";
51
- default:
52
- return "";
53
- }
120
+ /**
121
+ * 转换插件节点为 Markdown 字符串
122
+ */ var convertPluginNode = function(converted, preString, parent, plugins) {
123
+ switch(converted.type){
124
+ case 'code':
125
+ return convertCodeNode(converted, preString);
126
+ case 'blockquote':
127
+ return convertBlockquoteNode(converted, preString, parent, plugins);
128
+ case 'paragraph':
129
+ return convertParagraphNode(converted, preString, parent, plugins);
130
+ case 'heading':
131
+ return convertHeadingNode(converted, preString, parent, plugins);
132
+ case 'text':
133
+ return converted.value || '';
134
+ default:
135
+ return '';
136
+ }
54
137
  };
55
- var convertCodeNode = (codeNode, preString) => {
56
- const language = codeNode.lang || "";
57
- const value = codeNode.value || "";
58
- if (!(value == null ? void 0 : value.trim())) {
59
- return `${preString}\`\`\`${language}
60
- ${preString}\`\`\``;
61
- }
62
- const codeLines = value.split("\n");
63
- const indentedCode = codeLines.map((line, index) => {
64
- const isFirstOrLast = index === 0 || index === codeLines.length - 1;
65
- return isFirstOrLast ? line : preString + line;
66
- }).join("\n");
67
- return `${preString}\`\`\`${language}
68
- ${indentedCode}
69
- ${preString}\`\`\``;
138
+ /**
139
+ * 转换代码节点
140
+ */ var convertCodeNode = function(codeNode, preString) {
141
+ var language = codeNode.lang || '';
142
+ var value = codeNode.value || '';
143
+ if (!(value === null || value === void 0 ? void 0 : value.trim())) {
144
+ return "".concat(preString, "```").concat(language, "\n").concat(preString, "```");
145
+ }
146
+ var codeLines = value.split('\n');
147
+ var indentedCode = codeLines.map(function(line, index) {
148
+ var isFirstOrLast = index === 0 || index === codeLines.length - 1;
149
+ return isFirstOrLast ? line : preString + line;
150
+ }).join('\n');
151
+ return "".concat(preString, "```").concat(language, "\n").concat(indentedCode, "\n").concat(preString, "```");
70
152
  };
71
- var convertBlockquoteNode = (blockquoteNode, preString, parent, plugins) => {
72
- return "> " + parserSlateNodeToMarkdown(
73
- blockquoteNode.children || [],
74
- preString,
75
- [...parent, __spreadProps(__spreadValues({}, blockquoteNode), { converted: true })],
76
- plugins
77
- );
153
+ /**
154
+ * 转换引用节点
155
+ */ var convertBlockquoteNode = function(blockquoteNode, preString, parent, plugins) {
156
+ return '> ' + parserSlateNodeToMarkdown(blockquoteNode.children || [], preString, _to_consumable_array(parent).concat([
157
+ _object_spread_props(_object_spread({}, blockquoteNode), {
158
+ converted: true
159
+ })
160
+ ]), plugins);
78
161
  };
79
- var convertParagraphNode = (paragraphNode, preString, parent, plugins) => {
80
- return preString + parserSlateNodeToMarkdown(
81
- paragraphNode.children || [],
82
- preString,
83
- [...parent, __spreadProps(__spreadValues({}, paragraphNode), { converted: true })],
84
- plugins
85
- );
162
+ /**
163
+ * 转换段落节点
164
+ */ var convertParagraphNode = function(paragraphNode, preString, parent, plugins) {
165
+ return preString + parserSlateNodeToMarkdown(paragraphNode.children || [], preString, _to_consumable_array(parent).concat([
166
+ _object_spread_props(_object_spread({}, paragraphNode), {
167
+ converted: true
168
+ })
169
+ ]), plugins);
86
170
  };
87
- var convertHeadingNode = (headingNode, preString, parent, plugins) => {
88
- const level = headingNode.depth || 1;
89
- const content = parserSlateNodeToMarkdown(
90
- headingNode.children || [],
91
- preString,
92
- [...parent, __spreadProps(__spreadValues({}, headingNode), { converted: true })],
93
- plugins
94
- );
95
- return "#".repeat(level) + " " + content.replace(/\n+$/, "");
171
+ /**
172
+ * 转换标题节点
173
+ */ var convertHeadingNode = function(headingNode, preString, parent, plugins) {
174
+ var level = headingNode.depth || 1;
175
+ var content = parserSlateNodeToMarkdown(headingNode.children || [], preString, _to_consumable_array(parent).concat([
176
+ _object_spread_props(_object_spread({}, headingNode), {
177
+ converted: true
178
+ })
179
+ ]), plugins);
180
+ return '#'.repeat(level) + ' ' + content.replace(/\n+$/, '');
96
181
  };
97
- var parserNode = (node, preString = "", parent, plugins) => {
98
- let str = "";
99
- if (!node)
182
+ /**
183
+ * 解析单个 Slate 节点并转换为对应的 Markdown 字符串
184
+ *
185
+ * @param node - 要解析的 Slate 节点,包含 type、children、value 等属性
186
+ * @param preString - 前缀字符串,用于处理缩进和格式化,默认为空字符串
187
+ * @param parent - 父节点数组,用于上下文信息和嵌套处理,默认为空数组
188
+ * @param plugins - 可选的插件数组,用于自定义转换逻辑
189
+ * @returns 解析后的 Markdown 字符串
190
+ *
191
+ * @description
192
+ * 该函数是 Slate 节点到 Markdown 转换的核心处理器,支持以下节点类型:
193
+ *
194
+ * **容器节点:**
195
+ * - `card`: 卡片容器,递归处理子节点
196
+ * - `paragraph`: 段落节点,添加前缀并处理子节点
197
+ * - `blockquote`: 引用块,递归处理子节点
198
+ * - `list`: 列表容器,递归处理列表项
199
+ * - `list-item`: 列表项,递归处理子节点
200
+ *
201
+ * **标题节点:**
202
+ * - `head`: 标题节点,根据 level 生成对应级别的 Markdown 标题
203
+ *
204
+ * **代码节点:**
205
+ * - `code`: 代码块,支持三种模式:
206
+ * - HTML 渲染模式(language='html' && render=true)
207
+ * - Frontmatter 模式(frontmatter=true)
208
+ * - 普通代码块模式(默认)
209
+ *
210
+ * **媒体节点:**
211
+ * - `image`: 图片节点,支持 width、height、block 参数,URL 参数化
212
+ * - `media`: 多媒体节点,根据类型生成 video、img 或 iframe 标签
213
+ * - `attach`: 附件节点,生成下载链接
214
+ *
215
+ * **表格节点:**
216
+ * - `table`: 表格节点,调用 table 函数处理
217
+ * - `chart`: 图表节点,以表格形式渲染
218
+ * - `column-group`: 列组节点,以表格形式渲染
219
+ * - `description`: 描述列表,转换为表格格式
220
+ *
221
+ * **其他节点:**
222
+ * - `schema`: 模式定义,生成 schema 代码块
223
+ * - `link-card`: 链接卡片,生成 Markdown 链接格式
224
+ * - `hr`: 水平分割线,生成 `***`
225
+ * - `break`: 换行节点,生成 `<br/>` 标签
226
+ * - `footnoteDefinition`: 脚注定义,生成脚注引用格式
227
+ * - 文本节点:调用 composeText 函数处理文本样式
228
+ *
229
+ * **空节点:**
230
+ * - `card-before`, `card-after`: 卡片前后占位符,不输出内容
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * // 解析段落节点
235
+ * const paragraphNode = { type: 'paragraph', children: [{ text: 'Hello' }] };
236
+ * const result = parserNode(paragraphNode, '', []);
237
+ * // 输出: "Hello"
238
+ *
239
+ * // 解析标题节点
240
+ * const headNode = { type: 'head', level: 2, children: [{ text: 'Title' }] };
241
+ * const result = parserNode(headNode, '', []);
242
+ * // 输出: "## Title"
243
+ *
244
+ * // 解析代码块
245
+ * const codeNode = { type: 'code', language: 'javascript', value: 'console.log("hello");' };
246
+ * const result = parserNode(codeNode, '', []);
247
+ * // 输出: "```javascript\nconsole.log(\"hello\");\n```"
248
+ * ```
249
+ */ var parserNode = function(node) {
250
+ var preString = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '', parent = arguments.length > 2 ? arguments[2] : void 0, plugins = arguments.length > 3 ? arguments[3] : void 0;
251
+ var str = '';
252
+ if (!node) return str;
253
+ // 首先尝试使用插件处理
254
+ var pluginResult = tryPluginConversion(node, preString, parent, plugins);
255
+ if (pluginResult !== null) {
256
+ return pluginResult;
257
+ }
258
+ switch(node.type){
259
+ case 'card-before':
260
+ case 'card-after':
261
+ break;
262
+ case 'card':
263
+ str += handleCard(node, preString, parent, plugins);
264
+ break;
265
+ case 'paragraph':
266
+ str += handleParagraph(node, preString, parent, plugins);
267
+ break;
268
+ case 'head':
269
+ str += handleHead(node, preString, parent, plugins);
270
+ break;
271
+ case 'code':
272
+ case 'apaasify':
273
+ str += handleCode(node, preString);
274
+ break;
275
+ case 'attach':
276
+ str += handleAttach(node);
277
+ break;
278
+ case 'blockquote':
279
+ str += handleBlockquote(node, preString, parent, plugins);
280
+ break;
281
+ case 'image':
282
+ str += handleImage(node);
283
+ break;
284
+ case 'media':
285
+ str += handleMedia(node);
286
+ break;
287
+ case 'list':
288
+ str += '\n' + handleList(node, preString, parent, plugins) + '\n\n';
289
+ break;
290
+ case 'list-item':
291
+ str += handleListItem(node, preString, parent, plugins);
292
+ break;
293
+ case 'table':
294
+ str += table(node, parent, plugins);
295
+ break;
296
+ case 'chart':
297
+ str += table(node, parent, plugins);
298
+ break;
299
+ case 'schema':
300
+ str += handleSchema(node);
301
+ break;
302
+ case 'link-card':
303
+ str += handleLinkCard(node);
304
+ break;
305
+ case 'hr':
306
+ str += handleHr(preString);
307
+ break;
308
+ case 'break':
309
+ str += handleBreak(preString);
310
+ break;
311
+ case 'footnoteDefinition':
312
+ str += handleFootnoteDefinition(node);
313
+ break;
314
+ default:
315
+ str += handleDefault(node, parent);
316
+ break;
317
+ }
100
318
  return str;
101
- const pluginResult = tryPluginConversion(node, preString, parent, plugins);
102
- if (pluginResult !== null) {
103
- return pluginResult;
104
- }
105
- switch (node.type) {
106
- case "card-before":
107
- case "card-after":
108
- break;
109
- case "card":
110
- str += handleCard(node, preString, parent, plugins);
111
- break;
112
- case "paragraph":
113
- str += handleParagraph(node, preString, parent, plugins);
114
- break;
115
- case "head":
116
- str += handleHead(node, preString, parent, plugins);
117
- break;
118
- case "code":
119
- case "apaasify":
120
- str += handleCode(node, preString);
121
- break;
122
- case "attach":
123
- str += handleAttach(node);
124
- break;
125
- case "blockquote":
126
- str += handleBlockquote(node, preString, parent, plugins);
127
- break;
128
- case "image":
129
- str += handleImage(node);
130
- break;
131
- case "media":
132
- str += handleMedia(node);
133
- break;
134
- case "list":
135
- str += "\n" + handleList(node, preString, parent, plugins) + "\n\n";
136
- break;
137
- case "list-item":
138
- str += handleListItem(node, preString, parent, plugins);
139
- break;
140
- case "table":
141
- str += table(node, parent, plugins);
142
- break;
143
- case "chart":
144
- str += table(node, parent, plugins);
145
- break;
146
- case "schema":
147
- str += handleSchema(node);
148
- break;
149
- case "link-card":
150
- str += handleLinkCard(node);
151
- break;
152
- case "hr":
153
- str += handleHr(preString);
154
- break;
155
- case "break":
156
- str += handleBreak(preString);
157
- break;
158
- case "footnoteDefinition":
159
- str += handleFootnoteDefinition(node);
160
- break;
161
- default:
162
- str += handleDefault(node, parent);
163
- break;
164
- }
165
- return str;
166
319
  };
167
- var parserSlateNodeToMarkdown = (tree, preString = "", parent = [{ root: true }], plugins) => {
168
- var _a, _b, _c, _d, _e;
169
- let str = "";
170
- for (let i = 0; i < tree.length; i++) {
171
- const node = tree[i];
172
- if (node.otherProps && Object.keys(node.otherProps).length) {
173
- let configProps = __spreadValues({}, node.otherProps);
174
- delete configProps["columns"];
175
- delete configProps["dataSource"];
176
- if (node.type === "link-card") {
177
- configProps.type = "card";
178
- configProps.url = encodeURI(node == null ? void 0 : node.url);
179
- configProps.name = node.name || node.title || configProps.name;
180
- configProps.description = node.description || configProps.description;
181
- configProps.icon = node.icon || configProps.icon;
182
- }
183
- Object.keys(configProps).forEach((key) => {
184
- if (typeof configProps[key] === "object" && configProps[key]) {
185
- if (Array.isArray(configProps[key]) && configProps[key].length === 0) {
186
- delete configProps[key];
187
- return;
188
- }
189
- if (Object.keys(configProps[key]).length === 0) {
190
- delete configProps[key];
191
- return;
192
- }
320
+ /**
321
+ * Slate 节点树解析为 Markdown 字符串。
322
+ *
323
+ * @param tree - Slate 节点树。
324
+ * @param preString - 前缀字符串,默认为空字符串。
325
+ * @param parent - 父节点数组,默认为包含一个根节点的数组。
326
+ * @returns 解析后的 Markdown 字符串。
327
+ *
328
+ * 该函数遍历 Slate 节点树,并根据节点类型和属性生成相应的 Markdown 字符串。
329
+ * 对于具有其他属性的节点,会将这些属性转换为 JSON 字符串并作为注释插入。
330
+ * 对于列表项、引用块、段落等不同类型的节点,会根据其特定的格式生成相应的 Markdown。
331
+ */ export var parserSlateNodeToMarkdown = function(tree) {
332
+ var _loop = function(i) {
333
+ var _tree_, _tree_1;
334
+ var node = tree[i];
335
+ if (node.otherProps && Object.keys(node.otherProps).length) {
336
+ var configProps = _object_spread({}, node.otherProps);
337
+ delete configProps['columns'];
338
+ delete configProps['dataSource'];
339
+ if (node.type === 'link-card') {
340
+ configProps.type = 'card';
341
+ configProps.url = encodeURI(node === null || node === void 0 ? void 0 : node.url);
342
+ configProps.name = node.name || node.title || configProps.name;
343
+ configProps.description = node.description || configProps.description;
344
+ configProps.icon = node.icon || configProps.icon;
345
+ }
346
+ Object.keys(configProps).forEach(function(key) {
347
+ if (_type_of(configProps[key]) === 'object' && configProps[key]) {
348
+ if (Array.isArray(configProps[key]) && configProps[key].length === 0) {
349
+ delete configProps[key];
350
+ return;
351
+ }
352
+ if (Object.keys(configProps[key]).length === 0) {
353
+ delete configProps[key];
354
+ return;
355
+ }
356
+ }
357
+ });
358
+ // 只有当 configProps 不为空对象时才生成注释
359
+ if (Object.keys(configProps).length > 0) {
360
+ var propsToSerialize = node.type === 'chart' && configProps.config ? configProps.config : configProps;
361
+ str += "<!--".concat(JSON.stringify(propsToSerialize), "-->\n");
362
+ }
193
363
  }
194
- });
195
- if (Object.keys(configProps).length > 0) {
196
- const propsToSerialize = node.type === "chart" && configProps.config ? configProps.config : configProps;
197
- str += `<!--${JSON.stringify(propsToSerialize)}-->
198
- `;
199
- }
200
- }
201
- const p = parent.at(-1) || {};
202
- if (p.type === "list-item") {
203
- str += parserNode(node, "", parent, plugins);
204
- } else if (p.type === "blockquote") {
205
- str += parserNode(node, preString + "> ", parent, plugins);
206
- if (i !== tree.length - 1) {
207
- str += "\n" + preString + "> ";
208
- }
209
- } else if (node.type === "blockquote") {
210
- const blockquoteContent = node.children.map((child) => {
211
- if (child.type === "blockquote") {
212
- return parserNode(child, "> ", [...parent, node], plugins);
364
+ var p = parent.at(-1) || {};
365
+ if (p.type === 'list-item') {
366
+ str += parserNode(node, '', parent, plugins);
367
+ // if (i !== tree.length - 1) {
368
+ // str += '\n';
369
+ // }
370
+ } else if (p.type === 'blockquote') {
371
+ str += parserNode(node, preString + '> ', parent, plugins);
372
+ if (i !== tree.length - 1) {
373
+ str += '\n' + preString + '> ';
374
+ }
375
+ } else if (node.type === 'blockquote') {
376
+ // Handle blockquotes
377
+ var blockquoteContent = node.children.map(function(child) {
378
+ if (child.type === 'blockquote') {
379
+ // For nested blockquotes, increase the level
380
+ return parserNode(child, '> ', _to_consumable_array(parent).concat([
381
+ node
382
+ ]), plugins);
383
+ } else {
384
+ // For regular content, maintain the current level
385
+ var content = parserNode(child, '', _to_consumable_array(parent).concat([
386
+ node
387
+ ]), plugins);
388
+ if (!content.trim()) {
389
+ // For empty lines, just add the blockquote marker
390
+ return '>';
391
+ }
392
+ // For regular content, add blockquote marker and handle multi-line content
393
+ return content.split('\n').map(function(line) {
394
+ return '> ' + line;
395
+ }).join('\n');
396
+ }
397
+ }).join('\n');
398
+ str += blockquoteContent;
399
+ } else if (node.type === 'list') {
400
+ // Handle lists
401
+ var listItems = node.children.map(function(item, index) {
402
+ var prefix = node.order ? "".concat(index + (node.start || 1), ".") : '-';
403
+ return prefix + ' ' + parserNode(item, '', _to_consumable_array(parent).concat([
404
+ node
405
+ ]), plugins).trimEnd();
406
+ }).join('\n');
407
+ if (listItems.trim()) {
408
+ str += '\n\n';
409
+ str += listItems;
410
+ if (i !== tree.length - 1) {
411
+ str += '\n\n';
412
+ }
413
+ }
414
+ } else if (node.type === 'paragraph' && ((_tree_ = tree[i - 1]) === null || _tree_ === void 0 ? void 0 : _tree_.type) === 'list' && ((_tree_1 = tree[i + 1]) === null || _tree_1 === void 0 ? void 0 : _tree_1.type) === 'list') {
415
+ var _Node_string;
416
+ if (!((_Node_string = Node.string(node)) === null || _Node_string === void 0 ? void 0 : _Node_string.replace(/\s|\t/g, ''))) {
417
+ str += '<br/>\n\n';
418
+ } else {
419
+ var _parserNode;
420
+ str += preString + ((_parserNode = parserNode(node, preString, parent, plugins)) === null || _parserNode === void 0 ? void 0 : _parserNode.replace(/^[\s\t]+/g, '')) + '\n\n';
421
+ }
213
422
  } else {
214
- const content = parserNode(child, "", [...parent, node], plugins);
215
- if (!content.trim()) {
216
- return ">";
217
- }
218
- return content.split("\n").map((line) => "> " + line).join("\n");
423
+ str += parserNode(node, preString, parent, plugins);
424
+ // Special handling for different node types
425
+ if (node.type && !inlineNode.has(node.type)) {
426
+ // Tables should not have extra newlines between rows
427
+ if (node.type === 'table-row') {
428
+ str += '\n';
429
+ } else if (node.type === 'code' || node.type === 'media') {
430
+ str += '\n\n';
431
+ } else if (node.type === 'list') {
432
+ str += '\n\n';
433
+ } else if (i !== tree.length - 1) {
434
+ // Card 节点不添加额外的换行符,让其子节点自行处理
435
+ if (node.type !== 'card') {
436
+ str += '\n\n';
437
+ }
438
+ }
439
+ }
219
440
  }
220
- }).join("\n");
221
- str += blockquoteContent;
222
- } else if (node.type === "list") {
223
- const listItems = node.children.map((item, index) => {
224
- const prefix = node.order ? `${index + (node.start || 1)}.` : "-";
225
- return prefix + " " + parserNode(item, "", [...parent, node], plugins).trimEnd();
226
- }).join("\n");
227
- if (listItems.trim()) {
228
- str += "\n\n";
229
- str += listItems;
230
- if (i !== tree.length - 1) {
231
- str += "\n\n";
441
+ };
442
+ var preString = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '', parent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [
443
+ {
444
+ root: true
232
445
  }
233
- }
234
- } else if (node.type === "paragraph" && ((_a = tree[i - 1]) == null ? void 0 : _a.type) === "list" && ((_b = tree[i + 1]) == null ? void 0 : _b.type) === "list") {
235
- if (!((_c = Node.string(node)) == null ? void 0 : _c.replace(/\s|\t/g, ""))) {
236
- str += "<br/>\n\n";
237
- } else {
238
- str += preString + ((_d = parserNode(node, preString, parent, plugins)) == null ? void 0 : _d.replace(
239
- /^[\s\t]+/g,
240
- ""
241
- )) + "\n\n";
242
- }
243
- } else {
244
- str += parserNode(node, preString, parent, plugins);
245
- if (node.type && !inlineNode.has(node.type)) {
246
- if (node.type === "table-row") {
247
- str += "\n";
248
- } else if (node.type === "code" || node.type === "media") {
249
- str += "\n\n";
250
- } else if (node.type === "list") {
251
- str += "\n\n";
252
- } else if (i !== tree.length - 1) {
253
- if (node.type !== "card") {
254
- str += "\n\n";
255
- }
446
+ ], plugins = arguments.length > 3 ? arguments[3] : void 0;
447
+ var str = '';
448
+ for(var i = 0; i < tree.length; i++)_loop(i);
449
+ // Clean up trailing newlines and handle special cases
450
+ if (str) {
451
+ var _parent_;
452
+ // Remove all trailing newlines first
453
+ str = str.replace(/\n+$/, '');
454
+ // Only add newlines in specific cases
455
+ var lastNode = tree[tree.length - 1];
456
+ var isRoot = parent.length === 1 && parent[0].root;
457
+ var isConverted = lastNode === null || lastNode === void 0 ? void 0 : lastNode.converted;
458
+ var parentType = (_parent_ = parent[parent.length - 1]) === null || _parent_ === void 0 ? void 0 : _parent_.type;
459
+ var nextNode = tree[tree.indexOf(lastNode) + 1];
460
+ var isLastNodeInParent = !nextNode;
461
+ if (lastNode && lastNode.type && !isConverted) {
462
+ if (parentType === 'blockquote') {
463
+ // Only add trailing blockquote marker if this is not the last node in a nested blockquote
464
+ if (!isLastNodeInParent || parent.some(function(p) {
465
+ return p.type === 'blockquote' && p !== parent[parent.length - 1];
466
+ })) {
467
+ str += '\n> ';
468
+ }
469
+ } else if (lastNode.type === 'table') {
470
+ // Do not add any newlines for tables and description lists
471
+ str = str.replace(/\n+$/, '');
472
+ } else if (lastNode.type === 'code' || lastNode.type === 'media') {
473
+ // Add double newlines for code blocks and media, but not if it's the last node
474
+ if (!isLastNodeInParent) {
475
+ str += '\n\n';
476
+ }
477
+ } else if (!inlineNode.has(lastNode.type) && !isRoot && ![
478
+ 'list-item',
479
+ 'table-row'
480
+ ].includes(lastNode.type)) {
481
+ // Don't add newlines for list items and table rows
482
+ // Only add newlines if the next node is not a heading
483
+ if (!(lastNode.type === 'head' && (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'head')) {
484
+ str += '\n\n';
485
+ }
486
+ }
256
487
  }
257
- }
258
488
  }
259
- }
260
- if (str) {
261
- str = str.replace(/\n+$/, "");
262
- const lastNode = tree[tree.length - 1];
263
- const isRoot = parent.length === 1 && parent[0].root;
264
- const isConverted = lastNode == null ? void 0 : lastNode.converted;
265
- const parentType = (_e = parent[parent.length - 1]) == null ? void 0 : _e.type;
266
- const nextNode = tree[tree.indexOf(lastNode) + 1];
267
- const isLastNodeInParent = !nextNode;
268
- if (lastNode && lastNode.type && !isConverted) {
269
- if (parentType === "blockquote") {
270
- if (!isLastNodeInParent || parent.some(
271
- (p) => p.type === "blockquote" && p !== parent[parent.length - 1]
272
- )) {
273
- str += "\n> ";
274
- }
275
- } else if (lastNode.type === "table") {
276
- str = str.replace(/\n+$/, "");
277
- } else if (lastNode.type === "code" || lastNode.type === "media") {
278
- if (!isLastNodeInParent) {
279
- str += "\n\n";
280
- }
281
- } else if (!inlineNode.has(lastNode.type) && !isRoot && !["list-item", "table-row"].includes(lastNode.type)) {
282
- if (!(lastNode.type === "head" && (nextNode == null ? void 0 : nextNode.type) === "head")) {
283
- str += "\n\n";
284
- }
285
- }
489
+ // Clean up multiple consecutive newlines
490
+ str = str.replace(/\n{3,}/g, '\n\n');
491
+ // Remove leading newlines for root level content
492
+ if (parent.length === 1 && parent[0].root) {
493
+ str = str.replace(/^\n+/, '');
286
494
  }
287
- }
288
- str = str.replace(/\n{3,}/g, "\n\n");
289
- if (parent.length === 1 && parent[0].root) {
290
- str = str.replace(/^\n+/, "");
291
- }
292
- return str;
495
+ return str;
293
496
  };
294
- var isMix = (t) => {
295
- return Object.keys(t).filter(
296
- (key) => ["bold", "code", "italic", "strikethrough"].includes(key)
297
- ).length > 1;
497
+ export var isMix = function(t) {
498
+ return Object.keys(t).filter(function(key) {
499
+ return [
500
+ 'bold',
501
+ 'code',
502
+ 'italic',
503
+ 'strikethrough'
504
+ ].includes(key);
505
+ }).length > 1;
298
506
  };
299
- var textHtml = (t) => {
300
- let str = t.text || "";
301
- if (t.highColor)
302
- str = `<span style="color:${t.highColor}">${str}</span>`;
303
- if (t.code)
304
- str = `<code>${str}</code>`;
305
- if (t.italic)
306
- str = `<i>${str}</i>`;
307
- if (t.bold)
308
- str = `<b>${str}</b>`;
309
- if (t.strikethrough)
310
- str = `<del>${str}</del>`;
311
- if (t == null ? void 0 : t.url)
312
- str = `<a href="${t == null ? void 0 : t.url}">${str}</a>`;
313
- if ((t == null ? void 0 : t.identifier) || (t == null ? void 0 : t.fnc))
314
- str = `[^${str}]`;
315
- return str;
507
+ /**
508
+ * Converts a Text object to an HTML string with appropriate formatting.
509
+ *
510
+ * @param {Text} t - The Text object to be converted.
511
+ * @returns {string} - The formatted HTML string.
512
+ *
513
+ * The function applies the following HTML tags based on the properties of the Text object:
514
+ * - `<span style="color:{highColor}">` if `highColor` is defined.
515
+ * - `<code>` if `code` is true.
516
+ * - `<i>` if `italic` is true.
517
+ * - `<b>` if `bold` is true.
518
+ * - `<del>` if `strikethrough` is true.
519
+ * - `<a href="{url}">` if `url` is defined.
520
+ */ var textHtml = function(t) {
521
+ var str = t.text || '';
522
+ if (t.highColor) str = '<span style="color:'.concat(t.highColor, '">').concat(str, "</span>");
523
+ if (t.code) str = "<code>".concat(str, "</code>");
524
+ if (t.italic) str = "<i>".concat(str, "</i>");
525
+ if (t.bold) str = "<b>".concat(str, "</b>");
526
+ if (t.strikethrough) str = "<del>".concat(str, "</del>");
527
+ if (t === null || t === void 0 ? void 0 : t.url) str = '<a href="'.concat(t === null || t === void 0 ? void 0 : t.url, '">').concat(str, "</a>");
528
+ if ((t === null || t === void 0 ? void 0 : t.identifier) || (t === null || t === void 0 ? void 0 : t.fnc)) str = "[^".concat(str, "]");
529
+ return str;
316
530
  };
317
- var textStyle = (t) => {
318
- var _a, _b, _c;
319
- if (!t.text && !t.tag)
320
- return "";
321
- let str = ((_a = t == null ? void 0 : t.text) == null ? void 0 : _a.replace(new RegExp("(?<!\\\\)\\\\", "g"), "\\").replace(/\n/g, " \n")) || "";
322
- let preStr = "", afterStr = "";
323
- if (t.code || t.bold || t.strikethrough || t.italic) {
324
- preStr = ((_b = str.match(/^\s+/)) == null ? void 0 : _b[0]) || "";
325
- afterStr = ((_c = str.match(/\s+$/)) == null ? void 0 : _c[0]) || "";
326
- str = str.trim();
327
- }
328
- if (t.code && !t.tag) {
329
- str = `\`${str}\``;
330
- } else if (t.tag) {
331
- if (t.value) {
332
- str = `\`${`\${placeholder:${(t == null ? void 0 : t.placeholder) || "-"},value:${t.value}}` || ""}\``;
531
+ /**
532
+ * 将文本对象格式化为带有适当样式的 Markdown 字符串
533
+ *
534
+ * @param t - 要格式化的文本对象
535
+ * @returns 格式化后的 Markdown 字符串
536
+ *
537
+ * 该函数根据文本对象的属性应用以下 Markdown 样式:
538
+ * - `code`: 使用反引号(`)包裹文本
539
+ * - `italic`: 使用单个星号(*)包裹文本
540
+ * - `bold`: 使用双星号(**)包裹文本
541
+ * - `strikethrough`: 使用双波浪线(~~)包裹文本
542
+ *
543
+ * 此外,还会:
544
+ * - 转义反斜杠
545
+ * - 将换行符转换为 Markdown 换行符
546
+ * - 保留文本前后的空白字符
547
+ */ var textStyle = function(t) {
548
+ var _t_text;
549
+ if (!t.text && !t.tag) return '';
550
+ var str = (t === null || t === void 0 ? void 0 : (_t_text = t.text) === null || _t_text === void 0 ? void 0 : _t_text.replace(RegExp("(?<!\\\\)\\\\", "g"), '\\').replace(/\n/g, ' \n')) || '';
551
+ var preStr = '', afterStr = '';
552
+ // Extract whitespace
553
+ if (t.code || t.bold || t.strikethrough || t.italic) {
554
+ var _str_match, _str_match1;
555
+ preStr = ((_str_match = str.match(/^\s+/)) === null || _str_match === void 0 ? void 0 : _str_match[0]) || '';
556
+ afterStr = ((_str_match1 = str.match(/\s+$/)) === null || _str_match1 === void 0 ? void 0 : _str_match1[0]) || '';
557
+ str = str.trim();
558
+ }
559
+ // Apply formats in a consistent order:
560
+ // 1. Code (most specific)
561
+ // 2. Bold (strong emphasis)
562
+ // 3. Italic (emphasis)
563
+ // 4. Strikethrough (modification)
564
+ if (t.code && !t.tag) {
565
+ str = "`".concat(str, "`");
566
+ } else if (t.tag) {
567
+ if (t.value) {
568
+ str = "`".concat("${placeholder:".concat((t === null || t === void 0 ? void 0 : t.placeholder) || '-', ",value:").concat(t.value, "}") || '', "`");
569
+ } else {
570
+ str = "`".concat(str || "${placeholder:".concat((t === null || t === void 0 ? void 0 : t.placeholder) || '-', "}") || '', "`");
571
+ }
572
+ }
573
+ // For mixed formats, we want to ensure proper nesting
574
+ if (t.bold && t.italic) {
575
+ str = "***".concat(str, "***"); // Combined bold and italic
333
576
  } else {
334
- str = `\`${str || `\${placeholder:${(t == null ? void 0 : t.placeholder) || "-"}}` || ""}\``;
577
+ if (t.bold) str = "**".concat(str, "**");
578
+ if (t.italic) str = "*".concat(str, "*");
335
579
  }
336
- }
337
- if (t.bold && t.italic) {
338
- str = `***${str}***`;
339
- } else {
340
- if (t.bold)
341
- str = `**${str}**`;
342
- if (t.italic)
343
- str = `*${str}*`;
344
- }
345
- if (t.strikethrough)
346
- str = `~~${str}~~`;
347
- return preStr + str + afterStr;
580
+ if (t.strikethrough) str = "~~".concat(str, "~~");
581
+ // Preserve exact whitespace
582
+ return preStr + str + afterStr;
348
583
  };
349
- var composeText = (t, parent) => {
350
- var _a;
351
- if (!t.text && !t.tag)
352
- return "";
353
- if (t.highColor || t.identifier || t.fnc || t.strikethrough && (t.bold || t.italic || t.code))
354
- return textHtml(t);
355
- const siblings = (_a = parent[parent.length - 1]) == null ? void 0 : _a.children;
356
- const index = siblings == null ? void 0 : siblings.findIndex((n) => n === t);
357
- let str = textStyle(t);
358
- if (t == null ? void 0 : t.url) {
359
- str = `[${t.text}](${encodeURI(t == null ? void 0 : t.url)})`;
360
- } else if (isMix(t) && index !== -1) {
361
- const next = siblings[index + 1];
362
- if (!str.endsWith(" ") && next && !Node.string(next).startsWith(" ")) {
363
- str += " ";
584
+ /**
585
+ * 根据给定的文本节点及其父节点生成格式化的文本字符串
586
+ *
587
+ * @param t - 要处理的文本节点
588
+ * @param parent - 父节点数组,用于上下文信息
589
+ * @returns 处理后的文本字符串。如果文本节点没有内容,返回空字符串
590
+ *
591
+ * 该函数处理不同的文本样式和格式:
592
+ * - 如果文本有 highColor 属性或者同时具有删除线和其他样式(粗体、斜体、代码),返回 HTML 格式的文本
593
+ * - 如果文本有 URL,返回 Markdown 链接格式
594
+ * - 如果文本有多种样式且不在句子末尾,确保单词之间有适当的空格
595
+ *
596
+ * 特殊处理:
597
+ * - 高亮颜色:使用 span 标签和 style 属性
598
+ * - 脚注标识:使用 [^] 语法
599
+ * - 混合样式:确保相邻文本之间的空格正确
600
+ */ var composeText = function(t, parent) {
601
+ var _parent_;
602
+ if (!t.text && !t.tag) return '';
603
+ if (t.highColor || t.identifier || t.fnc || t.strikethrough && (t.bold || t.italic || t.code)) return textHtml(t);
604
+ var siblings = (_parent_ = parent[parent.length - 1]) === null || _parent_ === void 0 ? void 0 : _parent_.children;
605
+ // @ts-ignore
606
+ var index = siblings === null || siblings === void 0 ? void 0 : siblings.findIndex(function(n) {
607
+ return n === t;
608
+ });
609
+ var str = textStyle(t);
610
+ if (t === null || t === void 0 ? void 0 : t.url) {
611
+ str = "[".concat(t.text, "](").concat(encodeURI(t === null || t === void 0 ? void 0 : t.url), ")");
612
+ } else if (isMix(t) && index !== -1) {
613
+ var next = siblings[index + 1];
614
+ if (!str.endsWith(' ') && next && !Node.string(next).startsWith(' ')) {
615
+ str += ' ';
616
+ }
364
617
  }
365
- }
366
- return str;
618
+ return str;
367
619
  };
368
- var table = (el, parent, plugins) => {
369
- var _a, _b, _c, _d;
370
- const children = el.children;
371
- const head = (_a = children[0]) == null ? void 0 : _a.children;
372
- if (!children.length || !head.length)
373
- return "";
374
- const data = new Array(children.length);
375
- let maxColumns = 0;
376
- const tableProcessors = {
377
- default: () => {
378
- let rowIndex = 0;
379
- for (const c of children) {
380
- if (!c)
381
- continue;
382
- const processRow = (cells, processCell) => {
383
- const row = new Array(cells.length);
384
- for (let i = 0; i < cells.length; i++) {
385
- const cell = cells[i];
386
- const content = processCell(cell);
387
- row[i] = content;
388
- }
389
- if (cells.length > 0) {
390
- data[rowIndex] = row;
391
- maxColumns = Math.max(maxColumns, cells.length);
392
- rowIndex++;
393
- }
394
- };
395
- const cellProcessor = (cell) => {
396
- if (cell.type !== "table-cell")
397
- return "";
398
- return cell.children.map((child) => {
399
- if (child.type === "paragraph") {
400
- return parserSlateNodeToMarkdown(
401
- child.children,
402
- "",
403
- [...parent, cell, child],
404
- plugins
405
- );
620
+ /**
621
+ * 将类表格节点结构转换为 Markdown 表格字符串
622
+ *
623
+ * @param el - 表格节点,可以是 TableNode、ColumnNode、DescriptionNode ChartNode 类型
624
+ * @param preString - 前缀字符串,用于在表格每行前添加缩进
625
+ * @param parent - 父节点数组,用于提供上下文信息
626
+ * @param plugins - 可选的插件数组,用于自定义转换逻辑
627
+ * @returns 格式化后的 Markdown 表格字符串
628
+ *
629
+ * 该函数支持以下功能:
630
+ * 1. 列宽处理
631
+ * - 自动计算每列的最大宽度
632
+ * - 使用空格填充单元格以对齐
633
+ *
634
+ * 2. 对齐方式
635
+ * - 左对齐:`:---`
636
+ * - 居中对齐:`:---:`
637
+ * - 右对齐:`---:`
638
+ *
639
+ * 3. 特殊节点处理
640
+ * - column-group:生成带有默认列标题的表格
641
+ * - table/chart:处理标准表格数据
642
+ * - description:将描述列表转换为两行表格
643
+ *
644
+ * 4. 格式化细节
645
+ * - 转义表格分隔符 |
646
+ * - 保持单元格间距一致
647
+ * - 处理空行和空单元格
648
+ *
649
+ * @example
650
+ * 生成的表格格式如下:
651
+ * ```markdown
652
+ * | 列1 | 列2 | 列3 |
653
+ * |:--- |:---:| ---:|
654
+ * | 左对齐 | 居中 | 右对齐 |
655
+ * ```
656
+ */ var table = function(el, parent, plugins) {
657
+ var _children_;
658
+ var children = el.children;
659
+ var head = (_children_ = children[0]) === null || _children_ === void 0 ? void 0 : _children_.children;
660
+ if (!children.length || !head.length) return '';
661
+ var data = new Array(children.length);
662
+ var maxColumns = 0;
663
+ // 使用策略模式处理不同类型的表格
664
+ var tableProcessors = {
665
+ default: function() {
666
+ var rowIndex = 0;
667
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
668
+ try {
669
+ for(var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
670
+ var c = _step.value;
671
+ if (!c) continue;
672
+ var processRow = function(cells, processCell) {
673
+ var row = new Array(cells.length);
674
+ // 处理每个单元格,包括空单元格
675
+ for(var i = 0; i < cells.length; i++){
676
+ var cell = cells[i];
677
+ var content = processCell(cell);
678
+ row[i] = content; // 保持原始位置,不跳过空单元格
679
+ }
680
+ // 只要有单元格存在就添加这一行,即使所有单元格都是空的
681
+ if (cells.length > 0) {
682
+ data[rowIndex] = row;
683
+ maxColumns = Math.max(maxColumns, cells.length);
684
+ rowIndex++;
685
+ }
686
+ };
687
+ var cellProcessor = function(cell) {
688
+ if (cell.type !== 'table-cell') return '';
689
+ // 对于表格单元格,直接提取文本内容,避免段落格式化
690
+ return cell.children.map(function(child) {
691
+ if (child.type === 'paragraph') {
692
+ // 对于段落,直接处理其文本内容
693
+ return parserSlateNodeToMarkdown(child.children, '', _to_consumable_array(parent).concat([
694
+ cell,
695
+ child
696
+ ]), plugins);
697
+ }
698
+ return parserSlateNodeToMarkdown([
699
+ child
700
+ ], '', _to_consumable_array(parent).concat([
701
+ cell
702
+ ]), plugins);
703
+ }).join('').trim();
704
+ };
705
+ if (c.type === 'table-row' && (c === null || c === void 0 ? void 0 : c.children)) {
706
+ processRow(c.children, cellProcessor);
707
+ } else if (c.type === 'table-cell') {
708
+ processRow([
709
+ c
710
+ ], cellProcessor);
711
+ }
712
+ }
713
+ } catch (err) {
714
+ _didIteratorError = true;
715
+ _iteratorError = err;
716
+ } finally{
717
+ try {
718
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
719
+ _iterator.return();
720
+ }
721
+ } finally{
722
+ if (_didIteratorError) {
723
+ throw _iteratorError;
724
+ }
725
+ }
726
+ }
727
+ return rowIndex;
728
+ }
729
+ };
730
+ var processor = tableProcessors[el.type] || tableProcessors.default;
731
+ var rowCount = processor();
732
+ data.length = rowCount;
733
+ // 计算列宽
734
+ var colLength = new Array(maxColumns).fill(0);
735
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
736
+ try {
737
+ for(var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
738
+ var row = _step.value;
739
+ for(var i = 0; i < row.length; i++){
740
+ colLength[i] = Math.max(colLength[i], stringWidth(row[i] || ''));
741
+ }
742
+ }
743
+ } catch (err) {
744
+ _didIteratorError = true;
745
+ _iteratorError = err;
746
+ } finally{
747
+ try {
748
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
749
+ _iterator.return();
750
+ }
751
+ } finally{
752
+ if (_didIteratorError) {
753
+ throw _iteratorError;
406
754
  }
407
- return parserSlateNodeToMarkdown(
408
- [child],
409
- "",
410
- [...parent, cell],
411
- plugins
412
- );
413
- }).join("").trim();
414
- };
415
- if (c.type === "table-row" && (c == null ? void 0 : c.children)) {
416
- processRow(c.children, cellProcessor);
417
- } else if (c.type === "table-cell") {
418
- processRow([c], cellProcessor);
419
755
  }
420
- }
421
- return rowIndex;
422
- }
423
- };
424
- const processor = tableProcessors[el.type] || tableProcessors.default;
425
- const rowCount = processor();
426
- data.length = rowCount;
427
- const colLength = new Array(maxColumns).fill(0);
428
- for (const row of data) {
429
- for (let i = 0; i < row.length; i++) {
430
- colLength[i] = Math.max(colLength[i], stringWidth(row[i] || ""));
431
- }
432
- }
433
- const alignStrategies = {
434
- right: (str, diff) => " ".repeat(diff) + str,
435
- center: (str, diff) => {
436
- const pre = Math.floor(diff / 2);
437
- return " ".repeat(pre) + str + " ".repeat(diff - pre);
438
- },
439
- left: (str, diff) => str + " ".repeat(diff),
440
- default: (str, diff) => str + " ".repeat(diff)
441
- };
442
- const separatorStrategies = {
443
- left: (length) => ":" + "-".repeat(Math.max(3, length - 1)),
444
- center: (length) => ":" + "-".repeat(Math.max(3, length - 2)) + ":",
445
- right: (length) => "-".repeat(Math.max(3, length - 1)) + ":",
446
- default: (length) => ":" + "-".repeat(Math.max(3, length - 1))
447
- // 默认使用左对齐
448
- };
449
- const output = [];
450
- for (let i = 0; i < data.length; i++) {
451
- const cells = new Array(maxColumns);
452
- const row = data[i];
453
- for (let j = 0; j < maxColumns; j++) {
454
- let str = row[j] || "";
455
- const strLength = stringWidth(str);
456
- const length = Math.max(3, colLength[j]);
457
- const diff = length - strLength;
458
- const hasExplicitAlignment = ((_b = head[j]) == null ? void 0 : _b.align) !== void 0;
459
- str = diff > 0 && hasExplicitAlignment ? (alignStrategies[(_c = head[j]) == null ? void 0 : _c.align] || alignStrategies.default)(str, diff) : str;
460
- cells[j] = str.replace(/\|/g, "\\|");
461
756
  }
462
- output.push(`| ${cells.join(" | ")} |`);
463
- if (i === 0) {
464
- const separators = new Array(maxColumns);
465
- for (let j = 0; j < maxColumns; j++) {
466
- const minLength = Math.max(3, colLength[j]);
467
- separators[j] = (separatorStrategies[(_d = head[j]) == null ? void 0 : _d.align] || separatorStrategies.default)(minLength);
468
- }
469
- output.push(`| ${separators.join(" | ")} |`);
757
+ // 对齐策略表
758
+ var alignStrategies = {
759
+ right: function(str, diff) {
760
+ return ' '.repeat(diff) + str;
761
+ },
762
+ center: function(str, diff) {
763
+ var pre = Math.floor(diff / 2);
764
+ return ' '.repeat(pre) + str + ' '.repeat(diff - pre);
765
+ },
766
+ left: function(str, diff) {
767
+ return str + ' '.repeat(diff);
768
+ },
769
+ default: function(str, diff) {
770
+ return str + ' '.repeat(diff);
771
+ }
772
+ };
773
+ // 修改分隔符策略表
774
+ var separatorStrategies = {
775
+ left: function(length) {
776
+ return ':' + '-'.repeat(Math.max(3, length - 1));
777
+ },
778
+ center: function(length) {
779
+ return ':' + '-'.repeat(Math.max(3, length - 2)) + ':';
780
+ },
781
+ right: function(length) {
782
+ return '-'.repeat(Math.max(3, length - 1)) + ':';
783
+ },
784
+ default: function(length) {
785
+ return ':' + '-'.repeat(Math.max(3, length - 1));
786
+ }
787
+ };
788
+ var output = [];
789
+ // 构建表格内容
790
+ for(var i1 = 0; i1 < data.length; i1++){
791
+ var cells = new Array(maxColumns);
792
+ var row1 = data[i1];
793
+ // 处理单元格
794
+ for(var j = 0; j < maxColumns; j++){
795
+ var _head_j, _head_j1;
796
+ var str = row1[j] || '';
797
+ var strLength = stringWidth(str);
798
+ var length = Math.max(3, colLength[j]);
799
+ var diff = length - strLength;
800
+ // 检查是否有明确的对齐信息
801
+ var hasExplicitAlignment = ((_head_j = head[j]) === null || _head_j === void 0 ? void 0 : _head_j.align) !== undefined;
802
+ str = diff > 0 && hasExplicitAlignment ? (alignStrategies[(_head_j1 = head[j]) === null || _head_j1 === void 0 ? void 0 : _head_j1.align] || alignStrategies.default)(str, diff) : str;
803
+ cells[j] = str.replace(/\|/g, '\\|');
804
+ }
805
+ output.push("| ".concat(cells.join(' | '), " |"));
806
+ // 处理分隔行
807
+ if (i1 === 0) {
808
+ var separators = new Array(maxColumns);
809
+ for(var j1 = 0; j1 < maxColumns; j1++){
810
+ var _head_j2;
811
+ var minLength = Math.max(3, colLength[j1]); // 确保至少有3个字符的长度
812
+ separators[j1] = (separatorStrategies[(_head_j2 = head[j1]) === null || _head_j2 === void 0 ? void 0 : _head_j2.align] || separatorStrategies.default)(minLength);
813
+ }
814
+ output.push("| ".concat(separators.join(' | '), " |"));
815
+ }
470
816
  }
471
- }
472
- return output.join("\n");
817
+ return output.join('\n');
473
818
  };
474
- var handleCard = (node, preString, parent, plugins) => {
475
- return parserSlateNodeToMarkdown(
476
- node == null ? void 0 : node.children,
477
- preString,
478
- [...parent, node],
479
- plugins
480
- );
819
+ /**
820
+ * 处理卡片节点,递归处理其子节点
821
+ * @param node - 卡片节点
822
+ * @param preString - 前缀字符串,用于处理缩进
823
+ * @param parent - 父节点数组
824
+ * @param plugins - 可选的插件数组
825
+ * @returns 处理后的 Markdown 字符串
826
+ */ var handleCard = function(node, preString, parent, plugins) {
827
+ return parserSlateNodeToMarkdown(node === null || node === void 0 ? void 0 : node.children, preString, _to_consumable_array(parent).concat([
828
+ node
829
+ ]), plugins);
481
830
  };
482
- var handleParagraph = (node, preString, parent, plugins) => {
483
- let str = "";
484
- if (node.align) {
485
- str += `<!--${JSON.stringify({ align: node.align })}-->
486
- ${preString}`;
487
- }
488
- str += parserSlateNodeToMarkdown(
489
- node == null ? void 0 : node.children,
490
- preString,
491
- [...parent, node],
492
- plugins
493
- );
494
- return str;
831
+ /**
832
+ * 处理段落节点,添加前缀并处理其子节点
833
+ * @param node - 段落节点
834
+ * @param preString - 前缀字符串,用于处理缩进
835
+ * @param parent - 父节点数组
836
+ * @param plugins - 可选的插件数组
837
+ * @returns 处理后的 Markdown 字符串
838
+ */ var handleParagraph = function(node, preString, parent, plugins) {
839
+ var str = '';
840
+ // 处理对齐注释
841
+ if (node.align) {
842
+ str += "<!--".concat(JSON.stringify({
843
+ align: node.align
844
+ }), "-->\n").concat(preString);
845
+ }
846
+ str += parserSlateNodeToMarkdown(node === null || node === void 0 ? void 0 : node.children, preString, _to_consumable_array(parent).concat([
847
+ node
848
+ ]), plugins);
849
+ return str;
495
850
  };
496
- var handleHead = (node, preString, parent, plugins) => {
497
- let str = "";
498
- if (node.align) {
499
- str += `<!--${JSON.stringify({ align: node.align })}-->
500
- ${preString}`;
501
- }
502
- str += "#".repeat(node.level) + " " + parserSlateNodeToMarkdown(
503
- node == null ? void 0 : node.children,
504
- preString,
505
- [...parent, node],
506
- plugins
507
- );
508
- return str;
851
+ /**
852
+ * 处理标题节点,根据级别生成对应的 Markdown 标题
853
+ * @param node - 标题节点,包含 level 属性
854
+ * @param preString - 前缀字符串,用于处理缩进
855
+ * @param parent - 父节点数组
856
+ * @param plugins - 可选的插件数组
857
+ * @returns 处理后的 Markdown 标题字符串
858
+ */ var handleHead = function(node, preString, parent, plugins) {
859
+ var str = '';
860
+ // 处理对齐注释
861
+ if (node.align) {
862
+ str += "<!--".concat(JSON.stringify({
863
+ align: node.align
864
+ }), "-->\n").concat(preString);
865
+ }
866
+ str += '#'.repeat(node.level) + ' ' + parserSlateNodeToMarkdown(node === null || node === void 0 ? void 0 : node.children, preString, _to_consumable_array(parent).concat([
867
+ node
868
+ ]), plugins);
869
+ return str;
509
870
  };
510
- var handleCode = (node, preString) => {
511
- let code = (node == null ? void 0 : node.value) || "";
512
- if (typeof code === "object") {
513
- try {
514
- code = JSON.stringify(code, null, 2);
515
- } catch (e) {
516
- console.warn("Invalid code object", e);
871
+ /**
872
+ * 处理代码节点,支持三种模式:HTML渲染、Frontmatter、普通代码块
873
+ * @param node - 代码节点,包含 language、value、render、frontmatter 等属性
874
+ * @param preString - 前缀字符串,用于处理缩进
875
+ * @returns 处理后的代码块字符串
876
+ */ var handleCode = function(node, preString) {
877
+ var code = (node === null || node === void 0 ? void 0 : node.value) || '';
878
+ // 如果 code 是对象,则转换为 JSON 字符串,实现对 apaasify 等节点的支持
879
+ if ((typeof code === "undefined" ? "undefined" : _type_of(code)) === 'object') {
880
+ try {
881
+ code = JSON.stringify(code, null, 2);
882
+ } catch (e) {
883
+ console.warn('Invalid code object', e);
884
+ }
517
885
  }
518
- }
519
- if (node.language === "think") {
520
- const marker = "​";
521
- const restoredCode = code.replace(
522
- new RegExp(
523
- `${marker}【CODE_BLOCK:([\\w]*)】\\n?([\\s\\S]*?)\\n?【/CODE_BLOCK】${marker}`,
524
- "g"
525
- ),
526
- (_, lang, codeContent) => {
527
- return `\`\`\`${lang}
528
- ${codeContent}
529
- \`\`\``;
530
- }
531
- );
532
- return `<think>${restoredCode}</think>`;
533
- }
534
- if (node.language === "html" && node.render) {
535
- return code;
536
- }
537
- if (node.frontmatter) {
538
- return `${preString}---
539
- ${code}
540
- ${preString}---`;
541
- }
542
- const language = node.language || "";
543
- if (!code.trim()) {
544
- return `${preString}\`\`\`${language}
545
- ${preString}\`\`\``;
546
- }
547
- const codeLines = code.split("\n");
548
- const indentedCode = codeLines.map((line, index) => {
549
- if (index === 0 || index === codeLines.length - 1) {
550
- return line;
886
+ // 如果语言是 think,转换为 <think> 标签
887
+ if (node.language === 'think') {
888
+ // 恢复内容中的代码块特殊标记为 Markdown 格式
889
+ var marker = '\u200B'; // 零宽空格
890
+ var restoredCode = code.replace(new RegExp("".concat(marker, "【CODE_BLOCK:([\\w]*)】\\n?([\\s\\S]*?)\\n?【/CODE_BLOCK】").concat(marker), 'g'), function(_, lang, codeContent) {
891
+ return "```".concat(lang, "\n").concat(codeContent, "\n```");
892
+ });
893
+ return "<think>".concat(restoredCode, "</think>");
551
894
  }
552
- return preString + line;
553
- }).join("\n");
554
- return `${preString}\`\`\`${language}
555
- ${indentedCode}
556
- ${preString}\`\`\``;
557
- };
558
- var handleAttach = (node) => {
559
- return `<a href="${encodeURI(node == null ? void 0 : node.url)}" download data-size="${node.size}">${node.name}</a>`;
560
- };
561
- var handleBlockquote = (node, preString, parent, plugins) => {
562
- if (!node.children || node.children.length === 0) {
563
- return "> ";
564
- }
565
- const blockquoteContent = node.children.map((child) => {
566
- if (child.type === "blockquote") {
567
- const nestedContent = parserNode(child, "", [...parent, node], plugins);
568
- return nestedContent.split("\n").map((line) => "> " + line).join("\n");
569
- } else {
570
- const content = parserNode(child, "", [...parent, node], plugins);
571
- if (!content.trim()) {
572
- return "> ";
573
- }
574
- return content.split("\n").map((line) => "> " + line).join("\n");
895
+ if (node.language === 'html' && node.render) {
896
+ return code;
575
897
  }
576
- }).join("\n");
577
- return blockquoteContent;
578
- };
579
- var handleImage = (node) => {
580
- try {
581
- let nodeImageUrl = new URL(node == null ? void 0 : node.url);
582
- if (node.width) {
583
- nodeImageUrl.searchParams.set("width", node.width);
898
+ if (node.frontmatter) {
899
+ return "".concat(preString, "---\n").concat(code, "\n").concat(preString, "---");
584
900
  }
585
- if (node.height) {
586
- nodeImageUrl.searchParams.set("height", node.height);
901
+ var language = node.language || '';
902
+ if (!code.trim()) {
903
+ return "".concat(preString, "```").concat(language, "\n").concat(preString, "```");
587
904
  }
588
- if (node.block) {
589
- nodeImageUrl.searchParams.set("block", node.block);
905
+ var codeLines = code.split('\n');
906
+ var indentedCode = codeLines.map(function(line, index) {
907
+ if (index === 0 || index === codeLines.length - 1) {
908
+ return line;
909
+ }
910
+ return preString + line;
911
+ }).join('\n');
912
+ return "".concat(preString, "```").concat(language, "\n").concat(indentedCode, "\n").concat(preString, "```");
913
+ };
914
+ /**
915
+ * 处理附件节点,生成带下载属性的链接标签
916
+ * @param node - 附件节点,包含 url、size、name 属性
917
+ * @returns 处理后的 HTML 链接标签字符串
918
+ */ var handleAttach = function(node) {
919
+ return '<a href="'.concat(encodeURI(node === null || node === void 0 ? void 0 : node.url), '" download data-size="').concat(node.size, '">').concat(node.name, "</a>");
920
+ };
921
+ /**
922
+ * 处理引用块节点,递归处理其子节点
923
+ * @param node - 引用块节点
924
+ * @param preString - 前缀字符串,用于处理缩进
925
+ * @param parent - 父节点数组
926
+ * @param plugins - 可选的插件数组
927
+ * @returns 处理后的 Markdown 引用字符串
928
+ */ var handleBlockquote = function(node, preString, parent, plugins) {
929
+ // Handle empty blockquotes
930
+ if (!node.children || node.children.length === 0) {
931
+ return '> ';
590
932
  }
591
- return `![${node.alt || ""}](${nodeImageUrl.toString()})`;
592
- } catch (e) {
593
- console.warn("Invalid image URL:", node == null ? void 0 : node.url, e);
594
- return `![${node.alt || ""}](${encodeURI(node == null ? void 0 : node.url)})`;
595
- }
933
+ // Process each child node
934
+ var blockquoteContent = node.children.map(function(child) {
935
+ if (child.type === 'blockquote') {
936
+ // For nested blockquotes, increase the level
937
+ var nestedContent = parserNode(child, '', _to_consumable_array(parent).concat([
938
+ node
939
+ ]), plugins);
940
+ return nestedContent.split('\n').map(function(line) {
941
+ return '> ' + line;
942
+ }).join('\n');
943
+ } else {
944
+ // For regular content
945
+ var content = parserNode(child, '', _to_consumable_array(parent).concat([
946
+ node
947
+ ]), plugins);
948
+ if (!content.trim()) {
949
+ return '> ';
950
+ }
951
+ // Add blockquote marker and handle multi-line content
952
+ return content.split('\n').map(function(line) {
953
+ return '> ' + line;
954
+ }).join('\n');
955
+ }
956
+ }).join('\n');
957
+ return blockquoteContent;
596
958
  };
597
- var handleMedia = (node) => {
598
- let nodeUrl = node == null ? void 0 : node.url;
599
- let type = node.mediaType || getMediaType(nodeUrl, node == null ? void 0 : node.alt);
600
- if (node.height) {
601
- if (type === "video") {
602
- return `<video src="${encodeURI(nodeUrl)}" alt="" height="${node.height || ""}"/>`;
603
- } else if (type === "image" || type === "media") {
604
- return `<img src="${encodeURI(nodeUrl)}" alt="" height="${node.height || ""}" ${node.align ? `data-align="${node.align}"` : ""}/>`;
959
+ /**
960
+ * 处理图片节点,支持宽度、高度和块级显示参数
961
+ * @param node - 图片节点,包含 url、width、height、block、alt 属性
962
+ * @returns 处理后的 Markdown 图片字符串
963
+ */ var handleImage = function(node) {
964
+ try {
965
+ var nodeImageUrl = new URL(node === null || node === void 0 ? void 0 : node.url);
966
+ if (node.width) {
967
+ nodeImageUrl.searchParams.set('width', node.width);
968
+ }
969
+ if (node.height) {
970
+ nodeImageUrl.searchParams.set('height', node.height);
971
+ }
972
+ if (node.block) {
973
+ nodeImageUrl.searchParams.set('block', node.block);
974
+ }
975
+ return "![".concat(node.alt || '', "](").concat(nodeImageUrl.toString(), ")");
976
+ } catch (e) {
977
+ console.warn('Invalid image URL:', node === null || node === void 0 ? void 0 : node.url, e);
978
+ return "![".concat(node.alt || '', "](").concat(encodeURI(node === null || node === void 0 ? void 0 : node.url), ")");
605
979
  }
606
- } else {
607
- if (type === "video") {
608
- return `<video src="${encodeURI(nodeUrl)}"/>`;
609
- } else if (type === "image" || type === "media") {
610
- if (node.align) {
611
- return `<img src="${encodeURI(nodeUrl)}" alt="" ${node.align ? `data-align="${node.align}"` : ""}/>`;
612
- } else {
613
- return `![${node.alt || ""}](${encodeURI(nodeUrl)})`;
614
- }
980
+ };
981
+ /**
982
+ * 处理媒体节点,支持视频、图片和 iframe
983
+ * @param node - 媒体节点,包含 url、mediaType、height、align、alt 属性
984
+ * @returns 处理后的 HTML 媒体标签或 Markdown 图片字符串
985
+ */ var handleMedia = function(node) {
986
+ var nodeUrl = node === null || node === void 0 ? void 0 : node.url;
987
+ var type = node.mediaType || getMediaType(nodeUrl, node === null || node === void 0 ? void 0 : node.alt);
988
+ if (node.height) {
989
+ if (type === 'video') {
990
+ return '<video src="'.concat(encodeURI(nodeUrl), '" alt="" height="').concat(node.height || '', '"/>');
991
+ } else if (type === 'image' || type === 'media') {
992
+ return '<img src="'.concat(encodeURI(nodeUrl), '" alt="" height="').concat(node.height || '', '" ').concat(node.align ? 'data-align="'.concat(node.align, '"') : '', "/>");
993
+ }
615
994
  } else {
616
- return `<iframe src="${encodeURI(nodeUrl)}"/>`;
995
+ if (type === 'video') {
996
+ return '<video src="'.concat(encodeURI(nodeUrl), '"/>');
997
+ } else if (type === 'image' || type === 'media') {
998
+ if (node.align) {
999
+ return '<img src="'.concat(encodeURI(nodeUrl), '" alt="" ').concat(node.align ? 'data-align="'.concat(node.align, '"') : '', "/>");
1000
+ } else {
1001
+ return "![".concat(node.alt || '', "](").concat(encodeURI(nodeUrl), ")");
1002
+ }
1003
+ } else {
1004
+ return '<iframe src="'.concat(encodeURI(nodeUrl), '"/>');
1005
+ }
617
1006
  }
618
- }
619
- return "";
620
- };
621
- var handleList = (node, preString, parent, plugins) => {
622
- return parserSlateNodeToMarkdown(
623
- node.children,
624
- preString,
625
- [...parent, node],
626
- plugins
627
- );
1007
+ return '';
628
1008
  };
629
- var handleListItem = (node, preString, parent, plugins) => {
630
- return parserSlateNodeToMarkdown(
631
- node.children,
632
- preString,
633
- [...parent, node],
634
- plugins
635
- );
1009
+ /**
1010
+ * 处理列表节点,递归处理其子节点
1011
+ * @param node - 列表节点
1012
+ * @param preString - 前缀字符串,用于处理缩进
1013
+ * @param parent - 父节点数组
1014
+ * @param plugins - 可选的插件数组
1015
+ * @returns 处理后的 Markdown 列表字符串
1016
+ */ var handleList = function(node, preString, parent, plugins) {
1017
+ return parserSlateNodeToMarkdown(node.children, preString, _to_consumable_array(parent).concat([
1018
+ node
1019
+ ]), plugins);
636
1020
  };
637
- var handleSchema = (node) => {
638
- return "```schema\n" + JSON.stringify(node.otherProps, null, 2) + "\n```";
1021
+ /**
1022
+ * 处理列表项节点,递归处理其子节点
1023
+ * @param node - 列表项节点
1024
+ * @param preString - 前缀字符串,用于处理缩进
1025
+ * @param parent - 父节点数组
1026
+ * @param plugins - 可选的插件数组
1027
+ * @returns 处理后的 Markdown 列表项字符串
1028
+ */ var handleListItem = function(node, preString, parent, plugins) {
1029
+ return parserSlateNodeToMarkdown(node.children, preString, _to_consumable_array(parent).concat([
1030
+ node
1031
+ ]), plugins);
639
1032
  };
640
- var handleLinkCard = (node) => {
641
- return `[${node.name}](${node == null ? void 0 : node.url} "${node.name}")`;
1033
+ /**
1034
+ * 处理模式定义节点,生成 schema 代码块
1035
+ * @param node - 模式定义节点,包含 otherProps 属性
1036
+ * @returns 处理后的 schema 代码块字符串
1037
+ */ var handleSchema = function(node) {
1038
+ return '```schema\n' + JSON.stringify(node.otherProps, null, 2) + '\n```';
642
1039
  };
643
- var handleHr = (preString) => {
644
- return preString + "***";
1040
+ /**
1041
+ * 处理链接卡片节点,生成 Markdown 链接格式
1042
+ * @param node - 链接卡片节点,包含 name、url 属性
1043
+ * @returns 处理后的 Markdown 链接字符串
1044
+ */ var handleLinkCard = function(node) {
1045
+ return "[".concat(node.name, "](").concat(node === null || node === void 0 ? void 0 : node.url, ' "').concat(node.name, '")');
645
1046
  };
646
- var handleBreak = (preString) => {
647
- return preString + "<br/>";
1047
+ /**
1048
+ * 处理水平分割线节点
1049
+ * @param preString - 前缀字符串,用于处理缩进
1050
+ * @returns 处理后的 Markdown 分割线字符串
1051
+ */ var handleHr = function(preString) {
1052
+ return preString + '***';
648
1053
  };
649
- var handleFootnoteDefinition = (node) => {
650
- return `[^${node.identifier}]: [${node.value}](${node.url})
651
- `;
1054
+ /**
1055
+ * 处理换行节点
1056
+ * @param preString - 前缀字符串,用于处理缩进
1057
+ * @returns 处理后的 HTML 换行标签字符串
1058
+ */ var handleBreak = function(preString) {
1059
+ return preString + '<br/>';
652
1060
  };
653
- var handleDefault = (node, parent) => {
654
- if (node.text || node.tag)
655
- return composeText(node, parent);
656
- return "";
1061
+ /**
1062
+ * 处理脚注定义节点
1063
+ * @param node - 脚注定义节点,包含 identifier、value、url 属性
1064
+ * @returns 处理后的 Markdown 脚注字符串
1065
+ */ var handleFootnoteDefinition = function(node) {
1066
+ return "[^".concat(node.identifier, "]: [").concat(node.value, "](").concat(node.url, ")\n");
657
1067
  };
658
- export {
659
- isMix,
660
- parserSlateNodeToMarkdown
1068
+ /**
1069
+ * 处理默认文本节点
1070
+ * @param node - 文本节点
1071
+ * @param parent - 父节点数组
1072
+ * @returns 处理后的文本字符串
1073
+ */ var handleDefault = function(node, parent) {
1074
+ if (node.text || node.tag) return composeText(node, parent);
1075
+ return '';
661
1076
  };