diff --git a/frontend/src/features/schema/SchemaCanvas.tsx b/frontend/src/features/schema/SchemaCanvas.tsx index e90c45a..01fc2fd 100644 --- a/frontend/src/features/schema/SchemaCanvas.tsx +++ b/frontend/src/features/schema/SchemaCanvas.tsx @@ -189,7 +189,7 @@ export function SchemaCanvas() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - // Sync display settings + // Sync display settings: grid useEffect(() => { const graph = useSchemaStore.getState().graph; if (!graph) return; @@ -201,6 +201,45 @@ export function SchemaCanvas() { } }, [displaySettings.showGrid]); + // Sync display settings: labels + useEffect(() => { + const graph = useSchemaStore.getState().graph; + if (!graph) return; + + const show = displaySettings.showLabels; + + // Toggle edge labels + for (const edge of graph.getEdges()) { + const labels = edge.getLabels(); + if (labels.length > 0) { + edge.setLabels( + labels.map((label) => ({ + ...label, + attrs: { + ...label.attrs, + label: { + ...(label.attrs?.label as Record), + visibility: show ? 'visible' : 'hidden', + }, + rect: { + ...(label.attrs?.rect as Record), + visibility: show ? 'visible' : 'hidden', + }, + }, + })), + ); + } + } + + // Toggle port labels + for (const node of graph.getNodes()) { + const ports = node.getPorts(); + for (const port of ports) { + node.setPortProp(port.id!, 'attrs/text/visibility', show ? 'visible' : 'hidden'); + } + } + }, [displaySettings.showLabels]); + return (