@atlaskit/editor-core 185.15.4 → 185.16.0

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/plugins/card/index.js +29 -1
  3. package/dist/cjs/plugins/card/messages.js +20 -0
  4. package/dist/cjs/plugins/card/pm-plugins/actions.js +7 -4
  5. package/dist/cjs/plugins/card/pm-plugins/doc.js +26 -7
  6. package/dist/cjs/plugins/card/pm-plugins/main.js +3 -2
  7. package/dist/cjs/plugins/card/pm-plugins/reducers.js +11 -3
  8. package/dist/cjs/plugins/card/toolbar.js +3 -9
  9. package/dist/cjs/plugins/card/ui/DatasourceModal/ModalWithState.js +25 -0
  10. package/dist/cjs/plugins/card/ui/DatasourceModal/index.js +60 -0
  11. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +8 -28
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/plugins/card/index.js +29 -1
  15. package/dist/es2019/plugins/card/messages.js +13 -0
  16. package/dist/es2019/plugins/card/pm-plugins/actions.js +3 -2
  17. package/dist/es2019/plugins/card/pm-plugins/doc.js +27 -5
  18. package/dist/es2019/plugins/card/pm-plugins/main.js +3 -2
  19. package/dist/es2019/plugins/card/pm-plugins/reducers.js +12 -3
  20. package/dist/es2019/plugins/card/toolbar.js +4 -10
  21. package/dist/es2019/plugins/card/ui/DatasourceModal/ModalWithState.js +19 -0
  22. package/dist/es2019/plugins/card/ui/DatasourceModal/index.js +48 -0
  23. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +6 -26
  24. package/dist/es2019/version-wrapper.js +1 -1
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/esm/plugins/card/index.js +30 -1
  27. package/dist/esm/plugins/card/messages.js +13 -0
  28. package/dist/esm/plugins/card/pm-plugins/actions.js +7 -4
  29. package/dist/esm/plugins/card/pm-plugins/doc.js +23 -5
  30. package/dist/esm/plugins/card/pm-plugins/main.js +3 -2
  31. package/dist/esm/plugins/card/pm-plugins/reducers.js +11 -3
  32. package/dist/esm/plugins/card/toolbar.js +4 -10
  33. package/dist/esm/plugins/card/ui/DatasourceModal/ModalWithState.js +17 -0
  34. package/dist/esm/plugins/card/ui/DatasourceModal/index.js +49 -0
  35. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +6 -25
  36. package/dist/esm/version-wrapper.js +1 -1
  37. package/dist/esm/version.json +1 -1
  38. package/dist/types/plugins/card/messages.d.ts +12 -0
  39. package/dist/types/plugins/card/pm-plugins/actions.d.ts +2 -1
  40. package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -0
  41. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +1 -0
  42. package/dist/types/plugins/card/types.d.ts +3 -0
  43. package/dist/types/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  44. package/dist/{types-ts4.5/plugins/card/ui/DatasourceModal.d.ts → types/plugins/card/ui/DatasourceModal/index.d.ts} +3 -5
  45. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -7
  46. package/dist/types-ts4.5/plugins/card/messages.d.ts +12 -0
  47. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +2 -1
  48. package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +1 -0
  50. package/dist/types-ts4.5/plugins/card/types.d.ts +3 -0
  51. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  52. package/dist/{types/plugins/card/ui/DatasourceModal.d.ts → types-ts4.5/plugins/card/ui/DatasourceModal/index.d.ts} +3 -5
  53. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -7
  54. package/package.json +2 -2
  55. package/dist/cjs/plugins/card/ui/DatasourceModal.js +0 -41
  56. package/dist/es2019/plugins/card/ui/DatasourceModal.js +0 -30
  57. package/dist/esm/plugins/card/ui/DatasourceModal.js +0 -31
@@ -11,7 +11,7 @@ import { changeSelectedCardToText } from './pm-plugins/doc';
11
11
  import { commandWithMetadata } from '@atlaskit/editor-common/card';
12
12
  import { pluginKey } from './pm-plugins/main';
13
13
  import { richMediaClassName } from '@atlaskit/editor-common/styles';
14
- import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig, openDatasourceModal } from './ui/EditLinkToolbar';
14
+ import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
15
15
  import { displayInfoForCard, findCardInfo, titleUrlPairFromNode, appearanceForNodeType } from './utils';
16
16
  import { isSafeUrl } from '@atlaskit/adf-schema';
17
17
  import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
@@ -165,7 +165,7 @@ const withToolbarMetadata = command => commandWithMetadata(command, {
165
165
  inputMethod: INPUT_METHOD.FLOATING_TB
166
166
  });
167
167
  const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) => node => {
168
- var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs, _node$attrs2;
168
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs, _node$attrs2, _node$attrs2$datasour;
169
169
  const {
170
170
  url
171
171
  } = titleUrlPairFromNode(node);
@@ -192,7 +192,7 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
192
192
  const isDatasource = currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
193
193
  const shouldRenderDatasourceToolbar = isDatasource &&
194
194
  // not showing toolbar in mobile for now since not sure what our plans are for it
195
- platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.datasource);
195
+ platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : (_node$attrs2$datasour = _node$attrs2.datasource) === null || _node$attrs2$datasour === void 0 ? void 0 : _node$attrs2$datasour.id);
196
196
 
197
197
  /* mobile builds toolbar natively using toolbarItems */
198
198
  if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar && platform !== 'mobile') {
@@ -203,12 +203,6 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
203
203
  featureFlags,
204
204
  pluginInjectionApi
205
205
  })];
206
- } else if (pluginState !== null && pluginState !== void 0 && pluginState.showDatasourceModal) {
207
- return [openDatasourceModal({
208
- state,
209
- node,
210
- editorAnalyticsApi
211
- })];
212
206
  } else if (shouldRenderDatasourceToolbar) {
213
207
  return getDatasourceButtonGroup(state, metadata, intl, editorAnalyticsApi, node, hoverDecoration);
214
208
  } else {
@@ -334,7 +328,7 @@ const getDatasourceButtonGroup = (state, metadata, intl, editorAnalyticsApi, nod
334
328
  metadata: metadata,
335
329
  className: 'datasource-edit',
336
330
  title: intl.formatMessage(linkToolbarMessages.editDatasource),
337
- onClick: editDatasource(editorAnalyticsApi)
331
+ onClick: editDatasource(node, editorAnalyticsApi)
338
332
  }];
339
333
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
340
334
  toolbarItems.push({
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { DatasourceModal } from './index';
4
+ const ModalWithState = ({
5
+ api,
6
+ editorView
7
+ }) => {
8
+ const {
9
+ cardState
10
+ } = useSharedPluginState(api, ['card']);
11
+ if (!(cardState !== null && cardState !== void 0 && cardState.showDatasourceModal)) {
12
+ return null;
13
+ }
14
+ return /*#__PURE__*/React.createElement(DatasourceModal, {
15
+ view: editorView,
16
+ modalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
17
+ });
18
+ };
19
+ export default ModalWithState;
@@ -0,0 +1,48 @@
1
+ import React, { useCallback } from 'react';
2
+ import { JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
3
+ import { hideDatasourceModal } from '../../pm-plugins/actions';
4
+ import { updateExistingDatasource, insertDatasource } from '../../pm-plugins/doc';
5
+ import { NodeSelection } from 'prosemirror-state';
6
+ export const DatasourceModal = ({
7
+ view,
8
+ modalType
9
+ }) => {
10
+ const {
11
+ dispatch,
12
+ state
13
+ } = view;
14
+ const {
15
+ selection
16
+ } = state;
17
+ const existingNode = selection instanceof NodeSelection ? selection.node : undefined;
18
+ const onClose = useCallback(() => {
19
+ dispatch(hideDatasourceModal(state.tr));
20
+ }, [dispatch, state.tr]);
21
+ const onInsert = useCallback(newAdf => {
22
+ if (existingNode) {
23
+ updateExistingDatasource(state, existingNode, newAdf, view);
24
+ } else {
25
+ insertDatasource(state, newAdf, view);
26
+ }
27
+ }, [existingNode, state, view]);
28
+ if (modalType === 'jira') {
29
+ var _existingNode$attrs, _tableView$properties;
30
+ const {
31
+ id: datasourceId = JIRA_LIST_OF_LINKS_DATASOURCE_ID,
32
+ parameters,
33
+ views = []
34
+ } = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs = existingNode.attrs) === null || _existingNode$attrs === void 0 ? void 0 : _existingNode$attrs.datasource) || {};
35
+ const [tableView] = views;
36
+ const visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(column => column.key);
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ "data-testid": "jira-config-modal"
39
+ }, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
40
+ datasourceId: datasourceId,
41
+ visibleColumnKeys: visibleColumnKeys,
42
+ parameters: parameters,
43
+ onCancel: onClose,
44
+ onInsert: onInsert
45
+ }));
46
+ }
47
+ return null; // null for now until we have modal component that handles other datasources
48
+ };
@@ -10,8 +10,8 @@ import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
10
10
  import { findCardInfo, displayInfoForCard } from '../utils';
11
11
  import { NodeSelection } from 'prosemirror-state';
12
12
  import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
13
- import { DatasourceModal } from './DatasourceModal';
14
13
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
14
+ import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
15
15
  const HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkAddToolbarWithState);
16
16
  export function HyperlinkAddToolbarWithState({
17
17
  linkPickerOptions = {},
@@ -202,12 +202,14 @@ export const editLinkToolbarConfig = (showLinkingToolbar, lpLinkPicker) => {
202
202
  forcePlacement: true
203
203
  } : {};
204
204
  };
205
- export const editDatasource = editorAnalyticsApi => (state, dispatch) => {
206
- if (dispatch) {
205
+ export const editDatasource = (node, editorAnalyticsApi) => (state, dispatch) => {
206
+ var _node$attrs;
207
+ const modalType = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource.id) === JIRA_LIST_OF_LINKS_DATASOURCE_ID ? 'jira' : undefined;
208
+ if (dispatch && modalType) {
207
209
  const {
208
210
  tr
209
211
  } = state;
210
- showDatasourceModal(tr);
212
+ showDatasourceModal(modalType)(tr);
211
213
  // editorAnalyticsApi?.attachAnalyticsEvent(
212
214
  // buildEditLinkPayload(
213
215
  // type as
@@ -220,26 +222,4 @@ export const editDatasource = editorAnalyticsApi => (state, dispatch) => {
220
222
  return true;
221
223
  }
222
224
  return false;
223
- };
224
- export const openDatasourceModal = ({
225
- state,
226
- node,
227
- editorAnalyticsApi
228
- }) => {
229
- return {
230
- type: 'custom',
231
- disableArrowNavigation: true,
232
- fallback: [],
233
- render: view => {
234
- if (!view) {
235
- return null;
236
- }
237
- return /*#__PURE__*/React.createElement(DatasourceModal, {
238
- state: state,
239
- view: view,
240
- node: node,
241
- editorAnalyticsApi: editorAnalyticsApi
242
- });
243
- }
244
- };
245
225
  };
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.15.4";
2
+ export const version = "185.16.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.15.4",
3
+ "version": "185.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -13,6 +13,12 @@ import { EditorSmartCardEventsNext } from './ui/EditorSmartCardEventsNext';
13
13
  import LayoutButton from './ui/LayoutButton';
14
14
  import { pluginKey } from './pm-plugins/plugin-key';
15
15
  import { mountHyperlinkPlugin } from './pm-plugins/mountHyperlink';
16
+ import { showDatasourceModal } from './pm-plugins/actions';
17
+ import DatasourceModalWithState from './ui/DatasourceModal/ModalWithState';
18
+ import { messages } from './messages';
19
+ import { IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
20
+ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
21
+ import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
16
22
  var cardPlugin = function cardPlugin(options, api) {
17
23
  var _api$dependencies, _api$dependencies$fea;
18
24
  var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
@@ -87,6 +93,9 @@ var cardPlugin = function cardPlugin(options, api) {
87
93
  mountPoint: popupsMountPoint,
88
94
  scrollableElement: popupsScrollableElement,
89
95
  boundariesElement: popupsBoundariesElement
96
+ }), /*#__PURE__*/React.createElement(DatasourceModalWithState, {
97
+ api: api,
98
+ editorView: editorView
90
99
  }));
91
100
  },
92
101
  actions: {
@@ -96,7 +105,27 @@ var cardPlugin = function cardPlugin(options, api) {
96
105
  setSelectedCardAppearance: setSelectedCardAppearance
97
106
  },
98
107
  pluginsOptions: {
99
- floatingToolbar: floatingToolbar(options, featureFlags, options.platform, options.linkPicker, api)
108
+ floatingToolbar: floatingToolbar(options, featureFlags, options.platform, options.linkPicker, api),
109
+ quickInsert: function quickInsert(_ref3) {
110
+ var formatMessage = _ref3.formatMessage;
111
+ if (canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
112
+ return [{
113
+ id: 'datasource',
114
+ title: formatMessage(messages.datasourceJiraIssue),
115
+ description: formatMessage(messages.datasourceJiraIssueDescription),
116
+ keywords: ['jira'],
117
+ icon: function icon() {
118
+ return /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null);
119
+ },
120
+ action: function action(insert) {
121
+ var tr = insert(undefined);
122
+ showDatasourceModal('jira')(tr);
123
+ return tr;
124
+ }
125
+ }];
126
+ }
127
+ return [];
128
+ }
100
129
  }
101
130
  };
102
131
  };
@@ -0,0 +1,13 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ datasourceJiraIssue: {
4
+ id: 'fabric.editor.datasource.jiraIssue',
5
+ defaultMessage: 'Jira Issues',
6
+ description: 'Insert a jira datasource table'
7
+ },
8
+ datasourceJiraIssueDescription: {
9
+ id: 'fabric.editor.datasource.jiraIssue.description',
10
+ defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
11
+ description: 'Insert a jira datasource table'
12
+ }
13
+ });
@@ -87,10 +87,13 @@ export var hideLinkToolbar = function hideLinkToolbar(tr) {
87
87
  type: 'HIDE_LINK_TOOLBAR'
88
88
  });
89
89
  };
90
- export var showDatasourceModal = function showDatasourceModal(tr) {
91
- return cardAction(tr, {
92
- type: 'SHOW_DATASOURCE_MODAL'
93
- });
90
+ export var showDatasourceModal = function showDatasourceModal(modalType) {
91
+ return function (tr) {
92
+ return cardAction(tr, {
93
+ type: 'SHOW_DATASOURCE_MODAL',
94
+ modalType: modalType
95
+ });
96
+ };
94
97
  };
95
98
  export var hideDatasourceModal = function hideDatasourceModal(tr) {
96
99
  return cardAction(tr, {
@@ -419,13 +419,17 @@ export var updateExistingDatasource = function updateExistingDatasource(state, n
419
419
 
420
420
  // datasource to datasource
421
421
  if (newAdf.type === 'blockCard' && newAdf.attrs.datasource && node.attrs.datasource) {
422
- var _ref, _ref2, _newViews$, _newViews$$properties, _oldViews$, _oldViews$$properties, _newAdf$attrs, _node$attrs;
423
- var newViews = (_ref = newAdf.attrs.datasource.views) !== null && _ref !== void 0 ? _ref : [];
424
- var oldViews = (_ref2 = node.attrs.datasource.views) !== null && _ref2 !== void 0 ? _ref2 : [];
425
- var newColumnKeys = (_newViews$ = newViews[0]) === null || _newViews$ === void 0 ? void 0 : (_newViews$$properties = _newViews$.properties) === null || _newViews$$properties === void 0 ? void 0 : _newViews$$properties.columns.map(function (column) {
422
+ var _ref3, _ref6, _newViews$properties, _oldViews$properties, _newAdf$attrs, _node$attrs;
423
+ var _ref = (_ref3 = newAdf.attrs.datasource.views) !== null && _ref3 !== void 0 ? _ref3 : [],
424
+ _ref2 = _slicedToArray(_ref, 1),
425
+ newViews = _ref2[0];
426
+ var _ref4 = (_ref6 = node.attrs.datasource.views) !== null && _ref6 !== void 0 ? _ref6 : [],
427
+ _ref5 = _slicedToArray(_ref4, 1),
428
+ oldViews = _ref5[0];
429
+ var newColumnKeys = newViews === null || newViews === void 0 ? void 0 : (_newViews$properties = newViews.properties) === null || _newViews$properties === void 0 ? void 0 : _newViews$properties.columns.map(function (column) {
426
430
  return column.key;
427
431
  });
428
- var oldColumnKeys = (_oldViews$ = oldViews[0]) === null || _oldViews$ === void 0 ? void 0 : (_oldViews$$properties = _oldViews$.properties) === null || _oldViews$$properties === void 0 ? void 0 : _oldViews$$properties.columns.map(function (column) {
432
+ var oldColumnKeys = oldViews === null || oldViews === void 0 ? void 0 : (_oldViews$properties = oldViews.properties) === null || _oldViews$properties === void 0 ? void 0 : _oldViews$properties.columns.map(function (column) {
429
433
  return column.key;
430
434
  });
431
435
  var isColumnChange = !isEqual(oldColumnKeys, newColumnKeys);
@@ -439,4 +443,18 @@ export var updateExistingDatasource = function updateExistingDatasource(state, n
439
443
  }
440
444
  hideDatasourceModal(tr);
441
445
  view.dispatch(tr.scrollIntoView());
446
+ };
447
+ export var insertDatasource = function insertDatasource(state, adf, view) {
448
+ var tr = state.tr,
449
+ from = state.selection.from,
450
+ schemaNodes = state.schema.nodes;
451
+ var attrs = adf.attrs,
452
+ type = adf.type;
453
+ var schemaNode = type === 'inlineCard' ? schemaNodes.inlineCard : schemaNodes.blockCard;
454
+ var newNode = schemaNode.createChecked(attrs);
455
+ // in future, if we decide to do datasource insertion from the main toolbar, we should probably consider editor-plugin-content-insertion instead of tr.insert
456
+ // this will allow us to deal with insertions from multiple paths in a more consistent way
457
+ newNode && tr.insert(from, newNode);
458
+ hideDatasourceModal(tr);
459
+ view.dispatch(tr.scrollIntoView());
442
460
  };
@@ -47,6 +47,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
47
47
  smartLinkEventsNext: undefined,
48
48
  editorAppearance: editorAppearance,
49
49
  showDatasourceModal: false,
50
+ datasourceModalType: undefined,
50
51
  datasourceTableRef: undefined,
51
52
  layout: undefined
52
53
  };
@@ -158,8 +159,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
158
159
  var hasIntlContext = true;
159
160
  var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
160
161
  if (isDatasource) {
161
- var _node$attrs4;
162
- if (platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.datasource)) {
162
+ var _node$attrs4, _node$attrs4$datasour;
163
+ if (platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 ? void 0 : (_node$attrs4$datasour = _node$attrs4.datasource) === null || _node$attrs4$datasour === void 0 ? void 0 : _node$attrs4$datasour.id)) {
163
164
  return new Datasource({
164
165
  node: node,
165
166
  view: view,
@@ -60,9 +60,16 @@ var setLinkToolbar = function setLinkToolbar(state, action) {
60
60
  showLinkingToolbar: action.type === 'SHOW_LINK_TOOLBAR'
61
61
  });
62
62
  };
63
- var setDatasourceModal = function setDatasourceModal(state, action) {
63
+ var showDatasourceModal = function showDatasourceModal(state, action) {
64
64
  return _objectSpread(_objectSpread({}, state), {}, {
65
- showDatasourceModal: action.type === 'SHOW_DATASOURCE_MODAL'
65
+ showDatasourceModal: true,
66
+ datasourceModalType: action.type === 'SHOW_DATASOURCE_MODAL' ? action.modalType : undefined
67
+ });
68
+ };
69
+ var hideDatasourceModal = function hideDatasourceModal(state) {
70
+ return _objectSpread(_objectSpread({}, state), {}, {
71
+ showDatasourceModal: false,
72
+ datasourceModalType: undefined
66
73
  });
67
74
  };
68
75
  export default (function (state, action) {
@@ -89,7 +96,8 @@ export default (function (state, action) {
89
96
  case 'HIDE_LINK_TOOLBAR':
90
97
  return setLinkToolbar(state, action);
91
98
  case 'SHOW_DATASOURCE_MODAL':
99
+ return showDatasourceModal(state, action);
92
100
  case 'HIDE_DATASOURCE_MODAL':
93
- return setDatasourceModal(state, action);
101
+ return hideDatasourceModal(state);
94
102
  }
95
103
  });
@@ -15,7 +15,7 @@ import { changeSelectedCardToText } from './pm-plugins/doc';
15
15
  import { commandWithMetadata } from '@atlaskit/editor-common/card';
16
16
  import { pluginKey } from './pm-plugins/main';
17
17
  import { richMediaClassName } from '@atlaskit/editor-common/styles';
18
- import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig, openDatasourceModal } from './ui/EditLinkToolbar';
18
+ import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
19
19
  import { displayInfoForCard, findCardInfo, titleUrlPairFromNode, appearanceForNodeType } from './utils';
20
20
  import { isSafeUrl } from '@atlaskit/adf-schema';
21
21
  import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
@@ -163,7 +163,7 @@ var withToolbarMetadata = function withToolbarMetadata(command) {
163
163
  };
164
164
  var generateToolbarItems = function generateToolbarItems(state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) {
165
165
  return function (node) {
166
- var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs, _node$attrs2;
166
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs, _node$attrs2, _node$attrs2$datasour;
167
167
  var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
168
168
  url = _titleUrlPairFromNode2.url;
169
169
  var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.analytics) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
@@ -186,7 +186,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
186
186
  var isDatasource = currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
187
187
  var shouldRenderDatasourceToolbar = isDatasource &&
188
188
  // not showing toolbar in mobile for now since not sure what our plans are for it
189
- platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.datasource);
189
+ platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : (_node$attrs2$datasour = _node$attrs2.datasource) === null || _node$attrs2$datasour === void 0 ? void 0 : _node$attrs2$datasour.id);
190
190
 
191
191
  /* mobile builds toolbar natively using toolbarItems */
192
192
  if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar && platform !== 'mobile') {
@@ -197,12 +197,6 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
197
197
  featureFlags: featureFlags,
198
198
  pluginInjectionApi: pluginInjectionApi
199
199
  })];
200
- } else if (pluginState !== null && pluginState !== void 0 && pluginState.showDatasourceModal) {
201
- return [openDatasourceModal({
202
- state: state,
203
- node: node,
204
- editorAnalyticsApi: editorAnalyticsApi
205
- })];
206
200
  } else if (shouldRenderDatasourceToolbar) {
207
201
  return getDatasourceButtonGroup(state, metadata, intl, editorAnalyticsApi, node, hoverDecoration);
208
202
  } else {
@@ -325,7 +319,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(state, metadata
325
319
  metadata: metadata,
326
320
  className: 'datasource-edit',
327
321
  title: intl.formatMessage(linkToolbarMessages.editDatasource),
328
- onClick: editDatasource(editorAnalyticsApi)
322
+ onClick: editDatasource(node, editorAnalyticsApi)
329
323
  }];
330
324
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
331
325
  toolbarItems.push({
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { DatasourceModal } from './index';
4
+ var ModalWithState = function ModalWithState(_ref) {
5
+ var api = _ref.api,
6
+ editorView = _ref.editorView;
7
+ var _useSharedPluginState = useSharedPluginState(api, ['card']),
8
+ cardState = _useSharedPluginState.cardState;
9
+ if (!(cardState !== null && cardState !== void 0 && cardState.showDatasourceModal)) {
10
+ return null;
11
+ }
12
+ return /*#__PURE__*/React.createElement(DatasourceModal, {
13
+ view: editorView,
14
+ modalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
15
+ });
16
+ };
17
+ export default ModalWithState;
@@ -0,0 +1,49 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useCallback } from 'react';
3
+ import { JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
4
+ import { hideDatasourceModal } from '../../pm-plugins/actions';
5
+ import { updateExistingDatasource, insertDatasource } from '../../pm-plugins/doc';
6
+ import { NodeSelection } from 'prosemirror-state';
7
+ export var DatasourceModal = function DatasourceModal(_ref) {
8
+ var view = _ref.view,
9
+ modalType = _ref.modalType;
10
+ var dispatch = view.dispatch,
11
+ state = view.state;
12
+ var selection = state.selection;
13
+ var existingNode = selection instanceof NodeSelection ? selection.node : undefined;
14
+ var onClose = useCallback(function () {
15
+ dispatch(hideDatasourceModal(state.tr));
16
+ }, [dispatch, state.tr]);
17
+ var onInsert = useCallback(function (newAdf) {
18
+ if (existingNode) {
19
+ updateExistingDatasource(state, existingNode, newAdf, view);
20
+ } else {
21
+ insertDatasource(state, newAdf, view);
22
+ }
23
+ }, [existingNode, state, view]);
24
+ if (modalType === 'jira') {
25
+ var _existingNode$attrs, _tableView$properties;
26
+ var _ref2 = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs = existingNode.attrs) === null || _existingNode$attrs === void 0 ? void 0 : _existingNode$attrs.datasource) || {},
27
+ _ref2$id = _ref2.id,
28
+ datasourceId = _ref2$id === void 0 ? JIRA_LIST_OF_LINKS_DATASOURCE_ID : _ref2$id,
29
+ parameters = _ref2.parameters,
30
+ _ref2$views = _ref2.views,
31
+ views = _ref2$views === void 0 ? [] : _ref2$views;
32
+ var _ref3 = views,
33
+ _ref4 = _slicedToArray(_ref3, 1),
34
+ tableView = _ref4[0];
35
+ var visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(function (column) {
36
+ return column.key;
37
+ });
38
+ return /*#__PURE__*/React.createElement("div", {
39
+ "data-testid": "jira-config-modal"
40
+ }, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
41
+ datasourceId: datasourceId,
42
+ visibleColumnKeys: visibleColumnKeys,
43
+ parameters: parameters,
44
+ onCancel: onClose,
45
+ onInsert: onInsert
46
+ }));
47
+ }
48
+ return null; // null for now until we have modal component that handles other datasources
49
+ };
@@ -18,8 +18,8 @@ import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
18
18
  import { findCardInfo, displayInfoForCard } from '../utils';
19
19
  import { NodeSelection } from 'prosemirror-state';
20
20
  import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
21
- import { DatasourceModal } from './DatasourceModal';
22
21
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
22
+ import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
23
23
  var HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkAddToolbarWithState);
24
24
  export function HyperlinkAddToolbarWithState(_ref) {
25
25
  var _ref$linkPickerOption = _ref.linkPickerOptions,
@@ -220,11 +220,13 @@ export var editLinkToolbarConfig = function editLinkToolbarConfig(showLinkingToo
220
220
  forcePlacement: true
221
221
  } : {};
222
222
  };
223
- export var editDatasource = function editDatasource(editorAnalyticsApi) {
223
+ export var editDatasource = function editDatasource(node, editorAnalyticsApi) {
224
224
  return function (state, dispatch) {
225
- if (dispatch) {
225
+ var _node$attrs;
226
+ var modalType = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource.id) === JIRA_LIST_OF_LINKS_DATASOURCE_ID ? 'jira' : undefined;
227
+ if (dispatch && modalType) {
226
228
  var tr = state.tr;
227
- showDatasourceModal(tr);
229
+ showDatasourceModal(modalType)(tr);
228
230
  // editorAnalyticsApi?.attachAnalyticsEvent(
229
231
  // buildEditLinkPayload(
230
232
  // type as
@@ -238,25 +240,4 @@ export var editDatasource = function editDatasource(editorAnalyticsApi) {
238
240
  }
239
241
  return false;
240
242
  };
241
- };
242
- export var openDatasourceModal = function openDatasourceModal(_ref3) {
243
- var state = _ref3.state,
244
- node = _ref3.node,
245
- editorAnalyticsApi = _ref3.editorAnalyticsApi;
246
- return {
247
- type: 'custom',
248
- disableArrowNavigation: true,
249
- fallback: [],
250
- render: function render(view) {
251
- if (!view) {
252
- return null;
253
- }
254
- return /*#__PURE__*/React.createElement(DatasourceModal, {
255
- state: state,
256
- view: view,
257
- node: node,
258
- editorAnalyticsApi: editorAnalyticsApi
259
- });
260
- }
261
- };
262
243
  };
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "185.15.4";
2
+ export var version = "185.16.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.15.4",
3
+ "version": "185.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,12 @@
1
+ export declare const messages: {
2
+ datasourceJiraIssue: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ datasourceJiraIssueDescription: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ };
@@ -3,6 +3,7 @@ import { CardProvider } from '@atlaskit/editor-common/provider-factory';
3
3
  import { CardPluginAction, Request, CardInfo, SmartLinkEventsNext } from '../types';
4
4
  import { SmartLinkEvents } from '@atlaskit/smart-card';
5
5
  import { DatasourceTableLayout } from '../ui/LayoutButton/types';
6
+ import { DatasourceModalType } from '@atlaskit/editor-common/types';
6
7
  export declare const cardAction: (tr: Transaction, action: CardPluginAction) => Transaction;
7
8
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
8
9
  export declare const queueCards: (requests: Request[]) => (tr: Transaction) => Transaction;
@@ -18,5 +19,5 @@ export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTa
18
19
  }) => (tr: Transaction) => Transaction;
19
20
  export declare const showLinkToolbar: (tr: Transaction) => Transaction;
20
21
  export declare const hideLinkToolbar: (tr: Transaction) => Transaction;
21
- export declare const showDatasourceModal: (tr: Transaction) => Transaction;
22
+ export declare const showDatasourceModal: (modalType: DatasourceModalType) => (tr: Transaction) => Transaction;
22
23
  export declare const hideDatasourceModal: (tr: Transaction) => Transaction;
@@ -20,3 +20,4 @@ export declare const updateCard: (href: string, sourceEvent?: UIAnalyticsEvent |
20
20
  export declare const changeSelectedCardToText: (text: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
21
21
  export declare const setSelectedCardAppearance: (appearance: CardAppearance, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
22
22
  export declare const updateExistingDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView) => void;
23
+ export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView) => void;
@@ -24,6 +24,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
24
24
  smartLinkEventsNext?: import("../../types").SmartLinkEventsNext | undefined;
25
25
  editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
26
26
  showDatasourceModal: boolean;
27
+ datasourceModalType?: "jira" | undefined;
27
28
  datasourceTableRef?: HTMLElement | undefined;
28
29
  layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
29
30
  };
@@ -6,6 +6,7 @@ import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-c
6
6
  import type { EditorAppearance } from '@atlaskit/editor-common/types';
7
7
  import { LinkPickerOptions } from '@atlaskit/editor-common/types';
8
8
  import { DatasourceTableLayout } from './ui/LayoutButton/types';
9
+ import { DatasourceModalType } from '@atlaskit/editor-common/types';
9
10
  export type CardInfo = {
10
11
  title?: string;
11
12
  url?: string;
@@ -101,6 +102,7 @@ export type CardPluginState = {
101
102
  smartLinkEventsNext?: SmartLinkEventsNext;
102
103
  editorAppearance?: EditorAppearance;
103
104
  showDatasourceModal: boolean;
105
+ datasourceModalType?: DatasourceModalType;
104
106
  datasourceTableRef?: HTMLElement;
105
107
  layout?: DatasourceTableLayout;
106
108
  };
@@ -134,6 +136,7 @@ export type HideLinkToolbar = {
134
136
  };
135
137
  export type ShowDatasourceModal = {
136
138
  type: 'SHOW_DATASOURCE_MODAL';
139
+ modalType: DatasourceModalType;
137
140
  };
138
141
  export type HideDatasourceModal = {
139
142
  type: 'HIDE_DATASOURCE_MODAL';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type cardPlugin from '../../index';
5
+ declare const ModalWithState: ({ api, editorView, }: {
6
+ api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
7
+ editorView: EditorView;
8
+ }) => JSX.Element | null;
9
+ export default ModalWithState;