@atlaskit/editor-plugin-card 4.4.13 → 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 (64) hide show
  1. package/CHANGELOG.md +20 -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/plugin.js +4 -0
  7. package/dist/cjs/toolbar.js +30 -4
  8. package/dist/cjs/ui/DatasourceAppearanceButton.js +11 -13
  9. package/dist/cjs/ui/DatasourceModal/ModalWithState.js +16 -10
  10. package/dist/cjs/ui/EditToolbarButton/index.js +26 -28
  11. package/dist/cjs/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
  12. package/dist/cjs/ui/LinkToolbarAppearance.js +5 -6
  13. package/dist/cjs/ui/ToolbarViewedEvent.js +7 -9
  14. package/dist/cjs/ui/WithCardContext.js +14 -0
  15. package/dist/es2019/nodeviews/blockCard.js +0 -4
  16. package/dist/es2019/nodeviews/datasource.js +14 -26
  17. package/dist/es2019/nodeviews/embedCard.js +4 -16
  18. package/dist/es2019/nodeviews/genericCard.js +5 -9
  19. package/dist/es2019/plugin.js +5 -0
  20. package/dist/es2019/toolbar.js +31 -5
  21. package/dist/es2019/ui/DatasourceAppearanceButton.js +4 -5
  22. package/dist/es2019/ui/DatasourceModal/ModalWithState.js +14 -6
  23. package/dist/es2019/ui/EditToolbarButton/index.js +26 -29
  24. package/dist/es2019/ui/EditorLinkingPlatformAnalytics/index.js +4 -23
  25. package/dist/es2019/ui/LinkToolbarAppearance.js +3 -6
  26. package/dist/es2019/ui/ToolbarViewedEvent.js +4 -5
  27. package/dist/es2019/ui/WithCardContext.js +8 -0
  28. package/dist/esm/nodeviews/blockCard.js +0 -4
  29. package/dist/esm/nodeviews/datasource.js +14 -26
  30. package/dist/esm/nodeviews/embedCard.js +4 -15
  31. package/dist/esm/nodeviews/genericCard.js +17 -19
  32. package/dist/esm/plugin.js +5 -0
  33. package/dist/esm/toolbar.js +31 -5
  34. package/dist/esm/ui/DatasourceAppearanceButton.js +11 -13
  35. package/dist/esm/ui/DatasourceModal/ModalWithState.js +16 -10
  36. package/dist/esm/ui/EditToolbarButton/index.js +26 -28
  37. package/dist/esm/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
  38. package/dist/esm/ui/LinkToolbarAppearance.js +6 -6
  39. package/dist/esm/ui/ToolbarViewedEvent.js +7 -9
  40. package/dist/esm/ui/WithCardContext.js +7 -0
  41. package/dist/types/nodeviews/blockCard.d.ts +0 -4
  42. package/dist/types/nodeviews/datasource.d.ts +0 -5
  43. package/dist/types/nodeviews/embedCard.d.ts +0 -5
  44. package/dist/types/plugin.d.ts +12 -2
  45. package/dist/types/ui/DatasourceAppearanceButton.d.ts +1 -1
  46. package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +4 -3
  47. package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
  48. package/dist/types/ui/LinkToolbarAppearance.d.ts +1 -6
  49. package/dist/types/ui/WithCardContext.d.ts +5 -0
  50. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +0 -4
  51. package/dist/types-ts4.5/nodeviews/datasource.d.ts +0 -5
  52. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +0 -5
  53. package/dist/types-ts4.5/plugin.d.ts +12 -2
  54. package/dist/types-ts4.5/ui/DatasourceAppearanceButton.d.ts +1 -1
  55. package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +4 -3
  56. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
  57. package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +1 -6
  58. package/dist/types-ts4.5/ui/WithCardContext.d.ts +5 -0
  59. package/package.json +9 -6
  60. package/dist/cjs/ui/CardContextProvider.js +0 -47
  61. package/dist/es2019/ui/CardContextProvider.js +0 -22
  62. package/dist/esm/ui/CardContextProvider.js +0 -40
  63. package/dist/types/ui/CardContextProvider.d.ts +0 -20
  64. package/dist/types-ts4.5/ui/CardContextProvider.d.ts +0 -20
@@ -19,12 +19,12 @@ import React from 'react';
19
19
 
20
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
21
21
  import { jsx } from '@emotion/react';
22
- import PropTypes from 'prop-types';
23
22
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
24
23
  import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
25
24
  import { UnsupportedInline } from '@atlaskit/editor-common/ui';
26
25
  import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
27
26
  import { DatasourceTableView } from '@atlaskit/link-datasource';
27
+ import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
28
28
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
29
29
  import { fg } from '@atlaskit/platform-feature-flags';
30
30
  import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
@@ -43,8 +43,6 @@ var getPosSafely = function getPosSafely(pos) {
43
43
  export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
44
44
  _inherits(DatasourceComponent, _React$PureComponent);
45
45
  var _super = _createSuper(DatasourceComponent);
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
-
48
46
  function DatasourceComponent(props) {
49
47
  var _this;
50
48
  _classCallCheck(this, DatasourceComponent);
@@ -180,7 +178,6 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
180
178
  }, {
181
179
  key: "render",
182
180
  value: function render() {
183
- var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
184
181
  var datasource = this.getDatasource();
185
182
  var attrs = this.props.node.attrs;
186
183
  var tableView = this.getTableView();
@@ -189,34 +186,25 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
189
186
  visibleColumnKeys = _this$getColumnsInfo10.visibleColumnKeys,
190
187
  columnCustomSizes = _this$getColumnsInfo10.columnCustomSizes,
191
188
  wrappedColumnKeys = _this$getColumnsInfo10.wrappedColumnKeys;
192
-
193
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready
194
- if (cardContext && cardContext.value) {
195
- return jsx(EditorAnalyticsContext, {
196
- editorView: this.props.view
197
- }, jsx(cardContext.Provider, {
198
- value: cardContext.value
199
- }, jsx(DatasourceTableView, {
200
- datasourceId: datasource.id,
201
- parameters: datasource.parameters,
202
- visibleColumnKeys: visibleColumnKeys,
203
- onVisibleColumnKeysChange: this.handleColumnChange,
204
- url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
205
- onColumnResize: this.handleColumnResize,
206
- columnCustomSizes: columnCustomSizes,
207
- onWrappedColumnChange: this.handleWrappedColumnChange,
208
- wrappedColumnKeys: wrappedColumnKeys
209
- })));
210
- }
189
+ return jsx(EditorSmartCardProviderValueGuard, null, jsx(EditorAnalyticsContext, {
190
+ editorView: this.props.view
191
+ }, jsx(EditorSmartCardProvider, null, jsx(DatasourceTableView, {
192
+ datasourceId: datasource.id,
193
+ parameters: datasource.parameters,
194
+ visibleColumnKeys: visibleColumnKeys,
195
+ onVisibleColumnKeysChange: this.handleColumnChange,
196
+ url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
197
+ onColumnResize: this.handleColumnResize,
198
+ columnCustomSizes: columnCustomSizes,
199
+ onWrappedColumnChange: this.handleWrappedColumnChange,
200
+ wrappedColumnKeys: wrappedColumnKeys
201
+ }))));
211
202
  }
212
203
  return null;
213
204
  }
214
205
  }]);
215
206
  return DatasourceComponent;
216
207
  }(React.PureComponent);
217
- _defineProperty(DatasourceComponent, "contextTypes", {
218
- contextAdapter: PropTypes.object
219
- });
220
208
  export var Datasource = /*#__PURE__*/function (_ReactNodeView) {
221
209
  _inherits(Datasource, _ReactNodeView);
222
210
  var _super2 = _createSuper(Datasource);
@@ -12,7 +12,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  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); }; }
13
13
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
14
  import React from 'react';
15
- import PropTypes from 'prop-types';
16
15
  import rafSchedule from 'raf-schd';
17
16
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
18
17
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -149,8 +148,9 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
149
148
  })(view.state.tr));
150
149
  })();
151
150
  try {
152
- var cardContext = _this.context.contextAdapter ? _this.context.contextAdapter.card : undefined;
153
- var hasPreview = cardContext && cardContext.value.extractors.getPreview(url, 'web');
151
+ var _this$props$cardConte, _this$props$cardConte2;
152
+ var cardContext = (_this$props$cardConte = _this.props.cardContext) !== null && _this$props$cardConte !== void 0 && _this$props$cardConte.value ? (_this$props$cardConte2 = _this.props.cardContext) === null || _this$props$cardConte2 === void 0 ? void 0 : _this$props$cardConte2.value : undefined;
153
+ var hasPreview = url && cardContext && cardContext.extractors.getPreview(url, 'web');
154
154
  if (!hasPreview) {
155
155
  _this.setState({
156
156
  hasPreview: false
@@ -242,14 +242,11 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
242
242
  _this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
243
243
  return _this;
244
244
  }
245
-
246
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
245
  _createClass(EmbedCardComponent, [{
248
246
  key: "render",
249
247
  value: function render() {
250
248
  var _this$props = this.props,
251
249
  node = _this$props.node,
252
- cardContext = _this$props.cardContext,
253
250
  allowResizing = _this$props.allowResizing,
254
251
  fullWidthMode = _this$props.fullWidthMode,
255
252
  view = _this$props.view,
@@ -298,7 +295,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
298
295
  embedIframeRef: this.embedIframeRef,
299
296
  actionOptions: actionOptions
300
297
  });
301
- var cardInner = /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
298
+ return /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
302
299
  embedIframeRef: this.embedIframeRef,
303
300
  onHeightUpdate: this.onHeightUpdate
304
301
  }, /*#__PURE__*/React.createElement(CardInner, {
@@ -317,18 +314,10 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
317
314
  cardProps: cardProps,
318
315
  dispatchAnalyticsEvent: dispatchAnalyticsEvent
319
316
  }));
320
-
321
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready
322
- return /*#__PURE__*/React.createElement(React.Fragment, null, cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
323
- value: cardContext.value
324
- }, cardInner) : null);
325
317
  }
326
318
  }]);
327
319
  return EmbedCardComponent;
328
320
  }(React.PureComponent);
329
- _defineProperty(EmbedCardComponent, "contextTypes", {
330
- contextAdapter: PropTypes.object
331
- });
332
321
  var WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
333
322
  export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
334
323
  _inherits(EmbedCard, _ReactNodeView);
@@ -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
  }
@@ -23,6 +23,11 @@ import { EditorLinkingPlatformAnalytics } from './ui/EditorLinkingPlatformAnalyt
23
23
  import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
24
24
  import LayoutButton from './ui/LayoutButton';
25
25
  import { isDatasourceConfigEditable } from './utils';
26
+
27
+ // Dummpy type of AnnotationPlugin
28
+ // This is used to avoid editor universal preset's inferred type maximum length error
29
+ // TODO: Remove this when the issue is fixed
30
+
26
31
  export var cardPlugin = function cardPlugin(_ref) {
27
32
  var _options$lpLinkPicker;
28
33
  var _ref$config = _ref.config,
@@ -7,15 +7,17 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
7
7
  import { ACTION, ACTION_SUBJECT, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { buildLayoutButtons, commandWithMetadata } from '@atlaskit/editor-common/card';
9
9
  import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
10
- import commonMessages, { linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
11
11
  import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME, richMediaClassName } from '@atlaskit/editor-common/styles';
12
12
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
13
13
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
14
  import { findDomRefAtPos, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
15
+ import CommentIcon from '@atlaskit/icon/core/comment';
15
16
  import DeleteIcon from '@atlaskit/icon/core/delete';
16
17
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
17
18
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
18
19
  import SettingsIcon from '@atlaskit/icon/core/settings';
20
+ import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
19
21
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
20
22
  import CogIcon from '@atlaskit/icon/glyph/editor/settings';
21
23
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
@@ -179,7 +181,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
179
181
  };
180
182
  var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) {
181
183
  return function (node) {
182
- var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs;
184
+ var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs;
183
185
  var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
184
186
  url = _titleUrlPairFromNode2.url;
185
187
  var _ref = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
@@ -200,6 +202,19 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
200
202
  hoverDecoration = _ref2.hoverDecoration;
201
203
  var isDatasource = isDatasourceNode(node);
202
204
  var pluginState = pluginKey.getState(state);
205
+ var annotationApiState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.sharedState.currentState();
206
+ var activeCommentMark = node.marks.find(function (mark) {
207
+ return mark.type.name === 'annotation' && (annotationApiState === null || annotationApiState === void 0 ? void 0 : annotationApiState.annotations[mark.attrs.id]) === false;
208
+ });
209
+ var isCommentEnabled = annotationApiState && annotationApiState.isVisible && !annotationApiState.bookmark && !annotationApiState.mouseData.isSelecting && !activeCommentMark && node.type === state.schema.nodes.inlineCard && fg('platform_inline_node_as_valid_annotation_selection');
210
+ var onCommentButtonClick = function onCommentButtonClick(state, dispatch) {
211
+ if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.annotation) || !isCommentEnabled) {
212
+ return false;
213
+ }
214
+ var setInlineCommentDraftState = pluginInjectionApi.annotation.actions.setInlineCommentDraftState;
215
+ var command = setInlineCommentDraftState(true, INPUT_METHOD.FLOATING_TB);
216
+ return command(state, dispatch);
217
+ };
203
218
  var shouldRenderDatasourceToolbar = isDatasource && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 || (_node$attrs = _node$attrs.datasource) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id);
204
219
  if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar) {
205
220
  return [buildEditLinkToolbar({
@@ -239,7 +254,18 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
239
254
  }, {
240
255
  type: 'separator'
241
256
  }];
242
- var toolbarItems = [].concat(editItems, [{
257
+ var commentItems = isCommentEnabled ? [{
258
+ id: 'editor.link.commentLink',
259
+ type: 'button',
260
+ icon: CommentIcon,
261
+ testId: 'inline-card-toolbar-comment-button',
262
+ iconFallback: LegacyCommentIcon,
263
+ title: intl.formatMessage(annotationMessages.createComment),
264
+ onClick: onCommentButtonClick
265
+ }, {
266
+ type: 'separator'
267
+ }] : [];
268
+ var toolbarItems = [].concat(editItems, commentItems, [{
243
269
  id: 'editor.link.openLink',
244
270
  type: 'button',
245
271
  icon: LinkExternalIcon,
@@ -277,8 +303,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
277
303
  onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
278
304
  }]);
279
305
  if (currentAppearance === 'embed') {
280
- var _pluginInjectionApi$a2;
281
- var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions, cardOptions);
306
+ var _pluginInjectionApi$a3;
307
+ var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, cardOptions);
282
308
  if (alignmentOptions.length) {
283
309
  alignmentOptions.push({
284
310
  type: 'separator'
@@ -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;