@ant-design/agentic-ui 2.30.21 → 2.30.23
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/Bubble/MessagesContent/MarkdownPreview.d.ts +0 -58
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +79 -155
- package/dist/Bubble/OpenAIMessageBubble/index.d.ts +11 -0
- package/dist/Bubble/OpenAIMessageBubble/index.js +8 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOllamaMessages.d.ts +7 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOllamaMessages.js +136 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOpenAIMessages.d.ts +8 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOpenAIMessages.js +156 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOpenClawMessages.d.ts +8 -0
- package/dist/Bubble/OpenAIMessageBubble/mapOpenClawMessages.js +127 -0
- package/dist/Bubble/OpenAIMessageBubble/normalizeOllamaMessages.d.ts +16 -0
- package/dist/Bubble/OpenAIMessageBubble/normalizeOllamaMessages.js +110 -0
- package/dist/Bubble/OpenAIMessageBubble/normalizeOpenClawMessages.d.ts +10 -0
- package/dist/Bubble/OpenAIMessageBubble/normalizeOpenClawMessages.js +61 -0
- package/dist/Bubble/OpenAIMessageBubble/ollamaTypes.d.ts +48 -0
- package/dist/Bubble/OpenAIMessageBubble/ollamaTypes.js +1 -0
- package/dist/Bubble/OpenAIMessageBubble/openClawTypes.d.ts +27 -0
- package/dist/Bubble/OpenAIMessageBubble/openClawTypes.js +1 -0
- package/dist/Bubble/OpenAIMessageBubble/types.d.ts +71 -0
- package/dist/Bubble/OpenAIMessageBubble/types.js +1 -0
- package/dist/Bubble/OpenAIMessageBubble/useOllamaMessageBubbleData.d.ts +7 -0
- package/dist/Bubble/OpenAIMessageBubble/useOllamaMessageBubbleData.js +23 -0
- package/dist/Bubble/OpenAIMessageBubble/useOpenAIMessageBubbleData.d.ts +6 -0
- package/dist/Bubble/OpenAIMessageBubble/useOpenAIMessageBubbleData.js +20 -0
- package/dist/Bubble/OpenAIMessageBubble/useOpenClawMessageBubbleData.d.ts +7 -0
- package/dist/Bubble/OpenAIMessageBubble/useOpenClawMessageBubbleData.js +22 -0
- package/dist/Bubble/index.d.ts +2 -0
- package/dist/Bubble/index.js +1 -0
- package/dist/Hooks/useAutoScroll.js +6 -4
- package/dist/MarkdownEditor/BaseMarkdownEditor.d.ts +1 -50
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +11 -55
- package/dist/MarkdownEditor/editor/Editor.js +35 -21
- package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -0
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +5 -1
- package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.js +24 -8
- package/dist/MarkdownEditor/editor/elements/index.js +18 -14
- package/dist/MarkdownEditor/editor/plugins/elements.d.ts +2 -0
- package/dist/MarkdownEditor/editor/plugins/elements.js +4 -2
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +46 -35
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +133 -133
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +156 -140
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.d.ts +2 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +23 -4
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +40 -36
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +46 -44
- package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.js +1 -13
- package/dist/MarkdownEditor/editor/store.d.ts +15 -1
- package/dist/MarkdownEditor/editor/store.js +45 -34
- package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +15 -11
- package/dist/MarkdownEditor/editor/utils/editorCommands.js +98 -17
- package/dist/MarkdownEditor/editor/utils/editorUtils.d.ts +11 -0
- package/dist/MarkdownEditor/editor/utils/editorUtils.js +43 -6
- package/dist/MarkdownEditor/editor/utils/keyboard.js +14 -12
- package/dist/MarkdownEditor/types.d.ts +36 -414
- package/dist/MarkdownEditor/types.js +1 -4
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +1 -1
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +4 -5
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.d.ts +1 -1
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +1 -1
- package/dist/MarkdownInputField/MarkdownInputField.js +8 -1
- package/dist/MarkdownInputField/SendActions/index.js +7 -4
- package/dist/MarkdownInputField/SendButton/index.d.ts +6 -0
- package/dist/MarkdownInputField/SendButton/index.js +6 -0
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +2 -1
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +12 -3
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.d.ts +1 -0
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +36 -5
- package/dist/MarkdownInputField/utils/renderHelpers.js +5 -0
- package/dist/MarkdownRenderer/AnimationText.d.ts +1 -5
- package/dist/MarkdownRenderer/AnimationText.js +2 -8
- package/dist/MarkdownRenderer/CharacterQueue.d.ts +0 -2
- package/dist/MarkdownRenderer/CharacterQueue.js +2 -2
- package/dist/MarkdownRenderer/FncRefForMarkdown.d.ts +24 -0
- package/dist/MarkdownRenderer/FncRefForMarkdown.js +65 -0
- package/dist/MarkdownRenderer/MarkdownRenderer.d.ts +1 -9
- package/dist/MarkdownRenderer/MarkdownRenderer.js +25 -18
- package/dist/MarkdownRenderer/StreamingCursor.d.ts +4 -0
- package/dist/MarkdownRenderer/StreamingCursor.js +20 -0
- package/dist/MarkdownRenderer/extractFootnoteDefinitions.d.ts +13 -0
- package/dist/MarkdownRenderer/extractFootnoteDefinitions.js +40 -0
- package/dist/MarkdownRenderer/markdownReactShared.d.ts +11 -38
- package/dist/MarkdownRenderer/markdownReactShared.js +28 -54
- package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -1
- package/dist/MarkdownRenderer/renderers/CodeRenderer.d.ts +4 -1
- package/dist/MarkdownRenderer/renderers/CodeRenderer.js +27 -3
- package/dist/MarkdownRenderer/renderers/SchemaRenderer.d.ts +2 -0
- package/dist/MarkdownRenderer/renderers/SchemaRenderer.js +33 -5
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -3
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +16 -28
- package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +2 -1
- package/dist/MarkdownRenderer/style.js +18 -0
- package/dist/MarkdownRenderer/types.d.ts +17 -93
- package/dist/MarkdownRenderer/useMarkdownToReact.js +1 -1
- package/dist/MarkdownRenderer/useStreaming.d.ts +1 -10
- package/dist/MarkdownRenderer/useStreaming.js +5 -13
- package/dist/Plugins/mermaid/MermaidRendererImpl.js +481 -7
- package/dist/Plugins/mermaid/style.js +71 -22
- package/dist/Plugins/mermaid/useMermaidRender.d.ts +2 -1
- package/dist/Plugins/mermaid/useMermaidRender.js +41 -13
- package/dist/Plugins/mermaid/utils.d.ts +16 -0
- package/dist/Plugins/mermaid/utils.js +197 -5
- package/dist/ThoughtChainList/MarkdownEditor.d.ts +1 -35
- package/dist/ThoughtChainList/MarkdownEditor.js +5 -44
- package/dist/Workspace/Browser/index.js +19 -1
- package/dist/Workspace/RealtimeFollow/index.d.ts +3 -0
- package/dist/Workspace/RealtimeFollow/index.js +5 -3
- package/package.json +8 -7
|
@@ -1,77 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MarkdownEditorProps } from '../../';
|
|
3
3
|
import { MessageBubbleData } from '../type';
|
|
4
|
-
/**
|
|
5
|
-
* MarkdownPreview 组件用于渲染 Markdown 内容的预览。
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} props - 组件的属性。
|
|
8
|
-
* @param {string} props.content - 要渲染的 Markdown 内容。
|
|
9
|
-
* @param {MarkdownEditorProps['fncProps']} props.fncProps - Markdown 编辑器的函数属性。
|
|
10
|
-
* @param {boolean} [props.typing] - 是否启用打字机效果。
|
|
11
|
-
* @param {React.ReactNode} props.extra - 额外的 React 节点。
|
|
12
|
-
* @param {React.ReactNode} props.docListNode - 文档列表节点。
|
|
13
|
-
* @param {React.RefObject<HTMLDivElement>} props.htmlRef - HTML 元素的引用。
|
|
14
|
-
*
|
|
15
|
-
* @returns {JSX.Element} 渲染的 Markdown 预览组件。
|
|
16
|
-
*/
|
|
17
4
|
export interface MarkdownPreviewProps {
|
|
18
|
-
/** markdown 源文本内容,例如: "# 标题\n这是正文" */
|
|
19
5
|
content: string;
|
|
20
|
-
/** markdown 编辑器的功能属性配置,控制编辑器行为 */
|
|
21
6
|
fncProps?: MarkdownEditorProps['fncProps'];
|
|
22
7
|
placement?: 'left' | 'right';
|
|
23
|
-
/** 是否启用打字机效果,例如: true */
|
|
24
8
|
typing?: boolean;
|
|
25
|
-
/** 额外的 React 节点,用于显示附加内容,例如: <Button>更多</Button> */
|
|
26
9
|
extra?: React.ReactNode;
|
|
27
|
-
/** 文档列表节点,用于展示相关文档,例如: <DocList items={[...]} /> */
|
|
28
10
|
docListNode?: React.ReactNode;
|
|
29
|
-
/** HTML 元素的引用,用于获取容器尺寸,例如: useRef<HTMLDivElement>(null) */
|
|
30
11
|
htmlRef?: React.RefObject<HTMLDivElement>;
|
|
31
|
-
/** 内容是否已完成加载,例如: true */
|
|
32
12
|
isFinished?: boolean;
|
|
33
13
|
style?: React.CSSProperties;
|
|
34
14
|
originData?: MessageBubbleData;
|
|
35
15
|
markdownRenderConfig?: MarkdownEditorProps;
|
|
36
|
-
/** 在 content 前面插入的 DOM 元素,例如: <div>前置内容</div> */
|
|
37
16
|
beforeContent: React.ReactNode;
|
|
38
|
-
/** 在 content 后面插入的 DOM 元素,例如: <div>后置内容</div> */
|
|
39
17
|
afterContent: React.ReactNode;
|
|
40
18
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Markdown 预览组件
|
|
43
|
-
* @component MarkdownPreview
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} props - 组件属性
|
|
46
|
-
* @param {string} props.content - Markdown 内容
|
|
47
|
-
* @param {ReactNode} props.extra - 额外的内容
|
|
48
|
-
* @param {boolean} props.typing - 是否正在输入
|
|
49
|
-
* @param {React.RefObject} props.htmlRef - HTML 元素的引用
|
|
50
|
-
* @param {Object} props.fncProps - 功能属性
|
|
51
|
-
* @param {ReactNode} props.docListNode - 文档列表节点
|
|
52
|
-
* @param {boolean} props.isFinished - 内容是否已完成
|
|
53
|
-
* @param {ReactNode} props.beforeContent - 在 content 前面插入的 DOM 元素
|
|
54
|
-
* @param {ReactNode} props.afterContent - 在 content 后面插入的 DOM 元素
|
|
55
|
-
*
|
|
56
|
-
* @description
|
|
57
|
-
* 这是一个用于渲染 Markdown 内容的预览组件。它支持以下功能:
|
|
58
|
-
* - 普通 Markdown 渲染
|
|
59
|
-
* - 支持打字机效果
|
|
60
|
-
* - 错误边界处理
|
|
61
|
-
* - 支持 Apaasify 自定义渲染
|
|
62
|
-
* - 支持紧凑模式和标准模式
|
|
63
|
-
* - 支持弹出层展示额外内容
|
|
64
|
-
* - 支持在 content 前后插入自定义 DOM 元素
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```tsx
|
|
68
|
-
* <MarkdownPreview
|
|
69
|
-
* content="# Hello World"
|
|
70
|
-
* typing={false}
|
|
71
|
-
* htmlRef={ref}
|
|
72
|
-
* beforeContent={<div>前置内容</div>}
|
|
73
|
-
* afterContent={<div>后置内容</div>}
|
|
74
|
-
* />
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
19
|
export declare const MarkdownPreview: (props: MarkdownPreviewProps) => React.JSX.Element;
|
|
@@ -50,7 +50,7 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
-
import { Popover
|
|
53
|
+
import { Popover } from "antd";
|
|
54
54
|
import React, { useContext, useEffect, useMemo } from "react";
|
|
55
55
|
import { ErrorBoundary } from "react-error-boundary";
|
|
56
56
|
import { MarkdownEditor, parserMdToSchema } from "../..";
|
|
@@ -58,98 +58,69 @@ import { useLocale } from "../../I18n";
|
|
|
58
58
|
import { MarkdownRenderer } from "../../MarkdownRenderer";
|
|
59
59
|
import { BubbleConfigContext } from "../BubbleConfigProvide";
|
|
60
60
|
import { MessagesContext } from "./BubbleContext";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* @description
|
|
77
|
-
* 这是一个用于渲染 Markdown 内容的预览组件。它支持以下功能:
|
|
78
|
-
* - 普通 Markdown 渲染
|
|
79
|
-
* - 支持打字机效果
|
|
80
|
-
* - 错误边界处理
|
|
81
|
-
* - 支持 Apaasify 自定义渲染
|
|
82
|
-
* - 支持紧凑模式和标准模式
|
|
83
|
-
* - 支持弹出层展示额外内容
|
|
84
|
-
* - 支持在 content 前后插入自定义 DOM 元素
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```tsx
|
|
88
|
-
* <MarkdownPreview
|
|
89
|
-
* content="# Hello World"
|
|
90
|
-
* typing={false}
|
|
91
|
-
* htmlRef={ref}
|
|
92
|
-
* beforeContent={<div>前置内容</div>}
|
|
93
|
-
* afterContent={<div>后置内容</div>}
|
|
94
|
-
* />
|
|
95
|
-
* ```
|
|
96
|
-
*/ export var MarkdownPreview = function MarkdownPreview(props) {
|
|
97
|
-
var _ref, _ref1, _ref2;
|
|
98
|
-
var _props_markdownRenderConfig, _props_markdownRenderConfig1, _props_originData, _props_originData1, _props_originData2;
|
|
61
|
+
var CONTAINER_STYLE = {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
minWidth: 0,
|
|
65
|
+
maxWidth: '100%'
|
|
66
|
+
};
|
|
67
|
+
var POPOVER_SHARED_STYLE = {
|
|
68
|
+
padding: 0,
|
|
69
|
+
borderRadius: 'var(--radius-control-sm)',
|
|
70
|
+
background: 'var(--color-primary-bg-page)',
|
|
71
|
+
boxShadow: 'var(--shadow-control-base)'
|
|
72
|
+
};
|
|
73
|
+
export var MarkdownPreview = function MarkdownPreview(props) {
|
|
74
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
|
|
75
|
+
var _props_originData, _props_originData1, _props_originData2, _props_originData3;
|
|
99
76
|
var content = props.content, extra = props.extra, typing = props.typing, htmlRef = props.htmlRef, fncProps = props.fncProps, docListNode = props.docListNode, beforeContent = props.beforeContent, afterContent = props.afterContent;
|
|
100
|
-
var
|
|
77
|
+
var editorRef = React.useRef(undefined);
|
|
101
78
|
var hidePadding = (useContext(MessagesContext) || {}).hidePadding;
|
|
102
79
|
var config = useContext(BubbleConfigContext);
|
|
103
80
|
var locale = useLocale();
|
|
104
81
|
var standalone = config === null || config === void 0 ? void 0 : config.standalone;
|
|
105
82
|
var extraShowOnHover = config === null || config === void 0 ? void 0 : config.extraShowOnHover;
|
|
106
|
-
var
|
|
107
|
-
var renderMode = (_ref = (_ref1 =
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
}, [
|
|
112
|
-
extra,
|
|
113
|
-
typing
|
|
114
|
-
]);
|
|
83
|
+
var rc = props.markdownRenderConfig;
|
|
84
|
+
var renderMode = (_ref = (_ref1 = rc === null || rc === void 0 ? void 0 : rc.renderMode) !== null && _ref1 !== void 0 ? _ref1 : rc === null || rc === void 0 ? void 0 : rc.renderType) !== null && _ref !== void 0 ? _ref : 'slate';
|
|
85
|
+
var isStreaming = ((_ref2 = (_ref3 = rc === null || rc === void 0 ? void 0 : rc.streaming) !== null && _ref3 !== void 0 ? _ref3 : rc === null || rc === void 0 ? void 0 : rc.typewriter) !== null && _ref2 !== void 0 ? _ref2 : Boolean(typing)) && ((_ref4 = (_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isLast) !== null && _ref4 !== void 0 ? _ref4 : true);
|
|
86
|
+
var isFinished = (_ref5 = (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isFinished) !== null && _ref5 !== void 0 ? _ref5 : props.isFinished;
|
|
87
|
+
var noPadding = !!extra;
|
|
115
88
|
useEffect(function() {
|
|
116
|
-
var
|
|
89
|
+
var _editorRef_current;
|
|
117
90
|
if (renderMode !== 'slate') return;
|
|
118
|
-
|
|
119
|
-
(_MarkdownEditorRef_current = MarkdownEditorRef.current) === null || _MarkdownEditorRef_current === void 0 ? void 0 : _MarkdownEditorRef_current.store.updateNodeList(schema);
|
|
91
|
+
(_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.store.updateNodeList(parserMdToSchema(content).schema);
|
|
120
92
|
}, [
|
|
121
93
|
content,
|
|
122
94
|
renderMode
|
|
123
95
|
]);
|
|
124
96
|
var markdown = useMemo(function() {
|
|
125
|
-
var
|
|
126
|
-
var _content_includes, _htmlRef_current, _htmlRef_current1, _props_markdownRenderConfig, _props_originData, _props_originData1, _props_originData2, _props_markdownRenderConfig1, _props_markdownRenderConfig2, _props_originData3, _props_markdownRenderConfig3;
|
|
127
|
-
// MarkdownRenderer 渲染路径——轻量,不创建 Slate 实例
|
|
97
|
+
var _content_includes, _htmlRef_current, _htmlRef_current1, _props_originData, _props_originData1, _props_originData2;
|
|
128
98
|
if (renderMode === 'markdown') {
|
|
129
|
-
var _props_originData4, _props_markdownRenderConfig4, _props_markdownRenderConfig5, _props_markdownRenderConfig6, _props_markdownRenderConfig7, _props_markdownRenderConfig8, _props_markdownRenderConfig9, _props_markdownRenderConfig10;
|
|
130
99
|
return /*#__PURE__*/ React.createElement(MarkdownRenderer, {
|
|
131
100
|
content: content,
|
|
132
|
-
streaming:
|
|
133
|
-
isFinished:
|
|
134
|
-
plugins:
|
|
135
|
-
|
|
136
|
-
|
|
101
|
+
streaming: isStreaming,
|
|
102
|
+
isFinished: isFinished,
|
|
103
|
+
plugins: rc === null || rc === void 0 ? void 0 : rc.plugins,
|
|
104
|
+
remarkPlugins: rc === null || rc === void 0 ? void 0 : rc.markdownToHtmlOptions,
|
|
105
|
+
queueOptions: rc === null || rc === void 0 ? void 0 : rc.queueOptions,
|
|
106
|
+
streamingParagraphAnimation: rc === null || rc === void 0 ? void 0 : rc.streamingParagraphAnimation,
|
|
137
107
|
fncProps: fncProps,
|
|
108
|
+
linkConfig: rc === null || rc === void 0 ? void 0 : rc.linkConfig,
|
|
109
|
+
codeProps: rc === null || rc === void 0 ? void 0 : rc.codeProps,
|
|
110
|
+
apaasify: rc === null || rc === void 0 ? void 0 : rc.apaasify,
|
|
111
|
+
fileMapConfig: rc === null || rc === void 0 ? void 0 : rc.fileMapConfig,
|
|
112
|
+
eleRender: rc === null || rc === void 0 ? void 0 : rc.eleRender,
|
|
138
113
|
style: _object_spread({
|
|
139
114
|
maxWidth: standalone ? '100%' : undefined,
|
|
140
|
-
padding:
|
|
141
|
-
margin:
|
|
142
|
-
}, (
|
|
143
|
-
codeProps: (_props_markdownRenderConfig8 = props.markdownRenderConfig) === null || _props_markdownRenderConfig8 === void 0 ? void 0 : _props_markdownRenderConfig8.codeProps,
|
|
144
|
-
apaasify: (_props_markdownRenderConfig9 = props.markdownRenderConfig) === null || _props_markdownRenderConfig9 === void 0 ? void 0 : _props_markdownRenderConfig9.apaasify,
|
|
145
|
-
fileMapConfig: (_props_markdownRenderConfig10 = props.markdownRenderConfig) === null || _props_markdownRenderConfig10 === void 0 ? void 0 : _props_markdownRenderConfig10.fileMapConfig
|
|
115
|
+
padding: noPadding ? 0 : undefined,
|
|
116
|
+
margin: noPadding ? 0 : undefined
|
|
117
|
+
}, (rc === null || rc === void 0 ? void 0 : rc.style) || {})
|
|
146
118
|
});
|
|
147
119
|
}
|
|
148
|
-
// Slate 渲染路径——保持向后兼容
|
|
149
120
|
var minWidth = (content === null || content === void 0 ? void 0 : (_content_includes = content.includes) === null || _content_includes === void 0 ? void 0 : _content_includes.call(content, 'chartType')) ? standalone ? Math.max(((htmlRef === null || htmlRef === void 0 ? void 0 : (_htmlRef_current = htmlRef.current) === null || _htmlRef_current === void 0 ? void 0 : _htmlRef_current.clientWidth) || 600) - 23, 500) : Math.min(((htmlRef === null || htmlRef === void 0 ? void 0 : (_htmlRef_current1 = htmlRef.current) === null || _htmlRef_current1 === void 0 ? void 0 : _htmlRef_current1.clientWidth) || 600) - 128, 500) : undefined;
|
|
150
|
-
return /*#__PURE__*/ React.createElement(MarkdownEditor, _object_spread_props(_object_spread({},
|
|
121
|
+
return /*#__PURE__*/ React.createElement(MarkdownEditor, _object_spread_props(_object_spread({}, rc || {}), {
|
|
151
122
|
fncProps: fncProps,
|
|
152
|
-
editorRef:
|
|
123
|
+
editorRef: editorRef,
|
|
153
124
|
initValue: content,
|
|
154
125
|
toc: false,
|
|
155
126
|
width: "100%",
|
|
@@ -159,7 +130,7 @@ import { MessagesContext } from "./BubbleContext";
|
|
|
159
130
|
actions: {
|
|
160
131
|
fullScreen: 'modal'
|
|
161
132
|
}
|
|
162
|
-
}, (
|
|
133
|
+
}, (rc === null || rc === void 0 ? void 0 : rc.tableConfig) || {}),
|
|
163
134
|
deps: [
|
|
164
135
|
String((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isLast),
|
|
165
136
|
String((_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isFinished),
|
|
@@ -168,116 +139,69 @@ import { MessagesContext } from "./BubbleContext";
|
|
|
168
139
|
rootContainer: htmlRef,
|
|
169
140
|
editorStyle: _object_spread({
|
|
170
141
|
fontSize: 14
|
|
171
|
-
}, (
|
|
172
|
-
|
|
142
|
+
}, (rc === null || rc === void 0 ? void 0 : rc.editorStyle) || {}),
|
|
143
|
+
streaming: isStreaming,
|
|
173
144
|
style: _object_spread({
|
|
174
145
|
minWidth: minWidth ? "min(".concat(minWidth, "px,100%)") : undefined,
|
|
175
146
|
maxWidth: standalone ? '100%' : undefined,
|
|
176
|
-
padding:
|
|
177
|
-
margin:
|
|
178
|
-
}, (
|
|
147
|
+
padding: noPadding ? 0 : undefined,
|
|
148
|
+
margin: noPadding ? 0 : undefined
|
|
149
|
+
}, (rc === null || rc === void 0 ? void 0 : rc.style) || {}),
|
|
179
150
|
readonly: true
|
|
180
151
|
}));
|
|
181
152
|
}, [
|
|
182
153
|
hidePadding,
|
|
183
154
|
typing,
|
|
184
|
-
(
|
|
185
|
-
(
|
|
186
|
-
|
|
155
|
+
(_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : _props_originData2.isLast,
|
|
156
|
+
(_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : _props_originData3.isFinished,
|
|
157
|
+
noPadding,
|
|
187
158
|
content,
|
|
188
159
|
renderMode,
|
|
189
|
-
|
|
160
|
+
rc,
|
|
190
161
|
fncProps,
|
|
191
162
|
standalone
|
|
192
163
|
]);
|
|
193
164
|
var errorDom = /*#__PURE__*/ React.createElement("div", {
|
|
194
165
|
style: {
|
|
195
166
|
padding: 'var(--padding-5x)',
|
|
196
|
-
background: ' #
|
|
197
|
-
color:
|
|
167
|
+
background: 'var(--ant-color-bg-container, #fff)',
|
|
168
|
+
color: 'var(--ant-color-error, #ff4d4f)',
|
|
198
169
|
borderRadius: '16px 16px 2px 16px',
|
|
199
|
-
border: '1px solid '
|
|
170
|
+
border: '1px solid var(--ant-color-error-border, #ffccc7)',
|
|
200
171
|
marginLeft: props.placement === 'right' ? 0 : 24,
|
|
201
172
|
marginRight: props.placement === 'right' ? 24 : 0
|
|
202
173
|
}
|
|
203
174
|
}, (locale === null || locale === void 0 ? void 0 : locale['error.unexpected']) || '出现点意外情况,请重新发送');
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
minWidth: 0,
|
|
211
|
-
maxWidth: '100%'
|
|
212
|
-
}
|
|
213
|
-
}, /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
214
|
-
fallback: errorDom
|
|
215
|
-
}, beforeContent, markdown, docListNode, afterContent), extra);
|
|
216
|
-
}
|
|
217
|
-
// extraShowOnHover 开启时,无 extra 直接返回内容,避免 hover 出现空浮层
|
|
218
|
-
// 生成中(typing)时不使用 Popover,避免 hover 展示 extra
|
|
219
|
-
if (!extra || typing) {
|
|
220
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
221
|
-
style: {
|
|
222
|
-
display: 'flex',
|
|
223
|
-
flexDirection: 'column',
|
|
224
|
-
minWidth: 0,
|
|
225
|
-
maxWidth: '100%'
|
|
226
|
-
}
|
|
227
|
-
}, /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
228
|
-
fallback: errorDom
|
|
229
|
-
}, beforeContent, markdown, docListNode, afterContent));
|
|
230
|
-
}
|
|
231
|
-
// extraShowOnHover 开启时,左右两侧均通过 Popover 在 hover 时展示 extra
|
|
175
|
+
var body = /*#__PURE__*/ React.createElement("div", {
|
|
176
|
+
style: CONTAINER_STYLE
|
|
177
|
+
}, /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
178
|
+
fallback: errorDom
|
|
179
|
+
}, beforeContent, markdown, docListNode, afterContent), !extraShowOnHover && extra);
|
|
180
|
+
if (!extraShowOnHover || !extra || typing) return body;
|
|
232
181
|
var isLeft = props.placement === 'left';
|
|
233
|
-
var popoverAlign = isLeft ? {
|
|
234
|
-
points: [
|
|
235
|
-
'tl',
|
|
236
|
-
'bl'
|
|
237
|
-
],
|
|
238
|
-
offset: [
|
|
239
|
-
0,
|
|
240
|
-
-12
|
|
241
|
-
]
|
|
242
|
-
} : {
|
|
243
|
-
points: [
|
|
244
|
-
'tr',
|
|
245
|
-
'br'
|
|
246
|
-
],
|
|
247
|
-
offset: [
|
|
248
|
-
0,
|
|
249
|
-
-12
|
|
250
|
-
]
|
|
251
|
-
};
|
|
252
|
-
var popoverPlacement = isLeft ? 'bottomLeft' : 'bottomRight';
|
|
253
182
|
return /*#__PURE__*/ React.createElement(Popover, {
|
|
254
183
|
trigger: "hover",
|
|
255
|
-
align:
|
|
184
|
+
align: {
|
|
185
|
+
points: isLeft ? [
|
|
186
|
+
'tl',
|
|
187
|
+
'bl'
|
|
188
|
+
] : [
|
|
189
|
+
'tr',
|
|
190
|
+
'br'
|
|
191
|
+
],
|
|
192
|
+
offset: [
|
|
193
|
+
0,
|
|
194
|
+
-12
|
|
195
|
+
]
|
|
196
|
+
},
|
|
256
197
|
content: extra,
|
|
257
198
|
styles: {
|
|
258
|
-
root:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
boxShadow: 'var(--shadow-control-base)'
|
|
263
|
-
},
|
|
264
|
-
body: {
|
|
265
|
-
padding: 'var(--padding-0-5x)',
|
|
266
|
-
borderRadius: 'var(--radius-control-sm)',
|
|
267
|
-
background: 'var(--color-primary-bg-page)',
|
|
268
|
-
boxShadow: 'var(--shadow-control-base)'
|
|
269
|
-
}
|
|
199
|
+
root: POPOVER_SHARED_STYLE,
|
|
200
|
+
body: _object_spread_props(_object_spread({}, POPOVER_SHARED_STYLE), {
|
|
201
|
+
padding: 'var(--padding-0-5x)'
|
|
202
|
+
})
|
|
270
203
|
},
|
|
271
204
|
arrow: false,
|
|
272
|
-
placement:
|
|
273
|
-
},
|
|
274
|
-
style: {
|
|
275
|
-
display: 'flex',
|
|
276
|
-
flexDirection: 'column',
|
|
277
|
-
minWidth: 0,
|
|
278
|
-
maxWidth: '100%'
|
|
279
|
-
}
|
|
280
|
-
}, /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
281
|
-
fallback: errorDom
|
|
282
|
-
}, beforeContent, markdown, docListNode, afterContent)));
|
|
205
|
+
placement: isLeft ? 'bottomLeft' : 'bottomRight'
|
|
206
|
+
}, body);
|
|
283
207
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { mapOpenAIMessagesToMessageBubbleData } from './mapOpenAIMessages';
|
|
2
|
+
export { mapOpenClawMessagesToMessageBubbleData } from './mapOpenClawMessages';
|
|
3
|
+
export { mapOllamaMessagesToMessageBubbleData } from './mapOllamaMessages';
|
|
4
|
+
export { normalizeOpenClawMessageToOpenAI, normalizeOpenClawMessagesToOpenAI, } from './normalizeOpenClawMessages';
|
|
5
|
+
export { normalizeOllamaMessageToOpenAI, normalizeOllamaMessagesToOpenAI, } from './normalizeOllamaMessages';
|
|
6
|
+
export { useOpenAIMessageBubbleData } from './useOpenAIMessageBubbleData';
|
|
7
|
+
export { useOpenClawMessageBubbleData } from './useOpenClawMessageBubbleData';
|
|
8
|
+
export { useOllamaMessageBubbleData } from './useOllamaMessageBubbleData';
|
|
9
|
+
export type { OpenAIChatContentPart, OpenAIChatContentPartFallback, OpenAIChatMessage, OpenAIChatMessageAssistant, OpenAIChatMessageFunction, OpenAIChatMessageSystem, OpenAIChatMessageTool, OpenAIChatMessageUser, OpenAIChatRefusalPart, OpenAIChatTextPart, OpenAIMessagesMapMessage, OpenAIMessagesMapOptions, } from './types';
|
|
10
|
+
export type { OpenClawChatMessage, OpenClawChatMessageToolResult, OpenClawChatMeta, OpenClawMessagesMapOptions, } from './openClawTypes';
|
|
11
|
+
export type { OllamaChatMessage, OllamaMessagesMapOptions, OllamaToolCall, } from './ollamaTypes';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { mapOpenAIMessagesToMessageBubbleData } from "./mapOpenAIMessages";
|
|
2
|
+
export { mapOpenClawMessagesToMessageBubbleData } from "./mapOpenClawMessages";
|
|
3
|
+
export { mapOllamaMessagesToMessageBubbleData } from "./mapOllamaMessages";
|
|
4
|
+
export { normalizeOpenClawMessageToOpenAI, normalizeOpenClawMessagesToOpenAI } from "./normalizeOpenClawMessages";
|
|
5
|
+
export { normalizeOllamaMessageToOpenAI, normalizeOllamaMessagesToOpenAI } from "./normalizeOllamaMessages";
|
|
6
|
+
export { useOpenAIMessageBubbleData } from "./useOpenAIMessageBubbleData";
|
|
7
|
+
export { useOpenClawMessageBubbleData } from "./useOpenClawMessageBubbleData";
|
|
8
|
+
export { useOllamaMessageBubbleData } from "./useOllamaMessageBubbleData";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MessageBubbleData } from '../../Types/message';
|
|
2
|
+
import type { OpenAIMessagesMapMessage } from './types';
|
|
3
|
+
import type { OllamaChatMessage, OllamaMessagesMapOptions } from './ollamaTypes';
|
|
4
|
+
/**
|
|
5
|
+
* 将 Ollama `/api/chat` 的 `messages` 转为 `MessageBubbleData[]`
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapOllamaMessagesToMessageBubbleData(messages: OllamaChatMessage[], options?: OllamaMessagesMapOptions, mapMessage?: OpenAIMessagesMapMessage): MessageBubbleData[];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
function _object_without_properties(source, excluded) {
|
|
54
|
+
if (source == null) return {};
|
|
55
|
+
var target = {}, sourceKeys, key, i;
|
|
56
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
57
|
+
sourceKeys = Reflect.ownKeys(source);
|
|
58
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
59
|
+
key = sourceKeys[i];
|
|
60
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
61
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
target = _object_without_properties_loose(source, excluded);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
70
|
+
key = sourceKeys[i];
|
|
71
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
72
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
73
|
+
target[key] = source[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return target;
|
|
77
|
+
}
|
|
78
|
+
function _object_without_properties_loose(source, excluded) {
|
|
79
|
+
if (source == null) return {};
|
|
80
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
81
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
82
|
+
key = sourceKeys[i];
|
|
83
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
85
|
+
target[key] = source[key];
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
import { mapOpenAIMessagesToMessageBubbleData } from "./mapOpenAIMessages";
|
|
90
|
+
import { normalizeOllamaMessagesToOpenAI } from "./normalizeOllamaMessages";
|
|
91
|
+
function defaultOllamaGetMessageId(msg, index, originals) {
|
|
92
|
+
var _ref, _ref1;
|
|
93
|
+
var _originals_index;
|
|
94
|
+
return (_ref = (_ref1 = (_originals_index = originals[index]) === null || _originals_index === void 0 ? void 0 : _originals_index.id) !== null && _ref1 !== void 0 ? _ref1 : msg.id) !== null && _ref !== void 0 ? _ref : "ollama-msg-".concat(index);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 将 Ollama `/api/chat` 的 `messages` 转为 `MessageBubbleData[]`
|
|
98
|
+
*/ export function mapOllamaMessagesToMessageBubbleData(messages, options, mapMessage) {
|
|
99
|
+
var _ref = options !== null && options !== void 0 ? options : {}, _ref_appendThinkingToContent = _ref.appendThinkingToContent, appendThinkingToContent = _ref_appendThinkingToContent === void 0 ? true : _ref_appendThinkingToContent, _ref_appendImagesPlaceholder = _ref.appendImagesPlaceholder, appendImagesPlaceholder = _ref_appendImagesPlaceholder === void 0 ? true : _ref_appendImagesPlaceholder, _ref_preserveOllamaRawInExtra = _ref.preserveOllamaRawInExtra, preserveOllamaRawInExtra = _ref_preserveOllamaRawInExtra === void 0 ? true : _ref_preserveOllamaRawInExtra, userGetMessageId = _ref.getMessageId, rest = _object_without_properties(_ref, [
|
|
100
|
+
"appendThinkingToContent",
|
|
101
|
+
"appendImagesPlaceholder",
|
|
102
|
+
"preserveOllamaRawInExtra",
|
|
103
|
+
"getMessageId"
|
|
104
|
+
]);
|
|
105
|
+
var openai = normalizeOllamaMessagesToOpenAI(messages, {
|
|
106
|
+
appendThinkingToContent: appendThinkingToContent,
|
|
107
|
+
appendImagesPlaceholder: appendImagesPlaceholder
|
|
108
|
+
});
|
|
109
|
+
var getMessageId = userGetMessageId !== null && userGetMessageId !== void 0 ? userGetMessageId : function(msg, index) {
|
|
110
|
+
return defaultOllamaGetMessageId(msg, index, messages);
|
|
111
|
+
};
|
|
112
|
+
if (!preserveOllamaRawInExtra && !mapMessage) {
|
|
113
|
+
return mapOpenAIMessagesToMessageBubbleData(openai, _object_spread_props(_object_spread({}, rest), {
|
|
114
|
+
getMessageId: getMessageId
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
var innerMap = function innerMap(msg, index, draft) {
|
|
118
|
+
var d = draft;
|
|
119
|
+
if (preserveOllamaRawInExtra && messages[index]) {
|
|
120
|
+
d = _object_spread_props(_object_spread({}, d), {
|
|
121
|
+
extra: _object_spread_props(_object_spread({}, d.extra), {
|
|
122
|
+
ollama: {
|
|
123
|
+
raw: messages[index]
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (mapMessage) {
|
|
129
|
+
d = mapMessage(msg, index, d);
|
|
130
|
+
}
|
|
131
|
+
return d;
|
|
132
|
+
};
|
|
133
|
+
return mapOpenAIMessagesToMessageBubbleData(openai, _object_spread_props(_object_spread({}, rest), {
|
|
134
|
+
getMessageId: getMessageId
|
|
135
|
+
}), innerMap);
|
|
136
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MessageBubbleData } from '../../Types/message';
|
|
2
|
+
import type { OpenAIChatContentPart, OpenAIChatMessage, OpenAIMessagesMapMessage, OpenAIMessagesMapOptions } from './types';
|
|
3
|
+
/** @internal exported for OpenClaw 归一化复用 */
|
|
4
|
+
export declare function extractTextFromContent(content: string | OpenAIChatContentPart[] | null | undefined): string;
|
|
5
|
+
/**
|
|
6
|
+
* 将 OpenAI Chat Completions 风格的 messages 转为 MessageBubbleData[]
|
|
7
|
+
*/
|
|
8
|
+
export declare function mapOpenAIMessagesToMessageBubbleData(messages: OpenAIChatMessage[], options?: OpenAIMessagesMapOptions, mapMessage?: OpenAIMessagesMapMessage): MessageBubbleData[];
|