utils.ts 618 B

123456789101112131415161718192021222324
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { FlowDocument, FlowNodeEntity } from '@flowgram.ai/editor';
  6. export function getNodeChildrenIds(node: FlowNodeEntity | undefined, isBranch: boolean = false) {
  7. if (!node) {
  8. return [];
  9. }
  10. if (isBranch) {
  11. return getNodeChildrenIds(
  12. node.collapsedChildren.find(c => c.id === `$inlineBlocks$${node.id}`),
  13. );
  14. }
  15. return node?.collapsedChildren.map(c => c.id);
  16. }
  17. export function getRootChildrenIds(flowDocument: FlowDocument) {
  18. return getNodeChildrenIds(flowDocument.getNode('root'));
  19. }