mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
clicking on links inside tooltip now works too
This commit is contained in:
parent
c4ed01128b
commit
14acacf2e9
@ -10,7 +10,7 @@ $(document).bind('keydown', 'alt+l', () => {
|
|||||||
width: 500
|
width: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
function setDefaultlinkTitle(noteId) {
|
function setDefaultLinkTitle(noteId) {
|
||||||
const noteTitle = getNoteTitle(noteId);
|
const noteTitle = getNoteTitle(noteId);
|
||||||
|
|
||||||
$("#link-title").val(noteTitle);
|
$("#link-title").val(noteTitle);
|
||||||
@ -24,7 +24,7 @@ $(document).bind('keydown', 'alt+l', () => {
|
|||||||
const noteId = getNodeIdFromLabel(val);
|
const noteId = getNodeIdFromLabel(val);
|
||||||
|
|
||||||
if (noteId) {
|
if (noteId) {
|
||||||
setDefaultlinkTitle(noteId);
|
setDefaultLinkTitle(noteId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// this is called when user goes through autocomplete list with keyboard
|
// this is called when user goes through autocomplete list with keyboard
|
||||||
@ -37,7 +37,7 @@ $(document).bind('keydown', 'alt+l', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#insertLinkForm").submit(() => {
|
$("#insert-link-form").submit(() => {
|
||||||
let val = $("#note-autocomplete").val();
|
let val = $("#note-autocomplete").val();
|
||||||
|
|
||||||
const noteId = getNodeIdFromLabel(val);
|
const noteId = getNodeIdFromLabel(val);
|
||||||
@ -51,7 +51,7 @@ $("#insertLinkForm").submit(() => {
|
|||||||
noteDetail.summernote('editor.restoreRange');
|
noteDetail.summernote('editor.restoreRange');
|
||||||
|
|
||||||
noteDetail.summernote('createLink', {
|
noteDetail.summernote('createLink', {
|
||||||
text: link-title,
|
text: linkTitle,
|
||||||
url: 'app#' + noteId,
|
url: 'app#' + noteId,
|
||||||
isNewWindow: true
|
isNewWindow: true
|
||||||
});
|
});
|
||||||
@ -62,14 +62,33 @@ $("#insertLinkForm").submit(() => {
|
|||||||
|
|
||||||
// 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', 'div.popover-content a', e => {
|
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content', e => {
|
||||||
goToInternalNote(e);
|
goToInternalNote(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('dblclick', '.note-editable a', e => {
|
$(document).on('dblclick', '.note-editable a, div.ui-tooltip-content', e => {
|
||||||
goToInternalNote(e);
|
goToInternalNote(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function goToInternalNote(e, callback) {
|
||||||
|
const targetUrl = $(e.target).attr("href");
|
||||||
|
|
||||||
|
const noteId = getNoteIdFromLink(targetUrl);
|
||||||
|
|
||||||
|
if (noteId !== null) {
|
||||||
|
getNodeByKey(noteId).setActive();
|
||||||
|
|
||||||
|
// this is quite ugly hack, but it seems like we can't close the tooltip otherwise
|
||||||
|
$("[role='tooltip']").remove();
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getNoteIdFromLink(url) {
|
function getNoteIdFromLink(url) {
|
||||||
const noteIdMatch = /app#([A-Za-z0-9]{22})/.exec(url);
|
const noteIdMatch = /app#([A-Za-z0-9]{22})/.exec(url);
|
||||||
|
|
||||||
@ -81,22 +100,6 @@ function getNoteIdFromLink(url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToInternalNote(e, callback) {
|
|
||||||
const targetUrl = $(e.target).attr("href");
|
|
||||||
|
|
||||||
const noteId = getNoteIdFromLink(targetUrl);
|
|
||||||
|
|
||||||
if (noteId !== null) {
|
|
||||||
getNodeByKey(noteId).setActive();
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNodeIdFromLabel(label) {
|
function getNodeIdFromLabel(label) {
|
||||||
const noteIdMatch = / \(([A-Za-z0-9]{22})\)/.exec(label);
|
const noteIdMatch = / \(([A-Za-z0-9]{22})\)/.exec(label);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user