mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 01:18:44 +02:00
simplified and more consistent link handling, also fixes #1191
This commit is contained in:
parent
a87b710626
commit
c20577909c
@ -132,51 +132,8 @@ function linkContextMenu(e) {
|
||||
});
|
||||
}
|
||||
|
||||
// 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('mousedown', "a[data-action='note']", goToLink);
|
||||
$(document).on('mousedown', 'div.popover-content a, div.ui-tooltip-content a', goToLink);
|
||||
$(document).on('dblclick', '.note-detail-text a', goToLink);
|
||||
$(document).on('mousedown', '.note-detail-text a:not(.reference-link)', function (e) {
|
||||
const $link = $(e.target).closest("a");
|
||||
const notePath = getNotePathFromLink($link);
|
||||
|
||||
if ((e.which === 1 && e.ctrlKey) || e.which === 2) {
|
||||
// if it's a ctrl-click, then we open on new tab, otherwise normal flow (CKEditor opens link-editing dialog)
|
||||
e.preventDefault();
|
||||
|
||||
if (notePath) {
|
||||
appContext.tabManager.openTabWithNote(notePath, false);
|
||||
}
|
||||
else {
|
||||
const address = $link.attr('href');
|
||||
|
||||
window.open(address, '_blank');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mousedown', 'a.reference-link', goToLink);
|
||||
$(document).on('mousedown', '.note-detail-book a', goToLink);
|
||||
$(document).on('mousedown', '.note-detail-render a', goToLink);
|
||||
$(document).on('mousedown', '.note-detail-readonly-text a', goToLink);
|
||||
$(document).on('mousedown', 'a.ck-link-actions__preview', goToLink);
|
||||
$(document).on('click', 'section.include-note a', goToLink);
|
||||
$(document).on('click', 'a.ck-link-actions__preview', e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(document).on('contextmenu', 'a.ck-link-actions__preview', linkContextMenu);
|
||||
$(document).on('contextmenu', '.note-detail-text a', linkContextMenu);
|
||||
$(document).on('contextmenu', '.note-detail-readonly-text a', linkContextMenu);
|
||||
$(document).on('contextmenu', 'a.reference-link', linkContextMenu);
|
||||
$(document).on('contextmenu', "a[data-action='note']", linkContextMenu);
|
||||
$(document).on('contextmenu', ".note-detail-render a", linkContextMenu);
|
||||
$(document).on('contextmenu', ".note-paths-widget a", linkContextMenu);
|
||||
$(document).on('contextmenu', "section.include-note a", linkContextMenu);
|
||||
$(document).on('mousedown', "a", goToLink);
|
||||
$(document).on('contextmenu', 'a', linkContextMenu);
|
||||
|
||||
export default {
|
||||
getNotePathFromUrl,
|
||||
|
@ -42,23 +42,27 @@ const mentionSetup = {
|
||||
};
|
||||
|
||||
const TPL = `
|
||||
<div class="note-detail-text note-detail-printable">
|
||||
<div class="note-detail-editable-text note-detail-printable">
|
||||
<style>
|
||||
.note-detail-text h1 { font-size: 2.0em; }
|
||||
.note-detail-text h2 { font-size: 1.8em; }
|
||||
.note-detail-text h3 { font-size: 1.6em; }
|
||||
.note-detail-text h4 { font-size: 1.4em; }
|
||||
.note-detail-text h5 { font-size: 1.2em; }
|
||||
.note-detail-text h6 { font-size: 1.1em; }
|
||||
.note-detail-editable-text a:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.note-detail-text {
|
||||
.note-detail-editable-text h1 { font-size: 2.0em; }
|
||||
.note-detail-editable-text h2 { font-size: 1.8em; }
|
||||
.note-detail-editable-text h3 { font-size: 1.6em; }
|
||||
.note-detail-editable-text h4 { font-size: 1.4em; }
|
||||
.note-detail-editable-text h5 { font-size: 1.2em; }
|
||||
.note-detail-editable-text h6 { font-size: 1.1em; }
|
||||
|
||||
.note-detail-editable-text {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
font-family: var(--detail-text-font-family);
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.note-detail-text-editor {
|
||||
.note-detail-editable-text-editor {
|
||||
padding-top: 10px;
|
||||
border: 0 !important;
|
||||
box-shadow: none !important;
|
||||
@ -66,12 +70,12 @@ const TPL = `
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
.note-detail-text p:first-child, .note-detail-text::before {
|
||||
.note-detail-editable-text p:first-child, .note-detail-editable-text::before {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="note-detail-text-editor" tabindex="300"></div>
|
||||
<div class="note-detail-editable-text-editor" tabindex="300"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -80,7 +84,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$editor = this.$widget.find('.note-detail-text-editor');
|
||||
this.$editor = this.$widget.find('.note-detail-editable-text-editor');
|
||||
|
||||
this.initialized = this.initEditor();
|
||||
|
||||
|
@ -20,7 +20,7 @@ const TPL = `
|
||||
font-family: var(--detail-text-font-family);
|
||||
}
|
||||
|
||||
.note-detail-readonly-text p:first-child, .note-detail-text::before {
|
||||
.note-detail-readonly-text p:first-child, .note-detail-editable-text::before {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user