diff --git a/src/modules/management/components/KnowledgeBasePanel.jsx b/src/modules/management/components/KnowledgeBasePanel.jsx index 6fa103f..acb81ee 100644 --- a/src/modules/management/components/KnowledgeBasePanel.jsx +++ b/src/modules/management/components/KnowledgeBasePanel.jsx @@ -78,6 +78,32 @@ function collectPublishWarnings(node, warnings = []) { return warnings; } +function getFlowNodeWidth(level) { + return level >= 2 ? 260 : 300; +} + +function getFlowChildGap(level) { + return level >= 2 ? 56 : 40; +} + +function getFlowSubtreeWidth(node, level = 0) { + if (!node) return getFlowNodeWidth(level); + const children = node.children || []; + const nodeWidth = getFlowNodeWidth(level); + const horizontalPadding = level >= 2 ? 56 : 72; + + if (!children.length) { + return nodeWidth + horizontalPadding; + } + + const gap = getFlowChildGap(level); + const childrenWidth = + children.reduce((total, child) => total + getFlowSubtreeWidth(child, level + 1), 0) + + Math.max(0, children.length - 1) * gap; + + return Math.max(nodeWidth + horizontalPadding, childrenWidth); +} + function WhatsAppPreview({ message }) { return (