Skip to content

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

:bug: Keep mind map frames within the document width https://github.com/siyuan-note/siyuan/issues/20671

Danieldb18fdde236d
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scss
index 13e660078c..6c9984b7ff 100644
--- a/app/src/assets/scss/protyle/_mindmap-view.scss
+++ b/app/src/assets/scss/protyle/_mindmap-view.scss
@@ -14,6 +14,8 @@
[data-type="NodeList"][data-mindmap-view-rendered="true"]:not([fold="1"]),
[data-type="NodeMindmap"][data-mindmap-view-rendered="true"]:not([fold="1"]) {
height: auto !important;
+ max-width: 100%;
+ box-sizing: border-box;
}
[data-type="NodeList"][data-mindmap-view-rendered="true"] > [data-type="NodeListItem"],
diff --git a/app/src/protyle/render/iframeResize.test.ts b/app/src/protyle/render/iframeResize.test.ts
index e900cb0ee2..f45b49bb11 100644
--- a/app/src/protyle/render/iframeResize.test.ts
+++ b/app/src/protyle/render/iframeResize.test.ts
@@ -536,6 +536,28 @@ const browserCases = async (renderSource: string, resizeSource: string, luteSour
host.classList.add("fullscreen");
check.equal(getComputedStyle(host.querySelector(".mindmap-view__resize")).display, "none");
host.classList.remove("fullscreen");
+ for (const type of ["NodeMindmap", "NodeList"]) {
+ mindmap.dataset.type = type;
+ mindmap.className = type === "NodeList" ? "list" : "mindmap";
+ mindmap.setAttribute("custom-sy-list-mindmap", "1");
+ for (const width of ["", "1000px"]) {
+ mindmap.style.width = width;
+ const sourceStyle = mindmap.getAttribute("style");
+ for (const padding of ["24px", "20%", "24px"]) {
+ root.style.paddingLeft = padding;
+ root.style.paddingRight = padding;
+ const available = root.clientWidth - parseFloat(getComputedStyle(root).paddingLeft) -
+ parseFloat(getComputedStyle(root).paddingRight);
+ check.ok(mindmap.getBoundingClientRect().width <= available + 1,
+ `${type} fits the document after changing adaptive width (${width}, ${padding})`);
+ check.ok(host.getBoundingClientRect().width <= mindmap.getBoundingClientRect().width);
+ check.equal(mindmap.getAttribute("style"), sourceStyle, "layout preserves the saved source dimensions");
+ }
+ }
+ }
+ mindmap.style.width = "";
+ root.style.paddingLeft = "";
+ root.style.paddingRight = "";
block.querySelectorAll(".protyle-block-resize").forEach(handle => handle.classList.add("touch-resize-active"));
return "IFrame, widget and mind map resize cases passed";
};