utils.ts 518 B

12345678910111213141516171819
  1. import { FlowDocument, FlowNodeEntity } from '@flowgram.ai/editor';
  2. export function getNodeChildrenIds(node: FlowNodeEntity | undefined, isBranch: boolean = false) {
  3. if (!node) {
  4. return [];
  5. }
  6. if (isBranch) {
  7. return getNodeChildrenIds(
  8. node.collapsedChildren.find(c => c.id === `$inlineBlocks$${node.id}`),
  9. );
  10. }
  11. return node?.collapsedChildren.map(c => c.id);
  12. }
  13. export function getRootChildrenIds(flowDocument: FlowDocument) {
  14. return getNodeChildrenIds(flowDocument.getNode('root'));
  15. }