-import { isBrowser } from "@utils/browser";
+import { isBrowser, platform } from "@utils/browser";
import { numToSI, randomStr } from "@utils/helpers";
import autosize from "autosize";
import classNames from "classnames";
import { Icon, Spinner } from "./icon";
import { LanguageSelect } from "./language-select";
import ProgressBar from "./progress-bar";
-
interface MarkdownTextAreaProps {
/**
* Initial content inside the textarea
// Keybind handler
// Keybinds inspired by github comment area
handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) {
- if (event.ctrlKey || event.metaKey) {
+ if (platform.isMac() ? event.metaKey : event.ctrlKey) {
switch (event.key) {
case "k": {
i.handleInsertLink(i, event);
import isBrowser from "./is-browser";
import isDark from "./is-dark";
import loadCss from "./load-css";
+import platform from "./platform";
import restoreScrollPosition from "./restore-scroll-position";
import saveScrollPosition from "./save-scroll-position";
import setAuthCookie from "./set-auth-cookie";
isBrowser,
isDark,
loadCss,
+ platform,
restoreScrollPosition,
saveScrollPosition,
setAuthCookie,
--- /dev/null
+import { isBrowser } from "@utils/browser";
+
+const platformString = () =>
+ navigator.platform?.match(/mac|win|linux/i)?.[0].toLowerCase();
+const getPlatformPredicate = (platform: string) => () =>
+ isBrowser() && platformString() === platform;
+const isWin = getPlatformPredicate("win");
+const isMac = getPlatformPredicate("mac");
+const isLinux = getPlatformPredicate("linux");
+
+const platform = { isWin, isMac, isLinux };
+
+export default platform;