mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
parent
5cfd1c030d
commit
061f8acf11
@ -7,6 +7,8 @@ import froca from "../../services/froca.js";
|
||||
import treeService from "../../services/tree.js";
|
||||
import noteCreateService from "../../services/note_create.js";
|
||||
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
||||
import link from "../../services/link.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
|
||||
@ -254,6 +256,21 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
return text;
|
||||
}
|
||||
|
||||
async followLinkUnderCursorCommand() {
|
||||
await this.initialized;
|
||||
|
||||
const selection = this.textEditor.model.document.selection;
|
||||
if (!selection.hasAttribute('linkHref')) return;
|
||||
|
||||
const selectedLinkUrl = selection.getAttribute('linkHref');
|
||||
const notePath = link.getNotePathFromUrl(selectedLinkUrl);
|
||||
if (notePath) {
|
||||
await appContext.tabManager.getActiveContext().setNote(notePath);
|
||||
} else {
|
||||
window.open(selectedLinkUrl, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
addIncludeNoteToTextCommand() {
|
||||
import("../../dialogs/include_note.js").then(d => d.showDialog(this));
|
||||
}
|
||||
|
@ -284,6 +284,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
description: "Open dialog to add link to the text",
|
||||
scope: "text-detail"
|
||||
},
|
||||
{
|
||||
actionName: "followLinkUnderCursor",
|
||||
defaultShortcuts: ["CommandOrControl+Enter"],
|
||||
description: "Follow link within which the caret is placed",
|
||||
scope: "text-detail"
|
||||
},
|
||||
{
|
||||
actionName: "insertDateTimeToText",
|
||||
defaultShortcuts: ["Alt+T"],
|
||||
|
@ -93,6 +93,7 @@
|
||||
<kbd data-command="scrollToActiveNote">not set</kbd> will switch back from editor to tree pane.</li>
|
||||
<li><kbd>Ctrl+K</kbd> - create / edit external link</li>
|
||||
<li><kbd data-command="addLinkToText">not set</kbd> - create internal link</li>
|
||||
<li><kbd data-command="followLinkUnderCursor">not set</kbd> - follow link under cursor</li>
|
||||
<li><kbd data-command="insertDateTimeToText">not set</kbd> - insert current date and time at caret position</li>
|
||||
<li><kbd data-command="scrollToActiveNote">not set</kbd> - jump away to the tree pane and scroll to active note</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user