]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/shortcuts.js
Audit Log: Fixed bad reference to linked entity item
[bookstack] / resources / js / wysiwyg / shortcuts.js
index 1c20df9c5516c8df6a640151b0b5be4c1b99fa11..dbc725b1dcd64d55533978e862867fecffda5177 100644 (file)
@@ -48,6 +48,7 @@ export function register(editor) {
     editor.shortcuts.add('meta+shift+K', '', () => {
         /** @var {EntitySelectorPopup} * */
         const selectorPopup = window.$components.first('entity-selector-popup');
+        const selectionText = editor.selection.getContent({format: 'text'}).trim();
         selectorPopup.show(entity => {
             if (editor.selection.isCollapsed()) {
                 editor.insertContent(editor.dom.createHTML('a', {href: entity.link}, editor.dom.encode(entity.name)));
@@ -57,6 +58,11 @@ export function register(editor) {
 
             editor.selection.collapse(false);
             editor.focus();
+        }, {
+            initialValue: selectionText,
+            searchEndpoint: '/search/entity-selector',
+            entityTypes: 'page,book,chapter,bookshelf',
+            entityPermission: 'view',
         });
     });
 }