@ant-design/agentic-ui 2.30.22 → 2.30.24
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 -156
- 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 +11 -9
- package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -0
- 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/index.d.ts +1 -0
- package/dist/MarkdownEditor/editor/plugins/index.js +1 -0
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +46 -44
- package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.js +1 -13
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +2 -1
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.d.ts +7 -0
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +217 -0
- package/dist/MarkdownEditor/editor/store.d.ts +3 -1
- package/dist/MarkdownEditor/editor/store.js +15 -29
- 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/MarkdownInputField.js +2 -0
- 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 +6 -1
- 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/MarkdownRenderer.d.ts +1 -9
- package/dist/MarkdownRenderer/MarkdownRenderer.js +1 -9
- package/dist/MarkdownRenderer/StreamingCursor.d.ts +4 -0
- package/dist/MarkdownRenderer/StreamingCursor.js +20 -0
- package/dist/MarkdownRenderer/markdownReactShared.d.ts +8 -38
- package/dist/MarkdownRenderer/markdownReactShared.js +9 -45
- package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -1
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -3
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +16 -28
- package/dist/MarkdownRenderer/style.js +18 -0
- package/dist/MarkdownRenderer/types.d.ts +14 -86
- package/dist/MarkdownRenderer/useStreaming.d.ts +1 -10
- package/dist/MarkdownRenderer/useStreaming.js +5 -13
- package/dist/ThoughtChainList/MarkdownEditor.d.ts +1 -35
- package/dist/ThoughtChainList/MarkdownEditor.js +5 -44
- package/dist/Workspace/RealtimeFollow/index.d.ts +3 -0
- package/dist/Workspace/RealtimeFollow/index.js +5 -3
- package/package.json +2 -2
|
@@ -10,23 +10,6 @@ import { EditorStore } from './editor/store';
|
|
|
10
10
|
import { InsertAutocompleteProps } from './editor/tools/InsertAutocomplete';
|
|
11
11
|
import type { MarkdownToHtmlOptions } from './editor/utils/markdownToHtml';
|
|
12
12
|
import { CustomLeaf, Elements } from './el';
|
|
13
|
-
/**
|
|
14
|
-
* @typedef CommentDataType
|
|
15
|
-
* @description 表示评论数据的类型。
|
|
16
|
-
*
|
|
17
|
-
* @property {Selection} selection - 用户选择的文本范围。
|
|
18
|
-
* @property {number[]} path - 文档中选择路径的数组。
|
|
19
|
-
* @property {number} anchorOffset - 选择范围的起始偏移量。
|
|
20
|
-
* @property {number} focusOffset - 选择范围的结束偏移量。
|
|
21
|
-
* @property {string} refContent - 参考内容。
|
|
22
|
-
* @property {string} commentType - 评论的类型。
|
|
23
|
-
* @property {string} content - 评论的内容。
|
|
24
|
-
* @property {number} time - 评论的时间戳。
|
|
25
|
-
* @property {string | number} id - 评论的唯一标识符。
|
|
26
|
-
* @property {Object} [user] - 用户信息(可选)。
|
|
27
|
-
* @property {string} user.name - 用户名。
|
|
28
|
-
* @property {string} [user.avatar] - 用户头像(可选)。
|
|
29
|
-
*/
|
|
30
13
|
export type CommentDataType = {
|
|
31
14
|
selection: Selection;
|
|
32
15
|
path: number[];
|
|
@@ -49,49 +32,30 @@ export type JinjaTemplateItem = {
|
|
|
49
32
|
description?: string;
|
|
50
33
|
template: string;
|
|
51
34
|
};
|
|
52
|
-
/**
|
|
35
|
+
/** 模板列表:静态数组或异步加载 */
|
|
53
36
|
export type JinjaTemplatePanelItems = JinjaTemplateItem[] | ((params?: {
|
|
54
37
|
editor?: Editor;
|
|
55
38
|
}) => Promise<JinjaTemplateItem[]>);
|
|
56
|
-
/** 模板面板配置(与 tag 配置做成一样,支持 items 异步) */
|
|
57
39
|
export interface JinjaTemplatePanelConfig {
|
|
58
|
-
/**
|
|
40
|
+
/** 默认 true */
|
|
59
41
|
enable?: boolean;
|
|
60
42
|
/** 触发符,默认 '{}' */
|
|
61
43
|
trigger?: string;
|
|
62
|
-
/**
|
|
63
|
-
* 模板列表:静态数组或异步加载
|
|
64
|
-
* 不传时使用内置 JINJA_TEMPLATE_DATA
|
|
65
|
-
*/
|
|
44
|
+
/** 不传时使用内置 JINJA_TEMPLATE_DATA */
|
|
66
45
|
items?: JinjaTemplatePanelItems;
|
|
67
|
-
/** 无数据时展示,同 TagPopupProps.notFoundContent */
|
|
68
46
|
notFoundContent?: React.ReactNode;
|
|
69
47
|
}
|
|
70
|
-
/** Jinja 配置:总开关、使用说明链接、模板面板 */
|
|
71
48
|
export interface JinjaConfig {
|
|
72
|
-
/**
|
|
49
|
+
/** 总开关:语法高亮 + 模板面板 */
|
|
73
50
|
enable: boolean;
|
|
74
|
-
/**
|
|
51
|
+
/** 使用说明链接 */
|
|
75
52
|
docLink?: string;
|
|
76
|
-
/** 模板面板配置(与 tag 配置做成一样,支持 items 异步) */
|
|
77
53
|
templatePanel?: boolean | JinjaTemplatePanelConfig;
|
|
78
54
|
}
|
|
79
|
-
/**
|
|
80
|
-
* 编辑器接口定义
|
|
81
|
-
* @interface IEditor
|
|
82
|
-
*
|
|
83
|
-
* @property {IEditor[]} [children] - 子编辑器列表
|
|
84
|
-
* @property {boolean} [expand] - 是否展开
|
|
85
|
-
* @property {any[]} [schema] - 编辑器模式配置
|
|
86
|
-
* @property {any} [history] - 编辑器历史记录
|
|
87
|
-
*/
|
|
88
55
|
export type IEditor = {
|
|
89
56
|
children?: IEditor[];
|
|
90
57
|
expand?: boolean;
|
|
91
58
|
};
|
|
92
|
-
/**
|
|
93
|
-
* MarkdownEditor 实例
|
|
94
|
-
*/
|
|
95
59
|
export interface MarkdownEditorInstance {
|
|
96
60
|
range?: any;
|
|
97
61
|
store: EditorStore;
|
|
@@ -99,96 +63,21 @@ export interface MarkdownEditorInstance {
|
|
|
99
63
|
markdownEditorRef: React.MutableRefObject<BaseEditor & ReactEditor & HistoryEditor>;
|
|
100
64
|
exportHtml: (filename?: string) => void;
|
|
101
65
|
}
|
|
102
|
-
/**
|
|
103
|
-
* MarkdownEditor 的 props
|
|
104
|
-
* @param props
|
|
105
|
-
*/
|
|
106
66
|
export type MarkdownEditorProps = {
|
|
107
|
-
/**
|
|
108
|
-
* 自定义 CSS 类名
|
|
109
|
-
* @description 用于为编辑器根容器添加自定义类名
|
|
110
|
-
* @example "my-markdown-editor"
|
|
111
|
-
*/
|
|
112
67
|
className?: string;
|
|
113
|
-
/**
|
|
114
|
-
* 编辑器宽度
|
|
115
|
-
* @description 支持字符串(如 '100%', '500px')或数字(像素值)
|
|
116
|
-
* @example "100%" | 800
|
|
117
|
-
*/
|
|
118
68
|
width?: string | number;
|
|
119
|
-
/**
|
|
120
|
-
* 编辑器高度
|
|
121
|
-
* @description 支持字符串(如 '100%', '500px')或数字(像素值)
|
|
122
|
-
* @example "100%" | 600
|
|
123
|
-
*/
|
|
124
69
|
height?: string | number;
|
|
125
|
-
/**
|
|
126
|
-
* 标签输入配置
|
|
127
|
-
* @description 配置标签输入组件的显示和行为
|
|
128
|
-
* @property {boolean} [enable] - 是否启用标签输入功能
|
|
129
|
-
* @property {string} [placeholder] - 标签输入框的占位符文本
|
|
130
|
-
* @property {'panel' | 'dropdown'} [type] - 标签输入组件的显示类型,'panel' 为面板模式,'dropdown' 为下拉模式
|
|
131
|
-
* @example
|
|
132
|
-
* ```tsx
|
|
133
|
-
* tagInputProps={{
|
|
134
|
-
* enable: true,
|
|
135
|
-
* placeholder: '输入标签...',
|
|
136
|
-
* type: 'dropdown'
|
|
137
|
-
* }}
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
70
|
tagInputProps?: {
|
|
141
71
|
enable?: boolean;
|
|
142
72
|
placeholder?: string;
|
|
143
73
|
type?: 'panel' | 'dropdown';
|
|
144
74
|
} & TagPopupProps;
|
|
145
|
-
/**
|
|
146
|
-
* 编辑器样式
|
|
147
|
-
* @description 自定义编辑器容器的内联样式
|
|
148
|
-
* @example { padding: '10px', backgroundColor: '#f5f5f5' }
|
|
149
|
-
*/
|
|
150
75
|
editorStyle?: React.CSSProperties;
|
|
151
|
-
/**
|
|
152
|
-
* 功能属性配置
|
|
153
|
-
* @description 提供自定义渲染和事件处理的能力
|
|
154
|
-
* @property {Function} render - 自定义节点渲染函数,用于覆盖默认的节点渲染逻辑
|
|
155
|
-
* @property {Function} [onOriginUrlClick] - 点击原文链接时的回调函数
|
|
156
|
-
* @property {Function} [onFootnoteDefinitionChange] - 脚注定义变更时的回调函数
|
|
157
|
-
* @example
|
|
158
|
-
* ```tsx
|
|
159
|
-
* fncProps={{
|
|
160
|
-
* render: (props, defaultDom) => {
|
|
161
|
-
* // 自定义渲染逻辑
|
|
162
|
-
* return <CustomNode {...props} />;
|
|
163
|
-
* },
|
|
164
|
-
* onOriginUrlClick: (url) => {
|
|
165
|
-
* window.open(url);
|
|
166
|
-
* },
|
|
167
|
-
* onFootnoteDefinitionChange: (data) => {
|
|
168
|
-
* console.log('脚注定义变更:', data);
|
|
169
|
-
* }
|
|
170
|
-
* }}
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
76
|
fncProps?: {
|
|
174
|
-
/**
|
|
175
|
-
* 自定义节点渲染函数
|
|
176
|
-
* @param props - 包含节点属性和子节点的对象
|
|
177
|
-
* @param defaultDom - 默认的 DOM 渲染结果
|
|
178
|
-
* @returns 自定义渲染的 React 节点
|
|
179
|
-
*/
|
|
180
77
|
render: (props: CustomLeaf<Record<string, any>> & {
|
|
181
78
|
children: React.ReactNode;
|
|
182
79
|
}, defaultDom: React.ReactNode) => React.ReactNode;
|
|
183
|
-
/**
|
|
184
|
-
* 点击原文链接的回调函数
|
|
185
|
-
* @param url - 原文链接地址
|
|
186
|
-
*/
|
|
187
80
|
onOriginUrlClick?: (url?: string) => void;
|
|
188
|
-
/**
|
|
189
|
-
* 脚注定义变更的回调函数
|
|
190
|
-
* @param data - 脚注定义数据数组,包含 id、placeholder、origin_text、url、origin_url 等信息
|
|
191
|
-
*/
|
|
192
81
|
onFootnoteDefinitionChange?: (data: {
|
|
193
82
|
id: any;
|
|
194
83
|
placeholder: any;
|
|
@@ -198,70 +87,26 @@ export type MarkdownEditorProps = {
|
|
|
198
87
|
}[]) => void;
|
|
199
88
|
};
|
|
200
89
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* 支持配置代码块的显示和编辑行为,基于 Ace Editor。
|
|
90
|
+
* 代码块配置,基于 Ace Editor
|
|
204
91
|
*
|
|
205
|
-
*
|
|
206
|
-
* ```tsx
|
|
207
|
-
* <MarkdownEditor
|
|
208
|
-
* codeProps={{
|
|
209
|
-
* theme: 'monokai', // 代码编辑器主题
|
|
210
|
-
* fontSize: 14,
|
|
211
|
-
* hideToolBar: false,
|
|
212
|
-
* Languages: ['javascript', 'python', 'typescript'],
|
|
213
|
-
* showLineNumbers: true,
|
|
214
|
-
* wrap: true,
|
|
215
|
-
* disableHtmlPreview: true, // 禁用 HTML 预览
|
|
216
|
-
* viewModeLabels: {
|
|
217
|
-
* preview: 'Preview', // 自定义预览标签
|
|
218
|
-
* code: 'Code', // 自定义代码标签
|
|
219
|
-
* },
|
|
220
|
-
* }}
|
|
221
|
-
* />
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* @property {string[]} [Languages] - 支持的编程语言列表
|
|
225
|
-
* @property {boolean} [hideToolBar] - 是否隐藏代码块工具栏
|
|
226
|
-
* @property {boolean} [alwaysExpandedDeepThink] - 是否始终展开深度思考块
|
|
227
|
-
* @property {boolean} [disableHtmlPreview] - 是否禁用 HTML 代码块的预览功能,禁用后只显示代码模式
|
|
228
|
-
* @property {Object} [viewModeLabels] - 预览/代码切换按钮的标签配置
|
|
229
|
-
* @property {string} [viewModeLabels.preview] - 预览模式的标签文本,默认为 '预览'
|
|
230
|
-
* @property {string} [viewModeLabels.code] - 代码模式的标签文本,默认为 '代码'
|
|
231
|
-
* @property {string} [theme] - 代码编辑器主题,如 'chrome', 'monokai', 'github', 'dracula' 等
|
|
232
|
-
* @property {number} [fontSize] - 代码字体大小,默认 12
|
|
233
|
-
* @property {number} [tabSize] - Tab 缩进大小,默认 4
|
|
234
|
-
* @property {boolean} [showLineNumbers] - 是否显示行号,默认 true
|
|
235
|
-
* @property {boolean} [showGutter] - 是否显示代码栏,默认 true
|
|
236
|
-
* @property {boolean} [wrap] - 是否自动换行,默认 true
|
|
92
|
+
* `render` 返回 `undefined` 时回退到默认渲染;返回 `null` 时不渲染。
|
|
237
93
|
*/
|
|
238
94
|
codeProps?: {
|
|
239
95
|
render?: (props: CustomLeaf<Record<string, any>> & {
|
|
240
96
|
children: React.ReactNode;
|
|
241
97
|
}, defaultDom: React.ReactNode, codeProps?: MarkdownEditorProps['codeProps']) => React.ReactNode;
|
|
242
|
-
/**
|
|
243
|
-
* 自定义节点渲染函数
|
|
244
|
-
*
|
|
245
|
-
* 约定:当 `render` 返回 `undefined` 时,表示“不覆盖默认渲染”,组件会回退到内部默认的卡片/渲染逻辑;
|
|
246
|
-
* 若需要“不渲染任何内容”,请显式返回 `null`。
|
|
247
|
-
*/
|
|
248
98
|
Languages?: string[];
|
|
249
99
|
hideToolBar?: boolean;
|
|
250
100
|
alwaysExpandedDeepThink?: boolean;
|
|
251
|
-
/** 是否禁用 HTML 代码块的预览功能,禁用后只显示代码模式 */
|
|
252
101
|
disableHtmlPreview?: boolean;
|
|
253
|
-
/** 预览/代码切换按钮的标签配置 */
|
|
254
102
|
viewModeLabels?: {
|
|
255
|
-
/**
|
|
103
|
+
/** 默认 '预览' */
|
|
256
104
|
preview?: string;
|
|
257
|
-
/**
|
|
105
|
+
/** 默认 '代码' */
|
|
258
106
|
code?: string;
|
|
259
107
|
};
|
|
260
108
|
} & Partial<Ace.EditorOptions>;
|
|
261
109
|
anchorProps?: AnchorProps;
|
|
262
|
-
/**
|
|
263
|
-
* 配置图片数据
|
|
264
|
-
*/
|
|
265
110
|
image?: {
|
|
266
111
|
upload?: (file: File[] | string[]) => Promise<string[] | string>;
|
|
267
112
|
render?: (props: ImageProps, defaultDom: React.ReactNode) => React.ReactNode;
|
|
@@ -269,101 +114,36 @@ export type MarkdownEditorProps = {
|
|
|
269
114
|
insertAutocompleteProps?: InsertAutocompleteProps;
|
|
270
115
|
eleItemRender?: (ele: RenderElementProps, defaultDom: React.ReactNode) => React.ReactNode;
|
|
271
116
|
initValue?: string;
|
|
272
|
-
/**
|
|
273
|
-
* 只读模式
|
|
274
|
-
*/
|
|
275
117
|
readonly?: boolean;
|
|
276
|
-
/**
|
|
277
|
-
* 懒加载渲染配置
|
|
278
|
-
* 启用后,每个元素都会被包裹在一个使用 IntersectionObserver 的容器中
|
|
279
|
-
* 只有当元素进入视口时才会真正渲染,以提升大型文档的性能
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```tsx
|
|
283
|
-
* // 基本懒加载配置
|
|
284
|
-
* lazy={{
|
|
285
|
-
* enable: true,
|
|
286
|
-
* placeholderHeight: 100,
|
|
287
|
-
* rootMargin: '200px'
|
|
288
|
-
* }}
|
|
289
|
-
*
|
|
290
|
-
* // 自定义占位符渲染
|
|
291
|
-
* lazy={{
|
|
292
|
-
* enable: true,
|
|
293
|
-
* placeholderHeight: 120,
|
|
294
|
-
* rootMargin: '300px',
|
|
295
|
-
* renderPlaceholder: ({ height, style, isIntersecting }) => (
|
|
296
|
-
* <div style={style}>
|
|
297
|
-
* <div>加载中... {isIntersecting ? '(即将显示)' : ''}</div>
|
|
298
|
-
* </div>
|
|
299
|
-
* )
|
|
300
|
-
* }}
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
118
|
+
/** 懒加载,只有进入视口才渲染 */
|
|
303
119
|
lazy?: {
|
|
304
|
-
/**
|
|
305
|
-
* 是否启用懒加载,默认 false
|
|
306
|
-
*/
|
|
307
120
|
enable?: boolean;
|
|
308
|
-
/**
|
|
309
|
-
* 占位符高度(单位:px),默认 25
|
|
310
|
-
*/
|
|
121
|
+
/** 单位 px,默认 25 */
|
|
311
122
|
placeholderHeight?: number;
|
|
312
|
-
/**
|
|
313
|
-
* 提前加载的距离,默认 '200px'
|
|
314
|
-
* 支持所有 IntersectionObserver rootMargin 的值
|
|
315
|
-
*/
|
|
123
|
+
/** IntersectionObserver rootMargin,默认 '200px' */
|
|
316
124
|
rootMargin?: string;
|
|
317
|
-
/**
|
|
318
|
-
* 自定义占位符渲染函数
|
|
319
|
-
* 允许开发者自定义懒加载时的占位符显示内容
|
|
320
|
-
*/
|
|
321
125
|
renderPlaceholder?: (props: {
|
|
322
|
-
/** 占位符高度 */
|
|
323
126
|
height: number;
|
|
324
|
-
/** 占位符样式 */
|
|
325
127
|
style: React.CSSProperties;
|
|
326
|
-
/** 元素是否即将进入视口 */
|
|
327
128
|
isIntersecting: boolean;
|
|
328
|
-
/** 元素在文档中的位置信息(可选) */
|
|
329
129
|
elementInfo?: {
|
|
330
|
-
/** 元素类型 */
|
|
331
130
|
type: string;
|
|
332
|
-
/** 元素在文档中的索引 */
|
|
333
131
|
index: number;
|
|
334
|
-
/** 元素总数量 */
|
|
335
132
|
total: number;
|
|
336
133
|
};
|
|
337
134
|
}) => React.ReactNode;
|
|
338
135
|
};
|
|
339
136
|
/**
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* - `--agentic-ui-table-border-color` 表格边框颜色,默认 #E7E9E8
|
|
344
|
-
* - `--agentic-ui-table-header-bg` 表头背景色,默认 #f7f7f9
|
|
345
|
-
* - `--agentic-ui-table-hover-bg` 行悬停背景色,默认 rgba(0,0,0,0.04)
|
|
346
|
-
* - `--agentic-ui-table-cell-bg` 单元格背景色,默认 #ffffff
|
|
347
|
-
* - `--agentic-ui-table-cell-min-width` 单元格最小宽度,默认 40px
|
|
348
|
-
* - `--agentic-ui-table-cell-padding` 单元格内边距,默认 16px 12px
|
|
349
|
-
* @example style={{ ['--agentic-ui-table-border-color']: '#ddd', ['--agentic-ui-table-header-bg']: '#f0f0f0' } as React.CSSProperties}
|
|
137
|
+
* 支持 CSS 变量自定义表格样式:
|
|
138
|
+
* `--agentic-ui-table-border-radius`、`--agentic-ui-table-border-color`、
|
|
139
|
+
* `--agentic-ui-table-header-bg`、`--agentic-ui-table-hover-bg` 等
|
|
350
140
|
*/
|
|
351
141
|
style?: React.CSSProperties;
|
|
352
|
-
/**
|
|
353
|
-
* 内容样式
|
|
354
|
-
* @description 支持 `--agentic-ui-content-padding` 等 CSS 变量
|
|
355
|
-
*/
|
|
356
142
|
contentStyle?: React.CSSProperties;
|
|
357
|
-
/**
|
|
358
|
-
* 工具栏配置
|
|
359
|
-
*/
|
|
360
143
|
toolbarConfig?: {
|
|
361
144
|
show?: boolean;
|
|
362
145
|
items?: string[];
|
|
363
146
|
};
|
|
364
|
-
/**
|
|
365
|
-
* 表格配置
|
|
366
|
-
*/
|
|
367
147
|
tableConfig?: {
|
|
368
148
|
minColumn?: number;
|
|
369
149
|
minRows?: number;
|
|
@@ -374,81 +154,32 @@ export type MarkdownEditorProps = {
|
|
|
374
154
|
};
|
|
375
155
|
pure?: boolean;
|
|
376
156
|
previewTitle?: string;
|
|
377
|
-
/**
|
|
378
|
-
* 表格 CSS 变量覆盖,支持通过配置自定义表格样式
|
|
379
|
-
* @example
|
|
380
|
-
* ```tsx
|
|
381
|
-
* tableConfig={{
|
|
382
|
-
* cssVariables: {
|
|
383
|
-
* '--agentic-ui-table-border-color': '#d9d9d9',
|
|
384
|
-
* '--agentic-ui-table-header-bg': '#fafafa',
|
|
385
|
-
* '--agentic-ui-table-cell-min-width': '150px',
|
|
386
|
-
* },
|
|
387
|
-
* }}
|
|
388
|
-
* ```
|
|
389
|
-
*/
|
|
390
157
|
cssVariables?: Record<`--${string}`, string>;
|
|
391
158
|
};
|
|
392
|
-
/**
|
|
393
|
-
* 粘贴配置
|
|
394
|
-
*/
|
|
395
159
|
pasteConfig?: {
|
|
396
160
|
enabled?: boolean;
|
|
397
161
|
allowedTypes?: string[];
|
|
398
|
-
/**
|
|
399
|
-
* 仅插入纯文本,不解析 HTML/Markdown/链接等
|
|
400
|
-
* @default false
|
|
401
|
-
*/
|
|
162
|
+
/** @default false */
|
|
402
163
|
plainTextOnly?: boolean;
|
|
403
164
|
};
|
|
404
|
-
/**
|
|
405
|
-
* Jinja 配置:语法高亮与模板面板(输入 `{}` 触发)
|
|
406
|
-
*/
|
|
407
165
|
jinja?: JinjaConfig;
|
|
408
|
-
/**
|
|
409
|
-
* 插件配置
|
|
410
|
-
*/
|
|
411
166
|
plugins?: any[];
|
|
412
|
-
/**
|
|
413
|
-
* 变更回调
|
|
414
|
-
*/
|
|
415
167
|
onChange?: (value: string, schema: Elements[]) => void;
|
|
416
|
-
/**
|
|
417
|
-
* 选择变更回调
|
|
418
|
-
* @param selection - Slate 选区对象
|
|
419
|
-
* @param selectedMarkdown - 选中内容的 markdown 文本
|
|
420
|
-
* @param selectedNodes - 选中的节点数组
|
|
421
|
-
*/
|
|
422
168
|
onSelectionChange?: (selection: Selection | null, selectedMarkdown: string, selectedNodes: Elements[]) => void;
|
|
423
169
|
comment?: {
|
|
424
|
-
/**
|
|
425
|
-
* 是否启用评论功能
|
|
426
|
-
*/
|
|
427
170
|
enable?: boolean;
|
|
428
|
-
/**
|
|
429
|
-
* 评论数据
|
|
430
|
-
*/
|
|
431
171
|
commentList?: CommentDataType[];
|
|
432
172
|
loadMentions?: (text: string) => Promise<{
|
|
433
173
|
name: string;
|
|
434
174
|
}[]>;
|
|
435
|
-
/**
|
|
436
|
-
* 添加评论的回调函数
|
|
437
|
-
*/
|
|
438
175
|
onSubmit?: (id: string | number, comment: CommentDataType) => void;
|
|
439
|
-
/**
|
|
440
|
-
* 删除评论的回调函数
|
|
441
|
-
*/
|
|
442
176
|
onDelete?: (id: string | number, comment: CommentDataType) => void;
|
|
443
177
|
editorRender?: (dom: React.ReactNode) => React.ReactNode;
|
|
444
178
|
onClick?: (id: string | number, comment: CommentDataType) => void;
|
|
445
179
|
onEdit?: (id: string | number, comment: CommentDataType) => void;
|
|
446
180
|
deleteConfirmText?: string;
|
|
447
181
|
mentionsPlaceholder?: string;
|
|
448
|
-
/**
|
|
449
|
-
* 评论输入框占位符
|
|
450
|
-
* @description 评论输入框的占位符文本,如果不提供则使用 titlePlaceholderContent
|
|
451
|
-
*/
|
|
182
|
+
/** 未提供时回退到 titlePlaceholderContent */
|
|
452
183
|
placeholder?: string;
|
|
453
184
|
listItemRender?: (defaultDom: {
|
|
454
185
|
checkbox: React.JSX.Element | null;
|
|
@@ -463,194 +194,85 @@ export type MarkdownEditorProps = {
|
|
|
463
194
|
onFocus?: (value: string, schema: Elements[], e: React.FocusEvent<HTMLDivElement, Element>) => void;
|
|
464
195
|
onBlur?: (value: string, schema: Elements[], e: React.MouseEvent<HTMLDivElement, Element>) => void;
|
|
465
196
|
onPaste?: (e: React.ClipboardEvent<HTMLDivElement>) => boolean | void;
|
|
466
|
-
/**
|
|
467
|
-
* 自定义 markdown 转 HTML 的 remark 插件配置,格式类似 Babel 插件数组
|
|
468
|
-
*/
|
|
197
|
+
/** 自定义 remark 插件,格式同 Babel 插件数组 */
|
|
469
198
|
markdownToHtmlOptions?: MarkdownToHtmlOptions;
|
|
470
199
|
linkConfig?: {
|
|
471
|
-
/** 是否在新标签页打开链接 */
|
|
472
200
|
openInNewTab?: boolean;
|
|
473
|
-
/** 自定义链接渲染函数 */
|
|
474
201
|
onClick?: (url?: string) => boolean | void;
|
|
475
202
|
};
|
|
476
|
-
/**
|
|
477
|
-
* MarkdownRenderer 字符队列(仅 `renderMode: 'markdown'` 只读预览时生效)
|
|
478
|
-
* @description 默认关闭逐字 RAF;需要打字机时再设 `{ animate: true, animateTailChars: 50 }` 等
|
|
479
|
-
*/
|
|
203
|
+
/** 字符队列配置(仅 renderMode: 'markdown'),默认关闭逐字 RAF */
|
|
480
204
|
queueOptions?: CharacterQueueOptions;
|
|
481
|
-
/**
|
|
482
|
-
* 流式 Markdown 末段淡入(仅 `renderMode: 'markdown'` 时传给 MarkdownRenderer)
|
|
483
|
-
* @description 默认 false;设为 true 时末段使用 AnimationText 入场,可能在高频更新时产生闪动
|
|
484
|
-
*/
|
|
205
|
+
/** 末段淡入动画(仅 renderMode: 'markdown'),默认开启;传 false 关闭 */
|
|
485
206
|
streamingParagraphAnimation?: boolean;
|
|
486
|
-
/**
|
|
487
|
-
* 依赖数组
|
|
488
|
-
* @description 用于控制 MElement 组件是否刷新的依赖数组。当 deps 数组内容发生变化时,MElement 会重新渲染
|
|
489
|
-
* @example ['user-id', 'theme', 'locale']
|
|
490
|
-
*/
|
|
207
|
+
/** MElement 刷新依赖 */
|
|
491
208
|
deps?: string[];
|
|
492
|
-
/**
|
|
493
|
-
* Apaasify 自定义渲染配置
|
|
494
|
-
* @description 用于自定义渲染 apaasify 代码块的内容
|
|
495
|
-
* @property {boolean} enable - 是否启用自定义渲染
|
|
496
|
-
* @property {Function} render - 自定义渲染函数,接收 Schema 组件的 props 和 originData,返回 React 节点
|
|
497
|
-
* @example
|
|
498
|
-
* ```tsx
|
|
499
|
-
* <MarkdownEditor
|
|
500
|
-
* apaasify={{
|
|
501
|
-
* enable: true,
|
|
502
|
-
* render: (props, originData) => {
|
|
503
|
-
* return <CustomSchemaRenderer schema={props.element.value} />;
|
|
504
|
-
* }
|
|
505
|
-
* }}
|
|
506
|
-
* />
|
|
507
|
-
* ```
|
|
508
|
-
*/
|
|
509
209
|
apaasify?: {
|
|
510
210
|
enable?: boolean;
|
|
511
211
|
render?: (props: import('slate-react').RenderElementProps, originData?: import('../Bubble/type').MessageBubbleData) => React.ReactNode;
|
|
512
212
|
};
|
|
513
|
-
/**
|
|
514
|
-
* Apassify 自定义渲染配置(兼容旧版本)
|
|
515
|
-
* @description 与 apaasify 功能相同,用于向后兼容
|
|
516
|
-
* @deprecated @since 2.29.0 请使用 apaasify 代替
|
|
517
|
-
*/
|
|
213
|
+
/** @deprecated 请使用 apaasify */
|
|
518
214
|
apassify?: {
|
|
519
215
|
enable?: boolean;
|
|
520
216
|
render?: (props: import('slate-react').RenderElementProps, originData?: import('../Bubble/type').MessageBubbleData) => React.ReactNode;
|
|
521
217
|
};
|
|
522
218
|
children?: React.ReactNode;
|
|
523
|
-
/**
|
|
524
|
-
* 编辑器实例引用
|
|
525
|
-
* @description 用于获取编辑器实例,可调用 store、exportHtml 等方法
|
|
526
|
-
*/
|
|
527
219
|
editorRef?: React.Ref<MarkdownEditorInstance | undefined>;
|
|
528
|
-
/**
|
|
529
|
-
* 报告模式
|
|
530
|
-
* @description 启用后将使用报告模式样式
|
|
531
|
-
*/
|
|
532
220
|
reportMode?: boolean;
|
|
533
|
-
/**
|
|
534
|
-
* 是否显示目录
|
|
535
|
-
* @default false
|
|
536
|
-
*/
|
|
221
|
+
/** @default false */
|
|
537
222
|
toc?: boolean;
|
|
538
|
-
/**
|
|
539
|
-
* 工具栏配置
|
|
540
|
-
* @description 配置编辑器顶部的工具栏
|
|
541
|
-
*/
|
|
542
223
|
toolBar?: {
|
|
543
224
|
enable?: boolean;
|
|
544
225
|
min?: boolean;
|
|
545
226
|
hideTools?: ('bold' | 'italic' | 'underline' | 'strikethrough' | 'code' | 'heading' | 'link' | 'color' | 'clearFormat' | 'undo' | 'redo' | string)[];
|
|
546
227
|
extra?: React.ReactNode[];
|
|
547
228
|
};
|
|
548
|
-
/**
|
|
549
|
-
* 编辑器唯一标识
|
|
550
|
-
*/
|
|
551
229
|
id?: string;
|
|
552
|
-
/**
|
|
553
|
-
* 初始 Schema 值
|
|
554
|
-
* @description 直接传入 Slate schema 格式的数据,优先级高于 initValue
|
|
555
|
-
*/
|
|
230
|
+
/** 直接传入 Slate schema,优先级高于 initValue */
|
|
556
231
|
initSchemaValue?: Elements[];
|
|
557
|
-
/**
|
|
558
|
-
* 自定义叶子节点渲染函数
|
|
559
|
-
* @description 用于自定义文本节点的渲染方式
|
|
560
|
-
* @param props - 叶子节点属性
|
|
561
|
-
* @param defaultDom - 默认渲染 DOM
|
|
562
|
-
* @returns 自定义渲染结果
|
|
563
|
-
*/
|
|
564
232
|
leafRender?: (props: Record<string, any> & {
|
|
565
233
|
children: React.ReactNode;
|
|
566
234
|
}, defaultDom: React.ReactNode) => React.ReactNode;
|
|
235
|
+
/** 流式输出模式,同时传入时优先于 typewriter */
|
|
236
|
+
streaming?: boolean;
|
|
237
|
+
/** 流式是否完成(仅 renderMode: 'markdown'),未传入时回退到 !streaming */
|
|
238
|
+
isFinished?: boolean;
|
|
567
239
|
/**
|
|
568
|
-
*
|
|
569
|
-
* @
|
|
240
|
+
* streaming 的别名,向下兼容
|
|
241
|
+
* @deprecated 请使用 streaming
|
|
570
242
|
*/
|
|
571
243
|
typewriter?: boolean;
|
|
572
|
-
/**
|
|
573
|
-
* 根容器引用
|
|
574
|
-
* @description 编辑器根容器的 DOM 引用
|
|
575
|
-
*/
|
|
576
244
|
rootContainer?: React.MutableRefObject<HTMLDivElement | undefined>;
|
|
577
|
-
/**
|
|
578
|
-
* 幻灯片模式
|
|
579
|
-
* @description 启用后编辑器将使用幻灯片模式样式
|
|
580
|
-
*/
|
|
581
245
|
slideMode?: boolean;
|
|
582
|
-
/**
|
|
583
|
-
* 容器自定义类名
|
|
584
|
-
* @description 编辑器内容容器的类名
|
|
585
|
-
*/
|
|
586
246
|
containerClassName?: string;
|
|
587
|
-
/**
|
|
588
|
-
* 浮动工具栏配置
|
|
589
|
-
*/
|
|
590
247
|
floatBar?: {
|
|
591
248
|
enable?: boolean;
|
|
592
249
|
};
|
|
593
|
-
/**
|
|
594
|
-
* 文本区域配置
|
|
595
|
-
*/
|
|
596
250
|
textAreaProps?: {
|
|
597
251
|
enable?: boolean;
|
|
598
252
|
placeholder?: string;
|
|
599
253
|
};
|
|
600
|
-
/**
|
|
601
|
-
* 标题占位符文本
|
|
602
|
-
*/
|
|
603
254
|
titlePlaceholderContent?: string;
|
|
604
|
-
/**
|
|
605
|
-
* Markdown 输入配置
|
|
606
|
-
*/
|
|
607
255
|
markdown?: {
|
|
608
256
|
matchLeaf?: boolean;
|
|
609
257
|
matchInputToNode?: boolean;
|
|
610
258
|
};
|
|
611
|
-
/**
|
|
612
|
-
* 拖拽配置
|
|
613
|
-
*/
|
|
614
259
|
drag?: {
|
|
615
260
|
enable?: boolean;
|
|
616
261
|
};
|
|
617
|
-
/**
|
|
618
|
-
* 紧凑模式
|
|
619
|
-
* @description 启用后编辑器将使用更紧凑的间距
|
|
620
|
-
*/
|
|
621
262
|
compact?: boolean;
|
|
622
|
-
/**
|
|
623
|
-
* 附件配置
|
|
624
|
-
* @description 配置附件上传功能
|
|
625
|
-
*/
|
|
626
263
|
attachment?: Record<string, unknown>;
|
|
627
264
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* - '
|
|
631
|
-
* - 'markdown': 使用轻量 MarkdownRenderer 渲染(无 Slate 实例,性能更优)
|
|
632
|
-
* @default 'slate'
|
|
265
|
+
* 只读渲染模式,默认 'slate'
|
|
266
|
+
* - 'slate': Slate 编辑器渲染(向后兼容)
|
|
267
|
+
* - 'markdown': 轻量 MarkdownRenderer(无 Slate 实例)
|
|
633
268
|
*/
|
|
634
269
|
renderMode?: RenderMode;
|
|
635
|
-
/**
|
|
636
|
-
* 与 `renderMode` 等价,兼容部分协议或查询参数命名(如 `renderType=markdown`)
|
|
637
|
-
* @description 当同时传入时,`renderMode` 优先
|
|
638
|
-
*/
|
|
270
|
+
/** renderMode 的别名,同时传入时 renderMode 优先 */
|
|
639
271
|
renderType?: RenderMode;
|
|
640
272
|
/**
|
|
641
|
-
*
|
|
642
|
-
* @description 拦截并自定义 MarkdownRenderer 中任意块级/行内元素的渲染结果。
|
|
643
|
-
* 与 Slate 模式的 `eleItemRender` 对应,允许替换段落、标题、列表、图片等元素。
|
|
644
|
-
* 返回 `undefined` 时回退到默认渲染。
|
|
645
|
-
* @param props - 元素属性(tagName、node、children 等)
|
|
646
|
-
* @param defaultDom - 默认渲染结果
|
|
647
|
-
* @returns 自定义渲染节点,或 undefined 时回退到 defaultDom
|
|
273
|
+
* 自定义元素渲染(仅 renderMode: 'markdown'),返回 undefined 回退默认渲染
|
|
648
274
|
*/
|
|
649
275
|
eleRender?: (props: import('../MarkdownRenderer/types').MarkdownRendererEleProps, defaultDom: React.ReactNode) => React.ReactNode;
|
|
650
|
-
/**
|
|
651
|
-
* FileMapView 配置(仅 `renderMode: 'markdown'` 时生效)
|
|
652
|
-
* @description 透传给 agentic-ui-filemap 代码块渲染器,
|
|
653
|
-
* 统一配置图片/视频条目的 onPreview 拦截和 itemRender 自定义回显。
|
|
654
|
-
*/
|
|
276
|
+
/** FileMapView 配置(仅 renderMode: 'markdown') */
|
|
655
277
|
fileMapConfig?: import('../MarkdownRenderer/types').FileMapConfig;
|
|
656
278
|
};
|
|
@@ -140,6 +140,7 @@ import { useLocale } from "../I18n";
|
|
|
140
140
|
import { BaseMarkdownEditor } from "../MarkdownEditor";
|
|
141
141
|
import { BorderBeamAnimation } from "./BorderBeamAnimation";
|
|
142
142
|
import { useFileUploadManager } from "./FileUploadManager";
|
|
143
|
+
import { resolveSendDisabled } from "./SendButton";
|
|
143
144
|
import { useMarkdownInputFieldActions } from "./hooks/useMarkdownInputFieldActions";
|
|
144
145
|
import { useMarkdownInputFieldHandlers } from "./hooks/useMarkdownInputFieldHandlers";
|
|
145
146
|
import { useMarkdownInputFieldLayout } from "./hooks/useMarkdownInputFieldLayout";
|
|
@@ -280,6 +281,7 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
280
281
|
attachment: attachment,
|
|
281
282
|
triggerSendKey: props.triggerSendKey
|
|
282
283
|
},
|
|
284
|
+
sendDisabled: resolveSendDisabled(props.sendButtonProps, fileUploadStatus),
|
|
283
285
|
markdownEditorRef: markdownEditorRef,
|
|
284
286
|
inputRef: inputRef,
|
|
285
287
|
isSendingRef: isSendingRef,
|