@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,59 +1,241 @@
|
|
|
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 react/no-children-prop */ 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 classNames from "classnames";
|
|
43
|
-
import React, {
|
|
44
|
-
useCallback,
|
|
45
|
-
useContext,
|
|
46
|
-
useEffect,
|
|
47
|
-
useMemo,
|
|
48
|
-
useRef
|
|
49
|
-
} from "react";
|
|
236
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
50
237
|
import { ErrorBoundary } from "react-error-boundary";
|
|
51
|
-
import {
|
|
52
|
-
Editor,
|
|
53
|
-
Node,
|
|
54
|
-
Range,
|
|
55
|
-
Transforms
|
|
56
|
-
} from "slate";
|
|
238
|
+
import { Editor, Node, Range, Transforms } from "slate";
|
|
57
239
|
import { parserMdToSchema } from "../BaseMarkdownEditor";
|
|
58
240
|
import { LazyElement } from "./components/LazyElement";
|
|
59
241
|
import { MElement, MLeaf } from "./elements";
|
|
@@ -61,838 +243,973 @@ import { useDebounceFn } from "@ant-design/pro-components";
|
|
|
61
243
|
import { Editable, ReactEditor, Slate } from "slate-react";
|
|
62
244
|
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
63
245
|
import { PluginContext } from "../plugin";
|
|
64
|
-
import {
|
|
65
|
-
handleFilesPaste,
|
|
66
|
-
handleHtmlPaste,
|
|
67
|
-
handleHttpLinkPaste,
|
|
68
|
-
handlePlainTextPaste,
|
|
69
|
-
handleSlateMarkdownFragment,
|
|
70
|
-
handleSpecialTextPaste,
|
|
71
|
-
handleTagNodePaste,
|
|
72
|
-
shouldInsertTextDirectly
|
|
73
|
-
} from "./plugins/handlePaste";
|
|
246
|
+
import { handleFilesPaste, handleHtmlPaste, handleHttpLinkPaste, handlePlainTextPaste, handleSlateMarkdownFragment, handleSpecialTextPaste, handleTagNodePaste, shouldInsertTextDirectly } from "./plugins/handlePaste";
|
|
74
247
|
import { useHighlight } from "./plugins/useHighlight";
|
|
75
248
|
import { useKeyboard } from "./plugins/useKeyboard";
|
|
76
249
|
import { useOnchange } from "./plugins/useOnchange";
|
|
77
250
|
import { useEditorStore } from "./store";
|
|
78
251
|
import { useStyle } from "./style";
|
|
79
252
|
import { MARKDOWN_EDITOR_EVENTS, parserSlateNodeToMarkdown } from "./utils";
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
253
|
+
import { EditorUtils, findByPathAndText, findLeafPath, getSelectionFromDomSelection, hasEditableTarget, isEventHandled, isPath } from "./utils/editorUtils";
|
|
254
|
+
/**
|
|
255
|
+
* 生成表格最小尺寸配置
|
|
256
|
+
*
|
|
257
|
+
* 该函数用于设置表格的最小列数和行数,确保表格的基本结构。
|
|
258
|
+
* 通过递归遍历编辑器元素,找到表格元素并应用最小尺寸约束。
|
|
259
|
+
*
|
|
260
|
+
* @param elements - 编辑器元素数组
|
|
261
|
+
* @param config - 配置对象
|
|
262
|
+
* @param config.minColumn - 最小列数
|
|
263
|
+
* @param config.minRows - 最小行数
|
|
264
|
+
*/ var genTableMinSize = function(elements, config) {
|
|
265
|
+
if (!config) return elements;
|
|
266
|
+
elements.forEach(function(element) {
|
|
267
|
+
if (element.children) {
|
|
268
|
+
genTableMinSize(element.children, config);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
97
271
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
272
|
+
/**
|
|
273
|
+
* SlateMarkdownEditor 组件 - Slate Markdown编辑器组件
|
|
274
|
+
*
|
|
275
|
+
* 基于Slate.js的Markdown编辑器,支持丰富的编辑功能,包括文本编辑、表格、代码块、媒体插入、链接等。
|
|
276
|
+
* 通过MobX进行状态管理,支持多种编辑器事件和操作。
|
|
277
|
+
*
|
|
278
|
+
* @component
|
|
279
|
+
* @description 基于Slate.js的Markdown编辑器组件
|
|
280
|
+
* @param {MEditorProps} props - 编辑器属性
|
|
281
|
+
* @param {Function} [props.eleItemRender] - 自定义元素渲染函数
|
|
282
|
+
* @param {Function} [props.leafRender] - 自定义叶子节点渲染函数
|
|
283
|
+
* @param {Function} [props.onChange] - 内容变化回调
|
|
284
|
+
* @param {MarkdownEditorInstance} props.instance - 编辑器实例
|
|
285
|
+
* @param {string} [props.className] - 自定义CSS类名
|
|
286
|
+
* @param {CommentDataType} [props.comment] - 评论数据
|
|
287
|
+
* @param {string} [props.prefixCls] - 前缀类名
|
|
288
|
+
* @param {boolean} [props.reportMode] - 是否为报告模式
|
|
289
|
+
* @param {string} [props.placeholder] - 占位符文本
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```tsx
|
|
293
|
+
* <SlateMarkdownEditor
|
|
294
|
+
* instance={editorInstance}
|
|
295
|
+
* onChange={(value) => console.log('内容变化:', value)}
|
|
296
|
+
* placeholder="请输入Markdown内容..."
|
|
297
|
+
* reportMode={false}
|
|
298
|
+
* />
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* @returns {React.ReactElement} 渲染的Markdown编辑器组件
|
|
302
|
+
*
|
|
303
|
+
* @remarks
|
|
304
|
+
* - 基于Slate.js实现
|
|
305
|
+
* - 支持丰富的Markdown语法
|
|
306
|
+
* - 提供自定义渲染功能
|
|
307
|
+
* - 支持插件系统
|
|
308
|
+
* - 集成状态管理
|
|
309
|
+
* - 支持键盘快捷键
|
|
310
|
+
* - 提供粘贴处理
|
|
311
|
+
* - 支持错误边界
|
|
312
|
+
* - 响应式布局
|
|
313
|
+
*/ export var SlateMarkdownEditor = function(props) {
|
|
314
|
+
var _markdownEditorRef_current, _props_textAreaProps, _props_comment, _markdownEditorRef_current1;
|
|
315
|
+
// 所有hooks必须在组件顶部按固定顺序调用
|
|
316
|
+
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, setDomRect = _useEditorStore.setDomRect;
|
|
317
|
+
// 懒加载元素索引计数器
|
|
318
|
+
var lazyElementIndexRef = useRef(0);
|
|
319
|
+
// 用于标记是否已在当前渲染周期重置过索引
|
|
320
|
+
var hasResetIndexRef = useRef(false);
|
|
321
|
+
// 计算懒加载元素总数的函数
|
|
322
|
+
var countLazyElements = useCallback(function(nodes) {
|
|
323
|
+
var count = 0;
|
|
324
|
+
var traverse = function(nodeList) {
|
|
325
|
+
nodeList.forEach(function(node) {
|
|
326
|
+
// 跳过表格单元格和表格行
|
|
327
|
+
if (node.type !== 'table-cell' && node.type !== 'table-row') {
|
|
328
|
+
count++;
|
|
329
|
+
}
|
|
330
|
+
// 继续遍历子节点(例如表格内的元素)
|
|
331
|
+
if (node.children && Array.isArray(node.children)) {
|
|
332
|
+
traverse(node.children);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
traverse(nodes);
|
|
337
|
+
return count;
|
|
338
|
+
}, []);
|
|
339
|
+
var changedMark = useRef(false);
|
|
340
|
+
var value = useRef([
|
|
341
|
+
EditorUtils.p
|
|
342
|
+
]);
|
|
343
|
+
var nodeRef = useRef();
|
|
344
|
+
var first = useRef(true);
|
|
345
|
+
var plugins = useContext(PluginContext);
|
|
346
|
+
var onKeyDown = useKeyboard(store, markdownEditorRef, props);
|
|
347
|
+
var onChange = useOnchange(markdownEditorRef.current, props.onChange);
|
|
348
|
+
var high = useHighlight(store);
|
|
349
|
+
var childrenIsEmpty = useMemo(function() {
|
|
350
|
+
var _markdownEditorRef_current;
|
|
351
|
+
if (!((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children)) return false;
|
|
352
|
+
if (!Array.isArray(markdownEditorRef.current.children)) return false;
|
|
353
|
+
if (markdownEditorRef.current.children.length === 0) return false;
|
|
354
|
+
return value.current.filter(function(v) {
|
|
355
|
+
var _v_children_at, _v_children_at1, _v_children;
|
|
356
|
+
return v.type === 'paragraph' && ((_v_children = v.children) === null || _v_children === void 0 ? void 0 : (_v_children_at1 = _v_children.at) === null || _v_children_at1 === void 0 ? void 0 : (_v_children_at = _v_children_at1.call(_v_children, 0)) === null || _v_children_at === void 0 ? void 0 : _v_children_at.text) === '';
|
|
357
|
+
}).length < 1;
|
|
358
|
+
}, [
|
|
359
|
+
(_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children
|
|
360
|
+
]);
|
|
361
|
+
var readonlyCls = useMemo(function() {
|
|
362
|
+
if (readonly) return 'readonly';
|
|
363
|
+
return !childrenIsEmpty ? 'focus' : '';
|
|
364
|
+
}, [
|
|
365
|
+
readonly,
|
|
366
|
+
!childrenIsEmpty
|
|
367
|
+
]);
|
|
368
|
+
var _useStyle = useStyle("".concat(props.prefixCls, "-content"), {
|
|
369
|
+
placeholderContent: (props === null || props === void 0 ? void 0 : (_props_textAreaProps = props.textAreaProps) === null || _props_textAreaProps === void 0 ? void 0 : _props_textAreaProps.placeholder) || (props === null || props === void 0 ? void 0 : props.placeholder)
|
|
370
|
+
}), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
371
|
+
var commentMap = useMemo(function() {
|
|
372
|
+
var _props_comment_commentList, _props_comment;
|
|
373
|
+
var map = new Map();
|
|
374
|
+
props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : (_props_comment_commentList = _props_comment.commentList) === null || _props_comment_commentList === void 0 ? void 0 : _props_comment_commentList.forEach(function(c) {
|
|
375
|
+
c.updateTime = Date.now();
|
|
376
|
+
var path = c.path.join(',');
|
|
377
|
+
if (map.has(path)) {
|
|
378
|
+
var childrenMap = map.get(path);
|
|
379
|
+
var selection = JSON.stringify(c.selection);
|
|
380
|
+
if (childrenMap === null || childrenMap === void 0 ? void 0 : childrenMap.has(selection)) {
|
|
381
|
+
childrenMap.set(selection, _to_consumable_array(childrenMap.get(selection) || []).concat([
|
|
382
|
+
c
|
|
383
|
+
]));
|
|
384
|
+
map.set(path, childrenMap);
|
|
385
|
+
return;
|
|
386
|
+
} else if (childrenMap) {
|
|
387
|
+
childrenMap === null || childrenMap === void 0 ? void 0 : childrenMap.set(selection, [
|
|
388
|
+
c
|
|
389
|
+
]);
|
|
390
|
+
map.set(path, childrenMap);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
var childrenMap1 = new Map();
|
|
395
|
+
childrenMap1.set(JSON.stringify(c.selection), [
|
|
396
|
+
c
|
|
397
|
+
]);
|
|
398
|
+
map.set(path, childrenMap1);
|
|
399
|
+
});
|
|
400
|
+
return map;
|
|
401
|
+
}, [
|
|
402
|
+
props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : _props_comment.commentList
|
|
403
|
+
]);
|
|
404
|
+
var handleSelectionChange = useDebounceFn(/*#__PURE__*/ function() {
|
|
405
|
+
var _ref = _async_to_generator(function(e) {
|
|
406
|
+
var currentSelection, getSelectionContent, _markdownContainerRef_current, event, _props_onSelectionChange, _getSelectionContent, markdown, nodes, domSelection, _props_onSelectionChange1, selection, _markdownContainerRef_current1, event1, _props_onSelectionChange2, _getSelectionContent1, markdown1, nodes1, range, rect, _props_onSelectionChange3;
|
|
407
|
+
return _ts_generator(this, function(_state) {
|
|
408
|
+
currentSelection = markdownEditorRef.current.selection;
|
|
409
|
+
// 获取选中内容的 markdown 和节点
|
|
410
|
+
getSelectionContent = function(selection) {
|
|
411
|
+
if (!selection || Range.isCollapsed(selection)) {
|
|
412
|
+
return {
|
|
413
|
+
markdown: '',
|
|
414
|
+
nodes: []
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
var fragment = Editor.fragment(markdownEditorRef.current, selection);
|
|
419
|
+
var markdown = parserSlateNodeToMarkdown(fragment);
|
|
420
|
+
return {
|
|
421
|
+
markdown: markdown,
|
|
422
|
+
nodes: fragment
|
|
423
|
+
};
|
|
424
|
+
} catch (error) {
|
|
425
|
+
console.error('Failed to get selection content:', error);
|
|
426
|
+
return {
|
|
427
|
+
markdown: '',
|
|
428
|
+
nodes: []
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
if (!readonly) {
|
|
433
|
+
;
|
|
434
|
+
// 非只读模式下的选区处理
|
|
435
|
+
event = new CustomEvent(MARKDOWN_EDITOR_EVENTS.SELECTIONCHANGE, _object_spread_props(_object_spread({}, e), {
|
|
436
|
+
detail: currentSelection
|
|
437
|
+
}));
|
|
438
|
+
markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.dispatchEvent(event);
|
|
439
|
+
// 调用 props.onSelectionChange 回调
|
|
440
|
+
if (props.onSelectionChange) {
|
|
441
|
+
;
|
|
442
|
+
_getSelectionContent = getSelectionContent(currentSelection), markdown = _getSelectionContent.markdown, nodes = _getSelectionContent.nodes;
|
|
443
|
+
(_props_onSelectionChange = props.onSelectionChange) === null || _props_onSelectionChange === void 0 ? void 0 : _props_onSelectionChange.call(props, currentSelection, markdown, nodes);
|
|
444
|
+
}
|
|
445
|
+
return [
|
|
446
|
+
2
|
|
447
|
+
];
|
|
448
|
+
}
|
|
449
|
+
if (typeof window === 'undefined') return [
|
|
450
|
+
2
|
|
451
|
+
];
|
|
452
|
+
// 只读模式下的选区处理
|
|
453
|
+
domSelection = window.getSelection();
|
|
454
|
+
if (!domSelection) {
|
|
455
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
456
|
+
// 调用 props.onSelectionChange 回调(无选中)
|
|
457
|
+
if (props.onSelectionChange) {
|
|
458
|
+
;
|
|
459
|
+
(_props_onSelectionChange1 = props.onSelectionChange) === null || _props_onSelectionChange1 === void 0 ? void 0 : _props_onSelectionChange1.call(props, null, '', []);
|
|
460
|
+
}
|
|
461
|
+
return [
|
|
462
|
+
2
|
|
463
|
+
];
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection);
|
|
467
|
+
if (selection) {
|
|
468
|
+
;
|
|
469
|
+
// 更新编辑器的选区
|
|
470
|
+
markdownEditorRef.current.selection = selection;
|
|
471
|
+
// 触发选区变化事件
|
|
472
|
+
event1 = new CustomEvent(MARKDOWN_EDITOR_EVENTS.SELECTIONCHANGE, {
|
|
473
|
+
detail: selection
|
|
474
|
+
});
|
|
475
|
+
markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current1 = markdownContainerRef.current) === null || _markdownContainerRef_current1 === void 0 ? void 0 : _markdownContainerRef_current1.dispatchEvent(event1);
|
|
476
|
+
// 调用 props.onSelectionChange 回调
|
|
477
|
+
if (props.onSelectionChange) {
|
|
478
|
+
;
|
|
479
|
+
_getSelectionContent1 = getSelectionContent(selection), markdown1 = _getSelectionContent1.markdown, nodes1 = _getSelectionContent1.nodes;
|
|
480
|
+
(_props_onSelectionChange2 = props.onSelectionChange) === null || _props_onSelectionChange2 === void 0 ? void 0 : _props_onSelectionChange2.call(props, selection, markdown1, nodes1);
|
|
481
|
+
}
|
|
482
|
+
// 只有在有实际选中文本时才显示工具栏
|
|
483
|
+
if (!Range.isCollapsed(selection)) {
|
|
484
|
+
range = ReactEditor.toDOMRange(markdownEditorRef.current, selection);
|
|
485
|
+
rect = range === null || range === void 0 ? void 0 : range.getBoundingClientRect();
|
|
486
|
+
if (rect) {
|
|
487
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(rect);
|
|
488
|
+
} else {
|
|
489
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
490
|
+
}
|
|
491
|
+
} else {
|
|
492
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
496
|
+
// 调用 props.onSelectionChange 回调(无选中)
|
|
497
|
+
if (props.onSelectionChange) {
|
|
498
|
+
;
|
|
499
|
+
(_props_onSelectionChange3 = props.onSelectionChange) === null || _props_onSelectionChange3 === void 0 ? void 0 : _props_onSelectionChange3.call(props, null, '', []);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
} catch (error) {
|
|
503
|
+
console.error('Selection change error:', error);
|
|
504
|
+
}
|
|
505
|
+
return [
|
|
506
|
+
2
|
|
507
|
+
];
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
return function(e) {
|
|
511
|
+
return _ref.apply(this, arguments);
|
|
512
|
+
};
|
|
513
|
+
}(), 16);
|
|
514
|
+
// 添加选区变化的监听
|
|
515
|
+
useEffect(function() {
|
|
516
|
+
var container = markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : markdownContainerRef.current;
|
|
517
|
+
if (!container) return;
|
|
518
|
+
var handleMouseUp = function(e) {
|
|
519
|
+
e.preventDefault();
|
|
520
|
+
handleSelectionChange.run();
|
|
521
|
+
};
|
|
522
|
+
container.addEventListener('mouseup', handleMouseUp);
|
|
523
|
+
return function() {
|
|
524
|
+
container.removeEventListener('mouseup', handleMouseUp);
|
|
525
|
+
handleSelectionChange.cancel();
|
|
526
|
+
};
|
|
527
|
+
}, [
|
|
528
|
+
readonly,
|
|
529
|
+
markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : markdownContainerRef.current
|
|
530
|
+
]);
|
|
531
|
+
useEffect(function() {
|
|
532
|
+
if (nodeRef.current !== props.instance) {
|
|
533
|
+
initialNote();
|
|
115
534
|
}
|
|
116
|
-
|
|
117
|
-
|
|
535
|
+
}, [
|
|
536
|
+
props.instance,
|
|
537
|
+
markdownEditorRef.current
|
|
538
|
+
]);
|
|
539
|
+
useEffect(function() {
|
|
540
|
+
var _props_fncProps_onFootnoteDefinitionChange, _props_fncProps;
|
|
541
|
+
var footnoteDefinitionList = markdownEditorRef.current.children.filter(function(item) {
|
|
542
|
+
return item.type === 'footnoteDefinition';
|
|
543
|
+
}).map(function(item, index) {
|
|
544
|
+
return {
|
|
545
|
+
id: item.id || index,
|
|
546
|
+
placeholder: item.identifier,
|
|
547
|
+
origin_text: item.value,
|
|
548
|
+
url: item.url,
|
|
549
|
+
origin_url: item.url
|
|
550
|
+
};
|
|
551
|
+
});
|
|
552
|
+
props === null || props === void 0 ? void 0 : (_props_fncProps = props.fncProps) === null || _props_fncProps === void 0 ? void 0 : (_props_fncProps_onFootnoteDefinitionChange = _props_fncProps.onFootnoteDefinitionChange) === null || _props_fncProps_onFootnoteDefinitionChange === void 0 ? void 0 : _props_fncProps_onFootnoteDefinitionChange.call(_props_fncProps, footnoteDefinitionList);
|
|
553
|
+
}, [
|
|
554
|
+
(_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : _markdownEditorRef_current1.children
|
|
555
|
+
]);
|
|
556
|
+
// 非hook变量声明
|
|
557
|
+
var _ref = props.tagInputProps || {}, _ref_prefixCls = _ref.prefixCls, prefixCls = _ref_prefixCls === void 0 ? '$' : _ref_prefixCls;
|
|
558
|
+
var baseClassName = "".concat(props.prefixCls, "-content");
|
|
559
|
+
var onSlateChange = useRefFunction(function(v) {
|
|
560
|
+
var _markdownEditorRef_current_operations;
|
|
561
|
+
// 忽略初始化时的第一次变化
|
|
562
|
+
if (first.current) {
|
|
563
|
+
setTimeout(function() {
|
|
564
|
+
first.current = false;
|
|
565
|
+
}, 100);
|
|
566
|
+
return;
|
|
118
567
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const onKeyDown = useKeyboard(store, markdownEditorRef, props);
|
|
130
|
-
const onChange = useOnchange(markdownEditorRef.current, props.onChange);
|
|
131
|
-
const high = useHighlight(store);
|
|
132
|
-
const childrenIsEmpty = useMemo(() => {
|
|
133
|
-
var _a2;
|
|
134
|
-
if (!((_a2 = markdownEditorRef.current) == null ? void 0 : _a2.children))
|
|
135
|
-
return false;
|
|
136
|
-
if (!Array.isArray(markdownEditorRef.current.children))
|
|
137
|
-
return false;
|
|
138
|
-
if (markdownEditorRef.current.children.length === 0)
|
|
139
|
-
return false;
|
|
140
|
-
return value.current.filter(
|
|
141
|
-
(v) => {
|
|
142
|
-
var _a3, _b2, _c2;
|
|
143
|
-
return v.type === "paragraph" && ((_c2 = (_b2 = (_a3 = v.children) == null ? void 0 : _a3.at) == null ? void 0 : _b2.call(_a3, 0)) == null ? void 0 : _c2.text) === "";
|
|
144
|
-
}
|
|
145
|
-
).length < 1;
|
|
146
|
-
}, [(_a = markdownEditorRef.current) == null ? void 0 : _a.children]);
|
|
147
|
-
const readonlyCls = useMemo(() => {
|
|
148
|
-
if (readonly)
|
|
149
|
-
return "readonly";
|
|
150
|
-
return !childrenIsEmpty ? "focus" : "";
|
|
151
|
-
}, [readonly, !childrenIsEmpty]);
|
|
152
|
-
const { wrapSSR, hashId } = useStyle(`${props.prefixCls}-content`, {
|
|
153
|
-
placeholderContent: ((_b = props == null ? void 0 : props.textAreaProps) == null ? void 0 : _b.placeholder) || (props == null ? void 0 : props.placeholder)
|
|
154
|
-
});
|
|
155
|
-
const commentMap = useMemo(() => {
|
|
156
|
-
var _a2, _b2;
|
|
157
|
-
const map = /* @__PURE__ */ new Map();
|
|
158
|
-
(_b2 = (_a2 = props == null ? void 0 : props.comment) == null ? void 0 : _a2.commentList) == null ? void 0 : _b2.forEach((c) => {
|
|
159
|
-
c.updateTime = Date.now();
|
|
160
|
-
const path = c.path.join(",");
|
|
161
|
-
if (map.has(path)) {
|
|
162
|
-
const childrenMap2 = map.get(path);
|
|
163
|
-
const selection = JSON.stringify(c.selection);
|
|
164
|
-
if (childrenMap2 == null ? void 0 : childrenMap2.has(selection)) {
|
|
165
|
-
childrenMap2.set(selection, [
|
|
166
|
-
...childrenMap2.get(selection) || [],
|
|
167
|
-
c
|
|
168
|
-
]);
|
|
169
|
-
map.set(path, childrenMap2);
|
|
170
|
-
return;
|
|
171
|
-
} else if (childrenMap2) {
|
|
172
|
-
childrenMap2 == null ? void 0 : childrenMap2.set(selection, [c]);
|
|
173
|
-
map.set(path, childrenMap2);
|
|
174
|
-
return;
|
|
568
|
+
// 更新当前值引用
|
|
569
|
+
value.current = v;
|
|
570
|
+
// 触发onChange回调
|
|
571
|
+
onChange(v, markdownEditorRef.current.operations);
|
|
572
|
+
// 检查是否存在非选区变化操作,如有则标记内容已变更
|
|
573
|
+
var hasContentChanges = (_markdownEditorRef_current_operations = markdownEditorRef.current.operations) === null || _markdownEditorRef_current_operations === void 0 ? void 0 : _markdownEditorRef_current_operations.some(function(op) {
|
|
574
|
+
return op.type !== 'set_selection';
|
|
575
|
+
});
|
|
576
|
+
if (hasContentChanges && !changedMark.current) {
|
|
577
|
+
changedMark.current = true;
|
|
175
578
|
}
|
|
176
|
-
}
|
|
177
|
-
const childrenMap = /* @__PURE__ */ new Map();
|
|
178
|
-
childrenMap.set(JSON.stringify(c.selection), [c]);
|
|
179
|
-
map.set(path, childrenMap);
|
|
180
579
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return { markdown: "", nodes: [] };
|
|
580
|
+
var checkEnd = useRefFunction(function(e) {
|
|
581
|
+
var _props_textAreaProps;
|
|
582
|
+
// 如果启用打字机模式或为只读模式,不处理定位逻辑
|
|
583
|
+
if (props === null || props === void 0 ? void 0 : props.typewriter) return;
|
|
584
|
+
if (readonly) {
|
|
585
|
+
// 点击时清除工具栏
|
|
586
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
587
|
+
return;
|
|
190
588
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const markdown = parserSlateNodeToMarkdown(fragment);
|
|
197
|
-
return { markdown, nodes: fragment };
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error("Failed to get selection content:", error);
|
|
200
|
-
return { markdown: "", nodes: [] };
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
if (!readonly) {
|
|
204
|
-
const event = new CustomEvent(
|
|
205
|
-
MARKDOWN_EDITOR_EVENTS.SELECTIONCHANGE,
|
|
206
|
-
__spreadProps(__spreadValues({}, e), {
|
|
207
|
-
detail: currentSelection
|
|
208
|
-
})
|
|
209
|
-
);
|
|
210
|
-
(_a2 = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _a2.dispatchEvent(event);
|
|
211
|
-
if (props.onSelectionChange) {
|
|
212
|
-
const { markdown, nodes } = getSelectionContent(currentSelection);
|
|
213
|
-
(_b2 = props.onSelectionChange) == null ? void 0 : _b2.call(props, currentSelection, markdown, nodes);
|
|
589
|
+
// 获取目标元素
|
|
590
|
+
var target = e.target;
|
|
591
|
+
// 如果启用文本区域模式,不处理定位逻辑
|
|
592
|
+
if ((_props_textAreaProps = props.textAreaProps) === null || _props_textAreaProps === void 0 ? void 0 : _props_textAreaProps.enable) {
|
|
593
|
+
return false;
|
|
214
594
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
595
|
+
// 检查是否点击在编辑器内容区域
|
|
596
|
+
if (target.dataset.slateEditor) {
|
|
597
|
+
var _target_lastElementChild;
|
|
598
|
+
// 获取最后一个元素的顶部位置
|
|
599
|
+
var top = (_target_lastElementChild = target.lastElementChild) === null || _target_lastElementChild === void 0 ? void 0 : _target_lastElementChild.offsetTop;
|
|
600
|
+
// 判断点击位置是否在编辑器内容底部区域
|
|
601
|
+
// 当点击位置距离顶部的距离大于最后一个元素的顶部位置时,认为点击在底部区域
|
|
602
|
+
if (markdownContainerRef.current && markdownContainerRef.current.scrollTop + e.clientY - 60 > top) {
|
|
603
|
+
// 尝试将光标设置到编辑器内容末尾
|
|
604
|
+
if (EditorUtils.checkEnd(markdownEditorRef.current)) {
|
|
605
|
+
e.preventDefault();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
224
608
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
609
|
+
});
|
|
610
|
+
var handleClipboardCopy = useRefFunction(function(event, operationType) {
|
|
611
|
+
try {
|
|
612
|
+
var _markdownEditorRef_current;
|
|
613
|
+
// 1. 如果事件已被处理,则直接返回
|
|
614
|
+
if (isEventHandled(event)) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
// 2. 检查目标元素是否可编辑,如果不可编辑,则从DOM选区中获取编辑器选区
|
|
618
|
+
if (operationType === 'copy' && !hasEditableTarget(markdownEditorRef.current, event.target)) {
|
|
619
|
+
var domSelection = window.getSelection();
|
|
620
|
+
markdownEditorRef.current.selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection);
|
|
621
|
+
} else if (operationType === 'cut') {
|
|
622
|
+
var domSelection1 = window.getSelection();
|
|
623
|
+
markdownEditorRef.current.selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection1);
|
|
238
624
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
625
|
+
// 如果无法获取选区,则直接返回
|
|
626
|
+
if (!markdownEditorRef.current.selection) {
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
// 3. 处理复制/剪切选中内容
|
|
630
|
+
if ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.selection) {
|
|
631
|
+
var _event_clipboardData;
|
|
632
|
+
(_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.clearData();
|
|
633
|
+
var editor = markdownEditorRef.current;
|
|
634
|
+
try {
|
|
635
|
+
// 复制HTML内容
|
|
636
|
+
var tempDiv = document.createElement('div');
|
|
637
|
+
var domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
|
638
|
+
var selectedHtml = domRange.cloneContents();
|
|
639
|
+
tempDiv.appendChild(selectedHtml);
|
|
640
|
+
event.clipboardData.setData('text/html', tempDiv.innerHTML);
|
|
641
|
+
tempDiv === null || tempDiv === void 0 ? void 0 : tempDiv.remove();
|
|
642
|
+
// 设置Slate编辑器特定的片段数据,用于保留格式信息
|
|
643
|
+
event.clipboardData.setData('application/x-slate-md-fragment', JSON.stringify((editor === null || editor === void 0 ? void 0 : editor.getFragment()) || []));
|
|
644
|
+
event.clipboardData.setData('text/plain', parserSlateNodeToMarkdown(editor === null || editor === void 0 ? void 0 : editor.getFragment()));
|
|
645
|
+
event.clipboardData.setData('text/markdown', parserSlateNodeToMarkdown(editor === null || editor === void 0 ? void 0 : editor.getFragment()));
|
|
646
|
+
// 4. 设置剪贴板的片段数据
|
|
647
|
+
ReactEditor.setFragmentData(markdownEditorRef.current, event.clipboardData, operationType);
|
|
648
|
+
// 5. 如果是剪切操作,删除选中内容
|
|
649
|
+
if (operationType === 'cut') {
|
|
650
|
+
Transforms.delete(markdownEditorRef.current, {
|
|
651
|
+
at: markdownEditorRef.current.selection
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
// 阻止默认行为和事件冒泡
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
return true;
|
|
657
|
+
} catch (innerError) {
|
|
658
|
+
console.error('Error during clipboard operation:', innerError);
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
255
661
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
setDomRect == null ? void 0 : setDomRect(null);
|
|
261
|
-
if (props.onSelectionChange) {
|
|
262
|
-
(_f = props.onSelectionChange) == null ? void 0 : _f.call(props, null, "", []);
|
|
263
|
-
}
|
|
662
|
+
return false;
|
|
663
|
+
} catch (error) {
|
|
664
|
+
console.error('Clipboard copy/cut operation failed:', error);
|
|
665
|
+
return false;
|
|
264
666
|
}
|
|
265
|
-
} catch (error) {
|
|
266
|
-
console.error("Selection change error:", error);
|
|
267
|
-
}
|
|
268
|
-
}),
|
|
269
|
-
16
|
|
270
|
-
);
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
const container = markdownContainerRef == null ? void 0 : markdownContainerRef.current;
|
|
273
|
-
if (!container)
|
|
274
|
-
return;
|
|
275
|
-
const handleMouseUp = (e) => {
|
|
276
|
-
e.preventDefault();
|
|
277
|
-
handleSelectionChange.run();
|
|
278
|
-
};
|
|
279
|
-
container.addEventListener("mouseup", handleMouseUp);
|
|
280
|
-
return () => {
|
|
281
|
-
container.removeEventListener("mouseup", handleMouseUp);
|
|
282
|
-
handleSelectionChange.cancel();
|
|
283
|
-
};
|
|
284
|
-
}, [readonly, markdownContainerRef == null ? void 0 : markdownContainerRef.current]);
|
|
285
|
-
useEffect(() => {
|
|
286
|
-
if (nodeRef.current !== props.instance) {
|
|
287
|
-
initialNote();
|
|
288
|
-
}
|
|
289
|
-
}, [props.instance, markdownEditorRef.current]);
|
|
290
|
-
useEffect(() => {
|
|
291
|
-
var _a2, _b2;
|
|
292
|
-
const footnoteDefinitionList = markdownEditorRef.current.children.filter((item) => item.type === "footnoteDefinition").map((item, index) => {
|
|
293
|
-
return {
|
|
294
|
-
id: item.id || index,
|
|
295
|
-
placeholder: item.identifier,
|
|
296
|
-
origin_text: item.value,
|
|
297
|
-
url: item.url,
|
|
298
|
-
origin_url: item.url
|
|
299
|
-
};
|
|
300
667
|
});
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
var _a2;
|
|
307
|
-
if (first.current) {
|
|
308
|
-
setTimeout(() => {
|
|
309
|
-
first.current = false;
|
|
310
|
-
}, 100);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
value.current = v;
|
|
314
|
-
onChange(v, markdownEditorRef.current.operations);
|
|
315
|
-
const hasContentChanges = (_a2 = markdownEditorRef.current.operations) == null ? void 0 : _a2.some(
|
|
316
|
-
(op) => op.type !== "set_selection"
|
|
317
|
-
);
|
|
318
|
-
if (hasContentChanges && !changedMark.current) {
|
|
319
|
-
changedMark.current = true;
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
const checkEnd = useRefFunction((e) => {
|
|
323
|
-
var _a2, _b2;
|
|
324
|
-
if (props == null ? void 0 : props.typewriter)
|
|
325
|
-
return;
|
|
326
|
-
if (readonly) {
|
|
327
|
-
setDomRect == null ? void 0 : setDomRect(null);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
const target = e.target;
|
|
331
|
-
if ((_a2 = props.textAreaProps) == null ? void 0 : _a2.enable) {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
if (target.dataset.slateEditor) {
|
|
335
|
-
const top = (_b2 = target.lastElementChild) == null ? void 0 : _b2.offsetTop;
|
|
336
|
-
if (markdownContainerRef.current && markdownContainerRef.current.scrollTop + e.clientY - 60 > top) {
|
|
337
|
-
if (EditorUtils.checkEnd(markdownEditorRef.current)) {
|
|
338
|
-
e.preventDefault();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
const handleClipboardCopy = useRefFunction(
|
|
344
|
-
(event, operationType) => {
|
|
345
|
-
var _a2, _b2;
|
|
346
|
-
try {
|
|
347
|
-
if (isEventHandled(event)) {
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
if (operationType === "copy" && !hasEditableTarget(markdownEditorRef.current, event.target)) {
|
|
351
|
-
const domSelection = window.getSelection();
|
|
352
|
-
markdownEditorRef.current.selection = getSelectionFromDomSelection(
|
|
353
|
-
markdownEditorRef.current,
|
|
354
|
-
domSelection
|
|
355
|
-
);
|
|
356
|
-
} else if (operationType === "cut") {
|
|
357
|
-
const domSelection = window.getSelection();
|
|
358
|
-
markdownEditorRef.current.selection = getSelectionFromDomSelection(
|
|
359
|
-
markdownEditorRef.current,
|
|
360
|
-
domSelection
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
if (!markdownEditorRef.current.selection) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
if ((_a2 = markdownEditorRef.current) == null ? void 0 : _a2.selection) {
|
|
367
|
-
(_b2 = event.clipboardData) == null ? void 0 : _b2.clearData();
|
|
368
|
-
const editor = markdownEditorRef.current;
|
|
369
|
-
try {
|
|
370
|
-
const tempDiv = document.createElement("div");
|
|
371
|
-
const domRange = ReactEditor.toDOMRange(
|
|
372
|
-
editor,
|
|
373
|
-
editor.selection
|
|
374
|
-
);
|
|
375
|
-
const selectedHtml = domRange.cloneContents();
|
|
376
|
-
tempDiv.appendChild(selectedHtml);
|
|
377
|
-
event.clipboardData.setData("text/html", tempDiv.innerHTML);
|
|
378
|
-
tempDiv == null ? void 0 : tempDiv.remove();
|
|
379
|
-
event.clipboardData.setData(
|
|
380
|
-
"application/x-slate-md-fragment",
|
|
381
|
-
JSON.stringify((editor == null ? void 0 : editor.getFragment()) || [])
|
|
382
|
-
);
|
|
383
|
-
event.clipboardData.setData(
|
|
384
|
-
"text/plain",
|
|
385
|
-
parserSlateNodeToMarkdown(editor == null ? void 0 : editor.getFragment())
|
|
386
|
-
);
|
|
387
|
-
event.clipboardData.setData(
|
|
388
|
-
"text/markdown",
|
|
389
|
-
parserSlateNodeToMarkdown(editor == null ? void 0 : editor.getFragment())
|
|
390
|
-
);
|
|
391
|
-
ReactEditor.setFragmentData(
|
|
392
|
-
markdownEditorRef.current,
|
|
393
|
-
event.clipboardData,
|
|
394
|
-
operationType
|
|
395
|
-
);
|
|
396
|
-
if (operationType === "cut") {
|
|
397
|
-
Transforms.delete(markdownEditorRef.current, {
|
|
398
|
-
at: markdownEditorRef.current.selection
|
|
399
|
-
});
|
|
400
|
-
}
|
|
668
|
+
var handleKeyDown = useRefFunction(function(event) {
|
|
669
|
+
var _props_tagInputProps, _flat;
|
|
670
|
+
if (((_props_tagInputProps = props.tagInputProps) === null || _props_tagInputProps === void 0 ? void 0 : _props_tagInputProps.enable) && ((_flat = [
|
|
671
|
+
prefixCls
|
|
672
|
+
].flat(2)) === null || _flat === void 0 ? void 0 : _flat.includes(event === null || event === void 0 ? void 0 : event.key))) {
|
|
401
673
|
event.preventDefault();
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
674
|
+
event.stopPropagation();
|
|
675
|
+
Transforms.insertNodes(markdownEditorRef.current, [
|
|
676
|
+
{
|
|
677
|
+
code: true,
|
|
678
|
+
tag: true,
|
|
679
|
+
autoOpen: true,
|
|
680
|
+
text: (event === null || event === void 0 ? void 0 : event.key) + ' ',
|
|
681
|
+
triggerText: event === null || event === void 0 ? void 0 : event.key
|
|
682
|
+
}
|
|
683
|
+
]);
|
|
684
|
+
return;
|
|
407
685
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
if (props.instance) {
|
|
438
|
-
nodeRef.current = props.instance;
|
|
439
|
-
first.current = true;
|
|
440
|
-
const tableConfig = props.tableConfig;
|
|
441
|
-
genTableMinSize(props.initSchemaValue || [], {
|
|
442
|
-
minColumn: tableConfig == null ? void 0 : tableConfig.minColumn,
|
|
443
|
-
minRows: tableConfig == null ? void 0 : tableConfig.minRows
|
|
444
|
-
});
|
|
445
|
-
try {
|
|
446
|
-
EditorUtils.reset(
|
|
447
|
-
markdownEditorRef.current,
|
|
448
|
-
((_a2 = props.initSchemaValue) == null ? void 0 : _a2.length) ? props.initSchemaValue : void 0
|
|
449
|
-
);
|
|
450
|
-
} catch (e) {
|
|
451
|
-
EditorUtils.deleteAll(markdownEditorRef.current);
|
|
452
|
-
}
|
|
453
|
-
} else {
|
|
454
|
-
nodeRef.current = void 0;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
useEffect(() => {
|
|
458
|
-
if (nodeRef.current !== props.instance) {
|
|
459
|
-
initialNote();
|
|
460
|
-
}
|
|
461
|
-
}, [props.instance, markdownEditorRef.current]);
|
|
462
|
-
const onPaste = (event) => __async(void 0, null, function* () {
|
|
463
|
-
yield handlePasteEvent(event);
|
|
464
|
-
});
|
|
465
|
-
const handlePasteEvent = (event) => __async(void 0, null, function* () {
|
|
466
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
467
|
-
const pasteConfig = props.pasteConfig;
|
|
468
|
-
if ((pasteConfig == null ? void 0 : pasteConfig.enabled) === false) {
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
const currentTextSelection = markdownEditorRef.current.selection;
|
|
472
|
-
if (currentTextSelection && currentTextSelection.anchor && Editor.hasPath(
|
|
473
|
-
markdownEditorRef.current,
|
|
474
|
-
currentTextSelection.anchor.path
|
|
475
|
-
)) {
|
|
476
|
-
if (!Range.isCollapsed(currentTextSelection)) {
|
|
477
|
-
Transforms.delete(markdownEditorRef.current, {
|
|
478
|
-
at: currentTextSelection,
|
|
479
|
-
reverse: true
|
|
686
|
+
onKeyDown(event);
|
|
687
|
+
});
|
|
688
|
+
/**
|
|
689
|
+
* 初始化编辑器
|
|
690
|
+
*/ var initialNote = /*#__PURE__*/ function() {
|
|
691
|
+
var _ref = _async_to_generator(function() {
|
|
692
|
+
var tableConfig, _props_initSchemaValue;
|
|
693
|
+
return _ts_generator(this, function(_state) {
|
|
694
|
+
if (props.instance) {
|
|
695
|
+
nodeRef.current = props.instance;
|
|
696
|
+
first.current = true;
|
|
697
|
+
tableConfig = props.tableConfig;
|
|
698
|
+
genTableMinSize(props.initSchemaValue || [], {
|
|
699
|
+
minColumn: tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.minColumn,
|
|
700
|
+
minRows: tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.minRows
|
|
701
|
+
});
|
|
702
|
+
try {
|
|
703
|
+
;
|
|
704
|
+
EditorUtils.reset(markdownEditorRef.current, ((_props_initSchemaValue = props.initSchemaValue) === null || _props_initSchemaValue === void 0 ? void 0 : _props_initSchemaValue.length) ? props.initSchemaValue : undefined);
|
|
705
|
+
} catch (e) {
|
|
706
|
+
EditorUtils.deleteAll(markdownEditorRef.current);
|
|
707
|
+
}
|
|
708
|
+
} else {
|
|
709
|
+
nodeRef.current = undefined;
|
|
710
|
+
}
|
|
711
|
+
return [
|
|
712
|
+
2
|
|
713
|
+
];
|
|
714
|
+
});
|
|
480
715
|
});
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const curNode = nodeList == null ? void 0 : nodeList.at(0);
|
|
489
|
-
if (handleTagNodePaste(
|
|
490
|
-
markdownEditorRef.current,
|
|
491
|
-
currentTextSelection,
|
|
492
|
-
event.clipboardData,
|
|
493
|
-
curNode
|
|
494
|
-
)) {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
(_b2 = props.onPaste) == null ? void 0 : _b2.call(props, event);
|
|
499
|
-
const types = ((_c2 = event.clipboardData) == null ? void 0 : _c2.types) || ["text/plain"];
|
|
500
|
-
const defaultAllowedTypes = [
|
|
501
|
-
"application/x-slate-md-fragment",
|
|
502
|
-
"text/html",
|
|
503
|
-
"Files",
|
|
504
|
-
"text/markdown",
|
|
505
|
-
"text/plain"
|
|
506
|
-
];
|
|
507
|
-
const allowedTypes = (pasteConfig == null ? void 0 : pasteConfig.allowedTypes) || defaultAllowedTypes;
|
|
508
|
-
if (types.includes("application/x-slate-md-fragment") && allowedTypes.includes("application/x-slate-md-fragment")) {
|
|
509
|
-
if (handleSlateMarkdownFragment(
|
|
510
|
-
markdownEditorRef.current,
|
|
511
|
-
event.clipboardData,
|
|
512
|
-
currentTextSelection
|
|
513
|
-
)) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
if (types.includes("text/html") && allowedTypes.includes("text/html")) {
|
|
518
|
-
if (yield handleHtmlPaste(
|
|
519
|
-
markdownEditorRef.current,
|
|
520
|
-
event.clipboardData,
|
|
521
|
-
props
|
|
522
|
-
)) {
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
if (types.includes("Files") && allowedTypes.includes("Files")) {
|
|
527
|
-
if (yield handleFilesPaste(
|
|
528
|
-
markdownEditorRef.current,
|
|
529
|
-
event.clipboardData,
|
|
530
|
-
props
|
|
531
|
-
)) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
if (types.includes("text/markdown") && allowedTypes.includes("text/markdown")) {
|
|
536
|
-
const text = ((_f = (_e = (_d2 = event.clipboardData) == null ? void 0 : _d2.getData) == null ? void 0 : _e.call(_d2, "text/markdown")) == null ? void 0 : _f.trim()) || "";
|
|
537
|
-
if (text) {
|
|
538
|
-
Transforms.insertFragment(
|
|
539
|
-
markdownEditorRef.current,
|
|
540
|
-
parserMdToSchema(text, plugins).schema
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
if (types.includes("text/plain") && allowedTypes.includes("text/plain")) {
|
|
546
|
-
const text = ((_i = (_h = (_g = event.clipboardData) == null ? void 0 : _g.getData) == null ? void 0 : _h.call(_g, "text/plain")) == null ? void 0 : _i.trim()) || "";
|
|
547
|
-
if (!text)
|
|
548
|
-
return;
|
|
549
|
-
const selection = markdownEditorRef.current.selection;
|
|
550
|
-
if (shouldInsertTextDirectly(markdownEditorRef.current, selection)) {
|
|
551
|
-
Transforms.insertText(markdownEditorRef.current, text);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
try {
|
|
555
|
-
if (handleSpecialTextPaste(markdownEditorRef.current, text, selection)) {
|
|
556
|
-
return;
|
|
716
|
+
return function initialNote() {
|
|
717
|
+
return _ref.apply(this, arguments);
|
|
718
|
+
};
|
|
719
|
+
}();
|
|
720
|
+
useEffect(function() {
|
|
721
|
+
if (nodeRef.current !== props.instance) {
|
|
722
|
+
initialNote();
|
|
557
723
|
}
|
|
558
|
-
|
|
559
|
-
|
|
724
|
+
}, [
|
|
725
|
+
props.instance,
|
|
726
|
+
markdownEditorRef.current
|
|
727
|
+
]);
|
|
728
|
+
/**
|
|
729
|
+
* 处理粘贴事件,会把粘贴的内容转换为对应的节点
|
|
730
|
+
* @description paste event
|
|
731
|
+
* @param {React.ClipboardEvent<HTMLDivElement>} e
|
|
732
|
+
*/ var onPaste = /*#__PURE__*/ function() {
|
|
733
|
+
var _ref = _async_to_generator(function(event) {
|
|
734
|
+
return _ts_generator(this, function(_state) {
|
|
735
|
+
switch(_state.label){
|
|
736
|
+
case 0:
|
|
737
|
+
return [
|
|
738
|
+
4,
|
|
739
|
+
handlePasteEvent(event)
|
|
740
|
+
];
|
|
741
|
+
case 1:
|
|
742
|
+
_state.sent();
|
|
743
|
+
return [
|
|
744
|
+
2
|
|
745
|
+
];
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
return function onPaste(event) {
|
|
750
|
+
return _ref.apply(this, arguments);
|
|
751
|
+
};
|
|
752
|
+
}();
|
|
753
|
+
/**
|
|
754
|
+
* 实际的粘贴处理逻辑
|
|
755
|
+
*/ var handlePasteEvent = /*#__PURE__*/ function() {
|
|
756
|
+
var _ref = _async_to_generator(function(event) {
|
|
757
|
+
var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, types, defaultAllowedTypes, allowedTypes, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
|
|
758
|
+
return _ts_generator(this, function(_state) {
|
|
759
|
+
switch(_state.label){
|
|
760
|
+
case 0:
|
|
761
|
+
// 检查粘贴配置
|
|
762
|
+
pasteConfig = props.pasteConfig;
|
|
763
|
+
if ((pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.enabled) === false) {
|
|
764
|
+
return [
|
|
765
|
+
2
|
|
766
|
+
]; // 如果禁用粘贴功能,直接返回
|
|
767
|
+
}
|
|
768
|
+
currentTextSelection = markdownEditorRef.current.selection;
|
|
769
|
+
if (currentTextSelection && currentTextSelection.anchor && Editor.hasPath(markdownEditorRef.current, currentTextSelection.anchor.path)) {
|
|
770
|
+
if (!Range.isCollapsed(currentTextSelection)) {
|
|
771
|
+
Transforms.delete(markdownEditorRef.current, {
|
|
772
|
+
at: currentTextSelection,
|
|
773
|
+
reverse: true
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (currentTextSelection) {
|
|
778
|
+
nodeList = Editor === null || Editor === void 0 ? void 0 : Editor.node(markdownEditorRef.current, currentTextSelection.focus.path);
|
|
779
|
+
curNode = nodeList === null || nodeList === void 0 ? void 0 : nodeList.at(0);
|
|
780
|
+
if (handleTagNodePaste(markdownEditorRef.current, currentTextSelection, event.clipboardData, curNode)) {
|
|
781
|
+
return [
|
|
782
|
+
2
|
|
783
|
+
];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
(_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
|
|
787
|
+
types = ((_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.types) || [
|
|
788
|
+
'text/plain'
|
|
789
|
+
];
|
|
790
|
+
// 默认允许的类型
|
|
791
|
+
defaultAllowedTypes = [
|
|
792
|
+
'application/x-slate-md-fragment',
|
|
793
|
+
'text/html',
|
|
794
|
+
'Files',
|
|
795
|
+
'text/markdown',
|
|
796
|
+
'text/plain'
|
|
797
|
+
];
|
|
798
|
+
// 获取允许的类型
|
|
799
|
+
allowedTypes = (pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.allowedTypes) || defaultAllowedTypes;
|
|
800
|
+
// 1. 首先尝试处理 slate-md-fragment
|
|
801
|
+
if (types.includes('application/x-slate-md-fragment') && allowedTypes.includes('application/x-slate-md-fragment')) {
|
|
802
|
+
if (handleSlateMarkdownFragment(markdownEditorRef.current, event.clipboardData, currentTextSelection)) {
|
|
803
|
+
return [
|
|
804
|
+
2
|
|
805
|
+
];
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (!(types.includes('text/html') && allowedTypes.includes('text/html'))) return [
|
|
809
|
+
3,
|
|
810
|
+
2
|
|
811
|
+
];
|
|
812
|
+
return [
|
|
813
|
+
4,
|
|
814
|
+
handleHtmlPaste(markdownEditorRef.current, event.clipboardData, props)
|
|
815
|
+
];
|
|
816
|
+
case 1:
|
|
817
|
+
if (_state.sent()) {
|
|
818
|
+
return [
|
|
819
|
+
2
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
_state.label = 2;
|
|
823
|
+
case 2:
|
|
824
|
+
if (!(types.includes('Files') && allowedTypes.includes('Files'))) return [
|
|
825
|
+
3,
|
|
826
|
+
4
|
|
827
|
+
];
|
|
828
|
+
return [
|
|
829
|
+
4,
|
|
830
|
+
handleFilesPaste(markdownEditorRef.current, event.clipboardData, props)
|
|
831
|
+
];
|
|
832
|
+
case 3:
|
|
833
|
+
if (_state.sent()) {
|
|
834
|
+
return [
|
|
835
|
+
2
|
|
836
|
+
];
|
|
837
|
+
}
|
|
838
|
+
_state.label = 4;
|
|
839
|
+
case 4:
|
|
840
|
+
if (types.includes('text/markdown') && allowedTypes.includes('text/markdown')) {
|
|
841
|
+
;
|
|
842
|
+
text = ((_event_clipboardData1 = event.clipboardData) === null || _event_clipboardData1 === void 0 ? void 0 : (_event_clipboardData_getData1 = _event_clipboardData1.getData) === null || _event_clipboardData_getData1 === void 0 ? void 0 : (_event_clipboardData_getData = _event_clipboardData_getData1.call(_event_clipboardData1, 'text/markdown')) === null || _event_clipboardData_getData === void 0 ? void 0 : _event_clipboardData_getData.trim()) || '';
|
|
843
|
+
if (text) {
|
|
844
|
+
Transforms.insertFragment(markdownEditorRef.current, parserMdToSchema(text, plugins).schema);
|
|
845
|
+
}
|
|
846
|
+
return [
|
|
847
|
+
2
|
|
848
|
+
];
|
|
849
|
+
}
|
|
850
|
+
if (!(types.includes('text/plain') && allowedTypes.includes('text/plain'))) return [
|
|
851
|
+
3,
|
|
852
|
+
8
|
|
853
|
+
];
|
|
854
|
+
text1 = ((_event_clipboardData2 = event.clipboardData) === null || _event_clipboardData2 === void 0 ? void 0 : (_event_clipboardData_getData3 = _event_clipboardData2.getData) === null || _event_clipboardData_getData3 === void 0 ? void 0 : (_event_clipboardData_getData2 = _event_clipboardData_getData3.call(_event_clipboardData2, 'text/plain')) === null || _event_clipboardData_getData2 === void 0 ? void 0 : _event_clipboardData_getData2.trim()) || '';
|
|
855
|
+
if (!text1) return [
|
|
856
|
+
2
|
|
857
|
+
];
|
|
858
|
+
selection = markdownEditorRef.current.selection;
|
|
859
|
+
// 如果是表格或者代码块,直接插入文本
|
|
860
|
+
if (shouldInsertTextDirectly(markdownEditorRef.current, selection)) {
|
|
861
|
+
Transforms.insertText(markdownEditorRef.current, text1);
|
|
862
|
+
return [
|
|
863
|
+
2
|
|
864
|
+
];
|
|
865
|
+
}
|
|
866
|
+
_state.label = 5;
|
|
867
|
+
case 5:
|
|
868
|
+
_state.trys.push([
|
|
869
|
+
5,
|
|
870
|
+
7,
|
|
871
|
+
,
|
|
872
|
+
8
|
|
873
|
+
]);
|
|
874
|
+
// 处理特殊文本格式(media:// 和 attach:// 链接)
|
|
875
|
+
if (handleSpecialTextPaste(markdownEditorRef.current, text1, selection)) {
|
|
876
|
+
return [
|
|
877
|
+
2
|
|
878
|
+
];
|
|
879
|
+
}
|
|
880
|
+
// 处理 HTTP 链接
|
|
881
|
+
if (handleHttpLinkPaste(markdownEditorRef.current, text1, selection, store)) {
|
|
882
|
+
return [
|
|
883
|
+
2
|
|
884
|
+
];
|
|
885
|
+
}
|
|
886
|
+
return [
|
|
887
|
+
4,
|
|
888
|
+
handlePlainTextPaste(markdownEditorRef.current, text1, selection, plugins)
|
|
889
|
+
];
|
|
890
|
+
case 6:
|
|
891
|
+
// 处理普通文本
|
|
892
|
+
if (_state.sent()) {
|
|
893
|
+
return [
|
|
894
|
+
2
|
|
895
|
+
];
|
|
896
|
+
}
|
|
897
|
+
return [
|
|
898
|
+
3,
|
|
899
|
+
8
|
|
900
|
+
];
|
|
901
|
+
case 7:
|
|
902
|
+
e = _state.sent();
|
|
903
|
+
console.log('insert error', e);
|
|
904
|
+
return [
|
|
905
|
+
3,
|
|
906
|
+
8
|
|
907
|
+
];
|
|
908
|
+
case 8:
|
|
909
|
+
// 5. 如果前面的处理都失败了,才使用默认的插入行为
|
|
910
|
+
if (hasEditableTarget(markdownEditorRef.current, event.target)) {
|
|
911
|
+
ReactEditor.insertData(markdownEditorRef.current, event.clipboardData);
|
|
912
|
+
}
|
|
913
|
+
return [
|
|
914
|
+
2
|
|
915
|
+
];
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
});
|
|
919
|
+
return function handlePasteEvent(event) {
|
|
920
|
+
return _ref.apply(this, arguments);
|
|
921
|
+
};
|
|
922
|
+
}();
|
|
923
|
+
/**
|
|
924
|
+
* 处理输入法开始事件
|
|
925
|
+
*/ var onCompositionStart = function(e) {
|
|
926
|
+
var _markdownContainerRef_current, _markdownEditorRef_current_selection;
|
|
927
|
+
(_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.classList.add('composition');
|
|
928
|
+
store.inputComposition = true;
|
|
929
|
+
var focusPath = ((_markdownEditorRef_current_selection = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection === void 0 ? void 0 : _markdownEditorRef_current_selection.focus.path) || [];
|
|
930
|
+
if (focusPath.length > 0) {
|
|
931
|
+
var _markdownEditorRef_current_selection1;
|
|
932
|
+
var node = Node.get(markdownEditorRef.current, ((_markdownEditorRef_current_selection1 = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection1 === void 0 ? void 0 : _markdownEditorRef_current_selection1.focus.path) || []);
|
|
933
|
+
if (node) {
|
|
934
|
+
var dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
|
|
935
|
+
if (dom) {
|
|
936
|
+
var _dom_querySelector;
|
|
937
|
+
(_dom_querySelector = dom.querySelector('.tag-popup-input')) === null || _dom_querySelector === void 0 ? void 0 : _dom_querySelector.classList.add('tag-popup-input-composition');
|
|
938
|
+
}
|
|
939
|
+
}
|
|
560
940
|
}
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
text,
|
|
564
|
-
selection,
|
|
565
|
-
plugins
|
|
566
|
-
)) {
|
|
567
|
-
return;
|
|
941
|
+
if (markdownEditorRef.current.selection && Range.isCollapsed(markdownEditorRef.current.selection)) {
|
|
942
|
+
e.preventDefault();
|
|
568
943
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if (node) {
|
|
588
|
-
const dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
|
|
589
|
-
if (dom) {
|
|
590
|
-
(_d2 = dom.querySelector(".tag-popup-input")) == null ? void 0 : _d2.classList.add("tag-popup-input-composition");
|
|
944
|
+
};
|
|
945
|
+
/**
|
|
946
|
+
* 处理输入法结束事件
|
|
947
|
+
*/ var onCompositionEnd = function() {
|
|
948
|
+
var _markdownContainerRef_current, _markdownEditorRef_current_selection;
|
|
949
|
+
store.inputComposition = false;
|
|
950
|
+
(_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.classList.remove('composition');
|
|
951
|
+
var focusPath = ((_markdownEditorRef_current_selection = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection === void 0 ? void 0 : _markdownEditorRef_current_selection.focus.path) || [];
|
|
952
|
+
if (focusPath.length > 0) {
|
|
953
|
+
var _markdownEditorRef_current_selection1;
|
|
954
|
+
var node = Node.get(markdownEditorRef.current, ((_markdownEditorRef_current_selection1 = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection1 === void 0 ? void 0 : _markdownEditorRef_current_selection1.focus.path) || []);
|
|
955
|
+
if (node) {
|
|
956
|
+
var dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
|
|
957
|
+
if (dom) {
|
|
958
|
+
var _dom_querySelector;
|
|
959
|
+
(_dom_querySelector = dom.querySelector('.tag-popup-input')) === null || _dom_querySelector === void 0 ? void 0 : _dom_querySelector.classList.remove('tag-popup-input-composition');
|
|
960
|
+
}
|
|
961
|
+
}
|
|
591
962
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (focusPath.length > 0) {
|
|
604
|
-
const node = Node.get(
|
|
605
|
-
markdownEditorRef.current,
|
|
606
|
-
((_c2 = markdownEditorRef.current.selection) == null ? void 0 : _c2.focus.path) || []
|
|
607
|
-
);
|
|
608
|
-
if (node) {
|
|
609
|
-
const dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
|
|
610
|
-
if (dom) {
|
|
611
|
-
(_d2 = dom.querySelector(".tag-popup-input")) == null ? void 0 : _d2.classList.remove("tag-popup-input-composition");
|
|
963
|
+
};
|
|
964
|
+
var elementRenderElement = useCallback(function(eleProps) {
|
|
965
|
+
var _props_lazy;
|
|
966
|
+
// 在每个渲染周期的第一次调用时重置索引
|
|
967
|
+
if (!hasResetIndexRef.current) {
|
|
968
|
+
lazyElementIndexRef.current = 0;
|
|
969
|
+
hasResetIndexRef.current = true;
|
|
970
|
+
// 使用 Promise 在下一个事件循环重置标记
|
|
971
|
+
Promise.resolve().then(function() {
|
|
972
|
+
hasResetIndexRef.current = false;
|
|
973
|
+
});
|
|
612
974
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
var _a2, _b2, _c2, _d2, _e;
|
|
619
|
-
if (!hasResetIndexRef.current) {
|
|
620
|
-
lazyElementIndexRef.current = 0;
|
|
621
|
-
hasResetIndexRef.current = true;
|
|
622
|
-
Promise.resolve().then(() => {
|
|
623
|
-
hasResetIndexRef.current = false;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
const defaultDom = /* @__PURE__ */ React.createElement(
|
|
627
|
-
ErrorBoundary,
|
|
628
|
-
{
|
|
629
|
-
fallbackRender: () => {
|
|
630
|
-
return null;
|
|
631
|
-
}
|
|
632
|
-
},
|
|
633
|
-
/* @__PURE__ */ React.createElement(
|
|
634
|
-
MElement,
|
|
635
|
-
__spreadProps(__spreadValues({}, eleProps), {
|
|
975
|
+
var defaultDom = /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
976
|
+
fallbackRender: function() {
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
}, /*#__PURE__*/ React.createElement(MElement, _object_spread_props(_object_spread({}, eleProps), {
|
|
636
980
|
children: eleProps.children,
|
|
637
|
-
readonly
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
renderedDom = props.eleItemRender(
|
|
652
|
-
eleProps,
|
|
653
|
-
renderedDom
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
if ((_b2 = props.lazy) == null ? void 0 : _b2.enable) {
|
|
658
|
-
if (eleProps.element.type === "table-cell" || eleProps.element.type === "table-row") {
|
|
659
|
-
return renderedDom;
|
|
660
|
-
}
|
|
661
|
-
const currentIndex = lazyElementIndexRef.current;
|
|
662
|
-
lazyElementIndexRef.current += 1;
|
|
663
|
-
const totalElements = countLazyElements(value.current);
|
|
664
|
-
return /* @__PURE__ */ React.createElement(
|
|
665
|
-
LazyElement,
|
|
666
|
-
{
|
|
667
|
-
placeholderHeight: (_c2 = props.lazy) == null ? void 0 : _c2.placeholderHeight,
|
|
668
|
-
rootMargin: (_d2 = props.lazy) == null ? void 0 : _d2.rootMargin,
|
|
669
|
-
renderPlaceholder: (_e = props.lazy) == null ? void 0 : _e.renderPlaceholder,
|
|
670
|
-
elementInfo: {
|
|
671
|
-
type: eleProps.element.type,
|
|
672
|
-
index: currentIndex,
|
|
673
|
-
total: totalElements
|
|
981
|
+
readonly: readonly
|
|
982
|
+
})));
|
|
983
|
+
var renderedDom = defaultDom;
|
|
984
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
985
|
+
try {
|
|
986
|
+
// First check for plugin components
|
|
987
|
+
for(var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
988
|
+
var plugin = _step.value;
|
|
989
|
+
var _plugin_elements;
|
|
990
|
+
var Component = (_plugin_elements = plugin.elements) === null || _plugin_elements === void 0 ? void 0 : _plugin_elements[eleProps.element.type];
|
|
991
|
+
if (Component) {
|
|
992
|
+
renderedDom = /*#__PURE__*/ React.createElement(Component, eleProps);
|
|
993
|
+
break;
|
|
994
|
+
}
|
|
674
995
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
__spreadProps(__spreadValues({}, leafComponentProps), {
|
|
687
|
-
fncProps: props.fncProps,
|
|
688
|
-
comment: props == null ? void 0 : props.comment,
|
|
689
|
-
children: leafComponentProps.children,
|
|
690
|
-
hashId,
|
|
691
|
-
tagInputProps: props.tagInputProps
|
|
692
|
-
})
|
|
693
|
-
);
|
|
694
|
-
if (!props.leafRender)
|
|
695
|
-
return defaultDom;
|
|
696
|
-
return props.leafRender(
|
|
697
|
-
__spreadProps(__spreadValues({}, leafComponentProps), {
|
|
698
|
-
fncProps: props.fncProps,
|
|
699
|
-
comment: props == null ? void 0 : props.comment,
|
|
700
|
-
hashId,
|
|
701
|
-
tagInputProps: props.tagInputProps
|
|
702
|
-
}),
|
|
703
|
-
defaultDom
|
|
704
|
-
);
|
|
705
|
-
});
|
|
706
|
-
const decorateFn = (e) => {
|
|
707
|
-
var _a2;
|
|
708
|
-
const decorateList = high(e) || [];
|
|
709
|
-
if (!(props == null ? void 0 : props.comment))
|
|
710
|
-
return decorateList;
|
|
711
|
-
if (((_a2 = props == null ? void 0 : props.comment) == null ? void 0 : _a2.enable) === false)
|
|
712
|
-
return decorateList;
|
|
713
|
-
if (commentMap.size === 0)
|
|
714
|
-
return decorateList;
|
|
715
|
-
try {
|
|
716
|
-
const ranges = [];
|
|
717
|
-
const [, path] = e;
|
|
718
|
-
const itemMap = commentMap.get(path.join(","));
|
|
719
|
-
if (!itemMap)
|
|
720
|
-
return decorateList;
|
|
721
|
-
itemMap.forEach((itemList) => {
|
|
722
|
-
itemList == null ? void 0 : itemList.forEach((item) => {
|
|
723
|
-
const { anchor, focus } = item.selection || {};
|
|
724
|
-
let newSelection = void 0;
|
|
725
|
-
let fragment = void 0;
|
|
726
|
-
if (anchor && focus && isPath(anchor.path) && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, anchor.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
|
|
727
|
-
newSelection = {
|
|
728
|
-
anchor: {
|
|
729
|
-
path: findLeafPath(markdownEditorRef.current, anchor.path),
|
|
730
|
-
offset: anchor.offset
|
|
731
|
-
},
|
|
732
|
-
focus: {
|
|
733
|
-
path: findLeafPath(markdownEditorRef.current, focus.path),
|
|
734
|
-
offset: focus.offset
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
fragment = Editor.fragment(
|
|
738
|
-
markdownEditorRef.current,
|
|
739
|
-
newSelection
|
|
740
|
-
);
|
|
741
|
-
} else if (item.refContent) {
|
|
742
|
-
const findDom = findByPathAndText(
|
|
743
|
-
markdownEditorRef.current,
|
|
744
|
-
item.path,
|
|
745
|
-
item.refContent
|
|
746
|
-
).at(0);
|
|
747
|
-
if (findDom) {
|
|
748
|
-
newSelection = {
|
|
749
|
-
anchor: __spreadProps(__spreadValues({}, anchor), {
|
|
750
|
-
path: findLeafPath(markdownEditorRef.current, findDom.path),
|
|
751
|
-
offset: findDom.offset.start
|
|
752
|
-
}),
|
|
753
|
-
focus: __spreadProps(__spreadValues({}, focus), {
|
|
754
|
-
path: findLeafPath(markdownEditorRef.current, findDom.path),
|
|
755
|
-
offset: findDom.offset.end
|
|
756
|
-
})
|
|
757
|
-
};
|
|
758
|
-
fragment = Editor.fragment(
|
|
759
|
-
markdownEditorRef.current,
|
|
760
|
-
newSelection
|
|
761
|
-
);
|
|
762
|
-
} else {
|
|
763
|
-
if (focus && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
|
|
764
|
-
try {
|
|
765
|
-
const [node] = Editor.node(
|
|
766
|
-
markdownEditorRef.current,
|
|
767
|
-
item.path
|
|
768
|
-
);
|
|
769
|
-
if ((node == null ? void 0 : node.type) === "table" || (node == null ? void 0 : node.type) === "card") {
|
|
770
|
-
const startPoint = Editor.start(
|
|
771
|
-
markdownEditorRef.current,
|
|
772
|
-
item.path
|
|
773
|
-
);
|
|
774
|
-
const endPoint = Editor.end(
|
|
775
|
-
markdownEditorRef.current,
|
|
776
|
-
item.path
|
|
777
|
-
);
|
|
778
|
-
newSelection = {
|
|
779
|
-
anchor: startPoint,
|
|
780
|
-
focus: endPoint
|
|
781
|
-
};
|
|
782
|
-
fragment = Editor.fragment(
|
|
783
|
-
markdownEditorRef.current,
|
|
784
|
-
newSelection
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
} catch (error) {
|
|
788
|
-
console.error("Error selecting table node:", error);
|
|
996
|
+
} catch (err) {
|
|
997
|
+
_didIteratorError = true;
|
|
998
|
+
_iteratorError = err;
|
|
999
|
+
} finally{
|
|
1000
|
+
try {
|
|
1001
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1002
|
+
_iterator.return();
|
|
1003
|
+
}
|
|
1004
|
+
} finally{
|
|
1005
|
+
if (_didIteratorError) {
|
|
1006
|
+
throw _iteratorError;
|
|
789
1007
|
}
|
|
790
|
-
}
|
|
791
1008
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
ranges.push({
|
|
798
|
-
anchor: {
|
|
799
|
-
path: newAnchorPath,
|
|
800
|
-
offset: newSelection.anchor.offset
|
|
801
|
-
},
|
|
802
|
-
focus: {
|
|
803
|
-
path: newFocusPath,
|
|
804
|
-
offset: newSelection.focus.offset
|
|
805
|
-
},
|
|
806
|
-
data: itemList,
|
|
807
|
-
comment: true,
|
|
808
|
-
id: item.id,
|
|
809
|
-
selection: newSelection,
|
|
810
|
-
updateTime: itemList.map((i) => i.updateTime).sort().join(",")
|
|
811
|
-
});
|
|
1009
|
+
}
|
|
1010
|
+
// Then allow eleItemRender to process the result
|
|
1011
|
+
if (props.eleItemRender) {
|
|
1012
|
+
if (eleProps.element.type !== 'table-cell' && eleProps.element.type !== 'table-row') {
|
|
1013
|
+
renderedDom = props.eleItemRender(eleProps, renderedDom);
|
|
812
1014
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
1015
|
+
}
|
|
1016
|
+
// Finally, wrap with LazyElement if lazy mode is enabled
|
|
1017
|
+
if ((_props_lazy = props.lazy) === null || _props_lazy === void 0 ? void 0 : _props_lazy.enable) {
|
|
1018
|
+
var _props_lazy1, _props_lazy2, _props_lazy3;
|
|
1019
|
+
// 不对表格单元格和表格行进行懒加载,避免破坏表格结构
|
|
1020
|
+
if (eleProps.element.type === 'table-cell' || eleProps.element.type === 'table-row') {
|
|
1021
|
+
return renderedDom;
|
|
1022
|
+
}
|
|
1023
|
+
// 获取当前索引并递增
|
|
1024
|
+
var currentIndex = lazyElementIndexRef.current;
|
|
1025
|
+
lazyElementIndexRef.current += 1;
|
|
1026
|
+
// 计算总元素数
|
|
1027
|
+
var totalElements = countLazyElements(value.current);
|
|
1028
|
+
return /*#__PURE__*/ React.createElement(LazyElement, {
|
|
1029
|
+
placeholderHeight: (_props_lazy1 = props.lazy) === null || _props_lazy1 === void 0 ? void 0 : _props_lazy1.placeholderHeight,
|
|
1030
|
+
rootMargin: (_props_lazy2 = props.lazy) === null || _props_lazy2 === void 0 ? void 0 : _props_lazy2.rootMargin,
|
|
1031
|
+
renderPlaceholder: (_props_lazy3 = props.lazy) === null || _props_lazy3 === void 0 ? void 0 : _props_lazy3.renderPlaceholder,
|
|
1032
|
+
elementInfo: {
|
|
1033
|
+
type: eleProps.element.type,
|
|
1034
|
+
index: currentIndex,
|
|
1035
|
+
total: totalElements
|
|
1036
|
+
}
|
|
1037
|
+
}, renderedDom);
|
|
1038
|
+
}
|
|
1039
|
+
return renderedDom;
|
|
1040
|
+
}, [
|
|
1041
|
+
props.eleItemRender,
|
|
1042
|
+
props.lazy,
|
|
1043
|
+
plugins,
|
|
1044
|
+
readonly,
|
|
1045
|
+
countLazyElements
|
|
1046
|
+
]);
|
|
1047
|
+
var renderMarkdownLeaf = useRefFunction(function(leafComponentProps) {
|
|
1048
|
+
var defaultDom = /*#__PURE__*/ React.createElement(MLeaf, _object_spread_props(_object_spread({}, leafComponentProps), {
|
|
1049
|
+
fncProps: props.fncProps,
|
|
1050
|
+
comment: props === null || props === void 0 ? void 0 : props.comment,
|
|
1051
|
+
children: leafComponentProps.children,
|
|
1052
|
+
hashId: hashId,
|
|
1053
|
+
tagInputProps: props.tagInputProps
|
|
1054
|
+
}));
|
|
1055
|
+
if (!props.leafRender) return defaultDom;
|
|
1056
|
+
return props.leafRender(_object_spread_props(_object_spread({}, leafComponentProps), {
|
|
1057
|
+
fncProps: props.fncProps,
|
|
1058
|
+
comment: props === null || props === void 0 ? void 0 : props.comment,
|
|
1059
|
+
hashId: hashId,
|
|
1060
|
+
tagInputProps: props.tagInputProps
|
|
1061
|
+
}), defaultDom);
|
|
1062
|
+
});
|
|
1063
|
+
var decorateFn = function(e) {
|
|
1064
|
+
var _props_comment;
|
|
1065
|
+
var decorateList = high(e) || [];
|
|
1066
|
+
if (!(props === null || props === void 0 ? void 0 : props.comment)) return decorateList;
|
|
1067
|
+
if ((props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : _props_comment.enable) === false) return decorateList;
|
|
1068
|
+
if (commentMap.size === 0) return decorateList;
|
|
1069
|
+
try {
|
|
1070
|
+
var ranges = [];
|
|
1071
|
+
var _e = _sliced_to_array(e, 2), path = _e[1];
|
|
1072
|
+
var itemMap = commentMap.get(path.join(','));
|
|
1073
|
+
if (!itemMap) return decorateList;
|
|
1074
|
+
itemMap.forEach(function(itemList) {
|
|
1075
|
+
itemList === null || itemList === void 0 ? void 0 : itemList.forEach(function(item) {
|
|
1076
|
+
var _ref = item.selection || {}, anchor = _ref.anchor, focus = _ref.focus;
|
|
1077
|
+
var newSelection = undefined;
|
|
1078
|
+
var fragment = undefined;
|
|
1079
|
+
if (anchor && focus && isPath(anchor.path) && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, anchor.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
|
|
1080
|
+
newSelection = {
|
|
1081
|
+
anchor: {
|
|
1082
|
+
path: findLeafPath(markdownEditorRef.current, anchor.path),
|
|
1083
|
+
offset: anchor.offset
|
|
1084
|
+
},
|
|
1085
|
+
focus: {
|
|
1086
|
+
path: findLeafPath(markdownEditorRef.current, focus.path),
|
|
1087
|
+
offset: focus.offset
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
fragment = Editor.fragment(markdownEditorRef.current, newSelection);
|
|
1091
|
+
} else if (item.refContent) {
|
|
1092
|
+
var findDom = findByPathAndText(markdownEditorRef.current, item.path, item.refContent).at(0);
|
|
1093
|
+
if (findDom) {
|
|
1094
|
+
newSelection = {
|
|
1095
|
+
anchor: _object_spread_props(_object_spread({}, anchor), {
|
|
1096
|
+
path: findLeafPath(markdownEditorRef.current, findDom.path),
|
|
1097
|
+
offset: findDom.offset.start
|
|
1098
|
+
}),
|
|
1099
|
+
focus: _object_spread_props(_object_spread({}, focus), {
|
|
1100
|
+
path: findLeafPath(markdownEditorRef.current, findDom.path),
|
|
1101
|
+
offset: findDom.offset.end
|
|
1102
|
+
})
|
|
1103
|
+
};
|
|
1104
|
+
fragment = Editor.fragment(markdownEditorRef.current, newSelection);
|
|
1105
|
+
} else {
|
|
1106
|
+
// 检查 focus.path 是否存在且有效
|
|
1107
|
+
if (focus && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
|
|
1108
|
+
try {
|
|
1109
|
+
// 获取 focus.path 对应的节点
|
|
1110
|
+
var _Editor_node = _sliced_to_array(Editor.node(markdownEditorRef.current, item.path), 1), node = _Editor_node[0];
|
|
1111
|
+
// 检查该节点是否是 table 类型
|
|
1112
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === 'table' || (node === null || node === void 0 ? void 0 : node.type) === 'card') {
|
|
1113
|
+
// 获取 table 节点的开始和结尾位置
|
|
1114
|
+
var startPoint = Editor.start(markdownEditorRef.current, item.path);
|
|
1115
|
+
var endPoint = Editor.end(markdownEditorRef.current, item.path);
|
|
1116
|
+
newSelection = {
|
|
1117
|
+
anchor: startPoint,
|
|
1118
|
+
focus: endPoint
|
|
1119
|
+
};
|
|
1120
|
+
fragment = Editor.fragment(markdownEditorRef.current, newSelection);
|
|
1121
|
+
}
|
|
1122
|
+
} catch (error) {
|
|
1123
|
+
console.error('Error selecting table node:', error);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
// 尝试调整路径,处理可能的节点变化
|
|
1129
|
+
if (fragment && newSelection) {
|
|
1130
|
+
var newAnchorPath = newSelection.anchor.path;
|
|
1131
|
+
var newFocusPath = newSelection.focus.path;
|
|
1132
|
+
if (isPath(newFocusPath) && isPath(newAnchorPath) && Editor.hasPath(markdownEditorRef.current, newAnchorPath) && Editor.hasPath(markdownEditorRef.current, newFocusPath)) {
|
|
1133
|
+
ranges.push({
|
|
1134
|
+
anchor: {
|
|
1135
|
+
path: newAnchorPath,
|
|
1136
|
+
offset: newSelection.anchor.offset
|
|
1137
|
+
},
|
|
1138
|
+
focus: {
|
|
1139
|
+
path: newFocusPath,
|
|
1140
|
+
offset: newSelection.focus.offset
|
|
1141
|
+
},
|
|
1142
|
+
data: itemList,
|
|
1143
|
+
comment: true,
|
|
1144
|
+
id: item.id,
|
|
1145
|
+
selection: newSelection,
|
|
1146
|
+
updateTime: itemList.map(function(i) {
|
|
1147
|
+
return i.updateTime;
|
|
1148
|
+
}).sort().join(',')
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
});
|
|
1154
|
+
return decorateList.concat(ranges);
|
|
1155
|
+
} catch (error) {
|
|
1156
|
+
console.log('error', error);
|
|
1157
|
+
return decorateList;
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
var _obj;
|
|
1161
|
+
return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Slate, {
|
|
826
1162
|
editor: markdownEditorRef.current,
|
|
827
|
-
initialValue: [
|
|
1163
|
+
initialValue: [
|
|
1164
|
+
EditorUtils.p
|
|
1165
|
+
],
|
|
828
1166
|
onChange: onSlateChange
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
props.className,
|
|
843
|
-
baseClassName,
|
|
844
|
-
{
|
|
845
|
-
[`${baseClassName}-${readonlyCls}`]: readonlyCls,
|
|
846
|
-
[`${baseClassName}-report`]: props.reportMode,
|
|
847
|
-
[`${baseClassName}-edit`]: !readonly,
|
|
848
|
-
[`${baseClassName}-compact`]: props.compact
|
|
849
|
-
},
|
|
850
|
-
hashId
|
|
851
|
-
),
|
|
852
|
-
style: props.reportMode ? __spreadValues({
|
|
1167
|
+
}, /*#__PURE__*/ React.createElement(Editable, {
|
|
1168
|
+
decorate: decorateFn,
|
|
1169
|
+
onDragOver: function(e) {
|
|
1170
|
+
return e.preventDefault();
|
|
1171
|
+
},
|
|
1172
|
+
readOnly: readonly,
|
|
1173
|
+
spellCheck: false,
|
|
1174
|
+
autoCorrect: "off",
|
|
1175
|
+
autoCapitalize: "none",
|
|
1176
|
+
onCompositionStart: onCompositionStart,
|
|
1177
|
+
onCompositionEnd: onCompositionEnd,
|
|
1178
|
+
className: classNames(props.className, baseClassName, (_obj = {}, _define_property(_obj, "".concat(baseClassName, "-").concat(readonlyCls), readonlyCls), _define_property(_obj, "".concat(baseClassName, "-report"), props.reportMode), _define_property(_obj, "".concat(baseClassName, "-edit"), !readonly), _define_property(_obj, "".concat(baseClassName, "-compact"), props.compact), _obj), hashId),
|
|
1179
|
+
style: props.reportMode ? _object_spread({
|
|
853
1180
|
fontSize: 16
|
|
854
|
-
|
|
1181
|
+
}, props.style) : _object_spread({
|
|
855
1182
|
fontSize: 14
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
1183
|
+
}, props.style),
|
|
1184
|
+
onSelect: handleSelectionChange.run,
|
|
1185
|
+
onCut: function(event) {
|
|
1186
|
+
var handled = handleClipboardCopy(event, 'cut');
|
|
860
1187
|
if (!handled) {
|
|
861
|
-
|
|
1188
|
+
event.preventDefault();
|
|
862
1189
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
var
|
|
866
|
-
(
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
setDomRect == null ? void 0 : setDomRect(null);
|
|
875
|
-
},
|
|
876
|
-
onMouseDown: checkEnd,
|
|
877
|
-
onPaste: (event) => {
|
|
1190
|
+
},
|
|
1191
|
+
onFocus: function(e) {
|
|
1192
|
+
var _props_onFocus;
|
|
1193
|
+
(_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, parserSlateNodeToMarkdown(markdownEditorRef.current.children), markdownEditorRef.current.children, e);
|
|
1194
|
+
},
|
|
1195
|
+
onBlur: function() {
|
|
1196
|
+
// 失去焦点时清除工具栏
|
|
1197
|
+
setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
|
|
1198
|
+
},
|
|
1199
|
+
onMouseDown: checkEnd,
|
|
1200
|
+
onPaste: function(event) {
|
|
878
1201
|
event.preventDefault();
|
|
879
1202
|
event.stopPropagation();
|
|
880
1203
|
onPaste(event);
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1204
|
+
},
|
|
1205
|
+
onCopy: function(event) {
|
|
1206
|
+
var handled = handleClipboardCopy(event, 'copy');
|
|
884
1207
|
if (!handled) {
|
|
885
|
-
|
|
1208
|
+
event.preventDefault();
|
|
886
1209
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
)
|
|
893
|
-
))
|
|
894
|
-
);
|
|
895
|
-
};
|
|
896
|
-
export {
|
|
897
|
-
SlateMarkdownEditor
|
|
1210
|
+
},
|
|
1211
|
+
renderElement: elementRenderElement,
|
|
1212
|
+
onKeyDown: handleKeyDown,
|
|
1213
|
+
renderLeaf: renderMarkdownLeaf
|
|
1214
|
+
}))));
|
|
898
1215
|
};
|