X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/397a36cfd05d26faecc1350817fa1d2fb20aa6ff..refs/pull/4467/head:/resources/js/wysiwyg/shortcuts.js diff --git a/resources/js/wysiwyg/shortcuts.js b/resources/js/wysiwyg/shortcuts.js index b42851a46..1c20df9c5 100644 --- a/resources/js/wysiwyg/shortcuts.js +++ b/resources/js/wysiwyg/shortcuts.js @@ -4,7 +4,7 @@ export function register(editor) { // Headers for (let i = 1; i < 5; i++) { - editor.shortcuts.add('meta+' + i, '', ['FormatBlock', false, 'h' + (i+1)]); + editor.shortcuts.add(`meta+${i}`, '', ['FormatBlock', false, `h${i + 1}`]); } // Other block shortcuts @@ -30,22 +30,25 @@ export function register(editor) { }); // Loop through callout styles - editor.shortcuts.add('meta+9', '', function() { + editor.shortcuts.add('meta+9', '', () => { const selectedNode = editor.selection.getNode(); const callout = selectedNode ? selectedNode.closest('.callout') : null; const formats = ['info', 'success', 'warning', 'danger']; - const currentFormatIndex = formats.findIndex(format => callout && callout.classList.contains(format)); + const currentFormatIndex = formats.findIndex(format => { + return callout && callout.classList.contains(format); + }); const newFormatIndex = (currentFormatIndex + 1) % formats.length; const newFormat = formats[newFormatIndex]; - editor.formatter.apply('callout' + newFormat); + editor.formatter.apply(`callout${newFormat}`); }); // Link selector shortcut - editor.shortcuts.add('meta+shift+K', '', function() { - window.EntitySelectorPopup.show(function(entity) { - + editor.shortcuts.add('meta+shift+K', '', () => { + /** @var {EntitySelectorPopup} * */ + const selectorPopup = window.$components.first('entity-selector-popup'); + selectorPopup.show(entity => { if (editor.selection.isCollapsed()) { editor.insertContent(editor.dom.createHTML('a', {href: entity.link}, editor.dom.encode(entity.name))); } else { @@ -54,6 +57,6 @@ export function register(editor) { editor.selection.collapse(false); editor.focus(); - }) + }); }); -} \ No newline at end of file +}