An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Keep complete block indicators in one row or column https://github.com/siyuan-note/siyuan/issues/20894
Danielc6fec8383526
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scssindex c52d6c9ac4..c63cde9fbe 100644--- a/app/src/assets/scss/protyle/_protyle.scss+++ b/app/src/assets/scss/protyle/_protyle.scss@@ -149,7 +149,6 @@&--full {display: flex;- flex-wrap: wrap;width: max-content;scrollbar-width: none;overscroll-behavior: contain;@@ -220,6 +219,7 @@height: calc(var(--b3-font-size-editor) * 1.625);width: 16px;float: left;+ pointer-events: none;transition: var(--b3-color-transition);}}diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 8bf633e2fd..3e48701159 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -3940,6 +3940,7 @@ data-type="fold"${viewOccurrenceID ? ` data-view-occurrence-id="${encodeURICompoconst wasCompressed = this.element.style.width === "24px";const previousScrollTop = this.element.scrollTop;this.element.classList.toggle("protyle-gutters--full", fullGutter);+ this.element.style.flexDirection = "";this.element.style.maxHeight = "";this.element.style.overflowY = "";delete this.element.dataset.scrollable;@@ -4045,11 +4046,13 @@ data-type="fold"${viewOccurrenceID ? ` data-view-occurrence-id="${encodeURICompoconst viewportRight = Math.min(viewportRect.right, paneRect.right);const viewportBottom = Math.min(viewportRect.bottom, paneRect.bottom);if (fullGutter) {- // 完整层级按左侧可用宽度换行,超出视口的层级可滚动访问。+ // 完整层级在空间不足时整列排列,超出视口的层级可滚动访问。const buttons = Array.from(this.element.querySelectorAll<HTMLElement>("button[data-node-id], button[data-type='fold']"));const buttonWidth = Math.max(24, ...buttons.map(button => button.getBoundingClientRect().width));const availableWidth = Math.max(buttonWidth, horizontalAnchorLeft - space - gutterGap - viewportLeft);- this.element.style.width = `${Math.min(this.naturalWidth, availableWidth, viewportRight - viewportLeft)}px`;+ const vertical = this.naturalWidth > availableWidth;+ this.element.style.flexDirection = vertical ? "column" : "";+ this.element.style.width = `${Math.min(vertical ? buttonWidth : this.naturalWidth, viewportRight - viewportLeft)}px`;this.element.style.maxHeight = `${Math.max(0, viewportBottom - Math.max(contentTop, paneRect.top))}px`;if (this.element.scrollHeight > this.element.clientHeight) {this.element.style.overflowY = "auto";@@ -4060,8 +4063,9 @@ data-type="fold"${viewOccurrenceID ? ` data-view-occurrence-id="${encodeURICompo}}if (!element.classList.contains("av__row")) {+ const firstButtonHeight = fullGutter ? (this.element.firstElementChild as HTMLElement)?.offsetHeight : 0;const gutterMarginHeight = getGutterMarginHeight(- rect.height, this.element.clientHeight, fullGutter ? this.element.clientHeight : this.naturalHeight,+ rect.height, firstButtonHeight || this.element.clientHeight, fullGutter ? firstButtonHeight : this.naturalHeight,window.siyuan.config.editor.fontSize);if (typeof gutterMarginHeight === "number") {marginHeight = gutterMarginHeight;diff --git a/app/tests/listContainerGutter.test.js b/app/tests/listContainerGutter.test.jsindex 880e8f40e8..ce96873922 100644--- a/app/tests/listContainerGutter.test.js+++ b/app/tests/listContainerGutter.test.js@@ -413,6 +413,35 @@ ${legacyMindmap ? 'custom-sy-list-mindmap="1"' : ""}>${content}${attr}</div>${p(gutter.render(protyle, root.querySelector('[data-node-id="leaf"]'));check.equal(gutter.element.querySelectorAll('[draggable="true"]').length, 0, "read-only icons remain non-draggable");protyle.disabled = false;+ gutter.render(protyle, root.querySelector('[data-node-id="leaf"]'));++ const checkFullLayout = vertical => {+ const buttons = Array.from(gutter.element.querySelectorAll("button[data-node-id], button[data-type='fold']"));+ const rects = buttons.map(button => button.getBoundingClientRect());+ check.equal(new Set(rects.map(rect => vertical ? rect.left : rect.top)).size, 1,+ "complete indicators occupy one whole row or one whole column");+ for (const [index, button] of buttons.entries()) {+ const rect = rects[index];+ for (const x of [rect.left + 1, rect.right - 1]) {+ const y = rect.top + rect.height / 2;+ const target = document.elementFromPoint(x, y);+ check.equal(target?.closest("button"), button,+ `stable pointer target: ${button.dataset.nodeId || button.dataset.type} at ${x},${y}`);+ const before = state();+ check.deepEqual(hover(target, x, y), before, "moving across indicators preserves the whole chain");+ }+ }+ };+ checkFullLayout(false);+ root.style.paddingLeft = "24px";+ gutter.render(protyle, root.querySelector('[data-node-id="leaf"]'));+ checkFullLayout(true);+ const firstRect = gutter.element.querySelector("button[data-node-id]").getBoundingClientRect();+ check.ok(Math.abs(firstRect.top - root.querySelector('[data-node-id="leaf"]').getBoundingClientRect().top) <= 8,+ "a vertical chain starts at the content's first line");+ root.style.paddingLeft = "180px";+ gutter.render(protyle, root.querySelector('[data-node-id="leaf"]'));+ checkFullLayout(false);pane.style.cssText = "width:320px;height:200px";root.style.cssText = "padding:20px 24px;width:250px";