diff --git a/docs/help/contents/keyboard-shortcuts.md b/docs/help/contents/keyboard-shortcuts.md index 8cb170b8b..1be189cd5 100644 --- a/docs/help/contents/keyboard-shortcuts.md +++ b/docs/help/contents/keyboard-shortcuts.md @@ -9,72 +9,73 @@ The following keyboard shortcuts will help you navigate Notesnook faster. | Description | Web | Windows/Linux | Mac | | --- | --- | --- | --- | -| Next tab | Ctrl Alt right / Ctrl Alt Shift right | Ctrl tab | Command tab | -| Previous tab | Ctrl Alt left / Ctrl Alt Shift left | Ctrl Shift tab | Command Shift tab | -| New tab | - | Ctrl t | Command t | -| Close active tab | - | Ctrl w | Command w | -| Close all tabs | - | Ctrl Shift w | Command Shift w | -| Command palette | Ctrl k | Ctrl k | Command k | -| Quick open | Ctrl p | Ctrl p | Command p | +| Next tab | Ctrl Alt right / ⌘ ⌥ ⇧ right | Ctrl tab | ⌘ tab | +| Previous tab | Ctrl Alt left / ⌘ ⌥ ⇧ left | Ctrl ⇧ tab | ⌘ ⇧ tab | +| New tab | - | Ctrl t | ⌘ t | +| Close active tab | - | Ctrl w | ⌘ w | +| Close all tabs | - | Ctrl ⇧ w | ⌘ ⇧ w | +| Command palette | Ctrl k | Ctrl k | ⌘ k | +| Quick open | Ctrl p | Ctrl p | ⌘ p | ### Note | Description | Web | Windows/Linux | Mac | | --- | --- | --- | --- | -| New note | - | Ctrl n | Command n | +| New note | - | Ctrl n | ⌘ n | ### General | Description | Web | Windows/Linux | Mac | | --- | --- | --- | --- | -| Search in notes list view if editor is not focused | Ctrl f | Ctrl f | Command f | -| Settings | Ctrl , | Ctrl , | Command , | -| Keyboard shortcuts | Ctrl / | Ctrl / | Command / | +| Search in notes list view if editor is not focused | Ctrl f | Ctrl f | ⌘ f | +| Settings | Ctrl , | Ctrl , | ⌘ , | +| Keyboard shortcuts | Ctrl / | Ctrl / | ⌘ / | ### Editor | Description | Web | Windows/Linux | Mac | | --- | --- | --- | --- | -| Add attachment | Ctrl Shift A | Ctrl Shift A | Command Shift A | -| Insert blockquote | Ctrl Shift B | Ctrl Shift B | Command Shift B | -| Toggle bold | Ctrl b | Ctrl b | Command b | -| Toggle bullet list | Ctrl Shift 8 | Ctrl Shift 8 | Command Shift 8 | -| Toggle check list | Ctrl Shift 9 | Ctrl Shift 9 | Command Shift 9 | +| Add attachment | Ctrl ⇧ A | Ctrl ⇧ A | ⌘ ⇧ A | +| Insert blockquote | Ctrl ⇧ B | Ctrl ⇧ B | ⌘ ⇧ B | +| Toggle bold | Ctrl b | Ctrl b | ⌘ b | +| Toggle bullet list | Ctrl ⇧ 8 | Ctrl ⇧ 8 | ⌘ ⇧ 8 | +| Toggle check list | Ctrl ⇧ 9 | Ctrl ⇧ 9 | ⌘ ⇧ 9 | | Split list item | Enter | Enter | Enter | -| Lift list item | Shift Tab | Shift Tab | Shift Tab | -| Sink list item | Ctrl Shift Down | Ctrl Shift Down | Command Shift Down | -| Toggle code | Ctrl e | Ctrl e | Command e | -| Toggle code block | Ctrl Shift C | Ctrl Shift C | Command Shift C | +| Lift list item | ⇧ Tab | ⇧ Tab | ⇧ Tab | +| Sink list item | Ctrl ⇧ Down | Ctrl ⇧ Down | ⌘ ⇧ Down | +| Toggle code | Ctrl e | Ctrl e | ⌘ e | +| Toggle code block | Ctrl ⇧ C | Ctrl ⇧ C | ⌘ ⇧ C | | Insert date | Alt d | Alt d | Option d | | Insert time | Alt t | Alt t | Option t | -| Insert date and time | Ctrl Alt d | Ctrl Alt d | Command Option d | -| Insert date and time with timezone | Ctrl Alt z | Ctrl Alt z | Command Option z | -| Increase font size | Ctrl [ | Ctrl [ | Command [ | -| Decrease font size | Ctrl ] | Ctrl ] | Command ] | -| Insert heading 1 | Ctrl Alt 1 | Ctrl Alt 1 | Command Option 1 | -| Insert heading 2 | Ctrl Alt 2 | Ctrl Alt 2 | Command Option 2 | -| Insert heading 3 | Ctrl Alt 3 | Ctrl Alt 3 | Command Option 3 | -| Insert heading 4 | Ctrl Alt 4 | Ctrl Alt 4 | Command Option 4 | -| Insert heading 5 | Ctrl Alt 5 | Ctrl Alt 5 | Command Option 5 | -| Insert heading 6 | Ctrl Alt 6 | Ctrl Alt 6 | Command Option 6 | -| Undo | Ctrl z | Ctrl z | Command z | -| Redo | Ctrl Shift z / Ctrl y | Ctrl Shift z / Ctrl y | Command Shift z / Command y | -| Add image | Ctrl Shift I | Ctrl Shift I | Command Shift I | -| Toggle italic | Ctrl i | Ctrl i | Command i | -| Remove formatting in selection | Ctrl \ | Ctrl \ | Command \ | -| Insert internal link | Ctrl Shift L | Ctrl Shift L | Command Shift L | -| Insert link | Ctrl Shift K | Ctrl Shift K | Command Shift K | -| Insert math block | Ctrl Shift M | Ctrl Shift M | Command Shift M | -| Toggle ordered list | Ctrl Shift 7 | Ctrl Shift 7 | Command Shift 7 | -| Toggle outline list | Ctrl Shift O | Ctrl Shift O | Command Shift O | -| Toggle outline list expand | Ctrl Space | Ctrl Space | Command Space | -| Open search | Ctrl F | Ctrl F | Command F | -| Toggle strike | Ctrl Shift S | Ctrl Shift S | Command Shift S | -| Toggle subscript | Ctrl , | Ctrl , | Command , | -| Toggle superscript | Ctrl . | Ctrl . | Command . | -| Toggle task list | Ctrl Shift T | Ctrl Shift T | Command Shift T | -| Text align center | Ctrl Shift E | Ctrl Shift E | Command Shift E | -| Text align justify | Ctrl Shift J | Ctrl Shift J | Command Shift J | -| Text align left | Ctrl Shift L | Ctrl Shift L | Command Shift L | -| Text align right | Ctrl Shift R | Ctrl Shift R | Command Shift R | -| Underline | Ctrl u | Ctrl u | Command u | \ No newline at end of file +| Insert date and time | Ctrl Alt d | Ctrl Alt d | ⌘ Option d | +| Insert date and time with timezone | Ctrl Alt z | Ctrl Alt z | ⌘ Option z | +| Increase font size | Ctrl [ | Ctrl [ | ⌘ [ | +| Decrease font size | Ctrl ] | Ctrl ] | ⌘ ] | +| Insert paragraph | Ctrl ⇧ 0 | Ctrl ⇧ 0 | ⌘ ⇧ 0 | +| Insert heading 1 | Ctrl Alt 1 | Ctrl Alt 1 | ⌘ Option 1 | +| Insert heading 2 | Ctrl Alt 2 | Ctrl Alt 2 | ⌘ Option 2 | +| Insert heading 3 | Ctrl Alt 3 | Ctrl Alt 3 | ⌘ Option 3 | +| Insert heading 4 | Ctrl Alt 4 | Ctrl Alt 4 | ⌘ Option 4 | +| Insert heading 5 | Ctrl Alt 5 | Ctrl Alt 5 | ⌘ Option 5 | +| Insert heading 6 | Ctrl Alt 6 | Ctrl Alt 6 | ⌘ Option 6 | +| Undo | Ctrl z | Ctrl z | ⌘ z | +| Redo | Ctrl ⇧ z / ⌘ y | Ctrl ⇧ z / ⌘ y | ⌘ ⇧ z / ⌘ y | +| Add image | Ctrl ⇧ I | Ctrl ⇧ I | ⌘ ⇧ I | +| Toggle italic | Ctrl i | Ctrl i | ⌘ i | +| Remove formatting in selection | Ctrl \ | Ctrl \ | ⌘ \ | +| Insert internal link | Ctrl ⇧ L | Ctrl ⇧ L | ⌘ ⇧ L | +| Insert link | Ctrl ⇧ K | Ctrl ⇧ K | ⌘ ⇧ K | +| Insert math block | Ctrl ⇧ M | Ctrl ⇧ M | ⌘ ⇧ M | +| Toggle ordered list | Ctrl ⇧ 7 | Ctrl ⇧ 7 | ⌘ ⇧ 7 | +| Toggle outline list | Ctrl ⇧ O | Ctrl ⇧ O | ⌘ ⇧ O | +| Toggle outline list expand | Ctrl Space | Ctrl Space | ⌘ Space | +| Open search | Ctrl F | Ctrl F | ⌘ F | +| Toggle strike | Ctrl ⇧ S | Ctrl ⇧ S | ⌘ ⇧ S | +| Toggle subscript | Ctrl , | Ctrl , | ⌘ , | +| Toggle superscript | Ctrl . | Ctrl . | ⌘ . | +| Toggle task list | Ctrl ⇧ T | Ctrl ⇧ T | ⌘ ⇧ T | +| Text align center | Ctrl ⇧ E | Ctrl ⇧ E | ⌘ ⇧ E | +| Text align justify | Ctrl ⇧ J | Ctrl ⇧ J | ⌘ ⇧ J | +| Text align left | Ctrl ⇧ L | Ctrl ⇧ L | ⌘ ⇧ L | +| Text align right | Ctrl ⇧ R | Ctrl ⇧ R | ⌘ ⇧ R | +| Underline | Ctrl u | Ctrl u | ⌘ u | \ No newline at end of file diff --git a/docs/help/scripts/document-keyboard-shortcuts.mjs b/docs/help/scripts/document-keyboard-shortcuts.mjs index 81abbe043..445957cf0 100644 --- a/docs/help/scripts/document-keyboard-shortcuts.mjs +++ b/docs/help/scripts/document-keyboard-shortcuts.mjs @@ -45,21 +45,24 @@ function getGroupedTableKeybindingsMarkdown() { if (!mergedShortcuts[description]) { mergedShortcuts[description] = {}; } - mergedShortcuts[description].web = keys.map(formatKey); + mergedShortcuts[description].web = keys; }); desktopShortcuts.forEach(({ description, keys }) => { if (!mergedShortcuts[description]) { mergedShortcuts[description] = {}; } - mergedShortcuts[description].desktop = keys.map(formatKey); + mergedShortcuts[description].desktop = keys; }); const rows = Object.entries(mergedShortcuts) .map(([description, { web, desktop }]) => { - const webKeys = web?.join(" / ") || "-"; - const windowsLinuxKeys = desktop?.join(" / ") || "-"; + const webKeys = web?.map(formatKey).join(" / ") || "-"; + const windowsLinuxKeys = desktop?.map(formatKey).join(" / ") || "-"; const macKeys = - desktop?.map(macify).map(formatKey).join(" / ") || "-"; + desktop + ?.map(macify) + .map((k) => formatKey(k, true)) + .join(" / ") || "-"; return `| ${description} | ${webKeys} | ${windowsLinuxKeys} | ${macKeys} |`; }) diff --git a/packages/common/src/utils/keybindings.ts b/packages/common/src/utils/keybindings.ts index a9f29f72f..72362a5d0 100644 --- a/packages/common/src/utils/keybindings.ts +++ b/packages/common/src/utils/keybindings.ts @@ -410,14 +410,14 @@ export function macify(key: string) { .replace(/mod/gi, "Command"); } -export function formatKey(key: string) { +export function formatKey(key: string, isMac = false) { return key .replace(/\+|-/g, " ") - .replace(/\bcommand\b/gi, "Command") - .replace(/\bctrl\b/gi, "Ctrl") - .replace(/\bshift\b/gi, "Shift") - .replace(/\balt\b/gi, "Alt") - .replace(/\bmod\b/gi, "Ctrl") + .replace(/\bcommand\b/gi, isMac ? "⌘" : "Command") + .replace(/\bctrl\b/gi, isMac ? "⌘" : "Ctrl") + .replace(/\bshift\b/gi, "⇧") + .replace(/\balt\b/gi, isMac ? "⌥" : "Alt") + .replace(/\bmod\b/gi, isMac ? "⌘" : "Ctrl") .trim(); }