2021-06-14 03:13:07 +00:00
|
|
|
|
(() => {
|
|
|
|
|
const $ = document.querySelector.bind(document);
|
|
|
|
|
const $$ = (...args) => Array.prototype.slice.call(document.querySelectorAll(...args));
|
|
|
|
|
|
|
|
|
|
const isMac = /Macintosh/.test(window.navigator.userAgent);
|
|
|
|
|
|
|
|
|
|
function keyEventToShortcut(event) {
|
2021-06-13 06:48:18 +00:00
|
|
|
|
let elideShift = event.key.toUpperCase() === event.key && event.shiftKey;
|
|
|
|
|
return (event.ctrlKey ? 'Ctrl+' : '') +
|
|
|
|
|
(event.altKey ? 'Alt+' : '') +
|
|
|
|
|
(event.metaKey ? 'Meta+' : '') +
|
|
|
|
|
(!elideShift && event.shiftKey ? 'Shift+' : '') +
|
2021-06-13 08:14:03 +00:00
|
|
|
|
(event.key === ',' ? 'Comma' : event.key === ' ' ? 'Space' : event.key);
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
function prettifyShortcut(shortcut) {
|
2021-06-13 16:14:18 +00:00
|
|
|
|
let keys = shortcut.split('+');
|
|
|
|
|
|
|
|
|
|
if (isMac) {
|
|
|
|
|
let cmdIdx = keys.indexOf('Meta');
|
|
|
|
|
if (cmdIdx !== -1 && keys.length - cmdIdx > 2) {
|
|
|
|
|
let tmp = keys[cmdIdx + 1];
|
|
|
|
|
keys[cmdIdx + 1] = 'Meta';
|
|
|
|
|
keys[cmdIdx] = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let lastKey = keys[keys.length - 1];
|
|
|
|
|
if (!keys.includes('Shift') && lastKey.toUpperCase() === lastKey && lastKey.toLowerCase() !== lastKey) {
|
|
|
|
|
keys.splice(keys.length - 1, 0, 'Shift');
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
|
|
|
if (isMac) {
|
|
|
|
|
switch (keys[i]) {
|
|
|
|
|
case 'Ctrl': keys[i] = '⌃'; break;
|
|
|
|
|
case 'Alt': keys[i] = '⌥'; break;
|
|
|
|
|
case 'Shift': keys[i] = '⇧'; break;
|
|
|
|
|
case 'Meta': keys[i] = '⌘'; break;
|
|
|
|
|
}
|
2021-06-13 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
if (i === keys.length - 1 && i > 0 && keys[i].length === 1) {
|
|
|
|
|
keys[i] = keys[i].toUpperCase();
|
|
|
|
|
}
|
2021-06-13 16:28:02 +00:00
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
switch (keys[i]) {
|
|
|
|
|
case 'ArrowLeft': keys[i] = '←'; break;
|
|
|
|
|
case 'ArrowRight': keys[i] = '→'; break;
|
2021-06-14 03:33:11 +00:00
|
|
|
|
case 'ArrowUp': keys[i] = '↑'; break;
|
|
|
|
|
case 'ArrowDown': keys[i] = '↓'; break;
|
2021-06-14 03:13:07 +00:00
|
|
|
|
case 'Comma': keys[i] = ','; break;
|
|
|
|
|
case 'Enter': keys[i] = '↩'; break;
|
|
|
|
|
case ' ': keys[i] = 'Space'; break;
|
2021-06-13 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
keys[i] = `<kbd>${keys[i]}</kbd>`;
|
2021-06-13 19:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
return keys.join(isMac ? '' : ' + ');
|
|
|
|
|
}
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
function isTextField(element) {
|
|
|
|
|
let name = element.nodeName.toLowerCase();
|
|
|
|
|
return name === 'textarea' ||
|
|
|
|
|
name === 'select' ||
|
|
|
|
|
(name === 'input' && !['submit', 'reset', 'checkbox', 'radio'].includes(element.type)) ||
|
|
|
|
|
element.isContentEditable;
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 16:14:18 +00:00
|
|
|
|
let notTextField = event => !(event.target instanceof Node && isTextField(event.target));
|
|
|
|
|
|
|
|
|
|
let allShortcuts = [];
|
|
|
|
|
let shortcutsGroup = null;
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
class ShortcutHandler {
|
2021-06-14 01:11:15 +00:00
|
|
|
|
constructor(element, override, filter = () => true) {
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.element = element;
|
|
|
|
|
this.map = {};
|
|
|
|
|
this.active = this.map;
|
2021-06-14 03:58:36 +00:00
|
|
|
|
this.override = override;
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.filter = filter;
|
|
|
|
|
this.timeout = null;
|
2021-06-13 05:40:06 +00:00
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
|
|
|
this.resetActive = this.resetActive.bind(this);
|
2021-06-14 03:13:07 +00:00
|
|
|
|
this.addEventListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addEventListeners() {
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.element.addEventListener('keydown', this.handleKeyDown);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:58:36 +00:00
|
|
|
|
add(text, action, description = null, shownInHelp = true) {
|
|
|
|
|
let shortcuts = text.trim().split(',').map(shortcut => shortcut.trim().split(' '));
|
2021-06-13 06:48:18 +00:00
|
|
|
|
|
2021-06-14 03:58:36 +00:00
|
|
|
|
if (shortcutsGroup && shownInHelp) {
|
2021-06-13 16:14:18 +00:00
|
|
|
|
shortcutsGroup.push({
|
|
|
|
|
action,
|
|
|
|
|
shortcut: text,
|
|
|
|
|
description,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
for (let shortcut of shortcuts) {
|
|
|
|
|
let node = this.map;
|
|
|
|
|
for (let key of shortcut) {
|
|
|
|
|
if (!node[key]) {
|
|
|
|
|
node[key] = {};
|
|
|
|
|
}
|
|
|
|
|
node = node[key];
|
|
|
|
|
if (node.action) {
|
|
|
|
|
delete node.action;
|
|
|
|
|
delete node.shortcut;
|
|
|
|
|
delete node.description;
|
|
|
|
|
}
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
node.action = action;
|
|
|
|
|
node.shortcut = shortcut;
|
|
|
|
|
node.description = description;
|
|
|
|
|
}
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
group(...args) {
|
|
|
|
|
if (typeof args[0] === 'string') this.fakeItem(args.shift());
|
2021-06-13 16:14:18 +00:00
|
|
|
|
shortcutsGroup = [];
|
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
args[0].bind(this)();
|
|
|
|
|
|
2021-06-13 16:14:18 +00:00
|
|
|
|
if (shortcutsGroup && shortcutsGroup.length) allShortcuts.push(shortcutsGroup);
|
|
|
|
|
shortcutsGroup = null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
bindElement(shortcut, element, ...other) {
|
|
|
|
|
element = typeof element === 'string' ? $(element) : element;
|
|
|
|
|
if (!element) return;
|
|
|
|
|
this.add(shortcut, () => {
|
|
|
|
|
if (isTextField(element)) {
|
|
|
|
|
element.focus();
|
|
|
|
|
} else {
|
|
|
|
|
element.click();
|
|
|
|
|
}
|
|
|
|
|
}, ...other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bindLink(shortcut, link, ...other) {
|
|
|
|
|
this.add(shortcut, () => window.location.href = link, ...other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bindCollection(prefix, elements, collectionDescription, itemDescription) {
|
|
|
|
|
this.fakeItem(prefix + ' 1 – 9', collectionDescription);
|
|
|
|
|
|
|
|
|
|
if (typeof elements === 'string') {
|
|
|
|
|
elements = $$(elements);
|
|
|
|
|
} else if (Array.isArray(elements)) {
|
|
|
|
|
elements = elements.map(el => typeof el === 'string' ? $(el) : el);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 1; i <= elements.length && i < 10; i++) {
|
|
|
|
|
this.bindElement(`${prefix} ${i}`, elements[i-1], `${itemDescription} #${i}`, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 16:14:18 +00:00
|
|
|
|
fakeItem(shortcut, description = null) {
|
|
|
|
|
let list = shortcutsGroup || allShortcuts;
|
|
|
|
|
list.push({
|
|
|
|
|
shortcut: description ? shortcut : null,
|
|
|
|
|
description: description || shortcut,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
handleKeyDown(event) {
|
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
|
if (['Control', 'Alt', 'Shift', 'Meta'].includes(event.key)) return;
|
|
|
|
|
if (!this.filter(event)) return;
|
2021-06-13 05:40:06 +00:00
|
|
|
|
|
2021-06-14 03:13:07 +00:00
|
|
|
|
let shortcut = keyEventToShortcut(event);
|
2021-06-13 05:40:06 +00:00
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
if (!this.active[shortcut]) {
|
|
|
|
|
this.resetActive();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.active = this.active[shortcut];
|
|
|
|
|
if (this.active.action) {
|
2021-06-14 06:50:52 +00:00
|
|
|
|
event.stopPropagation();
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.active.action(event);
|
2021-06-14 03:58:36 +00:00
|
|
|
|
if (this.override) event.preventDefault();
|
2021-06-13 06:48:18 +00:00
|
|
|
|
this.resetActive();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.timeout) clearTimeout(this.timeout);
|
|
|
|
|
this.timeout = window.setTimeout(this.resetActive, 1500);
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
resetActive() {
|
|
|
|
|
this.active = this.map;
|
|
|
|
|
if (this.timeout) {
|
|
|
|
|
clearTimeout(this.timeout)
|
|
|
|
|
this.timeout = null;
|
|
|
|
|
}
|
2021-06-13 05:40:06 +00:00
|
|
|
|
}
|
2021-06-13 06:48:18 +00:00
|
|
|
|
}
|
2021-06-13 05:40:06 +00:00
|
|
|
|
|
2021-06-14 05:16:50 +00:00
|
|
|
|
class ShortcutsHelpDialog {
|
|
|
|
|
constructor() {
|
|
|
|
|
let template = $('#dialog-template');
|
2021-06-14 06:50:52 +00:00
|
|
|
|
let clonedTemplate = template.content.cloneNode(true);
|
|
|
|
|
this.backdrop = clonedTemplate.children[0];
|
|
|
|
|
this.dialog = clonedTemplate.children[1];
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.dialog.classList.add('shortcuts-help');
|
|
|
|
|
this.dialog.hidden = true;
|
|
|
|
|
this.backdrop.hidden = true;
|
|
|
|
|
|
|
|
|
|
document.body.appendChild(this.backdrop);
|
|
|
|
|
document.body.appendChild(this.dialog);
|
2021-06-14 05:16:50 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.close = this.close.bind(this);
|
2021-06-14 05:16:50 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.dialog.querySelector('.dialog__title').textContent = 'List of shortcuts';
|
|
|
|
|
this.dialog.querySelector('.dialog__close-button').addEventListener('click', this.close);
|
|
|
|
|
this.backdrop.addEventListener('click', this.close);
|
2021-06-14 05:16:50 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.shortcuts = new ShortcutHandler(this.dialog, false);
|
|
|
|
|
this.shortcuts.add('Escape', this.close, null, false);
|
2021-06-14 05:16:50 +00:00
|
|
|
|
|
|
|
|
|
let shortcutsGroup;
|
2021-06-14 03:40:15 +00:00
|
|
|
|
let shortcutsGroupTemplate = document.createElement('div');
|
|
|
|
|
shortcutsGroupTemplate.className = 'shortcuts-group';
|
|
|
|
|
|
2021-06-13 16:14:18 +00:00
|
|
|
|
for (let item of allShortcuts) {
|
|
|
|
|
if (item.description && !item.shortcut) {
|
2021-06-14 05:16:50 +00:00
|
|
|
|
shortcutsGroup = shortcutsGroupTemplate.cloneNode();
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.dialog.querySelector('.dialog__content').appendChild(shortcutsGroup);
|
2021-06-14 03:40:15 +00:00
|
|
|
|
|
2021-06-13 16:14:18 +00:00
|
|
|
|
let heading = document.createElement('h2');
|
|
|
|
|
heading.className = 'shortcuts-group-heading';
|
|
|
|
|
heading.textContent = item.description;
|
2021-06-14 03:40:15 +00:00
|
|
|
|
shortcutsGroup.appendChild(heading);
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
let list = document.createElement('ul');
|
2021-06-14 03:40:15 +00:00
|
|
|
|
list.className = 'shortcuts-list';
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
for (let shortcut of item) {
|
|
|
|
|
let listItem = document.createElement('li');
|
|
|
|
|
listItem.className = 'shortcut-row';
|
|
|
|
|
list.appendChild(listItem);
|
|
|
|
|
|
|
|
|
|
let descriptionColumn = document.createElement('div')
|
|
|
|
|
descriptionColumn.className = 'shortcut-row__description';
|
|
|
|
|
descriptionColumn.textContent = shortcut.description;
|
|
|
|
|
listItem.appendChild(descriptionColumn);
|
|
|
|
|
|
|
|
|
|
let shortcutColumn = document.createElement('div');
|
|
|
|
|
shortcutColumn.className = 'shortcut-row__keys';
|
|
|
|
|
shortcutColumn.innerHTML = shortcut.shortcut.split(',')
|
2021-06-14 03:13:07 +00:00
|
|
|
|
.map(shortcuts => shortcuts.trim().split(' ').map(prettifyShortcut).join(' '))
|
2021-06-14 03:35:37 +00:00
|
|
|
|
.join(' <span class="kbd-or">or</span> ');
|
2021-06-13 16:14:18 +00:00
|
|
|
|
listItem.appendChild(shortcutColumn);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 03:40:15 +00:00
|
|
|
|
shortcutsGroup.appendChild(list);
|
2021-06-13 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-14 05:16:50 +00:00
|
|
|
|
}
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-14 05:16:50 +00:00
|
|
|
|
open() {
|
|
|
|
|
this.prevActiveElement = document.activeElement;
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-14 05:16:50 +00:00
|
|
|
|
document.body.overflow = 'hidden';
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.backdrop.hidden = false;
|
|
|
|
|
this.dialog.hidden = false;
|
|
|
|
|
this.dialog.focus();
|
2021-06-13 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 05:16:50 +00:00
|
|
|
|
close() {
|
2021-06-13 16:14:18 +00:00
|
|
|
|
document.body.overflow = '';
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.backdrop.hidden = true;
|
|
|
|
|
this.dialog.hidden = true;
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-14 05:16:50 +00:00
|
|
|
|
if (this.prevActiveElement) {
|
|
|
|
|
this.prevActiveElement.focus();
|
|
|
|
|
this.prevActiveElement = null;
|
2021-06-13 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:48:18 +00:00
|
|
|
|
window.addEventListener('load', () => {
|
2021-06-14 05:16:50 +00:00
|
|
|
|
let helpDialog = null;
|
|
|
|
|
let openHelp = () => {
|
|
|
|
|
if (!helpDialog) helpDialog = new ShortcutsHelpDialog();
|
|
|
|
|
helpDialog.open();
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-14 07:11:33 +00:00
|
|
|
|
let onEditPage = typeof editTextarea !== 'undefined';
|
|
|
|
|
|
2021-06-14 03:58:36 +00:00
|
|
|
|
// Global shortcuts work everywhere.
|
|
|
|
|
let globalShortcuts = new ShortcutHandler(document, false);
|
2021-06-15 21:18:56 +00:00
|
|
|
|
globalShortcuts.add(isMac ? 'Meta+/' : 'Ctrl+/', openHelp);
|
2021-06-13 06:48:18 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
// Page shortcuts work everywhere except on text fields.
|
|
|
|
|
let pageShortcuts = new ShortcutHandler(document, false, notTextField);
|
|
|
|
|
pageShortcuts.add('?', openHelp, null, false);
|
2021-06-13 08:14:03 +00:00
|
|
|
|
|
2021-06-14 03:58:36 +00:00
|
|
|
|
// Common shortcuts
|
2021-06-14 06:50:52 +00:00
|
|
|
|
pageShortcuts.group('Common', function () {
|
2021-07-13 20:52:33 +00:00
|
|
|
|
this.bindCollection('g', '.top-bar__highlight-link', 'First 9 header links', 'Header link');
|
2021-06-14 06:50:52 +00:00
|
|
|
|
this.bindLink('g h', '/', 'Home');
|
|
|
|
|
this.bindLink('g l', '/list/', 'List of hyphae');
|
|
|
|
|
this.bindLink('g r', '/recent-changes/', 'Recent changes');
|
2021-07-13 20:52:33 +00:00
|
|
|
|
this.bindElement('g u', '.auth-links__user-link', 'Your profile′s hypha');
|
2021-06-14 06:50:52 +00:00
|
|
|
|
});
|
2021-06-13 06:57:40 +00:00
|
|
|
|
|
2021-06-14 07:11:33 +00:00
|
|
|
|
if (!onEditPage) {
|
2021-06-14 03:58:36 +00:00
|
|
|
|
// Hypha shortcuts
|
2021-06-14 06:50:52 +00:00
|
|
|
|
pageShortcuts.group('Hypha', function () {
|
|
|
|
|
this.bindCollection('', 'article .wikilink', 'First 9 hypha′s links', 'Hypha link');
|
|
|
|
|
this.bindElement('p, Alt+ArrowLeft, Ctrl+Alt+ArrowLeft', '.prevnext__prev', 'Next hypha');
|
|
|
|
|
this.bindElement('n, Alt+ArrowRight, Ctrl+Alt+ArrowRight', '.prevnext__next', 'Previous hypha');
|
|
|
|
|
this.bindElement('s, Alt+ArrowUp, Ctrl+Alt+ArrowUp', $$('.navi-title a').slice(1, -1).slice(-1)[0], 'Parent hypha');
|
|
|
|
|
this.bindElement('c, Alt+ArrowDown, Ctrl+Alt+ArrowDown', '.subhyphae__link', 'First child hypha');
|
2021-06-14 07:11:33 +00:00
|
|
|
|
|
2021-08-08 19:46:45 +00:00
|
|
|
|
this.bindElement('v', '.hypha-info__link[href^="/hypha/"]', 'Go to hypha′s page');
|
|
|
|
|
this.bindElement('e, ' + (isMac ? "Meta+Enter" : "Ctrl+Enter"), '.edit-btn__link[href^="/edit/"]', 'Edit this hypha');
|
|
|
|
|
this.bindElement('a', '.hypha-info__link[href^="/attachment/"]', 'Go to attachment');
|
|
|
|
|
this.bindElement('h', '.hypha-info__link[href^="/history/"]', 'Go to history');
|
|
|
|
|
this.bindElement('r', '.hypha-info__link[href^="/rename-ask/"]', 'Rename this hypha');
|
2021-06-14 06:50:52 +00:00
|
|
|
|
});
|
2021-06-13 16:21:49 +00:00
|
|
|
|
|
2021-06-14 03:58:36 +00:00
|
|
|
|
} else {
|
|
|
|
|
// Hypha editor shortcuts. These work only on editor's text area.
|
2021-06-14 01:11:15 +00:00
|
|
|
|
let editorShortcuts = new ShortcutHandler(editTextarea, true);
|
2021-06-13 08:14:03 +00:00
|
|
|
|
|
|
|
|
|
let shortcuts = [
|
2021-06-14 03:15:37 +00:00
|
|
|
|
// Win+Linux Mac Action Description
|
|
|
|
|
['Ctrl+b', 'Meta+b', wrapBold, 'Format: Bold'],
|
|
|
|
|
['Ctrl+i', 'Meta+i', wrapItalic, 'Format: Italic'],
|
|
|
|
|
['Ctrl+M', 'Meta+Shift+m', wrapMonospace, 'Format: Monospaced'],
|
|
|
|
|
['Ctrl+I', 'Meta+Shift+i', wrapHighlighted, 'Format: Highlight'],
|
2021-06-14 07:03:31 +00:00
|
|
|
|
['Ctrl+.', 'Meta+.', wrapLifted, 'Format: Superscript'],
|
|
|
|
|
['Ctrl+Comma', 'Meta+Comma', wrapLowered, 'Format: Subscript'],
|
2021-06-14 03:15:37 +00:00
|
|
|
|
['Ctrl+X', 'Meta+Shift+x', wrapStrikethrough, 'Format: Strikethrough'],
|
|
|
|
|
['Ctrl+k', 'Meta+k', wrapLink, 'Format: Link'],
|
2021-06-13 08:14:03 +00:00
|
|
|
|
];
|
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
editorShortcuts.group('Editor', function () {
|
|
|
|
|
for (let shortcut of shortcuts) {
|
|
|
|
|
if (isMac) {
|
|
|
|
|
this.add(shortcut[1], ...shortcut.slice(2))
|
|
|
|
|
} else {
|
|
|
|
|
this.add(shortcut[0], ...shortcut.slice(2))
|
|
|
|
|
}
|
2021-06-13 08:14:03 +00:00
|
|
|
|
}
|
2021-06-14 06:50:52 +00:00
|
|
|
|
});
|
2021-06-13 16:14:18 +00:00
|
|
|
|
|
2021-06-14 06:50:52 +00:00
|
|
|
|
editorShortcuts.group(function () {
|
|
|
|
|
this.bindElement(isMac ? 'Meta+Enter' : 'Ctrl+Enter', $('.edit-form__save'), 'Save changes');
|
|
|
|
|
});
|
2021-06-13 08:14:03 +00:00
|
|
|
|
}
|
2021-06-13 06:48:18 +00:00
|
|
|
|
});
|
2021-06-13 16:14:18 +00:00
|
|
|
|
})();
|