UNPKG

@atlaskit/editor-plugin-panel

Version:

Panel plugin for @atlaskit/editor-core.

69 lines 2.59 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import React from 'react'; import { PanelType } from '@atlaskit/adf-schema/panel'; import { blockTypeMessages } from '@atlaskit/editor-common/messages'; import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert'; import { CUSTOM_PANEL_MENU_ITEM, ERROR_PANEL_MENU_ITEM, INFO_PANEL_MENU_ITEM, NOTE_PANEL_MENU_ITEM, STRUCTURE_SECTION, SUCCESS_PANEL_MENU_ITEM, WARNING_PANEL_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys'; import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank'; import { PanelQuickInsertMenuItem } from './PanelQuickInsertMenuItem'; var standardPanelItems = [{ icon: IconPanel, menuItem: INFO_PANEL_MENU_ITEM, panelType: PanelType.INFO, title: blockTypeMessages.infoPanel }, { icon: IconPanelNote, menuItem: NOTE_PANEL_MENU_ITEM, panelType: PanelType.NOTE, title: blockTypeMessages.notePanel }, { icon: IconPanelSuccess, menuItem: SUCCESS_PANEL_MENU_ITEM, panelType: PanelType.SUCCESS, title: blockTypeMessages.successPanel }, { icon: IconPanelWarning, menuItem: WARNING_PANEL_MENU_ITEM, panelType: PanelType.WARNING, title: blockTypeMessages.warningPanel }, { icon: IconPanelError, menuItem: ERROR_PANEL_MENU_ITEM, panelType: PanelType.ERROR, title: blockTypeMessages.errorPanel }]; var customPanelItem = { icon: IconCustomPanel, menuItem: CUSTOM_PANEL_MENU_ITEM, panelType: PanelType.CUSTOM, title: blockTypeMessages.customPanel }; export var getPanelQuickInsertComponents = function getPanelQuickInsertComponents(_ref) { var api = _ref.api, allowCustomPanel = _ref.allowCustomPanel, allowCustomPanelEdit = _ref.allowCustomPanelEdit; var allPanelItems = [].concat(standardPanelItems, _toConsumableArray(allowCustomPanel && allowCustomPanelEdit ? [customPanelItem] : [])); return allPanelItems.map(function (_ref2) { var icon = _ref2.icon, menuItem = _ref2.menuItem, panelType = _ref2.panelType, title = _ref2.title; return { key: menuItem.key, type: menuItem.type, parents: [{ key: STRUCTURE_SECTION.key, type: STRUCTURE_SECTION.type, rank: STRUCTURE_SECTION_RANK[menuItem.key] }], component: function component() { return /*#__PURE__*/React.createElement(PanelQuickInsertMenuItem, { api: api, icon: icon, panelType: panelType, title: title }); } }; }); };