Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(web): restore flowchart connection handles

tianma-if239e078be45a
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjs
index 468d19aa..d5bb92b7 100644
--- a/apps/web/src/components/DiagramEditorPane.test.mjs
+++ b/apps/web/src/components/DiagramEditorPane.test.mjs
@@ -87,7 +87,18 @@ describe("diagram editor canvas surface", () => {
});
test("shows connection handles only on selected flowchart nodes", () => {
- expect(globalStyles).toContain('.edgeever-diagram-canvas[data-diagram-kind="flowchart"] .x6-node.x6-node-selected .x6-port-body');
+ expect(globalStyles).toContain('.x6-node.edgeever-flow-node-active .x6-port-body');
+ expect(globalStyles).not.toContain('.x6-node.x6-node-selected .x6-port-body');
+ expect(source).toContain('graph.on("node:selected"');
+ expect(source).toContain('setFlowNodePortsActive(graph, node, true)');
+ expect(source).toContain('graph.on("node:unselected"');
+ expect(source).toContain('setFlowNodePortsActive(graph, node, false)');
+ expect(source).toContain('port.style.setProperty("opacity", active ? "1" : "0", "important")');
+ expect(source).toContain('port.style.setProperty("pointer-events", active ? "auto" : "none", "important")');
+ expect(source).toContain('setOnlyFlowNodePortsActive(graph, node)');
+ expect(source).toContain('graph.on("blank:click"');
+ expect(source).toContain('setOnlyFlowNodePortsActive(graph);');
+ expect(globalStyles).toContain("fill: var(--brand-green) !important");
expect(globalStyles).toContain("pointer-events: none");
expect(globalStyles).toContain("pointer-events: auto");
expect(globalStyles).not.toContain('.edgeever-diagram-canvas[data-diagram-kind="flowchart"] .x6-node:hover .x6-port-body');
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsx
index f212e472..740449f9 100644
--- a/apps/web/src/components/DiagramEditorPane.tsx
+++ b/apps/web/src/components/DiagramEditorPane.tsx
@@ -115,6 +115,7 @@ type NodeEditorState = {
borderColor: string;
};
+const FLOW_ACTIVE_NODE_CLASS = "edgeever-flow-node-active";
const createId = (prefix: string) => `${prefix}-${crypto.randomUUID()}`;
const oppositeFlowPort = (port?: FlowPort): FlowPort | undefined => port ? ({
top: "bottom",
@@ -129,6 +130,36 @@ const removeFlowDraftEdge = (graph: Graph, edge: Edge, restoreHistory: boolean)
if (restoreHistory) graph.enableHistory();
};
+const setFlowNodePortsActive = (graph: Graph, node: Node, active: boolean) => {
+ const apply = () => {
+ const view = graph.findViewByCell(node);
+ if (!view) return false;
+ if (active) view.addClass(FLOW_ACTIVE_NODE_CLASS);
+ else view.removeClass(FLOW_ACTIVE_NODE_CLASS);
+ view.container.querySelectorAll<SVGElement>(".x6-port-body").forEach((port) => {
+ port.style.setProperty("opacity", active ? "1" : "0", "important");
+ port.style.setProperty("pointer-events", active ? "auto" : "none", "important");
+ if (active) {
+ port.style.setProperty("fill", "var(--brand-green)", "important");
+ port.style.setProperty("stroke", "var(--workspace-editor)", "important");
+ port.style.setProperty("stroke-width", "2px", "important");
+ port.style.setProperty("filter", "drop-shadow(0 1px 3px rgb(var(--brand-green-rgb) / 0.3))");
+ } else {
+ port.style.removeProperty("fill");
+ port.style.removeProperty("stroke");
+ port.style.removeProperty("stroke-width");
+ port.style.removeProperty("filter");
+ }
+ });
+ return true;
+ };
+ if (!apply()) window.requestAnimationFrame(apply);
+};
+
+const setOnlyFlowNodePortsActive = (graph: Graph, activeNode?: Node) => {
+ graph.getNodes().forEach((node) => setFlowNodePortsActive(graph, node, node.id === activeNode?.id));
+};
+
const applyDiagramSurface = (
graph: Graph,
theme: DiagramTheme,
@@ -615,6 +646,7 @@ export const DiagramEditorPane = ({
const clearSelectionAfterHistory = () => {
applyGraphPalette(graph, themeRef.current, document.kind, appearanceRef.current);
graph.cleanSelection();
+ if (document.kind === "flowchart") setOnlyFlowNodePortsActive(graph);
setSelectedNodeId(null);
setSelectedNodeLabel("");
setHasSelection(false);
@@ -627,9 +659,16 @@ export const DiagramEditorPane = ({
graph.on("history:change", updateHistory);
graph.on("history:undo", clearSelectionAfterHistory);
graph.on("history:redo", clearSelectionAfterHistory);
+ graph.on("node:selected", ({ node }: { node: Node }) => {
+ if (document.kind === "flowchart") setFlowNodePortsActive(graph, node, true);
+ });
+ graph.on("node:unselected", ({ node }: { node: Node }) => {
+ if (document.kind === "flowchart") setFlowNodePortsActive(graph, node, false);
+ });
graph.on("node:click", ({ node }: { node: Node }) => {
const data = node.getData<NodeData>();
dismissFlowQuickCreate();
+ if (document.kind === "flowchart") setOnlyFlowNodePortsActive(graph, node);
containerRef.current?.focus({ preventScroll: true });
setSelectedNodeId(node.id);
setSelectedNodeLabel(data?.label ?? "");
@@ -638,12 +677,14 @@ export const DiagramEditorPane = ({
graph.on("node:dblclick", ({ node }: { node: Node }) => beginNodeEdit(node));
graph.on("edge:click", () => {
dismissFlowQuickCreate();
+ if (document.kind === "flowchart") setOnlyFlowNodePortsActive(graph);
setSelectedNodeId(null);
setSelectedNodeLabel("");
setHasSelection(true);
});
graph.on("blank:click", () => {
dismissFlowQuickCreate();
+ if (document.kind === "flowchart") setOnlyFlowNodePortsActive(graph);
setSelectedNodeId(null);
setSelectedNodeLabel("");
setHasSelection(false);
diff --git a/apps/web/src/lib/diagram-layout.test.mjs b/apps/web/src/lib/diagram-layout.test.mjs
index cdb1894d..ded5f1d7 100644
--- a/apps/web/src/lib/diagram-layout.test.mjs
+++ b/apps/web/src/lib/diagram-layout.test.mjs
@@ -60,8 +60,8 @@ describe("diagram auto layout", () => {
});
test("uses compact flowchart nodes with aligned process and terminator centers", () => {
- expect(compactFlowchartNodeSize("process")).toEqual({ width: 112, height: 40 });
- expect(compactFlowchartNodeSize("terminator")).toEqual({ width: 104, height: 40 });
- expect(compactFlowchartNodeSize("decision")).toEqual({ width: 104, height: 64 });
+ expect(compactFlowchartNodeSize("process")).toEqual({ width: 124, height: 44 });
+ expect(compactFlowchartNodeSize("terminator")).toEqual({ width: 116, height: 44 });
+ expect(compactFlowchartNodeSize("decision")).toEqual({ width: 116, height: 72 });
});
});
diff --git a/apps/web/src/lib/diagram-layout.ts b/apps/web/src/lib/diagram-layout.ts
index bcc426d9..609668cd 100644
--- a/apps/web/src/lib/diagram-layout.ts
+++ b/apps/web/src/lib/diagram-layout.ts
@@ -23,10 +23,10 @@ export const compactMindMapNodeSize = (label: string, isRoot: boolean) => ({
export const compactFlowchartNodeSize = (shape: DiagramDocument["nodes"][number]["shape"]) => (
shape === "decision"
- ? { width: 104, height: 64 }
+ ? { width: 116, height: 72 }
: shape === "terminator"
- ? { width: 104, height: 40 }
- : { width: 112, height: 40 }
+ ? { width: 116, height: 44 }
+ : { width: 124, height: 44 }
);
const computeMindMapLayout = (
diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css
index 1cddf831..f7b21314 100644
--- a/apps/web/src/styles/globals.css
+++ b/apps/web/src/styles/globals.css
@@ -509,7 +509,11 @@ html[data-edgeever-extension-theme] .edgeever-memo-divider {
pointer-events: none;
}
-.edgeever-diagram-canvas[data-diagram-kind="flowchart"] .x6-node.x6-node-selected .x6-port-body {
+.edgeever-diagram-canvas[data-diagram-kind="flowchart"] .x6-node.edgeever-flow-node-active .x6-port-body {
+ fill: var(--brand-green) !important;
+ stroke: var(--workspace-editor) !important;
+ stroke-width: 2px !important;
+ filter: drop-shadow(0 1px 3px rgb(var(--brand-green-rgb) / 0.3));
opacity: 1;
pointer-events: auto;
}