From b5977588ae0f2338607779602d0017f4cf672f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Tue, 13 Feb 2024 08:14:12 +0000 Subject: [PATCH] Show correct meta key on Linux/macOS in hotkeys modal --- src/components/ExtendedTextarea.svelte | 2 +- src/lib/utils.ts | 12 +++++++++--- src/modals/HotkeysModal.svelte | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/ExtendedTextarea.svelte b/src/components/ExtendedTextarea.svelte index 8dda19fb6..618d6750a 100644 --- a/src/components/ExtendedTextarea.svelte +++ b/src/components/ExtendedTextarea.svelte @@ -220,7 +220,7 @@ or pasting them. {/if} - Markdown supported. Press {utils.isMac() ? "⌘" : "ctrl"}↵ to submit. + Markdown supported. Press {utils.modifierKey()}↵ to submit. {/if}
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5b8c9b8fa..fb83bb13f 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -204,14 +204,20 @@ export function scrollIntoView(id: string, options?: ScrollIntoViewOptions) { } export function isMac() { - // Precaution in case navigator.platform is not available. - if (navigator.platform) { - return navigator.platform.includes("Mac"); + if ( + (navigator.platform && navigator.platform.includes("Mac")) || + navigator.userAgent.includes("OS X") + ) { + return true; } else { return false; } } +export function modifierKey() { + return isMac() ? "⌘" : "ctrl"; +} + // Check whether the given path has a markdown file extension. export function isMarkdownPath(path: string): boolean { return /\.(md|mkd|markdown)$/i.test(path); diff --git a/src/modals/HotkeysModal.svelte b/src/modals/HotkeysModal.svelte index 87cf1d854..6b97ac742 100644 --- a/src/modals/HotkeysModal.svelte +++ b/src/modals/HotkeysModal.svelte @@ -1,4 +1,6 @@