@atlaskit/editor-plugin-card 16.5.4 → 16.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/cardPlugin.js +18 -4
  3. package/dist/cjs/nodeviews/blockCard.js +16 -5
  4. package/dist/cjs/nodeviews/embedCard.js +16 -5
  5. package/dist/cjs/nodeviews/genericCard.js +2 -6
  6. package/dist/cjs/nodeviews/inlineCard.js +8 -4
  7. package/dist/cjs/pm-plugins/doc.js +87 -22
  8. package/dist/cjs/pm-plugins/main.js +12 -5
  9. package/dist/cjs/ui/SmartCardSSRReactContextsProvider.js +28 -0
  10. package/dist/cjs/ui/WithCardContext.js +3 -18
  11. package/dist/es2019/cardPlugin.js +12 -1
  12. package/dist/es2019/nodeviews/blockCard.js +16 -5
  13. package/dist/es2019/nodeviews/embedCard.js +16 -5
  14. package/dist/es2019/nodeviews/genericCard.js +2 -6
  15. package/dist/es2019/nodeviews/inlineCard.js +8 -4
  16. package/dist/es2019/pm-plugins/doc.js +83 -21
  17. package/dist/es2019/pm-plugins/main.js +12 -5
  18. package/dist/es2019/ui/SmartCardSSRReactContextsProvider.js +22 -0
  19. package/dist/es2019/ui/WithCardContext.js +3 -14
  20. package/dist/esm/cardPlugin.js +19 -5
  21. package/dist/esm/nodeviews/blockCard.js +16 -5
  22. package/dist/esm/nodeviews/embedCard.js +16 -5
  23. package/dist/esm/nodeviews/genericCard.js +2 -6
  24. package/dist/esm/nodeviews/inlineCard.js +8 -4
  25. package/dist/esm/pm-plugins/doc.js +86 -21
  26. package/dist/esm/pm-plugins/main.js +12 -5
  27. package/dist/esm/ui/SmartCardSSRReactContextsProvider.js +21 -0
  28. package/dist/esm/ui/WithCardContext.js +3 -16
  29. package/dist/types/cardPluginType.d.ts +9 -3
  30. package/dist/types/nodeviews/blockCard.d.ts +6 -2
  31. package/dist/types/nodeviews/embedCard.d.ts +6 -2
  32. package/dist/types/nodeviews/genericCard.d.ts +3 -1
  33. package/dist/types/nodeviews/inlineCard.d.ts +1 -1
  34. package/dist/types/pm-plugins/doc.d.ts +9 -0
  35. package/dist/types/ui/SmartCardSSRReactContextsProvider.d.ts +10 -0
  36. package/dist/types/ui/WithCardContext.d.ts +1 -3
  37. package/dist/types-ts4.5/cardPluginType.d.ts +9 -3
  38. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +6 -2
  39. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +6 -2
  40. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
  41. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -1
  42. package/dist/types-ts4.5/pm-plugins/doc.d.ts +9 -0
  43. package/dist/types-ts4.5/ui/SmartCardSSRReactContextsProvider.d.ts +10 -0
  44. package/dist/types-ts4.5/ui/WithCardContext.d.ts +1 -3
  45. package/package.json +4 -4
@@ -17,10 +17,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
17
17
  import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
18
18
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
19
19
  import { CardSSR } from '@atlaskit/smart-card/ssr';
20
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
21
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { registerCard, removeCard } from '../pm-plugins/actions';
23
24
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
25
+ import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
24
26
  import { BlockCardComponent } from './blockCard';
25
27
  import { Card } from './genericCard';
26
28
 
@@ -505,9 +507,14 @@ export class EmbedCard extends ReactNodeView {
505
507
  onClickCallback,
506
508
  CompetitorPrompt,
507
509
  isPageSSRed,
508
- provider
510
+ provider,
511
+ intl,
512
+ smartCardContext
509
513
  } = this.reactComponentProps;
510
- return /*#__PURE__*/React.createElement(WrappedEmbedCard, {
514
+ return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
515
+ intl: intl,
516
+ smartCardContext: smartCardContext
517
+ }, /*#__PURE__*/React.createElement(WrappedEmbedCard, {
511
518
  node: this.node,
512
519
  view: this.view,
513
520
  eventDispatcher: eventDispatcher,
@@ -521,7 +528,7 @@ export class EmbedCard extends ReactNodeView {
521
528
  CompetitorPrompt: CompetitorPrompt,
522
529
  isPageSSRed: isPageSSRed,
523
530
  provider: provider
524
- });
531
+ }));
525
532
  }
526
533
 
527
534
  /**
@@ -553,7 +560,9 @@ export const embedCardNodeView = ({
553
560
  onClickCallback,
554
561
  CompetitorPrompt,
555
562
  isPageSSRed,
556
- provider
563
+ provider,
564
+ intl,
565
+ smartCardContext
557
566
  }) => (node, view, getPos) => {
558
567
  const {
559
568
  portalProviderAPI,
@@ -570,7 +579,9 @@ export const embedCardNodeView = ({
570
579
  onClickCallback: onClickCallback,
571
580
  CompetitorPrompt,
572
581
  isPageSSRed,
573
- provider
582
+ provider,
583
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
584
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
574
585
  };
575
586
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps).init();
576
587
  };
@@ -6,7 +6,6 @@ import { AnalyticsContext } from '@atlaskit/analytics-next';
6
6
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
7
7
  import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
8
8
  import Link from '@atlaskit/link';
9
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
9
  import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
11
10
  import { getPluginState } from '../pm-plugins/util/state';
12
11
  import { titleUrlPairFromNode } from '../pm-plugins/utils';
@@ -63,8 +62,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
63
62
  var _getPluginState;
64
63
  const {
65
64
  pluginInjectionApi,
66
- onClickCallback,
67
- smartCardContext
65
+ onClickCallback
68
66
  } = this.props;
69
67
  const {
70
68
  url
@@ -104,9 +102,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
104
102
  url: url
105
103
  }, ({
106
104
  onClick
107
- }) => /*#__PURE__*/React.createElement(WithCardContext, {
108
- value: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
109
- }, cardContext => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
105
+ }) => /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
110
106
  key: url,
111
107
  cardContext: cardContext
112
108
  // Ignored via go/ees005
@@ -15,6 +15,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
16
16
  import { registerCard, removeCard } from '../pm-plugins/actions';
17
17
  import { getAwarenessProps } from '../pm-plugins/utils';
18
+ import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
18
19
  import { visitCardLinkAnalytics } from '../ui/toolbar';
19
20
  import { Card } from './genericCard';
20
21
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
@@ -200,6 +201,7 @@ export function InlineCardNodeView(props) {
200
201
  isPageSSRed,
201
202
  provider,
202
203
  CompetitorPrompt,
204
+ intl,
203
205
  smartCardContext
204
206
  } = props;
205
207
  const {
@@ -238,17 +240,19 @@ export function InlineCardNodeView(props) {
238
240
  onClickCallback: onClickCallback,
239
241
  isPageSSRed: isPageSSRed,
240
242
  provider: provider,
241
- appearance: "inline",
242
- smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
243
+ appearance: "inline"
243
244
  // Ignored via go/ees005
244
245
  // eslint-disable-next-line react/jsx-props-no-spreading
245
246
  }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, mode === 'view'))), CompetitorPromptComponent);
246
- return /*#__PURE__*/React.createElement(SmartLinkDraggable, {
247
+ return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
248
+ intl: intl,
249
+ smartCardContext: smartCardContext
250
+ }, /*#__PURE__*/React.createElement(SmartLinkDraggable, {
247
251
  url: url,
248
252
  appearance: SMART_LINK_APPEARANCE.INLINE,
249
253
  source: SMART_LINK_DRAG_TYPES.EDITOR,
250
254
  isChangeboardTarget: isChangeboardTarget
251
- }, inlineCardContent);
255
+ }, inlineCardContent));
252
256
  }
253
257
  export const inlineCardNodeView = ({
254
258
  inlineCardViewProducer
@@ -176,6 +176,43 @@ export const handleFallbackWithAnalytics = (request, editorAnalyticsApi) => (sta
176
176
  }
177
177
  return true;
178
178
  };
179
+
180
+ /**
181
+ * Shared options used by both `queueCardsFromChangedTr` and
182
+ * `queueCardsFromRange` to build smart-link resolution requests for text
183
+ * nodes carrying a `link` mark.
184
+ */
185
+
186
+ /**
187
+ * Per-node walker shared by `queueCardsFromChangedTr` and
188
+ * `queueCardsFromRange`. Pushes a smart-link resolution request for every
189
+ * text node carrying a qualifying `link` mark.
190
+ *
191
+ * Returning `true`/`false` follows the ProseMirror `nodesBetween`/
192
+ * `nodesBetweenChanged` walker contract: `true` to descend into children,
193
+ * `false` to skip subtree.
194
+ */
195
+ const collectLinkRequest = (requests, node, pos, options) => {
196
+ if (!node.isText) {
197
+ return true;
198
+ }
199
+ const linkMark = node.marks.find(mark => mark.type === options.linkMarkType);
200
+ if (linkMark) {
201
+ if (!shouldReplaceLink(node, options.normalizeLinkText)) {
202
+ return false;
203
+ }
204
+ requests.push({
205
+ url: linkMark.attrs.href,
206
+ pos,
207
+ appearance: options.appearance,
208
+ compareLinkText: options.normalizeLinkText,
209
+ source: options.source,
210
+ analyticsAction: options.analyticsAction,
211
+ sourceEvent: options.sourceEvent
212
+ });
213
+ }
214
+ return false;
215
+ };
179
216
  export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, appearance = 'inline') => {
180
217
  const {
181
218
  schema
@@ -184,27 +221,52 @@ export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, norm
184
221
  link
185
222
  } = schema.marks;
186
223
  const requests = [];
187
- nodesBetweenChanged(tr, (node, pos) => {
188
- if (!node.isText) {
189
- return true;
190
- }
191
- const linkMark = node.marks.find(mark => mark.type === link);
192
- if (linkMark) {
193
- if (!shouldReplaceLink(node, normalizeLinkText)) {
194
- return false;
195
- }
196
- requests.push({
197
- url: linkMark.attrs.href,
198
- pos,
199
- appearance,
200
- compareLinkText: normalizeLinkText,
201
- source,
202
- analyticsAction,
203
- sourceEvent
204
- });
205
- }
206
- return false;
207
- });
224
+ const options = {
225
+ analyticsAction,
226
+ appearance,
227
+ linkMarkType: link,
228
+ normalizeLinkText,
229
+ source,
230
+ sourceEvent
231
+ };
232
+ nodesBetweenChanged(tr, (node, pos) => collectLinkRequest(requests, node, pos, options));
233
+ if (analyticsAction) {
234
+ addLinkMetadata(state.selection, tr, {
235
+ action: analyticsAction
236
+ });
237
+ }
238
+ return queueCards(requests)(tr);
239
+ };
240
+
241
+ /**
242
+ * Queue link-mark → smart-link resolution for text nodes within an explicit
243
+ * document range, rather than the entire step range of the transaction.
244
+ *
245
+ * Use this instead of `queueCardsFromChangedTr` when you know the exact range
246
+ * that was inserted/modified and want to avoid accidentally queuing pre-existing
247
+ * links that happen to fall within the broader step range.
248
+ */
249
+ export const queueCardsFromRange = (state, tr, from, to, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined, appearance = 'inline') => {
250
+ const {
251
+ schema
252
+ } = state;
253
+ const {
254
+ link
255
+ } = schema.marks;
256
+ const requests = [];
257
+ const options = {
258
+ analyticsAction,
259
+ appearance,
260
+ linkMarkType: link,
261
+ normalizeLinkText,
262
+ source,
263
+ sourceEvent
264
+ };
265
+ const clampedFrom = Math.max(0, from);
266
+ const clampedTo = Math.min(tr.doc.content.size, to);
267
+ if (clampedFrom < clampedTo) {
268
+ tr.doc.nodesBetween(clampedFrom, clampedTo, (node, pos) => collectLinkRequest(requests, node, pos, options));
269
+ }
208
270
  if (analyticsAction) {
209
271
  addLinkMetadata(state.selection, tr, {
210
272
  action: analyticsAction
@@ -1,4 +1,5 @@
1
1
  import rafSchedule from 'raf-schd';
2
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
2
3
  import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from '@atlaskit/editor-common/styles';
@@ -49,10 +50,11 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
49
50
  onClickCallback,
50
51
  isPageSSRed,
51
52
  provider,
52
- smartCardContext,
53
53
  CompetitorPrompt,
54
+ smartCardContext,
54
55
  embedCardTransformers
55
56
  } = options;
57
+ const intl = pmPluginFactoryParams.getIntl();
56
58
  const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
57
59
  const inlineCardViewProducer = getInlineNodeViewProducer({
58
60
  pmPluginFactoryParams,
@@ -67,8 +69,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
67
69
  onClickCallback,
68
70
  isPageSSRed,
69
71
  provider,
70
- smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined,
71
- CompetitorPrompt
72
+ CompetitorPrompt: isSSR() && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? undefined : CompetitorPrompt,
73
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
74
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
72
75
  }
73
76
  });
74
77
  return new SafePlugin({
@@ -272,7 +275,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
272
275
  inlineCardViewProducer,
273
276
  isPageSSRed,
274
277
  provider,
275
- CompetitorPrompt: options.CompetitorPrompt
278
+ CompetitorPrompt: isSSR() && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? undefined : options.CompetitorPrompt,
279
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
280
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
276
281
  }),
277
282
  embedCard: lazyEmbedCardView({
278
283
  allowResizing,
@@ -283,7 +288,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
283
288
  onClickCallback: options.onClickCallback,
284
289
  isPageSSRed,
285
290
  provider,
286
- CompetitorPrompt: options.CompetitorPrompt
291
+ CompetitorPrompt: isSSR() && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? undefined : options.CompetitorPrompt,
292
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
293
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
287
294
  })
288
295
  },
289
296
  ...(enableInlineUpgradeFeatures && {
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { RawIntlProvider } from 'react-intl';
3
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
4
+ import { SmartCardContext } from '@atlaskit/link-provider';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
+ export function SmartCardSSRReactContextsProvider({
7
+ smartCardContext,
8
+ children,
9
+ intl
10
+ }) {
11
+ if (!expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) || !isSSR()) {
12
+ return children;
13
+ }
14
+ if (!intl || !smartCardContext) {
15
+ return children;
16
+ }
17
+ return /*#__PURE__*/React.createElement(RawIntlProvider, {
18
+ value: intl
19
+ }, /*#__PURE__*/React.createElement(SmartCardContext.Provider, {
20
+ value: smartCardContext
21
+ }, children));
22
+ }
@@ -1,19 +1,8 @@
1
- import React, { useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { useSmartCardContext } from '@atlaskit/link-provider';
3
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
3
  export const WithCardContext = ({
5
- children,
6
- value
4
+ children
7
5
  }) => {
8
6
  const cardContext = useSmartCardContext();
9
- const cardContextWithValue = useMemo(() => {
10
- if (!expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
11
- return cardContext;
12
- }
13
- return value ? {
14
- ...cardContext,
15
- value
16
- } : cardContext;
17
- }, [value, cardContext]);
18
- return /*#__PURE__*/React.createElement(React.Fragment, null, children(cardContextWithValue));
7
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children(cardContext));
19
8
  };
@@ -14,7 +14,7 @@ import { blockCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/blockCard';
14
14
  import { embedCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/embedCard';
15
15
  import { inlineCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/inlineCard';
16
16
  import { hideLinkToolbar, setProvider as _setProvider, showDatasourceModal } from './pm-plugins/actions';
17
- import { queueCardsFromChangedTr } from './pm-plugins/doc';
17
+ import { queueCardsFromChangedTr, queueCardsFromRange as _queueCardsFromRange } from './pm-plugins/doc';
18
18
  import { cardKeymap } from './pm-plugins/keymap';
19
19
  import { createPlugin } from './pm-plugins/main';
20
20
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -129,6 +129,19 @@ export var cardPlugin = function cardPlugin(_ref) {
129
129
  editorView: editorView
130
130
  }));
131
131
  },
132
+ commands: {
133
+ queueCardsFromRange: function queueCardsFromRange(from, to, source, analyticsAction, normalizeLinkText, sourceEvent, appearance) {
134
+ return function (_ref5) {
135
+ var tr = _ref5.tr;
136
+ return _queueCardsFromRange(
137
+ // Synthesise the minimal EditorState shape the impl actually reads.
138
+ {
139
+ schema: tr.doc.type.schema,
140
+ selection: tr.selection
141
+ }, tr, from, to, source, analyticsAction, normalizeLinkText, sourceEvent, appearance);
142
+ };
143
+ }
144
+ },
132
145
  actions: {
133
146
  setProvider: function () {
134
147
  var _setProvider2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
@@ -148,8 +161,8 @@ export var cardPlugin = function cardPlugin(_ref) {
148
161
  return _context.abrupt("return", false);
149
162
  case 5:
150
163
  previousCardProvider = provider;
151
- return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref5) {
152
- var tr = _ref5.tr;
164
+ return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref6) {
165
+ var tr = _ref6.tr;
153
166
  return _setProvider(provider)(tr);
154
167
  })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
155
168
  case 7:
@@ -165,6 +178,7 @@ export var cardPlugin = function cardPlugin(_ref) {
165
178
  }(),
166
179
  hideLinkToolbar: hideLinkToolbar,
167
180
  queueCardsFromChangedTr: queueCardsFromChangedTr,
181
+ queueCardsFromRange: _queueCardsFromRange,
168
182
  registerEmbedCardTransformer: function registerEmbedCardTransformer(transformers) {
169
183
  instanceEmbedCardTransformers = transformers;
170
184
  },
@@ -256,8 +270,8 @@ export var cardPlugin = function cardPlugin(_ref) {
256
270
  },
257
271
  pluginsOptions: {
258
272
  floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
259
- quickInsert: function quickInsert(_ref6) {
260
- var formatMessage = _ref6.formatMessage;
273
+ quickInsert: function quickInsert(_ref7) {
274
+ var formatMessage = _ref7.formatMessage;
261
275
  var quickInsertArray = [];
262
276
  if (!options.allowDatasource) {
263
277
  return quickInsertArray;
@@ -20,9 +20,11 @@ import { SmartLinkDraggable, SMART_LINK_DRAG_TYPES, SMART_LINK_APPEARANCE } from
20
20
  import { fg } from '@atlaskit/platform-feature-flags';
21
21
  import { Card as SmartCard } from '@atlaskit/smart-card';
22
22
  import { CardSSR } from '@atlaskit/smart-card/ssr';
23
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
23
24
  import { Datasource } from '../nodeviews/datasource';
24
25
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
25
26
  import { isDatasourceNode } from '../pm-plugins/utils';
27
+ import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
26
28
  import { Card } from './genericCard';
27
29
 
28
30
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -211,8 +213,13 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
211
213
  onClickCallback = _this$reactComponentP3.onClickCallback,
212
214
  CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt,
213
215
  isPageSSRed = _this$reactComponentP3.isPageSSRed,
214
- provider = _this$reactComponentP3.provider;
215
- return /*#__PURE__*/React.createElement(WrappedBlockCard, {
216
+ provider = _this$reactComponentP3.provider,
217
+ intl = _this$reactComponentP3.intl,
218
+ smartCardContext = _this$reactComponentP3.smartCardContext;
219
+ return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
220
+ intl: intl,
221
+ smartCardContext: smartCardContext
222
+ }, /*#__PURE__*/React.createElement(WrappedBlockCard, {
216
223
  node: this.node,
217
224
  view: this.view,
218
225
  getPos: this.getPos,
@@ -223,7 +230,7 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
223
230
  CompetitorPrompt: CompetitorPrompt,
224
231
  isPageSSRed: isPageSSRed,
225
232
  provider: provider
226
- });
233
+ }));
227
234
  }
228
235
 
229
236
  /**
@@ -260,7 +267,9 @@ export var blockCardNodeView = function blockCardNodeView(_ref3) {
260
267
  inlineCardViewProducer = _ref3.inlineCardViewProducer,
261
268
  CompetitorPrompt = _ref3.CompetitorPrompt,
262
269
  isPageSSRed = _ref3.isPageSSRed,
263
- provider = _ref3.provider;
270
+ provider = _ref3.provider,
271
+ intl = _ref3.intl,
272
+ smartCardContext = _ref3.smartCardContext;
264
273
  return function (node, view, getPos, decorations) {
265
274
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
266
275
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
@@ -270,7 +279,9 @@ export var blockCardNodeView = function blockCardNodeView(_ref3) {
270
279
  onClickCallback: onClickCallback,
271
280
  CompetitorPrompt: CompetitorPrompt,
272
281
  isPageSSRed: isPageSSRed,
273
- provider: provider
282
+ provider: provider,
283
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
284
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
274
285
  };
275
286
  var isDatasource = isDatasourceNode(node);
276
287
  if (isDatasource) {
@@ -28,10 +28,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
28
28
  import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
29
29
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
30
30
  import { CardSSR } from '@atlaskit/smart-card/ssr';
31
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
31
32
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
32
33
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
33
34
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
34
35
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
36
+ import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
35
37
  import { BlockCardComponent } from './blockCard';
36
38
  import { Card } from './genericCard';
37
39
 
@@ -526,8 +528,13 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
526
528
  onClickCallback = _this$reactComponentP3.onClickCallback,
527
529
  CompetitorPrompt = _this$reactComponentP3.CompetitorPrompt,
528
530
  isPageSSRed = _this$reactComponentP3.isPageSSRed,
529
- provider = _this$reactComponentP3.provider;
530
- return /*#__PURE__*/React.createElement(WrappedEmbedCard, {
531
+ provider = _this$reactComponentP3.provider,
532
+ intl = _this$reactComponentP3.intl,
533
+ smartCardContext = _this$reactComponentP3.smartCardContext;
534
+ return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
535
+ intl: intl,
536
+ smartCardContext: smartCardContext
537
+ }, /*#__PURE__*/React.createElement(WrappedEmbedCard, {
531
538
  node: this.node,
532
539
  view: this.view,
533
540
  eventDispatcher: eventDispatcher,
@@ -541,7 +548,7 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
541
548
  CompetitorPrompt: CompetitorPrompt,
542
549
  isPageSSRed: isPageSSRed,
543
550
  provider: provider
544
- });
551
+ }));
545
552
  }
546
553
 
547
554
  /**
@@ -578,7 +585,9 @@ export var embedCardNodeView = function embedCardNodeView(_ref4) {
578
585
  onClickCallback = _ref4.onClickCallback,
579
586
  CompetitorPrompt = _ref4.CompetitorPrompt,
580
587
  isPageSSRed = _ref4.isPageSSRed,
581
- provider = _ref4.provider;
588
+ provider = _ref4.provider,
589
+ intl = _ref4.intl,
590
+ smartCardContext = _ref4.smartCardContext;
582
591
  return function (node, view, getPos) {
583
592
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
584
593
  eventDispatcher = pmPluginFactoryParams.eventDispatcher,
@@ -593,7 +602,9 @@ export var embedCardNodeView = function embedCardNodeView(_ref4) {
593
602
  onClickCallback: onClickCallback,
594
603
  CompetitorPrompt: CompetitorPrompt,
595
604
  isPageSSRed: isPageSSRed,
596
- provider: provider
605
+ provider: provider,
606
+ intl: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? intl : undefined,
607
+ smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
597
608
  };
598
609
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps).init();
599
610
  };
@@ -13,7 +13,6 @@ import { AnalyticsContext } from '@atlaskit/analytics-next';
13
13
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
14
14
  import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
15
15
  import Link from '@atlaskit/link';
16
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
16
  import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
18
17
  import { getPluginState } from '../pm-plugins/util/state';
19
18
  import { titleUrlPairFromNode } from '../pm-plugins/utils';
@@ -78,8 +77,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
78
77
  _this2 = this;
79
78
  var _this$props = this.props,
80
79
  pluginInjectionApi = _this$props.pluginInjectionApi,
81
- onClickCallback = _this$props.onClickCallback,
82
- smartCardContext = _this$props.smartCardContext;
80
+ onClickCallback = _this$props.onClickCallback;
83
81
  var _titleUrlPairFromNode = titleUrlPairFromNode(this.props.node),
84
82
  url = _titleUrlPairFromNode.url;
85
83
  if (url && !isSafeUrl(url)) {
@@ -117,9 +115,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
117
115
  url: url
118
116
  }, function (_ref2) {
119
117
  var onClick = _ref2.onClick;
120
- return /*#__PURE__*/React.createElement(WithCardContext, {
121
- value: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
122
- }, function (cardContext) {
118
+ return /*#__PURE__*/React.createElement(WithCardContext, null, function (cardContext) {
123
119
  return /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
124
120
  key: url,
125
121
  cardContext: cardContext
@@ -15,6 +15,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
16
16
  import { registerCard, removeCard } from '../pm-plugins/actions';
17
17
  import { getAwarenessProps } from '../pm-plugins/utils';
18
+ import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
18
19
  import { visitCardLinkAnalytics } from '../ui/toolbar';
19
20
  import { Card } from './genericCard';
20
21
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
@@ -191,6 +192,7 @@ export function InlineCardNodeView(props) {
191
192
  isPageSSRed = props.isPageSSRed,
192
193
  provider = props.provider,
193
194
  CompetitorPrompt = props.CompetitorPrompt,
195
+ intl = props.intl,
194
196
  smartCardContext = props.smartCardContext;
195
197
  var _useSharedPluginState = useSharedPluginStateWithSelector(pluginInjectionApi, expVal('cc_dnd_smart_link_changeboard_platform_css', 'isEnabled', false) && fg('cc_drag_and_drop_smart_link_from_content_to_tree') ? ['editorViewMode', 'card'] : ['editorViewMode'], expVal('cc_dnd_smart_link_changeboard_platform_css', 'isEnabled', false) && fg('cc_drag_and_drop_smart_link_from_content_to_tree') ? selectorWithCard : selectorWithoutCard),
196
198
  mode = _useSharedPluginState.mode,
@@ -227,17 +229,19 @@ export function InlineCardNodeView(props) {
227
229
  onClickCallback: onClickCallback,
228
230
  isPageSSRed: isPageSSRed,
229
231
  provider: provider,
230
- appearance: "inline",
231
- smartCardContext: expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? smartCardContext : undefined
232
+ appearance: "inline"
232
233
  // Ignored via go/ees005
233
234
  // eslint-disable-next-line react/jsx-props-no-spreading
234
235
  }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, mode === 'view'))), CompetitorPromptComponent);
235
- return /*#__PURE__*/React.createElement(SmartLinkDraggable, {
236
+ return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
237
+ intl: intl,
238
+ smartCardContext: smartCardContext
239
+ }, /*#__PURE__*/React.createElement(SmartLinkDraggable, {
236
240
  url: url,
237
241
  appearance: SMART_LINK_APPEARANCE.INLINE,
238
242
  source: SMART_LINK_DRAG_TYPES.EDITOR,
239
243
  isChangeboardTarget: isChangeboardTarget
240
- }, inlineCardContent);
244
+ }, inlineCardContent));
241
245
  }
242
246
  export var inlineCardNodeView = function inlineCardNodeView(_ref5) {
243
247
  var inlineCardViewProducer = _ref5.inlineCardViewProducer;