diff --git a/packages/nc-gui/components/ai/Erd/Flow.vue b/packages/nc-gui/components/ai/Erd/Flow.vue index f80ca55d10..c5fd5bb770 100644 --- a/packages/nc-gui/components/ai/Erd/Flow.vue +++ b/packages/nc-gui/components/ai/Erd/Flow.vue @@ -32,12 +32,12 @@ async function init() { // Center elements without changing zoom level await nextTick() setTimeout(() => { - fitView({ - duration: 200, + fitView({ + duration: 200, padding: 0.1, // Don't change zoom - keep current zoom level but center the content minZoom: viewport.value.zoom || 1, - maxZoom: viewport.value.zoom || 1 + maxZoom: viewport.value.zoom || 1, }) }, 100) } diff --git a/packages/nc-gui/components/ai/Erd/utils.ts b/packages/nc-gui/components/ai/Erd/utils.ts index 836c5c29da..31b5f5588c 100644 --- a/packages/nc-gui/components/ai/Erd/utils.ts +++ b/packages/nc-gui/components/ai/Erd/utils.ts @@ -76,11 +76,11 @@ export function useErdElements(schema: MaybeRef, props: MaybeRef ({})) - dagreGraph.setGraph({ + dagreGraph.setGraph({ rankdir: 'LR', align: 'UL', nodesep: 50, - ranksep: 100 + ranksep: 100, }) const erdSchema = computed(() => unref(schema)) @@ -232,14 +232,23 @@ export function useErdElements(schema: MaybeRef, props: MaybeRef).data!.columnLength > 0 ? nodeHeight.value * (el as Node).data!.columnLength : nodeHeight.value) - + const height = + nodeHeight.value + + (skeleton + ? 250 + : (el as Node).data!.columnLength > 0 + ? nodeHeight.value * (el as Node).data!.columnLength + : nodeHeight.value) + minX = Math.min(minX, nodeWithPosition.x - width / 2) minY = Math.min(minY, nodeWithPosition.y - height / 2) maxX = Math.max(maxX, nodeWithPosition.x + width / 2) @@ -260,9 +269,9 @@ export function useErdElements(schema: MaybeRef, props: MaybeRef { - fitView({ - duration: 200, + fitView({ + duration: 200, padding: 0.1, // Don't change zoom - keep current zoom level but center the content minZoom: viewport.value.zoom || 1, - maxZoom: viewport.value.zoom || 1 + maxZoom: viewport.value.zoom || 1, }) }, 100) } diff --git a/packages/nc-gui/components/erd/View.vue b/packages/nc-gui/components/erd/View.vue index 1df561f970..4443af4fbc 100644 --- a/packages/nc-gui/components/erd/View.vue +++ b/packages/nc-gui/components/erd/View.vue @@ -129,11 +129,7 @@ const filteredTables = computed(() => ) const currentSource = computed(() => { - return sources.value?.find((source: SourceType) => - props?.sourceId - ? source.id === props.sourceId - : source.enabled - ) + return sources.value?.find((source: SourceType) => (props?.sourceId ? source.id === props.sourceId : source.enabled)) }) const isExternalSource = computed(() => { diff --git a/packages/nc-gui/components/erd/utils.ts b/packages/nc-gui/components/erd/utils.ts index 9b1e2c5a6c..a2ba3ceb8b 100644 --- a/packages/nc-gui/components/erd/utils.ts +++ b/packages/nc-gui/components/erd/utils.ts @@ -60,11 +60,11 @@ export function useErdElements(tables: MaybeRef, props: MaybeRef ({})) - dagreGraph.setGraph({ + dagreGraph.setGraph({ rankdir: 'LR', align: 'UL', nodesep: 50, - ranksep: 100 + ranksep: 100, }) const { metasWithIdAsKey } = useMetas() @@ -296,14 +296,23 @@ export function useErdElements(tables: MaybeRef, props: MaybeRef).data!.columnLength > 0 ? nodeHeight.value * (el as Node).data!.columnLength : nodeHeight.value) - + const height = + nodeHeight.value + + (skeleton + ? 250 + : (el as Node).data!.columnLength > 0 + ? nodeHeight.value * (el as Node).data!.columnLength + : nodeHeight.value) + minX = Math.min(minX, nodeWithPosition.x - width / 2) minY = Math.min(minY, nodeWithPosition.y - height / 2) maxX = Math.max(maxX, nodeWithPosition.x + width / 2) @@ -324,9 +333,9 @@ export function useErdElements(tables: MaybeRef, props: MaybeRef {