UNPKG

@atlaskit/editor-plugin-text-formatting

Version:

Text-formatting plugin for @atlaskit/editor-core

112 lines 3.43 kB
import React from 'react'; import { TEXT_FORMATTING_GROUP, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMATTING_GROUP_COLLAPSED, TEXT_FORMATTING_HERO_BUTTON_COLLAPSED, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_GROUP_COLLAPSED_RANK, 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 TextFormattingGroup = ({ children }) => { const { editorAppearance } = useEditorToolbar(); if (editorAppearance === 'full-page') { return /*#__PURE__*/React.createElement(Show, { above: "xl" }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)); } }; const TextFormattingGroupCollapsed = ({ children }) => { const { editorAppearance } = useEditorToolbar(); if (editorAppearance === 'full-page') { return /*#__PURE__*/React.createElement(Show, { below: "xl" }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)); } return /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children); }; export const textFormattingGroupForPrimaryToolbar = api => [{ type: TEXT_FORMATTING_GROUP.type, key: TEXT_FORMATTING_GROUP.key, parents: [{ type: TEXT_SECTION_PRIMARY_TOOLBAR.type, key: TEXT_SECTION_PRIMARY_TOOLBAR.key, rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key] }], component: ({ children }) => { return /*#__PURE__*/React.createElement(TextFormattingGroup, null, children); } }, { type: TEXT_FORMATTING_GROUP_COLLAPSED.type, key: TEXT_FORMATTING_GROUP_COLLAPSED.key, parents: [{ type: TEXT_SECTION_PRIMARY_TOOLBAR.type, key: TEXT_SECTION_PRIMARY_TOOLBAR.key, rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key] }], component: ({ children }) => { return /*#__PURE__*/React.createElement(TextFormattingGroupCollapsed, null, children); } }, { type: TEXT_FORMATTING_HERO_BUTTON.type, key: TEXT_FORMATTING_HERO_BUTTON.key, parents: [{ type: TEXT_FORMATTING_GROUP.type, key: TEXT_FORMATTING_GROUP.key, rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key] }], component: ({ parents }) => { const { icon, command, shortcut, title } = formatOptions().em; return /*#__PURE__*/React.createElement(FormatButton, { api: api, parents: parents, icon: icon, title: title, shortcut: shortcut, optionType: FormatOptions.em, toggleMarkWithAnalyticsCallback: command }); } }, { type: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.type, key: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key, parents: [{ type: TEXT_FORMATTING_GROUP_COLLAPSED.type, key: TEXT_FORMATTING_GROUP_COLLAPSED.key, rank: TEXT_FORMAT_GROUP_COLLAPSED_RANK[TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key] }], 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 }); } }];