@ant-design/agentic-ui 2.29.6 → 2.29.8
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/AILabel/index.js +17 -8
- package/dist/AgenticLayout/index.js +3 -5
- package/dist/BackTo/BackBottom.js +17 -8
- package/dist/BackTo/BackTop.js +17 -8
- package/dist/BackTo/ScrollVisibleButton.js +75 -11
- package/dist/Bubble/AIBubble.js +131 -121
- package/dist/Bubble/Avatar/index.js +19 -10
- package/dist/Bubble/FileView.js +2 -2
- package/dist/Bubble/List/PureBubbleList.js +4 -5
- package/dist/Bubble/List/index.js +4 -5
- package/dist/Bubble/List/style.js +3 -0
- package/dist/Bubble/MessagesContent/BubbleExtra.js +108 -93
- package/dist/Bubble/MessagesContent/CopyButton/index.js +36 -26
- package/dist/Bubble/MessagesContent/DocInfo.js +19 -10
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +2 -2
- package/dist/Bubble/MessagesContent/index.js +149 -130
- package/dist/Bubble/PureBubble.js +151 -133
- package/dist/Bubble/UserBubble.js +1 -1
- package/dist/Bubble/style.js +2 -2
- package/dist/Bubble/types/BubbleExtra.js +4 -1
- package/dist/Bubble/types/DocInfo.js +9 -1
- package/dist/ChatLayout/components/FooterBackgroundLottie/images/img_0.png +0 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/images/img_1.png +0 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/images/img_2.png +0 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/index.d.ts +51 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/index.js +45 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/lottie.d.ts +85 -0
- package/dist/ChatLayout/components/FooterBackgroundLottie/lottie.js +382 -0
- package/dist/ChatLayout/index.js +52 -14
- package/dist/ChatLayout/style.js +11 -0
- package/dist/ChatLayout/types.d.ts +28 -0
- package/dist/Components/ActionIconBox/index.js +30 -38
- package/dist/Components/ActionItemBox/ActionItemBox.js +1 -1
- package/dist/Components/Button/SwitchButton/index.js +18 -17
- package/dist/Components/LayoutHeader/index.js +5 -3
- package/dist/Components/LayoutHeader/style.js +5 -0
- package/dist/Components/Loading/CreativeRecommendationLoading.js +2 -2
- package/dist/Components/Loading/CreativeSparkLoading.js +2 -2
- package/dist/Components/SuggestionList/index.js +20 -19
- package/dist/Components/TextAnimate/index.js +19 -10
- package/dist/Components/TypingAnimation/index.js +19 -10
- package/dist/Components/effects/EffectPlayer.js +20 -11
- package/dist/Components/icons/LoadingSpinnerIcon.js +19 -10
- package/dist/History/components/HistoryActionsBox.js +21 -23
- package/dist/History/components/HistoryItem.js +61 -53
- package/dist/History/components/HistoryRunningIcon.js +19 -10
- package/dist/History/components/LoadMoreComponent.js +61 -55
- package/dist/History/components/NewChatComponent.js +53 -47
- package/dist/History/components/SearchComponent.js +24 -26
- package/dist/History/hooks/useHistory.js +80 -73
- package/dist/History/index.js +17 -16
- package/dist/History/menu.js +17 -8
- package/dist/Hooks/useAutoScroll.js +19 -19
- package/dist/Hooks/useDebounceFn/index.js +51 -45
- package/dist/Hooks/useElementSize.d.ts +5 -0
- package/dist/Hooks/useElementSize.js +71 -0
- package/dist/Hooks/useIntersectionOnce.js +17 -8
- package/dist/Hooks/useLanguage.d.ts +3 -0
- package/dist/I18n/locales.d.ts +3 -0
- package/dist/I18n/locales.js +8 -0
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +23 -13
- package/dist/MarkdownEditor/editor/Editor.js +31 -39
- package/dist/MarkdownEditor/editor/components/CommentList/index.js +29 -37
- package/dist/MarkdownEditor/editor/elements/Blockquote/ReadonlyBlockquote.d.ts +33 -0
- package/dist/MarkdownEditor/editor/elements/Blockquote/ReadonlyBlockquote.js +69 -0
- package/dist/MarkdownEditor/editor/elements/Break/ReadonlyBreak.d.ts +30 -0
- package/dist/MarkdownEditor/editor/elements/Break/ReadonlyBreak.js +88 -0
- package/dist/MarkdownEditor/editor/elements/Card/ReadonlyCard.d.ts +34 -0
- package/dist/MarkdownEditor/editor/elements/Card/ReadonlyCard.js +96 -0
- package/dist/MarkdownEditor/editor/elements/Code/ReadonlyCode.d.ts +33 -0
- package/dist/MarkdownEditor/editor/elements/Code/ReadonlyCode.js +145 -0
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/ReadonlyFootnoteDefinition.d.ts +34 -0
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/ReadonlyFootnoteDefinition.js +125 -0
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/ReadonlyFootnoteReference.d.ts +34 -0
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/ReadonlyFootnoteReference.js +101 -0
- package/dist/MarkdownEditor/editor/elements/Head/ReadonlyHead.d.ts +35 -0
- package/dist/MarkdownEditor/editor/elements/Head/ReadonlyHead.js +111 -0
- package/dist/MarkdownEditor/editor/elements/Head/index.d.ts +3 -0
- package/dist/MarkdownEditor/editor/elements/Head/index.js +3 -1
- package/dist/MarkdownEditor/editor/elements/Hr/ReadonlyHr.d.ts +30 -0
- package/dist/MarkdownEditor/editor/elements/Hr/ReadonlyHr.js +95 -0
- package/dist/MarkdownEditor/editor/elements/Image/ReadonlyEditorImage.d.ts +35 -0
- package/dist/MarkdownEditor/editor/elements/Image/ReadonlyEditorImage.js +426 -0
- package/dist/MarkdownEditor/editor/elements/Image/index.js +124 -121
- package/dist/MarkdownEditor/editor/elements/InlineKatex/ReadonlyInlineKatex.d.ts +32 -0
- package/dist/MarkdownEditor/editor/elements/InlineKatex/ReadonlyInlineKatex.js +100 -0
- package/dist/MarkdownEditor/editor/elements/Katex/ReadonlyKatex.d.ts +32 -0
- package/dist/MarkdownEditor/editor/elements/Katex/ReadonlyKatex.js +110 -0
- package/dist/MarkdownEditor/editor/elements/LinkCard/ReadonlyLinkCard.d.ts +40 -0
- package/dist/MarkdownEditor/editor/elements/LinkCard/ReadonlyLinkCard.js +215 -0
- package/dist/MarkdownEditor/editor/elements/List/List.js +27 -12
- package/dist/MarkdownEditor/editor/elements/List/ListItem.js +17 -16
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyList.d.ts +33 -0
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyList.js +93 -0
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyListItem.d.ts +35 -0
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyListItem.js +138 -0
- package/dist/MarkdownEditor/editor/elements/Media/ReadonlyMedia.d.ts +36 -0
- package/dist/MarkdownEditor/editor/elements/Media/ReadonlyMedia.js +600 -0
- package/dist/MarkdownEditor/editor/elements/Media/index.js +107 -92
- package/dist/MarkdownEditor/editor/elements/Mermaid/ReadonlyMermaid.d.ts +32 -0
- package/dist/MarkdownEditor/editor/elements/Mermaid/ReadonlyMermaid.js +101 -0
- package/dist/MarkdownEditor/editor/elements/Paragraph/ReadonlyParagraph.d.ts +35 -0
- package/dist/MarkdownEditor/editor/elements/Paragraph/ReadonlyParagraph.js +109 -0
- package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +2 -1
- package/dist/MarkdownEditor/editor/elements/Schema/ReadonlySchema.d.ts +33 -0
- package/dist/MarkdownEditor/editor/elements/Schema/ReadonlySchema.js +163 -0
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +19 -10
- package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +17 -16
- package/dist/MarkdownEditor/editor/elements/index.d.ts +20 -1
- package/dist/MarkdownEditor/editor/elements/index.js +65 -29
- package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +19 -11
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +1 -1
- package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.js +1 -1
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +4 -1
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +66 -23
- package/dist/MarkdownEditor/editor/parser/remarkParse.js +3 -1
- package/dist/MarkdownEditor/editor/plugins/elements.js +60 -6
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +25 -30
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +0 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +97 -39
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +0 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +0 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.d.ts +14 -0
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +117 -91
- package/dist/MarkdownEditor/editor/plugins/index.d.ts +8 -0
- package/dist/MarkdownEditor/editor/plugins/index.js +8 -0
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.d.ts +12 -6
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +106 -95
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +1 -1
- package/dist/MarkdownEditor/editor/plugins/useOnchange.js +28 -22
- package/dist/MarkdownEditor/editor/plugins/utils.d.ts +31 -0
- package/dist/MarkdownEditor/editor/plugins/utils.js +75 -0
- package/dist/MarkdownEditor/editor/plugins/withCardPlugin.d.ts +15 -0
- package/dist/MarkdownEditor/editor/plugins/withCardPlugin.js +329 -0
- package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.d.ts +11 -0
- package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.js +299 -0
- package/dist/MarkdownEditor/editor/plugins/withInlineNodes.d.ts +12 -0
- package/dist/MarkdownEditor/editor/plugins/withInlineNodes.js +17 -0
- package/dist/MarkdownEditor/editor/plugins/withLinkAndMediaPlugin.d.ts +11 -0
- package/dist/MarkdownEditor/editor/plugins/withLinkAndMediaPlugin.js +70 -0
- package/dist/MarkdownEditor/editor/plugins/withListsPlugin.d.ts +23 -0
- package/dist/MarkdownEditor/editor/plugins/withListsPlugin.js +204 -0
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.d.ts +9 -12
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +17 -764
- package/dist/MarkdownEditor/editor/plugins/withSchemaPlugin.d.ts +11 -0
- package/dist/MarkdownEditor/editor/plugins/withSchemaPlugin.js +55 -0
- package/dist/MarkdownEditor/editor/plugins/withVoidNodes.d.ts +12 -0
- package/dist/MarkdownEditor/editor/plugins/withVoidNodes.js +17 -0
- package/dist/MarkdownEditor/editor/store.js +18 -14
- package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +202 -197
- package/dist/MarkdownEditor/editor/tools/InsertLink.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +142 -134
- package/dist/MarkdownEditor/editor/utils/ace.js +61 -61
- package/dist/MarkdownEditor/editor/utils/docx/module.js +41 -8
- package/dist/MarkdownEditor/editor/utils/editorCommands.d.ts +97 -0
- package/dist/MarkdownEditor/editor/utils/editorCommands.js +966 -0
- package/dist/MarkdownEditor/editor/utils/editorUtils.js +13 -6
- package/dist/MarkdownEditor/editor/utils/index.js +8 -2
- package/dist/MarkdownEditor/editor/utils/keyboard.js +46 -426
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +23 -17
- package/dist/MarkdownEditor/editor/utils/media.js +21 -23
- package/dist/MarkdownEditor/editor/utils/performanceMonitor.js +55 -50
- package/dist/MarkdownEditor/editor/utils/useLocalState.js +11 -4
- package/dist/MarkdownEditor/el.d.ts +12 -5
- package/dist/MarkdownEditor/types.d.ts +1 -0
- package/dist/MarkdownEditor/types.js +4 -1
- package/dist/MarkdownEditor/utils/native-table/native-table-editor.js +14 -14
- package/dist/MarkdownEditor/utils/native-table/native-table-keyboard.js +2 -2
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +1 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +33 -31
- package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +14 -7
- package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +2 -2
- package/dist/MarkdownInputField/FileMapView/index.js +17 -16
- package/dist/MarkdownInputField/FilePaste/index.js +25 -30
- package/dist/MarkdownInputField/FileUploadManager/index.js +39 -40
- package/dist/MarkdownInputField/MarkdownInputField.js +47 -51
- package/dist/MarkdownInputField/QuickActions/index.js +66 -60
- package/dist/MarkdownInputField/SendButton/index.js +22 -13
- package/dist/MarkdownInputField/Suggestion/index.js +17 -16
- package/dist/MarkdownInputField/VoiceInput/index.js +51 -45
- package/dist/MarkdownInputField/VoiceInputManager/index.js +133 -125
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +103 -101
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldStyles.js +1 -1
- package/dist/MarkdownInputField/style.js +8 -4
- package/dist/MarkdownInputField/types/MarkdownInputFieldProps.js +14 -1
- package/dist/Plugins/chart/BarChart/index.js +8 -8
- package/dist/Plugins/chart/ChartRender.js +52 -46
- package/dist/Plugins/chart/DonutChart/index.js +26 -17
- package/dist/Plugins/chart/DonutChart/plugins.js +1 -1
- package/dist/Plugins/chart/DonutChart/types.js +1 -1
- package/dist/Plugins/chart/FunnelChart/index.js +31 -28
- package/dist/Plugins/chart/LineChart/index.js +19 -10
- package/dist/Plugins/chart/RadarChart/index.js +19 -10
- package/dist/Plugins/chart/ScatterChart/index.js +19 -10
- package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +20 -11
- package/dist/Plugins/chart/index.js +31 -13
- package/dist/Plugins/chart/loadChartRuntime.js +17 -16
- package/dist/Plugins/chart/types/classNames.js +4 -1
- package/dist/Plugins/chart/utils.js +20 -20
- package/dist/Plugins/code/CodeUI/Katex/Katex.js +52 -46
- package/dist/Plugins/code/components/AceEditor.js +149 -133
- package/dist/Plugins/code/components/CodeRenderer.js +7 -7
- package/dist/Plugins/code/components/CodeToolbar.js +2 -2
- package/dist/Plugins/code/components/LanguageSelector.js +6 -6
- package/dist/Plugins/code/components/LoadImage.js +5 -5
- package/dist/Plugins/code/components/ThinkBlock.js +8 -8
- package/dist/Plugins/code/hooks/useCodeEditorState.js +5 -5
- package/dist/Plugins/code/index.js +6 -6
- package/dist/Plugins/code/langIconMap.js +0 -1
- package/dist/Plugins/code/langIcons/AbapIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ActionscriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/AdaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ApacheIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ApexIcon.js +19 -10
- package/dist/Plugins/code/langIcons/AplIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ApplescriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/AstroIcon.js +19 -10
- package/dist/Plugins/code/langIcons/AwkIcon.js +19 -10
- package/dist/Plugins/code/langIcons/BallerinaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/BatIcon.js +19 -10
- package/dist/Plugins/code/langIcons/BicepIcon.js +19 -10
- package/dist/Plugins/code/langIcons/BladeIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CadenceIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ClojureIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CmakeIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CobolIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CodeqlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CoffeeIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ConsoleIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CppIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CrystalIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CsharpIcon.js +19 -10
- package/dist/Plugins/code/langIcons/CssIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DartIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DatabaseIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DiffIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DockerIcon.js +19 -10
- package/dist/Plugins/code/langIcons/DotenvIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ElixirIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ElmIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ErbIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ErlangIcon.js +19 -10
- package/dist/Plugins/code/langIcons/FsharpIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GdscriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GlslIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GnuplotIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GoIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GraphqlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/GroovyIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HackIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HamlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HandlebarsIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HaskellIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HclIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HclLightIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HjsonIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HlslIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HtmlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/HttpIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ImbaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/IniIcon.js +19 -10
- package/dist/Plugins/code/langIcons/JavaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/JavascriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/JinjaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/Json5Icon.js +19 -10
- package/dist/Plugins/code/langIcons/JsonIcon.js +19 -10
- package/dist/Plugins/code/langIcons/JsonnetIcon.js +19 -10
- package/dist/Plugins/code/langIcons/JuliaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/KotlinIcon.js +19 -10
- package/dist/Plugins/code/langIcons/KustoIcon.js +19 -10
- package/dist/Plugins/code/langIcons/LessIcon.js +19 -10
- package/dist/Plugins/code/langIcons/LiquidIcon.js +19 -10
- package/dist/Plugins/code/langIcons/LispIcon.js +19 -10
- package/dist/Plugins/code/langIcons/LuaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MakefileIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MarkdownIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MarkojsIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MatlabIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MdxIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MermaidIcon.js +19 -10
- package/dist/Plugins/code/langIcons/MojoIcon.js +19 -10
- package/dist/Plugins/code/langIcons/NginxIcon.js +19 -10
- package/dist/Plugins/code/langIcons/NimIcon.js +19 -10
- package/dist/Plugins/code/langIcons/NixIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ObjectiveCIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ObjectiveCppIcon.js +19 -10
- package/dist/Plugins/code/langIcons/OcamlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PascalIcon.js +19 -10
- package/dist/Plugins/code/langIcons/Perl6Icon.js +19 -10
- package/dist/Plugins/code/langIcons/PerlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PhpIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PostcssIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PowershellIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PrismaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PrologIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ProtoIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PugIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PuppetIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PurescriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/PythonIcon.js +19 -10
- package/dist/Plugins/code/langIcons/RIcon.js +19 -10
- package/dist/Plugins/code/langIcons/RazorIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ReactIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ReactTsIcon.js +19 -10
- package/dist/Plugins/code/langIcons/RubyIcon.js +19 -10
- package/dist/Plugins/code/langIcons/RustIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SasIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SassIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ScalaIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SchemeIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ShaderlabIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SolidityIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SparqlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/StataIcon.js +19 -10
- package/dist/Plugins/code/langIcons/StylusIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SvelteIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SwiftIcon.js +19 -10
- package/dist/Plugins/code/langIcons/SystemverilogIcon.js +19 -10
- package/dist/Plugins/code/langIcons/TclIcon.js +19 -10
- package/dist/Plugins/code/langIcons/TexIcon.js +19 -10
- package/dist/Plugins/code/langIcons/TomlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/TwigIcon.js +19 -10
- package/dist/Plugins/code/langIcons/TypescriptIcon.js +19 -10
- package/dist/Plugins/code/langIcons/VerilogIcon.js +19 -10
- package/dist/Plugins/code/langIcons/VhdlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/VimIcon.js +19 -10
- package/dist/Plugins/code/langIcons/VueIcon.js +19 -10
- package/dist/Plugins/code/langIcons/WebassemblyIcon.js +19 -10
- package/dist/Plugins/code/langIcons/WenyanIcon.js +19 -10
- package/dist/Plugins/code/langIcons/WgslIcon.js +19 -10
- package/dist/Plugins/code/langIcons/WolframlanguageIcon.js +19 -10
- package/dist/Plugins/code/langIcons/XmlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/XslIcon.js +19 -10
- package/dist/Plugins/code/langIcons/YamlIcon.js +19 -10
- package/dist/Plugins/code/langIcons/ZigIcon.js +19 -10
- package/dist/Plugins/code/loadAceEditor.js +21 -23
- package/dist/Plugins/code/utils/langOptions.js +6 -6
- package/dist/Plugins/formatter/index.js +6 -6
- package/dist/Plugins/katex/InlineKatex.js +52 -46
- package/dist/Plugins/katex/Katex.js +53 -47
- package/dist/Plugins/katex/index.js +6 -6
- package/dist/Plugins/katex/loadKatex.js +27 -29
- package/dist/Plugins/mermaid/Mermaid.js +34 -28
- package/dist/Plugins/mermaid/useMermaidRender.js +103 -97
- package/dist/Plugins/mermaid/utils.js +25 -17
- package/dist/Schema/SchemaEditor/AceEditorWrapper.js +162 -150
- package/dist/Schema/SchemaEditor/index.js +8 -1
- package/dist/Schema/SchemaForm/index.js +2 -2
- package/dist/Schema/SchemaRenderer/index.js +45 -46
- package/dist/ThoughtChainList/index.js +22 -13
- package/dist/ToolUseBar/BarItem/Content.js +3 -3
- package/dist/ToolUseBar/BarItem/index.js +10 -3
- package/dist/ToolUseBar/index.js +19 -10
- package/dist/ToolUseBar/style.js +4 -4
- package/dist/Types/common.js +4 -1
- package/dist/Types/message.js +4 -1
- package/dist/Utils/debugUtils.js +8 -8
- package/dist/Utils/getScroll.js +12 -5
- package/dist/Utils/loadCSS.js +23 -22
- package/dist/Utils/proxySandbox/ProxySandbox.js +42 -34
- package/dist/Utils/proxySandbox/SecurityContextManager.js +54 -54
- package/dist/Utils/proxySandbox/index.js +25 -22
- package/dist/Utils/proxySandbox/types.js +11 -11
- package/dist/Utils/scrollTo.js +8 -1
- package/dist/WelcomeMessage/index.js +1 -1
- package/dist/Workspace/File/FileComponent.js +91 -66
- package/dist/Workspace/File/PreviewComponent.js +15 -8
- package/dist/Workspace/File/index.d.ts +1 -1
- package/dist/Workspace/File/style.js +7 -0
- package/dist/Workspace/RealtimeFollow/index.js +1 -2
- package/dist/Workspace/index.js +13 -11
- package/dist/Workspace/style.js +8 -14
- package/dist/Workspace/types.d.ts +50 -0
- package/dist/Workspace/types.js +0 -1
- package/package.json +27 -27
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array(iter) {
|
|
10
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
+
}
|
|
12
|
+
function _non_iterable_spread() {
|
|
13
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
+
}
|
|
15
|
+
function _to_consumable_array(arr) {
|
|
16
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
|
+
}
|
|
18
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
|
+
if (!o) return;
|
|
20
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
21
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
|
+
}
|
|
26
|
+
import { Editor, Node, Path, Range, Transforms } from "slate";
|
|
27
|
+
import { clearCardAreaText, hasRange, isCardEmpty } from "./utils";
|
|
28
|
+
/**
|
|
29
|
+
* 处理卡片相关节点的操作
|
|
30
|
+
*
|
|
31
|
+
* @param editor - Slate编辑器实例
|
|
32
|
+
* @param operation - 要处理的操作
|
|
33
|
+
* @param apply - 原始的apply函数
|
|
34
|
+
* @returns 如果操作被处理则返回true,否则返回false
|
|
35
|
+
*
|
|
36
|
+
* @description
|
|
37
|
+
* 处理以下卡片相关操作:
|
|
38
|
+
* - 删除卡片节点 (remove_node),包括card、card-before和card-after
|
|
39
|
+
* - 在卡片后插入文本 (insert_text)
|
|
40
|
+
* - 在卡片内插入节点 (insert_node)
|
|
41
|
+
* - 检查并删除空卡片
|
|
42
|
+
*/ var handleCardOperation = function(editor, operation, apply) {
|
|
43
|
+
if (operation.type === 'remove_node') {
|
|
44
|
+
var node = operation.node;
|
|
45
|
+
// 删除card时,直接删除整个卡片
|
|
46
|
+
if (node.type === 'card') {
|
|
47
|
+
// 直接执行原始操作,避免递归
|
|
48
|
+
apply(operation);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
// 删除card-after时,删除整个卡片
|
|
52
|
+
if (node.type === 'card-after') {
|
|
53
|
+
Transforms.removeNodes(editor, {
|
|
54
|
+
at: Path.parent(operation.path)
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
// 删除card-before时,阻止操作
|
|
59
|
+
if (node.type === 'card-before') {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
// 检查操作后的父级是否为空卡片,如果是则删除
|
|
63
|
+
if (operation.path && operation.path.length > 0) {
|
|
64
|
+
try {
|
|
65
|
+
var parentPath = Path.parent(operation.path);
|
|
66
|
+
var parentNode = Node.get(editor, parentPath);
|
|
67
|
+
if (parentNode && parentNode.type === 'card' && isCardEmpty(parentNode)) {
|
|
68
|
+
Transforms.removeNodes(editor, {
|
|
69
|
+
at: parentPath
|
|
70
|
+
});
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// 如果无法获取父节点,忽略错误
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (operation.type === 'insert_text') {
|
|
79
|
+
try {
|
|
80
|
+
var parentNode1 = Node.get(editor, Path.parent(operation.path));
|
|
81
|
+
// card-before 不允许任何文本输入
|
|
82
|
+
if (parentNode1.type === 'card-before') {
|
|
83
|
+
return true; // 阻止输入
|
|
84
|
+
}
|
|
85
|
+
// card-after 的输入会插入到卡片后面的新段落中
|
|
86
|
+
if (parentNode1.type === 'card-after') {
|
|
87
|
+
try {
|
|
88
|
+
var grandParentPath = Path.parent(Path.parent(operation.path));
|
|
89
|
+
var grandParentNode = Node.get(editor, grandParentPath);
|
|
90
|
+
if (grandParentNode.type === 'card') {
|
|
91
|
+
// 使用 Editor.withoutNormalizing 确保操作的原子性
|
|
92
|
+
Editor.withoutNormalizing(editor, function() {
|
|
93
|
+
// 先创建新段落
|
|
94
|
+
Transforms.insertNodes(editor, {
|
|
95
|
+
type: 'paragraph',
|
|
96
|
+
children: [
|
|
97
|
+
{
|
|
98
|
+
text: operation.text
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}, {
|
|
102
|
+
at: Path.next(grandParentPath)
|
|
103
|
+
});
|
|
104
|
+
// 然后选中新创建的段落
|
|
105
|
+
var newParagraphPath = Path.next(grandParentPath);
|
|
106
|
+
var textPath = _to_consumable_array(newParagraphPath).concat([
|
|
107
|
+
0
|
|
108
|
+
]);
|
|
109
|
+
Transforms.select(editor, {
|
|
110
|
+
anchor: {
|
|
111
|
+
path: textPath,
|
|
112
|
+
offset: operation.text.length
|
|
113
|
+
},
|
|
114
|
+
focus: {
|
|
115
|
+
path: textPath,
|
|
116
|
+
offset: operation.text.length
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
clearCardAreaText(editor, operation.path);
|
|
120
|
+
});
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
// 如果获取父级节点失败,继续阻止输入
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
// 如果无法获取父节点,允许操作继续
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (operation.type === 'insert_node') {
|
|
133
|
+
var parentNode2 = Node.get(editor, Path.parent(operation.path));
|
|
134
|
+
// card-before 不允许任何节点插入
|
|
135
|
+
if (parentNode2.type === 'card-before') {
|
|
136
|
+
return true; // 阻止插入
|
|
137
|
+
}
|
|
138
|
+
// card-after 的节点插入会放到卡片后面
|
|
139
|
+
if (parentNode2.type === 'card-after') {
|
|
140
|
+
if (Node.get(editor, Path.parent(Path.parent(operation.path))).type === 'card') {
|
|
141
|
+
var cardPath = Path.parent(Path.parent(operation.path));
|
|
142
|
+
Transforms.insertNodes(editor, operation.node, {
|
|
143
|
+
at: Path.next(cardPath)
|
|
144
|
+
});
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
Transforms.insertNodes(editor, operation.node, {
|
|
148
|
+
at: Path.parent(operation.path)
|
|
149
|
+
});
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// 对于删除文本操作,我们需要在操作执行后检查卡片是否变空
|
|
154
|
+
// 这将在 editor.apply 的最后处理
|
|
155
|
+
return false;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* 扩展编辑器以处理卡片节点的操作和行为
|
|
159
|
+
*
|
|
160
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
161
|
+
* @returns 增强后的编辑器实例,能够处理卡片相关操作
|
|
162
|
+
*
|
|
163
|
+
* @description
|
|
164
|
+
* 该插件重写编辑器的 `apply`、`insertText`、`insertFragment` 和 `deleteBackward` 方法,
|
|
165
|
+
* 添加对卡片节点的特殊处理逻辑,包括:
|
|
166
|
+
* - 卡片节点的删除、插入和文本操作
|
|
167
|
+
* - 卡片空检查逻辑
|
|
168
|
+
* - 卡片区域的文本和片段插入处理
|
|
169
|
+
*/ export var withCardPlugin = function(editor) {
|
|
170
|
+
var apply = editor.apply, insertText = editor.insertText, insertFragment = editor.insertFragment, deleteBackward = editor.deleteBackward;
|
|
171
|
+
editor.apply = function(operation) {
|
|
172
|
+
// 尝试处理卡片相关操作
|
|
173
|
+
if (handleCardOperation(editor, operation, apply)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
// 记录操作前可能涉及的卡片路径,用于操作后检查
|
|
177
|
+
var cardPathsToCheck = [];
|
|
178
|
+
if (operation.type === 'remove_text' || operation.type === 'insert_text') {
|
|
179
|
+
if (operation.path && operation.path.length > 0) {
|
|
180
|
+
try {
|
|
181
|
+
// 向上查找是否在卡片内
|
|
182
|
+
var currentPath = operation.path;
|
|
183
|
+
while(currentPath.length > 0){
|
|
184
|
+
var node = Node.get(editor, currentPath);
|
|
185
|
+
if (node && node.type === 'card') {
|
|
186
|
+
cardPathsToCheck.push(currentPath);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
currentPath = Path.parent(currentPath);
|
|
190
|
+
}
|
|
191
|
+
} catch (error) {
|
|
192
|
+
// 如果无法获取节点,忽略错误
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// 执行原始操作
|
|
197
|
+
apply(operation);
|
|
198
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
199
|
+
try {
|
|
200
|
+
// 操作执行后,检查涉及的卡片是否变空
|
|
201
|
+
for(var _iterator = cardPathsToCheck[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
202
|
+
var cardPath = _step.value;
|
|
203
|
+
try {
|
|
204
|
+
var cardNode = Node.get(editor, cardPath);
|
|
205
|
+
if (cardNode && cardNode.type === 'card' && isCardEmpty(cardNode)) {
|
|
206
|
+
Transforms.removeNodes(editor, {
|
|
207
|
+
at: cardPath
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
} catch (error) {
|
|
211
|
+
// 如果节点已被删除或不存在,忽略错误
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
_didIteratorError = true;
|
|
216
|
+
_iteratorError = err;
|
|
217
|
+
} finally{
|
|
218
|
+
try {
|
|
219
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
220
|
+
_iterator.return();
|
|
221
|
+
}
|
|
222
|
+
} finally{
|
|
223
|
+
if (_didIteratorError) {
|
|
224
|
+
throw _iteratorError;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
editor.insertText = function(text) {
|
|
230
|
+
var selection = editor.selection;
|
|
231
|
+
if (selection && Range.isCollapsed(selection)) {
|
|
232
|
+
try {
|
|
233
|
+
var node = Node.get(editor, Path.parent(selection.anchor.path));
|
|
234
|
+
// card-before 不允许任何文本输入
|
|
235
|
+
if (node.type === 'card-before') {
|
|
236
|
+
return; // 阻止输入
|
|
237
|
+
}
|
|
238
|
+
// card-after 的输入会插入到卡片后面的新段落中
|
|
239
|
+
if (node.type === 'card-after') {
|
|
240
|
+
var grandParentPath = Path.parent(Path.parent(selection.anchor.path));
|
|
241
|
+
var grandParent = Node.get(editor, grandParentPath);
|
|
242
|
+
if (grandParent.type === 'card') {
|
|
243
|
+
Editor.withoutNormalizing(editor, function() {
|
|
244
|
+
Transforms.insertNodes(editor, {
|
|
245
|
+
type: 'paragraph',
|
|
246
|
+
children: [
|
|
247
|
+
{
|
|
248
|
+
text: text
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}, {
|
|
252
|
+
at: Path.next(grandParentPath)
|
|
253
|
+
});
|
|
254
|
+
// 选中新创建的段落
|
|
255
|
+
var newParagraphPath = Path.next(grandParentPath);
|
|
256
|
+
var textPath = _to_consumable_array(newParagraphPath).concat([
|
|
257
|
+
0
|
|
258
|
+
]);
|
|
259
|
+
Transforms.select(editor, {
|
|
260
|
+
anchor: {
|
|
261
|
+
path: textPath,
|
|
262
|
+
offset: text.length
|
|
263
|
+
},
|
|
264
|
+
focus: {
|
|
265
|
+
path: textPath,
|
|
266
|
+
offset: text.length
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
var cardAfterPath = _to_consumable_array(grandParentPath).concat([
|
|
270
|
+
2,
|
|
271
|
+
0
|
|
272
|
+
]);
|
|
273
|
+
clearCardAreaText(editor, cardAfterPath);
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch (error) {
|
|
279
|
+
// 如果无法获取节点,继续原有逻辑
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
insertText(text);
|
|
283
|
+
};
|
|
284
|
+
editor.insertFragment = function(fragment) {
|
|
285
|
+
var selection = editor.selection;
|
|
286
|
+
if (selection && Range.isCollapsed(selection)) {
|
|
287
|
+
try {
|
|
288
|
+
var node = Node.get(editor, Path.parent(selection.anchor.path));
|
|
289
|
+
// card-before 不允许任何片段插入
|
|
290
|
+
if (node.type === 'card-before') {
|
|
291
|
+
return; // 阻止插入
|
|
292
|
+
}
|
|
293
|
+
// card-after 的片段插入会放到卡片后面
|
|
294
|
+
if (node.type === 'card-after') {
|
|
295
|
+
var grandParentPath = Path.parent(Path.parent(selection.anchor.path));
|
|
296
|
+
var grandParent = Node.get(editor, grandParentPath);
|
|
297
|
+
if (grandParent.type === 'card') {
|
|
298
|
+
// 将片段内容插入到卡片后面
|
|
299
|
+
Transforms.insertNodes(editor, fragment, {
|
|
300
|
+
at: Path.next(grandParentPath),
|
|
301
|
+
select: true
|
|
302
|
+
});
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} catch (error) {
|
|
307
|
+
// 如果无法获取节点,继续原有逻辑
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
insertFragment(fragment);
|
|
311
|
+
};
|
|
312
|
+
editor.deleteBackward = function(unit) {
|
|
313
|
+
var selection = editor.selection;
|
|
314
|
+
if (selection && hasRange(editor, selection) && Range.isCollapsed(selection)) {
|
|
315
|
+
var node = Node.get(editor, Path.parent(selection.anchor.path));
|
|
316
|
+
if (node.type === 'card-before') {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (node.type === 'card-after') {
|
|
320
|
+
Transforms.removeNodes(editor, {
|
|
321
|
+
at: Path.parent(selection.anchor.path)
|
|
322
|
+
});
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
deleteBackward(unit);
|
|
327
|
+
};
|
|
328
|
+
return editor;
|
|
329
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 扩展编辑器以处理代码和标签节点的操作
|
|
4
|
+
*
|
|
5
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
6
|
+
* @returns 增强后的编辑器实例,能够处理代码和标签相关操作
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* 该插件重写编辑器的 `apply` 和 `deleteBackward` 方法,添加对代码和标签节点的特殊处理逻辑。
|
|
10
|
+
*/
|
|
11
|
+
export declare const withCodeTagPlugin: (editor: Editor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
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 _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function _iterable_to_array_limit(arr, i) {
|
|
23
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
+
if (_i == null) return;
|
|
25
|
+
var _arr = [];
|
|
26
|
+
var _n = true;
|
|
27
|
+
var _d = false;
|
|
28
|
+
var _s, _e;
|
|
29
|
+
try {
|
|
30
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
31
|
+
_arr.push(_s.value);
|
|
32
|
+
if (i && _arr.length === i) break;
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_d = true;
|
|
36
|
+
_e = err;
|
|
37
|
+
} finally{
|
|
38
|
+
try {
|
|
39
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
+
} finally{
|
|
41
|
+
if (_d) throw _e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return _arr;
|
|
45
|
+
}
|
|
46
|
+
function _non_iterable_rest() {
|
|
47
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48
|
+
}
|
|
49
|
+
function _object_spread(target) {
|
|
50
|
+
for(var i = 1; i < arguments.length; i++){
|
|
51
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
52
|
+
var ownKeys = Object.keys(source);
|
|
53
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
54
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
ownKeys.forEach(function(key) {
|
|
59
|
+
_define_property(target, key, source[key]);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
function ownKeys(object, enumerableOnly) {
|
|
65
|
+
var keys = Object.keys(object);
|
|
66
|
+
if (Object.getOwnPropertySymbols) {
|
|
67
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
68
|
+
if (enumerableOnly) {
|
|
69
|
+
symbols = symbols.filter(function(sym) {
|
|
70
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
keys.push.apply(keys, symbols);
|
|
74
|
+
}
|
|
75
|
+
return keys;
|
|
76
|
+
}
|
|
77
|
+
function _object_spread_props(target, source) {
|
|
78
|
+
source = source != null ? source : {};
|
|
79
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
80
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
81
|
+
} else {
|
|
82
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
83
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _sliced_to_array(arr, i) {
|
|
89
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
90
|
+
}
|
|
91
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
92
|
+
if (!o) return;
|
|
93
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
94
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
95
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
96
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
97
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
98
|
+
}
|
|
99
|
+
import { Editor, Node, Path, Range, Transforms } from "slate";
|
|
100
|
+
import { hasRange } from "./utils";
|
|
101
|
+
/**
|
|
102
|
+
* 处理代码和标签相关节点的操作
|
|
103
|
+
*
|
|
104
|
+
* @param editor - Slate编辑器实例
|
|
105
|
+
* @param operation - 要处理的操作
|
|
106
|
+
* @param apply - 原始的apply函数
|
|
107
|
+
* @returns 如果操作被处理则返回true,否则返回false
|
|
108
|
+
*
|
|
109
|
+
* @description
|
|
110
|
+
* 处理以下代码和标签相关操作:
|
|
111
|
+
* - 删除文本 (remove_text),处理特殊触发文本和空标签
|
|
112
|
+
* - 删除节点 (remove_node),处理代码块周围的空格
|
|
113
|
+
* - 插入文本 (insert_text),处理代码块中的空格插入
|
|
114
|
+
*/ var handleCodeTagOperation = function(editor, operation, apply) {
|
|
115
|
+
if (operation.type === 'remove_text') {
|
|
116
|
+
var currentNode = Node.get(editor, operation.path);
|
|
117
|
+
if (currentNode === null || currentNode === void 0 ? void 0 : currentNode.tag) {
|
|
118
|
+
var _currentNode_text;
|
|
119
|
+
// 处理空标签的删除
|
|
120
|
+
if (((_currentNode_text = currentNode.text) === null || _currentNode_text === void 0 ? void 0 : _currentNode_text.trim()) === '') {
|
|
121
|
+
Editor.withoutNormalizing(editor, function() {
|
|
122
|
+
Transforms.setNodes(editor, {
|
|
123
|
+
tag: false,
|
|
124
|
+
code: false,
|
|
125
|
+
text: ' ',
|
|
126
|
+
triggerText: undefined
|
|
127
|
+
}, {
|
|
128
|
+
at: operation.path
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (currentNode.text === operation.text) {
|
|
134
|
+
Editor.withoutNormalizing(editor, function() {
|
|
135
|
+
Transforms.removeNodes(editor, {
|
|
136
|
+
at: operation.path
|
|
137
|
+
});
|
|
138
|
+
Transforms.insertNodes(editor, _object_spread_props(_object_spread({}, currentNode), {
|
|
139
|
+
tag: true,
|
|
140
|
+
code: true,
|
|
141
|
+
text: ' '
|
|
142
|
+
}), {
|
|
143
|
+
at: operation.path,
|
|
144
|
+
select: true
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
// 光标在 tag 内部,执行原始的删除操作
|
|
150
|
+
apply(operation);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (operation.type === 'insert_text') {
|
|
155
|
+
var _editor_selection;
|
|
156
|
+
var currentNode1 = Node.get(editor, operation.path);
|
|
157
|
+
if ((currentNode1 === null || currentNode1 === void 0 ? void 0 : currentNode1.tag) && operation.text === ' ' && ((_editor_selection = editor.selection) === null || _editor_selection === void 0 ? void 0 : _editor_selection.focus.offset) === currentNode1.text.length) {
|
|
158
|
+
// 检查前一个字符是否是空格
|
|
159
|
+
var lastChar = currentNode1.text.charAt(currentNode1.text.length - 1);
|
|
160
|
+
if (lastChar === ' ') {
|
|
161
|
+
// 如果前一个输入是空格,且当前输入也是空格,则插入一个空格到 tag 节点外
|
|
162
|
+
Transforms.insertNodes(editor, [
|
|
163
|
+
{
|
|
164
|
+
text: ' '
|
|
165
|
+
}
|
|
166
|
+
]);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if ((currentNode1 === null || currentNode1 === void 0 ? void 0 : currentNode1.tag) && operation.text.trim().length > 0 && currentNode1.text.trim().length === 0) {
|
|
171
|
+
Editor.withoutNormalizing(editor, function() {
|
|
172
|
+
Transforms.removeNodes(editor, {
|
|
173
|
+
at: operation.path
|
|
174
|
+
});
|
|
175
|
+
Transforms.insertNodes(editor, _object_spread_props(_object_spread({}, currentNode1), {
|
|
176
|
+
tag: true,
|
|
177
|
+
code: true,
|
|
178
|
+
text: operation.text
|
|
179
|
+
}), {
|
|
180
|
+
at: operation.path,
|
|
181
|
+
select: true
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (operation.type === 'split_node') {
|
|
188
|
+
var node = Node.get(editor, operation.path);
|
|
189
|
+
if ((node === null || node === void 0 ? void 0 : node.tag) || (node === null || node === void 0 ? void 0 : node.code)) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* 扩展编辑器以处理代码和标签节点的操作
|
|
197
|
+
*
|
|
198
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
199
|
+
* @returns 增强后的编辑器实例,能够处理代码和标签相关操作
|
|
200
|
+
*
|
|
201
|
+
* @description
|
|
202
|
+
* 该插件重写编辑器的 `apply` 和 `deleteBackward` 方法,添加对代码和标签节点的特殊处理逻辑。
|
|
203
|
+
*/ export var withCodeTagPlugin = function(editor) {
|
|
204
|
+
var apply = editor.apply, deleteBackward = editor.deleteBackward;
|
|
205
|
+
editor.apply = function(operation) {
|
|
206
|
+
// 尝试处理代码和标签相关操作
|
|
207
|
+
if (handleCodeTagOperation(editor, operation, apply)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// 否则执行原始操作
|
|
211
|
+
apply(operation);
|
|
212
|
+
};
|
|
213
|
+
editor.deleteBackward = function(unit) {
|
|
214
|
+
var selection = editor.selection;
|
|
215
|
+
if (selection && hasRange(editor, selection) && Range.isCollapsed(selection)) {
|
|
216
|
+
var curNode = Node.get(editor, selection.anchor.path);
|
|
217
|
+
// 检查前一个节点是否是 tag
|
|
218
|
+
try {
|
|
219
|
+
var _ref = _sliced_to_array(Editor.previous(editor, {
|
|
220
|
+
at: selection.anchor.path
|
|
221
|
+
}) || [], 2), previousNode = _ref[0], previousPath = _ref[1];
|
|
222
|
+
var isBeforeTag = selection && selection.anchor.offset <= 1;
|
|
223
|
+
if ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.tag) && previousPath && isBeforeTag) {
|
|
224
|
+
var _curNode_text, _curNode_text1;
|
|
225
|
+
// 如果当前节点不为空,且只有一个文本
|
|
226
|
+
if (((_curNode_text = curNode.text) === null || _curNode_text === void 0 ? void 0 : _curNode_text.trim()) && curNode.text.trimEnd().length === 1 && selection.anchor.offset > 0) {
|
|
227
|
+
Transforms.insertText(editor, '', {
|
|
228
|
+
at: selection.anchor.path
|
|
229
|
+
});
|
|
230
|
+
Transforms.insertNodes(editor, {
|
|
231
|
+
type: 'paragraph',
|
|
232
|
+
children: [
|
|
233
|
+
{
|
|
234
|
+
text: ' '
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}, {
|
|
238
|
+
at: selection.anchor.path,
|
|
239
|
+
select: true
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
} else if (((_curNode_text1 = curNode.text) === null || _curNode_text1 === void 0 ? void 0 : _curNode_text1.trim()) && selection.anchor.offset > 0) {
|
|
243
|
+
deleteBackward(unit);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// 如果前一个节点是 tag,直接删除整个 tag
|
|
247
|
+
Editor.withoutNormalizing(editor, function() {
|
|
248
|
+
var parent = Node.get(editor, Path.parent(previousPath));
|
|
249
|
+
var index = previousPath[previousPath.length - 1];
|
|
250
|
+
if (parent.children.length === 1) {
|
|
251
|
+
// 如果是唯一的节点,转换为普通文本
|
|
252
|
+
Transforms.setNodes(editor, {
|
|
253
|
+
tag: false,
|
|
254
|
+
code: false,
|
|
255
|
+
text: ' ',
|
|
256
|
+
triggerText: undefined
|
|
257
|
+
}, {
|
|
258
|
+
at: previousPath
|
|
259
|
+
});
|
|
260
|
+
} else if (index === 0) {
|
|
261
|
+
// 如果是第一个节点,删除并合并下一个节点
|
|
262
|
+
Transforms.removeNodes(editor, {
|
|
263
|
+
at: previousPath
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
// 如果是中间或最后节点,先合并再删除
|
|
267
|
+
Transforms.removeNodes(editor, {
|
|
268
|
+
at: previousPath
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
} catch (error) {
|
|
275
|
+
// 如果获取前一个节点失败,继续执行原始删除操作
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
var _node_text_trim, _node_text, _selection_anchor;
|
|
279
|
+
var node = Node.get(editor, selection.anchor.path);
|
|
280
|
+
if ((node === null || node === void 0 ? void 0 : node.tag) && (node === null || node === void 0 ? void 0 : (_node_text = node.text) === null || _node_text === void 0 ? void 0 : (_node_text_trim = _node_text.trim()) === null || _node_text_trim === void 0 ? void 0 : _node_text_trim.length) < 1 && (selection === null || selection === void 0 ? void 0 : (_selection_anchor = selection.anchor) === null || _selection_anchor === void 0 ? void 0 : _selection_anchor.offset) < 1) {
|
|
281
|
+
var _node_text1;
|
|
282
|
+
var text = node === null || node === void 0 ? void 0 : (_node_text1 = node.text) === null || _node_text1 === void 0 ? void 0 : _node_text1.replace(node.triggerText || '', '');
|
|
283
|
+
Transforms.setNodes(editor, {
|
|
284
|
+
tag: false,
|
|
285
|
+
code: false
|
|
286
|
+
}, {
|
|
287
|
+
at: selection.anchor.path
|
|
288
|
+
});
|
|
289
|
+
Transforms.insertText(editor, text, {
|
|
290
|
+
at: selection.anchor.path
|
|
291
|
+
});
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
} catch (unused) {}
|
|
295
|
+
}
|
|
296
|
+
deleteBackward(unit);
|
|
297
|
+
};
|
|
298
|
+
return editor;
|
|
299
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 扩展编辑器以识别行内节点类型
|
|
4
|
+
*
|
|
5
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
6
|
+
* @returns 增强后的编辑器实例,能够识别行内节点
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* 该插件扩展编辑器的 `isInline` 方法,使其能够识别特定的行内元素类型。
|
|
10
|
+
* 行内节点包括:'break'、'inline-katex'
|
|
11
|
+
*/
|
|
12
|
+
export declare const withInlineNodes: (editor: Editor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inlineNode } from "./utils";
|
|
2
|
+
/**
|
|
3
|
+
* 扩展编辑器以识别行内节点类型
|
|
4
|
+
*
|
|
5
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
6
|
+
* @returns 增强后的编辑器实例,能够识别行内节点
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* 该插件扩展编辑器的 `isInline` 方法,使其能够识别特定的行内元素类型。
|
|
10
|
+
* 行内节点包括:'break'、'inline-katex'
|
|
11
|
+
*/ export var withInlineNodes = function(editor) {
|
|
12
|
+
var isInline = editor.isInline;
|
|
13
|
+
editor.isInline = function(element) {
|
|
14
|
+
return inlineNode.has(element.type) || isInline(element);
|
|
15
|
+
};
|
|
16
|
+
return editor;
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 扩展编辑器以处理链接卡片和媒体节点的操作
|
|
4
|
+
*
|
|
5
|
+
* @param editor - 要扩展的Slate编辑器实例
|
|
6
|
+
* @returns 增强后的编辑器实例,能够处理链接和媒体相关操作
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* 该插件重写编辑器的 `apply` 方法,添加对链接卡片和媒体节点的特殊处理逻辑。
|
|
10
|
+
*/
|
|
11
|
+
export declare const withLinkAndMediaPlugin: (editor: Editor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor;
|