@atlaskit/editor-plugin-card 11.4.1 → 11.4.2
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 +8 -0
- package/dist/cjs/nodeviews/blockCard.js +20 -71
- package/dist/cjs/nodeviews/embedCard.js +21 -65
- package/dist/cjs/nodeviews/inlineCard.js +7 -51
- package/dist/es2019/nodeviews/blockCard.js +2 -27
- package/dist/es2019/nodeviews/embedCard.js +2 -23
- package/dist/es2019/nodeviews/inlineCard.js +4 -25
- package/dist/esm/nodeviews/blockCard.js +21 -71
- package/dist/esm/nodeviews/embedCard.js +21 -65
- package/dist/esm/nodeviews/inlineCard.js +8 -52
- package/dist/types/nodeviews/blockCard.d.ts +1 -7
- package/dist/types/nodeviews/embedCard.d.ts +0 -2
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +1 -7
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +0 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 11.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`57a9de1ebc5db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57a9de1ebc5db) -
|
|
8
|
+
fix: remove unnecessary re-renders in smart card node views
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 11.4.1
|
|
4
12
|
|
|
5
13
|
### 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) &&
|
|
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
|
|
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
|
-
|
|
213
|
-
(0, _defineProperty2.default)(
|
|
214
|
-
(0, _defineProperty2.default)(
|
|
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
|
|
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
|
-
|
|
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 (
|
|
230
|
-
var nextSharedState =
|
|
231
|
-
return
|
|
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(
|
|
288
|
-
var pmPluginFactoryParams =
|
|
289
|
-
actionOptions =
|
|
290
|
-
pluginInjectionApi =
|
|
291
|
-
onClickCallback =
|
|
292
|
-
allowDatasource =
|
|
293
|
-
inlineCardViewProducer =
|
|
294
|
-
CompetitorPrompt =
|
|
295
|
-
isPageSSRed =
|
|
296
|
-
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) &&
|
|
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
|
|
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
|
-
|
|
487
|
-
(0, _defineProperty2.default)(
|
|
488
|
-
(0, _defineProperty2.default)(
|
|
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
|
|
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
|
-
|
|
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 (
|
|
511
|
-
var nextSharedState =
|
|
512
|
-
return
|
|
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(
|
|
557
|
-
var allowResizing =
|
|
558
|
-
fullWidthMode =
|
|
559
|
-
pmPluginFactoryParams =
|
|
560
|
-
pluginInjectionApi =
|
|
561
|
-
actionOptions =
|
|
562
|
-
onClickCallback =
|
|
563
|
-
CompetitorPrompt =
|
|
564
|
-
isPageSSRed =
|
|
565
|
-
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,
|
|
@@ -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
|
|
144
|
-
editorAnalyticsApi =
|
|
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)
|
|
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
|
|
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(
|
|
251
|
-
var 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) &&
|
|
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) &&
|
|
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",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { memo, useCallback, useEffect, useMemo, useRef
|
|
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)
|
|
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
|
|
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) &&
|
|
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
|
|
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
|
-
|
|
206
|
-
_defineProperty(
|
|
207
|
-
_defineProperty(
|
|
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
|
|
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
|
-
|
|
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 (
|
|
223
|
-
var nextSharedState =
|
|
224
|
-
return
|
|
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(
|
|
281
|
-
var pmPluginFactoryParams =
|
|
282
|
-
actionOptions =
|
|
283
|
-
pluginInjectionApi =
|
|
284
|
-
onClickCallback =
|
|
285
|
-
allowDatasource =
|
|
286
|
-
inlineCardViewProducer =
|
|
287
|
-
CompetitorPrompt =
|
|
288
|
-
isPageSSRed =
|
|
289
|
-
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) &&
|
|
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
|
|
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
|
-
|
|
480
|
-
_defineProperty(
|
|
481
|
-
_defineProperty(
|
|
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
|
|
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
|
-
|
|
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 (
|
|
504
|
-
var nextSharedState =
|
|
505
|
-
return
|
|
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(
|
|
550
|
-
var allowResizing =
|
|
551
|
-
fullWidthMode =
|
|
552
|
-
pmPluginFactoryParams =
|
|
553
|
-
pluginInjectionApi =
|
|
554
|
-
actionOptions =
|
|
555
|
-
onClickCallback =
|
|
556
|
-
CompetitorPrompt =
|
|
557
|
-
isPageSSRed =
|
|
558
|
-
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,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
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
|
|
133
|
-
editorAnalyticsApi =
|
|
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)
|
|
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
|
|
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(
|
|
240
|
-
var 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
|
-
},
|
|
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
|
-
},
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "11.4.
|
|
3
|
+
"version": "11.4.2",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"@atlaskit/editor-plugin-toolbar": "^3.3.0",
|
|
47
47
|
"@atlaskit/editor-plugin-width": "^7.0.0",
|
|
48
48
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
49
|
-
"@atlaskit/editor-shared-styles": "^3.
|
|
49
|
+
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
50
50
|
"@atlaskit/frontend-utilities": "^3.2.0",
|
|
51
51
|
"@atlaskit/icon": "^28.5.0",
|
|
52
52
|
"@atlaskit/link": "^3.2.0",
|
|
53
53
|
"@atlaskit/link-analytics": "^11.0.0",
|
|
54
54
|
"@atlaskit/link-client-extension": "^6.0.0",
|
|
55
|
-
"@atlaskit/link-datasource": "^4.
|
|
55
|
+
"@atlaskit/link-datasource": "^4.27.0",
|
|
56
56
|
"@atlaskit/link-extractors": "^2.4.0",
|
|
57
57
|
"@atlaskit/linking-common": "^9.7.0",
|
|
58
58
|
"@atlaskit/linking-types": "^14.1.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
64
64
|
"@atlaskit/smart-card": "^43.2.0",
|
|
65
65
|
"@atlaskit/theme": "^21.0.0",
|
|
66
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
66
|
+
"@atlaskit/tmp-editor-statsig": "^13.15.0",
|
|
67
67
|
"@atlaskit/tokens": "^7.0.0",
|
|
68
68
|
"@babel/runtime": "^7.0.0",
|
|
69
69
|
"@emotion/react": "^11.7.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"uuid": "^3.1.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@atlaskit/editor-common": "^110.
|
|
76
|
+
"@atlaskit/editor-common": "^110.15.0",
|
|
77
77
|
"@atlaskit/link-provider": "^4.0.0",
|
|
78
78
|
"react": "^18.2.0",
|
|
79
79
|
"react-intl-next": "npm:react-intl@^5.18.1"
|