UNPKG

@atlaskit/editor-plugin-text-formatting

Version:

Text-formatting plugin for @atlaskit/editor-core

59 lines 1.65 kB
import React from 'react'; import { BOLD_BUTTON_GROUP, BOLD_BUTTON, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar'; import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar'; import { FormatOptions } from '../types'; import { FormatButton } from './Component'; import { formatOptions } from './utils'; const BoldButtonGroup = ({ children }) => { const { editorAppearance } = useEditorToolbar(); if (editorAppearance === 'full-page') { return /*#__PURE__*/React.createElement(Show, { above: "xl" }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)); } }; export const boldButtonGroup = api => [{ type: BOLD_BUTTON_GROUP.type, key: BOLD_BUTTON_GROUP.key, parents: [{ type: TEXT_SECTION_PRIMARY_TOOLBAR.type, key: TEXT_SECTION_PRIMARY_TOOLBAR.key, rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[BOLD_BUTTON_GROUP.key] }], component: ({ children }) => { return /*#__PURE__*/React.createElement(BoldButtonGroup, null, children); } }, { type: BOLD_BUTTON.type, key: BOLD_BUTTON.key, parents: [{ type: BOLD_BUTTON_GROUP.type, key: BOLD_BUTTON_GROUP.key, rank: 100 }], component: ({ parents }) => { const { icon, command, shortcut, title } = formatOptions().strong; return /*#__PURE__*/React.createElement(FormatButton, { api: api, parents: parents, icon: icon, title: title, shortcut: shortcut, optionType: FormatOptions.strong, toggleMarkWithAnalyticsCallback: command }); } }];