@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.
- package/dist/AgentRunBar/Robot.js +105 -57
- package/dist/AgentRunBar/icons/PauseIcon.js +38 -38
- package/dist/AgentRunBar/icons/PlayIcon.js +38 -38
- package/dist/AgentRunBar/icons/SimplePauseIcon.js +38 -38
- package/dist/AgentRunBar/icons/SimplePlayIcon.js +38 -38
- package/dist/AgentRunBar/icons/SimpleStopIcon.js +38 -38
- package/dist/AgentRunBar/icons/StopIcon.js +41 -50
- package/dist/AgentRunBar/icons/index.js +0 -1
- package/dist/AgentRunBar/index.js +270 -237
- package/dist/AgentRunBar/style.js +273 -239
- package/dist/AgenticLayout/index.js +140 -85
- package/dist/AgenticLayout/style.js +126 -107
- package/dist/AnswerAlert/components/CloseIcon.js +12 -21
- package/dist/AnswerAlert/components/ErrorIcon.js +42 -38
- package/dist/AnswerAlert/components/InfoIcon.js +42 -38
- package/dist/AnswerAlert/components/LoaderIcon.js +12 -21
- package/dist/AnswerAlert/components/SuccessIcon.js +42 -38
- package/dist/AnswerAlert/components/WarningIcon.js +42 -38
- package/dist/AnswerAlert/index.js +155 -75
- package/dist/AnswerAlert/style.js +159 -147
- package/dist/BackTo/BackBottom.js +154 -70
- package/dist/BackTo/BackTop.js +148 -68
- package/dist/BackTo/ScrollVisibleButton.js +124 -98
- package/dist/BackTo/hooks/useScrollVisible.js +79 -33
- package/dist/BackTo/icons/BottomIcon.js +37 -37
- package/dist/BackTo/icons/TopIcon.js +37 -37
- package/dist/BackTo/index.js +22 -7
- package/dist/BackTo/style.js +93 -70
- package/dist/Bubble/AIBubble.js +469 -406
- package/dist/Bubble/Avatar/index.js +139 -85
- package/dist/Bubble/Avatar/isEmoji.js +2 -6
- package/dist/Bubble/Bubble.js +114 -38
- package/dist/Bubble/BubbleBeforeNode.js +104 -74
- package/dist/Bubble/BubbleConfigProvide.js +3 -7
- package/dist/Bubble/FileView.js +63 -69
- package/dist/Bubble/List/PureBubbleList.js +130 -131
- package/dist/Bubble/List/SkeletonList.js +33 -24
- package/dist/Bubble/List/index.js +187 -124
- package/dist/Bubble/List/style.js +76 -47
- package/dist/Bubble/MessagesContent/BubbleContext.js +6 -12
- package/dist/Bubble/MessagesContent/BubbleExtra.js +663 -355
- package/dist/Bubble/MessagesContent/CopyButton/index.js +326 -96
- package/dist/Bubble/MessagesContent/DocInfo.js +351 -386
- package/dist/Bubble/MessagesContent/EXCEPTION.js +42 -22
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +206 -156
- package/dist/Bubble/MessagesContent/VoiceButton/index.js +213 -115
- package/dist/Bubble/MessagesContent/VoiceButton/style.js +129 -105
- package/dist/Bubble/MessagesContent/VoiceButton/types.js +9 -0
- package/dist/Bubble/MessagesContent/docInfoStyle.js +118 -88
- package/dist/Bubble/MessagesContent/icons.js +157 -57
- package/dist/Bubble/MessagesContent/index.js +609 -368
- package/dist/Bubble/PureBubble.js +439 -326
- package/dist/Bubble/Title.js +110 -87
- package/dist/Bubble/UserBubble.js +218 -279
- package/dist/Bubble/index.js +10 -16
- package/dist/Bubble/style.js +248 -227
- package/dist/Bubble/type.js +3 -0
- package/dist/Bubble/types/BubbleExtra.js +1 -0
- package/dist/Bubble/types/DocInfo.js +1 -0
- package/dist/ChatBootPage/ButtonTab.js +25 -45
- package/dist/ChatBootPage/ButtonTabGroup.js +74 -47
- package/dist/ChatBootPage/ButtonTabGroupStyle.js +73 -45
- package/dist/ChatBootPage/ButtonTabStyle.js +121 -98
- package/dist/ChatBootPage/CaseReply.js +119 -113
- package/dist/ChatBootPage/CaseReplyStyle.js +217 -189
- package/dist/ChatBootPage/Title.js +19 -23
- package/dist/ChatBootPage/index.js +9 -11
- package/dist/ChatBootPage/style.js +80 -50
- package/dist/ChatLayout/index.js +93 -57
- package/dist/ChatLayout/style.js +206 -176
- package/dist/ChatLayout/types.js +1 -0
- package/dist/Components/ActionIconBox/index.js +571 -197
- package/dist/Components/ActionIconBox/style.js +141 -111
- package/dist/Components/ActionItemBox/ActionItemBox.js +95 -149
- package/dist/Components/ActionItemBox/index.js +7 -7
- package/dist/Components/ActionItemBox/style.js +353 -361
- package/dist/Components/Button/IconButton/index.js +35 -43
- package/dist/Components/Button/IconButton/style.js +357 -331
- package/dist/Components/Button/SwitchButton/index.js +243 -87
- package/dist/Components/Button/SwitchButton/style.js +160 -146
- package/dist/Components/Button/ToggleButton/index.js +46 -57
- package/dist/Components/Button/ToggleButton/style.js +283 -258
- package/dist/Components/Button/index.js +6 -2
- package/dist/Components/GradientText/index.js +21 -27
- package/dist/Components/GradientText/style.js +88 -63
- package/dist/Components/ImageList.js +111 -133
- package/dist/Components/LayoutHeader/index.js +145 -81
- package/dist/Components/LayoutHeader/style.js +89 -64
- package/dist/Components/LayoutHeader/types.js +3 -0
- package/dist/Components/Loading/index.js +53 -22
- package/dist/Components/Robot/index.js +90 -56
- package/dist/Components/Robot/lotties/DazingLottie/index.js +78 -47
- package/dist/Components/Robot/lotties/ThinkingLottie/index.js +78 -47
- package/dist/Components/Robot/lotties/index.js +0 -1
- package/dist/Components/SuggestionList/index.js +354 -182
- package/dist/Components/SuggestionList/style.js +204 -186
- package/dist/Components/TextAnimate/index.js +494 -362
- package/dist/Components/TextAnimate/style.js +72 -48
- package/dist/Components/TypingAnimation/index.js +214 -169
- package/dist/Components/TypingAnimation/style.js +76 -52
- package/dist/Components/VisualList/index.js +267 -180
- package/dist/Components/VisualList/style.js +140 -124
- package/dist/Components/icons/LoadingSpinnerIcon.js +124 -73
- package/dist/Components/lotties/DazingLottie/index.js +78 -47
- package/dist/Components/lotties/LoadingLottie/index.js +82 -48
- package/dist/Components/lotties/TextLoading/index.js +73 -49
- package/dist/Components/lotties/TextLoading/style.js +95 -78
- package/dist/Components/lotties/ThinkingLottie/index.js +78 -47
- package/dist/Components/lotties/index.js +0 -1
- package/dist/Constants/colors.js +71 -97
- package/dist/History/components/HistoryActionsBox.js +407 -180
- package/dist/History/components/HistoryEmpty.js +38 -42
- package/dist/History/components/HistoryEmptyIcon.js +682 -964
- package/dist/History/components/HistoryItem.js +683 -471
- package/dist/History/components/HistoryList.js +170 -87
- package/dist/History/components/HistoryRunningIcon.js +160 -111
- package/dist/History/components/LoadMoreComponent.js +308 -103
- package/dist/History/components/NewChatComponent.js +261 -69
- package/dist/History/components/NewChatComponent.style.js +79 -53
- package/dist/History/components/SearchComponent.js +367 -156
- package/dist/History/components/index.js +11 -23
- package/dist/History/hooks/useHistory.js +404 -129
- package/dist/History/index.js +301 -186
- package/dist/History/menu.js +158 -212
- package/dist/History/style.js +282 -276
- package/dist/History/types/HistoryData.js +6 -10
- package/dist/History/types/HistoryList.js +3 -0
- package/dist/History/types/index.js +3 -0
- package/dist/History/utils/index.js +35 -32
- package/dist/Hooks/useAutoScroll.js +262 -84
- package/dist/Hooks/useClickAway.js +60 -21
- package/dist/Hooks/useCopied.js +72 -20
- package/dist/Hooks/useDebounceFn/index.js +213 -55
- package/dist/Hooks/useIntersectionOnce.js +163 -74
- package/dist/Hooks/useLanguage.d.ts +3 -0
- package/dist/Hooks/useLanguage.js +67 -26
- package/dist/Hooks/useRefFunction/index.js +76 -11
- package/dist/Hooks/useSpeechSynthesis.js +143 -99
- package/dist/Hooks/useStyle/index.js +95 -60
- package/dist/Hooks/useThrottleFn/index.js +41 -41
- package/dist/I18n/index.js +246 -109
- package/dist/I18n/locales.d.ts +3 -0
- package/dist/I18n/locales.js +724 -711
- package/dist/Icons/animated/VoicePlayLottie/index.js +75 -46
- package/dist/Icons/animated/VoicingLottie/index.js +78 -47
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +421 -349
- package/dist/MarkdownEditor/editor/Editor.js +1160 -843
- package/dist/MarkdownEditor/editor/components/CommentList/index.js +407 -239
- package/dist/MarkdownEditor/editor/components/CommentList/style.js +119 -89
- package/dist/MarkdownEditor/editor/components/ContributorAvatar/index.js +61 -63
- package/dist/MarkdownEditor/editor/components/ContributorAvatar/style.js +82 -52
- package/dist/MarkdownEditor/editor/components/LazyElement/index.js +208 -106
- package/dist/MarkdownEditor/editor/components/LazyElement/style.js +69 -42
- package/dist/MarkdownEditor/editor/components/fntTag/index.js +7 -11
- package/dist/MarkdownEditor/editor/components/fntTag/style.js +66 -36
- package/dist/MarkdownEditor/editor/components/index.js +0 -1
- package/dist/MarkdownEditor/editor/elements/Blockquote.js +95 -37
- package/dist/MarkdownEditor/editor/elements/Break.js +56 -25
- package/dist/MarkdownEditor/editor/elements/Card/index.js +131 -52
- package/dist/MarkdownEditor/editor/elements/Code.js +89 -67
- package/dist/MarkdownEditor/editor/elements/Comment/index.js +79 -50
- package/dist/MarkdownEditor/editor/elements/ErrorBoundary.js +117 -21
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition.js +83 -64
- package/dist/MarkdownEditor/editor/elements/FootnoteReference.js +115 -41
- package/dist/MarkdownEditor/editor/elements/Head.js +131 -67
- package/dist/MarkdownEditor/editor/elements/Hr.js +63 -38
- package/dist/MarkdownEditor/editor/elements/Image/index.js +636 -494
- package/dist/MarkdownEditor/editor/elements/InlineKatex.js +60 -44
- package/dist/MarkdownEditor/editor/elements/Katex.js +71 -55
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +79 -175
- package/dist/MarkdownEditor/editor/elements/LinkCard/style.js +130 -100
- package/dist/MarkdownEditor/editor/elements/List/List.js +96 -69
- package/dist/MarkdownEditor/editor/elements/List/ListItem.js +422 -247
- package/dist/MarkdownEditor/editor/elements/List/index.js +1 -5
- package/dist/MarkdownEditor/editor/elements/List/style.js +131 -117
- package/dist/MarkdownEditor/editor/elements/Media.js +637 -519
- package/dist/MarkdownEditor/editor/elements/Mermaid.js +79 -54
- package/dist/MarkdownEditor/editor/elements/Paragraph.js +144 -83
- package/dist/MarkdownEditor/editor/elements/Schema.js +167 -128
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +211 -178
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +73 -49
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +285 -204
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +397 -280
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.js +126 -101
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +381 -276
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.js +120 -98
- package/dist/MarkdownEditor/editor/elements/Table/TableContext.js +64 -21
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +52 -42
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.js +69 -39
- package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +126 -72
- package/dist/MarkdownEditor/editor/elements/Table/Td/style.js +85 -55
- package/dist/MarkdownEditor/editor/elements/Table/index.js +204 -105
- package/dist/MarkdownEditor/editor/elements/Table/style.js +244 -233
- package/dist/MarkdownEditor/editor/elements/Table/useScrollShadow.js +119 -62
- package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +438 -276
- package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +103 -77
- package/dist/MarkdownEditor/editor/elements/index.js +437 -424
- package/dist/MarkdownEditor/editor/parser/json-parse.js +38 -9
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1753 -1168
- package/dist/MarkdownEditor/editor/parser/parserMdToSchema.js +16 -20
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1021 -606
- package/dist/MarkdownEditor/editor/parser/remarkParse.js +158 -102
- package/dist/MarkdownEditor/editor/plugins/catchError.js +78 -17
- package/dist/MarkdownEditor/editor/plugins/elements.js +458 -342
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +752 -300
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +215 -129
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +325 -180
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +576 -418
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +157 -47
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +331 -209
- package/dist/MarkdownEditor/editor/plugins/index.js +0 -1
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +1245 -507
- package/dist/MarkdownEditor/editor/plugins/parseMarkdownToNodesAndInsert.js +36 -24
- package/dist/MarkdownEditor/editor/plugins/useHighlight.js +267 -116
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +234 -160
- package/dist/MarkdownEditor/editor/plugins/useOnchange.js +253 -92
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +728 -439
- package/dist/MarkdownEditor/editor/store.js +1819 -1389
- package/dist/MarkdownEditor/editor/style.js +551 -506
- package/dist/MarkdownEditor/editor/tagStyles.js +43 -43
- package/dist/MarkdownEditor/editor/tools/DragHandle.js +56 -54
- package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1049 -732
- package/dist/MarkdownEditor/editor/tools/InsertLink.js +232 -181
- package/dist/MarkdownEditor/editor/tools/Leading.js +566 -303
- package/dist/MarkdownEditor/editor/tools/ToolBar/BaseBar.js +415 -377
- package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +162 -125
- package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +480 -258
- package/dist/MarkdownEditor/editor/tools/ToolBar/ToolBar.js +44 -44
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ClearFormatButton.js +20 -35
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ColorPickerButton.js +69 -73
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormatButton.js +13 -19
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormattingTools.js +34 -41
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +53 -47
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/LinkButton.js +11 -19
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ToolBarItem.js +23 -43
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/UndoRedoButtons.js +14 -25
- package/dist/MarkdownEditor/editor/tools/ToolBar/config/toolsConfig.js +139 -102
- package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.js +95 -65
- package/dist/MarkdownEditor/editor/tools/ToolBar/hooks/useToolBarLogic.js +252 -161
- package/dist/MarkdownEditor/editor/tools/ToolBar/index.js +14 -24
- package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.js +95 -65
- package/dist/MarkdownEditor/editor/tools/insertAutocompleteStyle.js +82 -52
- package/dist/MarkdownEditor/editor/types/Table.js +1 -0
- package/dist/MarkdownEditor/editor/utils/InlineChromiumBugfix.js +11 -16
- package/dist/MarkdownEditor/editor/utils/ace.js +136 -40
- package/dist/MarkdownEditor/editor/utils/docx/docxDeserializer.js +29 -32
- package/dist/MarkdownEditor/editor/utils/docx/index.js +0 -1
- package/dist/MarkdownEditor/editor/utils/docx/module.js +193 -164
- package/dist/MarkdownEditor/editor/utils/docx/utils.js +113 -98
- package/dist/MarkdownEditor/editor/utils/dom.js +119 -90
- package/dist/MarkdownEditor/editor/utils/editorUtils.js +1369 -906
- package/dist/MarkdownEditor/editor/utils/htmlToMarkdown.js +196 -184
- package/dist/MarkdownEditor/editor/utils/index.js +354 -215
- package/dist/MarkdownEditor/editor/utils/isMarkdown.js +56 -44
- package/dist/MarkdownEditor/editor/utils/keyboard.js +1229 -664
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +294 -76
- package/dist/MarkdownEditor/editor/utils/media.js +274 -99
- package/dist/MarkdownEditor/editor/utils/path.js +22 -16
- package/dist/MarkdownEditor/editor/utils/performanceMonitor.js +370 -168
- package/dist/MarkdownEditor/editor/utils/useLocalState.js +96 -37
- package/dist/MarkdownEditor/el.js +1 -0
- package/dist/MarkdownEditor/hooks/editor.js +123 -41
- package/dist/MarkdownEditor/hooks/subscribe.js +18 -15
- package/dist/MarkdownEditor/index.js +118 -30
- package/dist/MarkdownEditor/plugin.js +2 -5
- package/dist/MarkdownEditor/style.js +96 -66
- package/dist/MarkdownEditor/types.js +1 -0
- package/dist/MarkdownEditor/utils/exportHtml.js +42 -83
- package/dist/MarkdownEditor/utils/native-table/index.js +0 -1
- package/dist/MarkdownEditor/utils/native-table/native-table-editor.js +337 -222
- package/dist/MarkdownEditor/utils/native-table/native-table-keyboard.js +201 -113
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +4 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +277 -82
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +62 -33
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +147 -125
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +174 -129
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +263 -237
- package/dist/MarkdownInputField/AttachmentButton/index.js +480 -205
- package/dist/MarkdownInputField/AttachmentButton/style.js +143 -114
- package/dist/MarkdownInputField/AttachmentButton/types.js +3 -0
- package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +60 -0
- package/dist/MarkdownInputField/AttachmentButton/utils.js +365 -33
- package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +438 -404
- package/dist/MarkdownInputField/Enlargement/index.js +7 -17
- package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +193 -216
- package/dist/MarkdownInputField/FileMapView/index.js +387 -174
- package/dist/MarkdownInputField/FileMapView/style.js +281 -259
- package/dist/MarkdownInputField/FilePaste/index.js +239 -65
- package/dist/MarkdownInputField/FileUploadManager/index.js +504 -170
- package/dist/MarkdownInputField/MarkdownInputField.js +819 -549
- package/dist/MarkdownInputField/QuickActions/index.js +304 -134
- package/dist/MarkdownInputField/RefinePromptButton/index.js +24 -33
- package/dist/MarkdownInputField/RefinePromptButton/style.js +99 -73
- package/dist/MarkdownInputField/SendActions/index.js +179 -197
- package/dist/MarkdownInputField/SendButton/index.js +150 -110
- package/dist/MarkdownInputField/SendButton/style.js +95 -64
- package/dist/MarkdownInputField/SkillModeBar/hooks/index.js +3 -5
- package/dist/MarkdownInputField/SkillModeBar/hooks/useSkillModeState.js +51 -26
- package/dist/MarkdownInputField/SkillModeBar/index.js +119 -106
- package/dist/MarkdownInputField/SkillModeBar/style.js +124 -98
- package/dist/MarkdownInputField/Suggestion/index.js +391 -154
- package/dist/MarkdownInputField/TopOperatingArea/index.js +37 -44
- package/dist/MarkdownInputField/TopOperatingArea/style.js +98 -81
- package/dist/MarkdownInputField/VoiceInput/index.js +210 -82
- package/dist/MarkdownInputField/VoiceInput/style.js +85 -59
- package/dist/MarkdownInputField/VoiceInputManager/index.js +321 -94
- package/dist/MarkdownInputField/style.js +296 -233
- package/dist/Plugins/chart/AreaChart/index.js +541 -393
- package/dist/Plugins/chart/AreaChart/style.js +114 -90
- package/dist/Plugins/chart/BarChart/index.d.ts +4 -0
- package/dist/Plugins/chart/BarChart/index.js +865 -697
- package/dist/Plugins/chart/BarChart/style.js +114 -90
- package/dist/Plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.js +82 -52
- package/dist/Plugins/chart/ChartAttrToolBar/index.js +94 -65
- package/dist/Plugins/chart/ChartMark/Area.js +176 -150
- package/dist/Plugins/chart/ChartMark/Bar.js +181 -152
- package/dist/Plugins/chart/ChartMark/Column.js +181 -151
- package/dist/Plugins/chart/ChartMark/Container.js +116 -75
- package/dist/Plugins/chart/ChartMark/Line.js +179 -151
- package/dist/Plugins/chart/ChartMark/Pie.js +79 -63
- package/dist/Plugins/chart/ChartMark/index.js +6 -13
- package/dist/Plugins/chart/ChartMark/useChart.js +1 -0
- package/dist/Plugins/chart/ChartRender.js +981 -696
- package/dist/Plugins/chart/ChartStatistic/index.js +47 -62
- package/dist/Plugins/chart/ChartStatistic/style.js +142 -143
- package/dist/Plugins/chart/ChartStatistic/utils.js +37 -27
- package/dist/Plugins/chart/DonutChart/Legend.js +94 -124
- package/dist/Plugins/chart/DonutChart/constants.js +4 -11
- package/dist/Plugins/chart/DonutChart/hooks.js +183 -112
- package/dist/Plugins/chart/DonutChart/index.js +588 -516
- package/dist/Plugins/chart/DonutChart/plugins.js +47 -44
- package/dist/Plugins/chart/DonutChart/style.js +186 -175
- package/dist/Plugins/chart/DonutChart/types.js +1 -0
- package/dist/Plugins/chart/FunnelChart/index.js +844 -647
- package/dist/Plugins/chart/FunnelChart/style.js +97 -71
- package/dist/Plugins/chart/LineChart/index.js +516 -393
- package/dist/Plugins/chart/LineChart/style.js +114 -90
- package/dist/Plugins/chart/RadarChart/index.js +580 -582
- package/dist/Plugins/chart/RadarChart/style.js +122 -112
- package/dist/Plugins/chart/ScatterChart/index.js +633 -640
- package/dist/Plugins/chart/ScatterChart/style.js +108 -94
- package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +151 -80
- package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +160 -41
- package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundaryExample.js +80 -62
- package/dist/Plugins/chart/components/ChartContainer/index.js +2 -7
- package/dist/Plugins/chart/components/ChartContainer/style.js +121 -91
- package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +58 -90
- package/dist/Plugins/chart/components/ChartFilter/style.js +169 -154
- package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +54 -59
- package/dist/Plugins/chart/components/ChartToolBar/style.js +132 -117
- package/dist/Plugins/chart/components/icons/TimeIcon.js +20 -26
- package/dist/Plugins/chart/components/index.js +32 -34
- package/dist/Plugins/chart/const.js +34 -25
- package/dist/Plugins/chart/hooks/useChartStatistic.js +1 -0
- package/dist/Plugins/chart/index.js +436 -339
- package/dist/Plugins/chart/loadChartRuntime.js +209 -110
- package/dist/Plugins/chart/utils.js +311 -87
- package/dist/Plugins/code/CodeUI/Katex/Katex.js +112 -66
- package/dist/Plugins/code/components/AceEditor.js +334 -237
- package/dist/Plugins/code/components/AceEditorContainer.js +23 -32
- package/dist/Plugins/code/components/CodeContainer.js +41 -56
- package/dist/Plugins/code/components/CodeRenderer.js +202 -155
- package/dist/Plugins/code/components/CodeToolbar.js +137 -181
- package/dist/Plugins/code/components/HtmlPreview.js +19 -22
- package/dist/Plugins/code/components/LanguageSelector.js +162 -96
- package/dist/Plugins/code/components/LoadImage.js +145 -46
- package/dist/Plugins/code/components/ThinkBlock.js +38 -42
- package/dist/Plugins/code/components/index.js +13 -23
- package/dist/Plugins/code/hooks/index.js +7 -9
- package/dist/Plugins/code/hooks/useCodeEditorState.js +139 -62
- package/dist/Plugins/code/hooks/useRenderConditions.js +31 -23
- package/dist/Plugins/code/hooks/useToolbarConfig.js +44 -46
- package/dist/Plugins/code/index.js +141 -89
- package/dist/Plugins/code/langIconMap.js +400 -108
- package/dist/Plugins/code/langIcons/AbapIcon.js +90 -57
- package/dist/Plugins/code/langIcons/ActionscriptIcon.js +89 -56
- package/dist/Plugins/code/langIcons/AdaIcon.js +89 -52
- package/dist/Plugins/code/langIcons/ApacheIcon.js +205 -254
- package/dist/Plugins/code/langIcons/ApexIcon.js +108 -82
- package/dist/Plugins/code/langIcons/AplIcon.js +90 -54
- package/dist/Plugins/code/langIcons/ApplescriptIcon.js +89 -56
- package/dist/Plugins/code/langIcons/AstroIcon.js +91 -58
- package/dist/Plugins/code/langIcons/AwkIcon.js +98 -68
- package/dist/Plugins/code/langIcons/BallerinaIcon.js +92 -59
- package/dist/Plugins/code/langIcons/BatIcon.js +158 -229
- package/dist/Plugins/code/langIcons/BicepIcon.js +91 -58
- package/dist/Plugins/code/langIcons/BladeIcon.js +90 -58
- package/dist/Plugins/code/langIcons/CIcon.js +90 -55
- package/dist/Plugins/code/langIcons/CadenceIcon.js +89 -56
- package/dist/Plugins/code/langIcons/ClojureIcon.js +96 -75
- package/dist/Plugins/code/langIcons/CmakeIcon.js +93 -62
- package/dist/Plugins/code/langIcons/CobolIcon.js +99 -70
- package/dist/Plugins/code/langIcons/CodeqlIcon.js +96 -76
- package/dist/Plugins/code/langIcons/CoffeeIcon.js +89 -56
- package/dist/Plugins/code/langIcons/ConsoleIcon.js +89 -56
- package/dist/Plugins/code/langIcons/CppIcon.js +90 -55
- package/dist/Plugins/code/langIcons/CrystalIcon.js +90 -57
- package/dist/Plugins/code/langIcons/CsharpIcon.js +90 -59
- package/dist/Plugins/code/langIcons/CssIcon.js +89 -52
- package/dist/Plugins/code/langIcons/DIcon.js +90 -53
- package/dist/Plugins/code/langIcons/DartIcon.js +92 -71
- package/dist/Plugins/code/langIcons/DatabaseIcon.js +90 -57
- package/dist/Plugins/code/langIcons/DiffIcon.js +90 -57
- package/dist/Plugins/code/langIcons/DockerIcon.js +89 -56
- package/dist/Plugins/code/langIcons/DotenvIcon.js +94 -56
- package/dist/Plugins/code/langIcons/ElixirIcon.js +91 -58
- package/dist/Plugins/code/langIcons/ElmIcon.js +105 -58
- package/dist/Plugins/code/langIcons/ErbIcon.js +90 -54
- package/dist/Plugins/code/langIcons/ErlangIcon.js +89 -56
- package/dist/Plugins/code/langIcons/FsharpIcon.js +93 -62
- package/dist/Plugins/code/langIcons/GdscriptIcon.js +96 -88
- package/dist/Plugins/code/langIcons/GlslIcon.js +90 -58
- package/dist/Plugins/code/langIcons/GnuplotIcon.js +98 -77
- package/dist/Plugins/code/langIcons/GoIcon.js +114 -93
- package/dist/Plugins/code/langIcons/GraphqlIcon.js +106 -66
- package/dist/Plugins/code/langIcons/GroovyIcon.js +89 -56
- package/dist/Plugins/code/langIcons/HackIcon.js +97 -64
- package/dist/Plugins/code/langIcons/HamlIcon.js +89 -56
- package/dist/Plugins/code/langIcons/HandlebarsIcon.js +89 -56
- package/dist/Plugins/code/langIcons/HaskellIcon.js +93 -64
- package/dist/Plugins/code/langIcons/HclIcon.js +118 -93
- package/dist/Plugins/code/langIcons/HclLightIcon.js +118 -97
- package/dist/Plugins/code/langIcons/HjsonIcon.js +94 -62
- package/dist/Plugins/code/langIcons/HlslIcon.js +96 -76
- package/dist/Plugins/code/langIcons/HtmlIcon.js +89 -56
- package/dist/Plugins/code/langIcons/HttpIcon.js +89 -56
- package/dist/Plugins/code/langIcons/ImbaIcon.js +98 -65
- package/dist/Plugins/code/langIcons/IniIcon.js +90 -54
- package/dist/Plugins/code/langIcons/JavaIcon.js +89 -56
- package/dist/Plugins/code/langIcons/JavascriptIcon.js +89 -56
- package/dist/Plugins/code/langIcons/JinjaIcon.js +100 -68
- package/dist/Plugins/code/langIcons/Json5Icon.js +100 -82
- package/dist/Plugins/code/langIcons/JsonIcon.js +89 -56
- package/dist/Plugins/code/langIcons/JsonnetIcon.js +102 -86
- package/dist/Plugins/code/langIcons/JuliaIcon.js +105 -52
- package/dist/Plugins/code/langIcons/KotlinIcon.js +104 -74
- package/dist/Plugins/code/langIcons/KustoIcon.js +90 -57
- package/dist/Plugins/code/langIcons/LessIcon.js +90 -57
- package/dist/Plugins/code/langIcons/LiquidIcon.js +91 -58
- package/dist/Plugins/code/langIcons/LispIcon.js +89 -56
- package/dist/Plugins/code/langIcons/LuaIcon.js +93 -60
- package/dist/Plugins/code/langIcons/MakefileIcon.js +91 -58
- package/dist/Plugins/code/langIcons/MarkdownIcon.js +89 -56
- package/dist/Plugins/code/langIcons/MarkojsIcon.js +96 -73
- package/dist/Plugins/code/langIcons/MatlabIcon.js +93 -64
- package/dist/Plugins/code/langIcons/MdxIcon.js +90 -53
- package/dist/Plugins/code/langIcons/MermaidIcon.js +95 -64
- package/dist/Plugins/code/langIcons/MojoIcon.js +95 -62
- package/dist/Plugins/code/langIcons/NginxIcon.js +94 -61
- package/dist/Plugins/code/langIcons/NimIcon.js +91 -54
- package/dist/Plugins/code/langIcons/NixIcon.js +92 -56
- package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +90 -59
- package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +90 -57
- package/dist/Plugins/code/langIcons/OcamlIcon.js +90 -61
- package/dist/Plugins/code/langIcons/PascalIcon.js +95 -55
- package/dist/Plugins/code/langIcons/Perl6Icon.js +299 -320
- package/dist/Plugins/code/langIcons/PerlIcon.js +89 -56
- package/dist/Plugins/code/langIcons/PhpIcon.js +89 -52
- package/dist/Plugins/code/langIcons/PostcssIcon.js +130 -113
- package/dist/Plugins/code/langIcons/PowershellIcon.js +91 -58
- package/dist/Plugins/code/langIcons/PrismaIcon.js +97 -68
- package/dist/Plugins/code/langIcons/PrologIcon.js +91 -58
- package/dist/Plugins/code/langIcons/ProtoIcon.js +94 -68
- package/dist/Plugins/code/langIcons/PugIcon.js +177 -145
- package/dist/Plugins/code/langIcons/PuppetIcon.js +96 -52
- package/dist/Plugins/code/langIcons/PurescriptIcon.js +93 -61
- package/dist/Plugins/code/langIcons/PythonIcon.js +90 -61
- package/dist/Plugins/code/langIcons/RIcon.js +89 -52
- package/dist/Plugins/code/langIcons/RazorIcon.js +90 -57
- package/dist/Plugins/code/langIcons/ReactIcon.js +89 -56
- package/dist/Plugins/code/langIcons/ReactTsIcon.js +90 -57
- package/dist/Plugins/code/langIcons/RubyIcon.js +91 -58
- package/dist/Plugins/code/langIcons/RustIcon.js +89 -56
- package/dist/Plugins/code/langIcons/SasIcon.js +89 -52
- package/dist/Plugins/code/langIcons/SassIcon.js +90 -57
- package/dist/Plugins/code/langIcons/ScalaIcon.js +96 -53
- package/dist/Plugins/code/langIcons/SchemeIcon.js +91 -58
- package/dist/Plugins/code/langIcons/ShaderlabIcon.js +89 -56
- package/dist/Plugins/code/langIcons/SolidityIcon.js +94 -52
- package/dist/Plugins/code/langIcons/SparqlIcon.js +94 -64
- package/dist/Plugins/code/langIcons/StataIcon.js +126 -108
- package/dist/Plugins/code/langIcons/StylusIcon.js +92 -59
- package/dist/Plugins/code/langIcons/SvelteIcon.js +91 -58
- package/dist/Plugins/code/langIcons/SwiftIcon.js +90 -57
- package/dist/Plugins/code/langIcons/SystemverilogIcon.js +115 -102
- package/dist/Plugins/code/langIcons/TclIcon.js +89 -52
- package/dist/Plugins/code/langIcons/TexIcon.js +99 -65
- package/dist/Plugins/code/langIcons/TomlIcon.js +94 -70
- package/dist/Plugins/code/langIcons/TwigIcon.js +89 -56
- package/dist/Plugins/code/langIcons/TypescriptIcon.js +93 -60
- package/dist/Plugins/code/langIcons/VerilogIcon.js +89 -56
- package/dist/Plugins/code/langIcons/VhdlIcon.js +94 -64
- package/dist/Plugins/code/langIcons/VimIcon.js +278 -420
- package/dist/Plugins/code/langIcons/VueIcon.js +92 -59
- package/dist/Plugins/code/langIcons/WebassemblyIcon.js +103 -76
- package/dist/Plugins/code/langIcons/WenyanIcon.js +104 -100
- package/dist/Plugins/code/langIcons/WgslIcon.js +93 -77
- package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +100 -71
- package/dist/Plugins/code/langIcons/XmlIcon.js +89 -52
- package/dist/Plugins/code/langIcons/XslIcon.js +94 -66
- package/dist/Plugins/code/langIcons/YamlIcon.js +89 -56
- package/dist/Plugins/code/langIcons/ZigIcon.js +106 -81
- package/dist/Plugins/code/langIcons/index.js +128 -259
- package/dist/Plugins/code/utils/index.js +5 -5
- package/dist/Plugins/code/utils/langOptions.js +86 -11
- package/dist/Plugins/defaultPlugins.js +9 -13
- package/dist/Plugins/formatter/index.js +205 -105
- package/dist/Plugins/index.js +6 -2
- package/dist/Plugins/katex/InlineKatex.js +196 -107
- package/dist/Plugins/katex/Katex.js +139 -65
- package/dist/Plugins/katex/index.js +163 -103
- package/dist/Plugins/mermaid/Mermaid.js +472 -197
- package/dist/Plugins/mermaid/index.js +237 -142
- package/dist/Quote/index.js +112 -73
- package/dist/Quote/style.js +176 -160
- package/dist/Schema/SchemaEditor/AceEditorWrapper.js +163 -119
- package/dist/Schema/SchemaEditor/index.js +385 -275
- package/dist/Schema/SchemaEditor/style.js +261 -269
- package/dist/Schema/SchemaForm/index.js +443 -268
- package/dist/Schema/SchemaForm/types.js +1 -0
- package/dist/Schema/SchemaRenderer/index.js +973 -588
- package/dist/Schema/SchemaRenderer/templateEngine.js +106 -26
- package/dist/Schema/index.js +7 -11
- package/dist/Schema/types.js +1 -0
- package/dist/Schema/validator.js +74 -36
- package/dist/TaskList/index.js +197 -142
- package/dist/TaskList/style.js +143 -122
- package/dist/ThoughtChainList/CostMillis.js +88 -54
- package/dist/ThoughtChainList/DeepThink.js +187 -152
- package/dist/ThoughtChainList/DotAni/index.js +29 -14
- package/dist/ThoughtChainList/DotAni/style.js +82 -50
- package/dist/ThoughtChainList/FlipText/index.js +74 -30
- package/dist/ThoughtChainList/MarkdownEditor.js +126 -72
- package/dist/ThoughtChainList/RagRetrievalInfo.js +113 -145
- package/dist/ThoughtChainList/TableSql.js +413 -459
- package/dist/ThoughtChainList/ThoughtChainListItem.js +388 -222
- package/dist/ThoughtChainList/TitleInfo.js +189 -185
- package/dist/ThoughtChainList/ToolCall.js +429 -463
- package/dist/ThoughtChainList/WebSearch.js +192 -162
- package/dist/ThoughtChainList/index.js +449 -410
- package/dist/ThoughtChainList/style.js +253 -232
- package/dist/ThoughtChainList/types.js +1 -0
- package/dist/ToolUseBar/ToolUseBarItem.js +183 -139
- package/dist/ToolUseBar/ToolUseBarItemComponents.js +345 -276
- package/dist/ToolUseBar/ToolUseBarThink.js +335 -396
- package/dist/ToolUseBar/index.js +226 -113
- package/dist/ToolUseBar/style.js +334 -308
- package/dist/ToolUseBar/thinkStyle.js +350 -328
- package/dist/Types/common.js +1 -0
- package/dist/Types/index.js +4 -2
- package/dist/Types/message.js +1 -0
- package/dist/Utils/easings.js +9 -12
- package/dist/Utils/formatTime.js +41 -17
- package/dist/Utils/getScroll.js +41 -41
- package/dist/Utils/language.js +355 -150
- package/dist/Utils/proxySandbox/ProxySandbox.js +1637 -1076
- package/dist/Utils/proxySandbox/SecurityContextManager.js +607 -343
- package/dist/Utils/proxySandbox/index.js +554 -267
- package/dist/Utils/proxySandbox/types.js +187 -52
- package/dist/Utils/scrollTo.js +48 -56
- package/dist/Utils/throttleByAnimationFrame.js +46 -20
- package/dist/WelcomeMessage/index.js +106 -58
- package/dist/WelcomeMessage/style.js +80 -55
- package/dist/Workspace/Browser/index.js +102 -40
- package/dist/Workspace/Browser/style.js +62 -33
- package/dist/Workspace/File/DataSourceStrategy.js +419 -217
- package/dist/Workspace/File/FileComponent.js +1004 -791
- package/dist/Workspace/File/FileTypeProcessor.js +337 -184
- package/dist/Workspace/File/PreviewComponent.js +472 -532
- package/dist/Workspace/File/index.js +3 -10
- package/dist/Workspace/File/style.js +397 -424
- package/dist/Workspace/File/utils.js +160 -106
- package/dist/Workspace/HtmlPreview/index.js +238 -137
- package/dist/Workspace/HtmlPreview/style.js +99 -77
- package/dist/Workspace/RealtimeFollow/index.js +411 -413
- package/dist/Workspace/RealtimeFollow/style.js +299 -303
- package/dist/Workspace/Task/index.js +53 -35
- package/dist/Workspace/Task/style.js +99 -73
- package/dist/Workspace/index.js +332 -254
- package/dist/Workspace/style.js +165 -146
- package/dist/Workspace/types.js +471 -252
- package/dist/Workspace/utils/codeLanguageUtils.js +148 -129
- package/dist/Workspace/utils.js +28 -20
- package/dist/index.js +27 -17
- package/package.json +3 -2
|
@@ -1,661 +1,1076 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
preString,
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
preString,
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
headingNode.
|
|
91
|
-
preString,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
str =
|
|
315
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
577
|
+
if (t.bold) str = "**".concat(str, "**");
|
|
578
|
+
if (t.italic) str = "*".concat(str, "*");
|
|
335
579
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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
|
-
|
|
553
|
-
|
|
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
|
-
|
|
577
|
-
|
|
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
|
-
|
|
586
|
-
|
|
901
|
+
var language = node.language || '';
|
|
902
|
+
if (!code.trim()) {
|
|
903
|
+
return "".concat(preString, "```").concat(language, "\n").concat(preString, "```");
|
|
587
904
|
}
|
|
588
|
-
|
|
589
|
-
|
|
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
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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(nodeImageUrl.toString(), ")");
|
|
976
|
+
} catch (e) {
|
|
977
|
+
console.warn('Invalid image URL:', node === null || node === void 0 ? void 0 : node.url, e);
|
|
978
|
+
return ".concat(encodeURI(node === null || node === void 0 ? void 0 : node.url), ")");
|
|
605
979
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
-
|
|
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(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
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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
|
-
|
|
638
|
-
|
|
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
|
-
|
|
641
|
-
|
|
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
|
-
|
|
644
|
-
|
|
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
|
-
|
|
647
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
* 处理水平分割线节点
|
|
1049
|
+
* @param preString - 前缀字符串,用于处理缩进
|
|
1050
|
+
* @returns 处理后的 Markdown 分割线字符串
|
|
1051
|
+
*/ var handleHr = function(preString) {
|
|
1052
|
+
return preString + '***';
|
|
648
1053
|
};
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
1054
|
+
/**
|
|
1055
|
+
* 处理换行节点
|
|
1056
|
+
* @param preString - 前缀字符串,用于处理缩进
|
|
1057
|
+
* @returns 处理后的 HTML 换行标签字符串
|
|
1058
|
+
*/ var handleBreak = function(preString) {
|
|
1059
|
+
return preString + '<br/>';
|
|
652
1060
|
};
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
};
|