@atlaskit/editor-plugin-card 4.5.0 → 4.5.1

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 (56) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/nodeviews/blockCard.js +0 -4
  3. package/dist/cjs/nodeviews/datasource.js +14 -26
  4. package/dist/cjs/nodeviews/embedCard.js +4 -15
  5. package/dist/cjs/nodeviews/genericCard.js +17 -19
  6. package/dist/cjs/ui/DatasourceAppearanceButton.js +11 -13
  7. package/dist/cjs/ui/DatasourceModal/ModalWithState.js +16 -10
  8. package/dist/cjs/ui/EditToolbarButton/index.js +26 -28
  9. package/dist/cjs/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
  10. package/dist/cjs/ui/LinkToolbarAppearance.js +5 -6
  11. package/dist/cjs/ui/ToolbarViewedEvent.js +7 -9
  12. package/dist/cjs/ui/WithCardContext.js +14 -0
  13. package/dist/es2019/nodeviews/blockCard.js +0 -4
  14. package/dist/es2019/nodeviews/datasource.js +14 -26
  15. package/dist/es2019/nodeviews/embedCard.js +4 -16
  16. package/dist/es2019/nodeviews/genericCard.js +5 -9
  17. package/dist/es2019/ui/DatasourceAppearanceButton.js +4 -5
  18. package/dist/es2019/ui/DatasourceModal/ModalWithState.js +14 -6
  19. package/dist/es2019/ui/EditToolbarButton/index.js +26 -29
  20. package/dist/es2019/ui/EditorLinkingPlatformAnalytics/index.js +4 -23
  21. package/dist/es2019/ui/LinkToolbarAppearance.js +3 -6
  22. package/dist/es2019/ui/ToolbarViewedEvent.js +4 -5
  23. package/dist/es2019/ui/WithCardContext.js +8 -0
  24. package/dist/esm/nodeviews/blockCard.js +0 -4
  25. package/dist/esm/nodeviews/datasource.js +14 -26
  26. package/dist/esm/nodeviews/embedCard.js +4 -15
  27. package/dist/esm/nodeviews/genericCard.js +17 -19
  28. package/dist/esm/ui/DatasourceAppearanceButton.js +11 -13
  29. package/dist/esm/ui/DatasourceModal/ModalWithState.js +16 -10
  30. package/dist/esm/ui/EditToolbarButton/index.js +26 -28
  31. package/dist/esm/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
  32. package/dist/esm/ui/LinkToolbarAppearance.js +6 -6
  33. package/dist/esm/ui/ToolbarViewedEvent.js +7 -9
  34. package/dist/esm/ui/WithCardContext.js +7 -0
  35. package/dist/types/nodeviews/blockCard.d.ts +0 -4
  36. package/dist/types/nodeviews/datasource.d.ts +0 -5
  37. package/dist/types/nodeviews/embedCard.d.ts +0 -5
  38. package/dist/types/ui/DatasourceAppearanceButton.d.ts +1 -1
  39. package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +4 -3
  40. package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
  41. package/dist/types/ui/LinkToolbarAppearance.d.ts +1 -6
  42. package/dist/types/ui/WithCardContext.d.ts +5 -0
  43. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +0 -4
  44. package/dist/types-ts4.5/nodeviews/datasource.d.ts +0 -5
  45. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +0 -5
  46. package/dist/types-ts4.5/ui/DatasourceAppearanceButton.d.ts +1 -1
  47. package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +4 -3
  48. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
  49. package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +1 -6
  50. package/dist/types-ts4.5/ui/WithCardContext.d.ts +5 -0
  51. package/package.json +1 -1
  52. package/dist/cjs/ui/CardContextProvider.js +0 -47
  53. package/dist/es2019/ui/CardContextProvider.js +0 -22
  54. package/dist/esm/ui/CardContextProvider.js +0 -40
  55. package/dist/types/ui/CardContextProvider.d.ts +0 -20
  56. package/dist/types-ts4.5/ui/CardContextProvider.d.ts +0 -20
@@ -9,7 +9,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  import React, { useCallback } from 'react';
12
- import PropTypes from 'prop-types';
13
12
  import { isSafeUrl } from '@atlaskit/adf-schema';
14
13
  import { AnalyticsContext } from '@atlaskit/analytics-next';
15
14
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -17,6 +16,7 @@ import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
17
16
  import { fg } from '@atlaskit/platform-feature-flags';
18
17
  import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
19
18
  import { getPluginState } from '../pm-plugins/util/state';
19
+ import { WithCardContext } from '../ui/WithCardContext';
20
20
  import { titleUrlPairFromNode } from '../utils';
21
21
  var WithClickHandler = function WithClickHandler(_ref) {
22
22
  var pluginInjectionApi = _ref.pluginInjectionApi,
@@ -58,13 +58,12 @@ var WithClickHandler = function WithClickHandler(_ref) {
58
58
  }));
59
59
  };
60
60
  export function Card(SmartCardComponent, UnsupportedComponent) {
61
- var _class;
62
- return _class = /*#__PURE__*/function (_React$Component) {
63
- _inherits(_class, _React$Component);
64
- var _super = _createSuper(_class);
65
- function _class() {
61
+ return /*#__PURE__*/function (_React$Component) {
62
+ _inherits(_class2, _React$Component);
63
+ var _super = _createSuper(_class2);
64
+ function _class2() {
66
65
  var _this;
67
- _classCallCheck(this, _class);
66
+ _classCallCheck(this, _class2);
68
67
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
69
68
  args[_key] = arguments[_key];
70
69
  }
@@ -74,7 +73,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
74
73
  });
75
74
  return _this;
76
75
  }
77
- _createClass(_class, [{
76
+ _createClass(_class2, [{
78
77
  key: "render",
79
78
  value: function render() {
80
79
  var _getPluginState,
@@ -99,7 +98,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
99
98
  return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
100
99
  }
101
100
  }
102
- var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
103
101
  var editorAppearance = (_getPluginState = getPluginState(this.props.view.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
104
102
  var analyticsEditorAppearance = getAnalyticsEditorAppearance(editorAppearance);
105
103
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
@@ -117,12 +115,14 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
117
115
  __livePage: this.props.__livePage
118
116
  }, function (_ref2) {
119
117
  var onClick = _ref2.onClick;
120
- return /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
121
- key: url,
122
- cardContext: cardContext
123
- }, _this2.props, {
124
- onClick: onClick
125
- }));
118
+ return /*#__PURE__*/React.createElement(WithCardContext, null, function (cardContext) {
119
+ return /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
120
+ key: url,
121
+ cardContext: cardContext
122
+ }, _this2.props, {
123
+ onClick: onClick
124
+ }));
125
+ });
126
126
  }));
127
127
  }
128
128
  }, {
@@ -159,8 +159,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
159
159
  }
160
160
  }
161
161
  }]);
162
- return _class;
163
- }(React.Component), _defineProperty(_class, "contextTypes", {
164
- contextAdapter: PropTypes.object
165
- }), _class;
162
+ return _class2;
163
+ }(React.Component);
166
164
  }
@@ -11,10 +11,10 @@ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
11
11
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
12
12
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
13
13
  import { buildDatasourceAdf } from '@atlaskit/link-datasource';
14
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
14
15
  import { Flex } from '@atlaskit/primitives';
15
16
  import { updateCardViaDatasource } from '../pm-plugins/doc';
16
17
  import { pluginKey } from '../pm-plugins/plugin-key';
17
- import { CardContextProvider } from './CardContextProvider';
18
18
  import { DatasourceIcon } from './DatasourceIcon';
19
19
  import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
20
20
  var buttonStyles = css({
@@ -105,17 +105,15 @@ export var DatasourceAppearanceButton = function DatasourceAppearanceButton(_ref
105
105
  editorState = _ref2.editorState,
106
106
  selected = _ref2.selected,
107
107
  inputMethod = _ref2.inputMethod;
108
- return jsx(CardContextProvider, null, function (_ref3) {
109
- var cardContext = _ref3.cardContext;
110
- return jsx(DatasourceAppearanceButtonWithCardContext, {
111
- url: url,
112
- intl: intl,
113
- editorAnalyticsApi: editorAnalyticsApi,
114
- editorView: editorView,
115
- editorState: editorState,
116
- cardContext: cardContext,
117
- selected: selected,
118
- inputMethod: inputMethod
119
- });
108
+ var cardContext = useSmartLinkContext();
109
+ return jsx(DatasourceAppearanceButtonWithCardContext, {
110
+ url: url,
111
+ intl: intl,
112
+ editorAnalyticsApi: editorAnalyticsApi,
113
+ editorView: editorView,
114
+ editorState: editorState,
115
+ cardContext: cardContext,
116
+ selected: selected,
117
+ inputMethod: inputMethod
120
118
  });
121
119
  };
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
4
+ import { EditorSmartCardProviderValueGuard, useSmartLinkContext } from '@atlaskit/link-provider';
4
5
  import { DatasourceErrorBoundary } from '../../datasourceErrorBoundary';
5
- import { CardContextProvider } from '../CardContextProvider';
6
6
  import { DatasourceModal } from './index';
7
7
  var ModalWithState = function ModalWithState(_ref) {
8
8
  var api = _ref.api,
9
9
  editorView = _ref.editorView;
10
+ var cardContext = useSmartLinkContext();
10
11
  var _useSharedPluginState = useSharedPluginState(api, ['card']),
11
12
  cardState = _useSharedPluginState.cardState;
12
13
  if (!cardState) {
@@ -23,16 +24,21 @@ var ModalWithState = function ModalWithState(_ref) {
23
24
  return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
24
25
  view: editorView,
25
26
  datasourceModalType: datasourceModalType
26
- }, /*#__PURE__*/React.createElement(CardContextProvider, null, function (_ref2) {
27
- var cardContext = _ref2.cardContext;
28
- return /*#__PURE__*/React.createElement(DatasourceModal, {
29
- view: editorView,
30
- cardContext: cardContext,
31
- datasourceId: datasourceId,
32
- componentType: componentType
33
- });
27
+ }, /*#__PURE__*/React.createElement(DatasourceModal, {
28
+ view: editorView,
29
+ cardContext: cardContext,
30
+ datasourceId: datasourceId,
31
+ componentType: componentType
34
32
  }));
35
33
  };
34
+ var SafeModalWithState = /*#__PURE__*/React.memo(function (_ref2) {
35
+ var api = _ref2.api,
36
+ editorView = _ref2.editorView;
37
+ return /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(ModalWithState, {
38
+ api: api,
39
+ editorView: editorView
40
+ }));
41
+ });
36
42
  export var modalTypeToComponentMap = {
37
43
  jira: {
38
44
  componentType: JiraIssuesConfigModal,
@@ -47,4 +53,4 @@ export var modalTypeToComponentMap = {
47
53
  datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
48
54
  }
49
55
  };
50
- export default ModalWithState;
56
+ export default SafeModalWithState;
@@ -14,10 +14,10 @@ import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-
14
14
  import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
15
15
  import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
16
16
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
17
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
17
18
  import { ButtonItem } from '@atlaskit/menu';
18
19
  import { Flex } from '@atlaskit/primitives';
19
20
  import { focusEditorView, isDatasourceConfigEditable } from '../../utils';
20
- import { CardContextProvider } from '../CardContextProvider';
21
21
  import { editDatasource } from '../editDatasourceAction';
22
22
  import { useFetchDatasourceDataInfo } from '../useFetchDatasourceDataInfo';
23
23
  import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
@@ -244,34 +244,11 @@ export var EditToolbarButton = function EditToolbarButton(props) {
244
244
  intl = props.intl,
245
245
  onLinkEditClick = props.onLinkEditClick,
246
246
  url = props.url;
247
- return jsx(CardContextProvider, null, function (_ref) {
248
- var cardContext = _ref.cardContext;
249
- if (props.url) {
250
- return jsx(EditToolbarButtonWithUrl, {
251
- datasourceId: datasourceId,
252
- url: props.url,
253
- intl: intl,
254
- editorAnalyticsApi: editorAnalyticsApi,
255
- editorView: editorView,
256
- cardContext: cardContext,
257
- onLinkEditClick: onLinkEditClick,
258
- currentAppearance: currentAppearance
259
- });
260
- }
261
- if (props.datasourceId && props.node) {
262
- return jsx(EditToolbarButtonWithDatasourceId, {
263
- datasourceId: props.datasourceId,
264
- node: props.node,
265
- intl: intl,
266
- editorAnalyticsApi: editorAnalyticsApi,
267
- editorView: editorView,
268
- onLinkEditClick: onLinkEditClick,
269
- currentAppearance: currentAppearance
270
- });
271
- }
272
- return jsx(EditToolbarButtonWithCardContext, {
247
+ var cardContext = useSmartLinkContext();
248
+ if (props.url) {
249
+ return jsx(EditToolbarButtonWithUrl, {
273
250
  datasourceId: datasourceId,
274
- url: url,
251
+ url: props.url,
275
252
  intl: intl,
276
253
  editorAnalyticsApi: editorAnalyticsApi,
277
254
  editorView: editorView,
@@ -279,5 +256,26 @@ export var EditToolbarButton = function EditToolbarButton(props) {
279
256
  onLinkEditClick: onLinkEditClick,
280
257
  currentAppearance: currentAppearance
281
258
  });
259
+ }
260
+ if (props.datasourceId && props.node) {
261
+ return jsx(EditToolbarButtonWithDatasourceId, {
262
+ datasourceId: props.datasourceId,
263
+ node: props.node,
264
+ intl: intl,
265
+ editorAnalyticsApi: editorAnalyticsApi,
266
+ editorView: editorView,
267
+ onLinkEditClick: onLinkEditClick,
268
+ currentAppearance: currentAppearance
269
+ });
270
+ }
271
+ return jsx(EditToolbarButtonWithCardContext, {
272
+ datasourceId: datasourceId,
273
+ url: url,
274
+ intl: intl,
275
+ editorAnalyticsApi: editorAnalyticsApi,
276
+ editorView: editorView,
277
+ cardContext: cardContext,
278
+ onLinkEditClick: onLinkEditClick,
279
+ currentAppearance: currentAppearance
282
280
  });
283
281
  };
@@ -3,11 +3,10 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
6
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
8
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
8
  import React from 'react';
10
- import PropTypes from 'prop-types';
9
+ import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
11
10
  import { EditorAnalyticsContext } from '../EditorAnalyticsContext';
12
11
  import { DatasourceEventsBinding } from './DatasourceEvents';
13
12
  import { LinkEventsBinding } from './LinkEvents';
@@ -22,30 +21,11 @@ export var EditorLinkingPlatformAnalytics = /*#__PURE__*/function (_React$PureCo
22
21
  }
23
22
  _createClass(EditorLinkingPlatformAnalytics, [{
24
23
  key: "render",
25
- value:
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
-
28
- function render() {
29
- var _this$context;
30
- var cardContext = (_this$context = this.context) === null || _this$context === void 0 || (_this$context = _this$context.contextAdapter) === null || _this$context === void 0 ? void 0 : _this$context.card;
31
-
32
- /**
33
- * The analytics hook needs to be able to communicate with the card context
34
- * If we can't access it, don't mount the event bindings
35
- * This effectively entirely disables all tracking behaviour
36
- */
37
- if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
38
- return null;
39
- }
40
- return /*#__PURE__*/React.createElement(cardContext.Provider, {
41
- value: cardContext.value
42
- }, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
24
+ value: function render() {
25
+ return /*#__PURE__*/React.createElement(EditorSmartCardProvider, null, /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
43
26
  editorView: this.props.editorView
44
- }, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props)));
27
+ }, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props))));
45
28
  }
46
29
  }]);
47
30
  return EditorLinkingPlatformAnalytics;
48
- }(React.PureComponent);
49
- _defineProperty(EditorLinkingPlatformAnalytics, "contextTypes", {
50
- contextAdapter: PropTypes.object
51
- });
31
+ }(React.PureComponent);
@@ -10,7 +10,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
11
11
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
12
  import React from 'react';
13
- import PropTypes from 'prop-types';
14
13
  import { AnalyticsContext } from '@atlaskit/analytics-next';
15
14
  import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
15
  import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } from '@atlaskit/editor-common/card';
@@ -22,7 +21,9 @@ import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugi
22
21
  import { shouldRenderToolbarPulse } from '../toolbar';
23
22
  import { getResolvedAttributesFromStore } from '../utils';
24
23
  import { DiscoveryPulse } from './Pulse';
24
+ import { WithCardContext } from './WithCardContext';
25
25
  // eslint-disable-next-line @repo/internal/react/no-class-components
26
+
26
27
  export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
27
28
  _inherits(LinkToolbarAppearance, _React$Component);
28
29
  var _super = _createSuper(LinkToolbarAppearance);
@@ -136,16 +137,15 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
136
137
  _createClass(LinkToolbarAppearance, [{
137
138
  key: "render",
138
139
  value: function render() {
139
- var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
140
+ var _this2 = this;
140
141
  var editorView = this.props.editorView;
141
- return this.renderDropdown(editorView, cardContext && cardContext.value);
142
+ return /*#__PURE__*/React.createElement(WithCardContext, null, function (cardContext) {
143
+ return _this2.renderDropdown(editorView, cardContext && cardContext.value);
144
+ });
142
145
  }
143
146
  }]);
144
147
  return LinkToolbarAppearance;
145
148
  }(React.Component);
146
- _defineProperty(LinkToolbarAppearance, "contextTypes", {
147
- contextAdapter: PropTypes.object
148
- });
149
149
  var getUnavailableMessage = function getUnavailableMessage(state, intl) {
150
150
  try {
151
151
  var parentNode = state.selection.$from.node(1);
@@ -3,8 +3,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import React, { useEffect } from 'react';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
6
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
6
7
  import { getResolvedAttributesFromStore } from '../utils';
7
- import { CardContextProvider } from './CardContextProvider';
8
8
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
9
9
  /**
10
10
  * Handles firing the toolbar viewed event
@@ -37,14 +37,12 @@ export var ToolbarViewedEvent = function ToolbarViewedEvent(_ref2) {
37
37
  var url = _ref2.url,
38
38
  display = _ref2.display,
39
39
  editorView = _ref2.editorView;
40
+ var cardContext = useSmartLinkContext();
40
41
  return /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
41
42
  editorView: editorView
42
- }, /*#__PURE__*/React.createElement(CardContextProvider, null, function (_ref3) {
43
- var cardContext = _ref3.cardContext;
44
- return url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
45
- url: url,
46
- display: display,
47
- cardContext: cardContext
48
- }) : null;
49
- }));
43
+ }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
44
+ url: url,
45
+ display: display,
46
+ cardContext: cardContext
47
+ }) : null);
50
48
  };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { useSmartCardContext } from '@atlaskit/link-provider';
3
+ export var WithCardContext = function WithCardContext(_ref) {
4
+ var children = _ref.children;
5
+ var cardContext = useSmartCardContext();
6
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children(cardContext));
7
+ };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import ReactNodeView, { type getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
4
3
  import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
5
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
@@ -8,9 +7,6 @@ import { Datasource } from '../nodeviews/datasource';
8
7
  import type { SmartCardProps } from './genericCard';
9
8
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
10
9
  private scrollContainer?;
11
- static contextTypes: {
12
- contextAdapter: PropTypes.Requireable<object>;
13
- };
14
10
  constructor(props: SmartCardProps);
15
11
  onResolve: (data: {
16
12
  url?: string | undefined;
@@ -4,7 +4,6 @@
4
4
  */
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- import PropTypes from 'prop-types';
8
7
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
9
8
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
10
9
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
@@ -25,10 +24,6 @@ export interface DatasourceProps extends ReactComponentProps {
25
24
  interface DatasourceComponentProps extends ReactComponentProps, Pick<DatasourceProps, 'node' | 'view' | 'getPos'> {
26
25
  }
27
26
  export declare class DatasourceComponent extends React.PureComponent<DatasourceComponentProps> {
28
- static contextTypes: {
29
- contextAdapter: PropTypes.Requireable<object>;
30
- };
31
- context: any;
32
27
  constructor(props: DatasourceComponentProps);
33
28
  private getDatasource;
34
29
  private getTableView;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
4
3
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
4
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
@@ -16,10 +15,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
16
15
  private scrollContainer?;
17
16
  private embedIframeRef;
18
17
  constructor(props: SmartCardProps);
19
- context: any;
20
- static contextTypes: {
21
- contextAdapter: PropTypes.Requireable<object>;
22
- };
23
18
  state: EmbedCardState;
24
19
  private getPosSafely;
25
20
  onResolve: (data: {
@@ -3,7 +3,7 @@ import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import type { CardContext } from '@atlaskit/link-provider';
6
+ import { type CardContext } from '@atlaskit/link-provider';
7
7
  export interface DatasourceAppearanceButtonProps {
8
8
  intl: IntlShape;
9
9
  editorAnalyticsApi?: EditorAnalyticsAPI;
@@ -5,10 +5,11 @@ import type { ConfigModalProps } from '@atlaskit/link-datasource';
5
5
  import type { DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
6
6
  import type { DatasourceParameters } from '@atlaskit/linking-types';
7
7
  import type { cardPlugin } from '../../plugin';
8
- declare const ModalWithState: ({ api, editorView, }: {
8
+ type ModalWithStateProps = {
9
9
  api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
10
10
  editorView: EditorView;
11
- }) => JSX.Element | null;
11
+ };
12
+ declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => JSX.Element>;
12
13
  export type ModalTypeToComponentMap = {
13
14
  componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
14
15
  datasourceId: string;
@@ -16,4 +17,4 @@ export type ModalTypeToComponentMap = {
16
17
  export declare const modalTypeToComponentMap: {
17
18
  [key in DatasourceModalType]: ModalTypeToComponentMap;
18
19
  };
19
- export default ModalWithState;
20
+ export default SafeModalWithState;
@@ -1,10 +1,5 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { AnalyticsBindingsProps } from './common';
4
3
  export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
5
- static contextTypes: {
6
- contextAdapter: PropTypes.Requireable<object>;
7
- };
8
- context: any;
9
- render(): JSX.Element | null;
4
+ render(): JSX.Element;
10
5
  }
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { IntlShape } from 'react-intl-next';
4
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
4
  import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
@@ -19,10 +18,6 @@ export interface LinkToolbarAppearanceProps {
19
18
  isDatasourceView?: boolean;
20
19
  }
21
20
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
22
- static contextTypes: {
23
- contextAdapter: PropTypes.Requireable<object>;
24
- };
25
- context: any;
26
21
  renderDropdown: (view?: EditorView, cardContext?: CardContext) => JSX.Element | null;
27
- render(): JSX.Element | null;
22
+ render(): JSX.Element;
28
23
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { useSmartCardContext } from '@atlaskit/link-provider';
3
+ export declare const WithCardContext: ({ children, }: {
4
+ children: (cardContext: ReturnType<typeof useSmartCardContext>) => React.ReactNode;
5
+ }) => JSX.Element;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import ReactNodeView, { type getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
4
3
  import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
5
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
@@ -8,9 +7,6 @@ import { Datasource } from '../nodeviews/datasource';
8
7
  import type { SmartCardProps } from './genericCard';
9
8
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
10
9
  private scrollContainer?;
11
- static contextTypes: {
12
- contextAdapter: PropTypes.Requireable<object>;
13
- };
14
10
  constructor(props: SmartCardProps);
15
11
  onResolve: (data: {
16
12
  url?: string | undefined;
@@ -4,7 +4,6 @@
4
4
  */
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- import PropTypes from 'prop-types';
8
7
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
9
8
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
10
9
  import type { getPosHandler, ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
@@ -25,10 +24,6 @@ export interface DatasourceProps extends ReactComponentProps {
25
24
  interface DatasourceComponentProps extends ReactComponentProps, Pick<DatasourceProps, 'node' | 'view' | 'getPos'> {
26
25
  }
27
26
  export declare class DatasourceComponent extends React.PureComponent<DatasourceComponentProps> {
28
- static contextTypes: {
29
- contextAdapter: PropTypes.Requireable<object>;
30
- };
31
- context: any;
32
27
  constructor(props: DatasourceComponentProps);
33
28
  private getDatasource;
34
29
  private getTableView;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
4
3
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
4
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
@@ -16,10 +15,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
16
15
  private scrollContainer?;
17
16
  private embedIframeRef;
18
17
  constructor(props: SmartCardProps);
19
- context: any;
20
- static contextTypes: {
21
- contextAdapter: PropTypes.Requireable<object>;
22
- };
23
18
  state: EmbedCardState;
24
19
  private getPosSafely;
25
20
  onResolve: (data: {
@@ -3,7 +3,7 @@ import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import type { CardContext } from '@atlaskit/link-provider';
6
+ import { type CardContext } from '@atlaskit/link-provider';
7
7
  export interface DatasourceAppearanceButtonProps {
8
8
  intl: IntlShape;
9
9
  editorAnalyticsApi?: EditorAnalyticsAPI;
@@ -5,10 +5,11 @@ import type { ConfigModalProps } from '@atlaskit/link-datasource';
5
5
  import type { DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
6
6
  import type { DatasourceParameters } from '@atlaskit/linking-types';
7
7
  import type { cardPlugin } from '../../plugin';
8
- declare const ModalWithState: ({ api, editorView, }: {
8
+ type ModalWithStateProps = {
9
9
  api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
10
10
  editorView: EditorView;
11
- }) => JSX.Element | null;
11
+ };
12
+ declare const SafeModalWithState: React.MemoExoticComponent<({ api, editorView }: ModalWithStateProps) => JSX.Element>;
12
13
  export type ModalTypeToComponentMap = {
13
14
  componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
14
15
  datasourceId: string;
@@ -16,4 +17,4 @@ export type ModalTypeToComponentMap = {
16
17
  export declare const modalTypeToComponentMap: {
17
18
  [key in DatasourceModalType]: ModalTypeToComponentMap;
18
19
  };
19
- export default ModalWithState;
20
+ export default SafeModalWithState;
@@ -1,10 +1,5 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { AnalyticsBindingsProps } from './common';
4
3
  export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
5
- static contextTypes: {
6
- contextAdapter: PropTypes.Requireable<object>;
7
- };
8
- context: any;
9
- render(): JSX.Element | null;
4
+ render(): JSX.Element;
10
5
  }
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type { IntlShape } from 'react-intl-next';
4
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
4
  import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
@@ -19,10 +18,6 @@ export interface LinkToolbarAppearanceProps {
19
18
  isDatasourceView?: boolean;
20
19
  }
21
20
  export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
22
- static contextTypes: {
23
- contextAdapter: PropTypes.Requireable<object>;
24
- };
25
- context: any;
26
21
  renderDropdown: (view?: EditorView, cardContext?: CardContext) => JSX.Element | null;
27
- render(): JSX.Element | null;
22
+ render(): JSX.Element;
28
23
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { useSmartCardContext } from '@atlaskit/link-provider';
3
+ export declare const WithCardContext: ({ children, }: {
4
+ children: (cardContext: ReturnType<typeof useSmartCardContext>) => React.ReactNode;
5
+ }) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",