@atlaskit/editor-plugin-card 36.0.4 → 36.0.6
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 +16 -0
- package/dist/cjs/nodeviews/blockCard.js +8 -0
- package/dist/cjs/nodeviews/createEmbedCardNodeView.js +15 -0
- package/dist/cjs/nodeviews/embedCard.js +155 -55
- package/dist/cjs/nodeviews/embedCardWithPreservation.js +72 -0
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/es2019/nodeviews/blockCard.js +6 -0
- package/dist/es2019/nodeviews/createEmbedCardNodeView.js +5 -0
- package/dist/es2019/nodeviews/embedCard.js +86 -4
- package/dist/es2019/nodeviews/embedCardWithPreservation.js +59 -0
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/esm/nodeviews/blockCard.js +10 -2
- package/dist/esm/nodeviews/createEmbedCardNodeView.js +9 -0
- package/dist/esm/nodeviews/embedCard.js +156 -56
- package/dist/esm/nodeviews/embedCardWithPreservation.js +66 -0
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/types/nodeviews/blockCard.d.ts +1 -0
- package/dist/types/nodeviews/createEmbedCardNodeView.d.ts +4 -0
- package/dist/types/nodeviews/embedCard.d.ts +14 -0
- package/dist/types/nodeviews/embedCardWithPreservation.d.ts +4 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 36.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9ed4f69277c0c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ed4f69277c0c) -
|
|
8
|
+
Preserve Smart Card iframe state across editor width changes using a shared node-view preservation
|
|
9
|
+
helper, behind platform_editor_preserve_smart_card_embeds. Keep the existing Remix preservation
|
|
10
|
+
path when the experiment is disabled.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 36.0.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 36.0.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -128,6 +128,14 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
this.removeCardDispatched = true;
|
|
131
|
+
this.removeCardRegistration();
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "removeCardRegistration",
|
|
135
|
+
value: function removeCardRegistration() {
|
|
136
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
131
139
|
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
|
|
132
140
|
var _pluginInjectionApi$c2;
|
|
133
141
|
var _this$props3 = this.props,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEmbedCardNodeViewFactory = exports.createEmbedCardNodeView = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
8
|
+
var _embedCard = require("./embedCard");
|
|
9
|
+
var _embedCardWithPreservation = require("./embedCardWithPreservation");
|
|
10
|
+
var getEmbedCardNodeViewFactory = exports.getEmbedCardNodeViewFactory = function getEmbedCardNodeViewFactory() {
|
|
11
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds') ? _embedCardWithPreservation.embedCardNodeViewWithPreservation : _embedCard.embedCardNodeView;
|
|
12
|
+
};
|
|
13
|
+
var createEmbedCardNodeView = exports.createEmbedCardNodeView = function createEmbedCardNodeView(properties) {
|
|
14
|
+
return getEmbedCardNodeViewFactory()(properties);
|
|
15
|
+
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getAspectRatioForUrl = exports.embedCardNodeView = exports.EmbedOrBlockCardComponent = exports.EmbedCardComponent = exports.EmbedCard = void 0;
|
|
7
|
+
exports.isPreviewPanelResponsivenessEnabled = exports.getAspectRatioForUrl = exports.embedCardNodeView = exports.EmbedOrBlockCardComponent = exports.EmbedCardComponent = exports.EmbedCard = void 0;
|
|
8
8
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -164,6 +164,16 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
(0, _defineProperty2.default)(_this, "onResolve", function (data) {
|
|
167
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds')) {
|
|
168
|
+
_this.resolvedCardData = {
|
|
169
|
+
title: data.title,
|
|
170
|
+
url: data.url,
|
|
171
|
+
nodeUrl: _this.props.node.attrs.url
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
_this.resolveCard(data);
|
|
175
|
+
});
|
|
176
|
+
(0, _defineProperty2.default)(_this, "resolveCard", function (data) {
|
|
167
177
|
var _getAspectRatioForUrl;
|
|
168
178
|
var view = _this.props.view;
|
|
169
179
|
var title = data.title,
|
|
@@ -225,6 +235,23 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
225
235
|
}
|
|
226
236
|
} catch (_unused2) {}
|
|
227
237
|
});
|
|
238
|
+
(0, _defineProperty2.default)(_this, "registerResolvedCard", function (_ref2) {
|
|
239
|
+
var _pluginInjectionApi$c2;
|
|
240
|
+
var title = _ref2.title,
|
|
241
|
+
url = _ref2.url;
|
|
242
|
+
if (_this.removeCardDispatched || _this.props.view.isDestroyed || _this.getPosSafely() === undefined) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
var _this$props2 = _this.props,
|
|
246
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
247
|
+
id = _this$props2.id;
|
|
248
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.registerCard({
|
|
249
|
+
id: id,
|
|
250
|
+
title: title,
|
|
251
|
+
url: url,
|
|
252
|
+
getPos: _this.getPosSafely
|
|
253
|
+
});
|
|
254
|
+
});
|
|
228
255
|
(0, _defineProperty2.default)(_this, "updateSize", function (pctWidth, layout) {
|
|
229
256
|
var _this$props$view = _this.props.view,
|
|
230
257
|
state = _this$props$view.state,
|
|
@@ -319,8 +346,8 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
319
346
|
});
|
|
320
347
|
_this.saveOriginalDimensionsAttributes(height, undefined);
|
|
321
348
|
});
|
|
322
|
-
(0, _defineProperty2.default)(_this, "onError", function (
|
|
323
|
-
var err =
|
|
349
|
+
(0, _defineProperty2.default)(_this, "onError", function (_ref3) {
|
|
350
|
+
var err = _ref3.err;
|
|
324
351
|
if (err) {
|
|
325
352
|
throw err;
|
|
326
353
|
}
|
|
@@ -336,6 +363,23 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
336
363
|
}
|
|
337
364
|
(0, _inherits2.default)(EmbedCardComponent, _React$PureComponent);
|
|
338
365
|
return (0, _createClass2.default)(EmbedCardComponent, [{
|
|
366
|
+
key: "componentDidUpdate",
|
|
367
|
+
value: function componentDidUpdate(prevProps) {
|
|
368
|
+
var _this2 = this;
|
|
369
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds')) {
|
|
370
|
+
var _this$resolvedCardDat;
|
|
371
|
+
if (((_this$resolvedCardDat = this.resolvedCardData) === null || _this$resolvedCardDat === void 0 ? void 0 : _this$resolvedCardDat.nodeUrl) !== this.props.node.attrs.url) {
|
|
372
|
+
this.resolvedCardData = undefined;
|
|
373
|
+
}
|
|
374
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') && this.props.getPos !== prevProps.getPos && this.resolvedCardData) {
|
|
375
|
+
var resolvedCardData = this.resolvedCardData;
|
|
376
|
+
(0, _rafSchd.default)(function () {
|
|
377
|
+
return _this2.registerResolvedCard(resolvedCardData);
|
|
378
|
+
})();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}, {
|
|
339
383
|
key: "componentWillUnmount",
|
|
340
384
|
value: function componentWillUnmount() {
|
|
341
385
|
this.removeCard();
|
|
@@ -347,12 +391,20 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
347
391
|
return;
|
|
348
392
|
}
|
|
349
393
|
this.removeCardDispatched = true;
|
|
394
|
+
this.removeCardRegistration();
|
|
395
|
+
}
|
|
396
|
+
}, {
|
|
397
|
+
key: "removeCardRegistration",
|
|
398
|
+
value: function removeCardRegistration() {
|
|
399
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
350
402
|
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
|
|
351
|
-
var _pluginInjectionApi$
|
|
352
|
-
var _this$
|
|
353
|
-
pluginInjectionApi = _this$
|
|
354
|
-
id = _this$
|
|
355
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
403
|
+
var _pluginInjectionApi$c3;
|
|
404
|
+
var _this$props3 = this.props,
|
|
405
|
+
pluginInjectionApi = _this$props3.pluginInjectionApi,
|
|
406
|
+
id = _this$props3.id;
|
|
407
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.removeRegisteredCard(id);
|
|
356
408
|
} else {
|
|
357
409
|
var tr = this.props.view.state.tr;
|
|
358
410
|
(0, _actions.removeCard)({
|
|
@@ -364,18 +416,18 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
364
416
|
}, {
|
|
365
417
|
key: "render",
|
|
366
418
|
value: function render() {
|
|
367
|
-
var _this$
|
|
368
|
-
node = _this$
|
|
369
|
-
allowResizing = _this$
|
|
370
|
-
fullWidthMode = _this$
|
|
371
|
-
view = _this$
|
|
372
|
-
dispatchAnalyticsEvent = _this$
|
|
373
|
-
getPos = _this$
|
|
374
|
-
pluginInjectionApi = _this$
|
|
375
|
-
actionOptions = _this$
|
|
376
|
-
onClick = _this$
|
|
377
|
-
CompetitorPrompt = _this$
|
|
378
|
-
isPageSSRed = _this$
|
|
419
|
+
var _this$props4 = this.props,
|
|
420
|
+
node = _this$props4.node,
|
|
421
|
+
allowResizing = _this$props4.allowResizing,
|
|
422
|
+
fullWidthMode = _this$props4.fullWidthMode,
|
|
423
|
+
view = _this$props4.view,
|
|
424
|
+
dispatchAnalyticsEvent = _this$props4.dispatchAnalyticsEvent,
|
|
425
|
+
getPos = _this$props4.getPos,
|
|
426
|
+
pluginInjectionApi = _this$props4.pluginInjectionApi,
|
|
427
|
+
actionOptions = _this$props4.actionOptions,
|
|
428
|
+
onClick = _this$props4.onClick,
|
|
429
|
+
CompetitorPrompt = _this$props4.CompetitorPrompt,
|
|
430
|
+
isPageSSRed = _this$props4.isPageSSRed;
|
|
379
431
|
var _node$attrs = node.attrs,
|
|
380
432
|
url = _node$attrs.url,
|
|
381
433
|
pctWidth = _node$attrs.width,
|
|
@@ -503,6 +555,11 @@ var EmbedOrBlockCardComponent = exports.EmbedOrBlockCardComponent = function Emb
|
|
|
503
555
|
provider: props.provider
|
|
504
556
|
});
|
|
505
557
|
};
|
|
558
|
+
var isPreviewPanelResponsivenessEnabled = exports.isPreviewPanelResponsivenessEnabled = function isPreviewPanelResponsivenessEnabled() {
|
|
559
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
560
|
+
exposure: true
|
|
561
|
+
});
|
|
562
|
+
};
|
|
506
563
|
var WrappedEmbedCardWithCondition = (0, _componentWithCondition.componentWithCondition)(function () {
|
|
507
564
|
return (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
508
565
|
exposure: true
|
|
@@ -511,18 +568,21 @@ var WrappedEmbedCardWithCondition = (0, _componentWithCondition.componentWithCon
|
|
|
511
568
|
var WrappedEmbedCard = (0, _genericCard.Card)(WrappedEmbedCardWithCondition, _UnsupportedBlock.default);
|
|
512
569
|
var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
513
570
|
function EmbedCard() {
|
|
514
|
-
var
|
|
571
|
+
var _this3;
|
|
515
572
|
(0, _classCallCheck2.default)(this, EmbedCard);
|
|
516
573
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
517
574
|
args[_key] = arguments[_key];
|
|
518
575
|
}
|
|
519
|
-
|
|
576
|
+
_this3 = _callSuper(this, EmbedCard, [].concat(args));
|
|
520
577
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
521
|
-
(0, _defineProperty2.default)(
|
|
522
|
-
(0, _defineProperty2.default)(
|
|
578
|
+
(0, _defineProperty2.default)(_this3, "id", (0, _uuid.v4)());
|
|
579
|
+
(0, _defineProperty2.default)(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
523
580
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
581
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds') && _this3.preservationSlot) {
|
|
582
|
+
_this3.preservationSlot.contentEditable = divElement.contentEditable;
|
|
583
|
+
}
|
|
524
584
|
});
|
|
525
|
-
return
|
|
585
|
+
return _this3;
|
|
526
586
|
}
|
|
527
587
|
(0, _inherits2.default)(EmbedCard, _ReactNodeView);
|
|
528
588
|
return (0, _createClass2.default)(EmbedCard, [{
|
|
@@ -537,33 +597,70 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
537
597
|
key: "createDomRef",
|
|
538
598
|
value: function createDomRef() {
|
|
539
599
|
var _this$reactComponentP,
|
|
540
|
-
|
|
600
|
+
_this4 = this,
|
|
541
601
|
_this$reactComponentP2;
|
|
542
602
|
var domRef = document.createElement('div');
|
|
543
603
|
// 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
|
|
544
|
-
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 (
|
|
545
|
-
var nextSharedState =
|
|
546
|
-
return
|
|
604
|
+
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) {
|
|
605
|
+
var nextSharedState = _ref4.nextSharedState;
|
|
606
|
+
return _this4.updateContentEditable(nextSharedState, domRef);
|
|
547
607
|
});
|
|
548
608
|
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);
|
|
549
609
|
domRef.setAttribute('spellcheck', 'false');
|
|
550
610
|
return domRef;
|
|
551
611
|
}
|
|
612
|
+
}, {
|
|
613
|
+
key: "setDomAttrs",
|
|
614
|
+
value: function setDomAttrs(node, element) {
|
|
615
|
+
_superPropGet(EmbedCard, "setDomAttrs", this, 3)([node, element]);
|
|
616
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds') && this.preservationSlot) {
|
|
617
|
+
_superPropGet(EmbedCard, "setDomAttrs", this, 3)([node, this.preservationSlot]);
|
|
618
|
+
if (element !== this.preservationSlot) {
|
|
619
|
+
Object.keys(node.attrs || {}).forEach(function (attr) {
|
|
620
|
+
return element.removeAttribute(attr);
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
key: "attachPreservationSlot",
|
|
627
|
+
value: function attachPreservationSlot(slot, getPos) {
|
|
628
|
+
var _this$unsubscribe,
|
|
629
|
+
_this$reactComponentP3,
|
|
630
|
+
_this5 = this;
|
|
631
|
+
this.getPos = getPos;
|
|
632
|
+
this.preservationSlot = slot;
|
|
633
|
+
slot.classList.add("".concat(this.node.type.name, "View-content-wrap"));
|
|
634
|
+
this.dom.classList.remove("".concat(this.node.type.name, "View-content-wrap"));
|
|
635
|
+
this.setDomAttrs(this.node, this.dom);
|
|
636
|
+
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
637
|
+
var editorViewMode = (_this$reactComponentP3 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP3 === void 0 || (_this$reactComponentP3 = _this$reactComponentP3.editorViewMode) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.sharedState;
|
|
638
|
+
this.unsubscribe = editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.onChange(function (_ref5) {
|
|
639
|
+
var nextSharedState = _ref5.nextSharedState;
|
|
640
|
+
return _this5.updateContentEditable(nextSharedState, _this5.dom);
|
|
641
|
+
});
|
|
642
|
+
this.updateContentEditable(editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.currentState(), this.dom);
|
|
643
|
+
}
|
|
644
|
+
}, {
|
|
645
|
+
key: "canReuseWith",
|
|
646
|
+
value: function canReuseWith(provider, eventDispatcher) {
|
|
647
|
+
return this.reactComponentProps.provider === provider && this.eventDispatcher === eventDispatcher;
|
|
648
|
+
}
|
|
552
649
|
}, {
|
|
553
650
|
key: "render",
|
|
554
651
|
value: function render() {
|
|
555
|
-
var _this$
|
|
556
|
-
eventDispatcher = _this$
|
|
557
|
-
allowResizing = _this$
|
|
558
|
-
fullWidthMode = _this$
|
|
559
|
-
dispatchAnalyticsEvent = _this$
|
|
560
|
-
pluginInjectionApi = _this$
|
|
561
|
-
onClickCallback = _this$
|
|
562
|
-
CompetitorPrompt = _this$
|
|
563
|
-
isPageSSRed = _this$
|
|
564
|
-
provider = _this$
|
|
565
|
-
intl = _this$
|
|
566
|
-
smartCardContext = _this$
|
|
652
|
+
var _this$reactComponentP4 = this.reactComponentProps,
|
|
653
|
+
eventDispatcher = _this$reactComponentP4.eventDispatcher,
|
|
654
|
+
allowResizing = _this$reactComponentP4.allowResizing,
|
|
655
|
+
fullWidthMode = _this$reactComponentP4.fullWidthMode,
|
|
656
|
+
dispatchAnalyticsEvent = _this$reactComponentP4.dispatchAnalyticsEvent,
|
|
657
|
+
pluginInjectionApi = _this$reactComponentP4.pluginInjectionApi,
|
|
658
|
+
onClickCallback = _this$reactComponentP4.onClickCallback,
|
|
659
|
+
CompetitorPrompt = _this$reactComponentP4.CompetitorPrompt,
|
|
660
|
+
isPageSSRed = _this$reactComponentP4.isPageSSRed,
|
|
661
|
+
provider = _this$reactComponentP4.provider,
|
|
662
|
+
intl = _this$reactComponentP4.intl,
|
|
663
|
+
smartCardContext = _this$reactComponentP4.smartCardContext;
|
|
567
664
|
return /*#__PURE__*/_react.default.createElement(_SmartCardSSRReactContextsProvider.SmartCardSSRReactContextsProvider, {
|
|
568
665
|
intl: intl,
|
|
569
666
|
smartCardContext: smartCardContext
|
|
@@ -603,24 +700,27 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
603
700
|
}, {
|
|
604
701
|
key: "destroy",
|
|
605
702
|
value: function destroy() {
|
|
606
|
-
var _this$
|
|
607
|
-
(_this$
|
|
703
|
+
var _this$unsubscribe2;
|
|
704
|
+
(_this$unsubscribe2 = this.unsubscribe) === null || _this$unsubscribe2 === void 0 || _this$unsubscribe2.call(this);
|
|
705
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_preserve_smart_card_embeds')) {
|
|
706
|
+
this.preservationSlot = undefined;
|
|
707
|
+
}
|
|
608
708
|
_superPropGet(EmbedCard, "destroy", this, 3)([]);
|
|
609
709
|
}
|
|
610
710
|
}]);
|
|
611
711
|
}(_reactNodeView.default);
|
|
612
|
-
var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(
|
|
613
|
-
var allowResizing =
|
|
614
|
-
fullWidthMode =
|
|
615
|
-
pmPluginFactoryParams =
|
|
616
|
-
pluginInjectionApi =
|
|
617
|
-
actionOptions =
|
|
618
|
-
onClickCallback =
|
|
619
|
-
CompetitorPrompt =
|
|
620
|
-
isPageSSRed =
|
|
621
|
-
provider =
|
|
622
|
-
intl =
|
|
623
|
-
smartCardContext =
|
|
712
|
+
var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(_ref6) {
|
|
713
|
+
var allowResizing = _ref6.allowResizing,
|
|
714
|
+
fullWidthMode = _ref6.fullWidthMode,
|
|
715
|
+
pmPluginFactoryParams = _ref6.pmPluginFactoryParams,
|
|
716
|
+
pluginInjectionApi = _ref6.pluginInjectionApi,
|
|
717
|
+
actionOptions = _ref6.actionOptions,
|
|
718
|
+
onClickCallback = _ref6.onClickCallback,
|
|
719
|
+
CompetitorPrompt = _ref6.CompetitorPrompt,
|
|
720
|
+
isPageSSRed = _ref6.isPageSSRed,
|
|
721
|
+
provider = _ref6.provider,
|
|
722
|
+
intl = _ref6.intl,
|
|
723
|
+
smartCardContext = _ref6.smartCardContext;
|
|
624
724
|
return function (node, view, getPos) {
|
|
625
725
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
626
726
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.embedCardNodeViewWithPreservation = void 0;
|
|
7
|
+
var _preserveNodeView = require("@atlaskit/editor-common/preserve-node-view");
|
|
8
|
+
var _constants = require("@atlaskit/editor-shared-styles/constants");
|
|
9
|
+
var _embedCard = require("./embedCard");
|
|
10
|
+
var embedCardNodeViewWithPreservation = exports.embedCardNodeViewWithPreservation = function embedCardNodeViewWithPreservation(properties) {
|
|
11
|
+
return function (node, view, getPos) {
|
|
12
|
+
var _properties$pluginInj;
|
|
13
|
+
var width = (_properties$pluginInj = properties.pluginInjectionApi) === null || _properties$pluginInj === void 0 || (_properties$pluginInj = _properties$pluginInj.width) === null || _properties$pluginInj === void 0 || (_properties$pluginInj = _properties$pluginInj.sharedState.currentState()) === null || _properties$pluginInj === void 0 ? void 0 : _properties$pluginInj.width;
|
|
14
|
+
var useResponsiveRenderer = (0, _embedCard.isPreviewPanelResponsivenessEnabled)() && !!width && width <= _constants.akEditorFullPageNarrowBreakout;
|
|
15
|
+
if (useResponsiveRenderer) {
|
|
16
|
+
return (0, _embedCard.embedCardNodeView)(properties)(node, view, getPos);
|
|
17
|
+
}
|
|
18
|
+
var _properties$pmPluginF = properties.pmPluginFactoryParams,
|
|
19
|
+
portalProviderAPI = _properties$pmPluginF.portalProviderAPI,
|
|
20
|
+
eventDispatcher = _properties$pmPluginF.eventDispatcher,
|
|
21
|
+
dispatchAnalyticsEvent = _properties$pmPluginF.dispatchAnalyticsEvent;
|
|
22
|
+
var renderProps = {
|
|
23
|
+
eventDispatcher: eventDispatcher,
|
|
24
|
+
allowResizing: properties.allowResizing,
|
|
25
|
+
fullWidthMode: properties.fullWidthMode,
|
|
26
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
27
|
+
pluginInjectionApi: properties.pluginInjectionApi,
|
|
28
|
+
actionOptions: properties.actionOptions,
|
|
29
|
+
onClickCallback: properties.onClickCallback,
|
|
30
|
+
CompetitorPrompt: properties.CompetitorPrompt,
|
|
31
|
+
isPageSSRed: properties.isPageSSRed,
|
|
32
|
+
provider: properties.provider,
|
|
33
|
+
intl: properties.intl,
|
|
34
|
+
smartCardContext: properties.smartCardContext
|
|
35
|
+
};
|
|
36
|
+
var createCard = function createCard(cardNode) {
|
|
37
|
+
return new _embedCard.EmbedCard(cardNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
|
|
38
|
+
};
|
|
39
|
+
return (0, _preserveNodeView.preserveNodeView)({
|
|
40
|
+
node: node,
|
|
41
|
+
view: view,
|
|
42
|
+
getPos: getPos,
|
|
43
|
+
renderProps: renderProps,
|
|
44
|
+
rendererKind: portalProviderAPI,
|
|
45
|
+
createNodeView: createCard,
|
|
46
|
+
isSameNode: function isSameNode(previous, next) {
|
|
47
|
+
return previous === next;
|
|
48
|
+
},
|
|
49
|
+
canUpdateNode: function canUpdateNode(previous, next) {
|
|
50
|
+
return previous.type === next.type;
|
|
51
|
+
},
|
|
52
|
+
canReuse: function canReuse(inner) {
|
|
53
|
+
if (!(inner instanceof _embedCard.EmbedCard) || !inner.canReuseWith(properties.provider, properties.pmPluginFactoryParams.eventDispatcher)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
var nodeIdentityCount = 0;
|
|
57
|
+
view.state.doc.descendants(function (candidate) {
|
|
58
|
+
if (candidate === inner.node) {
|
|
59
|
+
nodeIdentityCount++;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return nodeIdentityCount === 1;
|
|
63
|
+
},
|
|
64
|
+
onAttach: function onAttach(inner, slot, freshGetPos) {
|
|
65
|
+
if (inner instanceof _embedCard.EmbedCard) {
|
|
66
|
+
inner.attachPreservationSlot(slot, freshGetPos);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
requireUniqueMatch: true
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -18,7 +18,7 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
|
18
18
|
var _constants = require("@atlaskit/linking-common/constants");
|
|
19
19
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
20
20
|
var _blockCard = require("../nodeviews/blockCard");
|
|
21
|
-
var
|
|
21
|
+
var _createEmbedCardNodeView = require("../nodeviews/createEmbedCardNodeView");
|
|
22
22
|
var _inlineCard = require("../nodeviews/inlineCard");
|
|
23
23
|
var _lazyInlineCard = require("../nodeviews/lazy-inline-card");
|
|
24
24
|
var _eventsFromTr = require("../ui/analytics/events-from-tr");
|
|
@@ -302,7 +302,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
302
302
|
intl: intl,
|
|
303
303
|
smartCardContext: smartCardContext
|
|
304
304
|
}),
|
|
305
|
-
embedCard: (0,
|
|
305
|
+
embedCard: (0, _createEmbedCardNodeView.createEmbedCardNodeView)({
|
|
306
306
|
allowResizing: allowResizing,
|
|
307
307
|
fullWidthMode: fullWidthMode,
|
|
308
308
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
@@ -111,6 +111,12 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
this.removeCardDispatched = true;
|
|
114
|
+
this.removeCardRegistration();
|
|
115
|
+
}
|
|
116
|
+
removeCardRegistration() {
|
|
117
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
114
120
|
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
115
121
|
var _pluginInjectionApi$c2;
|
|
116
122
|
const {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
|
+
import { embedCardNodeView } from './embedCard';
|
|
3
|
+
import { embedCardNodeViewWithPreservation } from './embedCardWithPreservation';
|
|
4
|
+
export const getEmbedCardNodeViewFactory = () => isExperimentEnabled('platform_editor_preserve_smart_card_embeds') ? embedCardNodeViewWithPreservation : embedCardNodeView;
|
|
5
|
+
export const createEmbedCardNodeView = properties => getEmbedCardNodeViewFactory()(properties);
|
|
@@ -133,6 +133,18 @@ const CardInner = ({
|
|
|
133
133
|
};
|
|
134
134
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
135
135
|
export class EmbedCardComponent extends React.PureComponent {
|
|
136
|
+
componentDidUpdate(prevProps) {
|
|
137
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
138
|
+
var _this$resolvedCardDat;
|
|
139
|
+
if (((_this$resolvedCardDat = this.resolvedCardData) === null || _this$resolvedCardDat === void 0 ? void 0 : _this$resolvedCardDat.nodeUrl) !== this.props.node.attrs.url) {
|
|
140
|
+
this.resolvedCardData = undefined;
|
|
141
|
+
}
|
|
142
|
+
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2') && this.props.getPos !== prevProps.getPos && this.resolvedCardData) {
|
|
143
|
+
const resolvedCardData = this.resolvedCardData;
|
|
144
|
+
rafSchedule(() => this.registerResolvedCard(resolvedCardData))();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
136
148
|
constructor(props) {
|
|
137
149
|
super(props);
|
|
138
150
|
_defineProperty(this, "embedIframeRef", /*#__PURE__*/React.createRef());
|
|
@@ -150,6 +162,16 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
150
162
|
}
|
|
151
163
|
});
|
|
152
164
|
_defineProperty(this, "onResolve", data => {
|
|
165
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
166
|
+
this.resolvedCardData = {
|
|
167
|
+
title: data.title,
|
|
168
|
+
url: data.url,
|
|
169
|
+
nodeUrl: this.props.node.attrs.url
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
this.resolveCard(data);
|
|
173
|
+
});
|
|
174
|
+
_defineProperty(this, "resolveCard", data => {
|
|
153
175
|
var _getAspectRatioForUrl;
|
|
154
176
|
const {
|
|
155
177
|
view
|
|
@@ -217,6 +239,25 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
217
239
|
}
|
|
218
240
|
} catch {}
|
|
219
241
|
});
|
|
242
|
+
_defineProperty(this, "registerResolvedCard", ({
|
|
243
|
+
title,
|
|
244
|
+
url
|
|
245
|
+
}) => {
|
|
246
|
+
var _pluginInjectionApi$c2;
|
|
247
|
+
if (this.removeCardDispatched || this.props.view.isDestroyed || this.getPosSafely() === undefined) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const {
|
|
251
|
+
pluginInjectionApi,
|
|
252
|
+
id
|
|
253
|
+
} = this.props;
|
|
254
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.registerCard({
|
|
255
|
+
id,
|
|
256
|
+
title,
|
|
257
|
+
url,
|
|
258
|
+
getPos: this.getPosSafely
|
|
259
|
+
});
|
|
260
|
+
});
|
|
220
261
|
_defineProperty(this, "updateSize", (pctWidth, layout) => {
|
|
221
262
|
const {
|
|
222
263
|
state,
|
|
@@ -338,13 +379,19 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
338
379
|
return;
|
|
339
380
|
}
|
|
340
381
|
this.removeCardDispatched = true;
|
|
382
|
+
this.removeCardRegistration();
|
|
383
|
+
}
|
|
384
|
+
removeCardRegistration() {
|
|
385
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
341
388
|
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
342
|
-
var _pluginInjectionApi$
|
|
389
|
+
var _pluginInjectionApi$c3;
|
|
343
390
|
const {
|
|
344
391
|
pluginInjectionApi,
|
|
345
392
|
id
|
|
346
393
|
} = this.props;
|
|
347
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
394
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c3 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.removeRegisteredCard(id);
|
|
348
395
|
} else {
|
|
349
396
|
const {
|
|
350
397
|
tr
|
|
@@ -497,6 +544,9 @@ export const EmbedOrBlockCardComponent = props => {
|
|
|
497
544
|
provider: props.provider
|
|
498
545
|
});
|
|
499
546
|
};
|
|
547
|
+
export const isPreviewPanelResponsivenessEnabled = () => editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
548
|
+
exposure: true
|
|
549
|
+
});
|
|
500
550
|
const WrappedEmbedCardWithCondition = componentWithCondition(() => editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
501
551
|
exposure: true
|
|
502
552
|
}), EmbedOrBlockCardComponent, EmbedCardComponent);
|
|
@@ -508,6 +558,9 @@ export class EmbedCard extends ReactNodeView {
|
|
|
508
558
|
_defineProperty(this, "id", uuid());
|
|
509
559
|
_defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
|
|
510
560
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
561
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.preservationSlot) {
|
|
562
|
+
this.preservationSlot.contentEditable = divElement.contentEditable;
|
|
563
|
+
}
|
|
511
564
|
});
|
|
512
565
|
}
|
|
513
566
|
viewShouldUpdate(nextNode) {
|
|
@@ -527,6 +580,32 @@ export class EmbedCard extends ReactNodeView {
|
|
|
527
580
|
domRef.setAttribute('spellcheck', 'false');
|
|
528
581
|
return domRef;
|
|
529
582
|
}
|
|
583
|
+
setDomAttrs(node, element) {
|
|
584
|
+
super.setDomAttrs(node, element);
|
|
585
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.preservationSlot) {
|
|
586
|
+
super.setDomAttrs(node, this.preservationSlot);
|
|
587
|
+
if (element !== this.preservationSlot) {
|
|
588
|
+
Object.keys(node.attrs || {}).forEach(attr => element.removeAttribute(attr));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
attachPreservationSlot(slot, getPos) {
|
|
593
|
+
var _this$unsubscribe, _this$reactComponentP5, _this$reactComponentP6;
|
|
594
|
+
this.getPos = getPos;
|
|
595
|
+
this.preservationSlot = slot;
|
|
596
|
+
slot.classList.add(`${this.node.type.name}View-content-wrap`);
|
|
597
|
+
this.dom.classList.remove(`${this.node.type.name}View-content-wrap`);
|
|
598
|
+
this.setDomAttrs(this.node, this.dom);
|
|
599
|
+
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
600
|
+
const editorViewMode = (_this$reactComponentP5 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP5 === void 0 ? void 0 : (_this$reactComponentP6 = _this$reactComponentP5.editorViewMode) === null || _this$reactComponentP6 === void 0 ? void 0 : _this$reactComponentP6.sharedState;
|
|
601
|
+
this.unsubscribe = editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.onChange(({
|
|
602
|
+
nextSharedState
|
|
603
|
+
}) => this.updateContentEditable(nextSharedState, this.dom));
|
|
604
|
+
this.updateContentEditable(editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.currentState(), this.dom);
|
|
605
|
+
}
|
|
606
|
+
canReuseWith(provider, eventDispatcher) {
|
|
607
|
+
return this.reactComponentProps.provider === provider && this.eventDispatcher === eventDispatcher;
|
|
608
|
+
}
|
|
530
609
|
render() {
|
|
531
610
|
const {
|
|
532
611
|
eventDispatcher,
|
|
@@ -576,8 +655,11 @@ export class EmbedCard extends ReactNodeView {
|
|
|
576
655
|
return false;
|
|
577
656
|
}
|
|
578
657
|
destroy() {
|
|
579
|
-
var _this$
|
|
580
|
-
(_this$
|
|
658
|
+
var _this$unsubscribe2;
|
|
659
|
+
(_this$unsubscribe2 = this.unsubscribe) === null || _this$unsubscribe2 === void 0 ? void 0 : _this$unsubscribe2.call(this);
|
|
660
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
661
|
+
this.preservationSlot = undefined;
|
|
662
|
+
}
|
|
581
663
|
super.destroy();
|
|
582
664
|
}
|
|
583
665
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { preserveNodeView } from '@atlaskit/editor-common/preserve-node-view';
|
|
2
|
+
import { akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/constants';
|
|
3
|
+
import { embedCardNodeView, EmbedCard, isPreviewPanelResponsivenessEnabled } from './embedCard';
|
|
4
|
+
export const embedCardNodeViewWithPreservation = properties => (node, view, getPos) => {
|
|
5
|
+
var _properties$pluginInj, _properties$pluginInj2, _properties$pluginInj3;
|
|
6
|
+
const width = (_properties$pluginInj = properties.pluginInjectionApi) === null || _properties$pluginInj === void 0 ? void 0 : (_properties$pluginInj2 = _properties$pluginInj.width) === null || _properties$pluginInj2 === void 0 ? void 0 : (_properties$pluginInj3 = _properties$pluginInj2.sharedState.currentState()) === null || _properties$pluginInj3 === void 0 ? void 0 : _properties$pluginInj3.width;
|
|
7
|
+
const useResponsiveRenderer = isPreviewPanelResponsivenessEnabled() && !!width && width <= akEditorFullPageNarrowBreakout;
|
|
8
|
+
if (useResponsiveRenderer) {
|
|
9
|
+
return embedCardNodeView(properties)(node, view, getPos);
|
|
10
|
+
}
|
|
11
|
+
const {
|
|
12
|
+
portalProviderAPI,
|
|
13
|
+
eventDispatcher,
|
|
14
|
+
dispatchAnalyticsEvent
|
|
15
|
+
} = properties.pmPluginFactoryParams;
|
|
16
|
+
const renderProps = {
|
|
17
|
+
eventDispatcher,
|
|
18
|
+
allowResizing: properties.allowResizing,
|
|
19
|
+
fullWidthMode: properties.fullWidthMode,
|
|
20
|
+
dispatchAnalyticsEvent,
|
|
21
|
+
pluginInjectionApi: properties.pluginInjectionApi,
|
|
22
|
+
actionOptions: properties.actionOptions,
|
|
23
|
+
onClickCallback: properties.onClickCallback,
|
|
24
|
+
CompetitorPrompt: properties.CompetitorPrompt,
|
|
25
|
+
isPageSSRed: properties.isPageSSRed,
|
|
26
|
+
provider: properties.provider,
|
|
27
|
+
intl: properties.intl,
|
|
28
|
+
smartCardContext: properties.smartCardContext
|
|
29
|
+
};
|
|
30
|
+
const createCard = cardNode => new EmbedCard(cardNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
|
|
31
|
+
return preserveNodeView({
|
|
32
|
+
node,
|
|
33
|
+
view,
|
|
34
|
+
getPos,
|
|
35
|
+
renderProps,
|
|
36
|
+
rendererKind: portalProviderAPI,
|
|
37
|
+
createNodeView: createCard,
|
|
38
|
+
isSameNode: (previous, next) => previous === next,
|
|
39
|
+
canUpdateNode: (previous, next) => previous.type === next.type,
|
|
40
|
+
canReuse: inner => {
|
|
41
|
+
if (!(inner instanceof EmbedCard) || !inner.canReuseWith(properties.provider, properties.pmPluginFactoryParams.eventDispatcher)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
let nodeIdentityCount = 0;
|
|
45
|
+
view.state.doc.descendants(candidate => {
|
|
46
|
+
if (candidate === inner.node) {
|
|
47
|
+
nodeIdentityCount++;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return nodeIdentityCount === 1;
|
|
51
|
+
},
|
|
52
|
+
onAttach: (inner, slot, freshGetPos) => {
|
|
53
|
+
if (inner instanceof EmbedCard) {
|
|
54
|
+
inner.attachPreservationSlot(slot, freshGetPos);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
requireUniqueMatch: true
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -9,7 +9,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
9
9
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common/constants';
|
|
10
10
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
11
11
|
import { blockCardNodeView } from '../nodeviews/blockCard';
|
|
12
|
-
import {
|
|
12
|
+
import { createEmbedCardNodeView } from '../nodeviews/createEmbedCardNodeView';
|
|
13
13
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
14
14
|
import { lazyInlineCardView } from '../nodeviews/lazy-inline-card';
|
|
15
15
|
import { eventsFromTransaction } from '../ui/analytics/events-from-tr';
|
|
@@ -297,7 +297,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
297
297
|
intl,
|
|
298
298
|
smartCardContext
|
|
299
299
|
}),
|
|
300
|
-
embedCard:
|
|
300
|
+
embedCard: createEmbedCardNodeView({
|
|
301
301
|
allowResizing,
|
|
302
302
|
fullWidthMode,
|
|
303
303
|
pmPluginFactoryParams,
|
|
@@ -22,7 +22,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
22
22
|
import { Card as SmartCard } from '@atlaskit/smart-card/card/lazy';
|
|
23
23
|
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
24
24
|
import { Datasource } from '../nodeviews/datasource';
|
|
25
|
-
import { registerCard, removeCard
|
|
25
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
26
26
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
27
27
|
import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
|
|
28
28
|
import { Card } from './genericCard';
|
|
@@ -123,6 +123,14 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
this.removeCardDispatched = true;
|
|
126
|
+
this.removeCardRegistration();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "removeCardRegistration",
|
|
130
|
+
value: function removeCardRegistration() {
|
|
131
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
126
134
|
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
127
135
|
var _pluginInjectionApi$c2;
|
|
128
136
|
var _this$props3 = this.props,
|
|
@@ -131,7 +139,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
131
139
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.removeRegisteredCard(id);
|
|
132
140
|
} else {
|
|
133
141
|
var tr = this.props.view.state.tr;
|
|
134
|
-
|
|
142
|
+
removeCard({
|
|
135
143
|
id: this.props.id
|
|
136
144
|
})(tr);
|
|
137
145
|
this.props.view.dispatch(tr);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
|
+
import { embedCardNodeView } from './embedCard';
|
|
3
|
+
import { embedCardNodeViewWithPreservation } from './embedCardWithPreservation';
|
|
4
|
+
export var getEmbedCardNodeViewFactory = function getEmbedCardNodeViewFactory() {
|
|
5
|
+
return isExperimentEnabled('platform_editor_preserve_smart_card_embeds') ? embedCardNodeViewWithPreservation : embedCardNodeView;
|
|
6
|
+
};
|
|
7
|
+
export var createEmbedCardNodeView = function createEmbedCardNodeView(properties) {
|
|
8
|
+
return getEmbedCardNodeViewFactory()(properties);
|
|
9
|
+
};
|
|
@@ -34,7 +34,7 @@ import { EmbedResizeMessageListener } from '@atlaskit/smart-card/embed-resize-me
|
|
|
34
34
|
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
35
35
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
36
36
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
37
|
-
import { registerCard, removeCard
|
|
37
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
38
38
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
39
39
|
import { SmartCardSSRReactContextsProvider } from '../ui/SmartCardSSRReactContextsProvider';
|
|
40
40
|
import { BlockCardComponent } from './blockCard';
|
|
@@ -159,6 +159,16 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
_defineProperty(_this, "onResolve", function (data) {
|
|
162
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
163
|
+
_this.resolvedCardData = {
|
|
164
|
+
title: data.title,
|
|
165
|
+
url: data.url,
|
|
166
|
+
nodeUrl: _this.props.node.attrs.url
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
_this.resolveCard(data);
|
|
170
|
+
});
|
|
171
|
+
_defineProperty(_this, "resolveCard", function (data) {
|
|
162
172
|
var _getAspectRatioForUrl;
|
|
163
173
|
var view = _this.props.view;
|
|
164
174
|
var title = data.title,
|
|
@@ -220,6 +230,23 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
220
230
|
}
|
|
221
231
|
} catch (_unused2) {}
|
|
222
232
|
});
|
|
233
|
+
_defineProperty(_this, "registerResolvedCard", function (_ref2) {
|
|
234
|
+
var _pluginInjectionApi$c2;
|
|
235
|
+
var title = _ref2.title,
|
|
236
|
+
url = _ref2.url;
|
|
237
|
+
if (_this.removeCardDispatched || _this.props.view.isDestroyed || _this.getPosSafely() === undefined) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
var _this$props2 = _this.props,
|
|
241
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
242
|
+
id = _this$props2.id;
|
|
243
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.registerCard({
|
|
244
|
+
id: id,
|
|
245
|
+
title: title,
|
|
246
|
+
url: url,
|
|
247
|
+
getPos: _this.getPosSafely
|
|
248
|
+
});
|
|
249
|
+
});
|
|
223
250
|
_defineProperty(_this, "updateSize", function (pctWidth, layout) {
|
|
224
251
|
var _this$props$view = _this.props.view,
|
|
225
252
|
state = _this$props$view.state,
|
|
@@ -314,8 +341,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
314
341
|
});
|
|
315
342
|
_this.saveOriginalDimensionsAttributes(height, undefined);
|
|
316
343
|
});
|
|
317
|
-
_defineProperty(_this, "onError", function (
|
|
318
|
-
var err =
|
|
344
|
+
_defineProperty(_this, "onError", function (_ref3) {
|
|
345
|
+
var err = _ref3.err;
|
|
319
346
|
if (err) {
|
|
320
347
|
throw err;
|
|
321
348
|
}
|
|
@@ -331,6 +358,23 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
331
358
|
}
|
|
332
359
|
_inherits(EmbedCardComponent, _React$PureComponent);
|
|
333
360
|
return _createClass(EmbedCardComponent, [{
|
|
361
|
+
key: "componentDidUpdate",
|
|
362
|
+
value: function componentDidUpdate(prevProps) {
|
|
363
|
+
var _this2 = this;
|
|
364
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
365
|
+
var _this$resolvedCardDat;
|
|
366
|
+
if (((_this$resolvedCardDat = this.resolvedCardData) === null || _this$resolvedCardDat === void 0 ? void 0 : _this$resolvedCardDat.nodeUrl) !== this.props.node.attrs.url) {
|
|
367
|
+
this.resolvedCardData = undefined;
|
|
368
|
+
}
|
|
369
|
+
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2') && this.props.getPos !== prevProps.getPos && this.resolvedCardData) {
|
|
370
|
+
var resolvedCardData = this.resolvedCardData;
|
|
371
|
+
rafSchedule(function () {
|
|
372
|
+
return _this2.registerResolvedCard(resolvedCardData);
|
|
373
|
+
})();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
334
378
|
key: "componentWillUnmount",
|
|
335
379
|
value: function componentWillUnmount() {
|
|
336
380
|
this.removeCard();
|
|
@@ -342,15 +386,23 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
342
386
|
return;
|
|
343
387
|
}
|
|
344
388
|
this.removeCardDispatched = true;
|
|
389
|
+
this.removeCardRegistration();
|
|
390
|
+
}
|
|
391
|
+
}, {
|
|
392
|
+
key: "removeCardRegistration",
|
|
393
|
+
value: function removeCardRegistration() {
|
|
394
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.props.view.isDestroyed) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
345
397
|
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
346
|
-
var _pluginInjectionApi$
|
|
347
|
-
var _this$
|
|
348
|
-
pluginInjectionApi = _this$
|
|
349
|
-
id = _this$
|
|
350
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
398
|
+
var _pluginInjectionApi$c3;
|
|
399
|
+
var _this$props3 = this.props,
|
|
400
|
+
pluginInjectionApi = _this$props3.pluginInjectionApi,
|
|
401
|
+
id = _this$props3.id;
|
|
402
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.removeRegisteredCard(id);
|
|
351
403
|
} else {
|
|
352
404
|
var tr = this.props.view.state.tr;
|
|
353
|
-
|
|
405
|
+
removeCard({
|
|
354
406
|
id: this.props.id
|
|
355
407
|
})(tr);
|
|
356
408
|
this.props.view.dispatch(tr);
|
|
@@ -359,18 +411,18 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
359
411
|
}, {
|
|
360
412
|
key: "render",
|
|
361
413
|
value: function render() {
|
|
362
|
-
var _this$
|
|
363
|
-
node = _this$
|
|
364
|
-
allowResizing = _this$
|
|
365
|
-
fullWidthMode = _this$
|
|
366
|
-
view = _this$
|
|
367
|
-
dispatchAnalyticsEvent = _this$
|
|
368
|
-
getPos = _this$
|
|
369
|
-
pluginInjectionApi = _this$
|
|
370
|
-
actionOptions = _this$
|
|
371
|
-
onClick = _this$
|
|
372
|
-
CompetitorPrompt = _this$
|
|
373
|
-
isPageSSRed = _this$
|
|
414
|
+
var _this$props4 = this.props,
|
|
415
|
+
node = _this$props4.node,
|
|
416
|
+
allowResizing = _this$props4.allowResizing,
|
|
417
|
+
fullWidthMode = _this$props4.fullWidthMode,
|
|
418
|
+
view = _this$props4.view,
|
|
419
|
+
dispatchAnalyticsEvent = _this$props4.dispatchAnalyticsEvent,
|
|
420
|
+
getPos = _this$props4.getPos,
|
|
421
|
+
pluginInjectionApi = _this$props4.pluginInjectionApi,
|
|
422
|
+
actionOptions = _this$props4.actionOptions,
|
|
423
|
+
onClick = _this$props4.onClick,
|
|
424
|
+
CompetitorPrompt = _this$props4.CompetitorPrompt,
|
|
425
|
+
isPageSSRed = _this$props4.isPageSSRed;
|
|
374
426
|
var _node$attrs = node.attrs,
|
|
375
427
|
url = _node$attrs.url,
|
|
376
428
|
pctWidth = _node$attrs.width,
|
|
@@ -498,6 +550,11 @@ export var EmbedOrBlockCardComponent = function EmbedOrBlockCardComponent(props)
|
|
|
498
550
|
provider: props.provider
|
|
499
551
|
});
|
|
500
552
|
};
|
|
553
|
+
export var isPreviewPanelResponsivenessEnabled = function isPreviewPanelResponsivenessEnabled() {
|
|
554
|
+
return editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
555
|
+
exposure: true
|
|
556
|
+
});
|
|
557
|
+
};
|
|
501
558
|
var WrappedEmbedCardWithCondition = componentWithCondition(function () {
|
|
502
559
|
return editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
503
560
|
exposure: true
|
|
@@ -506,18 +563,21 @@ var WrappedEmbedCardWithCondition = componentWithCondition(function () {
|
|
|
506
563
|
var WrappedEmbedCard = Card(WrappedEmbedCardWithCondition, UnsupportedBlock);
|
|
507
564
|
export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
508
565
|
function EmbedCard() {
|
|
509
|
-
var
|
|
566
|
+
var _this3;
|
|
510
567
|
_classCallCheck(this, EmbedCard);
|
|
511
568
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
512
569
|
args[_key] = arguments[_key];
|
|
513
570
|
}
|
|
514
|
-
|
|
571
|
+
_this3 = _callSuper(this, EmbedCard, [].concat(args));
|
|
515
572
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
516
|
-
_defineProperty(
|
|
517
|
-
_defineProperty(
|
|
573
|
+
_defineProperty(_this3, "id", uuid());
|
|
574
|
+
_defineProperty(_this3, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
518
575
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
576
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && _this3.preservationSlot) {
|
|
577
|
+
_this3.preservationSlot.contentEditable = divElement.contentEditable;
|
|
578
|
+
}
|
|
519
579
|
});
|
|
520
|
-
return
|
|
580
|
+
return _this3;
|
|
521
581
|
}
|
|
522
582
|
_inherits(EmbedCard, _ReactNodeView);
|
|
523
583
|
return _createClass(EmbedCard, [{
|
|
@@ -532,33 +592,70 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
532
592
|
key: "createDomRef",
|
|
533
593
|
value: function createDomRef() {
|
|
534
594
|
var _this$reactComponentP,
|
|
535
|
-
|
|
595
|
+
_this4 = this,
|
|
536
596
|
_this$reactComponentP2;
|
|
537
597
|
var domRef = document.createElement('div');
|
|
538
598
|
// 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
|
|
539
|
-
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 (
|
|
540
|
-
var nextSharedState =
|
|
541
|
-
return
|
|
599
|
+
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) {
|
|
600
|
+
var nextSharedState = _ref4.nextSharedState;
|
|
601
|
+
return _this4.updateContentEditable(nextSharedState, domRef);
|
|
542
602
|
});
|
|
543
603
|
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);
|
|
544
604
|
domRef.setAttribute('spellcheck', 'false');
|
|
545
605
|
return domRef;
|
|
546
606
|
}
|
|
607
|
+
}, {
|
|
608
|
+
key: "setDomAttrs",
|
|
609
|
+
value: function setDomAttrs(node, element) {
|
|
610
|
+
_superPropGet(EmbedCard, "setDomAttrs", this, 3)([node, element]);
|
|
611
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds') && this.preservationSlot) {
|
|
612
|
+
_superPropGet(EmbedCard, "setDomAttrs", this, 3)([node, this.preservationSlot]);
|
|
613
|
+
if (element !== this.preservationSlot) {
|
|
614
|
+
Object.keys(node.attrs || {}).forEach(function (attr) {
|
|
615
|
+
return element.removeAttribute(attr);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
key: "attachPreservationSlot",
|
|
622
|
+
value: function attachPreservationSlot(slot, getPos) {
|
|
623
|
+
var _this$unsubscribe,
|
|
624
|
+
_this$reactComponentP3,
|
|
625
|
+
_this5 = this;
|
|
626
|
+
this.getPos = getPos;
|
|
627
|
+
this.preservationSlot = slot;
|
|
628
|
+
slot.classList.add("".concat(this.node.type.name, "View-content-wrap"));
|
|
629
|
+
this.dom.classList.remove("".concat(this.node.type.name, "View-content-wrap"));
|
|
630
|
+
this.setDomAttrs(this.node, this.dom);
|
|
631
|
+
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
632
|
+
var editorViewMode = (_this$reactComponentP3 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP3 === void 0 || (_this$reactComponentP3 = _this$reactComponentP3.editorViewMode) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.sharedState;
|
|
633
|
+
this.unsubscribe = editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.onChange(function (_ref5) {
|
|
634
|
+
var nextSharedState = _ref5.nextSharedState;
|
|
635
|
+
return _this5.updateContentEditable(nextSharedState, _this5.dom);
|
|
636
|
+
});
|
|
637
|
+
this.updateContentEditable(editorViewMode === null || editorViewMode === void 0 ? void 0 : editorViewMode.currentState(), this.dom);
|
|
638
|
+
}
|
|
639
|
+
}, {
|
|
640
|
+
key: "canReuseWith",
|
|
641
|
+
value: function canReuseWith(provider, eventDispatcher) {
|
|
642
|
+
return this.reactComponentProps.provider === provider && this.eventDispatcher === eventDispatcher;
|
|
643
|
+
}
|
|
547
644
|
}, {
|
|
548
645
|
key: "render",
|
|
549
646
|
value: function render() {
|
|
550
|
-
var _this$
|
|
551
|
-
eventDispatcher = _this$
|
|
552
|
-
allowResizing = _this$
|
|
553
|
-
fullWidthMode = _this$
|
|
554
|
-
dispatchAnalyticsEvent = _this$
|
|
555
|
-
pluginInjectionApi = _this$
|
|
556
|
-
onClickCallback = _this$
|
|
557
|
-
CompetitorPrompt = _this$
|
|
558
|
-
isPageSSRed = _this$
|
|
559
|
-
provider = _this$
|
|
560
|
-
intl = _this$
|
|
561
|
-
smartCardContext = _this$
|
|
647
|
+
var _this$reactComponentP4 = this.reactComponentProps,
|
|
648
|
+
eventDispatcher = _this$reactComponentP4.eventDispatcher,
|
|
649
|
+
allowResizing = _this$reactComponentP4.allowResizing,
|
|
650
|
+
fullWidthMode = _this$reactComponentP4.fullWidthMode,
|
|
651
|
+
dispatchAnalyticsEvent = _this$reactComponentP4.dispatchAnalyticsEvent,
|
|
652
|
+
pluginInjectionApi = _this$reactComponentP4.pluginInjectionApi,
|
|
653
|
+
onClickCallback = _this$reactComponentP4.onClickCallback,
|
|
654
|
+
CompetitorPrompt = _this$reactComponentP4.CompetitorPrompt,
|
|
655
|
+
isPageSSRed = _this$reactComponentP4.isPageSSRed,
|
|
656
|
+
provider = _this$reactComponentP4.provider,
|
|
657
|
+
intl = _this$reactComponentP4.intl,
|
|
658
|
+
smartCardContext = _this$reactComponentP4.smartCardContext;
|
|
562
659
|
return /*#__PURE__*/React.createElement(SmartCardSSRReactContextsProvider, {
|
|
563
660
|
intl: intl,
|
|
564
661
|
smartCardContext: smartCardContext
|
|
@@ -598,24 +695,27 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
598
695
|
}, {
|
|
599
696
|
key: "destroy",
|
|
600
697
|
value: function destroy() {
|
|
601
|
-
var _this$
|
|
602
|
-
(_this$
|
|
698
|
+
var _this$unsubscribe2;
|
|
699
|
+
(_this$unsubscribe2 = this.unsubscribe) === null || _this$unsubscribe2 === void 0 || _this$unsubscribe2.call(this);
|
|
700
|
+
if (isExperimentEnabled('platform_editor_preserve_smart_card_embeds')) {
|
|
701
|
+
this.preservationSlot = undefined;
|
|
702
|
+
}
|
|
603
703
|
_superPropGet(EmbedCard, "destroy", this, 3)([]);
|
|
604
704
|
}
|
|
605
705
|
}]);
|
|
606
706
|
}(ReactNodeView);
|
|
607
|
-
export var embedCardNodeView = function embedCardNodeView(
|
|
608
|
-
var allowResizing =
|
|
609
|
-
fullWidthMode =
|
|
610
|
-
pmPluginFactoryParams =
|
|
611
|
-
pluginInjectionApi =
|
|
612
|
-
actionOptions =
|
|
613
|
-
onClickCallback =
|
|
614
|
-
CompetitorPrompt =
|
|
615
|
-
isPageSSRed =
|
|
616
|
-
provider =
|
|
617
|
-
intl =
|
|
618
|
-
smartCardContext =
|
|
707
|
+
export var embedCardNodeView = function embedCardNodeView(_ref6) {
|
|
708
|
+
var allowResizing = _ref6.allowResizing,
|
|
709
|
+
fullWidthMode = _ref6.fullWidthMode,
|
|
710
|
+
pmPluginFactoryParams = _ref6.pmPluginFactoryParams,
|
|
711
|
+
pluginInjectionApi = _ref6.pluginInjectionApi,
|
|
712
|
+
actionOptions = _ref6.actionOptions,
|
|
713
|
+
onClickCallback = _ref6.onClickCallback,
|
|
714
|
+
CompetitorPrompt = _ref6.CompetitorPrompt,
|
|
715
|
+
isPageSSRed = _ref6.isPageSSRed,
|
|
716
|
+
provider = _ref6.provider,
|
|
717
|
+
intl = _ref6.intl,
|
|
718
|
+
smartCardContext = _ref6.smartCardContext;
|
|
619
719
|
return function (node, view, getPos) {
|
|
620
720
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
621
721
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { preserveNodeView } from '@atlaskit/editor-common/preserve-node-view';
|
|
2
|
+
import { akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/constants';
|
|
3
|
+
import { embedCardNodeView, EmbedCard, isPreviewPanelResponsivenessEnabled } from './embedCard';
|
|
4
|
+
export var embedCardNodeViewWithPreservation = function embedCardNodeViewWithPreservation(properties) {
|
|
5
|
+
return function (node, view, getPos) {
|
|
6
|
+
var _properties$pluginInj;
|
|
7
|
+
var width = (_properties$pluginInj = properties.pluginInjectionApi) === null || _properties$pluginInj === void 0 || (_properties$pluginInj = _properties$pluginInj.width) === null || _properties$pluginInj === void 0 || (_properties$pluginInj = _properties$pluginInj.sharedState.currentState()) === null || _properties$pluginInj === void 0 ? void 0 : _properties$pluginInj.width;
|
|
8
|
+
var useResponsiveRenderer = isPreviewPanelResponsivenessEnabled() && !!width && width <= akEditorFullPageNarrowBreakout;
|
|
9
|
+
if (useResponsiveRenderer) {
|
|
10
|
+
return embedCardNodeView(properties)(node, view, getPos);
|
|
11
|
+
}
|
|
12
|
+
var _properties$pmPluginF = properties.pmPluginFactoryParams,
|
|
13
|
+
portalProviderAPI = _properties$pmPluginF.portalProviderAPI,
|
|
14
|
+
eventDispatcher = _properties$pmPluginF.eventDispatcher,
|
|
15
|
+
dispatchAnalyticsEvent = _properties$pmPluginF.dispatchAnalyticsEvent;
|
|
16
|
+
var renderProps = {
|
|
17
|
+
eventDispatcher: eventDispatcher,
|
|
18
|
+
allowResizing: properties.allowResizing,
|
|
19
|
+
fullWidthMode: properties.fullWidthMode,
|
|
20
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
21
|
+
pluginInjectionApi: properties.pluginInjectionApi,
|
|
22
|
+
actionOptions: properties.actionOptions,
|
|
23
|
+
onClickCallback: properties.onClickCallback,
|
|
24
|
+
CompetitorPrompt: properties.CompetitorPrompt,
|
|
25
|
+
isPageSSRed: properties.isPageSSRed,
|
|
26
|
+
provider: properties.provider,
|
|
27
|
+
intl: properties.intl,
|
|
28
|
+
smartCardContext: properties.smartCardContext
|
|
29
|
+
};
|
|
30
|
+
var createCard = function createCard(cardNode) {
|
|
31
|
+
return new EmbedCard(cardNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
|
|
32
|
+
};
|
|
33
|
+
return preserveNodeView({
|
|
34
|
+
node: node,
|
|
35
|
+
view: view,
|
|
36
|
+
getPos: getPos,
|
|
37
|
+
renderProps: renderProps,
|
|
38
|
+
rendererKind: portalProviderAPI,
|
|
39
|
+
createNodeView: createCard,
|
|
40
|
+
isSameNode: function isSameNode(previous, next) {
|
|
41
|
+
return previous === next;
|
|
42
|
+
},
|
|
43
|
+
canUpdateNode: function canUpdateNode(previous, next) {
|
|
44
|
+
return previous.type === next.type;
|
|
45
|
+
},
|
|
46
|
+
canReuse: function canReuse(inner) {
|
|
47
|
+
if (!(inner instanceof EmbedCard) || !inner.canReuseWith(properties.provider, properties.pmPluginFactoryParams.eventDispatcher)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
var nodeIdentityCount = 0;
|
|
51
|
+
view.state.doc.descendants(function (candidate) {
|
|
52
|
+
if (candidate === inner.node) {
|
|
53
|
+
nodeIdentityCount++;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return nodeIdentityCount === 1;
|
|
57
|
+
},
|
|
58
|
+
onAttach: function onAttach(inner, slot, freshGetPos) {
|
|
59
|
+
if (inner instanceof EmbedCard) {
|
|
60
|
+
inner.attachPreservationSlot(slot, freshGetPos);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
requireUniqueMatch: true
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -13,7 +13,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
13
13
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common/constants';
|
|
14
14
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
15
15
|
import { blockCardNodeView } from '../nodeviews/blockCard';
|
|
16
|
-
import {
|
|
16
|
+
import { createEmbedCardNodeView } from '../nodeviews/createEmbedCardNodeView';
|
|
17
17
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
18
18
|
import { lazyInlineCardView } from '../nodeviews/lazy-inline-card';
|
|
19
19
|
import { eventsFromTransaction } from '../ui/analytics/events-from-tr';
|
|
@@ -295,7 +295,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
295
295
|
intl: intl,
|
|
296
296
|
smartCardContext: smartCardContext
|
|
297
297
|
}),
|
|
298
|
-
embedCard:
|
|
298
|
+
embedCard: createEmbedCardNodeView({
|
|
299
299
|
allowResizing: allowResizing,
|
|
300
300
|
fullWidthMode: fullWidthMode,
|
|
301
301
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
@@ -23,6 +23,7 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
|
|
|
23
23
|
componentWillUnmount(): void;
|
|
24
24
|
private removeCardDispatched;
|
|
25
25
|
private removeCard;
|
|
26
|
+
private removeCardRegistration;
|
|
26
27
|
gapCursorSpan: () => React.JSX.Element | undefined;
|
|
27
28
|
onError: ({ err }: {
|
|
28
29
|
err?: Error;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EmbedCardNodeViewProperties } from './embedCard';
|
|
2
|
+
import { embedCardNodeViewWithPreservation } from './embedCardWithPreservation';
|
|
3
|
+
export declare const getEmbedCardNodeViewFactory: () => typeof embedCardNodeViewWithPreservation;
|
|
4
|
+
export declare const createEmbedCardNodeView: (properties: EmbedCardNodeViewProperties) => ReturnType<typeof embedCardNodeViewWithPreservation>;
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { IntlShape } from 'react-intl';
|
|
4
4
|
import type { Layout as RichMediaLayout } from '@atlaskit/adf-schema/rich-media-common';
|
|
5
|
+
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
6
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
|
+
import type { getPosHandler } from '@atlaskit/editor-common/react-node-view/types';
|
|
6
8
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
7
9
|
import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types/plugin-factory';
|
|
8
10
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -32,6 +34,10 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
|
|
|
32
34
|
}, EmbedCardState> {
|
|
33
35
|
private scrollContainer?;
|
|
34
36
|
private embedIframeRef;
|
|
37
|
+
private resolvedCardData?;
|
|
38
|
+
componentDidUpdate(prevProps: Readonly<SmartCardProps & {
|
|
39
|
+
id: string;
|
|
40
|
+
}>): void;
|
|
35
41
|
constructor(props: SmartCardProps & {
|
|
36
42
|
id: string;
|
|
37
43
|
});
|
|
@@ -42,6 +48,8 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
|
|
|
42
48
|
title?: string;
|
|
43
49
|
url?: string;
|
|
44
50
|
}) => void;
|
|
51
|
+
private resolveCard;
|
|
52
|
+
private registerResolvedCard;
|
|
45
53
|
updateSize: (pctWidth: number | null, layout: RichMediaLayout) => true | undefined;
|
|
46
54
|
/**
|
|
47
55
|
* Defers line-length measurement until the embed card DOM has fully rendered.
|
|
@@ -68,15 +76,21 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
|
|
|
68
76
|
componentWillUnmount(): void;
|
|
69
77
|
private removeCardDispatched;
|
|
70
78
|
private removeCard;
|
|
79
|
+
private removeCardRegistration;
|
|
71
80
|
render(): React.JSX.Element;
|
|
72
81
|
}
|
|
73
82
|
export declare const EmbedOrBlockCardComponent: (props: ComponentProps<typeof EmbedCardComponent>) => React.JSX.Element;
|
|
83
|
+
export declare const isPreviewPanelResponsivenessEnabled: () => boolean;
|
|
74
84
|
export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback' | 'isPageSSRed' | 'provider' | 'CompetitorPrompt' | 'intl' | 'smartCardContext'>;
|
|
75
85
|
export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
|
|
76
86
|
private id;
|
|
87
|
+
private preservationSlot?;
|
|
77
88
|
unsubscribe: (() => void) | undefined;
|
|
78
89
|
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
79
90
|
createDomRef(): HTMLElement;
|
|
91
|
+
setDomAttrs(node: PMNode, element: HTMLElement): void;
|
|
92
|
+
attachPreservationSlot(slot: HTMLElement, getPos: getPosHandler): void;
|
|
93
|
+
canReuseWith(provider: EmbedCardNodeViewProps['provider'], eventDispatcher: EventDispatcher): boolean;
|
|
80
94
|
private updateContentEditable;
|
|
81
95
|
render(): React.JSX.Element;
|
|
82
96
|
/**
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { EmbedCardNodeViewProperties } from './embedCard';
|
|
4
|
+
export declare const embedCardNodeViewWithPreservation: (properties: EmbedCardNodeViewProperties) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => NodeView;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "36.0.
|
|
3
|
+
"version": "36.0.6",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"@atlaskit/link": "^5.1.0",
|
|
53
53
|
"@atlaskit/link-analytics": "^13.0.0",
|
|
54
54
|
"@atlaskit/link-client-extension": "^8.0.0",
|
|
55
|
-
"@atlaskit/link-datasource": "^7.
|
|
55
|
+
"@atlaskit/link-datasource": "^7.10.0",
|
|
56
56
|
"@atlaskit/link-extractors": "^5.0.0",
|
|
57
57
|
"@atlaskit/linking-common": "^13.0.0",
|
|
58
|
-
"@atlaskit/linking-types": "^16.
|
|
58
|
+
"@atlaskit/linking-types": "^16.1.0",
|
|
59
59
|
"@atlaskit/menu": "^11.0.0",
|
|
60
60
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
61
61
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
62
62
|
"@atlaskit/platform-feature-flags-react": "^1.2.0",
|
|
63
63
|
"@atlaskit/primitives": "^22.6.0",
|
|
64
64
|
"@atlaskit/prosemirror-history": "^1.3.0",
|
|
65
|
-
"@atlaskit/smart-card": "^46.
|
|
66
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
67
|
-
"@atlaskit/tokens": "^20.
|
|
65
|
+
"@atlaskit/smart-card": "^46.11.0",
|
|
66
|
+
"@atlaskit/tmp-editor-statsig": "^250.0.0",
|
|
67
|
+
"@atlaskit/tokens": "^20.9.0",
|
|
68
68
|
"@babel/runtime": "^7.0.0",
|
|
69
69
|
"@emotion/react": "^11.7.1",
|
|
70
70
|
"lodash": "^4.17.21",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"uuid": "^11.1.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atlaskit/editor-common": "^134.
|
|
75
|
+
"@atlaskit/editor-common": "^134.3.0",
|
|
76
76
|
"@atlaskit/link-provider": "^6.0.0",
|
|
77
77
|
"react": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|