@atlaskit/editor-core 185.15.2 → 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 (149) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +16 -0
  3. package/dist/cjs/actions/index.js +1 -1
  4. package/dist/cjs/commands/index.js +1 -1
  5. package/dist/cjs/editor-next/editor-internal.js +17 -17
  6. package/dist/cjs/editor-next/hooks/useMeasureEditorMountTime.js +1 -1
  7. package/dist/cjs/editor-next/hooks/useProviderFactory.js +3 -3
  8. package/dist/cjs/editor-next/index.js +15 -15
  9. package/dist/cjs/editor-next/utils/editorMeasureTTICallback.js +2 -2
  10. package/dist/cjs/editor-next/utils/onEditorCreated.js +1 -1
  11. package/dist/cjs/editor-next/utils/sendDurationAnalytics.js +1 -1
  12. package/dist/cjs/editor.js +5 -5
  13. package/dist/cjs/messages.js +4 -4
  14. package/dist/cjs/nodeviews/context-adapter.js +1 -1
  15. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  16. package/dist/cjs/plugins/card/index.js +29 -1
  17. package/dist/cjs/plugins/card/messages.js +20 -0
  18. package/dist/cjs/plugins/card/pm-plugins/actions.js +7 -4
  19. package/dist/cjs/plugins/card/pm-plugins/doc.js +26 -7
  20. package/dist/cjs/plugins/card/pm-plugins/main.js +3 -2
  21. package/dist/cjs/plugins/card/pm-plugins/reducers.js +11 -3
  22. package/dist/cjs/plugins/card/toolbar.js +3 -9
  23. package/dist/cjs/plugins/card/ui/DatasourceModal/ModalWithState.js +25 -0
  24. package/dist/cjs/plugins/card/ui/DatasourceModal/index.js +60 -0
  25. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +8 -28
  26. package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +4 -4
  27. package/dist/cjs/test-utils.js +3 -3
  28. package/dist/cjs/version-wrapper.js +1 -1
  29. package/dist/cjs/version.json +1 -1
  30. package/dist/es2019/actions/index.js +2 -3
  31. package/dist/es2019/commands/index.js +1 -1
  32. package/dist/es2019/editor-next/editor-internal.js +6 -7
  33. package/dist/es2019/editor-next/hooks/useMeasureEditorMountTime.js +1 -1
  34. package/dist/es2019/editor-next/hooks/useProviderFactory.js +3 -3
  35. package/dist/es2019/editor-next/index.js +10 -11
  36. package/dist/es2019/editor-next/utils/editorMeasureTTICallback.js +2 -2
  37. package/dist/es2019/editor-next/utils/onEditorCreated.js +1 -1
  38. package/dist/es2019/editor-next/utils/sendDurationAnalytics.js +1 -1
  39. package/dist/es2019/editor.js +1 -1
  40. package/dist/es2019/messages.js +1 -1
  41. package/dist/es2019/nodeviews/context-adapter.js +1 -1
  42. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  43. package/dist/es2019/plugins/card/index.js +29 -1
  44. package/dist/es2019/plugins/card/messages.js +13 -0
  45. package/dist/es2019/plugins/card/pm-plugins/actions.js +3 -2
  46. package/dist/es2019/plugins/card/pm-plugins/doc.js +27 -5
  47. package/dist/es2019/plugins/card/pm-plugins/main.js +3 -2
  48. package/dist/es2019/plugins/card/pm-plugins/reducers.js +12 -3
  49. package/dist/es2019/plugins/card/toolbar.js +4 -10
  50. package/dist/es2019/plugins/card/ui/DatasourceModal/ModalWithState.js +19 -0
  51. package/dist/es2019/plugins/card/ui/DatasourceModal/index.js +48 -0
  52. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +6 -26
  53. package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +5 -5
  54. package/dist/es2019/test-utils.js +3 -3
  55. package/dist/es2019/version-wrapper.js +1 -1
  56. package/dist/es2019/version.json +1 -1
  57. package/dist/esm/actions/index.js +2 -3
  58. package/dist/esm/commands/index.js +1 -1
  59. package/dist/esm/editor-next/editor-internal.js +6 -7
  60. package/dist/esm/editor-next/hooks/useMeasureEditorMountTime.js +1 -1
  61. package/dist/esm/editor-next/hooks/useProviderFactory.js +3 -3
  62. package/dist/esm/editor-next/index.js +10 -11
  63. package/dist/esm/editor-next/utils/editorMeasureTTICallback.js +2 -2
  64. package/dist/esm/editor-next/utils/onEditorCreated.js +1 -1
  65. package/dist/esm/editor-next/utils/sendDurationAnalytics.js +1 -1
  66. package/dist/esm/editor.js +1 -1
  67. package/dist/esm/messages.js +1 -1
  68. package/dist/esm/nodeviews/context-adapter.js +1 -1
  69. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  70. package/dist/esm/plugins/card/index.js +30 -1
  71. package/dist/esm/plugins/card/messages.js +13 -0
  72. package/dist/esm/plugins/card/pm-plugins/actions.js +7 -4
  73. package/dist/esm/plugins/card/pm-plugins/doc.js +23 -5
  74. package/dist/esm/plugins/card/pm-plugins/main.js +3 -2
  75. package/dist/esm/plugins/card/pm-plugins/reducers.js +11 -3
  76. package/dist/esm/plugins/card/toolbar.js +4 -10
  77. package/dist/esm/plugins/card/ui/DatasourceModal/ModalWithState.js +17 -0
  78. package/dist/esm/plugins/card/ui/DatasourceModal/index.js +49 -0
  79. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +6 -25
  80. package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +5 -5
  81. package/dist/esm/test-utils.js +3 -3
  82. package/dist/esm/version-wrapper.js +1 -1
  83. package/dist/esm/version.json +1 -1
  84. package/dist/types/actions/index.d.ts +2 -2
  85. package/dist/types/commands/index.d.ts +2 -2
  86. package/dist/types/create-editor/get-plugins.d.ts +6 -6
  87. package/dist/types/editor-next/editor-internal.d.ts +5 -6
  88. package/dist/types/editor-next/hooks/useMeasureEditorMountTime.d.ts +1 -1
  89. package/dist/types/editor-next/hooks/useProviderFactory.d.ts +3 -3
  90. package/dist/types/editor-next/index.d.ts +2 -1
  91. package/dist/types/editor-next/utils/deprecationWarnings.d.ts +1 -1
  92. package/dist/types/editor-next/utils/handleProviders.d.ts +1 -2
  93. package/dist/types/editor-next/utils/onEditorCreated.d.ts +3 -3
  94. package/dist/types/editor-next/utils/sendDurationAnalytics.d.ts +1 -1
  95. package/dist/types/editor-next/utils/trackEditorActions.d.ts +1 -1
  96. package/dist/types/editor.d.ts +1 -1
  97. package/dist/types/messages.d.ts +1 -1
  98. package/dist/types/plugins/card/messages.d.ts +12 -0
  99. package/dist/types/plugins/card/pm-plugins/actions.d.ts +2 -1
  100. package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -0
  101. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +1 -0
  102. package/dist/types/plugins/card/types.d.ts +3 -0
  103. package/dist/types/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  104. package/dist/{types-ts4.5/plugins/card/ui/DatasourceModal.d.ts → types/plugins/card/ui/DatasourceModal/index.d.ts} +3 -5
  105. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -7
  106. package/dist/types/selection-api/api.d.ts +1 -1
  107. package/dist/types/test-utils.d.ts +3 -3
  108. package/dist/types/types/editor-appearance-component.d.ts +8 -8
  109. package/dist/types/types/editor-config.d.ts +3 -3
  110. package/dist/types/types/editor-props.d.ts +10 -10
  111. package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +1 -1
  112. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  113. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  114. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  115. package/dist/types-ts4.5/actions/index.d.ts +2 -2
  116. package/dist/types-ts4.5/commands/index.d.ts +2 -2
  117. package/dist/types-ts4.5/create-editor/get-plugins.d.ts +6 -6
  118. package/dist/types-ts4.5/editor-next/editor-internal.d.ts +5 -6
  119. package/dist/types-ts4.5/editor-next/hooks/useMeasureEditorMountTime.d.ts +1 -1
  120. package/dist/types-ts4.5/editor-next/hooks/useProviderFactory.d.ts +3 -3
  121. package/dist/types-ts4.5/editor-next/index.d.ts +2 -1
  122. package/dist/types-ts4.5/editor-next/utils/deprecationWarnings.d.ts +1 -1
  123. package/dist/types-ts4.5/editor-next/utils/handleProviders.d.ts +1 -2
  124. package/dist/types-ts4.5/editor-next/utils/onEditorCreated.d.ts +3 -3
  125. package/dist/types-ts4.5/editor-next/utils/sendDurationAnalytics.d.ts +1 -1
  126. package/dist/types-ts4.5/editor-next/utils/trackEditorActions.d.ts +1 -1
  127. package/dist/types-ts4.5/editor.d.ts +1 -1
  128. package/dist/types-ts4.5/messages.d.ts +1 -1
  129. package/dist/types-ts4.5/plugins/card/messages.d.ts +12 -0
  130. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +2 -1
  131. package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +1 -0
  132. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +1 -0
  133. package/dist/types-ts4.5/plugins/card/types.d.ts +3 -0
  134. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  135. package/dist/{types/plugins/card/ui/DatasourceModal.d.ts → types-ts4.5/plugins/card/ui/DatasourceModal/index.d.ts} +3 -5
  136. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -7
  137. package/dist/types-ts4.5/selection-api/api.d.ts +1 -1
  138. package/dist/types-ts4.5/test-utils.d.ts +3 -3
  139. package/dist/types-ts4.5/types/editor-appearance-component.d.ts +8 -8
  140. package/dist/types-ts4.5/types/editor-config.d.ts +3 -3
  141. package/dist/types-ts4.5/types/editor-props.d.ts +10 -10
  142. package/dist/types-ts4.5/ui/Appearance/FullPage/FullPageContentArea.d.ts +1 -1
  143. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  144. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  145. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  146. package/package.json +3 -3
  147. package/dist/cjs/plugins/card/ui/DatasourceModal.js +0 -41
  148. package/dist/es2019/plugins/card/ui/DatasourceModal.js +0 -30
  149. package/dist/esm/plugins/card/ui/DatasourceModal.js +0 -31
@@ -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,11 +1,11 @@
1
- import { Node as PMNode, Fragment } from 'prosemirror-model';
2
- import { InsertTypeAheadStep, InsertTypeAheadStages } from '@atlaskit/adf-schema/steps';
3
1
  import { closeHistory } from 'prosemirror-history';
4
- import { pluginKey } from '../pm-plugins/key';
5
- import { insertBlockNode, insertInlineNodeOrFragment } from '../insert-utils';
6
- import { StatsModifier } from '../stats-modifier';
2
+ import { Fragment, Node as PMNode } from 'prosemirror-model';
3
+ import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
7
4
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
5
+ import { insertBlockNode, insertInlineNodeOrFragment } from '../insert-utils';
8
6
  import { ACTIONS } from '../pm-plugins/actions';
7
+ import { pluginKey } from '../pm-plugins/key';
8
+ import { StatsModifier } from '../stats-modifier';
9
9
  import { closeTypeAhead } from '../transforms/close-type-ahead';
10
10
  import { getPluginState } from '../utils';
11
11
  const validateNode = ({
@@ -1,10 +1,10 @@
1
1
  import { TextSelection } from 'prosemirror-state';
2
- import { sortByOrder } from './create-editor/sort-by-order';
2
+ import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
3
3
  import { createSchema } from './create-editor/create-schema';
4
- import basePlugin from './plugins/base';
4
+ import { sortByOrder } from './create-editor/sort-by-order';
5
5
  import { analyticsPluginKey } from './plugins/analytics/plugin-key';
6
+ import basePlugin from './plugins/base';
6
7
  export { createTypeAheadTools } from './plugins/type-ahead/api';
7
- import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
8
8
  export function getFireAnalytics(editorView) {
9
9
  var _analyticsPluginKey$g;
10
10
  return analyticsPluginKey === null || analyticsPluginKey === void 0 ? void 0 : (_analyticsPluginKey$g = analyticsPluginKey.getState(editorView.state)) === null || _analyticsPluginKey$g === void 0 ? void 0 : _analyticsPluginKey$g.fireAnalytics;
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.15.2";
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.2",
3
+ "version": "185.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -4,16 +4,15 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { Node } from 'prosemirror-model';
7
- import { analyticsEventKey } from '@atlaskit/editor-common/utils';
8
7
  import { NodeSelection, TextSelection } from 'prosemirror-state';
9
8
  import { findParentNode, safeInsert } from 'prosemirror-utils';
9
+ import { analyticsEventKey, isEmptyDocument, processRawValue } from '@atlaskit/editor-common/utils';
10
10
  import { createDispatch } from '../event-dispatcher';
11
11
  import { getCollabProvider } from '../plugins/collab-edit/native-collab-provider-plugin';
12
12
  import { findNodePosWithLocalId } from '../plugins/extension/utils';
13
13
  import { toJSON } from '../utils';
14
- import { getEditorValueWithMedia, __temporaryFixForConfigPanel as _temporaryFixForConfigPanel } from '../utils/action';
14
+ import { __temporaryFixForConfigPanel as _temporaryFixForConfigPanel, getEditorValueWithMedia } from '../utils/action';
15
15
  import deprecationWarnings from '../utils/deprecation-warnings';
16
- import { isEmptyDocument, processRawValue } from '@atlaskit/editor-common/utils';
17
16
  import { processRawFragmentValue } from '../utils/document';
18
17
  import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
19
18
  var EditorActions = /*#__PURE__*/function () {
@@ -4,8 +4,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import { Fragment } from 'prosemirror-model';
5
5
  import { NodeSelection, Selection, TextSelection } from 'prosemirror-state';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, withAnalytics } from '../plugins/analytics';
7
8
  import { canMoveDown, canMoveUp } from '../utils';
8
- import { withAnalytics, EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../plugins/analytics';
9
9
  export function preventDefault() {
10
10
  return function () {
11
11
  return true;
@@ -2,22 +2,21 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  /** @jsx jsx */
5
-
6
- import { BaseTheme, WidthProvider } from '@atlaskit/editor-common/ui';
7
- import { jsx, css } from '@emotion/react';
8
5
  import { Fragment } from 'react';
6
+ import { css, jsx } from '@emotion/react';
7
+ import { ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
8
+ import { PortalProviderWithThemeProviders, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
9
+ import { BaseTheme, WidthProvider } from '@atlaskit/editor-common/ui';
9
10
  import { getUiComponent } from '../create-editor';
10
- import ReactEditorView from '../create-editor/ReactEditorViewNext';
11
11
  import ErrorBoundary from '../create-editor/ErrorBoundary';
12
12
  import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
13
+ import ReactEditorView from '../create-editor/ReactEditorViewNext';
13
14
  import { ContextAdapter } from '../nodeviews/context-adapter';
14
- import { ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
15
15
  import EditorContext from '../ui/EditorContext';
16
- import { PortalProviderWithThemeProviders, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
17
16
  import { RenderTracking } from '../utils/performance/components/RenderTracking';
18
- import { getBaseFontSize } from './utils/getBaseFontSize';
19
17
  import useMeasureEditorMountTime from './hooks/useMeasureEditorMountTime';
20
18
  import useProviderFactory from './hooks/useProviderFactory';
19
+ import { getBaseFontSize } from './utils/getBaseFontSize';
21
20
  /**
22
21
  * EditorInternal is used for the internal editor react component
23
22
  * with the lifecycle methods extracted into hooks.
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { useEffect } from 'react';
3
- import { clearMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
4
3
  import { ACTION } from '@atlaskit/editor-common/analytics';
4
+ import { clearMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
5
5
  import measurements from '../../utils/performance/measure-enum';
6
6
  import sendDurationAnalytics from '../utils/sendDurationAnalytics';
7
7
  import useEditorConstructor from './useEditorMeasuresConstructor';
@@ -1,11 +1,11 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
2
  import { useEffect, useRef, useState } from 'react';
4
3
  import { usePreviousState } from '@atlaskit/editor-common/hooks';
5
- import prepareQuickInsertProvider from '../../utils/prepare-quick-insert-provider';
4
+ import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
5
  import prepareExtensionProvider from '../../utils/prepare-extension-provider';
7
- import handleProviders from '../utils/handleProviders';
6
+ import prepareQuickInsertProvider from '../../utils/prepare-quick-insert-provider';
8
7
  import getProvidersFromEditorProps from '../utils/getProvidersFromEditorProps';
8
+ import handleProviders from '../utils/handleProviders';
9
9
  function createNewState(editorActions, quickInsert, extensionProviders, createAnalyticsEvent) {
10
10
  var extensionProvider = prepareExtensionProvider(function () {
11
11
  return editorActions;
@@ -10,24 +10,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
12
  /** @jsx jsx */
13
-
14
- import { WithCreateAnalyticsEvent } from '@atlaskit/editor-common/ui';
15
- import { getAnalyticsAppearance } from '@atlaskit/editor-common/utils';
13
+ import React from 'react';
16
14
  import { jsx } from '@emotion/react';
17
15
  import PropTypes from 'prop-types';
18
- import React from 'react';
19
- import { name, version } from '../version-wrapper';
20
- import { FabricEditorAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
21
16
  import uuid from 'uuid/v4';
22
- import EditorActions from '../actions';
17
+ import { FabricEditorAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
23
18
  import { fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
19
+ import { WithCreateAnalyticsEvent } from '@atlaskit/editor-common/ui';
20
+ import { getAnalyticsAppearance } from '@atlaskit/editor-common/utils';
21
+ import EditorActions from '../actions';
22
+ import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
23
+ import { basePlugin } from '../plugins';
24
+ import { name, version } from '../version-wrapper';
24
25
  import EditorInternal from './editor-internal';
26
+ import deprecationWarnings from './utils/deprecationWarnings';
25
27
  import { propTypes } from './utils/editorPropTypes';
26
- import trackEditorActions from './utils/trackEditorActions';
27
28
  import _onEditorCreated from './utils/onEditorCreated';
28
- import deprecationWarnings from './utils/deprecationWarnings';
29
- import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
30
- import { basePlugin } from '../plugins';
29
+ import trackEditorActions from './utils/trackEditorActions';
31
30
  var EditorNext = /*#__PURE__*/function (_React$Component) {
32
31
  _inherits(EditorNext, _React$Component);
33
32
  var _super = _createSuper(EditorNext);
@@ -1,6 +1,6 @@
1
- import { getTTISeverity } from '@atlaskit/editor-common/utils';
2
- import { EditorExperience } from '@atlaskit/editor-common/ufo';
3
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { EditorExperience } from '@atlaskit/editor-common/ufo';
3
+ import { getTTISeverity } from '@atlaskit/editor-common/utils';
4
4
  export default function editorMeasureTTICallback(tti, ttiFromInvocation, canceled, performanceTracking, featureFlags, createAnalyticsEvent, experienceStore) {
5
5
  var _performanceTracking$;
6
6
  if (performanceTracking !== null && performanceTracking !== void 0 && (_performanceTracking$ = performanceTracking.ttiTracking) !== null && _performanceTracking$ !== void 0 && _performanceTracking$.enabled && createAnalyticsEvent) {
@@ -1,6 +1,6 @@
1
+ import { ACTION } from '@atlaskit/editor-common/analytics';
1
2
  import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
2
3
  import { startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
3
- import { ACTION } from '@atlaskit/editor-common/analytics';
4
4
  import measurements from '../../utils/performance/measure-enum';
5
5
  import sendDurationAnalytics from './sendDurationAnalytics';
6
6
  export default function onEditorCreated(instance, props, setExperienceStore, getExperienceStore, getCreateAnalyticsEvent, editorActions, startTime, registerEditorForActions) {
@@ -1,7 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { EditorExperience } from '@atlaskit/editor-common/ufo';
4
3
  import { ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import { EditorExperience } from '@atlaskit/editor-common/ufo';
5
5
  /**
6
6
  *
7
7
  * Util function to be used with the Editor component to send duration analytics
@@ -8,8 +8,8 @@ import _extends from "@babel/runtime/helpers/extends";
8
8
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
  /** @jsx jsx */
11
- import { jsx } from '@emotion/react';
12
11
  import React from 'react';
12
+ import { jsx } from '@emotion/react';
13
13
  import { defaultProps } from './editor-next/utils/editorPropTypes';
14
14
  import EditorNext from './editor-next';
15
15
  import useUniversalPreset from './labs/next/presets/useUniversalPreset';
@@ -1,7 +1,7 @@
1
1
  // Common Translations will live here
2
2
  import commonMessages, { linkMessages, linkToolbarMessages } from '@atlaskit/editor-common/messages';
3
- import { messages as statusMessages } from './plugins/status/nodeviews/messages';
4
3
  import { messages as dateMessages } from './plugins/date/nodeviews/messages';
4
+ import { messages as statusMessages } from './plugins/status/nodeviews/messages';
5
5
  export { linkMessages };
6
6
  export { statusMessages };
7
7
  export { dateMessages };
@@ -9,8 +9,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
  import React from 'react';
11
11
  import PropTypes from 'prop-types';
12
- import { SmartCardContext } from '@atlaskit/link-provider';
13
12
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
13
+ import { SmartCardContext } from '@atlaskit/link-provider';
14
14
  function useContextMemoized(reactContext) {
15
15
  var value = React.useContext(reactContext);
16
16
  var context = React.useMemo(function () {
@@ -1,8 +1,8 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { css } from '@emotion/react';
4
- import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
5
4
  import { inlineNodeViewClassname } from '@atlaskit/editor-common/react-node-view';
5
+ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
6
6
 
7
7
  // For reasoning behind styles, see comments in:
8
8
  // ./getInlineNodeViewProducer -> portalChildren()
@@ -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;