import { css, cx } from '@emotion/css'; import { ReactEditor } from '@src/components/slate-packages/slate-react'; import { f } from '@src/resource/string'; import { min } from 'lodash'; import React from 'react'; import { COLOR_DEFAULT } from '../Components'; import { ColorButton } from './buttons'; import { colorArray, colorChoice, ColorFormat } from './color'; const DEFAULT_COLOR = { FONT: 'rgb(0, 0, 0)', BACKGROUND: 'rgb(255, 255, 255)', }; const getDefaultColor = (colorFormat: ColorFormat) => { return colorFormat === 'fontColor' ? DEFAULT_COLOR.FONT : DEFAULT_COLOR.BACKGROUND; }; export const dropdownMenuColor = (editor: any, colorFormat: ColorFormat, callback: any, curSelectedColor: string) => (
{}
{ event.preventDefault(); event.stopPropagation(); event.nativeEvent.stopImmediatePropagation(); const { selection } = editor; if (selection && ReactEditor.hasRange(editor, selection) && min([selection.anchor.path[0], selection.focus.path[0]]) !== 0) { const defaultColor = getDefaultColor(colorFormat); colorChoice(editor, colorFormat, defaultColor); callback && callback(defaultColor); } }} >
{f('default')}
{colorArray.map((colorItem: string, index: number) => ( ))}
);