@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
@@ -9,8 +9,8 @@ exports.ToolbarViewedEvent = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _useAnalyticsEvents2 = require("@atlaskit/analytics-next/useAnalyticsEvents");
12
+ var _linkProvider = require("@atlaskit/link-provider");
12
13
  var _utils = require("../utils");
13
- var _CardContextProvider = require("./CardContextProvider");
14
14
  var _EditorAnalyticsContext = require("./EditorAnalyticsContext");
15
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -47,14 +47,12 @@ var ToolbarViewedEvent = exports.ToolbarViewedEvent = function ToolbarViewedEven
47
47
  var url = _ref2.url,
48
48
  display = _ref2.display,
49
49
  editorView = _ref2.editorView;
50
+ var cardContext = (0, _linkProvider.useSmartLinkContext)();
50
51
  return /*#__PURE__*/_react.default.createElement(_EditorAnalyticsContext.EditorAnalyticsContext, {
51
52
  editorView: editorView
52
- }, /*#__PURE__*/_react.default.createElement(_CardContextProvider.CardContextProvider, null, function (_ref3) {
53
- var cardContext = _ref3.cardContext;
54
- return url ? /*#__PURE__*/_react.default.createElement(ToolbarViewedEventBase, {
55
- url: url,
56
- display: display,
57
- cardContext: cardContext
58
- }) : null;
59
- }));
53
+ }, url ? /*#__PURE__*/_react.default.createElement(ToolbarViewedEventBase, {
54
+ url: url,
55
+ display: display,
56
+ cardContext: cardContext
57
+ }) : null);
60
58
  };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.WithCardContext = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _linkProvider = require("@atlaskit/link-provider");
10
+ var WithCardContext = exports.WithCardContext = function WithCardContext(_ref) {
11
+ var children = _ref.children;
12
+ var cardContext = (0, _linkProvider.useSmartCardContext)();
13
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children(cardContext));
14
+ };
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import rafSchedule from 'raf-schd';
5
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
6
5
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -94,9 +93,6 @@ export class BlockCardComponent extends React.PureComponent {
94
93
  }, cardInner) : data ? cardInner : null);
95
94
  }
96
95
  }
97
- _defineProperty(BlockCardComponent, "contextTypes", {
98
- contextAdapter: PropTypes.object
99
- });
100
96
  const WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
101
97
  export class BlockCard extends ReactNodeView {
102
98
  constructor(...args) {
@@ -7,12 +7,12 @@ import React from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { jsx } from '@emotion/react';
10
- import PropTypes from 'prop-types';
11
10
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
11
  import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
13
12
  import { UnsupportedInline } from '@atlaskit/editor-common/ui';
14
13
  import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
15
14
  import { DatasourceTableView } from '@atlaskit/link-datasource';
15
+ import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
16
16
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
17
17
  import { fg } from '@atlaskit/platform-feature-flags';
18
18
  import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
@@ -29,8 +29,6 @@ const getPosSafely = pos => {
29
29
  };
30
30
  // eslint-disable-next-line @repo/internal/react/no-class-components
31
31
  export class DatasourceComponent extends React.PureComponent {
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
-
34
32
  constructor(props) {
35
33
  super(props);
36
34
  _defineProperty(this, "getDatasource", () => this.props.node.attrs.datasource);
@@ -148,7 +146,6 @@ export class DatasourceComponent extends React.PureComponent {
148
146
  };
149
147
  }
150
148
  render() {
151
- const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
152
149
  const datasource = this.getDatasource();
153
150
  const attrs = this.props.node.attrs;
154
151
  const tableView = this.getTableView();
@@ -158,32 +155,23 @@ export class DatasourceComponent extends React.PureComponent {
158
155
  columnCustomSizes,
159
156
  wrappedColumnKeys
160
157
  } = this.getColumnsInfo();
161
-
162
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready
163
- if (cardContext && cardContext.value) {
164
- return jsx(EditorAnalyticsContext, {
165
- editorView: this.props.view
166
- }, jsx(cardContext.Provider, {
167
- value: cardContext.value
168
- }, jsx(DatasourceTableView, {
169
- datasourceId: datasource.id,
170
- parameters: datasource.parameters,
171
- visibleColumnKeys: visibleColumnKeys,
172
- onVisibleColumnKeysChange: this.handleColumnChange,
173
- url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
174
- onColumnResize: this.handleColumnResize,
175
- columnCustomSizes: columnCustomSizes,
176
- onWrappedColumnChange: this.handleWrappedColumnChange,
177
- wrappedColumnKeys: wrappedColumnKeys
178
- })));
179
- }
158
+ return jsx(EditorSmartCardProviderValueGuard, null, jsx(EditorAnalyticsContext, {
159
+ editorView: this.props.view
160
+ }, jsx(EditorSmartCardProvider, null, jsx(DatasourceTableView, {
161
+ datasourceId: datasource.id,
162
+ parameters: datasource.parameters,
163
+ visibleColumnKeys: visibleColumnKeys,
164
+ onVisibleColumnKeysChange: this.handleColumnChange,
165
+ url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
166
+ onColumnResize: this.handleColumnResize,
167
+ columnCustomSizes: columnCustomSizes,
168
+ onWrappedColumnChange: this.handleWrappedColumnChange,
169
+ wrappedColumnKeys: wrappedColumnKeys
170
+ }))));
180
171
  }
181
172
  return null;
182
173
  }
183
174
  }
184
- _defineProperty(DatasourceComponent, "contextTypes", {
185
- contextAdapter: PropTypes.object
186
- });
187
175
  export class Datasource extends ReactNodeView {
188
176
  constructor(props) {
189
177
  var _props$pluginInjectio, _props$pluginInjectio2, _sharedState$currentS;
@@ -1,7 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import React from 'react';
4
- import PropTypes from 'prop-types';
5
4
  import rafSchedule from 'raf-schd';
6
5
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
7
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -143,8 +142,9 @@ export class EmbedCardComponent extends React.PureComponent {
143
142
  })(view.state.tr));
144
143
  })();
145
144
  try {
146
- const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
147
- const hasPreview = cardContext && cardContext.value.extractors.getPreview(url, 'web');
145
+ var _this$props$cardConte, _this$props$cardConte2;
146
+ const 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;
147
+ const hasPreview = url && cardContext && cardContext.extractors.getPreview(url, 'web');
148
148
  if (!hasPreview) {
149
149
  this.setState({
150
150
  hasPreview: false
@@ -240,13 +240,9 @@ export class EmbedCardComponent extends React.PureComponent {
240
240
  });
241
241
  this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
242
242
  }
243
-
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
-
246
243
  render() {
247
244
  const {
248
245
  node,
249
- cardContext,
250
246
  allowResizing,
251
247
  fullWidthMode,
252
248
  view,
@@ -298,7 +294,7 @@ export class EmbedCardComponent extends React.PureComponent {
298
294
  embedIframeRef: this.embedIframeRef,
299
295
  actionOptions: actionOptions
300
296
  });
301
- const cardInner = /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
297
+ return /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
302
298
  embedIframeRef: this.embedIframeRef,
303
299
  onHeightUpdate: this.onHeightUpdate
304
300
  }, /*#__PURE__*/React.createElement(CardInner, {
@@ -317,16 +313,8 @@ export class EmbedCardComponent extends React.PureComponent {
317
313
  cardProps: cardProps,
318
314
  dispatchAnalyticsEvent: dispatchAnalyticsEvent
319
315
  }));
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
316
  }
326
317
  }
327
- _defineProperty(EmbedCardComponent, "contextTypes", {
328
- contextAdapter: PropTypes.object
329
- });
330
318
  const WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
331
319
  export class EmbedCard extends ReactNodeView {
332
320
  constructor(...args) {
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React, { useCallback } from 'react';
4
- import PropTypes from 'prop-types';
5
4
  import { isSafeUrl } from '@atlaskit/adf-schema';
6
5
  import { AnalyticsContext } from '@atlaskit/analytics-next';
7
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -9,6 +8,7 @@ import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
9
8
  import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
11
10
  import { getPluginState } from '../pm-plugins/util/state';
11
+ import { WithCardContext } from '../ui/WithCardContext';
12
12
  import { titleUrlPairFromNode } from '../utils';
13
13
  const WithClickHandler = ({
14
14
  pluginInjectionApi,
@@ -52,8 +52,7 @@ const WithClickHandler = ({
52
52
  }));
53
53
  };
54
54
  export function Card(SmartCardComponent, UnsupportedComponent) {
55
- var _class;
56
- return _class = class extends React.Component {
55
+ return class extends React.Component {
57
56
  constructor(...args) {
58
57
  super(...args);
59
58
  _defineProperty(this, "state", {
@@ -84,7 +83,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
84
83
  return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
85
84
  }
86
85
  }
87
- const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
88
86
  const editorAppearance = (_getPluginState = getPluginState(this.props.view.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
89
87
  const analyticsEditorAppearance = getAnalyticsEditorAppearance(editorAppearance);
90
88
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
@@ -102,12 +100,12 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
102
100
  __livePage: this.props.__livePage
103
101
  }, ({
104
102
  onClick
105
- }) => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
103
+ }) => /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
106
104
  key: url,
107
105
  cardContext: cardContext
108
106
  }, this.props, {
109
107
  onClick: onClick
110
- }))));
108
+ })))));
111
109
  }
112
110
  componentDidCatch(error) {
113
111
  const maybeAPIError = error;
@@ -142,7 +140,5 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
142
140
  });
143
141
  }
144
142
  }
145
- }, _defineProperty(_class, "contextTypes", {
146
- contextAdapter: PropTypes.object
147
- }), _class;
143
+ };
148
144
  }
@@ -18,6 +18,11 @@ import { EditorLinkingPlatformAnalytics } from './ui/EditorLinkingPlatformAnalyt
18
18
  import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
19
19
  import LayoutButton from './ui/LayoutButton';
20
20
  import { isDatasourceConfigEditable } from './utils';
21
+
22
+ // Dummpy type of AnnotationPlugin
23
+ // This is used to avoid editor universal preset's inferred type maximum length error
24
+ // TODO: Remove this when the issue is fixed
25
+
21
26
  export const cardPlugin = ({
22
27
  config: options = {},
23
28
  api
@@ -3,15 +3,17 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { buildLayoutButtons, commandWithMetadata } from '@atlaskit/editor-common/card';
5
5
  import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
6
- import commonMessages, { linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME, richMediaClassName } from '@atlaskit/editor-common/styles';
8
8
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
9
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findDomRefAtPos, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
11
+ import CommentIcon from '@atlaskit/icon/core/comment';
11
12
  import DeleteIcon from '@atlaskit/icon/core/delete';
12
13
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
13
14
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
14
15
  import SettingsIcon from '@atlaskit/icon/core/settings';
16
+ import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
15
17
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
16
18
  import CogIcon from '@atlaskit/icon/glyph/editor/settings';
17
19
  import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
@@ -177,7 +179,7 @@ const getToolbarViewedItem = (url, display) => {
177
179
  }];
178
180
  };
179
181
  const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) => node => {
180
- var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs, _node$attrs$datasourc;
182
+ var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs, _node$attrs$datasourc;
181
183
  const {
182
184
  url
183
185
  } = titleUrlPairFromNode(node);
@@ -202,6 +204,19 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
202
204
  } = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
203
205
  const isDatasource = isDatasourceNode(node);
204
206
  const pluginState = pluginKey.getState(state);
207
+ const annotationApiState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.sharedState.currentState();
208
+ const activeCommentMark = node.marks.find(mark => mark.type.name === 'annotation' && (annotationApiState === null || annotationApiState === void 0 ? void 0 : annotationApiState.annotations[mark.attrs.id]) === false);
209
+ const 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
+ const onCommentButtonClick = (state, dispatch) => {
211
+ if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.annotation) || !isCommentEnabled) {
212
+ return false;
213
+ }
214
+ const {
215
+ setInlineCommentDraftState
216
+ } = pluginInjectionApi.annotation.actions;
217
+ const command = setInlineCommentDraftState(true, INPUT_METHOD.FLOATING_TB);
218
+ return command(state, dispatch);
219
+ };
205
220
  const shouldRenderDatasourceToolbar = isDatasource && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : (_node$attrs$datasourc = _node$attrs.datasource) === null || _node$attrs$datasourc === void 0 ? void 0 : _node$attrs$datasourc.id);
206
221
  if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar) {
207
222
  return [buildEditLinkToolbar({
@@ -241,7 +256,18 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
241
256
  }, {
242
257
  type: 'separator'
243
258
  }];
244
- const toolbarItems = [...editItems, {
259
+ const commentItems = isCommentEnabled ? [{
260
+ id: 'editor.link.commentLink',
261
+ type: 'button',
262
+ icon: CommentIcon,
263
+ testId: 'inline-card-toolbar-comment-button',
264
+ iconFallback: LegacyCommentIcon,
265
+ title: intl.formatMessage(annotationMessages.createComment),
266
+ onClick: onCommentButtonClick
267
+ }, {
268
+ type: 'separator'
269
+ }] : [];
270
+ const toolbarItems = [...editItems, ...commentItems, {
245
271
  id: 'editor.link.openLink',
246
272
  type: 'button',
247
273
  icon: LinkExternalIcon,
@@ -279,8 +305,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
279
305
  onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
280
306
  }];
281
307
  if (currentAppearance === 'embed') {
282
- var _pluginInjectionApi$a2;
283
- const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions, cardOptions);
308
+ var _pluginInjectionApi$a3;
309
+ const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, cardOptions);
284
310
  if (alignmentOptions.length) {
285
311
  alignmentOptions.push({
286
312
  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
  const buttonStyles = css({
@@ -108,9 +108,8 @@ export const DatasourceAppearanceButton = ({
108
108
  selected,
109
109
  inputMethod
110
110
  }) => {
111
- return jsx(CardContextProvider, null, ({
112
- cardContext
113
- }) => jsx(DatasourceAppearanceButtonWithCardContext, {
111
+ const cardContext = useSmartLinkContext();
112
+ return jsx(DatasourceAppearanceButtonWithCardContext, {
114
113
  url: url,
115
114
  intl: intl,
116
115
  editorAnalyticsApi: editorAnalyticsApi,
@@ -119,5 +118,5 @@ export const DatasourceAppearanceButton = ({
119
118
  cardContext: cardContext,
120
119
  selected: selected,
121
120
  inputMethod: inputMethod
122
- }));
121
+ });
123
122
  };
@@ -1,13 +1,14 @@
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
  const ModalWithState = ({
8
8
  api,
9
9
  editorView
10
10
  }) => {
11
+ const cardContext = useSmartLinkContext();
11
12
  const {
12
13
  cardState
13
14
  } = useSharedPluginState(api, ['card']);
@@ -28,15 +29,22 @@ const ModalWithState = ({
28
29
  return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
29
30
  view: editorView,
30
31
  datasourceModalType: datasourceModalType
31
- }, /*#__PURE__*/React.createElement(CardContextProvider, null, ({
32
- cardContext
33
- }) => /*#__PURE__*/React.createElement(DatasourceModal, {
32
+ }, /*#__PURE__*/React.createElement(DatasourceModal, {
34
33
  view: editorView,
35
34
  cardContext: cardContext,
36
35
  datasourceId: datasourceId,
37
36
  componentType: componentType
38
- })));
37
+ }));
39
38
  };
39
+ const SafeModalWithState = /*#__PURE__*/React.memo(({
40
+ api,
41
+ editorView
42
+ }) => {
43
+ return /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(ModalWithState, {
44
+ api: api,
45
+ editorView: editorView
46
+ }));
47
+ });
40
48
  export const modalTypeToComponentMap = {
41
49
  jira: {
42
50
  componentType: JiraIssuesConfigModal,
@@ -51,4 +59,4 @@ export const modalTypeToComponentMap = {
51
59
  datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
52
60
  }
53
61
  };
54
- export default ModalWithState;
62
+ export default SafeModalWithState;
@@ -11,10 +11,10 @@ import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-
11
11
  import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
12
12
  import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
13
13
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
14
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
14
15
  import { ButtonItem } from '@atlaskit/menu';
15
16
  import { Flex } from '@atlaskit/primitives';
16
17
  import { focusEditorView, isDatasourceConfigEditable } from '../../utils';
17
- import { CardContextProvider } from '../CardContextProvider';
18
18
  import { editDatasource } from '../editDatasourceAction';
19
19
  import { useFetchDatasourceDataInfo } from '../useFetchDatasourceDataInfo';
20
20
  import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
@@ -241,35 +241,11 @@ export const EditToolbarButton = props => {
241
241
  onLinkEditClick,
242
242
  url
243
243
  } = props;
244
- return jsx(CardContextProvider, null, ({
245
- cardContext
246
- }) => {
247
- if (props.url) {
248
- return jsx(EditToolbarButtonWithUrl, {
249
- datasourceId: datasourceId,
250
- url: props.url,
251
- intl: intl,
252
- editorAnalyticsApi: editorAnalyticsApi,
253
- editorView: editorView,
254
- cardContext: cardContext,
255
- onLinkEditClick: onLinkEditClick,
256
- currentAppearance: currentAppearance
257
- });
258
- }
259
- if (props.datasourceId && props.node) {
260
- return jsx(EditToolbarButtonWithDatasourceId, {
261
- datasourceId: props.datasourceId,
262
- node: props.node,
263
- intl: intl,
264
- editorAnalyticsApi: editorAnalyticsApi,
265
- editorView: editorView,
266
- onLinkEditClick: onLinkEditClick,
267
- currentAppearance: currentAppearance
268
- });
269
- }
270
- return jsx(EditToolbarButtonWithCardContext, {
244
+ const cardContext = useSmartLinkContext();
245
+ if (props.url) {
246
+ return jsx(EditToolbarButtonWithUrl, {
271
247
  datasourceId: datasourceId,
272
- url: url,
248
+ url: props.url,
273
249
  intl: intl,
274
250
  editorAnalyticsApi: editorAnalyticsApi,
275
251
  editorView: editorView,
@@ -277,5 +253,26 @@ export const EditToolbarButton = props => {
277
253
  onLinkEditClick: onLinkEditClick,
278
254
  currentAppearance: currentAppearance
279
255
  });
256
+ }
257
+ if (props.datasourceId && props.node) {
258
+ return jsx(EditToolbarButtonWithDatasourceId, {
259
+ datasourceId: props.datasourceId,
260
+ node: props.node,
261
+ intl: intl,
262
+ editorAnalyticsApi: editorAnalyticsApi,
263
+ editorView: editorView,
264
+ onLinkEditClick: onLinkEditClick,
265
+ currentAppearance: currentAppearance
266
+ });
267
+ }
268
+ return jsx(EditToolbarButtonWithCardContext, {
269
+ datasourceId: datasourceId,
270
+ url: url,
271
+ intl: intl,
272
+ editorAnalyticsApi: editorAnalyticsApi,
273
+ editorView: editorView,
274
+ cardContext: cardContext,
275
+ onLinkEditClick: onLinkEditClick,
276
+ currentAppearance: currentAppearance
280
277
  });
281
278
  };
@@ -1,33 +1,14 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import React from 'react';
3
- import PropTypes from 'prop-types';
2
+ import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
4
3
  import { EditorAnalyticsContext } from '../EditorAnalyticsContext';
5
4
  import { DatasourceEventsBinding } from './DatasourceEvents';
6
5
  import { LinkEventsBinding } from './LinkEvents';
7
6
 
8
7
  // eslint-disable-next-line @repo/internal/react/no-class-components
9
8
  export class EditorLinkingPlatformAnalytics extends React.PureComponent {
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
-
12
9
  render() {
13
- var _this$context, _this$context$context;
14
- const cardContext = (_this$context = this.context) === null || _this$context === void 0 ? void 0 : (_this$context$context = _this$context.contextAdapter) === null || _this$context$context === void 0 ? void 0 : _this$context$context.card;
15
-
16
- /**
17
- * The analytics hook needs to be able to communicate with the card context
18
- * If we can't access it, don't mount the event bindings
19
- * This effectively entirely disables all tracking behaviour
20
- */
21
- if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
22
- return null;
23
- }
24
- return /*#__PURE__*/React.createElement(cardContext.Provider, {
25
- value: cardContext.value
26
- }, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
10
+ return /*#__PURE__*/React.createElement(EditorSmartCardProvider, null, /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
27
11
  editorView: this.props.editorView
28
- }, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props)));
12
+ }, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props))));
29
13
  }
30
- }
31
- _defineProperty(EditorLinkingPlatformAnalytics, "contextTypes", {
32
- contextAdapter: PropTypes.object
33
- });
14
+ }
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import { AnalyticsContext } from '@atlaskit/analytics-next';
5
4
  import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
5
  import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } from '@atlaskit/editor-common/card';
@@ -12,7 +11,9 @@ import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugi
12
11
  import { shouldRenderToolbarPulse } from '../toolbar';
13
12
  import { getResolvedAttributesFromStore } from '../utils';
14
13
  import { DiscoveryPulse } from './Pulse';
14
+ import { WithCardContext } from './WithCardContext';
15
15
  // eslint-disable-next-line @repo/internal/react/no-class-components
16
+
16
17
  export class LinkToolbarAppearance extends React.Component {
17
18
  constructor(...args) {
18
19
  super(...args);
@@ -114,16 +115,12 @@ export class LinkToolbarAppearance extends React.Component {
114
115
  });
115
116
  }
116
117
  render() {
117
- const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
118
118
  const {
119
119
  editorView
120
120
  } = this.props;
121
- return this.renderDropdown(editorView, cardContext && cardContext.value);
121
+ return /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => this.renderDropdown(editorView, cardContext && cardContext.value));
122
122
  }
123
123
  }
124
- _defineProperty(LinkToolbarAppearance, "contextTypes", {
125
- contextAdapter: PropTypes.object
126
- });
127
124
  const getUnavailableMessage = (state, intl) => {
128
125
  try {
129
126
  const parentNode = state.selection.$from.node(1);
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
3
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
3
4
  import { getResolvedAttributesFromStore } from '../utils';
4
- import { CardContextProvider } from './CardContextProvider';
5
5
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
6
6
  /**
7
7
  * Handles firing the toolbar viewed event
@@ -38,13 +38,12 @@ export const ToolbarViewedEvent = ({
38
38
  display,
39
39
  editorView
40
40
  }) => {
41
+ const cardContext = useSmartLinkContext();
41
42
  return /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
42
43
  editorView: editorView
43
- }, /*#__PURE__*/React.createElement(CardContextProvider, null, ({
44
- cardContext
45
- }) => url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
44
+ }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
46
45
  url: url,
47
46
  display: display,
48
47
  cardContext: cardContext
49
- }) : null));
48
+ }) : null);
50
49
  };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { useSmartCardContext } from '@atlaskit/link-provider';
3
+ export const WithCardContext = ({
4
+ children
5
+ }) => {
6
+ const cardContext = useSmartCardContext();
7
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children(cardContext));
8
+ };
@@ -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 from 'react';
12
- import PropTypes from 'prop-types';
13
12
  import rafSchedule from 'raf-schd';
14
13
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
15
14
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -106,9 +105,6 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
106
105
  }]);
107
106
  return BlockCardComponent;
108
107
  }(React.PureComponent);
109
- _defineProperty(BlockCardComponent, "contextTypes", {
110
- contextAdapter: PropTypes.object
111
- });
112
108
  var WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
113
109
  export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
114
110
  _inherits(BlockCard, _ReactNodeView);