An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Refine mind map layout dot grid alignment https://github.com/siyuan-note/siyuan/issues/20694
Daniel03f91f94253b
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scssindex 98041cc62e..71882304ee 100644--- a/app/src/assets/scss/protyle/_mindmap-view.scss+++ b/app/src/assets/scss/protyle/_mindmap-view.scss@@ -270,9 +270,10 @@border: 1px solid currentColor;border-radius: var(--b3-border-radius);overflow: hidden;- background-image: radial-gradient(circle, currentColor 1px, transparent 1px);- background-image: radial-gradient(circle, color-mix(in srgb, currentColor 24%, transparent) 1px, transparent 1px);- background-size: 24px 24px;+ background-image: radial-gradient(circle, currentColor .75px, transparent .75px);+ background-image: radial-gradient(circle, color-mix(in srgb, currentColor 24%, transparent) .75px, transparent .75px);+ // 默认单行节点最小高度 32px,加上 16px 纵向间隔;网格固定于取景框,不随导图缩放。+ background-size: 48px 48px;background-position: center;box-sizing: border-box;z-index: 4;@@ -289,6 +290,7 @@bottom: 0;left: 50%;border-left: 1px dashed currentColor;+ transform: translateX(-50%);}&::after {@@ -296,6 +298,7 @@right: 0;top: 50%;border-top: 1px dashed currentColor;+ transform: translateY(-50%);}}diff --git a/app/src/protyle/render/listMindmap/fullscreen.test.ts b/app/src/protyle/render/listMindmap/fullscreen.test.tsindex 87eee30141..bd7250938a 100644--- a/app/src/protyle/render/listMindmap/fullscreen.test.ts+++ b/app/src/protyle/render/listMindmap/fullscreen.test.ts@@ -133,6 +133,34 @@ const browserCases = async (source: string, css: string, contentCSS: string, theconst layoutCenter = center();const layoutScale = view.scale;const root = host.querySelector<HTMLElement>(".mindmap-view__node");+ const checkGrid = () => {+ const style = getComputedStyle(preview);+ check.match(style.backgroundImage, /radial-gradient/);+ check.match(style.backgroundImage, /0\.75px/);+ check.equal(style.backgroundSize, "48px 48px");+ check.equal(style.backgroundPosition, "50% 50%");+ check.equal(style.backgroundOrigin, "padding-box");+ check.equal(style.overflow, "hidden", "dots and guides stay inside the rounded frame");+ const vertical = getComputedStyle(preview, "::before");+ const horizontal = getComputedStyle(preview, "::after");+ check.equal(vertical.borderLeftStyle, "dashed");+ check.equal(horizontal.borderTopStyle, "dashed");+ check.equal(vertical.borderLeftColor, style.borderTopColor);+ check.equal(horizontal.borderTopColor, style.borderTopColor);+ const rect = preview.getBoundingClientRect();+ const width = rect.width - parseFloat(style.borderLeftWidth) - parseFloat(style.borderRightWidth);+ const height = rect.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth);+ const x = parseFloat(vertical.left) + new DOMMatrixReadOnly(vertical.transform).m41 ++ parseFloat(vertical.borderLeftWidth) / 2;+ const y = parseFloat(horizontal.top) + new DOMMatrixReadOnly(horizontal.transform).m42 ++ parseFloat(horizontal.borderTopWidth) / 2;+ check.ok(Math.abs(x - width / 2) < .02, "the vertical stroke center meets the center grid dot");+ check.ok(Math.abs(y - height / 2) < .02, "the horizontal stroke center meets the center grid dot");+ for (const guide of [vertical, horizontal]) {+ check.ok(Number(guide.opacity) > 0 && Number(guide.opacity) < 1);+ check.equal(guide.pointerEvents, "none");+ }+ };const checkFrame = () => {const rect = preview.getBoundingClientRect();const viewportRect = viewport.getBoundingClientRect();@@ -149,22 +177,7 @@ const browserCases = async (source: string, css: string, contentCSS: string, thecheck.equal(style.borderTopColor, canvasStyle.outlineColor, "the frame follows the active canvas color");check.equal(style.borderTopWidth, canvasStyle.outlineWidth);check.equal(style.borderTopLeftRadius, documentRadius, "the frame keeps the document canvas radius");- check.match(style.backgroundImage, /radial-gradient/);- check.equal(style.backgroundSize, "24px 24px");- check.equal(style.backgroundPosition, "50% 50%");- check.equal(style.overflow, "hidden", "dots and guides stay inside the rounded frame");- const vertical = getComputedStyle(preview, "::before");- const horizontal = getComputedStyle(preview, "::after");- check.equal(vertical.borderLeftStyle, "dashed");- check.equal(horizontal.borderTopStyle, "dashed");- check.equal(vertical.borderLeftColor, style.borderTopColor);- check.equal(horizontal.borderTopColor, style.borderTopColor);- check.ok(Math.abs(parseFloat(vertical.left) - preview.clientWidth / 2) < .1);- check.ok(Math.abs(parseFloat(horizontal.top) - preview.clientHeight / 2) < .1);- for (const guide of [vertical, horizontal]) {- check.ok(Number(guide.opacity) > 0 && Number(guide.opacity) < 1);- check.equal(guide.pointerEvents, "none");- }+ checkGrid();check.equal(button("listMindmapDocumentLayout").getAttribute("aria-pressed"), "true");};const captureLayout = () => {@@ -193,6 +206,15 @@ const browserCases = async (source: string, css: string, contentCSS: string, thebutton("listMindmapDocumentLayout").click();check.equal(preview.hidden, false);checkFrame();+ // 奇数和小数尺寸下,验证笔画中心与网格原点,而非只验证线条边缘的百分比位置。+ const frameStyle = preview.style.cssText;+ for (const [width, height] of [[320, 200], [321, 201], [320.5, 200.5], [321.25, 201.75]]) {+ preview.style.width = `${width}px`;+ preview.style.height = `${height}px`;+ checkGrid();+ }+ preview.style.cssText = frameStyle;+ checkFrame();const savedLayout = JSON.stringify(view.documentView);const fixedFrame = preview.getBoundingClientRect().toJSON();view.zoomAt(1.9);