UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

60 lines 2.5 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 const getCardQuickInsertComponents = ({ api, options }) => { if (!options.allowDatasource) { return []; } const 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(({ formatMessage }) => ({ 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: () => /*#__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(({ formatMessage }) => ({ description: formatMessage(messages.datasourceAssetsObjectsDescription), keywords: ['assets'], title: formatMessage(messages.datasourceAssetsObjectsGeneralAvailability) })), component: () => /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, { api: api, type: "assets" }) }); } return components; };