diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index 17856c2401..ae41381c48 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -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)); } diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js index c72d588ac7..24aa100a9c 100644 --- a/src/services/keyboard_actions.js +++ b/src/services/keyboard_actions.js @@ -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"], diff --git a/src/views/dialogs/help.ejs b/src/views/dialogs/help.ejs index f370f6ca54..541556ee71 100644 --- a/src/views/dialogs/help.ejs +++ b/src/views/dialogs/help.ejs @@ -93,6 +93,7 @@ not set will switch back from editor to tree pane.
  • Ctrl+K - create / edit external link
  • not set - create internal link
  • +
  • not set - follow link under cursor
  • not set - insert current date and time at caret position
  • not set - jump away to the tree pane and scroll to active note