@ant-design/agentic-ui 2.20.2 → 2.21.0
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/MarkdownEditor/BaseMarkdownEditor.js +1 -1
- package/dist/MarkdownEditor/editor/elements/Code.js +1 -1
- package/dist/MarkdownEditor/editor/elements/Image/index.js +37 -9
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +87 -2
- package/dist/MarkdownEditor/editor/elements/List/List.js +10 -2
- package/dist/MarkdownEditor/editor/elements/Media.js +75 -23
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +2 -13
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +89 -15
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +3 -75
- package/dist/MarkdownEditor/editor/elements/index.js +1 -32
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.d.ts +32 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +186 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.d.ts +39 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +315 -0
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +0 -4
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +629 -1043
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +15 -3
- package/dist/MarkdownEditor/editor/parser/remarkParse.d.ts +11 -1
- package/dist/MarkdownEditor/editor/parser/remarkParse.js +218 -39
- package/dist/MarkdownEditor/editor/types/Table.d.ts +2 -1
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +2 -1
- package/dist/MarkdownEditor/el.d.ts +3 -0
- package/dist/MarkdownEditor/style.js +2 -0
- package/dist/Plugins/chart/index.js +7 -7
- package/dist/Plugins/code/components/CodeRenderer.js +27 -10
- package/dist/Plugins/code/components/CodeToolbar.js +2 -2
- package/dist/Workspace/Task/index.d.ts +13 -8
- package/dist/Workspace/Task/index.js +19 -2
- package/dist/Workspace/index.js +3 -2
- package/dist/Workspace/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -336,6 +336,7 @@ var inlineNode = new Set([
|
|
|
336
336
|
var configProps = _object_spread({}, node.otherProps);
|
|
337
337
|
delete configProps['columns'];
|
|
338
338
|
delete configProps['dataSource'];
|
|
339
|
+
delete configProps['finished'];
|
|
339
340
|
if (node.type === 'link-card') {
|
|
340
341
|
configProps.type = 'card';
|
|
341
342
|
configProps.url = encodeURI(node === null || node === void 0 ? void 0 : node.url);
|
|
@@ -356,9 +357,20 @@ var inlineNode = new Set([
|
|
|
356
357
|
}
|
|
357
358
|
});
|
|
358
359
|
// 只有当 configProps 不为空对象时才生成注释
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
// 检查 configProps 是否为空对象(删除 finished 后可能变成空对象)
|
|
361
|
+
var hasValidProps = Object.keys(configProps).length > 0;
|
|
362
|
+
if (hasValidProps) {
|
|
363
|
+
var nodeConfig = node.type === 'chart' && configProps.config ? configProps.config : configProps;
|
|
364
|
+
// 过滤掉 undefined 值,但保留 false 值
|
|
365
|
+
var propsToSerialize = Object.keys(nodeConfig).reduce(function(acc, key) {
|
|
366
|
+
if (nodeConfig[key] !== undefined) {
|
|
367
|
+
acc[key] = nodeConfig[key];
|
|
368
|
+
}
|
|
369
|
+
return acc;
|
|
370
|
+
}, {});
|
|
371
|
+
if (propsToSerialize && (typeof propsToSerialize === "undefined" ? "undefined" : _type_of(propsToSerialize)) === 'object' && !Array.isArray(propsToSerialize) && Object.keys(propsToSerialize).length > 0) {
|
|
372
|
+
str += "<!--".concat(JSON.stringify(propsToSerialize), "-->\n");
|
|
373
|
+
}
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
376
|
var p = parent.at(-1) || {};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将段落节点转换为相应的节点类型(根据内容开头字符)
|
|
3
|
+
* - ! 开头 → image
|
|
4
|
+
* - | 开头 → table
|
|
5
|
+
* - [ 开头 → link
|
|
6
|
+
*
|
|
7
|
+
* @returns {(tree: any) => void}
|
|
8
|
+
* Transformer function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertParagraphToImage(): (tree: any) => void;
|
|
1
11
|
/**
|
|
2
12
|
* Plugin to fix bold text containing special characters like **$9.698M**, **57%**, etc.
|
|
3
13
|
*
|
|
@@ -5,5 +15,5 @@
|
|
|
5
15
|
* Transformer function.
|
|
6
16
|
*/
|
|
7
17
|
export declare function fixStrongWithSpecialChars(): (tree: any) => void;
|
|
8
|
-
declare const markdownParser: import("unified").Processor<import("mdast").Root,
|
|
18
|
+
declare const markdownParser: import("unified").Processor<import("mdast").Root, undefined, undefined, import("mdast").Root, string>;
|
|
9
19
|
export default markdownParser;
|
|
@@ -23,16 +23,122 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
23
23
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
25
|
}
|
|
26
|
-
import rehypeKatex from "rehype-katex";
|
|
27
|
-
import rehypeRaw from "rehype-raw";
|
|
28
26
|
import remarkFrontmatter from "remark-frontmatter";
|
|
29
27
|
import remarkGfm from "remark-gfm";
|
|
30
28
|
import remarkHtml from "remark-html";
|
|
31
29
|
import remarkMath from "remark-math";
|
|
32
30
|
import remarkParse from "remark-parse";
|
|
33
|
-
import remarkRehype from "remark-rehype";
|
|
34
31
|
import { unified } from "unified";
|
|
35
32
|
import { visit } from "unist-util-visit";
|
|
33
|
+
/**
|
|
34
|
+
* 提取段落节点的文本内容
|
|
35
|
+
* @param paragraphNode - 段落节点
|
|
36
|
+
* @returns 文本内容字符串
|
|
37
|
+
*/ function extractParagraphText(paragraphNode) {
|
|
38
|
+
if (!paragraphNode.children || !Array.isArray(paragraphNode.children)) {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
return paragraphNode.children.map(function(child) {
|
|
42
|
+
if (child.type === 'text') {
|
|
43
|
+
return child.value || '';
|
|
44
|
+
}
|
|
45
|
+
// 处理嵌套节点(如 strong, emphasis 等)
|
|
46
|
+
if (child.children && Array.isArray(child.children)) {
|
|
47
|
+
return child.children.map(function(grandChild) {
|
|
48
|
+
return grandChild.type === 'text' ? grandChild.value || '' : '';
|
|
49
|
+
}).join('');
|
|
50
|
+
}
|
|
51
|
+
return '';
|
|
52
|
+
}).join('').trim();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 将段落节点转换为相应的节点类型(根据内容开头字符)
|
|
56
|
+
* - ! 开头 → image
|
|
57
|
+
* - | 开头 → table
|
|
58
|
+
* - [ 开头 → link
|
|
59
|
+
*
|
|
60
|
+
* @returns {(tree: any) => void}
|
|
61
|
+
* Transformer function.
|
|
62
|
+
*/ export function convertParagraphToImage() {
|
|
63
|
+
return function(tree) {
|
|
64
|
+
// 使用 visit 访问 paragraph 节点,并通过 index 和 parent 来替换
|
|
65
|
+
visit(tree, 'paragraph', function(paragraphNode, index, parent) {
|
|
66
|
+
var textContent = extractParagraphText(paragraphNode);
|
|
67
|
+
if (!textContent) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// 检查是否以 ! 开头(图片)
|
|
71
|
+
if (textContent.startsWith('!')) {
|
|
72
|
+
// 提取 URL(去掉开头的 !)
|
|
73
|
+
var imageUrl = textContent.slice(1).trim();
|
|
74
|
+
// 如果 URL 不为空,则创建 image 节点并替换
|
|
75
|
+
if (imageUrl) {
|
|
76
|
+
var imageNode = {
|
|
77
|
+
type: 'image',
|
|
78
|
+
url: imageUrl,
|
|
79
|
+
finished: false,
|
|
80
|
+
alt: ''
|
|
81
|
+
};
|
|
82
|
+
// 替换父节点中的 paragraph 节点为 image 节点
|
|
83
|
+
if (parent && Array.isArray(parent.children) && typeof index === 'number') {
|
|
84
|
+
parent.children[index] = imageNode;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// 检查是否以 | 开头(表格)
|
|
90
|
+
if (textContent.startsWith('|')) {
|
|
91
|
+
// 创建不完整的表格节点
|
|
92
|
+
var tableNode = {
|
|
93
|
+
type: 'table',
|
|
94
|
+
finished: false,
|
|
95
|
+
align: [],
|
|
96
|
+
children: [
|
|
97
|
+
{
|
|
98
|
+
type: 'tableRow',
|
|
99
|
+
children: [
|
|
100
|
+
{
|
|
101
|
+
type: 'tableCell',
|
|
102
|
+
children: [
|
|
103
|
+
{
|
|
104
|
+
type: 'paragraph',
|
|
105
|
+
children: [
|
|
106
|
+
{
|
|
107
|
+
type: 'text',
|
|
108
|
+
value: textContent
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
};
|
|
118
|
+
// 替换父节点中的 paragraph 节点为 table 节点
|
|
119
|
+
if (parent && Array.isArray(parent.children) && typeof index === 'number') {
|
|
120
|
+
parent.children[index] = tableNode;
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// 检查是否以 [ 开头(链接)
|
|
125
|
+
if (textContent.startsWith('[')) {
|
|
126
|
+
// 创建不完整的链接节点
|
|
127
|
+
var linkNode = {
|
|
128
|
+
type: 'link',
|
|
129
|
+
url: '',
|
|
130
|
+
finished: false,
|
|
131
|
+
children: paragraphNode.children
|
|
132
|
+
};
|
|
133
|
+
// 替换父节点中的 paragraph 节点为 link 节点
|
|
134
|
+
if (parent && Array.isArray(parent.children) && typeof index === 'number') {
|
|
135
|
+
parent.children[index] = linkNode;
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
}
|
|
36
142
|
/**
|
|
37
143
|
* Plugin to fix bold text containing special characters like **$9.698M**, **57%**, etc.
|
|
38
144
|
*
|
|
@@ -47,13 +153,18 @@ import { visit } from "unist-util-visit";
|
|
|
47
153
|
for(var i = 0; i < paragraphNode.children.length; i++){
|
|
48
154
|
var child = paragraphNode.children[i];
|
|
49
155
|
if (child.type === 'text' && child.value && typeof child.value === 'string') {
|
|
50
|
-
//
|
|
156
|
+
// 匹配完整的加粗文本(**text**)
|
|
51
157
|
var strongPattern = /\*\*([^*\n]*[$%#@&+\-=\w\d.,。、;:!?""''()【】《》]+[^*\n]*?)\*\*/g;
|
|
158
|
+
// 匹配不完整的加粗文本(**text 但没有结束的 **)
|
|
159
|
+
var incompleteStrongPattern = /^\*\*([^*\n]+)$/;
|
|
160
|
+
var newNodes = [];
|
|
161
|
+
var lastIndex = 0;
|
|
162
|
+
var hasMatch = false;
|
|
163
|
+
// 先检查是否有完整的加粗文本
|
|
52
164
|
if (strongPattern.test(child.value)) {
|
|
53
165
|
// 重置正则表达式
|
|
54
166
|
strongPattern.lastIndex = 0;
|
|
55
|
-
|
|
56
|
-
var lastIndex = 0;
|
|
167
|
+
hasMatch = true;
|
|
57
168
|
var match = void 0;
|
|
58
169
|
// 分割文本并创建新的节点结构
|
|
59
170
|
while((match = strongPattern.exec(child.value)) !== null){
|
|
@@ -83,22 +194,52 @@ import { visit } from "unist-util-visit";
|
|
|
83
194
|
if (lastIndex < child.value.length) {
|
|
84
195
|
var afterText = child.value.slice(lastIndex);
|
|
85
196
|
if (afterText) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
197
|
+
// 检查剩余文本是否是不完整的加粗
|
|
198
|
+
var incompleteMatch = incompleteStrongPattern.exec(afterText);
|
|
199
|
+
if (incompleteMatch) {
|
|
200
|
+
newNodes.push({
|
|
201
|
+
type: 'strong',
|
|
202
|
+
finished: false,
|
|
203
|
+
children: [
|
|
204
|
+
{
|
|
205
|
+
type: 'text',
|
|
206
|
+
value: incompleteMatch[1]
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
newNodes.push({
|
|
212
|
+
type: 'text',
|
|
213
|
+
value: afterText
|
|
214
|
+
});
|
|
215
|
+
}
|
|
90
216
|
}
|
|
91
217
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
218
|
+
} else if (incompleteStrongPattern.test(child.value)) {
|
|
219
|
+
var incompleteMatch1 = incompleteStrongPattern.exec(child.value);
|
|
220
|
+
if (incompleteMatch1) {
|
|
221
|
+
hasMatch = true;
|
|
222
|
+
newNodes.push({
|
|
223
|
+
type: 'strong',
|
|
224
|
+
finished: false,
|
|
225
|
+
children: [
|
|
226
|
+
{
|
|
227
|
+
type: 'text',
|
|
228
|
+
value: incompleteMatch1[1]
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
});
|
|
100
232
|
}
|
|
101
233
|
}
|
|
234
|
+
// 替换当前文本节点
|
|
235
|
+
if (hasMatch && newNodes.length > 0) {
|
|
236
|
+
var _paragraphNode_children;
|
|
237
|
+
(_paragraphNode_children = paragraphNode.children).splice.apply(_paragraphNode_children, [
|
|
238
|
+
i,
|
|
239
|
+
1
|
|
240
|
+
].concat(_to_consumable_array(newNodes)));
|
|
241
|
+
i += newNodes.length - 1; // 调整索引以跳过新插入的节点
|
|
242
|
+
}
|
|
102
243
|
}
|
|
103
244
|
}
|
|
104
245
|
}
|
|
@@ -106,13 +247,18 @@ import { visit } from "unist-util-visit";
|
|
|
106
247
|
// 处理所有文本节点(作为备用方案)
|
|
107
248
|
visit(tree, 'text', function(node, index, parent) {
|
|
108
249
|
if (node.value && typeof node.value === 'string') {
|
|
109
|
-
//
|
|
250
|
+
// 匹配完整的加粗文本(**text**)
|
|
110
251
|
var strongPattern = /\*\*([^*\n]*[$%#@&+\-=\w\d.,。、;:!?""''()【】《》]+[^*\n]*?)\*\*/g;
|
|
252
|
+
// 匹配不完整的加粗文本(**text 但没有结束的 **)
|
|
253
|
+
var incompleteStrongPattern = /^\*\*([^*\n]+)$/;
|
|
254
|
+
var newNodes = [];
|
|
255
|
+
var lastIndex = 0;
|
|
256
|
+
var hasMatch = false;
|
|
257
|
+
// 先检查是否有完整的加粗文本
|
|
111
258
|
if (strongPattern.test(node.value)) {
|
|
112
259
|
// 重置正则表达式
|
|
113
260
|
strongPattern.lastIndex = 0;
|
|
114
|
-
|
|
115
|
-
var lastIndex = 0;
|
|
261
|
+
hasMatch = true;
|
|
116
262
|
var match;
|
|
117
263
|
// 分割文本并创建新的节点结构
|
|
118
264
|
while((match = strongPattern.exec(node.value)) !== null){
|
|
@@ -142,33 +288,66 @@ import { visit } from "unist-util-visit";
|
|
|
142
288
|
if (lastIndex < node.value.length) {
|
|
143
289
|
var afterText = node.value.slice(lastIndex);
|
|
144
290
|
if (afterText) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
291
|
+
// 检查剩余文本是否是不完整的加粗
|
|
292
|
+
var incompleteMatch = incompleteStrongPattern.exec(afterText);
|
|
293
|
+
if (incompleteMatch) {
|
|
294
|
+
newNodes.push({
|
|
295
|
+
type: 'strong',
|
|
296
|
+
finished: false,
|
|
297
|
+
children: [
|
|
298
|
+
{
|
|
299
|
+
type: 'text',
|
|
300
|
+
value: incompleteMatch[1]
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
});
|
|
304
|
+
} else {
|
|
305
|
+
newNodes.push({
|
|
306
|
+
type: 'text',
|
|
307
|
+
value: afterText
|
|
308
|
+
});
|
|
309
|
+
}
|
|
149
310
|
}
|
|
150
311
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
312
|
+
} else if (incompleteStrongPattern.test(node.value)) {
|
|
313
|
+
var incompleteMatch1 = incompleteStrongPattern.exec(node.value);
|
|
314
|
+
if (incompleteMatch1) {
|
|
315
|
+
hasMatch = true;
|
|
316
|
+
newNodes.push({
|
|
317
|
+
type: 'strong',
|
|
318
|
+
finished: false,
|
|
319
|
+
children: [
|
|
320
|
+
{
|
|
321
|
+
type: 'text',
|
|
322
|
+
value: incompleteMatch1[1]
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
});
|
|
158
326
|
}
|
|
159
327
|
}
|
|
328
|
+
// 替换原节点
|
|
329
|
+
if (hasMatch && newNodes.length > 0 && parent && Array.isArray(parent.children) && typeof index === 'number') {
|
|
330
|
+
var _parent_children;
|
|
331
|
+
(_parent_children = parent.children).splice.apply(_parent_children, [
|
|
332
|
+
index,
|
|
333
|
+
1
|
|
334
|
+
].concat(_to_consumable_array(newNodes)));
|
|
335
|
+
}
|
|
160
336
|
}
|
|
161
337
|
});
|
|
162
338
|
};
|
|
163
339
|
}
|
|
164
|
-
//
|
|
165
|
-
|
|
340
|
+
// Markdown 解析器(用于解析 Markdown 为 mdast AST)
|
|
341
|
+
// 注意:这个解析器只用于解析,不包含 HTML 渲染相关的插件
|
|
342
|
+
var markdownParser = unified().use(remarkParse) // 解析 Markdown
|
|
343
|
+
.use(remarkHtml).use(remarkFrontmatter, [
|
|
344
|
+
'yaml'
|
|
345
|
+
]) // 处理前置元数据
|
|
346
|
+
.use(remarkGfm) // GFM 插件
|
|
166
347
|
.use(fixStrongWithSpecialChars) // 修复包含特殊字符的加粗文本
|
|
348
|
+
.use(convertParagraphToImage) // 将以 ! 开头的段落转换为图片,将 | 开头的段落转换为表格
|
|
167
349
|
.use(remarkMath, {
|
|
168
350
|
singleDollarTextMath: true
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
}).use(rehypeRaw).use(rehypeKatex).use(remarkFrontmatter, [
|
|
172
|
-
'yaml'
|
|
173
|
-
]);
|
|
351
|
+
});
|
|
352
|
+
// 默认导出解析器(用于解析 Markdown 为 mdast AST)
|
|
174
353
|
export default markdownParser;
|
|
@@ -3,6 +3,7 @@ export type TableCustomElement = TableNode | TableHeadNode | TableFooterNode | T
|
|
|
3
3
|
export interface TableNode {
|
|
4
4
|
type: 'table';
|
|
5
5
|
children: Array<TableHeadNode | TrNode | TableFooterNode>;
|
|
6
|
+
finished?: boolean;
|
|
6
7
|
otherProps?: {
|
|
7
8
|
mergeCells?: Array<{
|
|
8
9
|
row: number;
|
|
@@ -10,7 +11,7 @@ export interface TableNode {
|
|
|
10
11
|
rowSpan: number;
|
|
11
12
|
colSpan: number;
|
|
12
13
|
}>;
|
|
13
|
-
|
|
14
|
+
finished?: boolean;
|
|
14
15
|
config?: any;
|
|
15
16
|
columns?: Array<any>;
|
|
16
17
|
};
|
|
@@ -166,7 +166,7 @@ import remarkParse from "remark-parse";
|
|
|
166
166
|
import remarkRehype from "remark-rehype";
|
|
167
167
|
import { unified } from "unified";
|
|
168
168
|
import { visit } from "unist-util-visit";
|
|
169
|
-
import { fixStrongWithSpecialChars } from "../parser/remarkParse";
|
|
169
|
+
import { convertParagraphToImage, fixStrongWithSpecialChars } from "../parser/remarkParse";
|
|
170
170
|
// HTML 转义相关的正则表达式和工具
|
|
171
171
|
var ESCAPE_TEST_NO_ENCODE = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
172
172
|
var ESCAPE_TEST = /[&<>"']/;
|
|
@@ -295,6 +295,7 @@ export var DEFAULT_MARKDOWN_REMARK_PLUGINS = [
|
|
|
295
295
|
remarkParse,
|
|
296
296
|
remarkGfm,
|
|
297
297
|
fixStrongWithSpecialChars,
|
|
298
|
+
convertParagraphToImage,
|
|
298
299
|
[
|
|
299
300
|
remarkMath,
|
|
300
301
|
INLINE_MATH_WITH_SINGLE_DOLLAR
|
|
@@ -74,6 +74,7 @@ export type ListNode<T = Record<string, any>> = {
|
|
|
74
74
|
order?: boolean;
|
|
75
75
|
start?: number;
|
|
76
76
|
task?: boolean;
|
|
77
|
+
finished?: boolean;
|
|
77
78
|
h?: number;
|
|
78
79
|
};
|
|
79
80
|
export type ChartTypeConfig<T = Record<string, any>> = {
|
|
@@ -139,6 +140,7 @@ export type MediaNode<T = Record<string, any>> = {
|
|
|
139
140
|
url?: string;
|
|
140
141
|
alt: string;
|
|
141
142
|
downloadUrl?: string;
|
|
143
|
+
finished?: boolean;
|
|
142
144
|
height?: number;
|
|
143
145
|
width?: number;
|
|
144
146
|
docId?: string;
|
|
@@ -164,6 +166,7 @@ export type LinkCardNode<T = Record<string, any>> = {
|
|
|
164
166
|
title?: string;
|
|
165
167
|
name?: string;
|
|
166
168
|
alt: string;
|
|
169
|
+
finished?: boolean;
|
|
167
170
|
children: BaseElement['children'];
|
|
168
171
|
};
|
|
169
172
|
export type AttachNode<T = Record<string, any>> = {
|
|
@@ -316,7 +316,7 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
|
|
|
316
316
|
]);
|
|
317
317
|
var columns = ((_node_otherProps2 = node.otherProps) === null || _node_otherProps2 === void 0 ? void 0 : _node_otherProps2.columns) || [];
|
|
318
318
|
// 检查图表是否未闭合
|
|
319
|
-
var isUnclosed = (node === null || node === void 0 ? void 0 : (_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.
|
|
319
|
+
var isUnclosed = (node === null || node === void 0 ? void 0 : (_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.finished) === false;
|
|
320
320
|
// 获取编辑器更新函数
|
|
321
321
|
var _useMEditor = _sliced_to_array(useMEditor(node), 2), update = _useMEditor[1];
|
|
322
322
|
// 判断是否是最后一个节点
|
|
@@ -334,11 +334,11 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
|
|
|
334
334
|
useEffect(function() {
|
|
335
335
|
if (isUnclosed && !readonly && !isLastNode) {
|
|
336
336
|
var _node_otherProps;
|
|
337
|
-
// 检查
|
|
338
|
-
if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.
|
|
337
|
+
// 检查 finished 是否仍然是 false(可能已经被其他逻辑更新)
|
|
338
|
+
if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finished) === false) {
|
|
339
339
|
update({
|
|
340
340
|
otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
|
|
341
|
-
|
|
341
|
+
finished: true
|
|
342
342
|
})
|
|
343
343
|
}, node);
|
|
344
344
|
}
|
|
@@ -355,11 +355,11 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
|
|
|
355
355
|
if (isUnclosed && !readonly && isLastNode) {
|
|
356
356
|
var timer = setTimeout(function() {
|
|
357
357
|
var _node_otherProps;
|
|
358
|
-
// 检查
|
|
359
|
-
if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.
|
|
358
|
+
// 检查 finished 是否仍然是 false(可能已经被其他逻辑更新)
|
|
359
|
+
if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finished) === false) {
|
|
360
360
|
update({
|
|
361
361
|
otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
|
|
362
|
-
|
|
362
|
+
finished: true
|
|
363
363
|
})
|
|
364
364
|
}, node);
|
|
365
365
|
}
|
|
@@ -99,7 +99,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
99
99
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
100
100
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
101
101
|
}
|
|
102
|
-
import { ConfigProvider, theme as antdTheme } from "antd";
|
|
102
|
+
import { ConfigProvider, Skeleton, theme as antdTheme } from "antd";
|
|
103
103
|
import React, { useEffect, useMemo, useState } from "react";
|
|
104
104
|
import { MarkdownEditor } from "../../../MarkdownEditor";
|
|
105
105
|
import { useEditorStore } from "../../../MarkdownEditor/editor/store";
|
|
@@ -163,18 +163,18 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
|
|
|
163
163
|
viewMode: viewMode
|
|
164
164
|
}).toolbarProps;
|
|
165
165
|
// 检查代码块是否未闭合
|
|
166
|
-
var isUnclosed = ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.
|
|
166
|
+
var isUnclosed = ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finished) === false;
|
|
167
167
|
// 5 秒超时机制:如果代码块未闭合,5 秒后自动设置为完成
|
|
168
168
|
useEffect(function() {
|
|
169
169
|
if (isUnclosed && !readonly) {
|
|
170
170
|
var timer = setTimeout(function() {
|
|
171
171
|
var _props_element_otherProps, _props_element;
|
|
172
|
-
// 检查
|
|
173
|
-
if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.
|
|
172
|
+
// 检查 finished 是否仍然是 false(可能已经被其他逻辑更新)
|
|
173
|
+
if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finished) === false) {
|
|
174
174
|
var _props_element1;
|
|
175
175
|
update({
|
|
176
176
|
otherProps: _object_spread_props(_object_spread({}, (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : _props_element1.otherProps), {
|
|
177
|
-
|
|
177
|
+
finished: true
|
|
178
178
|
})
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -186,13 +186,30 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
|
|
|
186
186
|
}, [
|
|
187
187
|
isUnclosed,
|
|
188
188
|
readonly,
|
|
189
|
-
(_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element1.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.
|
|
189
|
+
(_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element1.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.finished,
|
|
190
190
|
update
|
|
191
191
|
]);
|
|
192
192
|
// 渲染组件
|
|
193
193
|
return useMemo(function() {
|
|
194
|
-
//
|
|
194
|
+
// 配置型 HTML 代码块:如果未完成且内容较长,显示 skeleton
|
|
195
195
|
if (shouldHideConfigHtml) {
|
|
196
|
+
var _props_element_otherProps, _props_element, _props_element_value, _props_element1;
|
|
197
|
+
var isUnclosed = ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finished) === false;
|
|
198
|
+
var contentLength = ((_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_value = _props_element1.value) === null || _props_element_value === void 0 ? void 0 : _props_element_value.length) || 0;
|
|
199
|
+
var isLongContent = contentLength > 100; // 内容超过 100 字符视为较长
|
|
200
|
+
// 如果未完成且内容较长,显示 skeleton
|
|
201
|
+
if (isUnclosed && isLongContent) {
|
|
202
|
+
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
|
|
203
|
+
style: {
|
|
204
|
+
padding: '20px'
|
|
205
|
+
}
|
|
206
|
+
}), /*#__PURE__*/ React.createElement(Skeleton, {
|
|
207
|
+
active: true,
|
|
208
|
+
paragraph: {
|
|
209
|
+
rows: 3
|
|
210
|
+
}
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
196
213
|
return null;
|
|
197
214
|
}
|
|
198
215
|
// 只读模式下的思考块特殊渲染
|
|
@@ -203,7 +220,7 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
|
|
|
203
220
|
}
|
|
204
221
|
// 主要的代码编辑器渲染
|
|
205
222
|
if (shouldRenderAsCodeEditor) {
|
|
206
|
-
var _editorProps_codeProps,
|
|
223
|
+
var _editorProps_codeProps, _props_element2, _props_element3;
|
|
207
224
|
return /*#__PURE__*/ React.createElement(ConfigProvider, {
|
|
208
225
|
theme: {
|
|
209
226
|
algorithm: theme === 'chaos' ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm
|
|
@@ -229,9 +246,9 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
|
|
|
229
246
|
display: isExpanded ? 'block' : 'none'
|
|
230
247
|
}
|
|
231
248
|
}, viewMode === 'preview' && props.element.language === 'html' && /*#__PURE__*/ React.createElement(HtmlPreview, {
|
|
232
|
-
htmlStr: (
|
|
249
|
+
htmlStr: (_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : _props_element2.value
|
|
233
250
|
}), viewMode === 'preview' && props.element.language && props.element.language === 'markdown' && /*#__PURE__*/ React.createElement(MarkdownEditor, {
|
|
234
|
-
initValue: (
|
|
251
|
+
initValue: (_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : _props_element3.value
|
|
235
252
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
236
253
|
style: {
|
|
237
254
|
height: '100%',
|
|
@@ -48,9 +48,9 @@ import { LoadImage } from "./LoadImage";
|
|
|
48
48
|
// 检查代码块是否未闭合 - 使用 useMemo 确保正确响应变化
|
|
49
49
|
var isUnclosed = useMemo(function() {
|
|
50
50
|
var _element_otherProps;
|
|
51
|
-
return (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.
|
|
51
|
+
return (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.finished) === false;
|
|
52
52
|
}, [
|
|
53
|
-
element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.
|
|
53
|
+
element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.finished
|
|
54
54
|
]);
|
|
55
55
|
return /*#__PURE__*/ React.createElement("div", {
|
|
56
56
|
"data-testid": "code-toolbar",
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React, { type FC } from 'react';
|
|
2
|
+
export interface TaskItem {
|
|
3
|
+
key: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
content?: React.ReactNode | React.ReactNode[];
|
|
6
|
+
status: 'success' | 'pending' | 'loading' | 'error';
|
|
7
|
+
}
|
|
2
8
|
export interface TaskItemInput {
|
|
3
|
-
items:
|
|
4
|
-
key: string;
|
|
5
|
-
title?: string;
|
|
6
|
-
content?: React.ReactNode | React.ReactNode[];
|
|
7
|
-
status: 'success' | 'pending' | 'loading' | 'error';
|
|
8
|
-
}[];
|
|
9
|
+
items: TaskItem[];
|
|
9
10
|
}
|
|
10
|
-
export
|
|
11
|
+
export interface TaskListProps {
|
|
12
|
+
/** 任务列表数据 */
|
|
11
13
|
data: TaskItemInput;
|
|
12
|
-
|
|
14
|
+
/** 点击任务项时的回调 */
|
|
15
|
+
onItemClick?: (item: TaskItem) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const TaskList: FC<TaskListProps>;
|
|
@@ -35,17 +35,34 @@ var StatusIcon = function(param) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
export var TaskList = function(param) {
|
|
38
|
-
var data = param.data;
|
|
38
|
+
var data = param.data, onItemClick = param.onItemClick;
|
|
39
39
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
40
40
|
var prefixCls = getPrefixCls('agentic-workspace-task');
|
|
41
41
|
var _useTaskStyle = useTaskStyle(prefixCls), wrapSSR = _useTaskStyle.wrapSSR, hashId = _useTaskStyle.hashId;
|
|
42
|
+
var handleItemClick = function(item) {
|
|
43
|
+
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
44
|
+
};
|
|
42
45
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
43
46
|
className: classNames(prefixCls, hashId),
|
|
44
47
|
"data-testid": "task-list"
|
|
45
48
|
}, data.items.map(function(item) {
|
|
46
49
|
return /*#__PURE__*/ React.createElement("div", {
|
|
47
50
|
key: item.key,
|
|
48
|
-
className: classNames("".concat(prefixCls, "-item"), "".concat(prefixCls, "-item-").concat(item.status), hashId)
|
|
51
|
+
className: classNames("".concat(prefixCls, "-item"), "".concat(prefixCls, "-item-").concat(item.status), hashId),
|
|
52
|
+
role: onItemClick ? 'button' : undefined,
|
|
53
|
+
tabIndex: onItemClick ? 0 : undefined,
|
|
54
|
+
onClick: onItemClick ? function() {
|
|
55
|
+
return handleItemClick(item);
|
|
56
|
+
} : undefined,
|
|
57
|
+
onKeyDown: onItemClick ? function(e) {
|
|
58
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
handleItemClick(item);
|
|
61
|
+
}
|
|
62
|
+
} : undefined,
|
|
63
|
+
style: {
|
|
64
|
+
cursor: onItemClick ? 'pointer' : undefined
|
|
65
|
+
}
|
|
49
66
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
50
67
|
className: classNames("".concat(prefixCls, "-status"), hashId)
|
|
51
68
|
}, /*#__PURE__*/ React.createElement(StatusIcon, {
|