mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 02:42:27 +08:00
unified opening of external links in new tab (doubleclick in editor, singleclick in preview tooltip)
This commit is contained in:
parent
b171ce27bb
commit
3c3117e22f
@ -38,15 +38,28 @@ const link = (function() {
|
|||||||
return noteLink;
|
return noteLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToInternalNote(e) {
|
function goToLink(e) {
|
||||||
const linkEl = $(e.target);
|
e.preventDefault();
|
||||||
let noteId = linkEl.attr("note-path");
|
|
||||||
|
|
||||||
if (!noteId) {
|
const linkEl = $(e.target);
|
||||||
noteId = getNotePathFromLink(linkEl.attr('href'));
|
const notePath = linkEl.attr("note-path") ? linkEl.attr("note-path") : linkEl.attr('href');
|
||||||
|
|
||||||
|
if (!notePath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notePath.startsWith('http')) {
|
||||||
|
window.open(notePath, '_blank');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const noteId = getNotePathFromLink(notePath);
|
||||||
|
|
||||||
|
if (!noteId) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteId) {
|
|
||||||
noteTree.activateNode(noteId);
|
noteTree.activateNode(noteId);
|
||||||
|
|
||||||
// this is quite ugly hack, but it seems like we can't close the tooltip otherwise
|
// this is quite ugly hack, but it seems like we can't close the tooltip otherwise
|
||||||
@ -58,9 +71,6 @@ const link = (function() {
|
|||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLinkToEditor(linkTitle, linkHref) {
|
function addLinkToEditor(linkTitle, linkHref) {
|
||||||
@ -79,9 +89,9 @@ const link = (function() {
|
|||||||
|
|
||||||
// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior
|
// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior
|
||||||
// of opening the link in new window/tab
|
// of opening the link in new window/tab
|
||||||
$(document).on('click', "a[action='note']", goToInternalNote);
|
$(document).on('click', "a[action='note']", goToLink);
|
||||||
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content', goToInternalNote);
|
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content', goToLink);
|
||||||
$(document).on('dblclick', '#note-detail a, div.ui-tooltip-content', goToInternalNote);
|
$(document).on('dblclick', '#note-detail a, div.ui-tooltip-content', goToLink);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getNodePathFromLabel,
|
getNodePathFromLabel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user