@ant-design/agentic-ui 2.7.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -268
- 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.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.js +718 -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.js +86 -79
- 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 +465 -205
- package/dist/MarkdownInputField/AttachmentButton/style.js +143 -114
- package/dist/MarkdownInputField/AttachmentButton/types.js +3 -0
- package/dist/MarkdownInputField/AttachmentButton/utils.js +64 -34
- 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 +460 -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.d.ts +2 -0
- package/dist/Plugins/chart/ChartRender.js +981 -705
- 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 -87
- 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.d.ts +9 -4
- package/dist/Plugins/mermaid/Mermaid.js +475 -178
- 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,540 +1,1278 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable no-param-reassign */ function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
16
19
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
reject
|
|
27
|
-
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(undefined);
|
|
38
|
+
});
|
|
28
39
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
}
|
|
41
|
+
function _define_property(obj, key, value) {
|
|
42
|
+
if (key in obj) {
|
|
43
|
+
Object.defineProperty(obj, key, {
|
|
44
|
+
value: value,
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
obj[key] = value;
|
|
51
|
+
}
|
|
52
|
+
return obj;
|
|
53
|
+
}
|
|
54
|
+
function _iterable_to_array(iter) {
|
|
55
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
56
|
+
}
|
|
57
|
+
function _iterable_to_array_limit(arr, i) {
|
|
58
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
59
|
+
if (_i == null) return;
|
|
60
|
+
var _arr = [];
|
|
61
|
+
var _n = true;
|
|
62
|
+
var _d = false;
|
|
63
|
+
var _s, _e;
|
|
64
|
+
try {
|
|
65
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
66
|
+
_arr.push(_s.value);
|
|
67
|
+
if (i && _arr.length === i) break;
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
_d = true;
|
|
71
|
+
_e = err;
|
|
72
|
+
} finally{
|
|
73
|
+
try {
|
|
74
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
75
|
+
} finally{
|
|
76
|
+
if (_d) throw _e;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return _arr;
|
|
80
|
+
}
|
|
81
|
+
function _non_iterable_rest() {
|
|
82
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
83
|
+
}
|
|
84
|
+
function _non_iterable_spread() {
|
|
85
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
|
+
}
|
|
87
|
+
function _object_spread(target) {
|
|
88
|
+
for(var i = 1; i < arguments.length; i++){
|
|
89
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
90
|
+
var ownKeys = Object.keys(source);
|
|
91
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
92
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
93
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
ownKeys.forEach(function(key) {
|
|
97
|
+
_define_property(target, key, source[key]);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return target;
|
|
101
|
+
}
|
|
102
|
+
function ownKeys(object, enumerableOnly) {
|
|
103
|
+
var keys = Object.keys(object);
|
|
104
|
+
if (Object.getOwnPropertySymbols) {
|
|
105
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
106
|
+
if (enumerableOnly) {
|
|
107
|
+
symbols = symbols.filter(function(sym) {
|
|
108
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
keys.push.apply(keys, symbols);
|
|
112
|
+
}
|
|
113
|
+
return keys;
|
|
114
|
+
}
|
|
115
|
+
function _object_spread_props(target, source) {
|
|
116
|
+
source = source != null ? source : {};
|
|
117
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
118
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
119
|
+
} else {
|
|
120
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
121
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
126
|
+
function _sliced_to_array(arr, i) {
|
|
127
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
128
|
+
}
|
|
129
|
+
function _to_consumable_array(arr) {
|
|
130
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
131
|
+
}
|
|
132
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
133
|
+
if (!o) return;
|
|
134
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
135
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
136
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
137
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
138
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
139
|
+
}
|
|
140
|
+
function _ts_generator(thisArg, body) {
|
|
141
|
+
var f, y, t, g, _ = {
|
|
142
|
+
label: 0,
|
|
143
|
+
sent: function() {
|
|
144
|
+
if (t[0] & 1) throw t[1];
|
|
145
|
+
return t[1];
|
|
146
|
+
},
|
|
147
|
+
trys: [],
|
|
148
|
+
ops: []
|
|
35
149
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
150
|
+
return g = {
|
|
151
|
+
next: verb(0),
|
|
152
|
+
"throw": verb(1),
|
|
153
|
+
"return": verb(2)
|
|
154
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
155
|
+
return this;
|
|
156
|
+
}), g;
|
|
157
|
+
function verb(n) {
|
|
158
|
+
return function(v) {
|
|
159
|
+
return step([
|
|
160
|
+
n,
|
|
161
|
+
v
|
|
162
|
+
]);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function step(op) {
|
|
166
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
167
|
+
while(_)try {
|
|
168
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
169
|
+
if (y = 0, t) op = [
|
|
170
|
+
op[0] & 2,
|
|
171
|
+
t.value
|
|
172
|
+
];
|
|
173
|
+
switch(op[0]){
|
|
174
|
+
case 0:
|
|
175
|
+
case 1:
|
|
176
|
+
t = op;
|
|
177
|
+
break;
|
|
178
|
+
case 4:
|
|
179
|
+
_.label++;
|
|
180
|
+
return {
|
|
181
|
+
value: op[1],
|
|
182
|
+
done: false
|
|
183
|
+
};
|
|
184
|
+
case 5:
|
|
185
|
+
_.label++;
|
|
186
|
+
y = op[1];
|
|
187
|
+
op = [
|
|
188
|
+
0
|
|
189
|
+
];
|
|
190
|
+
continue;
|
|
191
|
+
case 7:
|
|
192
|
+
op = _.ops.pop();
|
|
193
|
+
_.trys.pop();
|
|
194
|
+
continue;
|
|
195
|
+
default:
|
|
196
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
197
|
+
_ = 0;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
201
|
+
_.label = op[1];
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
205
|
+
_.label = t[1];
|
|
206
|
+
t = op;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
if (t && _.label < t[2]) {
|
|
210
|
+
_.label = t[2];
|
|
211
|
+
_.ops.push(op);
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
if (t[2]) _.ops.pop();
|
|
215
|
+
_.trys.pop();
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
op = body.call(thisArg, _);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
op = [
|
|
221
|
+
6,
|
|
222
|
+
e
|
|
223
|
+
];
|
|
224
|
+
y = 0;
|
|
225
|
+
} finally{
|
|
226
|
+
f = t = 0;
|
|
227
|
+
}
|
|
228
|
+
if (op[0] & 5) throw op[1];
|
|
229
|
+
return {
|
|
230
|
+
value: op[0] ? op[1] : void 0,
|
|
231
|
+
done: true
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
42
235
|
import { message } from "antd";
|
|
43
236
|
import { Editor, Element, Node, Path, Range, Transforms } from "slate";
|
|
44
237
|
import { jsx } from "slate-hyperscript";
|
|
45
238
|
import { debugLog, EditorUtils } from "../utils";
|
|
46
239
|
import { docxDeserializer } from "../utils/docx/docxDeserializer";
|
|
47
240
|
import { BackspaceKey } from "./hotKeyCommands/backspace";
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var fragment = /* @__PURE__ */ new Set(["body", "figure", "div"]);
|
|
56
|
-
var ELEMENT_TAGS = {
|
|
57
|
-
BLOCKQUOTE: () => ({ type: "blockquote" }),
|
|
58
|
-
H1: () => ({ type: "head", level: 1 }),
|
|
59
|
-
H2: () => ({ type: "head", level: 2 }),
|
|
60
|
-
H3: () => ({ type: "head", level: 3 }),
|
|
61
|
-
H4: () => ({ type: "head", level: 4 }),
|
|
62
|
-
H5: () => ({ type: "head", level: 5 }),
|
|
63
|
-
TABLE: () => ({ type: "table" }),
|
|
64
|
-
IMG: (el) => {
|
|
65
|
-
const src = el.src;
|
|
66
|
-
const alt = el.alt;
|
|
67
|
-
const isValidImageUrl = (url) => {
|
|
68
|
-
if (!url)
|
|
69
|
-
return false;
|
|
70
|
-
if (url.startsWith("blob:") || url.startsWith("data:")) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
const imageExtensions = [
|
|
77
|
-
".jpg",
|
|
78
|
-
".jpeg",
|
|
79
|
-
".png",
|
|
80
|
-
".gif",
|
|
81
|
-
".svg",
|
|
82
|
-
".webp",
|
|
83
|
-
".bmp",
|
|
84
|
-
".ico"
|
|
85
|
-
];
|
|
86
|
-
const hasImageExtension = imageExtensions.some(
|
|
87
|
-
(ext) => url.toLowerCase().includes(ext)
|
|
88
|
-
);
|
|
89
|
-
const imagePaths = [
|
|
90
|
-
"/image",
|
|
91
|
-
"/img",
|
|
92
|
-
"/photo",
|
|
93
|
-
"/picture",
|
|
94
|
-
"/avatar",
|
|
95
|
-
"/icon"
|
|
96
|
-
];
|
|
97
|
-
const hasImagePath = imagePaths.some(
|
|
98
|
-
(path) => url.toLowerCase().includes(path)
|
|
99
|
-
);
|
|
100
|
-
const hasImageContentType = url.includes("image/") || url.includes("img/");
|
|
101
|
-
return hasImageExtension || hasImagePath || hasImageContentType;
|
|
102
|
-
};
|
|
103
|
-
if (!isValidImageUrl(src)) {
|
|
104
|
-
return {
|
|
105
|
-
type: "paragraph",
|
|
106
|
-
children: [{ text: src || alt || "图片链接" }]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return EditorUtils.createMediaNode(src, "image", {
|
|
110
|
-
alt,
|
|
111
|
-
downloadUrl: src && /^https?:/.test(src) ? src : void 0
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
TR: () => ({ type: "table-row" }),
|
|
115
|
-
TH: () => ({ type: "table-cell", title: true }),
|
|
116
|
-
TD: () => ({ type: "table-cell" }),
|
|
117
|
-
LI: () => ({ type: "list-item" }),
|
|
118
|
-
OL: () => ({ type: "list", order: true }),
|
|
119
|
-
P: () => ({ type: "paragraph" }),
|
|
120
|
-
PRE: () => ({ type: "code" }),
|
|
121
|
-
UL: () => ({ type: "list" })
|
|
241
|
+
// 性能优化常量
|
|
242
|
+
var BATCH_SIZE = 10; // 每批处理的节点数量
|
|
243
|
+
var BATCH_DELAY = 16; // 每批之间的延迟时间(ms),约60fps
|
|
244
|
+
var MAX_SYNC_SIZE = 1000; // 同步处理的最大字符数
|
|
245
|
+
var findElementByNode = function(node) {
|
|
246
|
+
var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
|
|
247
|
+
return node.parentElement.children[index];
|
|
122
248
|
};
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
249
|
+
var fragment = new Set([
|
|
250
|
+
'body',
|
|
251
|
+
'figure',
|
|
252
|
+
'div'
|
|
253
|
+
]);
|
|
254
|
+
export var ELEMENT_TAGS = {
|
|
255
|
+
BLOCKQUOTE: function() {
|
|
256
|
+
return {
|
|
257
|
+
type: 'blockquote'
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
H1: function() {
|
|
261
|
+
return {
|
|
262
|
+
type: 'head',
|
|
263
|
+
level: 1
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
H2: function() {
|
|
267
|
+
return {
|
|
268
|
+
type: 'head',
|
|
269
|
+
level: 2
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
H3: function() {
|
|
273
|
+
return {
|
|
274
|
+
type: 'head',
|
|
275
|
+
level: 3
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
H4: function() {
|
|
279
|
+
return {
|
|
280
|
+
type: 'head',
|
|
281
|
+
level: 4
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
H5: function() {
|
|
285
|
+
return {
|
|
286
|
+
type: 'head',
|
|
287
|
+
level: 5
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
TABLE: function() {
|
|
291
|
+
return {
|
|
292
|
+
type: 'table'
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
IMG: function(el) {
|
|
296
|
+
// 添加更严格的图片URL验证,避免将普通URL误识别为图片
|
|
297
|
+
var src = el.src;
|
|
298
|
+
var alt = el.alt;
|
|
299
|
+
// 检查是否为有效的图片URL
|
|
300
|
+
var isValidImageUrl = function(url) {
|
|
301
|
+
if (!url) return false;
|
|
302
|
+
// 检查是否为blob URL或data URL
|
|
303
|
+
if (url.startsWith('blob:') || url.startsWith('data:')) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
// 检查是否为有效的HTTP/HTTPS URL
|
|
307
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
// 检查URL是否包含图片文件扩展名
|
|
311
|
+
var imageExtensions = [
|
|
312
|
+
'.jpg',
|
|
313
|
+
'.jpeg',
|
|
314
|
+
'.png',
|
|
315
|
+
'.gif',
|
|
316
|
+
'.svg',
|
|
317
|
+
'.webp',
|
|
318
|
+
'.bmp',
|
|
319
|
+
'.ico'
|
|
320
|
+
];
|
|
321
|
+
var hasImageExtension = imageExtensions.some(function(ext) {
|
|
322
|
+
return url.toLowerCase().includes(ext);
|
|
323
|
+
});
|
|
324
|
+
// 检查URL是否包含图片相关的路径
|
|
325
|
+
var imagePaths = [
|
|
326
|
+
'/image',
|
|
327
|
+
'/img',
|
|
328
|
+
'/photo',
|
|
329
|
+
'/picture',
|
|
330
|
+
'/avatar',
|
|
331
|
+
'/icon'
|
|
332
|
+
];
|
|
333
|
+
var hasImagePath = imagePaths.some(function(path) {
|
|
334
|
+
return url.toLowerCase().includes(path);
|
|
335
|
+
});
|
|
336
|
+
// 检查Content-Type(如果可能的话)
|
|
337
|
+
var hasImageContentType = url.includes('image/') || url.includes('img/');
|
|
338
|
+
// 如果URL看起来像图片,或者是明确的图片URL,则认为是有效的
|
|
339
|
+
return hasImageExtension || hasImagePath || hasImageContentType;
|
|
340
|
+
};
|
|
341
|
+
// 如果URL不是有效的图片URL,则作为普通文本处理
|
|
342
|
+
if (!isValidImageUrl(src)) {
|
|
200
343
|
return {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
]
|
|
344
|
+
type: 'paragraph',
|
|
345
|
+
children: [
|
|
346
|
+
{
|
|
347
|
+
text: src || alt || '图片链接'
|
|
348
|
+
}
|
|
349
|
+
]
|
|
208
350
|
};
|
|
209
|
-
}
|
|
210
351
|
}
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
352
|
+
return EditorUtils.createMediaNode(src, 'image', {
|
|
353
|
+
alt: alt,
|
|
354
|
+
downloadUrl: src && /^https?:/.test(src) ? src : undefined
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
TR: function() {
|
|
358
|
+
return {
|
|
359
|
+
type: 'table-row'
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
TH: function() {
|
|
363
|
+
return {
|
|
364
|
+
type: 'table-cell',
|
|
365
|
+
title: true
|
|
366
|
+
};
|
|
367
|
+
},
|
|
368
|
+
TD: function() {
|
|
369
|
+
return {
|
|
370
|
+
type: 'table-cell'
|
|
371
|
+
};
|
|
372
|
+
},
|
|
373
|
+
LI: function() {
|
|
374
|
+
return {
|
|
375
|
+
type: 'list-item'
|
|
376
|
+
};
|
|
377
|
+
},
|
|
378
|
+
OL: function() {
|
|
379
|
+
return {
|
|
380
|
+
type: 'list',
|
|
381
|
+
order: true
|
|
382
|
+
};
|
|
383
|
+
},
|
|
384
|
+
P: function() {
|
|
385
|
+
return {
|
|
386
|
+
type: 'paragraph'
|
|
387
|
+
};
|
|
388
|
+
},
|
|
389
|
+
PRE: function() {
|
|
390
|
+
return {
|
|
391
|
+
type: 'code'
|
|
392
|
+
};
|
|
393
|
+
},
|
|
394
|
+
UL: function() {
|
|
395
|
+
return {
|
|
396
|
+
type: 'list'
|
|
397
|
+
};
|
|
215
398
|
}
|
|
216
|
-
}
|
|
217
|
-
if (TEXT_TAGS[nodeName]) {
|
|
218
|
-
const attrs = TEXT_TAGS[nodeName](el);
|
|
219
|
-
return children.map((child) => {
|
|
220
|
-
return jsx("text", attrs, child);
|
|
221
|
-
}).filter((c) => !!c.text);
|
|
222
|
-
}
|
|
223
|
-
return children;
|
|
224
|
-
};
|
|
225
|
-
var parserCodeText = (el) => {
|
|
226
|
-
el.innerHTML = el.innerHTML.replace(/<br\/?>|<\/div>(?=\S)/g, "\n");
|
|
227
|
-
return el.innerText;
|
|
228
399
|
};
|
|
229
|
-
var
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
400
|
+
export var TEXT_TAGS = {
|
|
401
|
+
A: function(el) {
|
|
402
|
+
return {
|
|
403
|
+
url: el.getAttribute('href')
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
CODE: function() {
|
|
407
|
+
return {
|
|
408
|
+
code: true
|
|
409
|
+
};
|
|
410
|
+
},
|
|
411
|
+
KBD: function() {
|
|
412
|
+
return {
|
|
413
|
+
code: true
|
|
414
|
+
};
|
|
415
|
+
},
|
|
416
|
+
SPAN: function(el) {
|
|
417
|
+
return {
|
|
418
|
+
text: el.textContent
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
DEL: function() {
|
|
422
|
+
return {
|
|
423
|
+
strikethrough: true
|
|
424
|
+
};
|
|
425
|
+
},
|
|
426
|
+
EM: function() {
|
|
427
|
+
return {
|
|
428
|
+
italic: true
|
|
429
|
+
};
|
|
430
|
+
},
|
|
431
|
+
I: function() {
|
|
432
|
+
return {
|
|
433
|
+
italic: true
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
S: function() {
|
|
437
|
+
return {
|
|
438
|
+
strikethrough: true
|
|
439
|
+
};
|
|
440
|
+
},
|
|
441
|
+
STRONG: function() {
|
|
442
|
+
return {
|
|
443
|
+
bold: true
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
B: function() {
|
|
447
|
+
return {
|
|
448
|
+
bold: true
|
|
449
|
+
};
|
|
234
450
|
}
|
|
235
|
-
if (n == null ? void 0 : n.children) {
|
|
236
|
-
text.push(...getTextsNode(n.children));
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return text;
|
|
240
451
|
};
|
|
241
|
-
var
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
452
|
+
export var deserialize = function(el) {
|
|
453
|
+
var parentTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
|
|
454
|
+
if (el.nodeName.toLowerCase() === 'script') return [];
|
|
455
|
+
if (el.nodeName.toLowerCase() === 'style') return [];
|
|
456
|
+
if (el.nodeName.toLowerCase() === 'meta') return [];
|
|
457
|
+
if (el.nodeName.toLowerCase() === 'link') return [];
|
|
458
|
+
if (el.nodeName.toLowerCase() === 'head') return [];
|
|
459
|
+
if (el.nodeName.toLowerCase() === 'colgroup') return [];
|
|
460
|
+
if (el.nodeName.toLowerCase() === 'noscript') return [];
|
|
461
|
+
if (el.nodeType === 3) {
|
|
462
|
+
return el.textContent;
|
|
463
|
+
} else if (el.nodeType !== 1) {
|
|
464
|
+
return null;
|
|
465
|
+
} else if (el.nodeName === 'BR') {
|
|
466
|
+
return '\n';
|
|
256
467
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
yield Promise.all(
|
|
270
|
-
batch.map((fragment2) => __async(void 0, null, function* () {
|
|
271
|
-
var _a, _b;
|
|
272
|
-
const url = fragment2.url;
|
|
273
|
-
if (url == null ? void 0 : url.startsWith("blob:")) {
|
|
274
|
-
const file = yield blobToFile(fragment2 == null ? void 0 : fragment2.url, "image.png");
|
|
275
|
-
if ((_a = editorProps.image) == null ? void 0 : _a.upload) {
|
|
276
|
-
const serverUrl = [yield editorProps.image.upload([file])].flat(
|
|
277
|
-
1
|
|
278
|
-
);
|
|
279
|
-
fragment2.url = serverUrl == null ? void 0 : serverUrl[0];
|
|
280
|
-
fragment2.downloadUrl = serverUrl == null ? void 0 : serverUrl[0];
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
if ((_b = editorProps.image) == null ? void 0 : _b.upload) {
|
|
284
|
-
const serverUrl = [
|
|
285
|
-
yield editorProps.image.upload([fragment2 == null ? void 0 : fragment2.url])
|
|
286
|
-
].flat(1);
|
|
287
|
-
fragment2.url = serverUrl == null ? void 0 : serverUrl[0];
|
|
288
|
-
fragment2.downloadUrl = serverUrl == null ? void 0 : serverUrl[0];
|
|
468
|
+
var nodeName = el.nodeName;
|
|
469
|
+
var target = el;
|
|
470
|
+
if (nodeName === 'PRE' && el.childNodes[0] && el.childNodes[0].nodeName === 'CODE') {
|
|
471
|
+
target = el.childNodes[0];
|
|
472
|
+
}
|
|
473
|
+
var children = Array.from(target.childNodes).map(function(n) {
|
|
474
|
+
return deserialize(n, target.nodeName.toLowerCase().toLowerCase());
|
|
475
|
+
}).flat();
|
|
476
|
+
if (children.length === 0) {
|
|
477
|
+
children = [
|
|
478
|
+
{
|
|
479
|
+
text: el.textContent || ''
|
|
289
480
|
}
|
|
290
|
-
|
|
291
|
-
}))
|
|
292
|
-
);
|
|
293
|
-
const progress = Math.min(
|
|
294
|
-
(i + BATCH_SIZE) / mediaFragments.length * 100,
|
|
295
|
-
100
|
|
296
|
-
);
|
|
297
|
-
hideLoading();
|
|
298
|
-
message.loading(
|
|
299
|
-
`Uploading ${mediaFragments.length} files... ${Math.round(progress)}%`,
|
|
300
|
-
0
|
|
301
|
-
);
|
|
302
|
-
if (i + BATCH_SIZE < mediaFragments.length) {
|
|
303
|
-
yield new Promise((resolve) => setTimeout(resolve, BATCH_DELAY));
|
|
304
|
-
}
|
|
481
|
+
];
|
|
305
482
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
console.error("文件上传失败:", error);
|
|
309
|
-
message.error("Some files failed to upload");
|
|
310
|
-
} finally {
|
|
311
|
-
hideLoading();
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
var insertNodesBatch = (editor, nodes, at, options) => __async(void 0, null, function* () {
|
|
315
|
-
if (nodes.length <= BATCH_SIZE) {
|
|
316
|
-
Transforms.insertNodes(editor, nodes, __spreadValues({ at }, options));
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
for (let i = 0; i < nodes.length; i += BATCH_SIZE) {
|
|
320
|
-
const batch = nodes.slice(i, i + BATCH_SIZE);
|
|
321
|
-
const insertAt = at ? [...at.slice(0, -1), at[at.length - 1] + i] : void 0;
|
|
322
|
-
Transforms.insertNodes(editor, batch, {
|
|
323
|
-
at: insertAt,
|
|
324
|
-
select: (options == null ? void 0 : options.select) && i + BATCH_SIZE >= nodes.length
|
|
325
|
-
});
|
|
326
|
-
if (i + BATCH_SIZE < nodes.length) {
|
|
327
|
-
yield new Promise((resolve) => setTimeout(resolve, BATCH_DELAY));
|
|
483
|
+
if (fragment.has(el.nodeName.toLowerCase())) {
|
|
484
|
+
return jsx('fragment', {}, children);
|
|
328
485
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return docxDeserializer(rtf, html.trim());
|
|
334
|
-
}
|
|
335
|
-
return new Promise((resolve) => {
|
|
336
|
-
const processInIdle = () => {
|
|
337
|
-
try {
|
|
338
|
-
const result = docxDeserializer(rtf, html.trim());
|
|
339
|
-
resolve(result);
|
|
340
|
-
} catch (error) {
|
|
341
|
-
console.error("HTML解析失败:", error);
|
|
342
|
-
resolve([]);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
if ("requestIdleCallback" in window) {
|
|
346
|
-
requestIdleCallback(processInIdle, { timeout: 1e3 });
|
|
347
|
-
} else {
|
|
348
|
-
setTimeout(processInIdle, 0);
|
|
486
|
+
if (TEXT_TAGS[nodeName] && Array.from(el.childNodes).some(function(e) {
|
|
487
|
+
return e.nodeType !== 3 && !TEXT_TAGS[e.nodeName];
|
|
488
|
+
})) {
|
|
489
|
+
return jsx('fragment', {}, children);
|
|
349
490
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
491
|
+
if (ELEMENT_TAGS[nodeName]) {
|
|
492
|
+
if (!parentTag || ![
|
|
493
|
+
'h1',
|
|
494
|
+
'h2',
|
|
495
|
+
'code',
|
|
496
|
+
'h3',
|
|
497
|
+
'h4',
|
|
498
|
+
'h5',
|
|
499
|
+
'th',
|
|
500
|
+
'td'
|
|
501
|
+
].includes(parentTag)) {
|
|
502
|
+
if (nodeName === 'PRE') {
|
|
503
|
+
var dom = findElementByNode(el);
|
|
504
|
+
var dataset = dom.dataset;
|
|
505
|
+
var inner = (dataset === null || dataset === void 0 ? void 0 : dataset.blType) === 'code';
|
|
506
|
+
if (inner) {
|
|
507
|
+
var value = Array.from(target.childNodes.values()).map(function(n) {
|
|
508
|
+
var _n_textContent_replace, _n_textContent;
|
|
509
|
+
return (_n_textContent = n.textContent) === null || _n_textContent === void 0 ? void 0 : (_n_textContent_replace = _n_textContent.replace(/\n/g, '')) === null || _n_textContent_replace === void 0 ? void 0 : _n_textContent_replace.replace(/\t/g, ' ');
|
|
510
|
+
});
|
|
511
|
+
return {
|
|
512
|
+
type: 'code',
|
|
513
|
+
language: dataset === null || dataset === void 0 ? void 0 : dataset.blLang,
|
|
514
|
+
value: value,
|
|
515
|
+
children: [
|
|
516
|
+
{
|
|
517
|
+
text: value
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
};
|
|
521
|
+
} else {
|
|
522
|
+
var text = parserCodeText(findElementByNode(target));
|
|
523
|
+
if (text) {
|
|
524
|
+
return {
|
|
525
|
+
type: 'code',
|
|
526
|
+
value: text,
|
|
527
|
+
children: [
|
|
528
|
+
{
|
|
529
|
+
text: text
|
|
530
|
+
}
|
|
531
|
+
]
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
// @ts-ignore
|
|
538
|
+
var attrs = ELEMENT_TAGS[nodeName](el);
|
|
539
|
+
return jsx('element', attrs, children);
|
|
540
|
+
}
|
|
357
541
|
}
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
children
|
|
362
|
-
|
|
542
|
+
if (TEXT_TAGS[nodeName]) {
|
|
543
|
+
// @ts-ignore
|
|
544
|
+
var attrs1 = TEXT_TAGS[nodeName](el);
|
|
545
|
+
return children.map(function(child) {
|
|
546
|
+
return jsx('text', attrs1, child);
|
|
547
|
+
}).filter(function(c) {
|
|
548
|
+
return !!c.text;
|
|
549
|
+
});
|
|
363
550
|
}
|
|
364
|
-
return
|
|
365
|
-
});
|
|
551
|
+
return children;
|
|
366
552
|
};
|
|
367
|
-
var
|
|
368
|
-
|
|
369
|
-
return
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const selection = editor.selection;
|
|
385
|
-
if (!selection || !Editor.hasPath(editor, selection.anchor.path)) {
|
|
386
|
-
const processedNodes2 = fragmentList == null ? void 0 : fragmentList.map((item) => {
|
|
387
|
-
if (!item.type) {
|
|
388
|
-
return { type: "paragraph", children: [item] };
|
|
553
|
+
var parserCodeText = function(el) {
|
|
554
|
+
el.innerHTML = el.innerHTML.replace(/<br\/?>|<\/div>(?=\S)/g, '\n');
|
|
555
|
+
return el.innerText;
|
|
556
|
+
};
|
|
557
|
+
var getTextsNode = function(nodes) {
|
|
558
|
+
var text = [];
|
|
559
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
560
|
+
try {
|
|
561
|
+
for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
562
|
+
var n = _step.value;
|
|
563
|
+
if (n.text) {
|
|
564
|
+
text.push(n);
|
|
565
|
+
}
|
|
566
|
+
if (n === null || n === void 0 ? void 0 : n.children) {
|
|
567
|
+
var _text;
|
|
568
|
+
(_text = text).push.apply(_text, _to_consumable_array(getTextsNode(n.children)));
|
|
569
|
+
}
|
|
389
570
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (editor.children.length > 1 && ((_b = node2 == null ? void 0 : node2[0]) == null ? void 0 : _b.type) === "paragraph" && !Node.string(node2[0])) {
|
|
403
|
-
Transforms.delete(editor, { at: [0] });
|
|
571
|
+
} catch (err) {
|
|
572
|
+
_didIteratorError = true;
|
|
573
|
+
_iteratorError = err;
|
|
574
|
+
} finally{
|
|
575
|
+
try {
|
|
576
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
577
|
+
_iterator.return();
|
|
578
|
+
}
|
|
579
|
+
} finally{
|
|
580
|
+
if (_didIteratorError) {
|
|
581
|
+
throw _iteratorError;
|
|
582
|
+
}
|
|
404
583
|
}
|
|
405
|
-
});
|
|
406
584
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
585
|
+
return text;
|
|
586
|
+
};
|
|
587
|
+
var blobToFile = /*#__PURE__*/ function() {
|
|
588
|
+
var _ref = _async_to_generator(function(blobUrl, fileName) {
|
|
589
|
+
var blob, file;
|
|
590
|
+
return _ts_generator(this, function(_state) {
|
|
591
|
+
switch(_state.label){
|
|
592
|
+
case 0:
|
|
593
|
+
return [
|
|
594
|
+
4,
|
|
595
|
+
fetch(blobUrl).then(function(r) {
|
|
596
|
+
return r.blob();
|
|
597
|
+
})
|
|
598
|
+
];
|
|
599
|
+
case 1:
|
|
600
|
+
blob = _state.sent();
|
|
601
|
+
file = new File([
|
|
602
|
+
blob
|
|
603
|
+
], fileName);
|
|
604
|
+
return [
|
|
605
|
+
2,
|
|
606
|
+
file
|
|
607
|
+
];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
410
610
|
});
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
611
|
+
return function blobToFile(blobUrl, fileName) {
|
|
612
|
+
return _ref.apply(this, arguments);
|
|
613
|
+
};
|
|
614
|
+
}();
|
|
615
|
+
/**
|
|
616
|
+
* 分段处理文件上传,避免阻塞主线程
|
|
617
|
+
*/ var upLoadFileBatch = /*#__PURE__*/ function() {
|
|
618
|
+
var _ref = _async_to_generator(function(fragmentList, editorProps) {
|
|
619
|
+
var mediaFragments, collectMediaFragments, hideLoading, i, batch, progress, error;
|
|
620
|
+
return _ts_generator(this, function(_state) {
|
|
621
|
+
switch(_state.label){
|
|
622
|
+
case 0:
|
|
623
|
+
mediaFragments = [];
|
|
624
|
+
// 收集所有需要上传的媒体文件
|
|
625
|
+
collectMediaFragments = function(fragments) {
|
|
626
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
627
|
+
try {
|
|
628
|
+
for(var _iterator = fragments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
629
|
+
var fragment = _step.value;
|
|
630
|
+
if (fragment.type === 'media') {
|
|
631
|
+
mediaFragments.push(fragment);
|
|
632
|
+
}
|
|
633
|
+
if (fragment === null || fragment === void 0 ? void 0 : fragment.children) {
|
|
634
|
+
collectMediaFragments(fragment.children);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
} catch (err) {
|
|
638
|
+
_didIteratorError = true;
|
|
639
|
+
_iteratorError = err;
|
|
640
|
+
} finally{
|
|
641
|
+
try {
|
|
642
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
643
|
+
_iterator.return();
|
|
644
|
+
}
|
|
645
|
+
} finally{
|
|
646
|
+
if (_didIteratorError) {
|
|
647
|
+
throw _iteratorError;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
collectMediaFragments(fragmentList);
|
|
653
|
+
if (mediaFragments.length === 0) {
|
|
654
|
+
return [
|
|
655
|
+
2
|
|
656
|
+
];
|
|
657
|
+
}
|
|
658
|
+
// 显示上传进度
|
|
659
|
+
hideLoading = message.loading("Uploading ".concat(mediaFragments.length, " files..."), 0);
|
|
660
|
+
_state.label = 1;
|
|
661
|
+
case 1:
|
|
662
|
+
_state.trys.push([
|
|
663
|
+
1,
|
|
664
|
+
7,
|
|
665
|
+
8,
|
|
666
|
+
9
|
|
667
|
+
]);
|
|
668
|
+
i = 0;
|
|
669
|
+
_state.label = 2;
|
|
670
|
+
case 2:
|
|
671
|
+
if (!(i < mediaFragments.length)) return [
|
|
672
|
+
3,
|
|
673
|
+
6
|
|
674
|
+
];
|
|
675
|
+
batch = mediaFragments.slice(i, i + BATCH_SIZE);
|
|
676
|
+
return [
|
|
677
|
+
4,
|
|
678
|
+
Promise.all(batch.map(/*#__PURE__*/ function() {
|
|
679
|
+
var _ref = _async_to_generator(function(fragment) {
|
|
680
|
+
var url, _editorProps_image, file, serverUrl, _editorProps_image1, serverUrl1;
|
|
681
|
+
return _ts_generator(this, function(_state) {
|
|
682
|
+
switch(_state.label){
|
|
683
|
+
case 0:
|
|
684
|
+
url = fragment.url;
|
|
685
|
+
if (!(url === null || url === void 0 ? void 0 : url.startsWith('blob:'))) return [
|
|
686
|
+
3,
|
|
687
|
+
4
|
|
688
|
+
];
|
|
689
|
+
return [
|
|
690
|
+
4,
|
|
691
|
+
blobToFile(fragment === null || fragment === void 0 ? void 0 : fragment.url, 'image.png')
|
|
692
|
+
];
|
|
693
|
+
case 1:
|
|
694
|
+
file = _state.sent();
|
|
695
|
+
if (!((_editorProps_image = editorProps.image) === null || _editorProps_image === void 0 ? void 0 : _editorProps_image.upload)) return [
|
|
696
|
+
3,
|
|
697
|
+
3
|
|
698
|
+
];
|
|
699
|
+
return [
|
|
700
|
+
4,
|
|
701
|
+
editorProps.image.upload([
|
|
702
|
+
file
|
|
703
|
+
])
|
|
704
|
+
];
|
|
705
|
+
case 2:
|
|
706
|
+
serverUrl = [
|
|
707
|
+
_state.sent()
|
|
708
|
+
].flat(1);
|
|
709
|
+
fragment.url = serverUrl === null || serverUrl === void 0 ? void 0 : serverUrl[0];
|
|
710
|
+
fragment.downloadUrl = serverUrl === null || serverUrl === void 0 ? void 0 : serverUrl[0];
|
|
711
|
+
_state.label = 3;
|
|
712
|
+
case 3:
|
|
713
|
+
return [
|
|
714
|
+
3,
|
|
715
|
+
6
|
|
716
|
+
];
|
|
717
|
+
case 4:
|
|
718
|
+
if (!((_editorProps_image1 = editorProps.image) === null || _editorProps_image1 === void 0 ? void 0 : _editorProps_image1.upload)) return [
|
|
719
|
+
3,
|
|
720
|
+
6
|
|
721
|
+
];
|
|
722
|
+
return [
|
|
723
|
+
4,
|
|
724
|
+
editorProps.image.upload([
|
|
725
|
+
fragment === null || fragment === void 0 ? void 0 : fragment.url
|
|
726
|
+
])
|
|
727
|
+
];
|
|
728
|
+
case 5:
|
|
729
|
+
serverUrl1 = [
|
|
730
|
+
_state.sent()
|
|
731
|
+
].flat(1);
|
|
732
|
+
fragment.url = serverUrl1 === null || serverUrl1 === void 0 ? void 0 : serverUrl1[0];
|
|
733
|
+
fragment.downloadUrl = serverUrl1 === null || serverUrl1 === void 0 ? void 0 : serverUrl1[0];
|
|
734
|
+
_state.label = 6;
|
|
735
|
+
case 6:
|
|
736
|
+
return [
|
|
737
|
+
2
|
|
738
|
+
];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
return function(fragment) {
|
|
743
|
+
return _ref.apply(this, arguments);
|
|
744
|
+
};
|
|
745
|
+
}()))
|
|
746
|
+
];
|
|
747
|
+
case 3:
|
|
748
|
+
_state.sent();
|
|
749
|
+
// 更新进度
|
|
750
|
+
progress = Math.min((i + BATCH_SIZE) / mediaFragments.length * 100, 100);
|
|
751
|
+
hideLoading();
|
|
752
|
+
message.loading("Uploading ".concat(mediaFragments.length, " files... ").concat(Math.round(progress), "%"), 0);
|
|
753
|
+
if (!(i + BATCH_SIZE < mediaFragments.length)) return [
|
|
754
|
+
3,
|
|
755
|
+
5
|
|
756
|
+
];
|
|
757
|
+
return [
|
|
758
|
+
4,
|
|
759
|
+
new Promise(function(resolve) {
|
|
760
|
+
return setTimeout(resolve, BATCH_DELAY);
|
|
761
|
+
})
|
|
762
|
+
];
|
|
763
|
+
case 4:
|
|
764
|
+
_state.sent();
|
|
765
|
+
_state.label = 5;
|
|
766
|
+
case 5:
|
|
767
|
+
i += BATCH_SIZE;
|
|
768
|
+
return [
|
|
769
|
+
3,
|
|
770
|
+
2
|
|
771
|
+
];
|
|
772
|
+
case 6:
|
|
773
|
+
message.success('Upload completed');
|
|
774
|
+
return [
|
|
775
|
+
3,
|
|
776
|
+
9
|
|
777
|
+
];
|
|
778
|
+
case 7:
|
|
779
|
+
error = _state.sent();
|
|
780
|
+
console.error('文件上传失败:', error);
|
|
781
|
+
message.error('Some files failed to upload');
|
|
782
|
+
return [
|
|
783
|
+
3,
|
|
784
|
+
9
|
|
785
|
+
];
|
|
786
|
+
case 8:
|
|
787
|
+
hideLoading();
|
|
788
|
+
return [
|
|
789
|
+
7
|
|
790
|
+
];
|
|
791
|
+
case 9:
|
|
792
|
+
return [
|
|
793
|
+
2
|
|
794
|
+
];
|
|
795
|
+
}
|
|
508
796
|
});
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
797
|
+
});
|
|
798
|
+
return function upLoadFileBatch(fragmentList, editorProps) {
|
|
799
|
+
return _ref.apply(this, arguments);
|
|
800
|
+
};
|
|
801
|
+
}();
|
|
802
|
+
/**
|
|
803
|
+
* 分段插入节点,避免一次性插入大量内容导致卡顿
|
|
804
|
+
*/ var insertNodesBatch = /*#__PURE__*/ function() {
|
|
805
|
+
var _ref = _async_to_generator(function(editor, nodes, at, options) {
|
|
806
|
+
var i, batch, insertAt;
|
|
807
|
+
return _ts_generator(this, function(_state) {
|
|
808
|
+
switch(_state.label){
|
|
809
|
+
case 0:
|
|
810
|
+
if (nodes.length <= BATCH_SIZE) {
|
|
811
|
+
// 小批量直接插入
|
|
812
|
+
Transforms.insertNodes(editor, nodes, _object_spread({
|
|
813
|
+
at: at
|
|
814
|
+
}, options));
|
|
815
|
+
return [
|
|
816
|
+
2
|
|
817
|
+
];
|
|
818
|
+
}
|
|
819
|
+
i = 0;
|
|
820
|
+
_state.label = 1;
|
|
821
|
+
case 1:
|
|
822
|
+
if (!(i < nodes.length)) return [
|
|
823
|
+
3,
|
|
824
|
+
4
|
|
825
|
+
];
|
|
826
|
+
batch = nodes.slice(i, i + BATCH_SIZE);
|
|
827
|
+
// 计算插入位置
|
|
828
|
+
insertAt = at ? _to_consumable_array(at.slice(0, -1)).concat([
|
|
829
|
+
at[at.length - 1] + i
|
|
830
|
+
]) : undefined;
|
|
831
|
+
Transforms.insertNodes(editor, batch, {
|
|
832
|
+
at: insertAt,
|
|
833
|
+
select: (options === null || options === void 0 ? void 0 : options.select) && i + BATCH_SIZE >= nodes.length
|
|
834
|
+
});
|
|
835
|
+
if (!(i + BATCH_SIZE < nodes.length)) return [
|
|
836
|
+
3,
|
|
837
|
+
3
|
|
838
|
+
];
|
|
839
|
+
return [
|
|
840
|
+
4,
|
|
841
|
+
new Promise(function(resolve) {
|
|
842
|
+
return setTimeout(resolve, BATCH_DELAY);
|
|
843
|
+
})
|
|
844
|
+
];
|
|
845
|
+
case 2:
|
|
846
|
+
_state.sent();
|
|
847
|
+
_state.label = 3;
|
|
848
|
+
case 3:
|
|
849
|
+
i += BATCH_SIZE;
|
|
850
|
+
return [
|
|
851
|
+
3,
|
|
852
|
+
1
|
|
853
|
+
];
|
|
854
|
+
case 4:
|
|
855
|
+
return [
|
|
856
|
+
2
|
|
857
|
+
];
|
|
858
|
+
}
|
|
521
859
|
});
|
|
522
|
-
}
|
|
523
|
-
return item;
|
|
524
860
|
});
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
861
|
+
return function insertNodesBatch(editor, nodes, at, options) {
|
|
862
|
+
return _ref.apply(this, arguments);
|
|
863
|
+
};
|
|
864
|
+
}();
|
|
865
|
+
/**
|
|
866
|
+
* 优化的HTML解析函数,支持分段处理
|
|
867
|
+
*/ var parseHtmlOptimized = /*#__PURE__*/ function() {
|
|
868
|
+
var _ref = _async_to_generator(function(html, rtf) {
|
|
869
|
+
return _ts_generator(this, function(_state) {
|
|
870
|
+
// 对于小内容,使用同步处理
|
|
871
|
+
if (html.length < MAX_SYNC_SIZE) {
|
|
872
|
+
return [
|
|
873
|
+
2,
|
|
874
|
+
docxDeserializer(rtf, html.trim())
|
|
875
|
+
];
|
|
876
|
+
}
|
|
877
|
+
// 对于大内容,使用异步处理
|
|
878
|
+
return [
|
|
879
|
+
2,
|
|
880
|
+
new Promise(function(resolve) {
|
|
881
|
+
// 使用 requestIdleCallback 在空闲时间处理
|
|
882
|
+
var processInIdle = function() {
|
|
883
|
+
try {
|
|
884
|
+
var result = docxDeserializer(rtf, html.trim());
|
|
885
|
+
resolve(result);
|
|
886
|
+
} catch (error) {
|
|
887
|
+
console.error('HTML解析失败:', error);
|
|
888
|
+
resolve([]);
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
if ('requestIdleCallback' in window) {
|
|
892
|
+
requestIdleCallback(processInIdle, {
|
|
893
|
+
timeout: 1000
|
|
894
|
+
});
|
|
895
|
+
} else {
|
|
896
|
+
// 降级到 setTimeout
|
|
897
|
+
setTimeout(processInIdle, 0);
|
|
898
|
+
}
|
|
899
|
+
})
|
|
900
|
+
];
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
return function parseHtmlOptimized(html, rtf) {
|
|
904
|
+
return _ref.apply(this, arguments);
|
|
905
|
+
};
|
|
906
|
+
}();
|
|
907
|
+
/**
|
|
908
|
+
* 转化 html 到 slate - 性能优化版本
|
|
909
|
+
* @param editor
|
|
910
|
+
* @param html
|
|
911
|
+
* @returns
|
|
912
|
+
*/ export var htmlToFragmentList = function(html, rtl) {
|
|
913
|
+
var fragmentList = docxDeserializer(rtl, html.trim());
|
|
914
|
+
return fragmentList.map(function(fragment) {
|
|
915
|
+
if (fragment.type === 'table') {
|
|
916
|
+
return EditorUtils.wrapperCardNode(fragment);
|
|
917
|
+
}
|
|
918
|
+
if (fragment.type === '"paragraph"' && fragment.children.length === 1) {
|
|
919
|
+
return {
|
|
920
|
+
type: 'paragraph',
|
|
921
|
+
children: fragment.children
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
return fragment;
|
|
925
|
+
});
|
|
540
926
|
};
|
|
927
|
+
export var insertParsedHtmlNodes = /*#__PURE__*/ function() {
|
|
928
|
+
var _ref = _async_to_generator(function(editor, html, editorProps, rtl) {
|
|
929
|
+
var hideLoading, fragmentList, _Editor_nodes, node, selection, processedNodes, back, _Editor_nodes1, specialNode, parsed, inner, hasCodeTags, textContent, children, _Editor_nodes2, p, parent, nextPath, texts, text, processedNodes1, error;
|
|
930
|
+
return _ts_generator(this, function(_state) {
|
|
931
|
+
switch(_state.label){
|
|
932
|
+
case 0:
|
|
933
|
+
// 1. 基础检查
|
|
934
|
+
if (html.startsWith('<html>\r\n<body>\r\n\x3C!--StartFragment--><img src="')) {
|
|
935
|
+
return [
|
|
936
|
+
2,
|
|
937
|
+
false
|
|
938
|
+
];
|
|
939
|
+
}
|
|
940
|
+
// 2. 显示解析提示
|
|
941
|
+
hideLoading = message.loading('parsing...', 0);
|
|
942
|
+
_state.label = 1;
|
|
943
|
+
case 1:
|
|
944
|
+
_state.trys.push([
|
|
945
|
+
1,
|
|
946
|
+
17,
|
|
947
|
+
,
|
|
948
|
+
18
|
|
949
|
+
]);
|
|
950
|
+
return [
|
|
951
|
+
4,
|
|
952
|
+
parseHtmlOptimized(html, rtl)
|
|
953
|
+
];
|
|
954
|
+
case 2:
|
|
955
|
+
fragmentList = _state.sent();
|
|
956
|
+
if (!(fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length)) {
|
|
957
|
+
hideLoading();
|
|
958
|
+
return [
|
|
959
|
+
2,
|
|
960
|
+
false
|
|
961
|
+
];
|
|
962
|
+
}
|
|
963
|
+
// 4. 异步处理文件上传
|
|
964
|
+
return [
|
|
965
|
+
4,
|
|
966
|
+
upLoadFileBatch(fragmentList, editorProps)
|
|
967
|
+
];
|
|
968
|
+
case 3:
|
|
969
|
+
_state.sent();
|
|
970
|
+
debugLog('wordFragmentList', fragmentList);
|
|
971
|
+
hideLoading();
|
|
972
|
+
// 5. 获取当前节点
|
|
973
|
+
_Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
|
|
974
|
+
match: function(n) {
|
|
975
|
+
return Element.isElement(n);
|
|
976
|
+
}
|
|
977
|
+
}), 1), node = _Editor_nodes[0];
|
|
978
|
+
selection = editor.selection;
|
|
979
|
+
if (!(!selection || !Editor.hasPath(editor, selection.anchor.path))) return [
|
|
980
|
+
3,
|
|
981
|
+
5
|
|
982
|
+
];
|
|
983
|
+
processedNodes = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
|
|
984
|
+
if (!item.type) {
|
|
985
|
+
return {
|
|
986
|
+
type: 'paragraph',
|
|
987
|
+
children: [
|
|
988
|
+
item
|
|
989
|
+
]
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
return item;
|
|
993
|
+
});
|
|
994
|
+
return [
|
|
995
|
+
4,
|
|
996
|
+
insertNodesBatch(editor, processedNodes)
|
|
997
|
+
];
|
|
998
|
+
case 4:
|
|
999
|
+
_state.sent();
|
|
1000
|
+
return [
|
|
1001
|
+
2,
|
|
1002
|
+
true
|
|
1003
|
+
];
|
|
1004
|
+
case 5:
|
|
1005
|
+
// 7. 处理非折叠选区
|
|
1006
|
+
if (!Range.isCollapsed(selection)) {
|
|
1007
|
+
back = new BackspaceKey(editor);
|
|
1008
|
+
back.range();
|
|
1009
|
+
Transforms.select(editor, Range.start(selection));
|
|
1010
|
+
setTimeout(function() {
|
|
1011
|
+
var _node_;
|
|
1012
|
+
var node = Editor === null || Editor === void 0 ? void 0 : Editor.node(editor, [
|
|
1013
|
+
0
|
|
1014
|
+
]);
|
|
1015
|
+
if (editor.children.length > 1 && (node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type) === 'paragraph' && !Node.string(node[0])) {
|
|
1016
|
+
Transforms.delete(editor, {
|
|
1017
|
+
at: [
|
|
1018
|
+
0
|
|
1019
|
+
]
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
// 8. 获取特殊节点类型
|
|
1025
|
+
_Editor_nodes1 = _sliced_to_array(Editor.nodes(editor, {
|
|
1026
|
+
match: function(n) {
|
|
1027
|
+
return Element.isElement(n) && [
|
|
1028
|
+
'code',
|
|
1029
|
+
'table-cell',
|
|
1030
|
+
'head',
|
|
1031
|
+
'list-item'
|
|
1032
|
+
].includes(n.type);
|
|
1033
|
+
},
|
|
1034
|
+
at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
|
|
1035
|
+
}), 1), specialNode = _Editor_nodes1[0];
|
|
1036
|
+
if (specialNode) {
|
|
1037
|
+
node = specialNode;
|
|
1038
|
+
}
|
|
1039
|
+
// 9. 处理代码块和表格单元格
|
|
1040
|
+
parsed = new DOMParser().parseFromString(html, 'text/html').body;
|
|
1041
|
+
inner = !!parsed.querySelector('[data-be]');
|
|
1042
|
+
// 对于代码块,检查是否包含代码相关的标签
|
|
1043
|
+
if ((node === null || node === void 0 ? void 0 : node[0].type) === 'code') {
|
|
1044
|
+
hasCodeTags = html.includes('<pre>') || html.includes('<code>') || inner;
|
|
1045
|
+
if (hasCodeTags) {
|
|
1046
|
+
// 从 HTML 中提取纯文本内容
|
|
1047
|
+
textContent = parsed.textContent || '';
|
|
1048
|
+
if (textContent.trim()) {
|
|
1049
|
+
Transforms.insertText(editor, textContent.trim(), {
|
|
1050
|
+
at: selection
|
|
1051
|
+
});
|
|
1052
|
+
return [
|
|
1053
|
+
2,
|
|
1054
|
+
true
|
|
1055
|
+
];
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
// 处理表格单元格
|
|
1060
|
+
if (inner && (node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
|
|
1061
|
+
return [
|
|
1062
|
+
2,
|
|
1063
|
+
true
|
|
1064
|
+
];
|
|
1065
|
+
}
|
|
1066
|
+
if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && fragmentList[0].type === 'list')) return [
|
|
1067
|
+
3,
|
|
1068
|
+
12
|
|
1069
|
+
];
|
|
1070
|
+
children = fragmentList[0].children || [];
|
|
1071
|
+
if (!children.length) {
|
|
1072
|
+
return [
|
|
1073
|
+
2,
|
|
1074
|
+
false
|
|
1075
|
+
];
|
|
1076
|
+
}
|
|
1077
|
+
_Editor_nodes2 = _sliced_to_array(Editor.nodes(editor, {
|
|
1078
|
+
match: function(n) {
|
|
1079
|
+
return Element.isElement(n) && n.type === 'paragraph';
|
|
1080
|
+
},
|
|
1081
|
+
at: Range.isCollapsed(selection) ? selection.anchor.path : Range.start(selection).path
|
|
1082
|
+
}), 1), p = _Editor_nodes2[0];
|
|
1083
|
+
if (!(specialNode && !Path.hasPrevious(p[1]))) return [
|
|
1084
|
+
3,
|
|
1085
|
+
12
|
|
1086
|
+
];
|
|
1087
|
+
if (!!Node.string(p[0])) return [
|
|
1088
|
+
3,
|
|
1089
|
+
7
|
|
1090
|
+
];
|
|
1091
|
+
return [
|
|
1092
|
+
4,
|
|
1093
|
+
insertNodesBatch(editor, children, Path.next(specialNode[1]))
|
|
1094
|
+
];
|
|
1095
|
+
case 6:
|
|
1096
|
+
_state.sent();
|
|
1097
|
+
parent = Node.parent(editor, p[1]);
|
|
1098
|
+
nextPath = _to_consumable_array(specialNode[1].slice(0, -1)).concat([
|
|
1099
|
+
specialNode[1][specialNode[1].length - 1] + children.length
|
|
1100
|
+
]);
|
|
1101
|
+
if (parent.children.length > 1) {
|
|
1102
|
+
Transforms.moveNodes(editor, {
|
|
1103
|
+
at: {
|
|
1104
|
+
anchor: {
|
|
1105
|
+
path: Path.next(p[1]),
|
|
1106
|
+
offset: 0
|
|
1107
|
+
},
|
|
1108
|
+
focus: {
|
|
1109
|
+
path: _to_consumable_array(p[1].slice(0, -1)).concat([
|
|
1110
|
+
parent.children.length - 1
|
|
1111
|
+
]),
|
|
1112
|
+
offset: 0
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
to: _to_consumable_array(nextPath).concat([
|
|
1116
|
+
1
|
|
1117
|
+
])
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
Transforms.delete(editor, {
|
|
1121
|
+
at: selection
|
|
1122
|
+
});
|
|
1123
|
+
return [
|
|
1124
|
+
3,
|
|
1125
|
+
9
|
|
1126
|
+
];
|
|
1127
|
+
case 7:
|
|
1128
|
+
return [
|
|
1129
|
+
4,
|
|
1130
|
+
insertNodesBatch(editor, children, selection.anchor.path, {
|
|
1131
|
+
select: true
|
|
1132
|
+
})
|
|
1133
|
+
];
|
|
1134
|
+
case 8:
|
|
1135
|
+
_state.sent();
|
|
1136
|
+
_state.label = 9;
|
|
1137
|
+
case 9:
|
|
1138
|
+
if (!(fragmentList.length > 1)) return [
|
|
1139
|
+
3,
|
|
1140
|
+
11
|
|
1141
|
+
];
|
|
1142
|
+
return [
|
|
1143
|
+
4,
|
|
1144
|
+
insertNodesBatch(editor, fragmentList.slice(1), selection.anchor.path, {
|
|
1145
|
+
select: true
|
|
1146
|
+
})
|
|
1147
|
+
];
|
|
1148
|
+
case 10:
|
|
1149
|
+
_state.sent();
|
|
1150
|
+
_state.label = 11;
|
|
1151
|
+
case 11:
|
|
1152
|
+
return [
|
|
1153
|
+
2,
|
|
1154
|
+
true
|
|
1155
|
+
];
|
|
1156
|
+
case 12:
|
|
1157
|
+
// 11. 处理表格单元格
|
|
1158
|
+
if ((node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
|
|
1159
|
+
Transforms.insertFragment(editor, getTextsNode(fragmentList), {
|
|
1160
|
+
at: selection
|
|
1161
|
+
});
|
|
1162
|
+
return [
|
|
1163
|
+
2,
|
|
1164
|
+
true
|
|
1165
|
+
];
|
|
1166
|
+
}
|
|
1167
|
+
if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'head')) return [
|
|
1168
|
+
3,
|
|
1169
|
+
15
|
|
1170
|
+
];
|
|
1171
|
+
if (fragmentList[0].type) {
|
|
1172
|
+
if (fragmentList[0].type !== 'paragraph') {
|
|
1173
|
+
Transforms.insertNodes(editor, {
|
|
1174
|
+
type: 'paragraph',
|
|
1175
|
+
children: [
|
|
1176
|
+
{
|
|
1177
|
+
text: ''
|
|
1178
|
+
}
|
|
1179
|
+
]
|
|
1180
|
+
}, {
|
|
1181
|
+
at: selection,
|
|
1182
|
+
select: true
|
|
1183
|
+
});
|
|
1184
|
+
return [
|
|
1185
|
+
2,
|
|
1186
|
+
true
|
|
1187
|
+
];
|
|
1188
|
+
}
|
|
1189
|
+
return [
|
|
1190
|
+
2,
|
|
1191
|
+
false
|
|
1192
|
+
];
|
|
1193
|
+
}
|
|
1194
|
+
texts = fragmentList.filter(function(c) {
|
|
1195
|
+
return c.text;
|
|
1196
|
+
});
|
|
1197
|
+
if (!texts.length) return [
|
|
1198
|
+
3,
|
|
1199
|
+
14
|
|
1200
|
+
];
|
|
1201
|
+
return [
|
|
1202
|
+
4,
|
|
1203
|
+
insertNodesBatch(editor, texts, selection.anchor.path)
|
|
1204
|
+
];
|
|
1205
|
+
case 13:
|
|
1206
|
+
_state.sent();
|
|
1207
|
+
return [
|
|
1208
|
+
2,
|
|
1209
|
+
true
|
|
1210
|
+
];
|
|
1211
|
+
case 14:
|
|
1212
|
+
return [
|
|
1213
|
+
2,
|
|
1214
|
+
false
|
|
1215
|
+
];
|
|
1216
|
+
case 15:
|
|
1217
|
+
// 13. 处理单个段落的特殊情况
|
|
1218
|
+
if (fragmentList.length === 1 && (fragmentList[0].type === 'paragraph' || !fragmentList[0].type) && node) {
|
|
1219
|
+
text = Node.string(fragmentList[0]);
|
|
1220
|
+
if (text) {
|
|
1221
|
+
Transforms.insertText(editor, text, {
|
|
1222
|
+
at: selection
|
|
1223
|
+
});
|
|
1224
|
+
return [
|
|
1225
|
+
2,
|
|
1226
|
+
true
|
|
1227
|
+
];
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
// 14. 默认情况:替换选中节点
|
|
1231
|
+
processedNodes1 = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
|
|
1232
|
+
if (!item.type) {
|
|
1233
|
+
return {
|
|
1234
|
+
type: 'paragraph',
|
|
1235
|
+
children: [
|
|
1236
|
+
item
|
|
1237
|
+
]
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
if (item.type === 'code') {
|
|
1241
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
1242
|
+
type: 'code',
|
|
1243
|
+
value: Node.string(item),
|
|
1244
|
+
language: item.language || 'txt'
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
return item;
|
|
1248
|
+
});
|
|
1249
|
+
return [
|
|
1250
|
+
4,
|
|
1251
|
+
insertNodesBatch(editor, processedNodes1)
|
|
1252
|
+
];
|
|
1253
|
+
case 16:
|
|
1254
|
+
_state.sent();
|
|
1255
|
+
return [
|
|
1256
|
+
2,
|
|
1257
|
+
true
|
|
1258
|
+
];
|
|
1259
|
+
case 17:
|
|
1260
|
+
error = _state.sent();
|
|
1261
|
+
console.error('插入HTML节点失败:', error);
|
|
1262
|
+
hideLoading();
|
|
1263
|
+
message.error('Content parsing failed, please try again');
|
|
1264
|
+
return [
|
|
1265
|
+
2,
|
|
1266
|
+
false
|
|
1267
|
+
];
|
|
1268
|
+
case 18:
|
|
1269
|
+
return [
|
|
1270
|
+
2
|
|
1271
|
+
];
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
});
|
|
1275
|
+
return function insertParsedHtmlNodes(editor, html, editorProps, rtl) {
|
|
1276
|
+
return _ref.apply(this, arguments);
|
|
1277
|
+
};
|
|
1278
|
+
}();
|