@atlaskit/editor-plugin-card 11.4.1 → 11.4.3

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.
@@ -1,8 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
4
  import uuid from 'uuid/v4';
5
- import { EditorCardProvider } from '@atlaskit/editor-card-provider';
6
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
6
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
7
  import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
@@ -50,22 +49,6 @@ export const InlineCard = /*#__PURE__*/memo(({
50
49
  view.dispatch(tr);
51
50
  };
52
51
  }, [getPos, view]);
53
- const [isSSRDataAvailable, setIsSSRDataAvailable] = useState(expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed);
54
- useEffect(() => {
55
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
56
- return;
57
- }
58
- if (!provider) {
59
- return;
60
- }
61
- const updateSSRDataAvailability = async () => {
62
- const resolvedProvider = await provider;
63
- if (resolvedProvider instanceof EditorCardProvider) {
64
- setIsSSRDataAvailable(resolvedProvider.getCacheStatusForNode(node) === 'ssr');
65
- }
66
- };
67
- void updateSSRDataAvailability();
68
- }, [provider, node]);
69
52
  const scrollContainer = useMemo(
70
53
  // Ignored via go/ees005
71
54
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -124,10 +107,7 @@ export const InlineCard = /*#__PURE__*/memo(({
124
107
  }, [propsOnClick, url, view, pluginInjectionApi]);
125
108
  const onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
126
109
  const card = useMemo(() => {
127
- if (
128
- // The `isSSRDataAvailable` check is only required when the OTP experiment is on,
129
- // because inline smart card SSR is already implemented without OTP.
130
- (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? isSSRDataAvailable : true) && isPageSSRed && url) {
110
+ if (isPageSSRed && url) {
131
111
  return /*#__PURE__*/React.createElement(CardSSR, {
132
112
  key: url,
133
113
  url: url,
@@ -143,9 +123,8 @@ export const InlineCard = /*#__PURE__*/memo(({
143
123
  hoverPreviewOptions: hoverPreviewOptions,
144
124
  disablePreviewPanel: disablePreviewPanel
145
125
  // Durin `platform_editor_smart_card_otp` cleaning up, replace this with `true`.
146
- // Ths `isSSRDataAvailable` should be checked in the `if` condition above.
147
126
  ,
148
- hideIconLoadingSkeleton: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isSSRDataAvailable
127
+ hideIconLoadingSkeleton: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)
149
128
  });
150
129
  }
151
130
  return /*#__PURE__*/React.createElement(SmartCard, {
@@ -163,7 +142,7 @@ export const InlineCard = /*#__PURE__*/memo(({
163
142
  hoverPreviewOptions: hoverPreviewOptions,
164
143
  disablePreviewPanel: disablePreviewPanel
165
144
  });
166
- }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, isSSRDataAvailable]);
145
+ }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel]);
167
146
 
168
147
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
169
148
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -1,5 +1,4 @@
1
1
  import _get from "@babel/runtime/helpers/get";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
@@ -7,15 +6,11 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
6
  import _inherits from "@babel/runtime/helpers/inherits";
8
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
8
  function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
10
- import _regeneratorRuntime from "@babel/runtime/regenerator";
11
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- 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; }
13
9
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
14
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
15
11
  import React from 'react';
16
12
  import rafSchedule from 'raf-schd';
17
13
  import uuid from 'uuid/v4';
18
- import { EditorCardProvider } from '@atlaskit/editor-card-provider';
19
14
  import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
20
15
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
21
16
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -27,6 +22,7 @@ import { Datasource } from '../nodeviews/datasource';
27
22
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
28
23
  import { isDatasourceNode } from '../pm-plugins/utils';
29
24
  import { Card } from './genericCard';
25
+
30
26
  // eslint-disable-next-line @repo/internal/react/no-class-components
31
27
  export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
32
28
  function BlockCardComponent(props) {
@@ -35,9 +31,6 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
35
31
  _this = _callSuper(this, BlockCardComponent, [props]);
36
32
  // Ignored via go/ees005
37
33
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
38
- _defineProperty(_this, "state", {
39
- isSSRDataAvailable: false
40
- });
41
34
  _defineProperty(_this, "onResolve", function (data) {
42
35
  var _this$props = _this.props,
43
36
  getPos = _this$props.getPos,
@@ -85,53 +78,10 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
85
78
  }
86
79
  });
87
80
  _this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
88
- _this.state = {
89
- isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
90
- };
91
81
  return _this;
92
82
  }
93
83
  _inherits(BlockCardComponent, _React$PureComponent);
94
84
  return _createClass(BlockCardComponent, [{
95
- key: "componentDidMount",
96
- value: function componentDidMount() {
97
- var _this2 = this;
98
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
99
- return;
100
- }
101
- var provider = this.props.provider;
102
- if (!provider) {
103
- return;
104
- }
105
- var updateSSRDataAvailability = /*#__PURE__*/function () {
106
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
107
- var resolvedProvider;
108
- return _regeneratorRuntime.wrap(function _callee$(_context) {
109
- while (1) switch (_context.prev = _context.next) {
110
- case 0:
111
- _context.next = 2;
112
- return provider;
113
- case 2:
114
- resolvedProvider = _context.sent;
115
- if (resolvedProvider instanceof EditorCardProvider) {
116
- _this2.setState(function (state) {
117
- return _objectSpread(_objectSpread({}, state), {}, {
118
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
119
- });
120
- });
121
- }
122
- case 4:
123
- case "end":
124
- return _context.stop();
125
- }
126
- }, _callee);
127
- }));
128
- return function updateSSRDataAvailability() {
129
- return _ref2.apply(this, arguments);
130
- };
131
- }();
132
- void updateSSRDataAvailability();
133
- }
134
- }, {
135
85
  key: "componentWillUnmount",
136
86
  value: function componentWillUnmount() {
137
87
  this.removeCard();
@@ -162,7 +112,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
162
112
  var _node$attrs = node.attrs,
163
113
  url = _node$attrs.url,
164
114
  data = _node$attrs.data;
165
- var cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
115
+ var cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
166
116
  key: url,
167
117
  url: url !== null && url !== void 0 ? url : data.url,
168
118
  container: this.scrollContainer,
@@ -197,31 +147,31 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
197
147
  var WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
198
148
  export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
199
149
  function BlockCard() {
200
- var _this3;
150
+ var _this2;
201
151
  _classCallCheck(this, BlockCard);
202
152
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
203
153
  args[_key] = arguments[_key];
204
154
  }
205
- _this3 = _callSuper(this, BlockCard, [].concat(args));
206
- _defineProperty(_this3, "id", uuid());
207
- _defineProperty(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
155
+ _this2 = _callSuper(this, BlockCard, [].concat(args));
156
+ _defineProperty(_this2, "id", uuid());
157
+ _defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
208
158
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
209
159
  });
210
- return _this3;
160
+ return _this2;
211
161
  }
212
162
  _inherits(BlockCard, _ReactNodeView);
213
163
  return _createClass(BlockCard, [{
214
164
  key: "createDomRef",
215
165
  value: function createDomRef() {
216
166
  var _this$reactComponentP,
217
- _this4 = this,
167
+ _this3 = this,
218
168
  _this$reactComponentP2;
219
169
  var domRef = document.createElement('div');
220
170
  // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
221
171
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
222
- this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref3) {
223
- var nextSharedState = _ref3.nextSharedState;
224
- return _this4.updateContentEditable(nextSharedState, domRef);
172
+ this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref2) {
173
+ var nextSharedState = _ref2.nextSharedState;
174
+ return _this3.updateContentEditable(nextSharedState, domRef);
225
175
  });
226
176
  this.updateContentEditable((_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.currentState(), domRef);
227
177
  domRef.setAttribute('spellcheck', 'false');
@@ -277,16 +227,16 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
277
227
  }
278
228
  }]);
279
229
  }(ReactNodeView);
280
- export var blockCardNodeView = function blockCardNodeView(_ref4) {
281
- var pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
282
- actionOptions = _ref4.actionOptions,
283
- pluginInjectionApi = _ref4.pluginInjectionApi,
284
- onClickCallback = _ref4.onClickCallback,
285
- allowDatasource = _ref4.allowDatasource,
286
- inlineCardViewProducer = _ref4.inlineCardViewProducer,
287
- CompetitorPrompt = _ref4.CompetitorPrompt,
288
- isPageSSRed = _ref4.isPageSSRed,
289
- provider = _ref4.provider;
230
+ export var blockCardNodeView = function blockCardNodeView(_ref3) {
231
+ var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
232
+ actionOptions = _ref3.actionOptions,
233
+ pluginInjectionApi = _ref3.pluginInjectionApi,
234
+ onClickCallback = _ref3.onClickCallback,
235
+ allowDatasource = _ref3.allowDatasource,
236
+ inlineCardViewProducer = _ref3.inlineCardViewProducer,
237
+ CompetitorPrompt = _ref3.CompetitorPrompt,
238
+ isPageSSRed = _ref3.isPageSSRed,
239
+ provider = _ref3.provider;
290
240
  return function (node, view, getPos, decorations) {
291
241
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
292
242
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
@@ -1,5 +1,4 @@
1
1
  import _get from "@babel/runtime/helpers/get";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
@@ -8,7 +7,6 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
8
  import _extends from "@babel/runtime/helpers/extends";
10
9
  function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
11
- import _regeneratorRuntime from "@babel/runtime/regenerator";
12
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
11
  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; }
14
12
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
@@ -17,7 +15,6 @@ import React from 'react';
17
15
  import rafSchedule from 'raf-schd';
18
16
  import uuid from 'uuid/v4';
19
17
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
20
- import { EditorCardProvider } from '@atlaskit/editor-card-provider';
21
18
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
22
19
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
23
20
  import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -261,53 +258,12 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
261
258
  _defineProperty(_this, "removeCardDispatched", false);
262
259
  _this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
263
260
  _this.state = {
264
- hasPreview: true,
265
- isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
261
+ hasPreview: true
266
262
  };
267
263
  return _this;
268
264
  }
269
265
  _inherits(EmbedCardComponent, _React$PureComponent);
270
266
  return _createClass(EmbedCardComponent, [{
271
- key: "componentDidMount",
272
- value: function componentDidMount() {
273
- var _this2 = this;
274
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
275
- return;
276
- }
277
- var provider = this.props.provider;
278
- if (!provider) {
279
- return;
280
- }
281
- var updateSSRDataAvailability = /*#__PURE__*/function () {
282
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
283
- var resolvedProvider;
284
- return _regeneratorRuntime.wrap(function _callee$(_context) {
285
- while (1) switch (_context.prev = _context.next) {
286
- case 0:
287
- _context.next = 2;
288
- return provider;
289
- case 2:
290
- resolvedProvider = _context.sent;
291
- if (resolvedProvider instanceof EditorCardProvider) {
292
- _this2.setState(function (state) {
293
- return _objectSpread(_objectSpread({}, state), {}, {
294
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
295
- });
296
- });
297
- }
298
- case 4:
299
- case "end":
300
- return _context.stop();
301
- }
302
- }, _callee);
303
- }));
304
- return function updateSSRDataAvailability() {
305
- return _ref3.apply(this, arguments);
306
- };
307
- }();
308
- void updateSSRDataAvailability();
309
- }
310
- }, {
311
267
  key: "componentWillUnmount",
312
268
  value: function componentWillUnmount() {
313
269
  this.removeCard();
@@ -366,7 +322,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
366
322
  pctWidth: pctWidth,
367
323
  fullWidthMode: fullWidthMode
368
324
  };
369
- var smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/React.createElement(CardSSR, {
325
+ var smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(CardSSR, {
370
326
  key: url,
371
327
  url: url,
372
328
  appearance: "embed",
@@ -471,17 +427,17 @@ var WrappedEmbedCardWithCondition = componentWithCondition(function () {
471
427
  var WrappedEmbedCard = Card(WrappedEmbedCardWithCondition, UnsupportedBlock);
472
428
  export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
473
429
  function EmbedCard() {
474
- var _this3;
430
+ var _this2;
475
431
  _classCallCheck(this, EmbedCard);
476
432
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
477
433
  args[_key] = arguments[_key];
478
434
  }
479
- _this3 = _callSuper(this, EmbedCard, [].concat(args));
480
- _defineProperty(_this3, "id", uuid());
481
- _defineProperty(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
435
+ _this2 = _callSuper(this, EmbedCard, [].concat(args));
436
+ _defineProperty(_this2, "id", uuid());
437
+ _defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
482
438
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
483
439
  });
484
- return _this3;
440
+ return _this2;
485
441
  }
486
442
  _inherits(EmbedCard, _ReactNodeView);
487
443
  return _createClass(EmbedCard, [{
@@ -496,13 +452,13 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
496
452
  key: "createDomRef",
497
453
  value: function createDomRef() {
498
454
  var _this$reactComponentP,
499
- _this4 = this,
455
+ _this3 = this,
500
456
  _this$reactComponentP2;
501
457
  var domRef = document.createElement('div');
502
458
  // It is a tradeoff for the bug mentioned that occurs in Chrome: https://product-fabric.atlassian.net/browse/ED-5379, https://github.com/ProseMirror/prosemirror/issues/884
503
- this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref4) {
504
- var nextSharedState = _ref4.nextSharedState;
505
- return _this4.updateContentEditable(nextSharedState, domRef);
459
+ this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref3) {
460
+ var nextSharedState = _ref3.nextSharedState;
461
+ return _this3.updateContentEditable(nextSharedState, domRef);
506
462
  });
507
463
  this.updateContentEditable((_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.currentState(), domRef);
508
464
  domRef.setAttribute('spellcheck', 'false');
@@ -546,16 +502,16 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
546
502
  }
547
503
  }]);
548
504
  }(ReactNodeView);
549
- export var embedCardNodeView = function embedCardNodeView(_ref5) {
550
- var allowResizing = _ref5.allowResizing,
551
- fullWidthMode = _ref5.fullWidthMode,
552
- pmPluginFactoryParams = _ref5.pmPluginFactoryParams,
553
- pluginInjectionApi = _ref5.pluginInjectionApi,
554
- actionOptions = _ref5.actionOptions,
555
- onClickCallback = _ref5.onClickCallback,
556
- CompetitorPrompt = _ref5.CompetitorPrompt,
557
- isPageSSRed = _ref5.isPageSSRed,
558
- provider = _ref5.provider;
505
+ export var embedCardNodeView = function embedCardNodeView(_ref4) {
506
+ var allowResizing = _ref4.allowResizing,
507
+ fullWidthMode = _ref4.fullWidthMode,
508
+ pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
509
+ pluginInjectionApi = _ref4.pluginInjectionApi,
510
+ actionOptions = _ref4.actionOptions,
511
+ onClickCallback = _ref4.onClickCallback,
512
+ CompetitorPrompt = _ref4.CompetitorPrompt,
513
+ isPageSSRed = _ref4.isPageSSRed,
514
+ provider = _ref4.provider;
559
515
  return function (node, view, getPos) {
560
516
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
561
517
  eventDispatcher = pmPluginFactoryParams.eventDispatcher,
@@ -18,6 +18,7 @@ import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
18
18
  import { getPluginState } from '../pm-plugins/util/state';
19
19
  import { titleUrlPairFromNode } from '../pm-plugins/utils';
20
20
  import { WithCardContext } from '../ui/WithCardContext';
21
+ var fatalErrorPositionMap = new Map();
21
22
  var WithClickHandler = function WithClickHandler(_ref) {
22
23
  var pluginInjectionApi = _ref.pluginInjectionApi,
23
24
  url = _ref.url,
@@ -155,7 +156,19 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
155
156
  if (!getPos || typeof getPos === 'boolean') {
156
157
  return;
157
158
  }
159
+ var pos = getPos();
160
+
161
+ /**
162
+ * We cache fatal errors by position to avoid retrying the same errors
163
+ * on the same links at the same position.
164
+ */
165
+ if (url && pos && fatalErrorPositionMap.get(url) === pos && fg('platform_editor_ai_aifc_patch_beta_2')) {
166
+ return null;
167
+ }
158
168
  changeSelectedCardToLinkFallback(undefined, url, true, node, getPos(), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(view.state, view.dispatch);
169
+ if (url && pos && fg('platform_editor_ai_aifc_patch_beta_2')) {
170
+ fatalErrorPositionMap.set(url, pos);
171
+ }
159
172
  return null;
160
173
  } else {
161
174
  // Otherwise, render a blue link as fallback (above in render()).
@@ -1,11 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
6
3
  import rafSchedule from 'raf-schd';
7
4
  import uuid from 'uuid/v4';
8
- import { EditorCardProvider } from '@atlaskit/editor-card-provider';
9
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
6
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
11
7
  import { UnsupportedInline, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
@@ -49,42 +45,6 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
49
45
  view.dispatch(tr);
50
46
  };
51
47
  }, [getPos, view]);
52
- var _useState = useState(expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed),
53
- _useState2 = _slicedToArray(_useState, 2),
54
- isSSRDataAvailable = _useState2[0],
55
- setIsSSRDataAvailable = _useState2[1];
56
- useEffect(function () {
57
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
58
- return;
59
- }
60
- if (!provider) {
61
- return;
62
- }
63
- var updateSSRDataAvailability = /*#__PURE__*/function () {
64
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
65
- var resolvedProvider;
66
- return _regeneratorRuntime.wrap(function _callee$(_context) {
67
- while (1) switch (_context.prev = _context.next) {
68
- case 0:
69
- _context.next = 2;
70
- return provider;
71
- case 2:
72
- resolvedProvider = _context.sent;
73
- if (resolvedProvider instanceof EditorCardProvider) {
74
- setIsSSRDataAvailable(resolvedProvider.getCacheStatusForNode(node) === 'ssr');
75
- }
76
- case 4:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }));
82
- return function updateSSRDataAvailability() {
83
- return _ref2.apply(this, arguments);
84
- };
85
- }();
86
- void updateSSRDataAvailability();
87
- }, [provider, node]);
88
48
  var scrollContainer = useMemo(
89
49
  // Ignored via go/ees005
90
50
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -129,8 +89,8 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
129
89
  var handleOnClick = useCallback(function (event) {
130
90
  if (event.metaKey || event.ctrlKey) {
131
91
  var _pluginInjectionApi$a;
132
- var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
133
- editorAnalyticsApi = _ref3.actions;
92
+ var _ref2 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
93
+ editorAnalyticsApi = _ref2.actions;
134
94
  visitCardLinkAnalytics(editorAnalyticsApi, INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
135
95
  window.open(url, '_blank');
136
96
  } else {
@@ -140,10 +100,7 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
140
100
  }, [propsOnClick, url, view, pluginInjectionApi]);
141
101
  var onClick = editorExperiment('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
142
102
  var card = useMemo(function () {
143
- if (
144
- // The `isSSRDataAvailable` check is only required when the OTP experiment is on,
145
- // because inline smart card SSR is already implemented without OTP.
146
- (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? isSSRDataAvailable : true) && isPageSSRed && url) {
103
+ if (isPageSSRed && url) {
147
104
  return /*#__PURE__*/React.createElement(CardSSR, {
148
105
  key: url,
149
106
  url: url,
@@ -159,9 +116,8 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
159
116
  hoverPreviewOptions: hoverPreviewOptions,
160
117
  disablePreviewPanel: disablePreviewPanel
161
118
  // Durin `platform_editor_smart_card_otp` cleaning up, replace this with `true`.
162
- // Ths `isSSRDataAvailable` should be checked in the `if` condition above.
163
119
  ,
164
- hideIconLoadingSkeleton: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isSSRDataAvailable
120
+ hideIconLoadingSkeleton: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)
165
121
  });
166
122
  }
167
123
  return /*#__PURE__*/React.createElement(SmartCard, {
@@ -179,7 +135,7 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
179
135
  hoverPreviewOptions: hoverPreviewOptions,
180
136
  disablePreviewPanel: disablePreviewPanel
181
137
  });
182
- }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, isSSRDataAvailable]);
138
+ }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel]);
183
139
 
184
140
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
185
141
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -236,8 +192,8 @@ export function InlineCardNodeView(props) {
236
192
  // eslint-disable-next-line react/jsx-props-no-spreading
237
193
  }, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, mode === 'view'))), fg('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
238
194
  }
239
- export var inlineCardNodeView = function inlineCardNodeView(_ref4) {
240
- var inlineCardViewProducer = _ref4.inlineCardViewProducer;
195
+ export var inlineCardNodeView = function inlineCardNodeView(_ref3) {
196
+ var inlineCardViewProducer = _ref3.inlineCardViewProducer;
241
197
  return function (node, view, getPos, decorations) {
242
198
  return inlineCardViewProducer(node, view, getPos, decorations);
243
199
  };
@@ -5,14 +5,10 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- interface State {
9
- isSSRDataAvailable?: boolean;
10
- }
11
8
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
12
9
  id?: string;
13
- }, State> {
10
+ }, unknown> {
14
11
  private scrollContainer?;
15
- state: State;
16
12
  constructor(props: SmartCardProps & {
17
13
  id?: string;
18
14
  });
@@ -20,7 +16,6 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
20
16
  title?: string;
21
17
  url?: string;
22
18
  }) => void;
23
- componentDidMount(): void;
24
19
  componentWillUnmount(): void;
25
20
  private removeCardDispatched;
26
21
  private removeCard;
@@ -56,4 +51,3 @@ export interface BlockCardNodeViewProperties {
56
51
  provider: BlockCardNodeViewProps['provider'];
57
52
  }
58
53
  export declare const blockCardNodeView: ({ pmPluginFactoryParams, actionOptions, pluginInjectionApi, onClickCallback, allowDatasource, inlineCardViewProducer, CompetitorPrompt, isPageSSRed, provider, }: BlockCardNodeViewProperties) => (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[]) => import("prosemirror-view").NodeView | Datasource | BlockCard;
59
- export {};
@@ -9,7 +9,6 @@ import type { SmartCardProps } from './genericCard';
9
9
  export type EmbedCardState = {
10
10
  hasPreview: boolean;
11
11
  initialAspectRatio?: number;
12
- isSSRDataAvailable?: boolean;
13
12
  liveHeight?: number;
14
13
  };
15
14
  export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
@@ -39,7 +38,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
39
38
  onError: ({ err }: {
40
39
  err?: Error;
41
40
  }) => void;
42
- componentDidMount(): void;
43
41
  componentWillUnmount(): void;
44
42
  private removeCardDispatched;
45
43
  private removeCard;
@@ -5,14 +5,10 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- interface State {
9
- isSSRDataAvailable?: boolean;
10
- }
11
8
  export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
12
9
  id?: string;
13
- }, State> {
10
+ }, unknown> {
14
11
  private scrollContainer?;
15
- state: State;
16
12
  constructor(props: SmartCardProps & {
17
13
  id?: string;
18
14
  });
@@ -20,7 +16,6 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
20
16
  title?: string;
21
17
  url?: string;
22
18
  }) => void;
23
- componentDidMount(): void;
24
19
  componentWillUnmount(): void;
25
20
  private removeCardDispatched;
26
21
  private removeCard;
@@ -56,4 +51,3 @@ export interface BlockCardNodeViewProperties {
56
51
  provider: BlockCardNodeViewProps['provider'];
57
52
  }
58
53
  export declare const blockCardNodeView: ({ pmPluginFactoryParams, actionOptions, pluginInjectionApi, onClickCallback, allowDatasource, inlineCardViewProducer, CompetitorPrompt, isPageSSRed, provider, }: BlockCardNodeViewProperties) => (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[]) => import("prosemirror-view").NodeView | Datasource | BlockCard;
59
- export {};
@@ -9,7 +9,6 @@ import type { SmartCardProps } from './genericCard';
9
9
  export type EmbedCardState = {
10
10
  hasPreview: boolean;
11
11
  initialAspectRatio?: number;
12
- isSSRDataAvailable?: boolean;
13
12
  liveHeight?: number;
14
13
  };
15
14
  export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
@@ -39,7 +38,6 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
39
38
  onError: ({ err }: {
40
39
  err?: Error;
41
40
  }) => void;
42
- componentDidMount(): void;
43
41
  componentWillUnmount(): void;
44
42
  private removeCardDispatched;
45
43
  private removeCard;