UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

45 lines 1.01 kB
import { cardMessages as messages } from '../messages'; import { IconCard } from './ui/assets/card'; import { IconEmbed } from './ui/assets/embed'; import { IconInline } from './ui/assets/inline'; import { IconUrl } from './ui/assets/url'; const appearancePropsMap = { url: { title: messages.urlTitle, icon: IconUrl }, inline: { title: messages.inlineTitle, icon: IconInline }, block: { title: messages.blockTitle, icon: IconCard }, embed: { title: messages.embedTitle, icon: IconEmbed } }; export const getButtonGroupOption = (intl, dispatchCommand, { disabled, onClick, selected, appearance, testId, tooltip }) => { const { title, icon } = appearancePropsMap[appearance !== null && appearance !== void 0 ? appearance : 'url']; return { title: intl.formatMessage(title), icon, onClick: () => dispatchCommand(onClick), disabled: Boolean(disabled), tooltipContent: tooltip || null, testId, selected }; };