import { memo, useMemo, } from 'react' import { useTranslation } from 'react-i18next' import { RiBold, RiItalic, RiLink, RiListUnordered, RiStrikethrough, } from '@remixicon/react' import { useStore } from '../store' import { useCommand } from './hooks' import cn from '@/utils/classnames' import Tooltip from '@/app/components/base/tooltip' type CommandProps = { type: 'bold' | 'italic' | 'strikethrough' | 'link' | 'bullet' } const Command = ({ type, }: CommandProps) => { const { t } = useTranslation() const selectedIsBold = useStore(s => s.selectedIsBold) const selectedIsItalic = useStore(s => s.selectedIsItalic) const selectedIsStrikeThrough = useStore(s => s.selectedIsStrikeThrough) const selectedIsLink = useStore(s => s.selectedIsLink) const selectedIsBullet = useStore(s => s.selectedIsBullet) const { handleCommand } = useCommand() const icon = useMemo(() => { switch (type) { case 'bold': return case 'italic': return case 'strikethrough': return case 'link': return case 'bullet': return } }, [type, selectedIsBold, selectedIsItalic, selectedIsStrikeThrough, selectedIsLink, selectedIsBullet]) const tip = useMemo(() => { switch (type) { case 'bold': return t('workflow.nodes.note.editor.bold') case 'italic': return t('workflow.nodes.note.editor.italic') case 'strikethrough': return t('workflow.nodes.note.editor.strikethrough') case 'link': return t('workflow.nodes.note.editor.link') case 'bullet': return t('workflow.nodes.note.editor.bulletList') } }, [type, t]) return ( handleCommand(type)} > {icon} ) } export default memo(Command)