@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,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
3
|
+
|
|
4
|
+
const content = `杭州今天和未来几天的天气预报如下:
|
|
5
|
+
|
|
6
|
+
今天(2月18日)多云,气温在4-12℃之间[2][3][two]。白天多云,夜间转阴[7]。风力较大,上午为偏东风2-3级,傍晚增大到4级[7]。
|
|
7
|
+
|
|
8
|
+
未来几天天气概况:
|
|
9
|
+
- 2月19日(明天):阴天,有小雨,气温11℃左右[3][7]
|
|
10
|
+
- 2月20日:阴天,小到中雨,气温7℃左右[3][7]
|
|
11
|
+
- 2月21日:多云,气温7℃左右[3]
|
|
12
|
+
- 2月22日:小雨,气温7℃左右[3]
|
|
13
|
+
|
|
14
|
+
总体来看,未来几天杭州天气较凉,以阴天和雨天为主,气温在7-11℃之间波动。建议市民适当增添衣物,注意保暖,外出时携带雨具[2][3][7][110]。
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const citationsMap = [
|
|
18
|
+
'https://www.weather.com.cn/weather/101210101.shtml',
|
|
19
|
+
'https://tianqi.moji.com/weather/china/zhejiang/hangzhou',
|
|
20
|
+
'https://weather.cma.cn/web/weather/58457.html',
|
|
21
|
+
'https://tianqi.so.com/weather/101210101',
|
|
22
|
+
'https://www.accuweather.com/zh/cn/hangzhou/106832/weather-forecast/106832',
|
|
23
|
+
'https://www.hzqx.com',
|
|
24
|
+
'https://www.hzqx.com/pc/hztq/',
|
|
25
|
+
].map((url, index) => {
|
|
26
|
+
return {
|
|
27
|
+
url,
|
|
28
|
+
title: `参考${index + 1}`,
|
|
29
|
+
content: url,
|
|
30
|
+
};
|
|
31
|
+
}).reduce((acc, item, index) => {
|
|
32
|
+
acc[index + 1] = item;
|
|
33
|
+
return acc;
|
|
34
|
+
}, {});
|
|
35
|
+
|
|
36
|
+
export default function () {
|
|
37
|
+
return <Markdown content={content} citationsMap={{
|
|
38
|
+
...citationsMap, two: {
|
|
39
|
+
url: 'two',
|
|
40
|
+
title: 'two',
|
|
41
|
+
content: 'two',
|
|
42
|
+
render: (props) => {
|
|
43
|
+
return <i>{props.content}</i>;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}} />;
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
2
|
+
import { Space } from 'antd';
|
|
3
|
+
|
|
4
|
+
const text = `Hello, world!`
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function () {
|
|
8
|
+
return <Space direction="vertical" ><Markdown content={text} cursor="dot" /> <Markdown content={text} cursor="underline" /></Space>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const content = `三角函数是一类数学函数,主要用来描述直角三角形中的角度与边长之间的关系。最常用的三角函数包括正弦(sine, 简写为sin)、余弦(cosine, 简写为cos)和正切(tangent, 简写为tan)。此外还有它们的倒数:余割(cosecant, 简写为csc或cosec)、正割(secant, 简写为sec)和余切(cotangent, 简写为cot)。
|
|
5
|
+
|
|
6
|
+
这些函数的基本定义如下:
|
|
7
|
+
|
|
8
|
+
1. **正弦(sin)**:对于一个角θ,在直角三角形中,正弦是该角对边与斜边的比值。
|
|
9
|
+
\\[ 1 + 2 = 3 \\]
|
|
10
|
+
|
|
11
|
+
2. **余弦(cos)**:对于一个角θ,在直角三角形中,余弦是该角邻边与斜边的比值。
|
|
12
|
+
\\[ \\cos(\\theta) = \\frac{\\text{邻边}}{\\text{斜边}} \\]
|
|
13
|
+
|
|
14
|
+
3. **正切(tan)**:对于一个角θ,在直角三角形中,正切是对边与邻边的比值。
|
|
15
|
+
\\[ \\tan(\\theta) = \\frac{\\text{对边}}{\\text{邻边}} \\]
|
|
16
|
+
|
|
17
|
+
4. **余割(csc)**:是正弦的倒数。
|
|
18
|
+
\\[ \\csc(\\theta) = \\frac{1}{\\sin(\\theta)} \\]
|
|
19
|
+
|
|
20
|
+
5. **正割(sec)**:是余弦的倒数。
|
|
21
|
+
\\[ \\sec(\\theta) = \\frac{1}{\\cos(\\theta)} \\]
|
|
22
|
+
|
|
23
|
+
6. **余切(cot)**:是正切的倒数。
|
|
24
|
+
\\[ \\cot(\\theta) = \\frac{1}{\\tan(\\theta)} \\]
|
|
25
|
+
|
|
26
|
+
三角函数在数学、物理学、工程学等领域有着广泛的应用,尤其是在处理周期性现象时。
|
|
27
|
+
|
|
28
|
+
矩阵是数学中一种重要的工具,广泛应用于线性代数、计算机科学、物理学等领域。以下是关于矩阵形式的详细说明:
|
|
29
|
+
矩阵是一个**按矩形排列的数表**,由 **m 行 n 列** 的元素组成,通常用大写字母表示(如 A、B)。
|
|
30
|
+
|
|
31
|
+
一般形式如下:
|
|
32
|
+
|
|
33
|
+
$$
|
|
34
|
+
A = \\begin{bmatrix}
|
|
35
|
+
a_{11} & a_{12} & \\cdots & a_{1n} \\\\
|
|
36
|
+
a_{21} & a_{22} & \\cdots & a_{2n} \\\\
|
|
37
|
+
\\vdots & \\vdots & \\ddots & \\vdots \\\\
|
|
38
|
+
a_{m1} & a_{m2} & \\cdots & a_{mn}
|
|
39
|
+
\\end{bmatrix}
|
|
40
|
+
$$
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
其中 \( C \) 表示圆的周长,\( \pi \) 是圆周率(大约等于 3.14159),而 \( r \) 是圆的半径。
|
|
45
|
+
|
|
46
|
+
其中 $ C $ 表示圆的周长,$ \pi $ 是圆周率(大约等于 3.14159),而 $ r $ 是圆的半径。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
\\[
|
|
51
|
+
x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}
|
|
52
|
+
\\]
|
|
53
|
+
|
|
54
|
+
\\[
|
|
55
|
+
\\begin{align*}
|
|
56
|
+
1. & \\quad x + y = 10 \\\\
|
|
57
|
+
2. & \\quad 2x - y = 0
|
|
58
|
+
\\end{align*}
|
|
59
|
+
\\]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
$$ x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} $$
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
\\begin{align*}
|
|
66
|
+
1. & \\quad x + y = 10 \\\\
|
|
67
|
+
2. & \\quad 2x - y = 0
|
|
68
|
+
\\end{align*}
|
|
69
|
+
$$
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export default function () {
|
|
74
|
+
return <Markdown
|
|
75
|
+
content={content}
|
|
76
|
+
/>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
2
|
+
import { Flex } from 'antd';
|
|
3
|
+
|
|
4
|
+
const fullContentZh = `# 出师表
|
|
5
|
+
臣亮言:先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。
|
|
6
|
+
|
|
7
|
+
然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。
|
|
8
|
+
|
|
9
|
+
诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。
|
|
10
|
+
|
|
11
|
+
亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。
|
|
12
|
+
|
|
13
|
+
先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。
|
|
14
|
+
|
|
15
|
+
臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。
|
|
16
|
+
|
|
17
|
+
先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。
|
|
18
|
+
|
|
19
|
+
先帝知臣谨慎,故临崩寄臣以大事也。
|
|
20
|
+
|
|
21
|
+
受命以来,夙夜忧叹,恐托付不效,以伤先帝之明,故五月渡泸,深入不毛。
|
|
22
|
+
|
|
23
|
+
今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。
|
|
24
|
+
|
|
25
|
+
此臣所以报先帝而忠陛下之职分也。
|
|
26
|
+
|
|
27
|
+
愿陛下托臣以讨贼兴复之效,不效,则治臣之罪,以告先帝之灵。
|
|
28
|
+
|
|
29
|
+
陛下亦宜自谋,以咨诹善道,察纳雅言。深追先帝遗诏,臣不胜受恩感激。今当远离,临表涕零,不知所言。`;
|
|
30
|
+
|
|
31
|
+
const fullContentEn = `# 出师表
|
|
32
|
+
|
|
33
|
+
Permit me to observe: the late emperor was taken from us before he could finish his life's work, the restoration of the Han. Today, the empire is still divided in three, and our very survival is threatened.
|
|
34
|
+
|
|
35
|
+
Yet still the officials at court and the soldiers throughout the realm remain loyal to you, your majesty. Because they remember the late emperor, all of them, and they wish to repay his kindness in service to you.
|
|
36
|
+
|
|
37
|
+
This is the moment to extend your divine influence, to honor the memory of the late Emperor and strengthen the morale of your officers. It is not the time to listen to bad advice, or close your ears to the suggestions of loyal men.
|
|
38
|
+
|
|
39
|
+
The emperors of the Western Han chose their courtiers wisely, and their dynasty flourished. The emperors of the Eastern Han chose poorly, and they doomed the empire to ruin.
|
|
40
|
+
|
|
41
|
+
Whenever the late Emperor discussed this problem with me, he lamented the failings of Emperors Huan and Ling.
|
|
42
|
+
|
|
43
|
+
I began as a common man, farming in my fields in Nanyang, doing what I could to survive in an age of chaos. I never had any interest in making a name for myself as a noble.
|
|
44
|
+
|
|
45
|
+
The late Emperor was not ashamed to visit my cottage and seek my advice. Grateful for his regard, I responded to his appeal and threw myself into his service.
|
|
46
|
+
|
|
47
|
+
The late Emperor always appreciated my caution and, in his final days, entrusted me with his cause.
|
|
48
|
+
|
|
49
|
+
Since that moment, I have been tormented day and night by the fear that I might let him down. That is why I crossed the Lu river at the height of summer, and entered the wastelands beyond.
|
|
50
|
+
|
|
51
|
+
Now the south has been subdued, and our forces are fully armed. I should lead our soldiers to conquer the northern heartland and attempt to remove the hateful traitors, restore the house of Han, and return it to the former capital.
|
|
52
|
+
|
|
53
|
+
This is the way I mean to honor my debt to the late Emperor and fulfill my duty to you.
|
|
54
|
+
|
|
55
|
+
My only desire is to be permitted to drive out the traitors and restore the Han. If I should let you down, punish my offense and report it to the spirit of the late Emperor.
|
|
56
|
+
|
|
57
|
+
Your Majesty, consider your course of action carefully. Seek out good advice, and never forget the late words of the late Emperor. I depart now on a long expedition, and I will be forever grateful if you heed my advice. Blinded by my own tears, I know not what I write.`;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export default function () {
|
|
61
|
+
return <Flex gap={32}>
|
|
62
|
+
<div style={{ flex: 1 }}>
|
|
63
|
+
|
|
64
|
+
<Markdown
|
|
65
|
+
typing={50}
|
|
66
|
+
enableAnimation={true}
|
|
67
|
+
enableWordCaching={true}
|
|
68
|
+
content={fullContentZh}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div style={{ flex: 1 }}>
|
|
73
|
+
|
|
74
|
+
<Markdown
|
|
75
|
+
cursor="underline"
|
|
76
|
+
typing={12.5}
|
|
77
|
+
enableWordCaching={true}
|
|
78
|
+
content={fullContentEn}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</Flex>
|
|
82
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: Output
|
|
4
|
+
order: 3
|
|
5
|
+
title: Markdown
|
|
6
|
+
description: Markdown is a React component for rendering Markdown text
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="Markdown" desc="Markdown is a React component for rendering Markdown text. It supports various Markdown syntax such as headings, lists, links, images, code blocks, etc."></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" height="600">Example</code>
|
|
12
|
+
|
|
13
|
+
<Install>
|
|
14
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
15
|
+
</Install>
|
|
16
|
+
|
|
17
|
+
#### More Examples
|
|
18
|
+
|
|
19
|
+
<code src="./demo/latex.tsx" height="600">Latex</code>
|
|
20
|
+
<code src="./demo/citations.tsx" height="auto">Citations</code>
|
|
21
|
+
<code src="./demo/cursor.tsx" height="auto">Cursor</code>
|
|
22
|
+
<code src="./demo/typing.tsx" height="300">Typing</code>
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#### API
|
|
26
|
+
|
|
27
|
+
<ApiParser source="./Markdown/index.tsx" id="MarkdownProps"></ApiParser>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type MarkdownProps } from './Markdown';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: 输出
|
|
4
|
+
order: 3
|
|
5
|
+
title: Markdown
|
|
6
|
+
description: 是一个用于渲染 Markdown 文本的 React 组件
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="Markdown" desc="是一个用于渲染 Markdown 文本的 React 组件。它支持各种 Markdown 语法,例如标题、列表、链接、图片、代码块等。"></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" height="600">示例</code>
|
|
12
|
+
|
|
13
|
+
<Install>
|
|
14
|
+
import { Markdown } from '@agentscope-ai/chat';
|
|
15
|
+
</Install>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#### 更多示例
|
|
19
|
+
|
|
20
|
+
<code src="./demo/latex.tsx" height="600">Latex</code>
|
|
21
|
+
<code src="./demo/citations.tsx" height="auto">引用</code>
|
|
22
|
+
<code src="./demo/cursor.tsx" height="auto">光标</code>
|
|
23
|
+
<code src="./demo/typing.tsx" height="300">打字效果</code>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
#### API
|
|
27
|
+
|
|
28
|
+
<ApiParser source="./Markdown/index.tsx" id="MarkdownProps"></ApiParser>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
3
|
+
import { Popover } from 'antd';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const Style = createGlobalStyle`
|
|
7
|
+
.${p => p.theme.prefixCls}-markdown-citation {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
min-width: 16px;
|
|
12
|
+
padding: 0 4px;
|
|
13
|
+
height: 16px;
|
|
14
|
+
margin-inline: 2px;
|
|
15
|
+
font-size: 10px;
|
|
16
|
+
color: ${p => p.theme.colorTextSecondary};
|
|
17
|
+
text-align: center;
|
|
18
|
+
vertical-align: top;
|
|
19
|
+
background: ${p => p.theme.colorFillSecondary};
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
transition: all 100ms ${p => p.theme.motionEaseOut};
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
line-height: 1;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
color: ${p => p.theme.colorWhite};
|
|
27
|
+
background: ${p => p.theme.colorPrimary};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export interface DefaultRenderProps {
|
|
34
|
+
text: string;
|
|
35
|
+
url: string;
|
|
36
|
+
title: string;
|
|
37
|
+
content: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CitationComponentProps extends DefaultRenderProps {
|
|
41
|
+
render: (props: DefaultRenderProps) => React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function DefaultRender(props: DefaultRenderProps) {
|
|
45
|
+
const { getPrefixCls } = useProviderContext();
|
|
46
|
+
const prefixCls = getPrefixCls('markdown-citation');
|
|
47
|
+
const { text, url, title, content } = props;
|
|
48
|
+
|
|
49
|
+
const isTooltip = content || title;
|
|
50
|
+
|
|
51
|
+
let node = <sup className={prefixCls}>{text}</sup>;
|
|
52
|
+
|
|
53
|
+
if (isTooltip) {
|
|
54
|
+
node = <Popover title={title} content={url ? <a href={url}
|
|
55
|
+
rel="noreferrer"
|
|
56
|
+
target={'_blank'}>{url}</a> : content}>{node}</Popover>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return <>
|
|
60
|
+
<Style />
|
|
61
|
+
{node}
|
|
62
|
+
</>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
export default function CitationComponent(props: DefaultRenderProps & { citationsData: Record<string, any> }) {
|
|
69
|
+
const Render = props.citationsData[props.text]?.render || DefaultRender;
|
|
70
|
+
|
|
71
|
+
return <Render {...props} />
|
|
72
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MarkdownProps } from "../../Markdown/interface";
|
|
2
|
+
export { default as CitationComponent } from './CitationComponent';
|
|
3
|
+
|
|
4
|
+
export function citationsExtension(citationsData: MarkdownProps['citationsMap']) {
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
name: 'citation',
|
|
8
|
+
level: 'inline' as const,
|
|
9
|
+
tokenizer(src: string) {
|
|
10
|
+
// 使用负向前瞻确保不匹配 markdown 链接语法 [text](url)
|
|
11
|
+
const match = src.match(/^\[([^\]]+)\](?!\()/);
|
|
12
|
+
if (match) {
|
|
13
|
+
const content = match[0].trim();
|
|
14
|
+
const text = content?.replace(/^\[([^\]]+)\]/g, '$1');
|
|
15
|
+
|
|
16
|
+
if (citationsData[text]) {
|
|
17
|
+
return {
|
|
18
|
+
type: 'citation',
|
|
19
|
+
raw: content,
|
|
20
|
+
text: content?.replace(/^\[([^\]]+)\]/g, '$1'),
|
|
21
|
+
renderType: 'component',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
renderer(token) {
|
|
27
|
+
if (citationsData && Object.keys(citationsData).length === 0) return null;
|
|
28
|
+
const { text } = token;
|
|
29
|
+
const citation = citationsData?.[text];
|
|
30
|
+
|
|
31
|
+
if (!citation) return token.raw;
|
|
32
|
+
|
|
33
|
+
return `<citation text="${text}" url="${citation.url}" title="${citation.title}" content="${citation.content}"></citation>`;
|
|
34
|
+
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
2
|
+
import { createGlobalStyle } from 'antd-style';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
const Style = createGlobalStyle`
|
|
6
|
+
.${p => p.theme.prefixCls}-markdown-cursor-dot {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
width: 0;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding-left: 2px;
|
|
11
|
+
gap: 4px;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
&-dot1 {
|
|
15
|
+
flex: 0 0 5px;
|
|
16
|
+
width: 5px;
|
|
17
|
+
height: 5px;
|
|
18
|
+
border-radius: 999px;
|
|
19
|
+
background-color: ${p => p.theme.colorText};
|
|
20
|
+
animation: markdown-cursor-dot1 2s infinite ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
&-dot2 {
|
|
25
|
+
flex: 0 0 5px;
|
|
26
|
+
width: 5px;
|
|
27
|
+
height: 5px;
|
|
28
|
+
border-radius: 999px;
|
|
29
|
+
opacity: 0.5;
|
|
30
|
+
background-color: ${p => p.theme.colorText};
|
|
31
|
+
animation: markdown-cursor-dot2 2s infinite ease;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@keyframes markdown-cursor-dot1 {
|
|
38
|
+
0% {
|
|
39
|
+
transform: translateX(0px)scale(1);
|
|
40
|
+
z-index: 1;
|
|
41
|
+
opacity: 1;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
40% {
|
|
46
|
+
transform: translateX(8.5px)scale(0.8);
|
|
47
|
+
z-index: 3;
|
|
48
|
+
opacity: 0.5;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
50% {
|
|
53
|
+
transform: translateX(8.5px) scale(0.8);
|
|
54
|
+
z-index: 1;
|
|
55
|
+
opacity: 0.5;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
90% {
|
|
59
|
+
transform: translateX(0px) scale(1);
|
|
60
|
+
z-index: 1;
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@keyframes markdown-cursor-dot2 {
|
|
66
|
+
0% {
|
|
67
|
+
transform: translateX(0px)scale(1);
|
|
68
|
+
z-index: 1;
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
40% {
|
|
74
|
+
transform: translateX(-8.5px)scale(1.25);
|
|
75
|
+
z-index: 3;
|
|
76
|
+
opacity: 1;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
50% {
|
|
81
|
+
transform: translateX(-8.5px) scale(1.25);
|
|
82
|
+
z-index: 1;
|
|
83
|
+
opacity: 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
90% {
|
|
87
|
+
transform: translateX(0px) scale(1);
|
|
88
|
+
z-index: 1;
|
|
89
|
+
opacity: 0.5;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`
|
|
93
|
+
|
|
94
|
+
export default function () {
|
|
95
|
+
const { getPrefixCls } = useProviderContext();
|
|
96
|
+
const prefixCls = getPrefixCls('markdown-cursor-dot');
|
|
97
|
+
|
|
98
|
+
return <>
|
|
99
|
+
<Style />
|
|
100
|
+
<span className={classNames(prefixCls, getPrefixCls('markdown-cursor'))}>
|
|
101
|
+
<span style={{ opacity: 0, marginLeft: '-.75em' }}>_</span>
|
|
102
|
+
<span className={`${prefixCls}-dot1`}></span>
|
|
103
|
+
<span className={`${prefixCls}-dot2`}></span>
|
|
104
|
+
</span>
|
|
105
|
+
</>
|
|
106
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { createGlobalStyle } from 'antd-style';
|
|
4
|
+
|
|
5
|
+
const Style = createGlobalStyle`
|
|
6
|
+
.markdown-cursor-underline {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
padding: 0 2px;
|
|
9
|
+
animation: markdown-cursor-underline .8s infinite;
|
|
10
|
+
|
|
11
|
+
&::after {
|
|
12
|
+
content: '_';
|
|
13
|
+
color: ${({theme}) => theme.colorPrimary};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@keyframes markdown-cursor-underline {
|
|
19
|
+
0% {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
100% {
|
|
24
|
+
opacity: 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default function () {
|
|
32
|
+
const { getPrefixCls } = useProviderContext();
|
|
33
|
+
const prefixCls = ('markdown-cursor-underline');
|
|
34
|
+
return <>
|
|
35
|
+
<Style />
|
|
36
|
+
<span className={classNames(prefixCls, getPrefixCls('markdown-cursor'))} />
|
|
37
|
+
</>
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Underline from './Underline';
|
|
3
|
+
import Dot from './Dot';
|
|
4
|
+
|
|
5
|
+
export const CursorComponent = function(props) {
|
|
6
|
+
|
|
7
|
+
if (props.type === 'dot') {
|
|
8
|
+
return <Dot />
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (props.type === 'underline') {
|
|
12
|
+
return <Underline />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function cursorExtension() {
|
|
19
|
+
const options = {
|
|
20
|
+
cursors: {
|
|
21
|
+
dot: 'dot',
|
|
22
|
+
underline: 'underline',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const cursorNames = Object.keys(options.cursors).map(e => e.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
|
|
27
|
+
const cursorRegex = new RegExp(`:(${cursorNames}):`);
|
|
28
|
+
const tokenizerRule = new RegExp(`^${cursorRegex.source}`);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
name: 'cursor',
|
|
32
|
+
level: 'inline',
|
|
33
|
+
start(src) { return src.match(cursorRegex)?.index; },
|
|
34
|
+
tokenizer(src, tokens) {
|
|
35
|
+
const match = tokenizerRule.exec(src);
|
|
36
|
+
if (!match) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const name = match[1];
|
|
41
|
+
const cursor = options.cursors[name];
|
|
42
|
+
|
|
43
|
+
if (!cursor) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
type: 'cursor',
|
|
49
|
+
raw: match[0],
|
|
50
|
+
name,
|
|
51
|
+
cursor,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
renderer(token) {
|
|
55
|
+
const content = `<cursor type="${token.name}"></cursor>`;
|
|
56
|
+
return content;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|