]> BookStack Code Mirror - bookstack/commitdiff
Added ctrl+shift+k shortcut to WYSIWYG
authorDan Brown <redacted>
Mon, 28 Feb 2022 13:29:34 +0000 (13:29 +0000)
committerDan Brown <redacted>
Mon, 28 Feb 2022 13:34:32 +0000 (13:34 +0000)
Shows entity select dialog for more direct entity link insertion.
Aligns with shortcut from markdown editor.

For #3244

resources/js/wysiwyg/shortcuts.js
resources/lang/en/editor.php
resources/views/help/wysiwyg.blade.php

index 7b7af41ec6db874b3f92b9c7887867275240560a..8b51437f1d811959afba20ed9b766b4c98b44c5e 100644 (file)
@@ -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
index 76a9f7fca07fd590f758ea99b6086aabf1d0b994..4fb1b8f2ea5c1143f635095a7a551f0a1b99bde3 100644 (file)
@@ -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:',
index 932e37d2e2318082703d3b2af9f1b3cd36fc5b31..30fdc18de8a071c91980a87f2e9900f05bc7fe5e 100644 (file)
                     {{ trans('editor.callouts_cycle') }}
                 </td>
             </tr>
+            <tr>
+                <td>
+                    <code>Ctrl</code>+<code>Shift</code>+<code>K</code>
+                </td>
+                <td>
+                    <code>Cmd</code>+<code>Shift</code>+<code>K</code>
+                </td>
+                <td>{{ trans('editor.link_selector') }}</td>
+            </tr>
             </tbody>
         </table>