RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(web): resize the mind map graph when its container changes size (#18616)
chanx26581955d5bc
diff --git a/web/src/components/indented-tree/indented-tree.tsx b/web/src/components/indented-tree/indented-tree.tsxindex 6b455f6eec..ceb5013246 100644--- a/web/src/components/indented-tree/indented-tree.tsx+++ b/web/src/components/indented-tree/indented-tree.tsx@@ -15,6 +15,7 @@*/import { Graph as G6Graph, treeToGraphData } from '@antv/g6';+import { useSize } from 'ahooks';import { useEffect, useMemo, useRef } from 'react';const assignIds = (node: any, parentId: string = '', index = 0) => {@@ -46,6 +47,9 @@ export const IndentedTree = (props: GraphProps) => {const containerRef = useRef<HTMLDivElement>(null);const graphRef = useRef<G6Graph>();+ const size = useSize(containerRef);+ const width = size?.width;+ const height = size?.height;const options = useMemo(() => ({@@ -123,5 +127,19 @@ export const IndentedTree = (props: GraphProps) => {.catch((error) => console.debug(error));}, [options, data, onRender]);+ // G6 sizes its canvas at creation time, so the graph must be resized and+ // re-fitted whenever the container (window / sheet) changes size.+ useEffect(() => {+ const graph = graphRef.current;++ if (!graph || graph.destroyed || !width || !height) return;++ const [canvasWidth, canvasHeight] = graph.getSize();+ if (canvasWidth === width && canvasHeight === height) return;++ graph.resize(width, height);+ graph.fitView().catch((error: unknown) => console.debug(error));+ }, [width, height]);+return <div ref={containerRef} style={{ width: '100%', height: '100%' }} />;};