UNPKG

@atlaskit/editor-plugin-loom

Version:

Loom plugin for @atlaskit/editor-core

54 lines (53 loc) 2.93 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.getToolbarComponents = void 0; var _react = _interopRequireDefault(require("react")); var _toolbar = require("@atlaskit/editor-common/toolbar"); var _LoomMenuItem = require("./LoomMenuItem"); var _MenuSection = require("./MenuSection"); var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(config, api) { return [{ type: _toolbar.LOOM_MENU_SECTION.type, key: _toolbar.LOOM_MENU_SECTION.key, parents: [{ type: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR.type, key: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR.key, rank: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK[_toolbar.LOOM_MENU_SECTION.key] }], component: function component(_ref) { var children = _ref.children; return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, { api: api }, children); } }, { type: _toolbar.LOOM_MENU_ITEM.type, key: _toolbar.LOOM_MENU_ITEM.key, parents: [{ type: _toolbar.LOOM_MENU_SECTION.type, key: _toolbar.LOOM_MENU_SECTION.key, rank: _toolbar.LOOM_MENU_SECTION_RANK[_toolbar.LOOM_MENU_ITEM.key] }, { type: _toolbar.OVERFLOW_EXTENSIONS_MENU_SECTION.type, key: _toolbar.OVERFLOW_EXTENSIONS_MENU_SECTION.key, rank: _toolbar.OVERFLOW_EXTENSIONS_MENU_SECTION_RANK[_toolbar.LOOM_MENU_ITEM.key] }], component: function component() { return /*#__PURE__*/_react.default.createElement(_LoomMenuItem.LoomMenuItem, { api: api, renderButton: config.renderButton }); }, isHidden: function isHidden() { var _api$loom, _api$editorViewMode$s, _api$editorViewMode, _config$shouldRenderB, _config$shouldRenderB2; var loomState = api === null || api === void 0 || (_api$loom = api.loom) === null || _api$loom === void 0 ? void 0 : _api$loom.sharedState.currentState(); var editorViewMode = (_api$editorViewMode$s = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) !== null && _api$editorViewMode$s !== void 0 ? _api$editorViewMode$s : 'edit'; // if shouldRenderButton is not provided, default to true var shouldRenderButton = (_config$shouldRenderB = config === null || config === void 0 || (_config$shouldRenderB2 = config.shouldRenderButton) === null || _config$shouldRenderB2 === void 0 ? void 0 : _config$shouldRenderB2.call(config)) !== null && _config$shouldRenderB !== void 0 ? _config$shouldRenderB : true; return 'renderButton' in config && shouldRenderButton === false || (loomState === null || loomState === void 0 ? void 0 : loomState.isEnabled) === undefined || editorViewMode !== 'edit'; } }]; };