@ant-design/agentic-ui 2.0.22 → 2.0.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/Components/GradientText/index.d.ts +2 -1
- package/dist/Components/GradientText/index.js +3 -2
- package/dist/Components/GradientText/style.js +3 -8
- package/dist/Components/TextAnimate/index.d.ts +1 -0
- package/dist/Components/TextAnimate/index.js +27 -16
- package/dist/Components/TypingAnimation/index.d.ts +1 -1
- package/dist/Components/TypingAnimation/index.js +9 -9
- package/dist/MarkdownEditor/editor/components/LazyElement/index.js +36 -4
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +4 -0
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +245 -344
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +74 -56
- package/dist/MarkdownEditor/editor/store.d.ts +36 -0
- package/dist/MarkdownEditor/editor/store.js +208 -76
- package/dist/MarkdownInputField/MarkdownInputField.js +12 -1
- package/dist/MarkdownInputField/SendButton/index.js +3 -0
- package/dist/Schema/SchemaRenderer/index.js +80 -55
- package/dist/Utils/proxySandbox/ProxySandbox.d.ts +32 -0
- package/dist/Utils/proxySandbox/ProxySandbox.js +170 -128
- package/dist/WelcomeMessage/index.d.ts +2 -2
- package/dist/WelcomeMessage/index.js +8 -5
- package/dist/WelcomeMessage/style.js +0 -1
- package/package.json +1 -1
|
@@ -23,66 +23,84 @@ import { Node } from "slate";
|
|
|
23
23
|
import stringWidth from "string-width";
|
|
24
24
|
import { getMediaType } from "../utils/dom";
|
|
25
25
|
var inlineNode = /* @__PURE__ */ new Set(["break"]);
|
|
26
|
-
var
|
|
26
|
+
var tryPluginConversion = (node, preString, parent, plugins) => {
|
|
27
27
|
var _a;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
if (!(plugins == null ? void 0 : plugins.length))
|
|
29
|
+
return null;
|
|
30
|
+
for (const plugin of plugins) {
|
|
31
|
+
const rule = (_a = plugin.toMarkdown) == null ? void 0 : _a.find((r) => r.match(node));
|
|
32
|
+
if (!rule)
|
|
33
|
+
continue;
|
|
34
|
+
const converted = rule.convert(node);
|
|
35
|
+
return convertPluginNode(converted, preString, parent, plugins);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
var convertPluginNode = (converted, preString, parent, plugins) => {
|
|
40
|
+
switch (converted.type) {
|
|
41
|
+
case "code":
|
|
42
|
+
return convertCodeNode(converted, preString);
|
|
43
|
+
case "blockquote":
|
|
44
|
+
return convertBlockquoteNode(converted, preString, parent, plugins);
|
|
45
|
+
case "paragraph":
|
|
46
|
+
return convertParagraphNode(converted, preString, parent, plugins);
|
|
47
|
+
case "heading":
|
|
48
|
+
return convertHeadingNode(converted, preString, parent, plugins);
|
|
49
|
+
case "text":
|
|
50
|
+
return converted.value || "";
|
|
51
|
+
default:
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var convertCodeNode = (codeNode, preString) => {
|
|
56
|
+
const language = codeNode.lang || "";
|
|
57
|
+
const value = codeNode.value || "";
|
|
58
|
+
if (!(value == null ? void 0 : value.trim())) {
|
|
59
|
+
return `${preString}\`\`\`${language}
|
|
42
60
|
${preString}\`\`\``;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}).join("\n");
|
|
51
|
-
return `${preString}\`\`\`${language}
|
|
61
|
+
}
|
|
62
|
+
const codeLines = value.split("\n");
|
|
63
|
+
const indentedCode = codeLines.map((line, index) => {
|
|
64
|
+
const isFirstOrLast = index === 0 || index === codeLines.length - 1;
|
|
65
|
+
return isFirstOrLast ? line : preString + line;
|
|
66
|
+
}).join("\n");
|
|
67
|
+
return `${preString}\`\`\`${language}
|
|
52
68
|
${indentedCode}
|
|
53
69
|
${preString}\`\`\``;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
};
|
|
71
|
+
var convertBlockquoteNode = (blockquoteNode, preString, parent, plugins) => {
|
|
72
|
+
return "> " + parserSlateNodeToMarkdown(
|
|
73
|
+
blockquoteNode.children || [],
|
|
74
|
+
preString,
|
|
75
|
+
[...parent, __spreadProps(__spreadValues({}, blockquoteNode), { converted: true })],
|
|
76
|
+
plugins
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
var convertParagraphNode = (paragraphNode, preString, parent, plugins) => {
|
|
80
|
+
return preString + parserSlateNodeToMarkdown(
|
|
81
|
+
paragraphNode.children || [],
|
|
82
|
+
preString,
|
|
83
|
+
[...parent, __spreadProps(__spreadValues({}, paragraphNode), { converted: true })],
|
|
84
|
+
plugins
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
var convertHeadingNode = (headingNode, preString, parent, plugins) => {
|
|
88
|
+
const level = headingNode.depth || 1;
|
|
89
|
+
const content = parserSlateNodeToMarkdown(
|
|
90
|
+
headingNode.children || [],
|
|
91
|
+
preString,
|
|
92
|
+
[...parent, __spreadProps(__spreadValues({}, headingNode), { converted: true })],
|
|
93
|
+
plugins
|
|
94
|
+
);
|
|
95
|
+
return "#".repeat(level) + " " + content.replace(/\n+$/, "");
|
|
96
|
+
};
|
|
97
|
+
var parserNode = (node, preString = "", parent, plugins) => {
|
|
98
|
+
let str = "";
|
|
99
|
+
if (!node)
|
|
100
|
+
return str;
|
|
101
|
+
const pluginResult = tryPluginConversion(node, preString, parent, plugins);
|
|
102
|
+
if (pluginResult !== null) {
|
|
103
|
+
return pluginResult;
|
|
86
104
|
}
|
|
87
105
|
switch (node.type) {
|
|
88
106
|
case "card-before":
|
|
@@ -330,6 +330,42 @@ export declare class EditorStore {
|
|
|
330
330
|
* @private
|
|
331
331
|
*/
|
|
332
332
|
private compareCells;
|
|
333
|
+
/**
|
|
334
|
+
* 比较单元格属性
|
|
335
|
+
*/
|
|
336
|
+
private compareCellProperties;
|
|
337
|
+
/**
|
|
338
|
+
* 比较单元格子节点
|
|
339
|
+
*/
|
|
340
|
+
private compareCellChildren;
|
|
341
|
+
/**
|
|
342
|
+
* 判断是否是简单文本单元格
|
|
343
|
+
*/
|
|
344
|
+
private isSimpleTextCell;
|
|
345
|
+
/**
|
|
346
|
+
* 比较简单文本单元格
|
|
347
|
+
*/
|
|
348
|
+
private compareSimpleTextCell;
|
|
349
|
+
/**
|
|
350
|
+
* 比较文本节点属性
|
|
351
|
+
*/
|
|
352
|
+
private compareTextNodeProperties;
|
|
353
|
+
/**
|
|
354
|
+
* 比较复杂单元格子节点
|
|
355
|
+
*/
|
|
356
|
+
private compareComplexCellChildren;
|
|
357
|
+
/**
|
|
358
|
+
* 判断结构是否不同
|
|
359
|
+
*/
|
|
360
|
+
private isStructurallyDifferent;
|
|
361
|
+
/**
|
|
362
|
+
* 替换复杂单元格子节点
|
|
363
|
+
*/
|
|
364
|
+
private replaceComplexCellChildren;
|
|
365
|
+
/**
|
|
366
|
+
* 逐个比较子节点
|
|
367
|
+
*/
|
|
368
|
+
private compareChildrenSequentially;
|
|
333
369
|
/**
|
|
334
370
|
* 执行操作队列中的所有操作。
|
|
335
371
|
*
|
|
@@ -242,27 +242,76 @@ var EditorStore = class {
|
|
|
242
242
|
var _a, _b, _c, _d;
|
|
243
243
|
if (md === void 0)
|
|
244
244
|
return;
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
try {
|
|
246
|
+
const currentMD = parserSlateNodeToMarkdown(
|
|
247
|
+
this._editor.current.children
|
|
248
|
+
);
|
|
249
|
+
if (md.trim() === currentMD.trim())
|
|
250
|
+
return;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console.warn(
|
|
253
|
+
"Failed to compare current content, proceeding with setMDContent:",
|
|
254
|
+
error
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
this.cancelSetMDContent();
|
|
247
258
|
const chunkSize = (_a = options == null ? void 0 : options.chunkSize) != null ? _a : 5e3;
|
|
248
259
|
const separator = (_b = options == null ? void 0 : options.separator) != null ? _b : /\n\n/;
|
|
249
260
|
const useRAF = (_c = options == null ? void 0 : options.useRAF) != null ? _c : true;
|
|
250
261
|
const batchSize = (_d = options == null ? void 0 : options.batchSize) != null ? _d : 50;
|
|
251
262
|
const targetPlugins = plugins || this.plugins;
|
|
252
263
|
if (md.length <= chunkSize) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
options.onProgress
|
|
264
|
+
try {
|
|
265
|
+
const nodeList = parserMdToSchema(md, targetPlugins).schema;
|
|
266
|
+
this.setContent(nodeList);
|
|
267
|
+
this._editor.current.children = nodeList;
|
|
268
|
+
ReactEditor.deselect(this._editor.current);
|
|
269
|
+
if (options == null ? void 0 : options.onProgress) {
|
|
270
|
+
options.onProgress(1);
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error("Failed to set MD content:", error);
|
|
274
|
+
throw error;
|
|
259
275
|
}
|
|
260
276
|
return;
|
|
261
277
|
}
|
|
278
|
+
const chunks = this._splitMarkdown(md, separator);
|
|
262
279
|
if (!useRAF) {
|
|
263
|
-
|
|
280
|
+
try {
|
|
281
|
+
const allNodes = [];
|
|
282
|
+
for (const chunk of chunks) {
|
|
283
|
+
if (chunk.trim()) {
|
|
284
|
+
const { schema } = parserMdToSchema(chunk, targetPlugins);
|
|
285
|
+
allNodes.push(...schema);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (allNodes.length > 0) {
|
|
289
|
+
this.setContent(allNodes);
|
|
290
|
+
this._editor.current.children = allNodes;
|
|
291
|
+
ReactEditor.deselect(this._editor.current);
|
|
292
|
+
}
|
|
293
|
+
if (options == null ? void 0 : options.onProgress) {
|
|
294
|
+
options.onProgress(1);
|
|
295
|
+
}
|
|
296
|
+
} catch (error) {
|
|
297
|
+
console.error("Failed to set MD content synchronously:", error);
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (chunks.length > 10) {
|
|
303
|
+
this._currentAbortController = new AbortController();
|
|
304
|
+
return this._parseAndSetContentWithRAF(
|
|
305
|
+
chunks,
|
|
306
|
+
targetPlugins || [],
|
|
307
|
+
batchSize,
|
|
308
|
+
options == null ? void 0 : options.onProgress,
|
|
309
|
+
this._currentAbortController.signal
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
264
313
|
const allNodes = [];
|
|
265
|
-
for (const chunk of
|
|
314
|
+
for (const chunk of chunks) {
|
|
266
315
|
if (chunk.trim()) {
|
|
267
316
|
const { schema } = parserMdToSchema(chunk, targetPlugins);
|
|
268
317
|
allNodes.push(...schema);
|
|
@@ -276,18 +325,9 @@ var EditorStore = class {
|
|
|
276
325
|
if (options == null ? void 0 : options.onProgress) {
|
|
277
326
|
options.onProgress(1);
|
|
278
327
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (useRAF && chunks.length > 10) {
|
|
283
|
-
this._currentAbortController = new AbortController();
|
|
284
|
-
return this._parseAndSetContentWithRAF(
|
|
285
|
-
chunks,
|
|
286
|
-
targetPlugins || [],
|
|
287
|
-
batchSize,
|
|
288
|
-
options == null ? void 0 : options.onProgress,
|
|
289
|
-
this._currentAbortController.signal
|
|
290
|
-
);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.error("Failed to set MD content with small chunks:", error);
|
|
330
|
+
throw error;
|
|
291
331
|
}
|
|
292
332
|
}
|
|
293
333
|
/**
|
|
@@ -328,6 +368,15 @@ var EditorStore = class {
|
|
|
328
368
|
reject(new Error("Operation was cancelled"));
|
|
329
369
|
return;
|
|
330
370
|
}
|
|
371
|
+
if (!this._editor.current) {
|
|
372
|
+
if (rafId) {
|
|
373
|
+
cancelAnimationFrame(rafId);
|
|
374
|
+
rafId = null;
|
|
375
|
+
}
|
|
376
|
+
this._currentAbortController = null;
|
|
377
|
+
reject(new Error("Editor instance is no longer available"));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
331
380
|
const endIndex = Math.min(
|
|
332
381
|
currentChunkIndex + parseChunksPerFrame,
|
|
333
382
|
totalChunks
|
|
@@ -335,24 +384,32 @@ var EditorStore = class {
|
|
|
335
384
|
for (let i = currentChunkIndex; i < endIndex; i++) {
|
|
336
385
|
const chunk = chunks[i];
|
|
337
386
|
if (chunk.trim()) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
387
|
+
try {
|
|
388
|
+
const { schema } = parserMdToSchema(chunk, plugins);
|
|
389
|
+
if (schema.length > 0) {
|
|
390
|
+
if (isFirstBatch) {
|
|
391
|
+
this._editor.current.children = schema;
|
|
392
|
+
this._editor.current.onChange();
|
|
393
|
+
isFirstBatch = false;
|
|
394
|
+
} else {
|
|
395
|
+
Transforms.insertNodes(this._editor.current, schema, {
|
|
396
|
+
at: [this._editor.current.children.length]
|
|
397
|
+
});
|
|
398
|
+
}
|
|
348
399
|
}
|
|
400
|
+
} catch (chunkError) {
|
|
401
|
+
console.warn(`Failed to parse chunk ${i}:`, chunkError);
|
|
349
402
|
}
|
|
350
403
|
}
|
|
351
404
|
}
|
|
352
405
|
currentChunkIndex = endIndex;
|
|
353
406
|
const progress = currentChunkIndex / totalChunks;
|
|
354
407
|
if (onProgress) {
|
|
355
|
-
|
|
408
|
+
try {
|
|
409
|
+
onProgress(progress);
|
|
410
|
+
} catch (progressError) {
|
|
411
|
+
console.warn("Progress callback failed:", progressError);
|
|
412
|
+
}
|
|
356
413
|
}
|
|
357
414
|
if (currentChunkIndex < totalChunks) {
|
|
358
415
|
rafId = requestAnimationFrame(parseAndInsertNextBatch);
|
|
@@ -817,6 +874,15 @@ var EditorStore = class {
|
|
|
817
874
|
* @private
|
|
818
875
|
*/
|
|
819
876
|
compareCells(newCell, oldCell, path, operations) {
|
|
877
|
+
this.compareCellProperties(newCell, oldCell, path, operations);
|
|
878
|
+
const newChildren = newCell.children || [];
|
|
879
|
+
const oldChildren = oldCell.children || [];
|
|
880
|
+
this.compareCellChildren(newChildren, oldChildren, path, operations);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* 比较单元格属性
|
|
884
|
+
*/
|
|
885
|
+
compareCellProperties(newCell, oldCell, path, operations) {
|
|
820
886
|
const newCellProps = __spreadProps(__spreadValues({}, newCell), { children: void 0 });
|
|
821
887
|
const oldCellProps = __spreadProps(__spreadValues({}, oldCell), { children: void 0 });
|
|
822
888
|
if (!isEqual(newCellProps, oldCellProps)) {
|
|
@@ -827,50 +893,116 @@ var EditorStore = class {
|
|
|
827
893
|
priority: 7
|
|
828
894
|
});
|
|
829
895
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* 比较单元格子节点
|
|
899
|
+
*/
|
|
900
|
+
compareCellChildren(newChildren, oldChildren, path, operations) {
|
|
901
|
+
if (this.isSimpleTextCell(newChildren, oldChildren)) {
|
|
902
|
+
this.compareSimpleTextCell(newChildren, oldChildren, path, operations);
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
this.compareComplexCellChildren(newChildren, oldChildren, path, operations);
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* 判断是否是简单文本单元格
|
|
909
|
+
*/
|
|
910
|
+
isSimpleTextCell(newChildren, oldChildren) {
|
|
911
|
+
return newChildren.length === 1 && oldChildren.length === 1 && typeof newChildren[0].text === "string" && typeof oldChildren[0].text === "string";
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* 比较简单文本单元格
|
|
915
|
+
*/
|
|
916
|
+
compareSimpleTextCell(newChildren, oldChildren, path, operations) {
|
|
917
|
+
if (newChildren[0].text !== oldChildren[0].text) {
|
|
918
|
+
operations.push({
|
|
919
|
+
type: "text",
|
|
920
|
+
path: [...path, 0],
|
|
921
|
+
text: newChildren[0].text,
|
|
922
|
+
priority: 8
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
this.compareTextNodeProperties(
|
|
926
|
+
newChildren[0],
|
|
927
|
+
oldChildren[0],
|
|
928
|
+
path,
|
|
929
|
+
operations
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* 比较文本节点属性
|
|
934
|
+
*/
|
|
935
|
+
compareTextNodeProperties(newChild, oldChild, path, operations) {
|
|
936
|
+
const newTextProps = __spreadValues({}, newChild);
|
|
937
|
+
const oldTextProps = __spreadValues({}, oldChild);
|
|
938
|
+
delete newTextProps.text;
|
|
939
|
+
delete oldTextProps.text;
|
|
940
|
+
if (!isEqual(newTextProps, oldTextProps)) {
|
|
941
|
+
operations.push({
|
|
942
|
+
type: "update",
|
|
943
|
+
path: [...path, 0],
|
|
944
|
+
properties: newTextProps,
|
|
945
|
+
priority: 7
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* 比较复杂单元格子节点
|
|
951
|
+
*/
|
|
952
|
+
compareComplexCellChildren(newChildren, oldChildren, path, operations) {
|
|
953
|
+
const structurallyDifferent = this.isStructurallyDifferent(
|
|
954
|
+
newChildren,
|
|
955
|
+
oldChildren
|
|
956
|
+
);
|
|
957
|
+
if (structurallyDifferent) {
|
|
958
|
+
this.replaceComplexCellChildren(
|
|
959
|
+
newChildren,
|
|
960
|
+
oldChildren,
|
|
961
|
+
path,
|
|
962
|
+
operations
|
|
963
|
+
);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
this.compareChildrenSequentially(
|
|
967
|
+
newChildren,
|
|
968
|
+
oldChildren,
|
|
969
|
+
path,
|
|
970
|
+
operations
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* 判断结构是否不同
|
|
975
|
+
*/
|
|
976
|
+
isStructurallyDifferent(newChildren, oldChildren) {
|
|
977
|
+
if (newChildren.length !== oldChildren.length)
|
|
978
|
+
return true;
|
|
979
|
+
return newChildren.some(
|
|
980
|
+
(n, i) => oldChildren[i] && n.type !== oldChildren[i].type
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* 替换复杂单元格子节点
|
|
985
|
+
*/
|
|
986
|
+
replaceComplexCellChildren(newChildren, oldChildren, path, operations) {
|
|
987
|
+
const childOps = this.generateDiffOperations(newChildren, oldChildren);
|
|
988
|
+
childOps.forEach((op) => {
|
|
989
|
+
operations.push(__spreadProps(__spreadValues({}, op), {
|
|
990
|
+
path: [...path, ...op.path]
|
|
991
|
+
}));
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* 逐个比较子节点
|
|
996
|
+
*/
|
|
997
|
+
compareChildrenSequentially(newChildren, oldChildren, path, operations) {
|
|
998
|
+
const length = Math.min(newChildren.length, oldChildren.length);
|
|
999
|
+
for (let i = 0; i < length; i++) {
|
|
1000
|
+
this.compareNodes(
|
|
1001
|
+
newChildren[i],
|
|
1002
|
+
oldChildren[i],
|
|
1003
|
+
[...path, i],
|
|
1004
|
+
operations
|
|
856
1005
|
);
|
|
857
|
-
if (structurallyDifferent) {
|
|
858
|
-
const childOps = this.generateDiffOperations(newChildren, oldChildren);
|
|
859
|
-
childOps.forEach((op) => {
|
|
860
|
-
operations.push(__spreadProps(__spreadValues({}, op), {
|
|
861
|
-
path: [...path, ...op.path]
|
|
862
|
-
}));
|
|
863
|
-
});
|
|
864
|
-
} else {
|
|
865
|
-
for (let i = 0; i < Math.min(newChildren.length, oldChildren.length); i++) {
|
|
866
|
-
this.compareNodes(
|
|
867
|
-
newChildren[i],
|
|
868
|
-
oldChildren[i],
|
|
869
|
-
[...path, i],
|
|
870
|
-
operations
|
|
871
|
-
);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
1006
|
}
|
|
875
1007
|
}
|
|
876
1008
|
/**
|
|
@@ -106,6 +106,7 @@ var MarkdownInputField = (_a) => {
|
|
|
106
106
|
const markdownEditorRef = React.useRef();
|
|
107
107
|
const quickActionsRef = React.useRef(null);
|
|
108
108
|
const actionsRef = React.useRef(null);
|
|
109
|
+
const isSendingRef = React.useRef(false);
|
|
109
110
|
const [collapseSendActions, setCollapseSendActions] = useState(() => {
|
|
110
111
|
if (typeof window === "undefined")
|
|
111
112
|
return false;
|
|
@@ -199,6 +200,10 @@ var MarkdownInputField = (_a) => {
|
|
|
199
200
|
return;
|
|
200
201
|
if (props.typing)
|
|
201
202
|
return;
|
|
203
|
+
if (isLoading)
|
|
204
|
+
return;
|
|
205
|
+
if (isSendingRef.current)
|
|
206
|
+
return;
|
|
202
207
|
if (recording)
|
|
203
208
|
yield stopRecording();
|
|
204
209
|
const mdValue = (_b3 = (_a3 = markdownEditorRef == null ? void 0 : markdownEditorRef.current) == null ? void 0 : _a3.store) == null ? void 0 : _b3.getMDContent();
|
|
@@ -206,6 +211,7 @@ var MarkdownInputField = (_a) => {
|
|
|
206
211
|
(_c2 = props.onChange) == null ? void 0 : _c2.call(props, mdValue);
|
|
207
212
|
}
|
|
208
213
|
if (props.onSend && (props.allowEmptySubmit || mdValue)) {
|
|
214
|
+
isSendingRef.current = true;
|
|
209
215
|
setIsLoading(true);
|
|
210
216
|
try {
|
|
211
217
|
yield props.onSend(mdValue || "");
|
|
@@ -213,8 +219,12 @@ var MarkdownInputField = (_a) => {
|
|
|
213
219
|
(_f2 = props.onChange) == null ? void 0 : _f2.call(props, "");
|
|
214
220
|
setValue("");
|
|
215
221
|
setFileMap == null ? void 0 : setFileMap(/* @__PURE__ */ new Map());
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error("Send message failed:", error);
|
|
224
|
+
throw error;
|
|
216
225
|
} finally {
|
|
217
226
|
setIsLoading(false);
|
|
227
|
+
isSendingRef.current = false;
|
|
218
228
|
}
|
|
219
229
|
}
|
|
220
230
|
}));
|
|
@@ -328,8 +338,9 @@ var MarkdownInputField = (_a) => {
|
|
|
328
338
|
return;
|
|
329
339
|
e.stopPropagation();
|
|
330
340
|
e.preventDefault();
|
|
331
|
-
if (props.onSend)
|
|
341
|
+
if (props.onSend && !isLoading && !props.disabled && !props.typing) {
|
|
332
342
|
sendMessage();
|
|
343
|
+
}
|
|
333
344
|
}
|
|
334
345
|
}
|
|
335
346
|
);
|