Skip to content

Build your personal knowledge base with Trilium Notes

Merge branch 'master' into next61

zadamc2f70031d043
diff --cc src/public/app/entities/fnote.js
index 506e466bb2,6af816a44d..8cd398c5da
--- a/src/public/app/entities/fnote.js
+++ b/src/public/app/entities/fnote.js
@@@ -357,11 -314,14 +357,11 @@@ class FNote
return [['root']];
}
- const parentNotes = this.getParentNotes();
+ const parentNotes = this.getParentNotes().filter(note => note.type !== 'search');
- let notePaths = [];
- if (parentNotes.length === 1) { // optimization for most common case
- notePaths = parentNotes[0].getAllNotePaths();
- } else {
- notePaths = parentNotes.flatMap(parentNote => parentNote.getAllNotePaths());
- }
+ const notePaths = parentNotes.length === 1
+ ? parentNotes[0].getAllNotePaths() // optimization for the most common case
+ : parentNotes.flatMap(parentNote => parentNote.getAllNotePaths());
for (const notePath of notePaths) {
notePath.push(this.noteId);
diff --cc src/public/app/services/link.js
index c35025f99e,a7c2cfaf3d..c532803e15
--- a/src/public/app/services/link.js
+++ b/src/public/app/services/link.js
@@@ -163,18 -101,18 +163,21 @@@ function goToLink(evt)
evt.preventDefault();
evt.stopPropagation();
- const notePath = getNotePathFromLink($link);
+ const { notePath, viewScope } = parseNavigationStateFromUrl(hrefLink);
const ctrlKey = utils.isCtrlKey(evt);
+ const isLeftClick = evt.which === 1;
+ const isMiddleClick = evt.which === 2;
+ const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick;
+ const leftClick = evt.which === 1;
+ const middleClick = evt.which === 2;
+
if (notePath) {
- if ((leftClick && ctrlKey) || middleClick) {
- appContext.tabManager.openTabWithNoteWithHoisting(notePath);
+ if (openInNewTab) {
+ appContext.tabManager.openTabWithNoteWithHoisting(notePath, { viewScope });
}
- else if (leftClick) {
+ else if (isLeftClick) {
const ntxId = $(evt.target).closest("[data-ntx-id]").attr("data-ntx-id");
const noteContext = ntxId
@@@ -188,19 -126,23 +191,21 @@@
});
}
}
- else {
+ else if (hrefLink) {
- // this branch handles external links
- const isWithinCKLinkDialog = $link.hasClass("ck-link-actions__preview");
- const isOutsideCKEditor = $link.closest("[contenteditable]").length === 0;
+ const withinEditLink = $link.hasClass("ck-link-actions__preview");
+ const outsideOfCKEditor = $link.closest("[contenteditable]").length === 0;
- if (openInNewTab || isWithinCKLinkDialog || isOutsideCKEditor) {
- if ((leftClick && ctrlKey) || middleClick
++ if (openInNewTab
+ || (withinEditLink && (leftClick || middleClick))
+ || (outsideOfCKEditor && (leftClick || middleClick))
+ ) {
- if (address) {
- if (address.toLowerCase().startsWith('http')) {
- window.open(address, '_blank');
- }
- else if (address.toLowerCase().startsWith('file:') && utils.isElectron()) {
- const electron = utils.dynamicRequire('electron');
+ if (hrefLink.toLowerCase().startsWith('http')) {
+ window.open(hrefLink, '_blank');
+ }
+ else if (hrefLink.toLowerCase().startsWith('file:') && utils.isElectron()) {
+ const electron = utils.dynamicRequire('electron');
- electron.shell.openPath(address);
- }
+ electron.shell.openPath(hrefLink);
}
}
}