Skip to content

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

:bug: Keep horizontal super block layout when toggling read-only mode https://github.com/siyuan-note/siyuan/issues/20439

Daniel0aa711f4c4ca
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss
index 9208e92bb6..948fcab584 100644
--- a/app/src/assets/scss/protyle/_wysiwyg.scss
+++ b/app/src/assets/scss/protyle/_wysiwyg.scss
@@ -1070,8 +1070,10 @@ body[data-format-painter] .protyle-wysiwyg[data-readonly="false"] {
.protyle-wysiwyg:not([contenteditable]),
.protyle-wysiwyg[data-readonly="true"] {
+ // 只读时仅隐藏手柄并禁用交互,保留其占位宽度,避免子块间距变化导致横向布局改变
.sb__resize {
- display: none;
+ visibility: hidden;
+ pointer-events: none;
}
.img:hover .protyle-icons {
diff --git a/app/src/protyle/render/foldedContent.test.ts b/app/src/protyle/render/foldedContent.test.ts
index af5ee9813f..680c99407f 100644
--- a/app/src/protyle/render/foldedContent.test.ts
+++ b/app/src/protyle/render/foldedContent.test.ts
@@ -173,10 +173,14 @@ const browserCases = async (sources: Record<string, string>, css: string) => {
sb.dataset.nodeId = "sb";
sb.innerHTML = '<div data-node-id="left">Left</div><div class="sb__resize"></div><div data-node-id="right">Right</div>';
root.appendChild(sb);
+ const resize = sb.querySelector(".sb__resize") as HTMLElement;
+ const editableRightLeft = sb.lastElementChild.getBoundingClientRect().left;
root.dataset.readonly = "true";
- check.equal(getComputedStyle(sb.querySelector(".sb__resize")).display, "none");
+ check.equal(getComputedStyle(resize).visibility, "hidden");
+ check.equal(getComputedStyle(resize).pointerEvents, "none");
+ check.equal(sb.lastElementChild.getBoundingClientRect().left, editableRightLeft, "read-only keeps the column layout");
root.dataset.readonly = "false";
- check.notEqual(getComputedStyle(sb.querySelector(".sb__resize")).display, "none");
+ check.equal(getComputedStyle(resize).visibility, "visible");
root.remove();
return "Folded rendering cases passed";
};