Skip to content

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

:bug: Restore document navigation controls https://github.com/siyuan-note/siyuan/issues/18721

Daniela23c26bbe667
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 55471add33..25faed0139 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -45,6 +45,13 @@
}
}
+ @media (hover: none) {
+ &__down,
+ &__up {
+ opacity: 1;
+ }
+ }
+
&__bar {
position: absolute;
right: calc(4px - var(--b3-dynamicscroll-width) / 2);
diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts
index 7b5e24f194..6895012518 100644
--- a/app/src/protyle/scroll/index.ts
+++ b/app/src/protyle/scroll/index.ts
@@ -263,8 +263,9 @@ export class Scroll {
this.inputElement.setAttribute("max", protyle.block.blockCount.toString());
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${protyle.block.blockCount}`);
}
- const visible = protyle.options.render.scroll && !protyle.block.showAll && protyle.block.scroll &&
+ const containerVisible = protyle.options.render.scroll &&
!protyle.contentElement.classList.contains("fn__none");
- updateScrollVisibility(this.parentElement, this.element, visible);
+ const barVisible = containerVisible && !protyle.block.showAll && protyle.block.scroll;
+ updateScrollVisibility(this.parentElement, this.element, containerVisible, barVisible);
}
}
diff --git a/app/src/protyle/scroll/visibility.test.ts b/app/src/protyle/scroll/visibility.test.ts
index 8f7304c90d..6c8ee4cb15 100644
--- a/app/src/protyle/scroll/visibility.test.ts
+++ b/app/src/protyle/scroll/visibility.test.ts
@@ -21,22 +21,32 @@ const createElement = () => {
};
describe("updateScrollVisibility", () => {
- it("keeps the container and bar hidden together", () => {
+ it("hides the container and bar", () => {
const parent = createElement();
const bar = createElement();
- updateScrollVisibility(parent.element, bar.element, false);
+ updateScrollVisibility(parent.element, bar.element, false, false);
assert.equal(parent.hasClass("fn__none"), true);
assert.equal(bar.hasClass("fn__none"), true);
});
- it("shows the container and bar together", () => {
+ it("shows the container while keeping the bar hidden", () => {
const parent = createElement();
const bar = createElement();
- updateScrollVisibility(parent.element, bar.element, false);
- updateScrollVisibility(parent.element, bar.element, true);
+ updateScrollVisibility(parent.element, bar.element, true, false);
+
+ assert.equal(parent.hasClass("fn__none"), false);
+ assert.equal(bar.hasClass("fn__none"), true);
+ });
+
+ it("shows the container and bar", () => {
+ const parent = createElement();
+ const bar = createElement();
+ updateScrollVisibility(parent.element, bar.element, false, false);
+
+ updateScrollVisibility(parent.element, bar.element, true, true);
assert.equal(parent.hasClass("fn__none"), false);
assert.equal(bar.hasClass("fn__none"), false);
diff --git a/app/src/protyle/scroll/visibility.ts b/app/src/protyle/scroll/visibility.ts
index df011d89a3..17382f5321 100644
--- a/app/src/protyle/scroll/visibility.ts
+++ b/app/src/protyle/scroll/visibility.ts
@@ -1,4 +1,9 @@
-export const updateScrollVisibility = (parentElement: HTMLElement, barElement: HTMLElement, visible: boolean) => {
- parentElement.classList.toggle("fn__none", !visible);
- barElement.classList.toggle("fn__none", !visible);
+export const updateScrollVisibility = (
+ parentElement: HTMLElement,
+ barElement: HTMLElement,
+ containerVisible: boolean,
+ barVisible: boolean,
+) => {
+ parentElement.classList.toggle("fn__none", !containerVisible);
+ barElement.classList.toggle("fn__none", !barVisible);
};