Merge pull request #363 from Pranav4399/master

Fix: Added seperate shortcut keys for Windows and Mac.
This commit is contained in:
Chi Zhang 2022-09-03 16:14:08 +08:00 committed by GitHub
commit 50f404c60f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -12,13 +12,20 @@ export const INLINE_MENU_UI_TYPES = {
} as const; } as const;
/** inline menu item { key : display-name } */ /** inline menu item { key : display-name } */
export const inlineMenuShortcuts = { export const MacInlineMenuShortcuts = {
textBold: '⌘+B', textBold: '⌘+B',
textItalic: '⌘+I', textItalic: '⌘+I',
textStrikethrough: '⌘+S', textStrikethrough: '⌘+S',
link: '⌘+K', link: '⌘+K',
[Protocol.Block.Type.code]: '⌘+E', [Protocol.Block.Type.code]: '⌘+E',
}; };
export const WinInlineMenuShortcuts = {
textBold: 'Ctrl+B',
textItalic: 'Ctrl+I',
textStrikethrough: 'Ctrl+S',
link: 'Ctrl+K',
[Protocol.Block.Type.code]: 'Ctrl+E',
};
export const inlineMenuNames = { export const inlineMenuNames = {
currentText: 'TEXT SIZE', currentText: 'TEXT SIZE',
[Protocol.Block.Type.heading1]: 'Heading 1', [Protocol.Block.Type.heading1]: 'Heading 1',

View File

@ -12,10 +12,12 @@ import {
} from '@toeverything/components/common'; } from '@toeverything/components/common';
import { ArrowDropDownIcon } from '@toeverything/components/icons'; import { ArrowDropDownIcon } from '@toeverything/components/icons';
import type { DropdownItemType, WithEditorSelectionType } from '../types'; import type { DropdownItemType, WithEditorSelectionType } from '../types';
import { uaHelper } from '@toeverything/utils';
import { import {
inlineMenuNamesKeys, inlineMenuNamesKeys,
inlineMenuNamesForFontColor, inlineMenuNamesForFontColor,
inlineMenuShortcuts, MacInlineMenuShortcuts,
WinInlineMenuShortcuts
} from '../config'; } from '../config';
type MenuDropdownItemProps = DropdownItemType & WithEditorSelectionType; type MenuDropdownItemProps = DropdownItemType & WithEditorSelectionType;
@ -37,7 +39,7 @@ export const MenuDropdownItem = ({
}, []); }, []);
//@ts-ignore //@ts-ignore
const shortcut = inlineMenuShortcuts[nameKey]; const shortcut = uaHelper.isMacOs ? MacInlineMenuShortcuts[nameKey] : WinInlineMenuShortcuts[nameKey];
return ( return (
<> <>

View File

@ -2,8 +2,9 @@ import React, { useCallback } from 'react';
import style9 from 'style9'; import style9 from 'style9';
import type { IconItemType, WithEditorSelectionType } from '../types'; import type { IconItemType, WithEditorSelectionType } from '../types';
import { inlineMenuNamesKeys, inlineMenuShortcuts } from '../config'; import { inlineMenuNamesKeys, MacInlineMenuShortcuts, WinInlineMenuShortcuts } from '../config';
import { Tooltip } from '@toeverything/components/ui'; import { Tooltip } from '@toeverything/components/ui';
import { uaHelper } from '@toeverything/utils';
type MenuIconItemProps = IconItemType & WithEditorSelectionType; type MenuIconItemProps = IconItemType & WithEditorSelectionType;
export const MenuIconItem = ({ export const MenuIconItem = ({
@ -35,7 +36,7 @@ export const MenuIconItem = ({
); );
//@ts-ignore //@ts-ignore
const shortcut = inlineMenuShortcuts[nameKey]; const shortcut = uaHelper.isMacOs ? MacInlineMenuShortcuts[nameKey] : WinInlineMenuShortcuts[nameKey];
return ( return (
<Tooltip <Tooltip