@atlaskit/editor-plugin-text-formatting
Version:
Text-formatting plugin for @atlaskit/editor-core
111 lines (110 loc) • 4.69 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.textFormattingGroupForPrimaryToolbar = void 0;
var _react = _interopRequireDefault(require("react"));
var _toolbar = require("@atlaskit/editor-common/toolbar");
var _editorToolbar = require("@atlaskit/editor-toolbar");
var _types = require("../types");
var _Component = require("./Component");
var _utils = require("./utils");
var TextFormattingGroup = function TextFormattingGroup(_ref) {
var children = _ref.children;
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
editorAppearance = _useEditorToolbar.editorAppearance;
if (editorAppearance === 'full-page') {
return /*#__PURE__*/_react.default.createElement(_editorToolbar.Show, {
above: "xl"
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButtonGroup, null, children));
}
};
var TextFormattingGroupCollapsed = function TextFormattingGroupCollapsed(_ref2) {
var children = _ref2.children;
var _useEditorToolbar2 = (0, _toolbar.useEditorToolbar)(),
editorAppearance = _useEditorToolbar2.editorAppearance;
if (editorAppearance === 'full-page') {
return /*#__PURE__*/_react.default.createElement(_editorToolbar.Show, {
below: "xl"
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButtonGroup, null, children));
}
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButtonGroup, null, children);
};
var textFormattingGroupForPrimaryToolbar = exports.textFormattingGroupForPrimaryToolbar = function textFormattingGroupForPrimaryToolbar(api) {
return [{
type: _toolbar.TEXT_FORMATTING_GROUP.type,
key: _toolbar.TEXT_FORMATTING_GROUP.key,
parents: [{
type: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR.type,
key: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR.key,
rank: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR_RANK[_toolbar.TEXT_FORMATTING_GROUP.key]
}],
component: function component(_ref3) {
var children = _ref3.children;
return /*#__PURE__*/_react.default.createElement(TextFormattingGroup, null, children);
}
}, {
type: _toolbar.TEXT_FORMATTING_GROUP_COLLAPSED.type,
key: _toolbar.TEXT_FORMATTING_GROUP_COLLAPSED.key,
parents: [{
type: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR.type,
key: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR.key,
rank: _toolbar.TEXT_SECTION_PRIMARY_TOOLBAR_RANK[_toolbar.TEXT_FORMATTING_GROUP.key]
}],
component: function component(_ref4) {
var children = _ref4.children;
return /*#__PURE__*/_react.default.createElement(TextFormattingGroupCollapsed, null, children);
}
}, {
type: _toolbar.TEXT_FORMATTING_HERO_BUTTON.type,
key: _toolbar.TEXT_FORMATTING_HERO_BUTTON.key,
parents: [{
type: _toolbar.TEXT_FORMATTING_GROUP.type,
key: _toolbar.TEXT_FORMATTING_GROUP.key,
rank: _toolbar.TEXT_FORMAT_GROUP_RANK[_toolbar.TEXT_FORMATTING_HERO_BUTTON.key]
}],
component: function component(_ref5) {
var parents = _ref5.parents;
var _formatOptions$em = (0, _utils.formatOptions)().em,
icon = _formatOptions$em.icon,
command = _formatOptions$em.command,
shortcut = _formatOptions$em.shortcut,
title = _formatOptions$em.title;
return /*#__PURE__*/_react.default.createElement(_Component.FormatButton, {
api: api,
parents: parents,
icon: icon,
title: title,
shortcut: shortcut,
optionType: _types.FormatOptions.em,
toggleMarkWithAnalyticsCallback: command
});
}
}, {
type: _toolbar.TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.type,
key: _toolbar.TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key,
parents: [{
type: _toolbar.TEXT_FORMATTING_GROUP_COLLAPSED.type,
key: _toolbar.TEXT_FORMATTING_GROUP_COLLAPSED.key,
rank: _toolbar.TEXT_FORMAT_GROUP_COLLAPSED_RANK[_toolbar.TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key]
}],
component: function component(_ref6) {
var parents = _ref6.parents;
var _formatOptions$strong = (0, _utils.formatOptions)().strong,
icon = _formatOptions$strong.icon,
command = _formatOptions$strong.command,
shortcut = _formatOptions$strong.shortcut,
title = _formatOptions$strong.title;
return /*#__PURE__*/_react.default.createElement(_Component.FormatButton, {
api: api,
parents: parents,
icon: icon,
title: title,
shortcut: shortcut,
optionType: _types.FormatOptions.strong,
toggleMarkWithAnalyticsCallback: command
});
}
}];
};