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,
},
},
onCreate() {
// NOTICE: 这个函数是为了避免触发固定布局 flowDocument.addBlocksAsChildren
},
};

View File

@ -229,7 +229,8 @@ export class FlowDocument<T = FlowDocumentJSON> implements Disposable {
addNode(
data: AddNodeData,
addedNodes?: FlowNodeEntity[],
ignoreCreateAndUpdateEvent?: boolean
ignoreCreateAndUpdateEvent?: boolean,
ignoreBlocks?: boolean
): FlowNodeEntity {
const { id, type = 'block', originParent, parent, meta, hidden, index } = data;
let node = this.getNode(id);
@ -278,7 +279,7 @@ export class FlowDocument<T = FlowDocumentJSON> implements Disposable {
if (extendNodes && addedNodes) {
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) {
this.addInlineBlocks(node, data.blocks, addedNodes);

View File

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

View File

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