Merge branch 'main' into eslint-tweak

This commit is contained in:
SleeplessOne1917 2023-07-28 20:03:39 +00:00 committed by GitHub
commit b1de991176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -1,4 +1,4 @@
import { isBrowser } from "@utils/browser"; import { isBrowser, platform } from "@utils/browser";
import { numToSI, randomStr } from "@utils/helpers"; import { numToSI, randomStr } from "@utils/helpers";
import autosize from "autosize"; import autosize from "autosize";
import classNames from "classnames"; import classNames from "classnames";
@ -21,7 +21,6 @@ import { EmojiPicker } from "./emoji-picker";
import { Icon, Spinner } from "./icon"; import { Icon, Spinner } from "./icon";
import { LanguageSelect } from "./language-select"; import { LanguageSelect } from "./language-select";
import ProgressBar from "./progress-bar"; import ProgressBar from "./progress-bar";
interface MarkdownTextAreaProps { interface MarkdownTextAreaProps {
/** /**
* Initial content inside the textarea * Initial content inside the textarea
@ -477,7 +476,7 @@ export class MarkdownTextArea extends Component<
// Keybind handler // Keybind handler
// Keybinds inspired by github comment area // Keybinds inspired by github comment area
handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) { handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) {
if (event.ctrlKey || event.metaKey) { if (platform.isMac() ? event.metaKey : event.ctrlKey) {
switch (event.key) { switch (event.key) {
case "k": { case "k": {
i.handleInsertLink(i, event); i.handleInsertLink(i, event);

View file

@ -4,6 +4,7 @@ import dataBsTheme from "./data-bs-theme";
import isBrowser from "./is-browser"; import isBrowser from "./is-browser";
import isDark from "./is-dark"; import isDark from "./is-dark";
import loadCss from "./load-css"; import loadCss from "./load-css";
import platform from "./platform";
import restoreScrollPosition from "./restore-scroll-position"; import restoreScrollPosition from "./restore-scroll-position";
import saveScrollPosition from "./save-scroll-position"; import saveScrollPosition from "./save-scroll-position";
import setAuthCookie from "./set-auth-cookie"; import setAuthCookie from "./set-auth-cookie";
@ -16,6 +17,7 @@ export {
isBrowser, isBrowser,
isDark, isDark,
loadCss, loadCss,
platform,
restoreScrollPosition, restoreScrollPosition,
saveScrollPosition, saveScrollPosition,
setAuthCookie, setAuthCookie,

View file

@ -0,0 +1,13 @@
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;