From: Dan Brown Date: Mon, 28 Feb 2022 13:29:34 +0000 (+0000) Subject: Added ctrl+shift+k shortcut to WYSIWYG X-Git-Tag: v22.03~1^2~19^2~1 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/20ecaa5c5abcf86bd3411a6e2c440a208631f203 Added ctrl+shift+k shortcut to WYSIWYG Shows entity select dialog for more direct entity link insertion. Aligns with shortcut from markdown editor. For #3244 --- diff --git a/resources/js/wysiwyg/shortcuts.js b/resources/js/wysiwyg/shortcuts.js index 7b7af41ec..8b51437f1 100644 --- a/resources/js/wysiwyg/shortcuts.js +++ b/resources/js/wysiwyg/shortcuts.js @@ -39,4 +39,19 @@ export function register(editor) { editor.formatter.apply('callout' + newFormat); }); + + // Link selector shortcut + editor.shortcuts.add('meta+shift+K', '', function() { + window.EntitySelectorPopup.show(function(entity) { + + if (editor.selection.isCollapsed()) { + editor.insertContent(editor.dom.createHTML('a', {href: entity.link}, editor.dom.encode(entity.name))); + } else { + editor.formatter.apply('link', {href: entity.link}); + } + + editor.selection.collapse(false); + editor.focus(); + }) + }); } \ No newline at end of file diff --git a/resources/lang/en/editor.php b/resources/lang/en/editor.php index 76a9f7fca..4fb1b8f2e 100644 --- a/resources/lang/en/editor.php +++ b/resources/lang/en/editor.php @@ -145,6 +145,7 @@ return [ 'editor_tiny_license_link' => 'The copyright and license details of TinyMCE can be found here.', 'save_continue' => 'Save Page & Continue', 'callouts_cycle' => '(Keep pressing to toggle through types)', + 'link_selector' => 'Link to content', 'shortcuts' => 'Shortcuts', 'shortcut' => 'Shortcut', 'shortcuts_intro' => 'The following shortcuts are available in the editor:', diff --git a/resources/views/help/wysiwyg.blade.php b/resources/views/help/wysiwyg.blade.php index 932e37d2e..30fdc18de 100644 --- a/resources/views/help/wysiwyg.blade.php +++ b/resources/views/help/wysiwyg.blade.php @@ -115,6 +115,15 @@ {{ trans('editor.callouts_cycle') }} + + + Ctrl+Shift+K + + + Cmd+Shift+K + + {{ trans('editor.link_selector') }} +