fix(core): free document prevent to trigger flowDocument.addBlocksAsChildren (#273)

This commit is contained in:
Louis Young 2025-05-26 16:37:57 +08:00 committed by GitHub
parent 9ae858b363
commit 2da1f3c5bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 8 deletions

View File

@ -74,7 +74,4 @@ export const LoopNodeRegistry: FlowNodeRegistry = {
batchFor: provideBatchInputEffect, batchFor: provideBatchInputEffect,
}, },
}, },
onCreate() {
// NOTICE: 这个函数是为了避免触发固定布局 flowDocument.addBlocksAsChildren
},
}; };

View File

@ -229,7 +229,8 @@ export class FlowDocument<T = FlowDocumentJSON> implements Disposable {
addNode( addNode(
data: AddNodeData, data: AddNodeData,
addedNodes?: FlowNodeEntity[], addedNodes?: FlowNodeEntity[],
ignoreCreateAndUpdateEvent?: boolean ignoreCreateAndUpdateEvent?: boolean,
ignoreBlocks?: boolean
): FlowNodeEntity { ): FlowNodeEntity {
const { id, type = 'block', originParent, parent, meta, hidden, index } = data; const { id, type = 'block', originParent, parent, meta, hidden, index } = data;
let node = this.getNode(id); let node = this.getNode(id);
@ -278,7 +279,7 @@ export class FlowDocument<T = FlowDocumentJSON> implements Disposable {
if (extendNodes && addedNodes) { if (extendNodes && addedNodes) {
addedNodes.push(...extendNodes); addedNodes.push(...extendNodes);
} }
} else if (data.blocks && data.blocks.length > 0) { } else if (data.blocks && data.blocks.length > 0 && !ignoreBlocks) {
// 兼容老的写法 // 兼容老的写法
if (!data.blocks[0].type) { if (!data.blocks[0].type) {
this.addInlineBlocks(node, data.blocks, addedNodes); this.addInlineBlocks(node, data.blocks, addedNodes);

View File

@ -170,6 +170,7 @@ export class WorkflowDocument extends FlowDocument {
parent, parent,
}, },
undefined, undefined,
true,
true true
) as WorkflowNodeEntity; ) as WorkflowNodeEntity;

View File

@ -31,7 +31,4 @@ export const GroupNodeRegistry: FlowNodeRegistry = {
formMeta: { formMeta: {
render: () => <></>, render: () => <></>,
}, },
onCreate() {
// NOTICE: 这个函数是为了避免触发固定布局 flowDocument.addBlocksAsChildren
},
}; };