UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

65 lines 2.78 kB
import React from 'react'; import { cardMessages as messages } from '@atlaskit/editor-common/messages'; import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher'; import { ASSETS_MENU_ITEM, DATA_AND_CHARTS_SECTION, JIRA_WORK_ITEMS_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys'; import { DATA_AND_CHARTS_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank'; import { canRenderDatasource } from '@atlaskit/editor-common/utils'; import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/assets-modal'; import { fg } from '@atlaskit/platform-feature-flags/fg'; import { DatasourceQuickInsertMenuItem } from './DatasourceQuickInsertMenuItem'; export var getCardQuickInsertComponents = function getCardQuickInsertComponents(_ref) { var api = _ref.api, options = _ref.options; if (!options.allowDatasource) { return []; } var components = [{ key: JIRA_WORK_ITEMS_MENU_ITEM.key, type: JIRA_WORK_ITEMS_MENU_ITEM.type, parents: [{ key: DATA_AND_CHARTS_SECTION.key, type: DATA_AND_CHARTS_SECTION.type, rank: DATA_AND_CHARTS_SECTION_RANK[JIRA_WORK_ITEMS_MENU_ITEM.key] }], match: createQuickInsertMatcher(function (_ref2) { var formatMessage = _ref2.formatMessage; return { description: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueDescriptionIssueTermRefresh : messages.datasourceJiraIssueDescription), keywords: ['jira'], title: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue) }; }), component: function component() { return /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, { api: api, type: "jira" }); } }]; if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) { components.push({ key: ASSETS_MENU_ITEM.key, type: ASSETS_MENU_ITEM.type, parents: [{ key: DATA_AND_CHARTS_SECTION.key, type: DATA_AND_CHARTS_SECTION.type, rank: DATA_AND_CHARTS_SECTION_RANK[ASSETS_MENU_ITEM.key] }], match: createQuickInsertMatcher(function (_ref3) { var formatMessage = _ref3.formatMessage; return { description: formatMessage(messages.datasourceAssetsObjectsDescription), keywords: ['assets'], title: formatMessage(messages.datasourceAssetsObjectsGeneralAvailability) }; }), component: function component() { return /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, { api: api, type: "assets" }); } }); } return components; };