From b86407b7f55d698d2d9f15e97fea6ec0586ee864 Mon Sep 17 00:00:00 2001
From: SiriusXT <1160925501@qq.com>
Date: Thu, 17 Apr 2025 16:30:46 +0800
Subject: [PATCH 1/3] Make each part of the note path clickable.
---
.../app/widgets/ribbon_widgets/note_paths.ts | 46 ++++++++++++-------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/public/app/widgets/ribbon_widgets/note_paths.ts b/src/public/app/widgets/ribbon_widgets/note_paths.ts
index 961878589..131fed2a4 100644
--- a/src/public/app/widgets/ribbon_widgets/note_paths.ts
+++ b/src/public/app/widgets/ribbon_widgets/note_paths.ts
@@ -19,15 +19,15 @@ const TPL = /*html*/`
margin-top: 10px;
}
- .note-path-list .path-current {
+ .note-path-list .path-current a {
font-weight: bold;
}
- .note-path-list .path-archived {
+ .note-path-list .path-archived a {
color: var(--muted-text-color) !important;
}
- .note-path-list .path-search {
+ .note-path-list .path-search a {
font-style: italic;
}
@@ -72,7 +72,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
this.$notePathList.empty();
if (!this.note || this.noteId === "root") {
- this.$notePathList.empty().append(await this.getRenderedPath("root"));
+ this.$notePathList.empty().append(await this.getRenderedPath(["root"]));
return;
}
@@ -88,7 +88,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
const renderedPaths = [];
for (const notePathRecord of sortedNotePaths) {
- const notePath = notePathRecord.notePath.join("/");
+ const notePath = notePathRecord.notePath;
renderedPaths.push(await this.getRenderedPath(notePath, notePathRecord));
}
@@ -96,42 +96,54 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
this.$notePathList.empty().append(...renderedPaths);
}
- async getRenderedPath(notePath: string, notePathRecord: NotePathRecord | null = null) {
- const title = await treeService.getNotePathTitle(notePath);
+ async getRenderedPath(notePath: string[], notePathRecord: NotePathRecord | null = null) {
+ const $pathItem = $("
");
+ const pathSegments: string[] = [];
+ const lastIndex = notePath.length - 1;
+
+ for (let i = 0; i < notePath.length; i++) {
+ const noteId = notePath[i];
+ pathSegments.push(noteId);
+ const title = await treeService.getNoteTitle(noteId);
+ const $noteLink = await linkService.createLink(pathSegments.join("/"), { title });
- const $noteLink = await linkService.createLink(notePath, { title });
-
- $noteLink.find("a").addClass("no-tooltip-preview tn-link");
+ $noteLink.find("a").addClass("no-tooltip-preview tn-link");
+ $pathItem.append($noteLink);
+
+ if (i != lastIndex) {
+ $pathItem.append(" / ");
+ }
+ }
const icons = [];
- if (this.notePath === notePath) {
- $noteLink.addClass("path-current");
+ if (this.notePath === notePath.join("/")) {
+ $pathItem.addClass("path-current");
}
if (!notePathRecord || notePathRecord.isInHoistedSubTree) {
- $noteLink.addClass("path-in-hoisted-subtree");
+ $pathItem.addClass("path-in-hoisted-subtree");
} else {
icons.push(``);
}
if (notePathRecord?.isArchived) {
- $noteLink.addClass("path-archived");
+ $pathItem.addClass("path-archived");
icons.push(``);
}
if (notePathRecord?.isSearch) {
- $noteLink.addClass("path-search");
+ $pathItem.addClass("path-search");
icons.push(``);
}
if (icons.length > 0) {
- $noteLink.append(` ${icons.join(" ")}`);
+ $pathItem.append(` ${icons.join(" ")}`);
}
- return $("").append($noteLink);
+ return $pathItem;
}
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
From 49bc6e8c91b2d6138709a7ee5049b5ad83b2e3ff Mon Sep 17 00:00:00 2001
From: SiriusXT <1160925501@qq.com>
Date: Thu, 17 Apr 2025 17:12:48 +0800
Subject: [PATCH 2/3] Add Shift + Click to open the note in a new tab and
activate it.
---
src/public/app/services/link.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts
index 138df7221..f9d5912d4 100644
--- a/src/public/app/services/link.ts
+++ b/src/public/app/services/link.ts
@@ -286,7 +286,7 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent
if (notePath) {
if (openInNewTab) {
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
- activate: targetIsBlank,
+ activate: evt.shiftKey ? true : targetIsBlank,
viewScope
});
} else if (isLeftClick) {
From b7e7196f480703ac8925cff99b335196b94aec5e Mon Sep 17 00:00:00 2001
From: SiriusXT <1160925501@qq.com>
Date: Thu, 17 Apr 2025 18:37:58 +0800
Subject: [PATCH 3/3] Shortcut to open link
---
src/public/app/services/link.ts | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts
index f9d5912d4..a0d464741 100644
--- a/src/public/app/services/link.ts
+++ b/src/public/app/services/link.ts
@@ -278,15 +278,20 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent
const { notePath, viewScope } = parseNavigationStateFromUrl(hrefLink);
const ctrlKey = utils.isCtrlKey(evt);
+ const shiftKey = evt.shiftKey;
const isLeftClick = "which" in evt && evt.which === 1;
const isMiddleClick = "which" in evt && evt.which === 2;
const targetIsBlank = ($link?.attr("target") === "_blank");
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
+ const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
+ const openInNewWindow = isLeftClick && evt.shiftKey && !ctrlKey;
if (notePath) {
- if (openInNewTab) {
+ if (openInNewWindow) {
+ appContext.triggerCommand("openInWindow", { notePath, viewScope });
+ } else if (openInNewTab) {
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
- activate: evt.shiftKey ? true : targetIsBlank,
+ activate: activate ? true : targetIsBlank,
viewScope
});
} else if (isLeftClick) {