Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Restore mind map connections between adjacent nodes https://github.com/siyuan-note/siyuan/issues/18831

Vanessa60e8a5030b0b
diff --git a/app/src/protyle/render/listMindmap/routing.test.ts b/app/src/protyle/render/listMindmap/routing.test.ts
index 445569740a..4a48f94f7c 100644
--- a/app/src/protyle/render/listMindmap/routing.test.ts
+++ b/app/src/protyle/render/listMindmap/routing.test.ts
@@ -19,6 +19,15 @@ const validate = (route: MindmapRoutePoint[], nodes: MindmapRouteBox[]) => {
}
};
+test("vertically adjacent nodes connect when their clearance ports coincide", () => {
+ const nodes = [
+ {x: 200, y: 0, width: 64, height: 38},
+ {x: 200, y: 62, width: 64, height: 38},
+ ];
+ validate(routeMindmapRelation(nodes[0], nodes[1], nodes), nodes);
+ validate(routeMindmapRelation(nodes[1], nodes[0], nodes), nodes);
+});
+
test("connection preview routes to the exact pointer position around obstacles", () => {
const from = {x: 0, y: 0, width: 100, height: 40};
const obstacle = {x: 160, y: 0, width: 100, height: 80};
diff --git a/app/src/protyle/render/listMindmap/routing.ts b/app/src/protyle/render/listMindmap/routing.ts
index afe050f60d..c075be6305 100644
--- a/app/src/protyle/render/listMindmap/routing.ts
+++ b/app/src/protyle/render/listMindmap/routing.ts
@@ -90,7 +90,8 @@ export const routeMindmapRelation = (from: MindmapRouteBox, to: MindmapRouteBox,
}
const index = Math.floor(current.key / 2);
const a = point(index);
- if (targets.has(current.key)) {
+ // 相邻节点的避让端口可能重合,不能将尚未走过任何线段的起点作为完整路径。
+ if (targets.has(current.key) && previous.has(current.key)) {
const route: MindmapRoutePoint[] = [];
let key: number | undefined = current.key;
while (key !== undefined) {