@ant-design/agentic-ui 2.29.8 → 2.29.9
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.
|
@@ -204,17 +204,6 @@ export declare class EditorStore {
|
|
|
204
204
|
* @private
|
|
205
205
|
*/
|
|
206
206
|
private _parseAndSetContentWithRAF;
|
|
207
|
-
/**
|
|
208
|
-
* 使用 requestAnimationFrame 分批设置内容
|
|
209
|
-
* 每帧插入一批节点,避免长时间阻塞主线程
|
|
210
|
-
*
|
|
211
|
-
* @param allNodes - 所有要插入的节点
|
|
212
|
-
* @param batchSize - 每帧处理的节点数量
|
|
213
|
-
* @param onProgress - 进度回调函数
|
|
214
|
-
* @returns Promise,在所有节点插入完成后 resolve
|
|
215
|
-
* @private
|
|
216
|
-
*/
|
|
217
|
-
private _setContentWithRAF;
|
|
218
207
|
/**
|
|
219
208
|
* 按指定分隔符拆分 markdown 内容
|
|
220
209
|
* 保持内容结构的完整性
|
|
@@ -648,64 +648,6 @@ export var EditorStoreContext = createContext(null);
|
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
650
|
},
|
|
651
|
-
{
|
|
652
|
-
key: "_setContentWithRAF",
|
|
653
|
-
value: /**
|
|
654
|
-
* 使用 requestAnimationFrame 分批设置内容
|
|
655
|
-
* 每帧插入一批节点,避免长时间阻塞主线程
|
|
656
|
-
*
|
|
657
|
-
* @param allNodes - 所有要插入的节点
|
|
658
|
-
* @param batchSize - 每帧处理的节点数量
|
|
659
|
-
* @param onProgress - 进度回调函数
|
|
660
|
-
* @returns Promise,在所有节点插入完成后 resolve
|
|
661
|
-
* @private
|
|
662
|
-
*/ function _setContentWithRAF(allNodes, batchSize, onProgress) {
|
|
663
|
-
var _this = this;
|
|
664
|
-
return new Promise(function(resolve, reject) {
|
|
665
|
-
var currentIndex = 0;
|
|
666
|
-
var totalNodes = allNodes.length;
|
|
667
|
-
var rafId = null;
|
|
668
|
-
var insertBatch = function() {
|
|
669
|
-
try {
|
|
670
|
-
var endIndex = Math.min(currentIndex + batchSize, totalNodes);
|
|
671
|
-
var batch = allNodes.slice(currentIndex, endIndex);
|
|
672
|
-
if (currentIndex === 0) {
|
|
673
|
-
// 第一批:清空并插入
|
|
674
|
-
_this._editor.current.children = batch;
|
|
675
|
-
_this._editor.current.onChange();
|
|
676
|
-
} else {
|
|
677
|
-
var // 后续批次:追加节点
|
|
678
|
-
_this__editor_current_children;
|
|
679
|
-
(_this__editor_current_children = _this._editor.current.children).push.apply(_this__editor_current_children, _to_consumable_array(batch));
|
|
680
|
-
_this._editor.current.onChange();
|
|
681
|
-
}
|
|
682
|
-
currentIndex = endIndex;
|
|
683
|
-
var progress = currentIndex / totalNodes;
|
|
684
|
-
// 直接调用进度回调,避免嵌套 requestAnimationFrame
|
|
685
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
|
|
686
|
-
if (currentIndex < totalNodes) {
|
|
687
|
-
// 还有节点未处理,继续下一帧
|
|
688
|
-
rafId = requestAnimationFrame(insertBatch);
|
|
689
|
-
} else {
|
|
690
|
-
// 所有节点处理完成
|
|
691
|
-
ReactEditor.deselect(_this._editor.current);
|
|
692
|
-
rafId = null;
|
|
693
|
-
resolve();
|
|
694
|
-
}
|
|
695
|
-
} catch (error) {
|
|
696
|
-
// 清理资源并拒绝 Promise
|
|
697
|
-
if (rafId) {
|
|
698
|
-
cancelAnimationFrame(rafId);
|
|
699
|
-
rafId = null;
|
|
700
|
-
}
|
|
701
|
-
reject(error);
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
// 开始第一帧
|
|
705
|
-
rafId = requestAnimationFrame(insertBatch);
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
},
|
|
709
651
|
{
|
|
710
652
|
key: "_splitMarkdown",
|
|
711
653
|
value: /**
|
|
@@ -952,67 +894,17 @@ export var EditorStoreContext = createContext(null);
|
|
|
952
894
|
* @param nodeList - 要设置为编辑器内容的节点列表
|
|
953
895
|
*/ key: "setContent",
|
|
954
896
|
value: function setContent(nodeList) {
|
|
955
|
-
var _this = this;
|
|
956
897
|
var currentChildren = this._editor.current.children;
|
|
957
|
-
|
|
958
|
-
// 逐个比较节点,如果 hash 和 finished 相同就保留旧节点,否则使用新节点
|
|
959
|
-
for(var i = 0; i < nodeList.length; i++){
|
|
960
|
-
var newNode = nodeList[i];
|
|
961
|
-
var oldNode = currentChildren[i];
|
|
962
|
-
// 如果旧节点不存在,直接使用新节点
|
|
963
|
-
if (!oldNode) {
|
|
964
|
-
resultChildren.push(newNode);
|
|
965
|
-
continue;
|
|
966
|
-
}
|
|
967
|
-
// 如果 hash 和 finished 都相同,保留旧节点,继续处理下一个
|
|
968
|
-
if (this._isNodeEqual(newNode, oldNode)) {
|
|
969
|
-
resultChildren.push(oldNode);
|
|
970
|
-
continue;
|
|
971
|
-
}
|
|
972
|
-
// hash 或 finished 不相同,使用新节点替换
|
|
973
|
-
resultChildren.push(newNode);
|
|
974
|
-
}
|
|
975
|
-
// 使用批处理模式执行所有操作
|
|
976
|
-
Editor.withoutNormalizing(this._editor.current, function() {
|
|
977
|
-
// 先删除多余的节点(从后往前删除,避免索引变化)
|
|
978
|
-
if (currentChildren.length > resultChildren.length) {
|
|
979
|
-
for(var i = currentChildren.length - 1; i >= resultChildren.length; i--){
|
|
980
|
-
Transforms.removeNodes(_this._editor.current, {
|
|
981
|
-
at: [
|
|
982
|
-
i
|
|
983
|
-
]
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
// 然后逐个替换或插入节点(从前往后处理)
|
|
988
|
-
for(var i1 = 0; i1 < resultChildren.length; i1++){
|
|
989
|
-
var newNode = resultChildren[i1];
|
|
990
|
-
var oldNode = currentChildren[i1];
|
|
991
|
-
if (!oldNode) {
|
|
992
|
-
// 旧节点不存在,插入新节点
|
|
993
|
-
Transforms.insertNodes(_this._editor.current, newNode, {
|
|
994
|
-
at: [
|
|
995
|
-
i1
|
|
996
|
-
]
|
|
997
|
-
});
|
|
998
|
-
} else if (oldNode !== newNode) {
|
|
999
|
-
// 节点不同,替换节点
|
|
1000
|
-
_this._replaceNodeAt([
|
|
1001
|
-
i1
|
|
1002
|
-
], newNode);
|
|
1003
|
-
}
|
|
1004
|
-
// 如果 oldNode === newNode,说明是同一个对象引用,不需要更新
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
898
|
+
this._editor.current.children = nodeList;
|
|
1007
899
|
this._editor.current.onChange();
|
|
1008
900
|
// 检查最后一个节点是否以换行符结尾
|
|
1009
|
-
var lastNode =
|
|
901
|
+
var lastNode = currentChildren[currentChildren.length - 1];
|
|
1010
902
|
if (lastNode && Text.isText(lastNode)) {
|
|
1011
903
|
var text = Node.string(lastNode);
|
|
1012
904
|
if (!text.endsWith('\n')) {
|
|
1013
905
|
this._editor.current.insertText('\n', {
|
|
1014
906
|
at: [
|
|
1015
|
-
|
|
907
|
+
currentChildren.length - 1
|
|
1016
908
|
]
|
|
1017
909
|
});
|
|
1018
910
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.9",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"preview": "pnpm dumi preview",
|
|
28
28
|
"report:demo": "node scripts/generateDemoReport.js",
|
|
29
29
|
"start": "pnpm run dev",
|
|
30
|
-
"test": "
|
|
30
|
+
"test": "vitest --run --exclude \"**/e2e/**\"",
|
|
31
31
|
"test:coverage": "vitest --run --exclude \"**/e2e/**\" --coverage",
|
|
32
32
|
"test:e2e": "playwright test",
|
|
33
33
|
"test:e2e:debug": "playwright test --debug",
|