Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/5394

Vanessabff305aa6aac
diff --git a/app/src/assets/scss/_dialog.scss b/app/src/assets/scss/_dialog.scss
index a02e17e6c0..50b33e98e1 100644
--- a/app/src/assets/scss/_dialog.scss
+++ b/app/src/assets/scss/_dialog.scss
@@ -84,6 +84,7 @@
&--switch {
max-height: 70vh;
+ max-width: 520px;
.b3-list:last-child {
border-left: 1px solid var(--b3-border-color);
@@ -91,5 +92,16 @@
max-width: 360px;
min-width: 200px;
}
+
+ .dialog__path {
+ padding: 4px 8px;
+ border-top: 1px solid var(--b3-border-color);
+ color: var(--b3-theme-on-surface);
+ font-size: 12px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ line-height: 18px;
+ }
}
}
diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts
index cc79d929d7..b33c32e770 100644
--- a/app/src/util/globalShortcut.ts
+++ b/app/src/util/globalShortcut.ts
@@ -195,7 +195,7 @@ export const globalShortcut = () => {
window.siyuan.altIsPressed = false;
if (switchDialog && switchDialog.element.parentElement) {
if (event.key === "Tab") {
- const currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
+ let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
currentLiElement.classList.remove("b3-list-item--focus");
if (event.shiftKey) {
if (currentLiElement.previousElementSibling) {
@@ -204,7 +204,11 @@ export const globalShortcut = () => {
currentLiElement.parentElement.lastElementChild.classList.add("b3-list-item--focus");
currentLiElement.removeAttribute("data-original");
} else if (currentLiElement.parentElement.nextElementSibling) {
- currentLiElement.parentElement.nextElementSibling.lastElementChild.classList.add("b3-list-item--focus");
+ 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");
+ }
} else if (currentLiElement.parentElement.previousElementSibling) {
currentLiElement.parentElement.previousElementSibling.lastElementChild.classList.add("b3-list-item--focus");
}
@@ -215,11 +219,28 @@ export const globalShortcut = () => {
currentLiElement.parentElement.firstElementChild.classList.add("b3-list-item--focus");
currentLiElement.removeAttribute("data-original");
} else if (currentLiElement.parentElement.nextElementSibling) {
- currentLiElement.parentElement.nextElementSibling.firstElementChild.classList.add("b3-list-item--focus");
+ 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");
+ }
} else if (currentLiElement.parentElement.previousElementSibling) {
currentLiElement.parentElement.previousElementSibling.firstElementChild.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) {
+ fetchPost("/api/filetree/getFullHPathByID", {
+ id: rootId
+ }, (response) => {
+ currentLiElement.parentElement.parentElement.nextElementSibling.innerHTML = escapeHtml(response.data);
+ });
+ } else {
+ currentLiElement.parentElement.parentElement.nextElementSibling.innerHTML = currentLiElement.querySelector(".b3-list-item__text").innerHTML;
+ }
+ }
} else if (event.key === "Control") {
let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
// 快速切换时,不触发 Tab
@@ -304,15 +325,7 @@ export const globalShortcut = () => {
if (switchDialog && switchDialog.element.parentElement) {
return;
}
- let dockHtml = "";
let tabHtml = "";
- getAllDocks().forEach(item => {
- dockHtml += `<li data-type="${item.type}" class="b3-list-item">
- <svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>
- <span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span>
- <span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>
-</li>`;
- });
let currentTabElement = document.querySelector(".layout__wnd--active .layout-tab-bar > .item--focus");
if (!currentTabElement) {
currentTabElement = document.querySelector(".layout-tab-bar > .item--focus");
@@ -323,12 +336,22 @@ export const globalShortcut = () => {
return itemA.headElement.getAttribute("data-activetime") > itemB.headElement.getAttribute("data-activetime") ? -1 : 1;
}).forEach(item => {
let icon = `<svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>`;
+ let rootId = "";
if (item.model instanceof Editor) {
+ rootId = ` data-node-id="${item.model.editor.protyle.block.rootID}"`
icon = `<span class="b3-list-item__graphic">${unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE)}</span>`;
}
- tabHtml += `<li data-id="${item.id}" class="b3-list-item${currentId === item.id ? " b3-list-item--focus" : ""}"${currentId === item.id ? ' data-original="true"' : ""}>${icon}<span class="b3-list-item__text">${escapeHtml(item.title)}</span></li>`;
+ tabHtml += `<li data-id="${item.id}"${rootId} class="b3-list-item${currentId === item.id ? " b3-list-item--focus" : ""}"${currentId === item.id ? ' data-original="true"' : ""}>${icon}<span class="b3-list-item__text">${escapeHtml(item.title)}</span></li>`;
});
}
+ let dockHtml = "";
+ getAllDocks().forEach(item => {
+ dockHtml += `<li data-type="${item.type}" class="b3-list-item${(!tabHtml && !dockHtml) ? " b3-list-item--focus" : ""}">
+ <svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>
+ <span class="b3-list-item__text">${window.siyuan.languages[item.hotkeyLangId]}</span>
+ <span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>
+</li>`;
+ });
switchDialog = new Dialog({
content: `<div class="fn__flex-column b3-dialog--switch">
<div class="fn__hr"></div>
@@ -336,7 +359,7 @@ export const globalShortcut = () => {
<ul class="b3-list b3-list--background">${dockHtml}</ul>
<ul class="b3-list b3-list--background">${tabHtml}</ul>
</div>
- <div class="fn__hr"></div>
+ <div class="dialog__path"></div>
</div>`,
disableClose: true,
disableAnimation: true,