@atlaskit/editor-plugin-selection-toolbar
Version:
@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core
72 lines (70 loc) • 2.41 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getToolbarComponents = void 0;
var _react = _interopRequireDefault(require("react"));
var _keys = require("@atlaskit/editor-common/toolbar/keys");
var _rank = require("@atlaskit/editor-common/toolbar/rank");
var _MenuSection = require("./MenuSection");
var _PinButton = require("./PinButton");
var _PinMenuItem = require("./PinMenuItem");
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled, disablePin) {
var components = [{
type: _keys.PIN_MENU_SECTION.type,
key: _keys.PIN_MENU_SECTION.key,
parents: [{
type: _keys.OVERFLOW_MENU.type,
key: _keys.OVERFLOW_MENU.key,
rank: _rank.OVERFLOW_MENU_RANK[_keys.PIN_MENU_SECTION.key]
}],
component: function component(_ref) {
var children = _ref.children;
return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
api: api
}, children);
}
}, {
type: _keys.PIN_MENU_ITEM.type,
key: _keys.PIN_MENU_ITEM.key,
parents: [{
type: _keys.PIN_MENU_SECTION.type,
key: _keys.PIN_MENU_SECTION.key,
rank: _rank.PIN_MENU_SECTION_RANK[_keys.PIN_MENU_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/_react.default.createElement(_PinMenuItem.PinMenuItem, {
api: api,
disablePin: disablePin
});
}
}];
// Add pin button to primary toolbar when contextual formatting is enabled
if (contextualFormattingEnabled) {
var pinButtonComponents = [{
type: _keys.PIN_GROUP.type,
key: _keys.PIN_GROUP.key,
parents: [{
type: _keys.PIN_SECTION.type,
key: _keys.PIN_SECTION.key,
rank: _rank.PIN_SECTION_RANK[_keys.PIN_GROUP.key]
}]
}, {
type: _keys.PIN_BUTTON.type,
key: _keys.PIN_BUTTON.key,
parents: [{
type: _keys.PIN_GROUP.type,
key: _keys.PIN_GROUP.key,
rank: _rank.PIN_GROUP_RANK[_keys.PIN_BUTTON.key]
}],
component: function component() {
return /*#__PURE__*/_react.default.createElement(_PinButton.PinButton, {
api: api
});
}
}];
components.push.apply(components, pinButtonComponents);
}
return components;
};