Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15546

Vanessa97f74ea1726c
diff --git a/app/src/boot/globalEvent/keyup.ts b/app/src/boot/globalEvent/keyup.ts
index de7cda8b0c..9919a9b3d9 100644
--- a/app/src/boot/globalEvent/keyup.ts
+++ b/app/src/boot/globalEvent/keyup.ts
@@ -6,6 +6,7 @@ import {getAllTabs} from "../../layout/getAll";
import {App} from "../../index";
import {Constants} from "../../constants";
import {matchHotKey} from "../../protyle/util/hotKey";
+import {isWindow} from "../../util/functions";
export const windowKeyUp = (app: App, event: KeyboardEvent) => {
window.siyuan.ctrlIsPressed = false;
@@ -22,37 +23,52 @@ export const windowKeyUp = (app: App, event: KeyboardEvent) => {
let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
currentLiElement.classList.remove("b3-list-item--focus");
if (matchHotKey(window.siyuan.config.keymap.general.goToEditTabPrev.custom, event)) {
- if (currentLiElement.previousElementSibling) {
- currentLiElement.previousElementSibling.classList.add("b3-list-item--focus");
- } else if (currentLiElement.getAttribute("data-original")) {
- currentLiElement.parentElement.lastElementChild.classList.add("b3-list-item--focus");
- currentLiElement.removeAttribute("data-original");
- } else if (currentLiElement.parentElement.nextElementSibling) {
- if (currentLiElement.parentElement.nextElementSibling.lastElementChild) {
- currentLiElement.parentElement.nextElementSibling.lastElementChild.classList.add("b3-list-item--focus");
- } else {
- currentLiElement.parentElement.lastElementChild.classList.add("b3-list-item--focus");
+ while (true) {
+ if (currentLiElement.previousElementSibling) {
+ currentLiElement = currentLiElement.previousElementSibling;
+ } else if (currentLiElement.getAttribute("data-original")) {
+ currentLiElement.removeAttribute("data-original");
+ currentLiElement = currentLiElement.parentElement.lastElementChild;
+ } else if (currentLiElement.parentElement.nextElementSibling) {
+ if (currentLiElement.parentElement.nextElementSibling.lastElementChild) {
+ currentLiElement = currentLiElement.parentElement.nextElementSibling.lastElementChild;
+ } else {
+ currentLiElement = currentLiElement.parentElement.lastElementChild;
+ }
+ } else if (currentLiElement.parentElement.previousElementSibling) {
+ currentLiElement = currentLiElement.parentElement.previousElementSibling.lastElementChild;
+ } else if (isWindow()) {
+ currentLiElement = currentLiElement.parentElement.lastElementChild;
+ }
+ if (currentLiElement.getBoundingClientRect().height !== 0) {
+ break;
}
- } else if (currentLiElement.parentElement.previousElementSibling) {
- currentLiElement.parentElement.previousElementSibling.lastElementChild.classList.add("b3-list-item--focus");
}
+ currentLiElement.classList.add("b3-list-item--focus");
} else {
- if (currentLiElement.nextElementSibling) {
- currentLiElement.nextElementSibling.classList.add("b3-list-item--focus");
- } else if (currentLiElement.getAttribute("data-original")) {
- currentLiElement.parentElement.firstElementChild.classList.add("b3-list-item--focus");
- currentLiElement.removeAttribute("data-original");
- } else if (currentLiElement.parentElement.nextElementSibling) {
- if (currentLiElement.parentElement.nextElementSibling.firstElementChild) {
- currentLiElement.parentElement.nextElementSibling.firstElementChild.classList.add("b3-list-item--focus");
- } else {
- currentLiElement.parentElement.firstElementChild.classList.add("b3-list-item--focus");
+ while (true) {
+ if (currentLiElement.nextElementSibling) {
+ currentLiElement = currentLiElement.nextElementSibling;
+ } else if (currentLiElement.getAttribute("data-original")) {
+ currentLiElement.removeAttribute("data-original");
+ currentLiElement = currentLiElement.parentElement.firstElementChild;
+ } else if (currentLiElement.parentElement.nextElementSibling) {
+ if (currentLiElement.parentElement.nextElementSibling.firstElementChild) {
+ currentLiElement = currentLiElement.parentElement.nextElementSibling.firstElementChild;
+ } else {
+ currentLiElement = currentLiElement.parentElement.firstElementChild;
+ }
+ } else if (currentLiElement.parentElement.previousElementSibling) {
+ currentLiElement = currentLiElement.parentElement.previousElementSibling.firstElementChild;
+ } else if (isWindow()) {
+ currentLiElement = currentLiElement.parentElement.firstElementChild;
+ }
+ if (currentLiElement.getBoundingClientRect().height !== 0) {
+ break;
}
- } else if (currentLiElement.parentElement.previousElementSibling) {
- currentLiElement.parentElement.previousElementSibling.firstElementChild.classList.add("b3-list-item--focus");
}
+ currentLiElement.classList.add("b3-list-item--focus");
}
- currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
if (currentLiElement) {
const rootId = currentLiElement.getAttribute("data-node-id");
if (rootId) {
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 692af32f8c..4d9c50ca41 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -667,7 +667,9 @@ export const resizeTopBar = () => {
return;
}
const dragElement = toolbarElement.querySelector("#drag") as HTMLElement;
-
+ if (!dragElement) {
+ return;
+ }
dragElement.style.padding = "";
const barMoreElement = toolbarElement.querySelector("#barMore");
barMoreElement.classList.remove("fn__none");
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index efc4cf97e1..b2a6ba0aa7 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -196,11 +196,11 @@ export class Plugin {
iconElement.setAttribute("data-location", options.position || "right");
resizeTopBar();
}
- if (isMobile()) {
+ if (isMobile() && window.siyuan.storage) {
if (!window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
document.querySelector("#menuAbout")?.after(iconElement);
}
- } else if (!isWindow()) {
+ } else if (!isWindow() && window.siyuan.storage) {
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
iconElement.classList.add("fn__none");
}