mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 02:21:49 +03:00
Merge pull request #363 from Pranav4399/master
Fix: Added seperate shortcut keys for Windows and Mac.
This commit is contained in:
commit
50f404c60f
@ -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',
|
||||||
|
@ -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 (
|
||||||
<>
|
<>
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user