fix: ctrl+a does not work on Windows in code block (#5692)
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
BrowserIcon,
|
||||
} from "outline-icons";
|
||||
import * as React from "react";
|
||||
import { isMac } from "@shared/utils/browser";
|
||||
import {
|
||||
developersUrl,
|
||||
changelogUrl,
|
||||
@@ -26,7 +27,6 @@ import KeyboardShortcuts from "~/scenes/KeyboardShortcuts";
|
||||
import { createAction } from "~/actions";
|
||||
import { NavigationSection, RecentSearchesSection } from "~/actions/sections";
|
||||
import Desktop from "~/utils/Desktop";
|
||||
import { isMac } from "~/utils/browser";
|
||||
import history from "~/utils/history";
|
||||
import isCloudHosted from "~/utils/isCloudHosted";
|
||||
import {
|
||||
|
||||
@@ -6,6 +6,7 @@ import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { depths, s } from "@shared/styles";
|
||||
import { supportsPassiveListener } from "@shared/utils/browser";
|
||||
import Button from "~/components/Button";
|
||||
import Fade from "~/components/Fade";
|
||||
import Flex from "~/components/Flex";
|
||||
@@ -14,7 +15,6 @@ import useMobile from "~/hooks/useMobile";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { draggableOnDesktop, fadeOnDesktopBackgrounded } from "~/styles";
|
||||
import Desktop from "~/utils/Desktop";
|
||||
import { supportsPassiveListener } from "~/utils/browser";
|
||||
|
||||
type Props = {
|
||||
left?: React.ReactNode;
|
||||
|
||||
@@ -3,12 +3,12 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
import { isMac } from "@shared/utils/browser";
|
||||
import Flex from "~/components/Flex";
|
||||
import NudeButton from "~/components/NudeButton";
|
||||
import Tooltip from "~/components/Tooltip";
|
||||
import useKeyDown from "~/hooks/useKeyDown";
|
||||
import Desktop from "~/utils/Desktop";
|
||||
import { isMac } from "~/utils/browser";
|
||||
|
||||
function HistoryNavigation(props: React.ComponentProps<typeof Flex>) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// maintained.
|
||||
import throttle from "lodash/throttle";
|
||||
import { useState, useEffect } from "react";
|
||||
import { supportsPassiveListener } from "~/utils/browser";
|
||||
import { supportsPassiveListener } from "@shared/utils/browser";
|
||||
|
||||
const getPosition = () => ({
|
||||
x: window.pageXOffset,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useHistory } from "react-router-dom";
|
||||
import { IndexeddbPersistence } from "y-indexeddb";
|
||||
import * as Y from "yjs";
|
||||
import MultiplayerExtension from "@shared/editor/extensions/Multiplayer";
|
||||
import { supportsPassiveListener } from "@shared/utils/browser";
|
||||
import Editor, { Props as EditorProps } from "~/components/Editor";
|
||||
import env from "~/env";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
@@ -16,7 +17,6 @@ import useStores from "~/hooks/useStores";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
import { AwarenessChangeEvent } from "~/types";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { supportsPassiveListener } from "~/utils/browser";
|
||||
import { homePath } from "~/utils/routeHelpers";
|
||||
|
||||
type Props = EditorProps & {
|
||||
|
||||
@@ -2,10 +2,10 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
import { isMac } from "@shared/utils/browser";
|
||||
import Flex from "~/components/Flex";
|
||||
import InputSearch from "~/components/InputSearch";
|
||||
import Key from "~/components/Key";
|
||||
import { isMac } from "~/utils/browser";
|
||||
import { metaDisplay, altDisplay } from "~/utils/keyboard";
|
||||
|
||||
function KeyboardShortcuts() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isTouchDevice } from "@shared/utils/browser";
|
||||
import Desktop from "~/utils/Desktop";
|
||||
import { isTouchDevice } from "~/utils/browser";
|
||||
|
||||
/**
|
||||
* Returns "hover" on a non-touch device and "active" on a touch device. To
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isMac, isWindows } from "./browser";
|
||||
import { isMac, isWindows } from "@shared/utils/browser";
|
||||
|
||||
export default class Desktop {
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isMac } from "~/utils/browser";
|
||||
import { isMac } from "@shared/utils/browser";
|
||||
|
||||
export const altDisplay = isMac() ? "⌥" : "Alt";
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
const SSR = typeof window === "undefined";
|
||||
const isMac = !SSR && window.navigator.platform === "MacIntel";
|
||||
|
||||
export default function isModKey(event: KeyboardEvent | MouseEvent): boolean {
|
||||
return isMac ? event.metaKey : event.ctrlKey;
|
||||
}
|
||||
@@ -58,6 +58,7 @@ import { Primitive } from "utility-types";
|
||||
import { Dictionary } from "~/hooks/useDictionary";
|
||||
import { UserPreferences } from "../../types";
|
||||
import Storage from "../../utils/Storage";
|
||||
import { isMac } from "../../utils/browser";
|
||||
import {
|
||||
newlineInCode,
|
||||
insertSpaceTab,
|
||||
@@ -208,14 +209,22 @@ export default class CodeFence extends Node {
|
||||
}
|
||||
|
||||
keys({ type, schema }: { type: NodeType; schema: Schema }) {
|
||||
return {
|
||||
const output = {
|
||||
"Shift-Ctrl-\\": toggleBlockType(type, schema.nodes.paragraph),
|
||||
Tab: insertSpaceTab,
|
||||
Enter: newlineInCode,
|
||||
"Shift-Enter": newlineInCode,
|
||||
"Ctrl-a": moveToPreviousNewline,
|
||||
"Ctrl-e": moveToNextNewline,
|
||||
};
|
||||
|
||||
if (isMac()) {
|
||||
return {
|
||||
...output,
|
||||
"Ctrl-a": moveToPreviousNewline,
|
||||
"Ctrl-e": moveToNextNewline,
|
||||
};
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
get plugins() {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
const SSR = typeof window === "undefined";
|
||||
|
||||
/**
|
||||
* Returns true if the client is a touch device.
|
||||
*/
|
||||
export function isTouchDevice(): boolean {
|
||||
if (typeof window === "undefined") {
|
||||
if (SSR) {
|
||||
return false;
|
||||
}
|
||||
return window.matchMedia?.("(hover: none) and (pointer: coarse)")?.matches;
|
||||
@@ -12,6 +14,9 @@ export function isTouchDevice(): boolean {
|
||||
* Returns true if the client is running on a Mac.
|
||||
*/
|
||||
export function isMac(): boolean {
|
||||
if (SSR) {
|
||||
return false;
|
||||
}
|
||||
return window.navigator.platform === "MacIntel";
|
||||
}
|
||||
|
||||
@@ -19,6 +24,9 @@ export function isMac(): boolean {
|
||||
* Returns true if the client is running on Windows.
|
||||
*/
|
||||
export function isWindows(): boolean {
|
||||
if (SSR) {
|
||||
return false;
|
||||
}
|
||||
return window.navigator.platform === "Win32";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user