UNPKG

@gechiui/block-editor

Version:
48 lines (46 loc) 1.48 kB
import { createElement } from "@gechiui/element"; /** * GeChiUI dependencies */ import { Button } from '@gechiui/components'; import { formatStrikethrough, formatUnderline } from '@gechiui/icons'; import { __ } from '@gechiui/i18n'; const TEXT_DECORATIONS = [{ name: __('下划线'), value: 'underline', icon: formatUnderline }, { name: __('删除线'), value: 'line-through', icon: formatStrikethrough }]; /** * Control to facilitate text decoration selections. * * @param {Object} props Component props. * @param {string} props.value Currently selected text decoration. * @param {Function} props.onChange Handles change in text decoration selection. * * @return {GCElement} Text decoration control. */ export default function TextDecorationControl(_ref) { let { value, onChange } = _ref; return createElement("fieldset", { className: "block-editor-text-decoration-control" }, createElement("legend", null, __('装饰')), createElement("div", { className: "block-editor-text-decoration-control__buttons" }, TEXT_DECORATIONS.map(textDecoration => { return createElement(Button, { key: textDecoration.value, icon: textDecoration.icon, isSmall: true, isPressed: textDecoration.value === value, onClick: () => onChange(textDecoration.value === value ? undefined : textDecoration.value), "aria-label": textDecoration.name }); }))); } //# sourceMappingURL=index.js.map