@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
|
@@ -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,
|
|
@@ -52,6 +52,6 @@ export const DatasourceQuickInsertMenuItem = ({
|
|
|
52
52
|
isDisabled: isOffline,
|
|
53
53
|
onSelect: onSelect,
|
|
54
54
|
preview: preview,
|
|
55
|
-
title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : isConfluenceSearch ? messages.
|
|
55
|
+
title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : isConfluenceSearch ? messages.datasourceConfluenceList : messages.datasourceAssetsObjectsGeneralAvailability)
|
|
56
56
|
});
|
|
57
57
|
};
|
|
@@ -88,7 +88,7 @@ export const getCardQuickInsertComponents = ({
|
|
|
88
88
|
}) => ({
|
|
89
89
|
description: formatMessage(messages.datasourceConfluenceSearchDescription),
|
|
90
90
|
keywords: ['confluence'],
|
|
91
|
-
title: formatMessage(messages.
|
|
91
|
+
title: formatMessage(messages.datasourceConfluenceList)
|
|
92
92
|
})),
|
|
93
93
|
component: () => /*#__PURE__*/React.createElement(DatasourceQuickInsertMenuItem, {
|
|
94
94
|
api: api,
|
|
@@ -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,
|
|
@@ -52,6 +52,6 @@ export var DatasourceQuickInsertMenuItem = function DatasourceQuickInsertMenuIte
|
|
|
52
52
|
isDisabled: isOffline,
|
|
53
53
|
onSelect: onSelect,
|
|
54
54
|
preview: preview,
|
|
55
|
-
title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : isConfluenceSearch ? messages.
|
|
55
|
+
title: formatMessage(isJira ? fg('confluence-issue-terminology-refresh') ? messages.datasourceJiraIssueIssueTermRefresh : messages.datasourceJiraIssue : isConfluenceSearch ? messages.datasourceConfluenceList : messages.datasourceAssetsObjectsGeneralAvailability)
|
|
56
56
|
});
|
|
57
57
|
};
|
|
@@ -90,7 +90,7 @@ export var getCardQuickInsertComponents = function getCardQuickInsertComponents(
|
|
|
90
90
|
return {
|
|
91
91
|
description: formatMessage(messages.datasourceConfluenceSearchDescription),
|
|
92
92
|
keywords: ['confluence'],
|
|
93
|
-
title: formatMessage(messages.
|
|
93
|
+
title: formatMessage(messages.datasourceConfluenceList)
|
|
94
94
|
};
|
|
95
95
|
}),
|
|
96
96
|
component: function component() {
|
|
@@ -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;
|