This commit is contained in:
DarkSky
2022-09-05 23:32:24 +08:00
parent e52ee910c3
commit 9c619ea22f
2 changed files with 110 additions and 104 deletions

View File

@@ -1,24 +1,24 @@
import React, { useState, useCallback } from 'react';
import style9 from 'style9';
import {
Popover,
styled,
type SvgIconProps,
Tooltip,
} from '@toeverything/components/ui';
import { import {
fontBgColorPalette, fontBgColorPalette,
fontColorPalette, fontColorPalette,
} 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 { uaHelper } from '@toeverything/utils';
import { import {
inlineMenuNamesKeys, Popover,
styled,
Tooltip,
type SvgIconProps,
} from '@toeverything/components/ui';
import { uaHelper } from '@toeverything/utils';
import { useCallback, useState } from 'react';
import style9 from 'style9';
import {
inlineMenuNamesForFontColor, inlineMenuNamesForFontColor,
inlineMenuNamesKeys,
MacInlineMenuShortcuts, MacInlineMenuShortcuts,
WinInlineMenuShortcuts WinInlineMenuShortcuts,
} from '../config'; } from '../config';
import type { DropdownItemType, WithEditorSelectionType } from '../types';
type MenuDropdownItemProps = DropdownItemType & WithEditorSelectionType; type MenuDropdownItemProps = DropdownItemType & WithEditorSelectionType;
@@ -38,11 +38,13 @@ export const MenuDropdownItem = ({
set_anchor_ele(null); set_anchor_ele(null);
}, []); }, []);
//@ts-ignore const shortcut = uaHelper.isMacOs
const shortcut = uaHelper.isMacOs ? MacInlineMenuShortcuts[nameKey] : WinInlineMenuShortcuts[nameKey]; ? //@ts-ignore
MacInlineMenuShortcuts[nameKey]
: //@ts-ignore
WinInlineMenuShortcuts[nameKey];
return ( return (
<>
<Popover <Popover
trigger="click" trigger="click"
placement="bottom-start" placement="bottom-start"
@@ -71,8 +73,7 @@ export const MenuDropdownItem = ({
editor, editor,
type: itemNameKey, type: itemNameKey,
anchorNodeId: anchorNodeId:
selectionInfo?.anchorNode selectionInfo?.anchorNode?.id,
?.id,
}); });
} }
handle_close_dropdown_menu(); handle_close_dropdown_menu();
@@ -103,9 +104,7 @@ export const MenuDropdownItem = ({
// } // }
/> />
{/* <ItemIcon sx={{ width: 20, height: 20 }} /> */} {/* <ItemIcon sx={{ width: 20, height: 20 }} /> */}
<span <span className={styles('dropdownItemItext')}>
className={styles('dropdownItemItext')}
>
{name} {name}
</span> </span>
</button> </button>
@@ -133,7 +132,6 @@ export const MenuDropdownItem = ({
</button> </button>
</Tooltip> </Tooltip>
</Popover> </Popover>
</>
); );
}; };

View File

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