mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 17:21:23 +08:00
clicking on links inside tooltip now works too
This commit is contained in:
parent
c4ed01128b
commit
14acacf2e9
1 changed files with 25 additions and 22 deletions
|
@ -10,7 +10,7 @@ $(document).bind('keydown', 'alt+l', () => {
|
|||
width: 500
|
||||
});
|
||||
|
||||
function setDefaultlinkTitle(noteId) {
|
||||
function setDefaultLinkTitle(noteId) {
|
||||
const noteTitle = getNoteTitle(noteId);
|
||||
|
||||
$("#link-title").val(noteTitle);
|
||||
|
@ -24,7 +24,7 @@ $(document).bind('keydown', 'alt+l', () => {
|
|||
const noteId = getNodeIdFromLabel(val);
|
||||
|
||||
if (noteId) {
|
||||
setDefaultlinkTitle(noteId);
|
||||
setDefaultLinkTitle(noteId);
|
||||
}
|
||||
},
|
||||
// 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();
|
||||
|
||||
const noteId = getNodeIdFromLabel(val);
|
||||
|
@ -51,7 +51,7 @@ $("#insertLinkForm").submit(() => {
|
|||
noteDetail.summernote('editor.restoreRange');
|
||||
|
||||
noteDetail.summernote('createLink', {
|
||||
text: link-title,
|
||||
text: linkTitle,
|
||||
url: 'app#' + noteId,
|
||||
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
|
||||
// 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);
|
||||
});
|
||||
|
||||
$(document).on('dblclick', '.note-editable a', e => {
|
||||
$(document).on('dblclick', '.note-editable a, div.ui-tooltip-content', 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) {
|
||||
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) {
|
||||
const noteIdMatch = / \(([A-Za-z0-9]{22})\)/.exec(label);
|
||||
|
||||
|
|
Loading…
Reference in a new issue