Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Show correct meta key on Linux/macOS in hotkeys modal
Merged rudolfs opened 2 years ago
3 files changed +13 -5 c3626ea5 b5977588
modified src/components/ExtendedTextarea.svelte
@@ -220,7 +220,7 @@
          </label>
          or pasting them.
        {/if}
-
        Markdown supported. Press {utils.isMac() ? "⌘" : "ctrl"}↵ to submit.
+
        Markdown supported. Press {utils.modifierKey()}↵ to submit.
      </div>
    {/if}
    <div class="buttons">
modified 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);
modified src/modals/HotkeysModal.svelte
@@ -1,4 +1,6 @@
<script lang="ts">
+
  import { modifierKey } from "@app/lib/utils";
+

  import Icon from "@app/components/Icon.svelte";
  import IconSmall from "@app/components/IconSmall.svelte";
  import KeyHint from "@app/components/KeyHint.svelte";
@@ -39,7 +41,7 @@
      <div class="pair">
        <span>Post comment</span>
        <div class="keys">
-
          <KeyHint>⌘</KeyHint> +
+
          <KeyHint>{modifierKey()}</KeyHint> +
          <KeyHint>⏎</KeyHint>
        </div>
      </div>