@agentscope-ai/chat 1.1.20 → 1.1.22
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/bin/client.js +1 -1
- package/components/AGUI/components/HelpModal/icons.tsx +68 -0
- package/components/AGUI/components/HelpModal/index.tsx +1 -0
- package/components/AGUI/components/HelpModal/modal.tsx +101 -0
- package/components/AGUI/components/chat/Button.tsx +18 -0
- package/components/AGUI/components/chat/Chat.tsx +780 -0
- package/components/AGUI/components/chat/ChatContext.tsx +248 -0
- package/components/AGUI/components/chat/CodeBlock.tsx +406 -0
- package/components/AGUI/components/chat/Header.tsx +22 -0
- package/components/AGUI/components/chat/Icons.tsx +237 -0
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +77 -0
- package/components/AGUI/components/chat/Input.tsx +24 -0
- package/components/AGUI/components/chat/Markdown.tsx +134 -0
- package/components/AGUI/components/chat/Messages.tsx +259 -0
- package/components/AGUI/components/chat/Modal.tsx +133 -0
- package/components/AGUI/components/chat/Popup.tsx +57 -0
- package/components/AGUI/components/chat/PoweredByTag.tsx +29 -0
- package/components/AGUI/components/chat/Sidebar.tsx +74 -0
- package/components/AGUI/components/chat/Suggestion.tsx +132 -0
- package/components/AGUI/components/chat/Suggestions.tsx +20 -0
- package/components/AGUI/components/chat/Textarea.tsx +61 -0
- package/components/AGUI/components/chat/Window.tsx +152 -0
- package/components/AGUI/components/chat/index.tsx +11 -0
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +69 -0
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +129 -0
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +116 -0
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +26 -0
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +51 -0
- package/components/AGUI/components/chat/messages/UserMessage.tsx +10 -0
- package/components/AGUI/components/chat/props.ts +186 -0
- package/components/AGUI/components/index.ts +1 -0
- package/components/AGUI/context/index.ts +1 -0
- package/components/AGUI/hooks/index.ts +1 -0
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +122 -0
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +29 -0
- package/components/AGUI/hooks/use-dark-mode.ts +10 -0
- package/components/AGUI/hooks/use-push-to-talk.tsx +166 -0
- package/components/AGUI/index.tsx +4 -0
- package/components/AGUI/lib/utils.test.ts +7 -0
- package/components/AGUI/lib/utils.ts +27 -0
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +1 -0
- package/components/AGUI/types/suggestions.ts +6 -0
- package/components/Accordion/Accordion.tsx +203 -0
- package/components/Accordion/BodyContent.tsx +28 -0
- package/components/Accordion/DeepThinking.tsx +91 -0
- package/components/Accordion/SoftLightTitle.tsx +13 -0
- package/components/Accordion/demo/search.tsx +39 -0
- package/components/Accordion/demo/steps.tsx +135 -0
- package/components/Accordion/demo/thinking.tsx +62 -0
- package/components/Accordion/index.en-US.md +34 -0
- package/components/Accordion/index.tsx +3 -0
- package/components/Accordion/index.zh-CN.md +34 -0
- package/components/Accordion/style.ts +208 -0
- package/components/AgentScopeRuntimeWebUI/demo/index.tsx +4 -0
- package/components/AgentScopeRuntimeWebUI/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.tsx +39 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.tsx +205 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.tsx +44 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.tsx +7 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.tsx +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.tsx +16 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.tsx +19 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.tsx +100 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/index.tsx +77 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.tsx +53 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.tsx +66 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.tsx +5 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.tsx +130 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.tsx +87 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.tsx +50 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/index.tsx +18 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/styles.tsx +59 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.tsx +76 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.tsx +111 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/styles.ts +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/styles.tsx +104 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/index.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/styles.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/sessionApi/index.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.ts +358 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IMessages.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/ISessions.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/starter/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/starter/sessionApi/index.ts +51 -0
- package/components/Attachments/DropArea.tsx +97 -0
- package/components/Attachments/FileList/AudioIcon.tsx +20 -0
- package/components/Attachments/FileList/FileListCard.tsx +270 -0
- package/components/Attachments/FileList/Progress.tsx +30 -0
- package/components/Attachments/FileList/VideoIcon.tsx +20 -0
- package/components/Attachments/FileList/index.tsx +201 -0
- package/components/Attachments/PlaceholderUploader.tsx +124 -0
- package/components/Attachments/SilentUploader.tsx +39 -0
- package/components/Attachments/context.tsx +11 -0
- package/components/Attachments/demo/basic.tsx +71 -0
- package/components/Attachments/index.en-US.md.bk +10 -0
- package/components/Attachments/index.tsx +274 -0
- package/components/Attachments/index.zh-CN.md.bk +10 -0
- package/components/Attachments/style/fileCard.ts +163 -0
- package/components/Attachments/style/index.ts +232 -0
- package/components/Attachments/util.ts +56 -0
- package/components/Bubble/Avatar.tsx +39 -0
- package/components/Bubble/Bubble.tsx +131 -0
- package/components/Bubble/BubbleList.tsx +105 -0
- package/components/Bubble/Cards.tsx +61 -0
- package/components/Bubble/Footer.tsx +55 -0
- package/components/Bubble/Interrupted.tsx +82 -0
- package/components/Bubble/ScrollToBottom.tsx +42 -0
- package/components/Bubble/Spin.tsx +13 -0
- package/components/Bubble/demo/assistantWithCode.tsx +60 -0
- package/components/Bubble/demo/assistantWithErrorStatus.tsx +102 -0
- package/components/Bubble/demo/assistantWithImage.tsx +46 -0
- package/components/Bubble/demo/assistantWithProcess.tsx +103 -0
- package/components/Bubble/demo/assistantWithSearch.tsx +69 -0
- package/components/Bubble/demo/assistantWithThinking.tsx +54 -0
- package/components/Bubble/demo/basic.tsx +55 -0
- package/components/Bubble/demo/userWithFile.tsx +27 -0
- package/components/Bubble/demo/userWithImage.tsx +26 -0
- package/components/Bubble/hooks/useDisplayData.ts +0 -0
- package/components/Bubble/hooks/useListData.ts +0 -0
- package/components/Bubble/index.en-US.md +33 -0
- package/components/Bubble/index.tsx +21 -0
- package/components/Bubble/index.zh-CN.md +33 -0
- package/components/Bubble/interface.ts +71 -0
- package/components/Bubble/loading.tsx +15 -0
- package/components/Bubble/style/avatar.ts +43 -0
- package/components/Bubble/style/footer.ts +45 -0
- package/components/Bubble/style/index.ts +192 -0
- package/components/Bubble/style/list.ts +51 -0
- package/components/ChatAnywhere/Chat/Ref.tsx +20 -0
- package/components/ChatAnywhere/Chat/index.tsx +56 -0
- package/components/ChatAnywhere/Chat/style.ts +59 -0
- package/components/ChatAnywhere/Header/index.tsx +37 -0
- package/components/ChatAnywhere/Header/style.ts +27 -0
- package/components/ChatAnywhere/Input/index.tsx +158 -0
- package/components/ChatAnywhere/Input/style.ts +14 -0
- package/components/ChatAnywhere/Layout/index.tsx +70 -0
- package/components/ChatAnywhere/Layout/style.ts +51 -0
- package/components/ChatAnywhere/SessionList/index.tsx +122 -0
- package/components/ChatAnywhere/SessionList/style.ts +53 -0
- package/components/ChatAnywhere/hooks/ChatAnywhereProvider.tsx +219 -0
- package/components/ChatAnywhere/hooks/types.ts +333 -0
- package/components/ChatAnywhere/hooks/useInput.tsx +22 -0
- package/components/ChatAnywhere/hooks/useMessages.tsx +63 -0
- package/components/ChatAnywhere/hooks/useSessionList.tsx +123 -0
- package/components/ChatAnywhere/index.tsx +49 -0
- package/components/Conversations/GroupTitle.tsx +28 -0
- package/components/Conversations/Item.tsx +189 -0
- package/components/Conversations/demo/basic.tsx +107 -0
- package/components/Conversations/demo/timeline.tsx +111 -0
- package/components/Conversations/demo/timestamp.tsx +110 -0
- package/components/Conversations/hooks/useGroupable.ts +81 -0
- package/components/Conversations/index.en-US.md +32 -0
- package/components/Conversations/index.tsx +176 -0
- package/components/Conversations/index.zh-CN.md +31 -0
- package/components/Conversations/interface.ts +69 -0
- package/components/Conversations/style.ts +153 -0
- package/components/DefaultCards/DeepThinking/index.tsx +33 -0
- package/components/DefaultCards/Files/index.tsx +69 -0
- package/components/DefaultCards/Footer/index.tsx +16 -0
- package/components/DefaultCards/Images/index.tsx +53 -0
- package/components/DefaultCards/Interrupted/index.tsx +13 -0
- package/components/DefaultCards/Text/index.tsx +13 -0
- package/components/DefaultCards/index.tsx +6 -0
- package/components/DeviceAction/actionMap.tsx +100 -0
- package/components/DeviceAction/demo/index.tsx +132 -0
- package/components/DeviceAction/index.en-US.md +19 -0
- package/components/DeviceAction/index.tsx +75 -0
- package/components/DeviceAction/index.zh-CN.md +19 -0
- package/components/Disclaimer/demo/index.tsx +4 -0
- package/components/Disclaimer/demo/withLink.tsx +4 -0
- package/components/Disclaimer/index.en-US.md +23 -0
- package/components/Disclaimer/index.tsx +42 -0
- package/components/Disclaimer/index.zh-CN.md +24 -0
- package/components/Disclaimer/style.ts +17 -0
- package/components/ImageGenerator/demo/basic.tsx +23 -0
- package/components/ImageGenerator/demo/custom.tsx +56 -0
- package/components/ImageGenerator/demo/size.tsx +15 -0
- package/components/ImageGenerator/index.en-US.md +23 -0
- package/components/ImageGenerator/index.tsx +124 -0
- package/components/ImageGenerator/index.zh-CN.md +23 -0
- package/components/ImageGenerator/style.ts +99 -0
- package/components/Markdown/Markdown/AnimationNode.tsx +89 -0
- package/components/Markdown/Markdown/Markdown.tsx +61 -0
- package/components/Markdown/Markdown/core/Parser.ts +52 -0
- package/components/Markdown/Markdown/core/Renderer.ts +121 -0
- package/components/Markdown/Markdown/core/index.ts +4 -0
- package/components/Markdown/Markdown/defaultComponents/CodeBlock.tsx +113 -0
- package/components/Markdown/Markdown/defaultComponents/DisabledImage.tsx +3 -0
- package/components/Markdown/Markdown/defaultComponents/Media.tsx +71 -0
- package/components/Markdown/Markdown/hooks/index.ts +4 -0
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +27 -0
- package/components/Markdown/Markdown/hooks/useCitationsData.tsx +36 -0
- package/components/Markdown/Markdown/hooks/useStreaming.ts +503 -0
- package/components/Markdown/Markdown/hooks/useTyping.ts +22 -0
- package/components/Markdown/Markdown/index.tsx +198 -0
- package/components/Markdown/Markdown/interface.ts +217 -0
- package/components/Markdown/Markdown/style.ts +152 -0
- package/components/Markdown/demo/basic.tsx +107 -0
- package/components/Markdown/demo/citations.tsx +47 -0
- package/components/Markdown/demo/cursor.tsx +9 -0
- package/components/Markdown/demo/latex.tsx +77 -0
- package/components/Markdown/demo/typing.tsx +82 -0
- package/components/Markdown/index.en-US.md +27 -0
- package/components/Markdown/index.ts +1 -0
- package/components/Markdown/index.zh-CN.md +28 -0
- package/components/Markdown/plugins/citations/CitationComponent.tsx +72 -0
- package/components/Markdown/plugins/citations/index.tsx +37 -0
- package/components/Markdown/plugins/cursor/Dot.tsx +106 -0
- package/components/Markdown/plugins/cursor/Underline.tsx +38 -0
- package/components/Markdown/plugins/cursor/index.tsx +59 -0
- package/components/Markdown/plugins/latex/index.ts +109 -0
- package/components/Markdown/plugins/type.ts +71 -0
- package/components/Mermaid/demo/basic.tsx +12 -0
- package/components/Mermaid/demo/class.tsx +31 -0
- package/components/Mermaid/demo/flowchart.tsx +13 -0
- package/components/Mermaid/demo/sequence.tsx +18 -0
- package/components/Mermaid/demo/state.tsx +16 -0
- package/components/Mermaid/demo/timeline.tsx +15 -0
- package/components/Mermaid/index.en-US.md +27 -0
- package/components/Mermaid/index.tsx +118 -0
- package/components/Mermaid/index.zh-CN.md +27 -0
- package/components/OperateCard/OperateCard.tsx +93 -0
- package/components/OperateCard/demo/index.tsx +35 -0
- package/components/OperateCard/demo/rag.tsx +19 -0
- package/components/OperateCard/demo/thinking.tsx +17 -0
- package/components/OperateCard/demo/todo.tsx +28 -0
- package/components/OperateCard/demo/toolCall.tsx +14 -0
- package/components/OperateCard/demo/webSearch.tsx +12 -0
- package/components/OperateCard/index.en-US.md +51 -0
- package/components/OperateCard/index.tsx +1 -0
- package/components/OperateCard/index.zh-CN.md +51 -0
- package/components/OperateCard/preset/Rag.tsx +90 -0
- package/components/OperateCard/preset/Thinking.tsx +45 -0
- package/components/OperateCard/preset/TodoList.tsx +73 -0
- package/components/OperateCard/preset/ToolCall.tsx +67 -0
- package/components/OperateCard/preset/WebSearch.tsx +65 -0
- package/components/OperateCard/preset/index.tsx +5 -0
- package/components/OperateCard/style.ts +268 -0
- package/components/Provider/CustomCardsProvider.tsx +17 -0
- package/components/Provider/GlobalProvider.tsx +17 -0
- package/components/Provider/index.tsx +33 -0
- package/components/Provider/types.ts +23 -0
- package/components/ResponsesAPI/index.tsx +0 -0
- package/components/Sender/ModeSelect/index.tsx +160 -0
- package/components/Sender/ModeSelect/styles.ts +0 -0
- package/components/Sender/SenderHeader.tsx +164 -0
- package/components/Sender/StopLoading.tsx +48 -0
- package/components/Sender/components/ActionButton.tsx +106 -0
- package/components/Sender/components/ClearButton.tsx +10 -0
- package/components/Sender/components/LoadingButton.tsx +26 -0
- package/components/Sender/components/SendButton.tsx +22 -0
- package/components/Sender/components/SpeechButton/RecordingIcon.tsx +68 -0
- package/components/Sender/components/SpeechButton/index.tsx +30 -0
- package/components/Sender/demo/asr.tsx +7 -0
- package/components/Sender/demo/basic.tsx +7 -0
- package/components/Sender/demo/loading.tsx +5 -0
- package/components/Sender/demo/moreMode.tsx +45 -0
- package/components/Sender/demo/morePrefixAction.tsx +40 -0
- package/components/Sender/demo/withFile.tsx +54 -0
- package/components/Sender/demo/withImage.tsx +52 -0
- package/components/Sender/index.en-US.md +29 -0
- package/components/Sender/index.tsx +491 -0
- package/components/Sender/index.zh-CN.md +30 -0
- package/components/Sender/style/index.ts +150 -0
- package/components/Sender/useSpeech.ts +133 -0
- package/components/StatusCard/demo/index.tsx +32 -0
- package/components/StatusCard/index.en-US.md +30 -0
- package/components/StatusCard/index.tsx +162 -0
- package/components/StatusCard/index.zh-CN.md +27 -0
- package/components/StatusCard/style.ts +119 -0
- package/components/Stream/index.ts +203 -0
- package/components/Util/hooks/use-proxy-imperative-handle.ts +25 -0
- package/components/Util/sleep.ts +3 -0
- package/components/Util/type.ts +1 -0
- package/components/Util/warning.ts +118 -0
- package/components/Version/index.ts +3 -0
- package/components/Voice/Recorder.tsx +3 -0
- package/components/Voice/demo/index.tsx +0 -0
- package/components/Voice/index.en-US.md +8 -0
- package/components/Voice/index.tsx +0 -0
- package/components/Voice/index.zh-CN.md +9 -0
- package/components/Welcome/demo/EyeFollower.tsx +161 -0
- package/components/Welcome/demo/demo0.tsx +14 -0
- package/components/Welcome/demo/demo1.tsx +16 -0
- package/components/Welcome/demo/demo2.tsx +30 -0
- package/components/Welcome/demo/demo3.tsx +16 -0
- package/components/Welcome/index.en-US.md +28 -0
- package/components/Welcome/index.tsx +72 -0
- package/components/Welcome/index.zh-CN.md +28 -0
- package/components/index.ts +88 -0
- package/components/overview.en-US.md +10 -0
- package/components/overview.zh-CN.md +10 -0
- package/lib/AgentScopeRuntimeWebUI/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/index.js +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.d.ts +9 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.js +33 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.d.ts +7 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.js +188 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.d.ts +29 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.js +35 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.d.ts +6 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.js +49 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.js +70 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.d.ts +14 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.js +143 -0
- package/package.json +3 -2
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import Markdown from './Markdown';
|
|
2
|
+
import CodeBlock from './defaultComponents/CodeBlock';
|
|
3
|
+
import Media from './defaultComponents/Media';
|
|
4
|
+
import DisabledImage from './defaultComponents/DisabledImage';
|
|
5
|
+
import { useGlobalContext, useProviderContext } from '@agentscope-ai/chat';
|
|
6
|
+
import { useTyping } from './hooks/useTyping';
|
|
7
|
+
import type { MarkdownProps as InnerMarkdownProps } from './interface';
|
|
8
|
+
import { cursorExtension, CursorComponent } from '../plugins/cursor';
|
|
9
|
+
import { citationsExtension } from '../plugins/citations';
|
|
10
|
+
import latex from '../plugins/latex';
|
|
11
|
+
import useCitationsData from './hooks/useCitationsData';
|
|
12
|
+
import classnames from 'classnames';
|
|
13
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
14
|
+
import { memo, useMemo } from 'react';
|
|
15
|
+
|
|
16
|
+
export interface MarkdownProps {
|
|
17
|
+
/**
|
|
18
|
+
* @description 需要渲染的 Markdown 内容
|
|
19
|
+
* @descriptionEn Markdown content to be rendered
|
|
20
|
+
*/
|
|
21
|
+
content?: InnerMarkdownProps['content'];
|
|
22
|
+
/**
|
|
23
|
+
* @description 光标样式类型,支持点状、下划线或布尔值控制
|
|
24
|
+
* @descriptionEn Cursor style type, supports dot, underline, or boolean control
|
|
25
|
+
*/
|
|
26
|
+
cursor?: boolean | 'dot' | 'underline';
|
|
27
|
+
/**
|
|
28
|
+
* @description 基础字体大小,影响整个Markdown内容的字体大小
|
|
29
|
+
* @descriptionEn Base font size that affects the font size of the entire Markdown content
|
|
30
|
+
*/
|
|
31
|
+
baseFontSize?: InnerMarkdownProps['baseFontSize'];
|
|
32
|
+
/**
|
|
33
|
+
* @description 基础行高,影响文本的行间距
|
|
34
|
+
* @descriptionEn Base line height that affects text line spacing
|
|
35
|
+
*/
|
|
36
|
+
baseLineHeight?: InnerMarkdownProps['baseLineHeight'];
|
|
37
|
+
/**
|
|
38
|
+
* @description 引用数据数组,用于显示引用信息
|
|
39
|
+
* @descriptionEn Citation data array for displaying reference information
|
|
40
|
+
*/
|
|
41
|
+
citations?: InnerMarkdownProps['citations'];
|
|
42
|
+
/**
|
|
43
|
+
* @description 引用映射对象,用于快速查找引用信息
|
|
44
|
+
* @descriptionEn Citation mapping object for quick lookup of reference information
|
|
45
|
+
*/
|
|
46
|
+
citationsMap?: InnerMarkdownProps['citationsMap'];
|
|
47
|
+
/**
|
|
48
|
+
* @description 用于替换 HTML 元素的自定义 React 组件映射,组件会接收 domNode、streamStatus 等属性
|
|
49
|
+
* @descriptionEn Custom React components to replace HTML elements, components receive domNode, streamStatus, etc.
|
|
50
|
+
*/
|
|
51
|
+
components?: InnerMarkdownProps['components'];
|
|
52
|
+
/**
|
|
53
|
+
* @description 是否允许渲染HTML标签,影响安全性
|
|
54
|
+
* @descriptionEn Whether to allow rendering HTML tags, affects security
|
|
55
|
+
*/
|
|
56
|
+
allowHtml?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description 是否禁用图片渲染
|
|
59
|
+
* @descriptionEn Whether to disable image rendering
|
|
60
|
+
*/
|
|
61
|
+
disableImage?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* @description 是否启用打字机效果,逐字显示内容
|
|
64
|
+
* @descriptionEn Whether to enable typewriter effect for character-by-character display
|
|
65
|
+
*/
|
|
66
|
+
typing?: boolean | number;
|
|
67
|
+
/**
|
|
68
|
+
* @description 是否以原始文本形式显示,跳过Markdown解析
|
|
69
|
+
* @descriptionEn Whether to display as raw text, skipping Markdown parsing
|
|
70
|
+
*/
|
|
71
|
+
raw?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* @description 组件的CSS类名
|
|
74
|
+
* @descriptionEn CSS class name for the component
|
|
75
|
+
*/
|
|
76
|
+
className?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @description 启用英文单词缓存,单词会在遇到空格或标点后才整体显示(仅在 typing 为 true 时生效)
|
|
79
|
+
* @descriptionEn Enable English word caching, words will be displayed as a whole after encountering spaces or punctuation (only works when typing is true)
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
enableWordCaching?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* @description 启用 LaTeX 公式缓存,公式会在完整后才整体显示(仅在 typing 为 true 时生效)
|
|
85
|
+
* @descriptionEn Enable LaTeX formula caching, formulas will be displayed as a whole when complete (only works when typing is true)
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
enableMathCaching?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* @description 启用文字出现动画效果
|
|
91
|
+
* @descriptionEn Enable text appearance animation effects
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
enableAnimation?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const Null = () => null;
|
|
98
|
+
|
|
99
|
+
// 缓存不变的 dompurify 配置
|
|
100
|
+
const EMPTY_DOMPURIFY_CONFIG = {
|
|
101
|
+
ALLOWED_TAGS: [],
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 检测浏览器是否支持正则表达式的 lookbehind assertions
|
|
107
|
+
* iOS Safari < 16.4 不支持此特性
|
|
108
|
+
*/
|
|
109
|
+
function supportsLookbehindAssertions(): boolean {
|
|
110
|
+
try {
|
|
111
|
+
// 尝试创建包含正向后行断言的正则表达式
|
|
112
|
+
new RegExp('(?<=a)b');
|
|
113
|
+
return true;
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const isSupportsLookbehindAssertions = supportsLookbehindAssertions();
|
|
120
|
+
|
|
121
|
+
console.log({ isSupportsLookbehindAssertions });
|
|
122
|
+
|
|
123
|
+
export default memo(function (props: MarkdownProps) {
|
|
124
|
+
const baseFontSize = props.baseFontSize || 14;
|
|
125
|
+
const baseLineHeight = props.baseLineHeight || 1.7;
|
|
126
|
+
const { getPrefixCls, } = useProviderContext();
|
|
127
|
+
const prefixCls = getPrefixCls('markdown');
|
|
128
|
+
const {
|
|
129
|
+
className,
|
|
130
|
+
allowHtml = true,
|
|
131
|
+
content: _content = '',
|
|
132
|
+
typing = false,
|
|
133
|
+
cursor = false,
|
|
134
|
+
enableWordCaching = false,
|
|
135
|
+
enableMathCaching = true,
|
|
136
|
+
enableAnimation = false,
|
|
137
|
+
...restProps
|
|
138
|
+
} = props;
|
|
139
|
+
const content = useTyping({ content: _content, typing });
|
|
140
|
+
const { citationsData, citationsDataCount, CitationComponent } = useCitationsData({ citations: props.citations, citationsMap: props.citationsMap });
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if (props.raw || !isSupportsLookbehindAssertions) return <div className={prefixCls} style={{ fontSize: baseFontSize, lineHeight: baseLineHeight }}>{content}</div>;
|
|
144
|
+
|
|
145
|
+
// 使用 useMemo 缓存 extensions 配置
|
|
146
|
+
const extensions = useMemo(() => {
|
|
147
|
+
const exts = [
|
|
148
|
+
cursorExtension(),
|
|
149
|
+
...latex()
|
|
150
|
+
];
|
|
151
|
+
if (citationsDataCount > 0) exts.push(citationsExtension(citationsData));
|
|
152
|
+
return exts;
|
|
153
|
+
}, [citationsDataCount, citationsData]);
|
|
154
|
+
|
|
155
|
+
// 使用 useMemo 缓存 config 对象
|
|
156
|
+
const config = useMemo(() => ({
|
|
157
|
+
extensions,
|
|
158
|
+
}), [extensions]);
|
|
159
|
+
|
|
160
|
+
// 使用 useMemo 缓存 streaming 配置
|
|
161
|
+
const streaming = useMemo(() => ({
|
|
162
|
+
hasNextChunk: Boolean(typing),
|
|
163
|
+
enableWordCaching,
|
|
164
|
+
enableMathCaching,
|
|
165
|
+
enableAnimation
|
|
166
|
+
}), [typing, enableWordCaching, enableMathCaching, enableAnimation]);
|
|
167
|
+
|
|
168
|
+
// 使用 useMemo 缓存 components 对象
|
|
169
|
+
const components = useMemo(() => ({
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
pre: CodeBlock,
|
|
172
|
+
style: Null,
|
|
173
|
+
script: Null,
|
|
174
|
+
img: props.disableImage ? DisabledImage : Media,
|
|
175
|
+
cursor: CursorComponent,
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
citation: CitationComponent,
|
|
178
|
+
}), [props.disableImage, CitationComponent]);
|
|
179
|
+
|
|
180
|
+
// 使用 useMemo 缓存 dompurifyConfig
|
|
181
|
+
const dompurifyConfig = useMemo(() =>
|
|
182
|
+
allowHtml ? undefined : EMPTY_DOMPURIFY_CONFIG
|
|
183
|
+
, [allowHtml]);
|
|
184
|
+
|
|
185
|
+
return <ErrorBoundary fallback={<div className={prefixCls} style={{ fontSize: baseFontSize, lineHeight: baseLineHeight }}>{content}</div>}>
|
|
186
|
+
<Markdown
|
|
187
|
+
baseFontSize={baseFontSize}
|
|
188
|
+
baseLineHeight={baseLineHeight}
|
|
189
|
+
dompurifyConfig={dompurifyConfig}
|
|
190
|
+
streaming={streaming}
|
|
191
|
+
cursor={cursor}
|
|
192
|
+
className={classnames(prefixCls, className)}
|
|
193
|
+
components={components as unknown as InnerMarkdownProps['components']}
|
|
194
|
+
content={content}
|
|
195
|
+
config={config}
|
|
196
|
+
{...restProps}
|
|
197
|
+
/></ErrorBoundary>
|
|
198
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { Config as DOMPurifyConfig } from 'dompurify';
|
|
2
|
+
import type { DOMNode } from 'html-react-parser';
|
|
3
|
+
import type { MarkedExtension, Tokens } from 'marked';
|
|
4
|
+
import type { CSSProperties, JSX } from 'react';
|
|
5
|
+
|
|
6
|
+
export interface AnimationConfig {
|
|
7
|
+
/**
|
|
8
|
+
* @description 淡入动画的持续时间(毫秒)
|
|
9
|
+
* @description The duration of the fade-in animation in milliseconds
|
|
10
|
+
* @default 200
|
|
11
|
+
*/
|
|
12
|
+
fadeDuration?: number;
|
|
13
|
+
/**
|
|
14
|
+
* @description 动画的缓动函数
|
|
15
|
+
* @description Easing function for the animation
|
|
16
|
+
* @default 'ease-in-out'
|
|
17
|
+
*/
|
|
18
|
+
easing?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Token = Tokens.Generic;
|
|
22
|
+
|
|
23
|
+
interface SteamingOption {
|
|
24
|
+
/**
|
|
25
|
+
* @description 指示是否还有后续内容块,为 false 时刷新所有缓存并完成渲染
|
|
26
|
+
* @description Indicates whether more content chunks are expected. When false, flushes all cached content and completes rendering
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hasNextChunk?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @description 为块级元素(p、li、h1、h2、h3、h4)启用文字淡入动画
|
|
32
|
+
* @description Enables text fade-in animation for block elements (p, li, h1, h2, h3, h4)
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
enableAnimation?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @description 文字出现动画效果的配置
|
|
38
|
+
* @description Configuration for text appearance animation effects
|
|
39
|
+
*/
|
|
40
|
+
animationConfig?: AnimationConfig;
|
|
41
|
+
/**
|
|
42
|
+
* @description 启用英文单词缓存,单词会在遇到空格或标点后才整体显示
|
|
43
|
+
* @description Enable English word caching, words will be displayed as a whole after encountering spaces or punctuation
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
enableWordCaching?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @description 启用 LaTeX 公式缓存,公式会在完整后才整体显示($...$、$$...$$、\(...\)、\[...\])
|
|
49
|
+
* @description Enable LaTeX formula caching, formulas will be displayed as a whole when complete ($...$, $$...$$, \(...\), \[...\])
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
enableMathCaching?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type StreamStatus = 'loading' | 'done';
|
|
56
|
+
|
|
57
|
+
type ComponentProps<
|
|
58
|
+
T extends Record<string, unknown> = Record<string, unknown>,
|
|
59
|
+
> = React.HTMLAttributes<HTMLElement> & {
|
|
60
|
+
/**
|
|
61
|
+
* @description 组件对应的 DOM 节点,包含解析后的 DOM 节点信息
|
|
62
|
+
* @description Component Element from html-react-parser, contains the parsed DOM node information
|
|
63
|
+
*/
|
|
64
|
+
domNode: DOMNode;
|
|
65
|
+
/**
|
|
66
|
+
* @description 流式状态,`loading` 表示正在加载,`done` 表示加载完成
|
|
67
|
+
* @description Streaming status, `loading` indicates streaming in progress, `done` indicates streaming complete
|
|
68
|
+
*/
|
|
69
|
+
streamStatus: StreamStatus;
|
|
70
|
+
} & T;
|
|
71
|
+
|
|
72
|
+
interface MarkdownProps {
|
|
73
|
+
citations?: {
|
|
74
|
+
/**
|
|
75
|
+
* @description 引用的标题
|
|
76
|
+
* @descriptionEn Title of the citation
|
|
77
|
+
*/
|
|
78
|
+
title?: string;
|
|
79
|
+
/**
|
|
80
|
+
* @description 引用的URL地址
|
|
81
|
+
* @descriptionEn URL address of the citation
|
|
82
|
+
*/
|
|
83
|
+
url?: string;
|
|
84
|
+
/**
|
|
85
|
+
* @description 引用的内容
|
|
86
|
+
* @descriptionEn Content of the citation
|
|
87
|
+
*/
|
|
88
|
+
content?: string;
|
|
89
|
+
/**
|
|
90
|
+
* @description 引用的渲染函数
|
|
91
|
+
* @descriptionEn Rendering function of the citation
|
|
92
|
+
*/
|
|
93
|
+
render?: (props: {
|
|
94
|
+
text: string;
|
|
95
|
+
url: string;
|
|
96
|
+
title: string;
|
|
97
|
+
content: string;
|
|
98
|
+
}) => React.ReactNode;
|
|
99
|
+
}[];
|
|
100
|
+
/**
|
|
101
|
+
* @description 引用映射对象,用于快速查找引用信息
|
|
102
|
+
* @descriptionEn Citation mapping object for quick lookup of reference information
|
|
103
|
+
*/
|
|
104
|
+
citationsMap?: Record<
|
|
105
|
+
string,
|
|
106
|
+
{
|
|
107
|
+
/**
|
|
108
|
+
* @description 引用的标题
|
|
109
|
+
* @descriptionEn Title of the citation
|
|
110
|
+
*/
|
|
111
|
+
title?: string;
|
|
112
|
+
/**
|
|
113
|
+
* @description 引用的URL地址
|
|
114
|
+
* @descriptionEn URL address of the citation
|
|
115
|
+
*/
|
|
116
|
+
url?: string;
|
|
117
|
+
/**
|
|
118
|
+
* @description 引用的内容
|
|
119
|
+
* @descriptionEn Content of the citation
|
|
120
|
+
*/
|
|
121
|
+
content?: string;
|
|
122
|
+
/**
|
|
123
|
+
* @description 引用的渲染函数
|
|
124
|
+
* @descriptionEn Rendering function of the citation
|
|
125
|
+
*/
|
|
126
|
+
render?: (props: {
|
|
127
|
+
text: string;
|
|
128
|
+
url: string;
|
|
129
|
+
title: string;
|
|
130
|
+
content: string;
|
|
131
|
+
}) => React.ReactNode;
|
|
132
|
+
}
|
|
133
|
+
>;
|
|
134
|
+
/**
|
|
135
|
+
* @description 光标样式类型,支持点状、下划线或布尔值控制
|
|
136
|
+
* @description Cursor style type, supports dot, underline, or boolean control
|
|
137
|
+
*/
|
|
138
|
+
cursor?: boolean | 'dot' | 'underline';
|
|
139
|
+
/**
|
|
140
|
+
* @description 基础字体大小,影响整个Markdown内容的字体大小
|
|
141
|
+
* @description Base font size that affects the font size of the entire Markdown content
|
|
142
|
+
*/
|
|
143
|
+
baseFontSize?: number;
|
|
144
|
+
/**
|
|
145
|
+
* @description 基础行高,影响文本的行间距
|
|
146
|
+
* @description Base line height that affects text line spacing
|
|
147
|
+
*/
|
|
148
|
+
baseLineHeight?: number;
|
|
149
|
+
/**
|
|
150
|
+
* @description 需要渲染的 Markdown 内容
|
|
151
|
+
* @description Markdown content to be rendered
|
|
152
|
+
*/
|
|
153
|
+
content?: string;
|
|
154
|
+
/**
|
|
155
|
+
* @description Markdown 内容,作为 `content` 属性的别名
|
|
156
|
+
* @description Markdown content, alias for `content` property
|
|
157
|
+
*/
|
|
158
|
+
children?: string;
|
|
159
|
+
/**
|
|
160
|
+
* @description 用于替换 HTML 元素的自定义 React 组件映射,组件会接收 domNode、streamStatus 等属性
|
|
161
|
+
* @description Custom React components to replace HTML elements, components receive domNode, streamStatus, etc.
|
|
162
|
+
*/
|
|
163
|
+
components?: {
|
|
164
|
+
[tagName: string]:
|
|
165
|
+
| React.ComponentType<ComponentProps>
|
|
166
|
+
| keyof JSX.IntrinsicElements;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* @description 流式渲染行为的配置
|
|
170
|
+
* @description Configuration for streaming rendering behavior
|
|
171
|
+
*/
|
|
172
|
+
streaming?: SteamingOption;
|
|
173
|
+
/**
|
|
174
|
+
* @description Markdown 解析和扩展的 Marked.js 配置
|
|
175
|
+
* @description Marked.js configuration for Markdown parsing and extensions
|
|
176
|
+
*/
|
|
177
|
+
config?: MarkedExtension;
|
|
178
|
+
/**
|
|
179
|
+
* @description 根元素的额外 CSS 类名
|
|
180
|
+
* @description Additional CSS class name for the root container
|
|
181
|
+
*/
|
|
182
|
+
rootClassName?: string;
|
|
183
|
+
/**
|
|
184
|
+
* @description 根容器的额外 CSS 类名
|
|
185
|
+
* @description Additional CSS class name for the root container
|
|
186
|
+
*/
|
|
187
|
+
className?: string;
|
|
188
|
+
/**
|
|
189
|
+
* @description 段落元素的自定义 HTML 标签,防止自定义组件包含块级元素时的验证错误
|
|
190
|
+
* @description Custom HTML tag for paragraph elements, prevents validation errors when custom components contain block-level elements
|
|
191
|
+
* @default 'p'
|
|
192
|
+
*/
|
|
193
|
+
paragraphTag?: keyof JSX.IntrinsicElements;
|
|
194
|
+
/**
|
|
195
|
+
* @description 根容器的内联样式
|
|
196
|
+
* @description Inline styles for the root container
|
|
197
|
+
*/
|
|
198
|
+
style?: CSSProperties;
|
|
199
|
+
/**
|
|
200
|
+
* @description 组件的 CSS 类名前缀
|
|
201
|
+
* @description CSS class name prefix for the component
|
|
202
|
+
*/
|
|
203
|
+
prefixCls?: string;
|
|
204
|
+
/**
|
|
205
|
+
* @description 是否为所有锚点标签添加 `target="_blank"`
|
|
206
|
+
* @description Whether to add `target="_blank"` to all anchor tags
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
openLinksInNewTab?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* @description HTML 净化和 XSS 防护的 DOMPurify 配置
|
|
212
|
+
* @description DOMPurify configuration for HTML sanitization and XSS protection
|
|
213
|
+
*/
|
|
214
|
+
dompurifyConfig?: DOMPurifyConfig;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export type { ComponentProps, MarkdownProps, StreamStatus, Token, Tokens };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
export default createGlobalStyle`
|
|
4
|
+
.${(p) => p.theme.prefixCls}-markdown {
|
|
5
|
+
color: inherit;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
|
|
8
|
+
ol, ul {
|
|
9
|
+
padding-left: 30px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
blockquote {
|
|
13
|
+
padding-inline: 0.6em 0;
|
|
14
|
+
padding-block: 0;
|
|
15
|
+
margin: 1em 0;
|
|
16
|
+
border-inline-start: 4px solid ${(p) => p.theme.colorBorder};
|
|
17
|
+
opacity: 0.85;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
figure {
|
|
21
|
+
margin: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
code {
|
|
25
|
+
font-size: 0.8571428571428571em;
|
|
26
|
+
border: 0;
|
|
27
|
+
margin: 0;
|
|
28
|
+
background-color: ${(p) => p.theme.colorFillQuaternary};
|
|
29
|
+
color: ${(p) => p.theme.colorText};
|
|
30
|
+
border-radius: ${(p) => p.theme.borderRadiusSM}px;
|
|
31
|
+
padding: 2px 6px;
|
|
32
|
+
margin-inline: 3px;
|
|
33
|
+
border: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pre code {
|
|
37
|
+
font-size: 0.8571428571428571em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
h1,
|
|
41
|
+
h2,
|
|
42
|
+
h3,
|
|
43
|
+
h4,
|
|
44
|
+
h5,
|
|
45
|
+
h6 {
|
|
46
|
+
margin-top: 0.5714285714285714em;
|
|
47
|
+
margin-bottom: 0.5714285714285714em;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
line-height: 1.7777;
|
|
50
|
+
color: inherit;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
p {
|
|
54
|
+
margin-top: 0.5714285714285714em;
|
|
55
|
+
margin-bottom: 0.5714285714285714em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
h1 {
|
|
59
|
+
font-size: 1.2857142857142858em;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
h2 {
|
|
63
|
+
font-size: 1.1428571428571428em;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
h3 {
|
|
67
|
+
font-size: 1em;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
h4 {
|
|
71
|
+
font-size: 1em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
h5 {
|
|
75
|
+
font-size: 1em;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
h6 {
|
|
79
|
+
font-size: 1em;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
hr {
|
|
83
|
+
border-color: ${(p) => p.theme.colorBorderSecondary};
|
|
84
|
+
border-style: solid;
|
|
85
|
+
border-width: 1px 0 0 0;
|
|
86
|
+
margin: 1em 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
table {
|
|
90
|
+
border-collapse: collapse;
|
|
91
|
+
display: block;
|
|
92
|
+
width: max-content;
|
|
93
|
+
max-width: 100%;
|
|
94
|
+
overflow: auto;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
table th {
|
|
98
|
+
background: ${(p) => p.theme.colorFillQuaternary};
|
|
99
|
+
text-align: left;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
table td,
|
|
103
|
+
table th {
|
|
104
|
+
padding: 0.75em 1.5em;
|
|
105
|
+
border: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
106
|
+
white-space: pre;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.${(p) => p.theme.prefixCls}-image {
|
|
110
|
+
max-width: 480px;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.${(p) => p.theme.prefixCls}-markdown-video {
|
|
115
|
+
position: relative;
|
|
116
|
+
|
|
117
|
+
&-poster {
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
max-width: 480px;
|
|
122
|
+
background-color: #000;
|
|
123
|
+
border-radius: 8px;
|
|
124
|
+
padding: 100px 0;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&-play {
|
|
129
|
+
color: #ccc;
|
|
130
|
+
font-size: 30px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.${(p) => p.theme.prefixCls}-markdown > *:last-child {
|
|
137
|
+
margin-bottom: 0 !important;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.${(p) => p.theme.prefixCls}-markdown > *:first-child {
|
|
141
|
+
margin-top: 0 !important;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@keyframes ${(p) => p.theme.prefixCls}-markdown-fadeIn {
|
|
145
|
+
from {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
}
|
|
148
|
+
to {
|
|
149
|
+
opacity: 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
2
|
+
import { SparkEditLine } from '@agentscope-ai/icons';
|
|
3
|
+
import { IconButton, Input, Modal } from '@agentscope-ai/design';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const content = `# 这是一个一级标题
|
|
8
|
+
## 这是一个二级标题
|
|
9
|
+
### 这是一个三级标题
|
|
10
|
+
#### 这是一个四级标题
|
|
11
|
+
##### 这是一个五级标题
|
|
12
|
+
###### 这是一个六级标题
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
这是第一个段落。
|
|
17
|
+
|
|
18
|
+
这是第二个段落。
|
|
19
|
+
|
|
20
|
+
city pop, short for city pop, is a genre of music that originated in japan during the late 1970s and early 1980s. it blends elements of jazz, folk, easy listening, and aor (adult oriented rock) with a distinctly urban feel. the term "city pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of tokyo and other major japanese cities during this period. city pop is characterized by its smooth melodies, mellow rhythms, and often dreamy or introspective lyrics. common themes include city life, summer vibes, nature, and romantic encounters. the music is frequently associated with a particular aesthetic that reflects the fashion, design, and cultural trends of urban japan in the 1980s. some notable city pop artists include mariya takeuchi, known for her iconic song " plastic love," and joe hisaishi, a composer famous for his work on studio ghibli films, though he is not strictly considered a city pop artist. today, city pop has experienced a resurgence in popularity, particularly among younger generations who appreciate its unique sound and the nostalgic value it holds.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
- 项目1
|
|
25
|
+
- 项目2
|
|
26
|
+
- 子项目2.1
|
|
27
|
+
- 子项目2.2
|
|
28
|
+
- 项目3
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
1. 第一项
|
|
33
|
+
2. 第二项
|
|
34
|
+
1. 第二项的第一子项
|
|
35
|
+
2. 第二项的第二子项
|
|
36
|
+
3. 第三项
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
> 这是一个引用。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
*这是斜体文本*
|
|
45
|
+
_这是斜体文本_
|
|
46
|
+
**这是粗体文本**
|
|
47
|
+
__这是粗体文本__
|
|
48
|
+
|
|
49
|
+
***这是粗斜体文本***
|
|
50
|
+
**_这是粗斜体文本_**
|
|
51
|
+
_**这是粗斜体文本**_
|
|
52
|
+
___这是粗斜体文本___
|
|
53
|
+
~~这是删除线文本~~
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
[https://www.aliyun.com](https://www.aliyun.com)
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
\`hello world\`
|
|
67
|
+
|
|
68
|
+
\`\`\`java
|
|
69
|
+
class HelloWorld {
|
|
70
|
+
public static void main(String[] args) {
|
|
71
|
+
System.out.println("Hello World!");
|
|
72
|
+
// Hello World!
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
\`\`\`mermaid
|
|
78
|
+
sequenceDiagram
|
|
79
|
+
Alice->>John: Hello John, how are you?
|
|
80
|
+
John-->>Alice: Great!
|
|
81
|
+
Alice-)John: See you later!
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
| 标题1 | 标题2 | 标题3 |标题2 | 标题3 |标题1 | 标题2 | 标题3 |标题2 | 标题3 |标题1 | 标题2 | 标题3 |标题2 | 标题3 |
|
|
87
|
+
|-------|-------|-------|----|-------|------|-------|-------|----|-------|------|-------|-------|----|-------|
|
|
88
|
+
| 单元格1 | 单元格2 | 单元格3 |单元格3 |单元格3 |单元格1 | 单元格2 | 单元格3 |单元格3 |单元格3 |单元格1 | 单元格2 | 单元格3 |单元格3 |单元格3 |
|
|
89
|
+
| 单元格4 | 单元格5 | 单元格6 |单元格6 |单元格6 |单元格4 | 单元格5 | 单元格6 |单元格6 |单元格6 |单元格4 | 单元格5 | 单元格6 |单元格6 |单元格6 |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
export default function () {
|
|
95
|
+
const [value, setValue] = useState(content);
|
|
96
|
+
const [open, setOpen] = useState(false);
|
|
97
|
+
|
|
98
|
+
return <>
|
|
99
|
+
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
100
|
+
<IconButton icon={<SparkEditLine />} onClick={() => setOpen(true)} />
|
|
101
|
+
<Modal open={open} onCancel={() => setOpen(false)} title="markdown editor" footer={null} centered>
|
|
102
|
+
<Input.TextArea value={value} onChange={(e) => setValue(e.target.value)} autoSize={{ minRows: 30, maxRows: 30 }} />
|
|
103
|
+
</Modal>
|
|
104
|
+
</div>
|
|
105
|
+
<Markdown content={value} />
|
|
106
|
+
</>;
|
|
107
|
+
}
|