@atlaskit/editor-plugin-card 19.0.1 → 19.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 19.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 19.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7087f393ec725`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7087f393ec725) -
14
+ Add the categorized registered Quick Insert browse experience with representative native elements
15
+ - Updated dependencies
16
+
3
17
  ## 19.0.1
4
18
 
5
19
  ### Patch Changes
@@ -16,6 +16,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
16
16
  var _utils = require("@atlaskit/editor-common/utils");
17
17
  var _linkDatasource = require("@atlaskit/link-datasource");
18
18
  var _context3 = require("@atlaskit/link-provider/context");
19
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
19
20
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
21
22
  var _blockCard = require("./nodeviews/toDOM-fixes/blockCard");
@@ -33,6 +34,7 @@ var _EditorLinkingPlatformAnalytics = require("./ui/EditorLinkingPlatformAnalyti
33
34
  var _EditorSmartCardEvents = require("./ui/EditorSmartCardEvents");
34
35
  var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
35
36
  var _PasteDisplayAsMenu = require("./ui/PasteDisplayAsMenu");
37
+ var _getCardQuickInsertComponents = require("./ui/quick-insert/getCardQuickInsertComponents");
36
38
  var _toolbar = require("./ui/toolbar");
37
39
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
38
40
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -55,6 +57,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
55
57
  api = _ref2.api;
56
58
  var previousCardProvider;
57
59
  var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
60
+ var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
58
61
  var instanceEmbedCardTransformers = options.embedCardTransformers;
59
62
  var editorViewForPasteMenu;
60
63
  var pasteMenuSmartCardClientRef = {
@@ -74,6 +77,13 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
74
77
  smartCardClientRef: pasteMenuSmartCardClientRef
75
78
  }));
76
79
  }
80
+ if (isRegisteredSlashCommandEnabled) {
81
+ var _api$uiControlRegistr2;
82
+ api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 || _api$uiControlRegistr2.actions.register((0, _getCardQuickInsertComponents.getCardQuickInsertComponents)({
83
+ api: api,
84
+ options: options
85
+ }));
86
+ }
77
87
  api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref3) {
78
88
  var tr = _ref3.tr,
79
89
  node = _ref3.node,
@@ -321,8 +331,9 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
321
331
  getStartingToolbarItems: (0, _toolbar.getStartingToolbarItems)(options, api),
322
332
  getEndingToolbarItems: (0, _toolbar.getEndingToolbarItems)(options, api)
323
333
  },
324
- pluginsOptions: {
325
- floatingToolbar: (0, _toolbar.floatingToolbar)(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
334
+ pluginsOptions: _objectSpread({
335
+ floatingToolbar: (0, _toolbar.floatingToolbar)(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar)
336
+ }, isRegisteredSlashCommandEnabled ? {} : {
326
337
  quickInsert: function quickInsert(_ref8) {
327
338
  var formatMessage = _ref8.formatMessage;
328
339
  var quickInsertArray = [];
@@ -388,6 +399,6 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
388
399
  }
389
400
  return quickInsertArray;
390
401
  }
391
- }
402
+ })
392
403
  };
393
404
  };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DatasourceQuickInsertMenuItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _messages = require("@atlaskit/editor-common/messages");
12
+ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
13
+ var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
14
+ var _connectivityPluginType = require("@atlaskit/editor-plugin-connectivity/connectivityPluginType");
15
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
16
+ var _actions = require("../../pm-plugins/actions");
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
18
+ var DatasourceQuickInsertMenuItem = exports.DatasourceQuickInsertMenuItem = function DatasourceQuickInsertMenuItem(_ref) {
19
+ var api = _ref.api,
20
+ type = _ref.type;
21
+ var _useIntl = (0, _reactIntl.useIntl)(),
22
+ formatMessage = _useIntl.formatMessage;
23
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (_ref2) {
24
+ var connectivityState = _ref2.connectivityState;
25
+ return {
26
+ isOffline: (0, _connectivityPluginType.isOfflineMode)(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
27
+ };
28
+ }),
29
+ isOffline = _useSharedPluginState.isOffline;
30
+ var isJira = type === 'jira';
31
+ var onSelect = (0, _react.useCallback)(function (_ref3) {
32
+ var insert = _ref3.insert;
33
+ var tr = insert(undefined);
34
+ (0, _actions.showDatasourceModal)(type)(tr);
35
+ return tr;
36
+ }, [type]);
37
+ return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
38
+ iconBefore: isJira ? /*#__PURE__*/_react.default.createElement(_quickInsert.IconDatasourceJiraIssue, null) : /*#__PURE__*/_react.default.createElement(_quickInsert.IconDatasourceAssetsObjects, null),
39
+ isDisabled: isOffline,
40
+ onSelect: onSelect,
41
+ title: formatMessage(isJira ? (0, _fg.fg)('confluence-issue-terminology-refresh') ? _messages.cardMessages.datasourceJiraIssueIssueTermRefresh : _messages.cardMessages.datasourceJiraIssue : _messages.cardMessages.datasourceAssetsObjectsGeneralAvailability)
42
+ });
43
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getCardQuickInsertComponents = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _keys = require("@atlaskit/editor-common/quick-insert/keys");
10
+ var _rank = require("@atlaskit/editor-common/quick-insert/rank");
11
+ var _utils = require("@atlaskit/editor-common/utils");
12
+ var _assetsModal = require("@atlaskit/link-datasource/assets-modal");
13
+ var _DatasourceQuickInsertMenuItem = require("./DatasourceQuickInsertMenuItem");
14
+ var getCardQuickInsertComponents = exports.getCardQuickInsertComponents = function getCardQuickInsertComponents(_ref) {
15
+ var api = _ref.api,
16
+ options = _ref.options;
17
+ if (!options.allowDatasource) {
18
+ return [];
19
+ }
20
+ var components = [{
21
+ key: _keys.JIRA_WORK_ITEMS_MENU_ITEM.key,
22
+ type: _keys.JIRA_WORK_ITEMS_MENU_ITEM.type,
23
+ parents: [{
24
+ key: _keys.DATA_AND_CHARTS_SECTION.key,
25
+ type: _keys.DATA_AND_CHARTS_SECTION.type,
26
+ rank: _rank.DATA_AND_CHARTS_SECTION_RANK[_keys.JIRA_WORK_ITEMS_MENU_ITEM.key]
27
+ }],
28
+ component: function component() {
29
+ return /*#__PURE__*/_react.default.createElement(_DatasourceQuickInsertMenuItem.DatasourceQuickInsertMenuItem, {
30
+ api: api,
31
+ type: "jira"
32
+ });
33
+ }
34
+ }];
35
+ if ((0, _utils.canRenderDatasource)(_assetsModal.ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
36
+ components.push({
37
+ key: _keys.ASSETS_MENU_ITEM.key,
38
+ type: _keys.ASSETS_MENU_ITEM.type,
39
+ parents: [{
40
+ key: _keys.DATA_AND_CHARTS_SECTION.key,
41
+ type: _keys.DATA_AND_CHARTS_SECTION.type,
42
+ rank: _rank.DATA_AND_CHARTS_SECTION_RANK[_keys.ASSETS_MENU_ITEM.key]
43
+ }],
44
+ component: function component() {
45
+ return /*#__PURE__*/_react.default.createElement(_DatasourceQuickInsertMenuItem.DatasourceQuickInsertMenuItem, {
46
+ api: api,
47
+ type: "assets"
48
+ });
49
+ }
50
+ });
51
+ }
52
+ return components;
53
+ };
@@ -4,6 +4,7 @@ import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDataso
4
4
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
5
5
  import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
6
6
  import { SmartCardContext } from '@atlaskit/link-provider/context';
7
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal';
9
10
  import { blockCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/blockCard';
@@ -23,6 +24,7 @@ import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
23
24
  // eslint-disable-next-line import/no-named-as-default
24
25
  import LayoutButton from './ui/LayoutButton';
25
26
  import { getPasteDisplayAsMenuComponents } from './ui/PasteDisplayAsMenu';
27
+ import { getCardQuickInsertComponents } from './ui/quick-insert/getCardQuickInsertComponents';
26
28
  import { floatingToolbar, getEndingToolbarItems, getStartingToolbarItems } from './ui/toolbar';
27
29
  const PasteMenuSmartCardClientSync = ({
28
30
  clientRef
@@ -42,6 +44,7 @@ export const cardPlugin = ({
42
44
  var _api$base, _options$lpLinkPicker;
43
45
  let previousCardProvider;
44
46
  const cardPluginEvents = createEventsQueue();
47
+ const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
45
48
  let instanceEmbedCardTransformers = options.embedCardTransformers;
46
49
  let editorViewForPasteMenu;
47
50
  const pasteMenuSmartCardClientRef = {
@@ -59,6 +62,13 @@ export const cardPlugin = ({
59
62
  smartCardClientRef: pasteMenuSmartCardClientRef
60
63
  }));
61
64
  }
65
+ if (isRegisteredSlashCommandEnabled) {
66
+ var _api$uiControlRegistr2;
67
+ api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.register(getCardQuickInsertComponents({
68
+ api,
69
+ options
70
+ }));
71
+ }
62
72
  api === null || api === void 0 ? void 0 : (_api$base = api.base) === null || _api$base === void 0 ? void 0 : _api$base.actions.registerMarks(({
63
73
  tr,
64
74
  node,
@@ -256,66 +266,68 @@ export const cardPlugin = ({
256
266
  },
257
267
  pluginsOptions: {
258
268
  floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
259
- quickInsert: ({
260
- formatMessage
261
- }) => {
262
- const quickInsertArray = [];
263
- if (!options.allowDatasource) {
264
- return quickInsertArray;
265
- }
266
- quickInsertArray.push({
267
- id: 'datasource',
268
- title: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue),
269
- description: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueDescriptionIssueTermRefresh : messages.datasourceJiraIssueDescription),
270
- isDisabledOffline: true,
271
- categories: ['external-content', 'development'],
272
- keywords: ['jira'],
273
- featured: true,
274
- ...(fg('jim-lower-ranking-in-jira-macro-search') && {
275
- priority: 500
276
- }),
277
- icon: () => /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null),
278
- action(insert) {
279
- const tr = insert(undefined);
280
- showDatasourceModal('jira')(tr);
281
- return tr;
269
+ ...(isRegisteredSlashCommandEnabled ? {} : {
270
+ quickInsert: ({
271
+ formatMessage
272
+ }) => {
273
+ const quickInsertArray = [];
274
+ if (!options.allowDatasource) {
275
+ return quickInsertArray;
282
276
  }
283
- });
284
- if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
285
277
  quickInsertArray.push({
286
278
  id: 'datasource',
287
- title: formatMessage(messages.datasourceAssetsObjectsGeneralAvailability),
288
- description: formatMessage(messages.datasourceAssetsObjectsDescription),
279
+ title: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue),
280
+ description: formatMessage(fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueDescriptionIssueTermRefresh : messages.datasourceJiraIssueDescription),
289
281
  isDisabledOffline: true,
290
282
  categories: ['external-content', 'development'],
291
- keywords: ['assets'],
292
- icon: () => /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null),
293
- action(insert) {
294
- const tr = insert(undefined);
295
- showDatasourceModal('assets')(tr);
296
- return tr;
297
- }
298
- });
299
- }
300
- if (isDatasourceConfigEditable(CONFLUENCE_SEARCH_DATASOURCE_ID)) {
301
- quickInsertArray.push({
302
- id: 'datasource',
303
- title: formatMessage(messages.datasourceConfluenceSearch),
304
- description: formatMessage(messages.datasourceConfluenceSearchDescription),
305
- isDisabledOffline: true,
306
- categories: ['external-content', 'development'],
307
- keywords: ['confluence'],
283
+ keywords: ['jira'],
308
284
  featured: true,
309
- icon: () => /*#__PURE__*/React.createElement(IconDatasourceConfluenceSearch, null),
285
+ ...(fg('jim-lower-ranking-in-jira-macro-search') && {
286
+ priority: 500
287
+ }),
288
+ icon: () => /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null),
310
289
  action(insert) {
311
290
  const tr = insert(undefined);
312
- showDatasourceModal('confluence-search')(tr);
291
+ showDatasourceModal('jira')(tr);
313
292
  return tr;
314
293
  }
315
294
  });
295
+ if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
296
+ quickInsertArray.push({
297
+ id: 'datasource',
298
+ title: formatMessage(messages.datasourceAssetsObjectsGeneralAvailability),
299
+ description: formatMessage(messages.datasourceAssetsObjectsDescription),
300
+ isDisabledOffline: true,
301
+ categories: ['external-content', 'development'],
302
+ keywords: ['assets'],
303
+ icon: () => /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null),
304
+ action(insert) {
305
+ const tr = insert(undefined);
306
+ showDatasourceModal('assets')(tr);
307
+ return tr;
308
+ }
309
+ });
310
+ }
311
+ if (isDatasourceConfigEditable(CONFLUENCE_SEARCH_DATASOURCE_ID)) {
312
+ quickInsertArray.push({
313
+ id: 'datasource',
314
+ title: formatMessage(messages.datasourceConfluenceSearch),
315
+ description: formatMessage(messages.datasourceConfluenceSearchDescription),
316
+ isDisabledOffline: true,
317
+ categories: ['external-content', 'development'],
318
+ keywords: ['confluence'],
319
+ featured: true,
320
+ icon: () => /*#__PURE__*/React.createElement(IconDatasourceConfluenceSearch, null),
321
+ action(insert) {
322
+ const tr = insert(undefined);
323
+ showDatasourceModal('confluence-search')(tr);
324
+ return tr;
325
+ }
326
+ });
327
+ }
328
+ return quickInsertArray;
316
329
  }
317
- return quickInsertArray;
318
- }
330
+ })
319
331
  }
320
332
  };
321
333
  };
@@ -0,0 +1,38 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { IconDatasourceAssetsObjects, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
6
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
7
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity/connectivityPluginType';
8
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
9
+ import { showDatasourceModal } from '../../pm-plugins/actions';
10
+ export const DatasourceQuickInsertMenuItem = ({
11
+ api,
12
+ type
13
+ }) => {
14
+ const {
15
+ formatMessage
16
+ } = useIntl();
17
+ const {
18
+ isOffline
19
+ } = useSharedPluginStateWithSelector(api, ['connectivity'], ({
20
+ connectivityState
21
+ }) => ({
22
+ isOffline: isOfflineMode(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
23
+ }));
24
+ const isJira = type === 'jira';
25
+ const onSelect = useCallback(({
26
+ insert
27
+ }) => {
28
+ const tr = insert(undefined);
29
+ showDatasourceModal(type)(tr);
30
+ return tr;
31
+ }, [type]);
32
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
33
+ iconBefore: isJira ? /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null) : /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null),
34
+ isDisabled: isOffline,
35
+ onSelect: onSelect,
36
+ title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : messages.datasourceAssetsObjectsGeneralAvailability)
37
+ });
38
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { ASSETS_MENU_ITEM, DATA_AND_CHARTS_SECTION, JIRA_WORK_ITEMS_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
3
+ import { DATA_AND_CHARTS_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
4
+ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
5
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/assets-modal';
6
+ import { DatasourceQuickInsertMenuItem } from './DatasourceQuickInsertMenuItem';
7
+ export const getCardQuickInsertComponents = ({
8
+ api,
9
+ options
10
+ }) => {
11
+ if (!options.allowDatasource) {
12
+ return [];
13
+ }
14
+ const components = [{
15
+ key: JIRA_WORK_ITEMS_MENU_ITEM.key,
16
+ type: JIRA_WORK_ITEMS_MENU_ITEM.type,
17
+ parents: [{
18
+ key: DATA_AND_CHARTS_SECTION.key,
19
+ type: DATA_AND_CHARTS_SECTION.type,
20
+ rank: DATA_AND_CHARTS_SECTION_RANK[JIRA_WORK_ITEMS_MENU_ITEM.key]
21
+ }],
22
+ component: () => /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
23
+ api: api,
24
+ type: "jira"
25
+ })
26
+ }];
27
+ if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
28
+ components.push({
29
+ key: ASSETS_MENU_ITEM.key,
30
+ type: ASSETS_MENU_ITEM.type,
31
+ parents: [{
32
+ key: DATA_AND_CHARTS_SECTION.key,
33
+ type: DATA_AND_CHARTS_SECTION.type,
34
+ rank: DATA_AND_CHARTS_SECTION_RANK[ASSETS_MENU_ITEM.key]
35
+ }],
36
+ component: () => /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
37
+ api: api,
38
+ type: "assets"
39
+ })
40
+ });
41
+ }
42
+ return components;
43
+ };
@@ -10,6 +10,7 @@ import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDataso
10
10
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
11
11
  import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
12
12
  import { SmartCardContext } from '@atlaskit/link-provider/context';
13
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal';
15
16
  import { blockCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/blockCard';
@@ -29,6 +30,7 @@ import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
29
30
  // eslint-disable-next-line import/no-named-as-default
30
31
  import LayoutButton from './ui/LayoutButton';
31
32
  import { getPasteDisplayAsMenuComponents } from './ui/PasteDisplayAsMenu';
33
+ import { getCardQuickInsertComponents } from './ui/quick-insert/getCardQuickInsertComponents';
32
34
  import { floatingToolbar, getEndingToolbarItems, getStartingToolbarItems } from './ui/toolbar';
33
35
  var PasteMenuSmartCardClientSync = function PasteMenuSmartCardClientSync(_ref) {
34
36
  var _smartCardContext$con2;
@@ -47,6 +49,7 @@ export var cardPlugin = function cardPlugin(_ref2) {
47
49
  api = _ref2.api;
48
50
  var previousCardProvider;
49
51
  var cardPluginEvents = createEventsQueue();
52
+ var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
50
53
  var instanceEmbedCardTransformers = options.embedCardTransformers;
51
54
  var editorViewForPasteMenu;
52
55
  var pasteMenuSmartCardClientRef = {
@@ -66,6 +69,13 @@ export var cardPlugin = function cardPlugin(_ref2) {
66
69
  smartCardClientRef: pasteMenuSmartCardClientRef
67
70
  }));
68
71
  }
72
+ if (isRegisteredSlashCommandEnabled) {
73
+ var _api$uiControlRegistr2;
74
+ api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 || _api$uiControlRegistr2.actions.register(getCardQuickInsertComponents({
75
+ api: api,
76
+ options: options
77
+ }));
78
+ }
69
79
  api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref3) {
70
80
  var tr = _ref3.tr,
71
81
  node = _ref3.node,
@@ -313,8 +323,9 @@ export var cardPlugin = function cardPlugin(_ref2) {
313
323
  getStartingToolbarItems: getStartingToolbarItems(options, api),
314
324
  getEndingToolbarItems: getEndingToolbarItems(options, api)
315
325
  },
316
- pluginsOptions: {
317
- floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
326
+ pluginsOptions: _objectSpread({
327
+ floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar)
328
+ }, isRegisteredSlashCommandEnabled ? {} : {
318
329
  quickInsert: function quickInsert(_ref8) {
319
330
  var formatMessage = _ref8.formatMessage;
320
331
  var quickInsertArray = [];
@@ -380,6 +391,6 @@ export var cardPlugin = function cardPlugin(_ref2) {
380
391
  }
381
392
  return quickInsertArray;
382
393
  }
383
- }
394
+ })
384
395
  };
385
396
  };
@@ -0,0 +1,35 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { IconDatasourceAssetsObjects, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
6
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
7
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity/connectivityPluginType';
8
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
9
+ import { showDatasourceModal } from '../../pm-plugins/actions';
10
+ export var DatasourceQuickInsertMenuItem = function DatasourceQuickInsertMenuItem(_ref) {
11
+ var api = _ref.api,
12
+ type = _ref.type;
13
+ var _useIntl = useIntl(),
14
+ formatMessage = _useIntl.formatMessage;
15
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (_ref2) {
16
+ var connectivityState = _ref2.connectivityState;
17
+ return {
18
+ isOffline: isOfflineMode(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
19
+ };
20
+ }),
21
+ isOffline = _useSharedPluginState.isOffline;
22
+ var isJira = type === 'jira';
23
+ var onSelect = useCallback(function (_ref3) {
24
+ var insert = _ref3.insert;
25
+ var tr = insert(undefined);
26
+ showDatasourceModal(type)(tr);
27
+ return tr;
28
+ }, [type]);
29
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
30
+ iconBefore: isJira ? /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null) : /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null),
31
+ isDisabled: isOffline,
32
+ onSelect: onSelect,
33
+ title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : messages.datasourceAssetsObjectsGeneralAvailability)
34
+ });
35
+ };
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { ASSETS_MENU_ITEM, DATA_AND_CHARTS_SECTION, JIRA_WORK_ITEMS_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
3
+ import { DATA_AND_CHARTS_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
4
+ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
5
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/assets-modal';
6
+ import { DatasourceQuickInsertMenuItem } from './DatasourceQuickInsertMenuItem';
7
+ export var getCardQuickInsertComponents = function getCardQuickInsertComponents(_ref) {
8
+ var api = _ref.api,
9
+ options = _ref.options;
10
+ if (!options.allowDatasource) {
11
+ return [];
12
+ }
13
+ var components = [{
14
+ key: JIRA_WORK_ITEMS_MENU_ITEM.key,
15
+ type: JIRA_WORK_ITEMS_MENU_ITEM.type,
16
+ parents: [{
17
+ key: DATA_AND_CHARTS_SECTION.key,
18
+ type: DATA_AND_CHARTS_SECTION.type,
19
+ rank: DATA_AND_CHARTS_SECTION_RANK[JIRA_WORK_ITEMS_MENU_ITEM.key]
20
+ }],
21
+ component: function component() {
22
+ return /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
23
+ api: api,
24
+ type: "jira"
25
+ });
26
+ }
27
+ }];
28
+ if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
29
+ components.push({
30
+ key: ASSETS_MENU_ITEM.key,
31
+ type: ASSETS_MENU_ITEM.type,
32
+ parents: [{
33
+ key: DATA_AND_CHARTS_SECTION.key,
34
+ type: DATA_AND_CHARTS_SECTION.type,
35
+ rank: DATA_AND_CHARTS_SECTION_RANK[ASSETS_MENU_ITEM.key]
36
+ }],
37
+ component: function component() {
38
+ return /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
39
+ api: api,
40
+ type: "assets"
41
+ });
42
+ }
43
+ });
44
+ }
45
+ return components;
46
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { CardPlugin } from '../../cardPluginType';
4
+ type Props = {
5
+ api: ExtractInjectionAPI<CardPlugin> | undefined;
6
+ type: 'assets' | 'jira';
7
+ };
8
+ export declare const DatasourceQuickInsertMenuItem: ({ api, type }: Props) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ import type { CardPlugin } from '../../cardPluginType';
4
+ import type { CardPluginOptions } from '../../types';
5
+ type Params = {
6
+ api: ExtractInjectionAPI<CardPlugin> | undefined;
7
+ options: CardPluginOptions;
8
+ };
9
+ export declare const getCardQuickInsertComponents: ({ api, options }: Params) => RegisterMenuItem[];
10
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "19.0.1",
3
+ "version": "19.0.3",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -43,8 +43,9 @@
43
43
  "@atlaskit/editor-shared-styles": "^4.0.0",
44
44
  "@atlaskit/editor-smart-link-draggable": "^1.2.0",
45
45
  "@atlaskit/editor-toolbar": "^2.4.0",
46
+ "@atlaskit/editor-ui-control-model": "^2.4.0",
46
47
  "@atlaskit/frontend-utilities": "^4.1.0",
47
- "@atlaskit/icon": "^37.2.0",
48
+ "@atlaskit/icon": "^37.3.0",
48
49
  "@atlaskit/json-ld-types": "^2.0.0",
49
50
  "@atlaskit/link": "^5.0.0",
50
51
  "@atlaskit/link-analytics": "^12.1.0",
@@ -54,12 +55,13 @@
54
55
  "@atlaskit/linking-common": "^11.0.0",
55
56
  "@atlaskit/linking-types": "^15.0.0",
56
57
  "@atlaskit/menu": "^9.2.0",
58
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
57
59
  "@atlaskit/platform-feature-flags": "^2.1.0",
58
60
  "@atlaskit/platform-feature-flags-react": "^1.1.0",
59
61
  "@atlaskit/primitives": "^22.2.0",
60
62
  "@atlaskit/prosemirror-history": "^1.1.0",
61
63
  "@atlaskit/smart-card": "^45.17.0",
62
- "@atlaskit/tmp-editor-statsig": "^139.0.0",
64
+ "@atlaskit/tmp-editor-statsig": "^140.0.0",
63
65
  "@atlaskit/tokens": "^16.3.0",
64
66
  "@babel/runtime": "^7.0.0",
65
67
  "@emotion/react": "^11.7.1",
@@ -69,7 +71,7 @@
69
71
  "uuid": "^3.1.0"
70
72
  },
71
73
  "peerDependencies": {
72
- "@atlaskit/editor-common": "^117.0.0",
74
+ "@atlaskit/editor-common": "^117.2.0",
73
75
  "@atlaskit/link-provider": "^5.3.0",
74
76
  "react": "^18.2.0 || ^19.2.0",
75
77
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"