Skip to content

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

:bug: Keep only one block gutter visible in the editor https://github.com/siyuan-note/siyuan/issues/18319

Danielbd14068e29e7
diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts
index 7816ad9691..4fdccda4f5 100644
--- a/app/src/layout/dock/Backlink.ts
+++ b/app/src/layout/dock/Backlink.ts
@@ -13,6 +13,7 @@ import {App} from "../../index";
import {isSupportCSSHL, searchMarkRender} from "../../protyle/render/searchMarkRender";
import {getDocDisplayName, isEncryptedBox} from "../../util/pathName";
import {getAllModels} from "../getAll";
+import {hideElements} from "../../protyle/ui/hideElements";
export class Backlink extends Model {
public element: HTMLElement;
@@ -256,6 +257,7 @@ export class Backlink extends Model {
});
// 为了快捷键的 dispatch
this.element.querySelector('[data-type="collapse"]').addEventListener("click", () => {
+ this.hideEditorGutters(this.tree.element);
this.tree.element.querySelectorAll(".protyle").forEach(item => {
item.classList.add("fn__none");
});
@@ -295,6 +297,7 @@ export class Backlink extends Model {
event.stopPropagation();
break;
case "mCollapse":
+ this.hideEditorGutters(this.mTree.element);
this.mTree.element.querySelectorAll(".protyle").forEach(item => {
item.classList.add("fn__none");
});
@@ -414,6 +417,9 @@ export class Backlink extends Model {
private setBottomLayout(element: HTMLElement, listElement: HTMLElement) {
const folded = !listElement.classList.contains("fn__none");
+ if (folded) {
+ this.hideEditorGutters(listElement);
+ }
listElement.classList.toggle("fn__none", folded);
if (folded) {
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
@@ -529,6 +535,7 @@ export class Backlink extends Model {
if (svgElement.classList.contains("b3-list-item__arrow--open")) {
svgElement.classList.remove("b3-list-item__arrow--open");
if (editor && this.type === "bottom") {
+ hideElements(["gutter"], editor.protyle);
editor.protyle.element.classList.add("fn__none");
} else if (editor) {
editor.destroy();
@@ -585,6 +592,14 @@ export class Backlink extends Model {
}
}
+ private hideEditorGutters(element: Element) {
+ this.editors.forEach(editor => {
+ if (editor.protyle.element === element || element.contains(editor.protyle.element)) {
+ hideElements(["gutter"], editor.protyle);
+ }
+ });
+ }
+
private updateBottomBacklinkSpacing() {
if (this.type !== "bottom") {
return;
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 04780cbd4e..3d8eaaccba 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -2874,6 +2874,17 @@ export class Gutter {
if (selectElement && !selectElement.classList.contains("fn__none")) {
return;
}
+ document.querySelectorAll(".protyle-gutters").forEach(item => {
+ if (item !== this.element) {
+ item.classList.add("fn__none");
+ item.innerHTML = "";
+ }
+ });
+ document.querySelectorAll(".protyle-wysiwyg--hl, .av__row--hl").forEach(item => {
+ if (item.closest(".protyle") !== protyle.element) {
+ item.classList.remove("protyle-wysiwyg--hl", "av__row--hl");
+ }
+ });
let html = "";
let nodeElement = element;
let space = 0;