@atlaskit/editor-plugin-text-formatting
Version:
Text-formatting plugin for @atlaskit/editor-core
59 lines • 2.32 kB
JavaScript
import React from 'react';
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar/context';
import { UNDERLINE_BUTTON_GROUP, UNDERLINE_BUTTON, TEXT_SECTION_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar/keys';
import { TEXT_SECTION_PRIMARY_TOOLBAR_RANK } from '@atlaskit/editor-common/toolbar/rank';
import { Show } from '@atlaskit/editor-toolbar/show';
import { ToolbarButtonGroup } from '@atlaskit/editor-toolbar/toolbar-button-group';
import { FormatOptions } from '../types';
import { FormatButton } from './Component';
import { formatOptions } from './utils';
var UnderlineButtonGroup = function UnderlineButtonGroup(_ref) {
var children = _ref.children;
var _useEditorToolbar = useEditorToolbar(),
editorAppearance = _useEditorToolbar.editorAppearance;
if (editorAppearance === 'full-page') {
return /*#__PURE__*/React.createElement(Show, {
above: "xl"
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
}
};
export var underlineButtonGroup = function underlineButtonGroup(api) {
return [{
type: UNDERLINE_BUTTON_GROUP.type,
key: UNDERLINE_BUTTON_GROUP.key,
parents: [{
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[UNDERLINE_BUTTON_GROUP.key]
}],
component: function component(_ref2) {
var children = _ref2.children;
return /*#__PURE__*/React.createElement(UnderlineButtonGroup, null, children);
}
}, {
type: UNDERLINE_BUTTON.type,
key: UNDERLINE_BUTTON.key,
parents: [{
type: UNDERLINE_BUTTON_GROUP.type,
key: UNDERLINE_BUTTON_GROUP.key,
rank: 100
}],
component: function component(_ref3) {
var parents = _ref3.parents;
var _formatOptions$underl = formatOptions().underline,
icon = _formatOptions$underl.icon,
command = _formatOptions$underl.command,
shortcut = _formatOptions$underl.shortcut,
title = _formatOptions$underl.title;
return /*#__PURE__*/React.createElement(FormatButton, {
api: api,
parents: parents,
icon: icon,
title: title,
shortcut: shortcut,
optionType: FormatOptions.underline,
toggleMarkWithAnalyticsCallback: command
});
}
}];
};