@atlaskit/editor-plugin-panel
Version:
Panel plugin for @atlaskit/editor-core.
127 lines (126 loc) • 5.33 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPanelQuickInsertComponents = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _react = _interopRequireDefault(require("react"));
var _panel = require("@atlaskit/adf-schema/panel");
var _blockType = require("@atlaskit/editor-common/messages/block-type");
var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
var _pencil = _interopRequireDefault(require("@atlaskit/icon-lab/core/pencil"));
var _statusWorkflowCancelled = _interopRequireDefault(require("@atlaskit/icon-lab/core/status-workflow-cancelled"));
var _warningOutline = _interopRequireDefault(require("@atlaskit/icon-lab/core/warning-outline"));
var _checkCircle = _interopRequireDefault(require("@atlaskit/icon/core/check-circle"));
var _informationCircle = _interopRequireDefault(require("@atlaskit/icon/core/information-circle"));
var _note = _interopRequireDefault(require("@atlaskit/icon/core/note"));
var _PanelQuickInsertMenuItem = require("./PanelQuickInsertMenuItem");
var standardPanelItems = [{
description: _blockType.messages.infoPanelDescription,
icon: _informationCircle.default,
keywords: ['panel'],
menuItem: _keys.INFO_PANEL_MENU_ITEM,
panelType: _panel.PanelType.INFO,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKL.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVHA.png'
},
title: _blockType.messages.infoPanel
}, {
description: _blockType.messages.notePanelDescription,
icon: _note.default,
menuItem: _keys.NOTE_PANEL_MENU_ITEM,
panelType: _panel.PanelType.NOTE,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKJ.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVHB.png'
},
title: _blockType.messages.notePanel
}, {
description: _blockType.messages.successPanelDescription,
icon: _checkCircle.default,
keywords: ['tip'],
menuItem: _keys.SUCCESS_PANEL_MENU_ITEM,
panelType: _panel.PanelType.SUCCESS,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKP.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVH6.png'
},
title: _blockType.messages.successPanel
}, {
description: _blockType.messages.warningPanelDescription,
icon: _warningOutline.default,
menuItem: _keys.WARNING_PANEL_MENU_ITEM,
panelType: _panel.PanelType.WARNING,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKO.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVHC.png'
},
title: _blockType.messages.warningPanel
}, {
description: _blockType.messages.errorPanelDescription,
icon: _statusWorkflowCancelled.default,
menuItem: _keys.ERROR_PANEL_MENU_ITEM,
panelType: _panel.PanelType.ERROR,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKQ.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVH1.png'
},
title: _blockType.messages.errorPanel
}];
var customPanelItem = {
description: _blockType.messages.customPanelDescription,
icon: _pencil.default,
menuItem: _keys.CUSTOM_PANEL_MENU_ITEM,
panelType: _panel.PanelType.CUSTOM,
previewImageUrls: {
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVKN.png',
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVHD.png'
},
title: _blockType.messages.customPanel
};
var getPanelQuickInsertComponents = exports.getPanelQuickInsertComponents = function getPanelQuickInsertComponents(_ref) {
var api = _ref.api,
allowCustomPanel = _ref.allowCustomPanel,
allowCustomPanelEdit = _ref.allowCustomPanelEdit;
var allPanelItems = [].concat(standardPanelItems, (0, _toConsumableArray2.default)(allowCustomPanel && allowCustomPanelEdit ? [customPanelItem] : []));
return allPanelItems.map(function (_ref2) {
var description = _ref2.description,
icon = _ref2.icon,
keywords = _ref2.keywords,
menuItem = _ref2.menuItem,
panelType = _ref2.panelType,
previewImageUrls = _ref2.previewImageUrls,
title = _ref2.title;
return {
key: menuItem.key,
type: menuItem.type,
parents: [{
key: _keys.STRUCTURE_SECTION.key,
type: _keys.STRUCTURE_SECTION.type,
rank: _rank.STRUCTURE_SECTION_RANK[menuItem.key]
}],
match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref3) {
var formatMessage = _ref3.formatMessage;
return {
description: formatMessage(description),
keywords: keywords,
title: formatMessage(title)
};
}),
component: function component() {
return /*#__PURE__*/_react.default.createElement(_PanelQuickInsertMenuItem.PanelQuickInsertMenuItem, {
api: api,
description: description,
icon: icon,
panelType: panelType,
previewImageUrls: previewImageUrls,
title: title
});
}
};
});
};