From 80e3645bb0dacb8f6d772f810b5db2416422f835 Mon Sep 17 00:00:00 2001 From: handlerug Date: Sun, 13 Jun 2021 23:21:49 +0700 Subject: [PATCH] Shortcut for editing opened hypha It's `e` --- static/shortcuts.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/static/shortcuts.js b/static/shortcuts.js index 6ed468b..83ea527 100644 --- a/static/shortcuts.js +++ b/static/shortcuts.js @@ -311,24 +311,25 @@ bindElement(`g ${i}`, headerLinks[i-1], `Header link #${i}`); } - globalShortcuts.groupStart(); - globalShortcuts.fakeItem('1 – 9', 'First 9 hypha′s links'); - bindElement('p, Alt+ArrowLeft', '.prevnext__prev', 'Next hypha'); - bindElement('n, Alt+ArrowRight', '.prevnext__next', 'Previous hypha'); - bindElement('s, Alt+ArrowTop', $$('.navi-title a').slice(1, -1).slice(-1)[0], 'Parent hypha'); - globalShortcuts.groupEnd(); + // * Hypha shortcuts + if (typeof editTextarea === 'undefined') { + globalShortcuts.fakeItem('Hypha'); - let hyphaLinks = $$('article .wikilink'); - for (let i = 1; i <= hyphaLinks.length && i < 10; i++) { - bindElement(i.toString(), hyphaLinks[i-1], `Hypha link #${i}`); + globalShortcuts.groupStart(); + globalShortcuts.fakeItem('1 – 9', 'First 9 hypha′s links'); + bindElement('p, Alt+ArrowLeft', '.prevnext__prev', 'Next hypha'); + bindElement('n, Alt+ArrowRight', '.prevnext__next', 'Previous hypha'); + bindElement('s, Alt+ArrowTop', $$('.navi-title a').slice(1, -1).slice(-1)[0], 'Parent hypha'); + bindElement('e', '.hypha-tabs__link[href^="/edit/"]', 'Edit this hypha'); + globalShortcuts.groupEnd(); + + let hyphaLinks = $$('article .wikilink'); + for (let i = 1; i <= hyphaLinks.length && i < 10; i++) { + bindElement(i.toString(), hyphaLinks[i-1], `Hypha link #${i}`); + } } - // * Meta shortcuts - - globalShortcuts.add('?', openShortcutsReference); - // Hypha editor shortcuts - if (typeof editTextarea !== 'undefined') { let editorShortcuts = new ShortcutHandler(editTextarea); @@ -363,5 +364,8 @@ editorShortcuts.add(isMac ? 'Meta+/' : 'Ctrl+/', openShortcutsReference); } + + // * Meta shortcuts + globalShortcuts.add('?', openShortcutsReference); }); })();