UNPKG

@atlaskit/editor-plugin-alignment

Version:

Alignment plugin for @atlaskit/editor-core

78 lines 2.77 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import React from 'react'; import { ALIGNMENT_GROUP, ALIGNMENT_GROUP_RANK, ALIGNMENT_MENU, ALIGNMENT_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, ALIGNMENT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_SECTION_PRIMARY_TOOLBAR_RANK } from '@atlaskit/editor-common/toolbar'; import { AlignmentMenu } from './Toolbar/AlignmentMenu'; import { AlignmentMenuItem } from './Toolbar/AlignmentMenuItem'; import { MenuSection } from './Toolbar/MenuSection'; import { alignmentOptions } from './Toolbar/options'; var getAlignmentMenuItems = function getAlignmentMenuItems(api) { return Object.entries(alignmentOptions()).map(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), alignment = _ref2[0], item = _ref2[1]; var key = item.key, type = item.type, rank = item.rank; return { type: type, key: key, parents: [{ type: ALIGNMENT_MENU_SECTION.type, key: ALIGNMENT_MENU_SECTION.key, rank: rank }], component: function component(_ref3) { var parents = _ref3.parents; return /*#__PURE__*/React.createElement(AlignmentMenuItem, { api: api, option: item, alignment: alignment, parents: parents }); } }; }); }; export var getToolbarComponents = function getToolbarComponents(api) { return [{ type: ALIGNMENT_GROUP.type, key: ALIGNMENT_GROUP.key, parents: [{ type: TEXT_SECTION.type, key: TEXT_SECTION.key, rank: TEXT_SECTION_RANK[ALIGNMENT_GROUP.key] }, { type: TEXT_SECTION_PRIMARY_TOOLBAR.type, key: TEXT_SECTION_PRIMARY_TOOLBAR.key, rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[ALIGNMENT_GROUP.key] }] }, { type: ALIGNMENT_MENU.type, key: ALIGNMENT_MENU.key, parents: [{ type: ALIGNMENT_GROUP.type, key: ALIGNMENT_GROUP.key, rank: ALIGNMENT_GROUP_RANK[ALIGNMENT_MENU.key] }], component: function component(_ref4) { var children = _ref4.children; return /*#__PURE__*/React.createElement(AlignmentMenu, { api: api }, children); } }, { type: ALIGNMENT_MENU_SECTION.type, key: ALIGNMENT_MENU_SECTION.key, parents: [{ type: ALIGNMENT_MENU.type, key: ALIGNMENT_MENU.key, rank: ALIGNMENT_MENU_RANK[ALIGNMENT_MENU_SECTION.key] }, { type: TEXT_COLLAPSED_MENU.type, key: TEXT_COLLAPSED_MENU.key, rank: TEXT_COLLAPSED_MENU_RANK[ALIGNMENT_MENU_SECTION.key] }], component: MenuSection }].concat(_toConsumableArray(getAlignmentMenuItems(api))); };