@atlaskit/editor-plugin-card 36.0.5 → 36.0.8
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 +26 -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/cjs/ui/quick-insert/DatasourceQuickInsertMenuItem.js +1 -1
- package/dist/cjs/ui/quick-insert/getCardQuickInsertComponents.js +1 -1
- 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/es2019/ui/quick-insert/DatasourceQuickInsertMenuItem.js +1 -1
- package/dist/es2019/ui/quick-insert/getCardQuickInsertComponents.js +1 -1
- 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/esm/ui/quick-insert/DatasourceQuickInsertMenuItem.js +1 -1
- package/dist/esm/ui/quick-insert/getCardQuickInsertComponents.js +1 -1
- 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,31 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 36.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 36.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`ce5f97ab62e45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ce5f97ab62e45) -
|
|
14
|
+
[EDITOR-9779] Apply Hello slash menu naming and ranking behind platform_editor_slash_command:
|
|
15
|
+
rename the Loom record item to "Loom" and Insert Confluence list to "Confluence list", rank Assets
|
|
16
|
+
after the Spaces items in Data and charts, and stop forcing Smart button into Structure
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 36.0.6
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`9ed4f69277c0c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ed4f69277c0c) -
|
|
24
|
+
Preserve Smart Card iframe state across editor width changes using a shared node-view preservation
|
|
25
|
+
helper, behind platform_editor_preserve_smart_card_embeds. Keep the existing Remix preservation
|
|
26
|
+
path when the experiment is disabled.
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 36.0.5
|
|
4
30
|
|
|
5
31
|
### 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,
|
|
@@ -61,6 +61,6 @@ var DatasourceQuickInsertMenuItem = exports.DatasourceQuickInsertMenuItem = func
|
|
|
61
61
|
isDisabled: isOffline,
|
|
62
62
|
onSelect: onSelect,
|
|
63
63
|
preview: preview,
|
|
64
|
-
title: formatMessage(isJira ? (0, _fg.fg)('confluence-issue-terminology-refresh') ? _card.messages.datasourceJiraIssueIssueTermRefresh : _card.messages.datasourceJiraIssue : isConfluenceSearch ? _card.messages.
|
|
64
|
+
title: formatMessage(isJira ? (0, _fg.fg)('confluence-issue-terminology-refresh') ? _card.messages.datasourceJiraIssueIssueTermRefresh : _card.messages.datasourceJiraIssue : isConfluenceSearch ? _card.messages.datasourceConfluenceList : _card.messages.datasourceAssetsObjectsGeneralAvailability)
|
|
65
65
|
});
|
|
66
66
|
};
|
|
@@ -97,7 +97,7 @@ var getCardQuickInsertComponents = exports.getCardQuickInsertComponents = functi
|
|
|
97
97
|
return {
|
|
98
98
|
description: formatMessage(_card.messages.datasourceConfluenceSearchDescription),
|
|
99
99
|
keywords: ['confluence'],
|
|
100
|
-
title: formatMessage(_card.messages.
|
|
100
|
+
title: formatMessage(_card.messages.datasourceConfluenceList)
|
|
101
101
|
};
|
|
102
102
|
}),
|
|
103
103
|
component: function component() {
|
|
@@ -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
|
}
|