@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
106 lines • 4.81 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import { messages } from '@atlaskit/editor-common/messages/card';
import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
import { ASSETS_MENU_ITEM, CONFLUENCE_LIST_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/datasource';
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/assets-modal';
import { CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource/confluence-search-modal';
import { fg } from '@atlaskit/platform-feature-flags/fg';
import { isDatasourceConfigEditable } from '../../pm-plugins/utils';
import { DatasourceQuickInsertMenuItem } from './DatasourceQuickInsertMenuItem';
var datasourcePreviewImageUrlsByKey = _defineProperty(_defineProperty(_defineProperty({}, JIRA_WORK_ITEMS_MENU_ITEM.key, {
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVIM.png',
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVLA.png'
}), CONFLUENCE_LIST_MENU_ITEM.key, {
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVIK.png',
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVMD.png'
}), ASSETS_MENU_ITEM.key, {
dark: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVJ2.png',
light: 'https://dam-cdn.atl.orangelogic.com/CDNLink/AT12OVM6.png'
});
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,
previewImageUrls: datasourcePreviewImageUrlsByKey[JIRA_WORK_ITEMS_MENU_ITEM.key],
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,
previewImageUrls: datasourcePreviewImageUrlsByKey[ASSETS_MENU_ITEM.key],
type: "assets"
});
}
});
}
if (isDatasourceConfigEditable(CONFLUENCE_SEARCH_DATASOURCE_ID)) {
components.push({
key: CONFLUENCE_LIST_MENU_ITEM.key,
type: CONFLUENCE_LIST_MENU_ITEM.type,
parents: [{
key: DATA_AND_CHARTS_SECTION.key,
type: DATA_AND_CHARTS_SECTION.type,
rank: DATA_AND_CHARTS_SECTION_RANK[CONFLUENCE_LIST_MENU_ITEM.key]
}],
match: createQuickInsertMatcher(function (_ref4) {
var formatMessage = _ref4.formatMessage;
return {
description: formatMessage(messages.datasourceConfluenceSearchDescription),
keywords: ['confluence'],
title: formatMessage(messages.datasourceConfluenceList)
};
}),
component: function component() {
return /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
api: api,
previewImageUrls: datasourcePreviewImageUrlsByKey[CONFLUENCE_LIST_MENU_ITEM.key],
type: "confluence-search"
});
}
});
}
return components;
};