@atlaskit/editor-plugin-card 13.0.3 → 13.0.5
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 +12 -0
- package/dist/cjs/cardPlugin.js +5 -0
- package/dist/cjs/pm-plugins/doc.js +44 -3
- package/dist/cjs/pm-plugins/main.js +5 -3
- package/dist/cjs/pm-plugins/util/resolve.js +4 -4
- package/dist/es2019/cardPlugin.js +5 -0
- package/dist/es2019/pm-plugins/doc.js +44 -3
- package/dist/es2019/pm-plugins/main.js +5 -3
- package/dist/es2019/pm-plugins/util/resolve.js +4 -4
- package/dist/esm/cardPlugin.js +5 -0
- package/dist/esm/pm-plugins/doc.js +44 -3
- package/dist/esm/pm-plugins/main.js +5 -3
- package/dist/esm/pm-plugins/util/resolve.js +4 -4
- package/dist/types/pm-plugins/doc.d.ts +2 -2
- package/dist/types/pm-plugins/util/resolve.d.ts +2 -2
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +3 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/dist/cjs/cardPlugin.js
CHANGED
|
@@ -39,6 +39,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
39
39
|
api = _ref.api;
|
|
40
40
|
var previousCardProvider;
|
|
41
41
|
var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
|
|
42
|
+
var instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
42
43
|
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref2) {
|
|
43
44
|
var tr = _ref2.tr,
|
|
44
45
|
node = _ref2.node,
|
|
@@ -95,6 +96,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
95
96
|
allowAlignment: allowAlignment,
|
|
96
97
|
allowDatasource: allowDatasource,
|
|
97
98
|
cardPluginEvents: cardPluginEvents,
|
|
99
|
+
embedCardTransformers: instanceEmbedCardTransformers,
|
|
98
100
|
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
99
101
|
}), api)
|
|
100
102
|
}];
|
|
@@ -168,6 +170,9 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
168
170
|
}(),
|
|
169
171
|
hideLinkToolbar: _actions.hideLinkToolbar,
|
|
170
172
|
queueCardsFromChangedTr: _doc.queueCardsFromChangedTr,
|
|
173
|
+
registerEmbedCardTransformer: function registerEmbedCardTransformer(transformers) {
|
|
174
|
+
instanceEmbedCardTransformers = transformers;
|
|
175
|
+
},
|
|
171
176
|
getStartingToolbarItems: (0, _toolbar.getStartingToolbarItems)(options, api),
|
|
172
177
|
getEndingToolbarItems: (0, _toolbar.getEndingToolbarItems)(options, api)
|
|
173
178
|
},
|
|
@@ -60,7 +60,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
60
60
|
}
|
|
61
61
|
return $pos.node($pos.depth - 1).type.name;
|
|
62
62
|
}
|
|
63
|
-
var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) {
|
|
63
|
+
var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) {
|
|
64
64
|
return function (editorState, dispatch) {
|
|
65
65
|
var state = _pluginKey.pluginKey.getState(editorState);
|
|
66
66
|
if (!state) {
|
|
@@ -74,7 +74,18 @@ var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function repla
|
|
|
74
74
|
|
|
75
75
|
// try to transform response to ADF
|
|
76
76
|
var schema = editorState.schema;
|
|
77
|
-
var cardAdf =
|
|
77
|
+
var cardAdf = null;
|
|
78
|
+
|
|
79
|
+
// If an embed card transformer is provided and the resolved card is an embedCard,
|
|
80
|
+
// attempt to transform it into an alternative node representation first.
|
|
81
|
+
if (cardData.type === 'embedCard' && embedCardNodeTransformer) {
|
|
82
|
+
var _embedCardNodeTransfo;
|
|
83
|
+
cardAdf = (_embedCardNodeTransfo = embedCardNodeTransformer(schema, cardData.attrs)) !== null && _embedCardNodeTransfo !== void 0 ? _embedCardNodeTransfo : null;
|
|
84
|
+
}
|
|
85
|
+
if (!cardAdf) {
|
|
86
|
+
var _processRawValue;
|
|
87
|
+
cardAdf = (_processRawValue = (0, _utils.processRawValue)(schema, cardData)) !== null && _processRawValue !== void 0 ? _processRawValue : null;
|
|
88
|
+
}
|
|
78
89
|
var tr = editorState.tr;
|
|
79
90
|
if (cardAdf) {
|
|
80
91
|
// Should prevent any other node than cards? [inlineCard, blockCard].includes(cardAdf.type)
|
|
@@ -380,7 +391,7 @@ var changeSelectedCardToText = exports.changeSelectedCardToText = function chang
|
|
|
380
391
|
};
|
|
381
392
|
var setSelectedCardAppearance = exports.setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
|
|
382
393
|
return function (state, dispatch) {
|
|
383
|
-
var _previousNode$type;
|
|
394
|
+
var _selectedNode$attrs$d, _previousNode$type;
|
|
384
395
|
var selectedNode = state.selection instanceof _state.NodeSelection ? state.selection.node : undefined;
|
|
385
396
|
if (!selectedNode) {
|
|
386
397
|
// When there is no selected node, we insert a new one
|
|
@@ -403,6 +414,36 @@ var setSelectedCardAppearance = exports.setSelectedCardAppearance = function set
|
|
|
403
414
|
to = _state$selection.to;
|
|
404
415
|
var nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
405
416
|
var tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
417
|
+
|
|
418
|
+
// If switching to embed appearance, attempt to use a registered transform command
|
|
419
|
+
// to create an alternative node representation (e.g. a native embed).
|
|
420
|
+
if (appearance === 'embed' && (selectedNode.attrs.url || (_selectedNode$attrs$d = selectedNode.attrs.data) !== null && _selectedNode$attrs$d !== void 0 && _selectedNode$attrs$d.url)) {
|
|
421
|
+
var _cardState$embedCardT;
|
|
422
|
+
var cardState = _pluginKey.pluginKey.getState(state);
|
|
423
|
+
var createEmbedCardTransformCommand = cardState === null || cardState === void 0 || (_cardState$embedCardT = cardState.embedCardTransformers) === null || _cardState$embedCardT === void 0 ? void 0 : _cardState$embedCardT.createEmbedCardTransformCommand;
|
|
424
|
+
if (createEmbedCardTransformCommand) {
|
|
425
|
+
var transformCommand = createEmbedCardTransformCommand({
|
|
426
|
+
augmentTransaction: function augmentTransaction(augmentTr) {
|
|
427
|
+
updateDatasourceStash(augmentTr, selectedNode);
|
|
428
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
429
|
+
action: _analytics.ACTION.CHANGED_TYPE,
|
|
430
|
+
actionSubject: _analytics.ACTION_SUBJECT.SMART_LINK,
|
|
431
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
432
|
+
attributes: {
|
|
433
|
+
newType: appearance,
|
|
434
|
+
previousType: (0, _utils2.appearanceForNodeType)(selectedNode.type)
|
|
435
|
+
}
|
|
436
|
+
})(augmentTr);
|
|
437
|
+
(0, _card.addLinkMetadata)(state.selection, augmentTr, {
|
|
438
|
+
action: _analytics.ACTION.CHANGED_TYPE
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
if (transformCommand(state, dispatch)) {
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
406
447
|
updateDatasourceStash(tr, selectedNode);
|
|
407
448
|
|
|
408
449
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
@@ -55,7 +55,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
55
55
|
onClickCallback = options.onClickCallback,
|
|
56
56
|
isPageSSRed = options.isPageSSRed,
|
|
57
57
|
provider = options.provider,
|
|
58
|
-
CompetitorPrompt = options.CompetitorPrompt
|
|
58
|
+
CompetitorPrompt = options.CompetitorPrompt,
|
|
59
|
+
embedCardTransformers = options.embedCardTransformers;
|
|
59
60
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
|
|
60
61
|
var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)({
|
|
61
62
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
@@ -84,6 +85,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
84
85
|
showLinkingToolbar: false,
|
|
85
86
|
smartLinkEvents: undefined,
|
|
86
87
|
editorAppearance: editorAppearance,
|
|
88
|
+
embedCardTransformers: embedCardTransformers,
|
|
87
89
|
showDatasourceModal: false,
|
|
88
90
|
datasourceModalType: undefined,
|
|
89
91
|
datasourceTableRef: undefined,
|
|
@@ -210,8 +212,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
210
212
|
* other tasks as per common implementations of the JavaScript event loop in browsers.
|
|
211
213
|
*/
|
|
212
214
|
var invoke = (0, _rafSchd.default)(function () {
|
|
213
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3;
|
|
214
|
-
return (0, _resolve.resolveWithProvider)(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
|
|
215
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _currentState$embedCa;
|
|
216
|
+
return (0, _resolve.resolveWithProvider)(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 || (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
215
217
|
});
|
|
216
218
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
217
219
|
invoke();
|
|
@@ -33,7 +33,7 @@ var isFreshlyPastedOnNewLine = function isFreshlyPastedOnNewLine(view) {
|
|
|
33
33
|
// ============================================================================ //
|
|
34
34
|
// Used for all interactions with the EditorCardProvider.
|
|
35
35
|
// ============================================================================ //
|
|
36
|
-
var resolveWithProvider = exports.resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent) {
|
|
36
|
+
var resolveWithProvider = exports.resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) {
|
|
37
37
|
var isEmbedFriendlyLocation = isFreshlyPastedOnNewLine(view);
|
|
38
38
|
|
|
39
39
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
@@ -42,7 +42,7 @@ var resolveWithProvider = exports.resolveWithProvider = function resolveWithProv
|
|
|
42
42
|
// packages/editor/editor-core/src/plugins/card/pm-plugins/doc.ts @ convertHyperlinkToSmartCard
|
|
43
43
|
// Which is used when user switching from URL to smart link appearance.
|
|
44
44
|
!!request.shouldReplaceLink;
|
|
45
|
-
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options), handleRejected(view, request, editorAnalyticsApi));
|
|
45
|
+
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer), handleRejected(view, request, editorAnalyticsApi));
|
|
46
46
|
return handleResolve;
|
|
47
47
|
};
|
|
48
48
|
var updateCardType = function updateCardType(resolvedCard, options) {
|
|
@@ -63,10 +63,10 @@ var updateCardType = function updateCardType(resolvedCard, options) {
|
|
|
63
63
|
resolvedCard.type = 'inlineCard';
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options) {
|
|
66
|
+
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer) {
|
|
67
67
|
return function (resolvedCard) {
|
|
68
68
|
updateCardType(resolvedCard, options);
|
|
69
|
-
(0, _doc.replaceQueuedUrlWithCard)(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent)(view.state, view.dispatch);
|
|
69
|
+
(0, _doc.replaceQueuedUrlWithCard)(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer)(view.state, view.dispatch);
|
|
70
70
|
return resolvedCard;
|
|
71
71
|
};
|
|
72
72
|
};
|
|
@@ -28,6 +28,7 @@ export const cardPlugin = ({
|
|
|
28
28
|
var _api$base, _options$lpLinkPicker;
|
|
29
29
|
let previousCardProvider;
|
|
30
30
|
const cardPluginEvents = createEventsQueue();
|
|
31
|
+
let instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
31
32
|
api === null || api === void 0 ? void 0 : (_api$base = api.base) === null || _api$base === void 0 ? void 0 : _api$base.actions.registerMarks(({
|
|
32
33
|
tr,
|
|
33
34
|
node,
|
|
@@ -92,6 +93,7 @@ export const cardPlugin = ({
|
|
|
92
93
|
allowAlignment,
|
|
93
94
|
allowDatasource,
|
|
94
95
|
cardPluginEvents,
|
|
96
|
+
embedCardTransformers: instanceEmbedCardTransformers,
|
|
95
97
|
showUpgradeDiscoverability
|
|
96
98
|
}, api)
|
|
97
99
|
}];
|
|
@@ -146,6 +148,9 @@ export const cardPlugin = ({
|
|
|
146
148
|
},
|
|
147
149
|
hideLinkToolbar,
|
|
148
150
|
queueCardsFromChangedTr,
|
|
151
|
+
registerEmbedCardTransformer: transformers => {
|
|
152
|
+
instanceEmbedCardTransformers = transformers;
|
|
153
|
+
},
|
|
149
154
|
getStartingToolbarItems: getStartingToolbarItems(options, api),
|
|
150
155
|
getEndingToolbarItems: getEndingToolbarItems(options, api)
|
|
151
156
|
},
|
|
@@ -54,7 +54,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
54
54
|
}
|
|
55
55
|
return $pos.node($pos.depth - 1).type.name;
|
|
56
56
|
}
|
|
57
|
-
export const replaceQueuedUrlWithCard = (url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) => (editorState, dispatch) => {
|
|
57
|
+
export const replaceQueuedUrlWithCard = (url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) => (editorState, dispatch) => {
|
|
58
58
|
const state = pluginKey.getState(editorState);
|
|
59
59
|
if (!state) {
|
|
60
60
|
return false;
|
|
@@ -65,7 +65,18 @@ export const replaceQueuedUrlWithCard = (url, cardData, analyticsAction, editorA
|
|
|
65
65
|
|
|
66
66
|
// try to transform response to ADF
|
|
67
67
|
const schema = editorState.schema;
|
|
68
|
-
|
|
68
|
+
let cardAdf = null;
|
|
69
|
+
|
|
70
|
+
// If an embed card transformer is provided and the resolved card is an embedCard,
|
|
71
|
+
// attempt to transform it into an alternative node representation first.
|
|
72
|
+
if (cardData.type === 'embedCard' && embedCardNodeTransformer) {
|
|
73
|
+
var _embedCardNodeTransfo;
|
|
74
|
+
cardAdf = (_embedCardNodeTransfo = embedCardNodeTransformer(schema, cardData.attrs)) !== null && _embedCardNodeTransfo !== void 0 ? _embedCardNodeTransfo : null;
|
|
75
|
+
}
|
|
76
|
+
if (!cardAdf) {
|
|
77
|
+
var _processRawValue;
|
|
78
|
+
cardAdf = (_processRawValue = processRawValue(schema, cardData)) !== null && _processRawValue !== void 0 ? _processRawValue : null;
|
|
79
|
+
}
|
|
69
80
|
const tr = editorState.tr;
|
|
70
81
|
if (cardAdf) {
|
|
71
82
|
// Should prevent any other node than cards? [inlineCard, blockCard].includes(cardAdf.type)
|
|
@@ -350,7 +361,7 @@ export const changeSelectedCardToText = (text, editorAnalyticsApi) => (state, di
|
|
|
350
361
|
return true;
|
|
351
362
|
};
|
|
352
363
|
export const setSelectedCardAppearance = (appearance, editorAnalyticsApi) => (state, dispatch) => {
|
|
353
|
-
var _previousNode$type;
|
|
364
|
+
var _selectedNode$attrs$d, _previousNode$type;
|
|
354
365
|
const selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
355
366
|
if (!selectedNode) {
|
|
356
367
|
// When there is no selected node, we insert a new one
|
|
@@ -374,6 +385,36 @@ export const setSelectedCardAppearance = (appearance, editorAnalyticsApi) => (st
|
|
|
374
385
|
} = state.selection;
|
|
375
386
|
const nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
376
387
|
const tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
388
|
+
|
|
389
|
+
// If switching to embed appearance, attempt to use a registered transform command
|
|
390
|
+
// to create an alternative node representation (e.g. a native embed).
|
|
391
|
+
if (appearance === 'embed' && (selectedNode.attrs.url || (_selectedNode$attrs$d = selectedNode.attrs.data) !== null && _selectedNode$attrs$d !== void 0 && _selectedNode$attrs$d.url)) {
|
|
392
|
+
var _cardState$embedCardT;
|
|
393
|
+
const cardState = pluginKey.getState(state);
|
|
394
|
+
const createEmbedCardTransformCommand = cardState === null || cardState === void 0 ? void 0 : (_cardState$embedCardT = cardState.embedCardTransformers) === null || _cardState$embedCardT === void 0 ? void 0 : _cardState$embedCardT.createEmbedCardTransformCommand;
|
|
395
|
+
if (createEmbedCardTransformCommand) {
|
|
396
|
+
const transformCommand = createEmbedCardTransformCommand({
|
|
397
|
+
augmentTransaction: augmentTr => {
|
|
398
|
+
updateDatasourceStash(augmentTr, selectedNode);
|
|
399
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
400
|
+
action: ACTION.CHANGED_TYPE,
|
|
401
|
+
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
402
|
+
eventType: EVENT_TYPE.TRACK,
|
|
403
|
+
attributes: {
|
|
404
|
+
newType: appearance,
|
|
405
|
+
previousType: appearanceForNodeType(selectedNode.type)
|
|
406
|
+
}
|
|
407
|
+
})(augmentTr);
|
|
408
|
+
addLinkMetadata(state.selection, augmentTr, {
|
|
409
|
+
action: ACTION.CHANGED_TYPE
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
if (transformCommand(state, dispatch)) {
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
377
418
|
updateDatasourceStash(tr, selectedNode);
|
|
378
419
|
|
|
379
420
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
@@ -44,7 +44,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
44
44
|
onClickCallback,
|
|
45
45
|
isPageSSRed,
|
|
46
46
|
provider,
|
|
47
|
-
CompetitorPrompt
|
|
47
|
+
CompetitorPrompt,
|
|
48
|
+
embedCardTransformers
|
|
48
49
|
} = options;
|
|
49
50
|
const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
|
|
50
51
|
const inlineCardViewProducer = getInlineNodeViewProducer({
|
|
@@ -74,6 +75,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
74
75
|
showLinkingToolbar: false,
|
|
75
76
|
smartLinkEvents: undefined,
|
|
76
77
|
editorAppearance,
|
|
78
|
+
embedCardTransformers,
|
|
77
79
|
showDatasourceModal: false,
|
|
78
80
|
datasourceModalType: undefined,
|
|
79
81
|
datasourceTableRef: undefined,
|
|
@@ -209,8 +211,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
209
211
|
* other tasks as per common implementations of the JavaScript event loop in browsers.
|
|
210
212
|
*/
|
|
211
213
|
const invoke = rafSchedule(() => {
|
|
212
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _pluginInjectionApi$a4;
|
|
213
|
-
return resolveWithProvider(view, provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
|
|
214
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _pluginInjectionApi$a4, _currentState$embedCa;
|
|
215
|
+
return resolveWithProvider(view, provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 ? void 0 : (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
214
216
|
});
|
|
215
217
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
216
218
|
invoke();
|
|
@@ -30,7 +30,7 @@ const isFreshlyPastedOnNewLine = view => {
|
|
|
30
30
|
// ============================================================================ //
|
|
31
31
|
// Used for all interactions with the EditorCardProvider.
|
|
32
32
|
// ============================================================================ //
|
|
33
|
-
export const resolveWithProvider = (view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent) => {
|
|
33
|
+
export const resolveWithProvider = (view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) => {
|
|
34
34
|
const isEmbedFriendlyLocation = isFreshlyPastedOnNewLine(view);
|
|
35
35
|
|
|
36
36
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
@@ -39,7 +39,7 @@ export const resolveWithProvider = (view, provider, request, options, editorAnal
|
|
|
39
39
|
// packages/editor/editor-core/src/plugins/card/pm-plugins/doc.ts @ convertHyperlinkToSmartCard
|
|
40
40
|
// Which is used when user switching from URL to smart link appearance.
|
|
41
41
|
!!request.shouldReplaceLink;
|
|
42
|
-
const handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options), handleRejected(view, request, editorAnalyticsApi));
|
|
42
|
+
const handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer), handleRejected(view, request, editorAnalyticsApi));
|
|
43
43
|
return handleResolve;
|
|
44
44
|
};
|
|
45
45
|
const updateCardType = (resolvedCard, options) => {
|
|
@@ -60,9 +60,9 @@ const updateCardType = (resolvedCard, options) => {
|
|
|
60
60
|
resolvedCard.type = 'inlineCard';
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
const handleResolved = (view, request, editorAnalyticsApi, createAnalyticsEvent, options) => resolvedCard => {
|
|
63
|
+
const handleResolved = (view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer) => resolvedCard => {
|
|
64
64
|
updateCardType(resolvedCard, options);
|
|
65
|
-
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent)(view.state, view.dispatch);
|
|
65
|
+
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer)(view.state, view.dispatch);
|
|
66
66
|
return resolvedCard;
|
|
67
67
|
};
|
|
68
68
|
const handleRejected = (view, request, editorAnalyticsApi) => () => {
|
package/dist/esm/cardPlugin.js
CHANGED
|
@@ -33,6 +33,7 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
33
33
|
api = _ref.api;
|
|
34
34
|
var previousCardProvider;
|
|
35
35
|
var cardPluginEvents = createEventsQueue();
|
|
36
|
+
var instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
36
37
|
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref2) {
|
|
37
38
|
var tr = _ref2.tr,
|
|
38
39
|
node = _ref2.node,
|
|
@@ -89,6 +90,7 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
89
90
|
allowAlignment: allowAlignment,
|
|
90
91
|
allowDatasource: allowDatasource,
|
|
91
92
|
cardPluginEvents: cardPluginEvents,
|
|
93
|
+
embedCardTransformers: instanceEmbedCardTransformers,
|
|
92
94
|
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
93
95
|
}), api)
|
|
94
96
|
}];
|
|
@@ -162,6 +164,9 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
162
164
|
}(),
|
|
163
165
|
hideLinkToolbar: hideLinkToolbar,
|
|
164
166
|
queueCardsFromChangedTr: queueCardsFromChangedTr,
|
|
167
|
+
registerEmbedCardTransformer: function registerEmbedCardTransformer(transformers) {
|
|
168
|
+
instanceEmbedCardTransformers = transformers;
|
|
169
|
+
},
|
|
165
170
|
getStartingToolbarItems: getStartingToolbarItems(options, api),
|
|
166
171
|
getEndingToolbarItems: getEndingToolbarItems(options, api)
|
|
167
172
|
},
|
|
@@ -54,7 +54,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
54
54
|
}
|
|
55
55
|
return $pos.node($pos.depth - 1).type.name;
|
|
56
56
|
}
|
|
57
|
-
export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) {
|
|
57
|
+
export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) {
|
|
58
58
|
return function (editorState, dispatch) {
|
|
59
59
|
var state = pluginKey.getState(editorState);
|
|
60
60
|
if (!state) {
|
|
@@ -68,7 +68,18 @@ export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, car
|
|
|
68
68
|
|
|
69
69
|
// try to transform response to ADF
|
|
70
70
|
var schema = editorState.schema;
|
|
71
|
-
var cardAdf =
|
|
71
|
+
var cardAdf = null;
|
|
72
|
+
|
|
73
|
+
// If an embed card transformer is provided and the resolved card is an embedCard,
|
|
74
|
+
// attempt to transform it into an alternative node representation first.
|
|
75
|
+
if (cardData.type === 'embedCard' && embedCardNodeTransformer) {
|
|
76
|
+
var _embedCardNodeTransfo;
|
|
77
|
+
cardAdf = (_embedCardNodeTransfo = embedCardNodeTransformer(schema, cardData.attrs)) !== null && _embedCardNodeTransfo !== void 0 ? _embedCardNodeTransfo : null;
|
|
78
|
+
}
|
|
79
|
+
if (!cardAdf) {
|
|
80
|
+
var _processRawValue;
|
|
81
|
+
cardAdf = (_processRawValue = processRawValue(schema, cardData)) !== null && _processRawValue !== void 0 ? _processRawValue : null;
|
|
82
|
+
}
|
|
72
83
|
var tr = editorState.tr;
|
|
73
84
|
if (cardAdf) {
|
|
74
85
|
// Should prevent any other node than cards? [inlineCard, blockCard].includes(cardAdf.type)
|
|
@@ -374,7 +385,7 @@ export var changeSelectedCardToText = function changeSelectedCardToText(text, ed
|
|
|
374
385
|
};
|
|
375
386
|
export var setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
|
|
376
387
|
return function (state, dispatch) {
|
|
377
|
-
var _previousNode$type;
|
|
388
|
+
var _selectedNode$attrs$d, _previousNode$type;
|
|
378
389
|
var selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
379
390
|
if (!selectedNode) {
|
|
380
391
|
// When there is no selected node, we insert a new one
|
|
@@ -397,6 +408,36 @@ export var setSelectedCardAppearance = function setSelectedCardAppearance(appear
|
|
|
397
408
|
to = _state$selection.to;
|
|
398
409
|
var nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
399
410
|
var tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
411
|
+
|
|
412
|
+
// If switching to embed appearance, attempt to use a registered transform command
|
|
413
|
+
// to create an alternative node representation (e.g. a native embed).
|
|
414
|
+
if (appearance === 'embed' && (selectedNode.attrs.url || (_selectedNode$attrs$d = selectedNode.attrs.data) !== null && _selectedNode$attrs$d !== void 0 && _selectedNode$attrs$d.url)) {
|
|
415
|
+
var _cardState$embedCardT;
|
|
416
|
+
var cardState = pluginKey.getState(state);
|
|
417
|
+
var createEmbedCardTransformCommand = cardState === null || cardState === void 0 || (_cardState$embedCardT = cardState.embedCardTransformers) === null || _cardState$embedCardT === void 0 ? void 0 : _cardState$embedCardT.createEmbedCardTransformCommand;
|
|
418
|
+
if (createEmbedCardTransformCommand) {
|
|
419
|
+
var transformCommand = createEmbedCardTransformCommand({
|
|
420
|
+
augmentTransaction: function augmentTransaction(augmentTr) {
|
|
421
|
+
updateDatasourceStash(augmentTr, selectedNode);
|
|
422
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
423
|
+
action: ACTION.CHANGED_TYPE,
|
|
424
|
+
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
425
|
+
eventType: EVENT_TYPE.TRACK,
|
|
426
|
+
attributes: {
|
|
427
|
+
newType: appearance,
|
|
428
|
+
previousType: appearanceForNodeType(selectedNode.type)
|
|
429
|
+
}
|
|
430
|
+
})(augmentTr);
|
|
431
|
+
addLinkMetadata(state.selection, augmentTr, {
|
|
432
|
+
action: ACTION.CHANGED_TYPE
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
if (transformCommand(state, dispatch)) {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
400
441
|
updateDatasourceStash(tr, selectedNode);
|
|
401
442
|
|
|
402
443
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
@@ -48,7 +48,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
48
48
|
onClickCallback = options.onClickCallback,
|
|
49
49
|
isPageSSRed = options.isPageSSRed,
|
|
50
50
|
provider = options.provider,
|
|
51
|
-
CompetitorPrompt = options.CompetitorPrompt
|
|
51
|
+
CompetitorPrompt = options.CompetitorPrompt,
|
|
52
|
+
embedCardTransformers = options.embedCardTransformers;
|
|
52
53
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability;
|
|
53
54
|
var inlineCardViewProducer = getInlineNodeViewProducer({
|
|
54
55
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
@@ -77,6 +78,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
77
78
|
showLinkingToolbar: false,
|
|
78
79
|
smartLinkEvents: undefined,
|
|
79
80
|
editorAppearance: editorAppearance,
|
|
81
|
+
embedCardTransformers: embedCardTransformers,
|
|
80
82
|
showDatasourceModal: false,
|
|
81
83
|
datasourceModalType: undefined,
|
|
82
84
|
datasourceTableRef: undefined,
|
|
@@ -203,8 +205,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
203
205
|
* other tasks as per common implementations of the JavaScript event loop in browsers.
|
|
204
206
|
*/
|
|
205
207
|
var invoke = rafSchedule(function () {
|
|
206
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3;
|
|
207
|
-
return resolveWithProvider(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
|
|
208
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _currentState$embedCa;
|
|
209
|
+
return resolveWithProvider(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 || (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
208
210
|
});
|
|
209
211
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
210
212
|
invoke();
|
|
@@ -27,7 +27,7 @@ var isFreshlyPastedOnNewLine = function isFreshlyPastedOnNewLine(view) {
|
|
|
27
27
|
// ============================================================================ //
|
|
28
28
|
// Used for all interactions with the EditorCardProvider.
|
|
29
29
|
// ============================================================================ //
|
|
30
|
-
export var resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent) {
|
|
30
|
+
export var resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer) {
|
|
31
31
|
var isEmbedFriendlyLocation = isFreshlyPastedOnNewLine(view);
|
|
32
32
|
|
|
33
33
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
@@ -36,7 +36,7 @@ export var resolveWithProvider = function resolveWithProvider(view, provider, re
|
|
|
36
36
|
// packages/editor/editor-core/src/plugins/card/pm-plugins/doc.ts @ convertHyperlinkToSmartCard
|
|
37
37
|
// Which is used when user switching from URL to smart link appearance.
|
|
38
38
|
!!request.shouldReplaceLink;
|
|
39
|
-
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options), handleRejected(view, request, editorAnalyticsApi));
|
|
39
|
+
var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance, isEmbedFriendlyLocation).then(handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer), handleRejected(view, request, editorAnalyticsApi));
|
|
40
40
|
return handleResolve;
|
|
41
41
|
};
|
|
42
42
|
var updateCardType = function updateCardType(resolvedCard, options) {
|
|
@@ -57,10 +57,10 @@ var updateCardType = function updateCardType(resolvedCard, options) {
|
|
|
57
57
|
resolvedCard.type = 'inlineCard';
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options) {
|
|
60
|
+
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options, embedCardNodeTransformer) {
|
|
61
61
|
return function (resolvedCard) {
|
|
62
62
|
updateCardType(resolvedCard, options);
|
|
63
|
-
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent)(view.state, view.dispatch);
|
|
63
|
+
replaceQueuedUrlWithCard(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent, embedCardNodeTransformer)(view.state, view.dispatch);
|
|
64
64
|
return resolvedCard;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CreateUIAnalyticsEvent, UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
4
|
+
import type { CardReplacementInputMethod, EmbedCardNodeTransformer } from '@atlaskit/editor-common/card';
|
|
5
5
|
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Attrs, Node, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -9,7 +9,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
|
|
|
9
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import type { CardAdf, DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
11
11
|
import type { Request } from '../types';
|
|
12
|
-
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent) => Command;
|
|
12
|
+
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent, embedCardNodeTransformer?: EmbedCardNodeTransformer) => Command;
|
|
13
13
|
export declare const handleFallbackWithAnalytics: (request: Request, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
14
14
|
export declare const queueCardsFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction?: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Transaction;
|
|
15
15
|
export declare const queueCardFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, previousAppearance?: CardAppearance | "url") => Transaction;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { CardOptions, EmbedCardNodeTransformer } from '@atlaskit/editor-common/card';
|
|
4
4
|
import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { BlockCardAdf, DatasourceAdf, EmbedCardAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
7
7
|
import type { Request } from '../../types';
|
|
8
|
-
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | DatasourceAdf<Record<string, unknown>> | InlineCardAdf | BlockCardAdf | EmbedCardAdf>;
|
|
8
|
+
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined, embedCardNodeTransformer?: EmbedCardNodeTransformer) => Promise<void | DatasourceAdf<Record<string, unknown>> | InlineCardAdf | BlockCardAdf | EmbedCardAdf>;
|
|
9
9
|
export declare const handleProvider: (_: "cardProvider", provider: Promise<CardProvider> | undefined, view: EditorView) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RichMediaAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
3
|
import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
4
|
+
import type { CardOptions, CardReplacementInputMethod, EmbedCardTransformers, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
5
5
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -88,6 +88,7 @@ export type CardPluginState = {
|
|
|
88
88
|
datasourceStash: DatasourceStash;
|
|
89
89
|
datasourceTableRef?: HTMLElement;
|
|
90
90
|
editorAppearance?: EditorAppearance;
|
|
91
|
+
embedCardTransformers?: EmbedCardTransformers;
|
|
91
92
|
inlineCardAwarenessCandidatePosition?: number;
|
|
92
93
|
layout?: DatasourceTableLayout;
|
|
93
94
|
overlayCandidatePosition?: number;
|
|
@@ -107,6 +108,7 @@ export type CardPluginOptions = CardOptions & {
|
|
|
107
108
|
}>;
|
|
108
109
|
disableFloatingToolbar?: boolean;
|
|
109
110
|
editorAppearance?: EditorAppearance;
|
|
111
|
+
embedCardTransformers?: EmbedCardTransformers;
|
|
110
112
|
fullWidthMode?: boolean;
|
|
111
113
|
isPageSSRed?: boolean;
|
|
112
114
|
linkPicker?: LinkPickerOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CreateUIAnalyticsEvent, UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
4
|
+
import type { CardReplacementInputMethod, EmbedCardNodeTransformer } from '@atlaskit/editor-common/card';
|
|
5
5
|
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Attrs, Node, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -9,7 +9,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
|
|
|
9
9
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import type { CardAdf, DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
11
11
|
import type { Request } from '../types';
|
|
12
|
-
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent) => Command;
|
|
12
|
+
export declare const replaceQueuedUrlWithCard: (url: string, cardData: CardAdf | DatasourceAdf, analyticsAction?: ACTION, editorAnalyticsApi?: EditorAnalyticsAPI, createAnalyticsEvent?: CreateUIAnalyticsEvent, embedCardNodeTransformer?: EmbedCardNodeTransformer) => Command;
|
|
13
13
|
export declare const handleFallbackWithAnalytics: (request: Request, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
14
14
|
export declare const queueCardsFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction?: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Transaction;
|
|
15
15
|
export declare const queueCardFromChangedTr: (state: EditorState, tr: Transaction, source: CardReplacementInputMethod, analyticsAction: ACTION, normalizeLinkText?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, previousAppearance?: CardAppearance | "url") => Transaction;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
+
import type { CardOptions, EmbedCardNodeTransformer } from '@atlaskit/editor-common/card';
|
|
4
4
|
import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { BlockCardAdf, DatasourceAdf, EmbedCardAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
7
7
|
import type { Request } from '../../types';
|
|
8
|
-
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | DatasourceAdf<Record<string, unknown>> | InlineCardAdf | BlockCardAdf | EmbedCardAdf>;
|
|
8
|
+
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined, embedCardNodeTransformer?: EmbedCardNodeTransformer) => Promise<void | DatasourceAdf<Record<string, unknown>> | InlineCardAdf | BlockCardAdf | EmbedCardAdf>;
|
|
9
9
|
export declare const handleProvider: (_: "cardProvider", provider: Promise<CardProvider> | undefined, view: EditorView) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RichMediaAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
3
|
import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
4
|
+
import type { CardOptions, CardReplacementInputMethod, EmbedCardTransformers, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
5
5
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -88,6 +88,7 @@ export type CardPluginState = {
|
|
|
88
88
|
datasourceStash: DatasourceStash;
|
|
89
89
|
datasourceTableRef?: HTMLElement;
|
|
90
90
|
editorAppearance?: EditorAppearance;
|
|
91
|
+
embedCardTransformers?: EmbedCardTransformers;
|
|
91
92
|
inlineCardAwarenessCandidatePosition?: number;
|
|
92
93
|
layout?: DatasourceTableLayout;
|
|
93
94
|
overlayCandidatePosition?: number;
|
|
@@ -107,6 +108,7 @@ export type CardPluginOptions = CardOptions & {
|
|
|
107
108
|
}>;
|
|
108
109
|
disableFloatingToolbar?: boolean;
|
|
109
110
|
editorAppearance?: EditorAppearance;
|
|
111
|
+
embedCardTransformers?: EmbedCardTransformers;
|
|
110
112
|
fullWidthMode?: boolean;
|
|
111
113
|
isPageSSRed?: boolean;
|
|
112
114
|
linkPicker?: LinkPickerOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.5",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^52.
|
|
32
|
+
"@atlaskit/adf-schema": "^52.3.0",
|
|
33
33
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
34
34
|
"@atlaskit/custom-steps": "^0.16.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
48
48
|
"@atlaskit/editor-smart-link-draggable": "^0.1.0",
|
|
49
49
|
"@atlaskit/frontend-utilities": "^3.2.0",
|
|
50
|
-
"@atlaskit/icon": "^32.
|
|
50
|
+
"@atlaskit/icon": "^32.1.0",
|
|
51
51
|
"@atlaskit/link": "^3.3.0",
|
|
52
52
|
"@atlaskit/link-analytics": "^11.0.0",
|
|
53
53
|
"@atlaskit/link-client-extension": "^6.0.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
63
63
|
"@atlaskit/smart-card": "^43.26.0",
|
|
64
64
|
"@atlaskit/theme": "^22.0.0",
|
|
65
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
65
|
+
"@atlaskit/tmp-editor-statsig": "^39.0.0",
|
|
66
66
|
"@atlaskit/tokens": "^11.1.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|
|
68
68
|
"@emotion/react": "^11.7.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"uuid": "^3.1.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atlaskit/editor-common": "^112.
|
|
75
|
+
"@atlaskit/editor-common": "^112.3.0",
|
|
76
76
|
"@atlaskit/link-provider": "^4.2.0",
|
|
77
77
|
"react": "^18.2.0",
|
|
78
78
|
"react-intl-next": "npm:react-intl@^5.18.1"
|