@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 11.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9854f5d3e02e7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9854f5d3e02e7) -
8
+ EDITOR-2416: Add a fatal error position map to cache errors to prevent the failed link conversion
9
+ to run multiple times for the same links at the same positions.
10
+ - [`c28cd65d12c24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c28cd65d12c24) -
11
+ EDITOR-2447 Bump adf-schema to 51.3.1
12
+ - Updated dependencies
13
+
14
+ ## 11.4.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [`57a9de1ebc5db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57a9de1ebc5db) -
19
+ fix: remove unnecessary re-renders in smart card node views
20
+ - Updated dependencies
21
+
3
22
  ## 11.4.1
4
23
 
5
24
  ### Patch Changes
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.blockCardNodeView = exports.BlockCardComponent = exports.BlockCard = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
8
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -17,7 +15,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
17
15
  var _react = _interopRequireDefault(require("react"));
18
16
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
17
  var _v = _interopRequireDefault(require("uuid/v4"));
20
- var _editorCardProvider = require("@atlaskit/editor-card-provider");
21
18
  var _browser = require("@atlaskit/editor-common/browser");
22
19
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
23
20
  var _ui = require("@atlaskit/editor-common/ui");
@@ -30,8 +27,6 @@ var _actions = require("../pm-plugins/actions");
30
27
  var _utils2 = require("../pm-plugins/utils");
31
28
  var _genericCard = require("./genericCard");
32
29
  function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
33
- 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; }
34
- 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) { (0, _defineProperty2.default)(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; }
35
30
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
36
31
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
37
32
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -42,9 +37,6 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
42
37
  _this = _callSuper(this, BlockCardComponent, [props]);
43
38
  // Ignored via go/ees005
44
39
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
45
- (0, _defineProperty2.default)(_this, "state", {
46
- isSSRDataAvailable: false
47
- });
48
40
  (0, _defineProperty2.default)(_this, "onResolve", function (data) {
49
41
  var _this$props = _this.props,
50
42
  getPos = _this$props.getPos,
@@ -92,53 +84,10 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
92
84
  }
93
85
  });
94
86
  _this.scrollContainer = (0, _ui.findOverflowScrollParent)(props.view.dom) || undefined;
95
- _this.state = {
96
- isSSRDataAvailable: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
97
- };
98
87
  return _this;
99
88
  }
100
89
  (0, _inherits2.default)(BlockCardComponent, _React$PureComponent);
101
90
  return (0, _createClass2.default)(BlockCardComponent, [{
102
- key: "componentDidMount",
103
- value: function componentDidMount() {
104
- var _this2 = this;
105
- if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
106
- return;
107
- }
108
- var provider = this.props.provider;
109
- if (!provider) {
110
- return;
111
- }
112
- var updateSSRDataAvailability = /*#__PURE__*/function () {
113
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
114
- var resolvedProvider;
115
- return _regenerator.default.wrap(function _callee$(_context) {
116
- while (1) switch (_context.prev = _context.next) {
117
- case 0:
118
- _context.next = 2;
119
- return provider;
120
- case 2:
121
- resolvedProvider = _context.sent;
122
- if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
123
- _this2.setState(function (state) {
124
- return _objectSpread(_objectSpread({}, state), {}, {
125
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
126
- });
127
- });
128
- }
129
- case 4:
130
- case "end":
131
- return _context.stop();
132
- }
133
- }, _callee);
134
- }));
135
- return function updateSSRDataAvailability() {
136
- return _ref2.apply(this, arguments);
137
- };
138
- }();
139
- void updateSSRDataAvailability();
140
- }
141
- }, {
142
91
  key: "componentWillUnmount",
143
92
  value: function componentWillUnmount() {
144
93
  this.removeCard();
@@ -169,7 +118,7 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
169
118
  var _node$attrs = node.attrs,
170
119
  url = _node$attrs.url,
171
120
  data = _node$attrs.data;
172
- var cardInner = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
121
+ var cardInner = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
173
122
  key: url,
174
123
  url: url !== null && url !== void 0 ? url : data.url,
175
124
  container: this.scrollContainer,
@@ -204,31 +153,31 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
204
153
  var WrappedBlockCard = (0, _genericCard.Card)(BlockCardComponent, _ui.UnsupportedBlock);
205
154
  var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
206
155
  function BlockCard() {
207
- var _this3;
156
+ var _this2;
208
157
  (0, _classCallCheck2.default)(this, BlockCard);
209
158
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
210
159
  args[_key] = arguments[_key];
211
160
  }
212
- _this3 = _callSuper(this, BlockCard, [].concat(args));
213
- (0, _defineProperty2.default)(_this3, "id", (0, _v.default)());
214
- (0, _defineProperty2.default)(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
161
+ _this2 = _callSuper(this, BlockCard, [].concat(args));
162
+ (0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
163
+ (0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
215
164
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
216
165
  });
217
- return _this3;
166
+ return _this2;
218
167
  }
219
168
  (0, _inherits2.default)(BlockCard, _ReactNodeView);
220
169
  return (0, _createClass2.default)(BlockCard, [{
221
170
  key: "createDomRef",
222
171
  value: function createDomRef() {
223
172
  var _this$reactComponentP,
224
- _this4 = this,
173
+ _this3 = this,
225
174
  _this$reactComponentP2;
226
175
  var domRef = document.createElement('div');
227
176
  // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
228
177
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
229
- 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) {
230
- var nextSharedState = _ref3.nextSharedState;
231
- return _this4.updateContentEditable(nextSharedState, domRef);
178
+ 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) {
179
+ var nextSharedState = _ref2.nextSharedState;
180
+ return _this3.updateContentEditable(nextSharedState, domRef);
232
181
  });
233
182
  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);
234
183
  domRef.setAttribute('spellcheck', 'false');
@@ -284,16 +233,16 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
284
233
  }
285
234
  }]);
286
235
  }(_reactNodeView.default);
287
- var blockCardNodeView = exports.blockCardNodeView = function blockCardNodeView(_ref4) {
288
- var pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
289
- actionOptions = _ref4.actionOptions,
290
- pluginInjectionApi = _ref4.pluginInjectionApi,
291
- onClickCallback = _ref4.onClickCallback,
292
- allowDatasource = _ref4.allowDatasource,
293
- inlineCardViewProducer = _ref4.inlineCardViewProducer,
294
- CompetitorPrompt = _ref4.CompetitorPrompt,
295
- isPageSSRed = _ref4.isPageSSRed,
296
- provider = _ref4.provider;
236
+ var blockCardNodeView = exports.blockCardNodeView = function blockCardNodeView(_ref3) {
237
+ var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
238
+ actionOptions = _ref3.actionOptions,
239
+ pluginInjectionApi = _ref3.pluginInjectionApi,
240
+ onClickCallback = _ref3.onClickCallback,
241
+ allowDatasource = _ref3.allowDatasource,
242
+ inlineCardViewProducer = _ref3.inlineCardViewProducer,
243
+ CompetitorPrompt = _ref3.CompetitorPrompt,
244
+ isPageSSRed = _ref3.isPageSSRed,
245
+ provider = _ref3.provider;
297
246
  return function (node, view, getPos, decorations) {
298
247
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
299
248
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.embedCardNodeView = exports.EmbedOrBlockCardComponent = exports.EmbedCardComponent = exports.EmbedCard = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
8
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -19,7 +17,6 @@ var _react = _interopRequireDefault(require("react"));
19
17
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
20
18
  var _v = _interopRequireDefault(require("uuid/v4"));
21
19
  var _steps = require("@atlaskit/adf-schema/steps");
22
- var _editorCardProvider = require("@atlaskit/editor-card-provider");
23
20
  var _hooks = require("@atlaskit/editor-common/hooks");
24
21
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
25
22
  var _ui = require("@atlaskit/editor-common/ui");
@@ -268,53 +265,12 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
268
265
  (0, _defineProperty2.default)(_this, "removeCardDispatched", false);
269
266
  _this.scrollContainer = (0, _ui.findOverflowScrollParent)(props.view.dom) || undefined;
270
267
  _this.state = {
271
- hasPreview: true,
272
- isSSRDataAvailable: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
268
+ hasPreview: true
273
269
  };
274
270
  return _this;
275
271
  }
276
272
  (0, _inherits2.default)(EmbedCardComponent, _React$PureComponent);
277
273
  return (0, _createClass2.default)(EmbedCardComponent, [{
278
- key: "componentDidMount",
279
- value: function componentDidMount() {
280
- var _this2 = this;
281
- if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
282
- return;
283
- }
284
- var provider = this.props.provider;
285
- if (!provider) {
286
- return;
287
- }
288
- var updateSSRDataAvailability = /*#__PURE__*/function () {
289
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
290
- var resolvedProvider;
291
- return _regenerator.default.wrap(function _callee$(_context) {
292
- while (1) switch (_context.prev = _context.next) {
293
- case 0:
294
- _context.next = 2;
295
- return provider;
296
- case 2:
297
- resolvedProvider = _context.sent;
298
- if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
299
- _this2.setState(function (state) {
300
- return _objectSpread(_objectSpread({}, state), {}, {
301
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
302
- });
303
- });
304
- }
305
- case 4:
306
- case "end":
307
- return _context.stop();
308
- }
309
- }, _callee);
310
- }));
311
- return function updateSSRDataAvailability() {
312
- return _ref3.apply(this, arguments);
313
- };
314
- }();
315
- void updateSSRDataAvailability();
316
- }
317
- }, {
318
274
  key: "componentWillUnmount",
319
275
  value: function componentWillUnmount() {
320
276
  this.removeCard();
@@ -373,7 +329,7 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
373
329
  pctWidth: pctWidth,
374
330
  fullWidthMode: fullWidthMode
375
331
  };
376
- var smartCard = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
332
+ var smartCard = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
377
333
  key: url,
378
334
  url: url,
379
335
  appearance: "embed",
@@ -478,17 +434,17 @@ var WrappedEmbedCardWithCondition = (0, _platformFeatureFlagsReact.componentWith
478
434
  var WrappedEmbedCard = (0, _genericCard.Card)(WrappedEmbedCardWithCondition, _ui.UnsupportedBlock);
479
435
  var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
480
436
  function EmbedCard() {
481
- var _this3;
437
+ var _this2;
482
438
  (0, _classCallCheck2.default)(this, EmbedCard);
483
439
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
484
440
  args[_key] = arguments[_key];
485
441
  }
486
- _this3 = _callSuper(this, EmbedCard, [].concat(args));
487
- (0, _defineProperty2.default)(_this3, "id", (0, _v.default)());
488
- (0, _defineProperty2.default)(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
442
+ _this2 = _callSuper(this, EmbedCard, [].concat(args));
443
+ (0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
444
+ (0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
489
445
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
490
446
  });
491
- return _this3;
447
+ return _this2;
492
448
  }
493
449
  (0, _inherits2.default)(EmbedCard, _ReactNodeView);
494
450
  return (0, _createClass2.default)(EmbedCard, [{
@@ -503,13 +459,13 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
503
459
  key: "createDomRef",
504
460
  value: function createDomRef() {
505
461
  var _this$reactComponentP,
506
- _this4 = this,
462
+ _this3 = this,
507
463
  _this$reactComponentP2;
508
464
  var domRef = document.createElement('div');
509
465
  // 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
510
- 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) {
511
- var nextSharedState = _ref4.nextSharedState;
512
- return _this4.updateContentEditable(nextSharedState, domRef);
466
+ 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) {
467
+ var nextSharedState = _ref3.nextSharedState;
468
+ return _this3.updateContentEditable(nextSharedState, domRef);
513
469
  });
514
470
  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);
515
471
  domRef.setAttribute('spellcheck', 'false');
@@ -553,16 +509,16 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
553
509
  }
554
510
  }]);
555
511
  }(_reactNodeView.default);
556
- var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(_ref5) {
557
- var allowResizing = _ref5.allowResizing,
558
- fullWidthMode = _ref5.fullWidthMode,
559
- pmPluginFactoryParams = _ref5.pmPluginFactoryParams,
560
- pluginInjectionApi = _ref5.pluginInjectionApi,
561
- actionOptions = _ref5.actionOptions,
562
- onClickCallback = _ref5.onClickCallback,
563
- CompetitorPrompt = _ref5.CompetitorPrompt,
564
- isPageSSRed = _ref5.isPageSSRed,
565
- provider = _ref5.provider;
512
+ var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(_ref4) {
513
+ var allowResizing = _ref4.allowResizing,
514
+ fullWidthMode = _ref4.fullWidthMode,
515
+ pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
516
+ pluginInjectionApi = _ref4.pluginInjectionApi,
517
+ actionOptions = _ref4.actionOptions,
518
+ onClickCallback = _ref4.onClickCallback,
519
+ CompetitorPrompt = _ref4.CompetitorPrompt,
520
+ isPageSSRed = _ref4.isPageSSRed,
521
+ provider = _ref4.provider;
566
522
  return function (node, view, getPos) {
567
523
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
568
524
  eventDispatcher = pmPluginFactoryParams.eventDispatcher,
@@ -27,6 +27,7 @@ var _WithCardContext = require("../ui/WithCardContext");
27
27
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
28
28
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
29
29
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
30
+ var fatalErrorPositionMap = new Map();
30
31
  var WithClickHandler = function WithClickHandler(_ref) {
31
32
  var pluginInjectionApi = _ref.pluginInjectionApi,
32
33
  url = _ref.url,
@@ -164,7 +165,19 @@ function Card(SmartCardComponent, UnsupportedComponent) {
164
165
  if (!getPos || typeof getPos === 'boolean') {
165
166
  return;
166
167
  }
168
+ var pos = getPos();
169
+
170
+ /**
171
+ * We cache fatal errors by position to avoid retrying the same errors
172
+ * on the same links at the same position.
173
+ */
174
+ if (url && pos && fatalErrorPositionMap.get(url) === pos && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
175
+ return null;
176
+ }
167
177
  (0, _doc.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);
178
+ if (url && pos && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_beta_2')) {
179
+ fatalErrorPositionMap.set(url, pos);
180
+ }
168
181
  return null;
169
182
  } else {
170
183
  // Otherwise, render a blue link as fallback (above in render()).
@@ -8,14 +8,10 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.InlineCard = void 0;
9
9
  exports.InlineCardNodeView = InlineCardNodeView;
10
10
  exports.inlineCardNodeView = void 0;
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
12
  var _react = _interopRequireWildcard(require("react"));
16
13
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
17
14
  var _v = _interopRequireDefault(require("uuid/v4"));
18
- var _editorCardProvider = require("@atlaskit/editor-card-provider");
19
15
  var _analytics = require("@atlaskit/editor-common/analytics");
20
16
  var _hooks = require("@atlaskit/editor-common/hooks");
21
17
  var _ui = require("@atlaskit/editor-common/ui");
@@ -60,42 +56,6 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
60
56
  view.dispatch(tr);
61
57
  };
62
58
  }, [getPos, view]);
63
- var _useState = (0, _react.useState)((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed),
64
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
65
- isSSRDataAvailable = _useState2[0],
66
- setIsSSRDataAvailable = _useState2[1];
67
- (0, _react.useEffect)(function () {
68
- if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
69
- return;
70
- }
71
- if (!provider) {
72
- return;
73
- }
74
- var updateSSRDataAvailability = /*#__PURE__*/function () {
75
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
76
- var resolvedProvider;
77
- return _regenerator.default.wrap(function _callee$(_context) {
78
- while (1) switch (_context.prev = _context.next) {
79
- case 0:
80
- _context.next = 2;
81
- return provider;
82
- case 2:
83
- resolvedProvider = _context.sent;
84
- if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
85
- setIsSSRDataAvailable(resolvedProvider.getCacheStatusForNode(node) === 'ssr');
86
- }
87
- case 4:
88
- case "end":
89
- return _context.stop();
90
- }
91
- }, _callee);
92
- }));
93
- return function updateSSRDataAvailability() {
94
- return _ref2.apply(this, arguments);
95
- };
96
- }();
97
- void updateSSRDataAvailability();
98
- }, [provider, node]);
99
59
  var scrollContainer = (0, _react.useMemo)(
100
60
  // Ignored via go/ees005
101
61
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -140,8 +100,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
140
100
  var handleOnClick = (0, _react.useCallback)(function (event) {
141
101
  if (event.metaKey || event.ctrlKey) {
142
102
  var _pluginInjectionApi$a;
143
- var _ref3 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
144
- editorAnalyticsApi = _ref3.actions;
103
+ var _ref2 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
104
+ editorAnalyticsApi = _ref2.actions;
145
105
  (0, _toolbar.visitCardLinkAnalytics)(editorAnalyticsApi, _analytics.INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
146
106
  window.open(url, '_blank');
147
107
  } else {
@@ -151,10 +111,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
151
111
  }, [propsOnClick, url, view, pluginInjectionApi]);
152
112
  var onClick = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
153
113
  var card = (0, _react.useMemo)(function () {
154
- if (
155
- // The `isSSRDataAvailable` check is only required when the OTP experiment is on,
156
- // because inline smart card SSR is already implemented without OTP.
157
- ((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) ? isSSRDataAvailable : true) && isPageSSRed && url) {
114
+ if (isPageSSRed && url) {
158
115
  return /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
159
116
  key: url,
160
117
  url: url,
@@ -170,9 +127,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
170
127
  hoverPreviewOptions: hoverPreviewOptions,
171
128
  disablePreviewPanel: disablePreviewPanel
172
129
  // Durin `platform_editor_smart_card_otp` cleaning up, replace this with `true`.
173
- // Ths `isSSRDataAvailable` should be checked in the `if` condition above.
174
130
  ,
175
- hideIconLoadingSkeleton: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isSSRDataAvailable
131
+ hideIconLoadingSkeleton: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)
176
132
  });
177
133
  }
178
134
  return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
@@ -190,7 +146,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
190
146
  hoverPreviewOptions: hoverPreviewOptions,
191
147
  disablePreviewPanel: disablePreviewPanel
192
148
  });
193
- }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel, isSSRDataAvailable]);
149
+ }, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel]);
194
150
 
195
151
  // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
196
152
  // otherwise if we got data, we can render the card directly since it doesn't need the Provider
@@ -247,8 +203,8 @@ function InlineCardNodeView(props) {
247
203
  // eslint-disable-next-line react/jsx-props-no-spreading
248
204
  }, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, mode === 'view'))), (0, _platformFeatureFlags.fg)('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
249
205
  }
250
- var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref4) {
251
- var inlineCardViewProducer = _ref4.inlineCardViewProducer;
206
+ var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref3) {
207
+ var inlineCardViewProducer = _ref3.inlineCardViewProducer;
252
208
  return function (node, view, getPos, decorations) {
253
209
  return inlineCardViewProducer(node, view, getPos, decorations);
254
210
  };
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React 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 { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
7
6
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
8
7
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -14,15 +13,13 @@ import { Datasource } from '../nodeviews/datasource';
14
13
  import { registerCard, removeCard } from '../pm-plugins/actions';
15
14
  import { isDatasourceNode } from '../pm-plugins/utils';
16
15
  import { Card } from './genericCard';
16
+
17
17
  // eslint-disable-next-line @repo/internal/react/no-class-components
18
18
  export class BlockCardComponent extends React.PureComponent {
19
19
  constructor(props) {
20
20
  super(props);
21
21
  // Ignored via go/ees005
22
22
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
23
- _defineProperty(this, "state", {
24
- isSSRDataAvailable: false
25
- });
26
23
  _defineProperty(this, "onResolve", data => {
27
24
  const {
28
25
  getPos,
@@ -74,28 +71,6 @@ export class BlockCardComponent extends React.PureComponent {
74
71
  }
75
72
  });
76
73
  this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
77
- this.state = {
78
- isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
79
- };
80
- }
81
- componentDidMount() {
82
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
83
- return;
84
- }
85
- const provider = this.props.provider;
86
- if (!provider) {
87
- return;
88
- }
89
- const updateSSRDataAvailability = async () => {
90
- const resolvedProvider = await provider;
91
- if (resolvedProvider instanceof EditorCardProvider) {
92
- this.setState(state => ({
93
- ...state,
94
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(this.props.node) === 'ssr'
95
- }));
96
- }
97
- };
98
- void updateSSRDataAvailability();
99
74
  }
100
75
  componentWillUnmount() {
101
76
  this.removeCard();
@@ -126,7 +101,7 @@ export class BlockCardComponent extends React.PureComponent {
126
101
  url,
127
102
  data
128
103
  } = node.attrs;
129
- const cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
104
+ const cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
130
105
  key: url,
131
106
  url: url !== null && url !== void 0 ? url : data.url,
132
107
  container: this.scrollContainer,
@@ -4,7 +4,6 @@ import React from 'react';
4
4
  import rafSchedule from 'raf-schd';
5
5
  import uuid from 'uuid/v4';
6
6
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
7
- import { EditorCardProvider } from '@atlaskit/editor-card-provider';
8
7
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
8
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
10
9
  import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
@@ -260,29 +259,9 @@ export class EmbedCardComponent extends React.PureComponent {
260
259
  _defineProperty(this, "removeCardDispatched", false);
261
260
  this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
262
261
  this.state = {
263
- hasPreview: true,
264
- isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
262
+ hasPreview: true
265
263
  };
266
264
  }
267
- componentDidMount() {
268
- if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
269
- return;
270
- }
271
- const provider = this.props.provider;
272
- if (!provider) {
273
- return;
274
- }
275
- const updateSSRDataAvailability = async () => {
276
- const resolvedProvider = await provider;
277
- if (resolvedProvider instanceof EditorCardProvider) {
278
- this.setState(state => ({
279
- ...state,
280
- isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(this.props.node) === 'ssr'
281
- }));
282
- }
283
- };
284
- void updateSSRDataAvailability();
285
- }
286
265
  componentWillUnmount() {
287
266
  this.removeCard();
288
267
  }
@@ -341,7 +320,7 @@ export class EmbedCardComponent extends React.PureComponent {
341
320
  pctWidth,
342
321
  fullWidthMode
343
322
  };
344
- const smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && this.state.isSSRDataAvailable && isPageSSRed ? /*#__PURE__*/React.createElement(CardSSR, {
323
+ const smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(CardSSR, {
345
324
  key: url,
346
325
  url: url,
347
326
  appearance: "embed",
@@ -11,6 +11,7 @@ import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
11
11
  import { getPluginState } from '../pm-plugins/util/state';
12
12
  import { titleUrlPairFromNode } from '../pm-plugins/utils';
13
13
  import { WithCardContext } from '../ui/WithCardContext';
14
+ const fatalErrorPositionMap = new Map();
14
15
  const WithClickHandler = ({
15
16
  pluginInjectionApi,
16
17
  url,
@@ -139,7 +140,19 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
139
140
  if (!getPos || typeof getPos === 'boolean') {
140
141
  return;
141
142
  }
143
+ const pos = getPos();
144
+
145
+ /**
146
+ * We cache fatal errors by position to avoid retrying the same errors
147
+ * on the same links at the same position.
148
+ */
149
+ if (url && pos && fatalErrorPositionMap.get(url) === pos && fg('platform_editor_ai_aifc_patch_beta_2')) {
150
+ return null;
151
+ }
142
152
  changeSelectedCardToLinkFallback(undefined, url, true, node, getPos(), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(view.state, view.dispatch);
153
+ if (url && pos && fg('platform_editor_ai_aifc_patch_beta_2')) {
154
+ fatalErrorPositionMap.set(url, pos);
155
+ }
143
156
  return null;
144
157
  } else {
145
158
  // Otherwise, render a blue link as fallback (above in render()).