@atlaskit/editor-plugin-selection-toolbar
Version:
@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core
64 lines (63 loc) • 2.04 kB
JavaScript
import React from 'react';
import { OVERFLOW_MENU, OVERFLOW_MENU_RANK, PIN_BUTTON, PIN_GROUP, PIN_MENU_ITEM, PIN_MENU_SECTION, PIN_MENU_SECTION_RANK, PIN_GROUP_RANK, PIN_SECTION, PIN_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
import { MenuSection } from './MenuSection';
import { PinButton } from './PinButton';
import { PinMenuItem } from './PinMenuItem';
export var getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled, disablePin) {
var components = [{
type: PIN_MENU_SECTION.type,
key: PIN_MENU_SECTION.key,
parents: [{
type: OVERFLOW_MENU.type,
key: OVERFLOW_MENU.key,
rank: OVERFLOW_MENU_RANK[PIN_MENU_SECTION.key]
}],
component: function component(_ref) {
var children = _ref.children;
return /*#__PURE__*/React.createElement(MenuSection, {
api: api
}, children);
}
}, {
type: PIN_MENU_ITEM.type,
key: PIN_MENU_ITEM.key,
parents: [{
type: PIN_MENU_SECTION.type,
key: PIN_MENU_SECTION.key,
rank: PIN_MENU_SECTION_RANK[PIN_MENU_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(PinMenuItem, {
api: api,
disablePin: disablePin
});
}
}];
// Add pin button to primary toolbar when contextual formatting is enabled
if (contextualFormattingEnabled) {
var pinButtonComponents = [{
type: PIN_GROUP.type,
key: PIN_GROUP.key,
parents: [{
type: PIN_SECTION.type,
key: PIN_SECTION.key,
rank: PIN_SECTION_RANK[PIN_GROUP.key]
}]
}, {
type: PIN_BUTTON.type,
key: PIN_BUTTON.key,
parents: [{
type: PIN_GROUP.type,
key: PIN_GROUP.key,
rank: PIN_GROUP_RANK[PIN_BUTTON.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(PinButton, {
api: api
});
}
}];
components.push.apply(components, pinButtonComponents);
}
return components;
};