@atlaskit/editor-plugin-card 35.0.2 → 35.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/cjs/actions/cardRegistry.js +65 -0
- package/dist/cjs/actions/useCardRegistry.js +19 -0
- package/dist/cjs/cardPlugin.js +6 -0
- package/dist/cjs/nodeviews/blockCard.js +45 -21
- package/dist/cjs/nodeviews/embedCard.js +50 -26
- package/dist/cjs/nodeviews/inlineCardBase.js +41 -20
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +14 -10
- package/dist/cjs/pm-plugins/doc.js +1 -1
- package/dist/cjs/pm-plugins/main.js +11 -9
- package/dist/cjs/pm-plugins/utils.js +19 -7
- package/dist/cjs/ui/EditLinkToolbar.js +5 -3
- package/dist/cjs/ui/PasteDisplayAsMenu.js +16 -4
- package/dist/cjs/ui/toolbar.js +37 -21
- package/dist/es2019/actions/cardRegistry.js +58 -0
- package/dist/es2019/actions/useCardRegistry.js +9 -0
- package/dist/es2019/cardPlugin.js +6 -0
- package/dist/es2019/nodeviews/blockCard.js +42 -16
- package/dist/es2019/nodeviews/embedCard.js +42 -16
- package/dist/es2019/nodeviews/inlineCardBase.js +43 -22
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -8
- package/dist/es2019/pm-plugins/doc.js +1 -1
- package/dist/es2019/pm-plugins/main.js +11 -9
- package/dist/es2019/pm-plugins/utils.js +15 -5
- package/dist/es2019/ui/EditLinkToolbar.js +5 -3
- package/dist/es2019/ui/PasteDisplayAsMenu.js +12 -4
- package/dist/es2019/ui/toolbar.js +35 -19
- package/dist/esm/actions/cardRegistry.js +58 -0
- package/dist/esm/actions/useCardRegistry.js +13 -0
- package/dist/esm/cardPlugin.js +6 -0
- package/dist/esm/nodeviews/blockCard.js +45 -21
- package/dist/esm/nodeviews/embedCard.js +50 -26
- package/dist/esm/nodeviews/inlineCardBase.js +41 -20
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +14 -10
- package/dist/esm/pm-plugins/doc.js +1 -1
- package/dist/esm/pm-plugins/main.js +11 -9
- package/dist/esm/pm-plugins/utils.js +19 -7
- package/dist/esm/ui/EditLinkToolbar.js +5 -3
- package/dist/esm/ui/PasteDisplayAsMenu.js +16 -4
- package/dist/esm/ui/toolbar.js +37 -21
- package/dist/types/actions/cardRegistry.d.ts +37 -0
- package/dist/types/actions/useCardRegistry.d.ts +3 -0
- package/dist/types/nodeviews/blockCard.d.ts +2 -2
- package/dist/types/nodeviews/embedCard.d.ts +2 -2
- package/dist/types/nodeviews/genericCard.d.ts +2 -4
- package/dist/types/pm-plugins/utils.d.ts +2 -1
- package/package.json +9 -6
|
@@ -5,6 +5,7 @@ import { getResolvedAttributes } from '@atlaskit/link-analytics/get-resolved-att
|
|
|
5
5
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/assets-modal';
|
|
6
6
|
import { CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource/confluence-search-modal';
|
|
7
7
|
import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource/jira-issues-modal';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
9
|
import { pluginKey } from './plugin-key';
|
|
9
10
|
export var appearanceForNodeType = function appearanceForNodeType(spec) {
|
|
10
11
|
if (spec.name === 'inlineCard') {
|
|
@@ -43,14 +44,25 @@ export var mergeCardInfo = function mergeCardInfo(titleUrlPair, info) {
|
|
|
43
44
|
export var displayInfoForCard = function displayInfoForCard(node, info) {
|
|
44
45
|
return mergeCardInfo(titleUrlPairFromNode(node), info);
|
|
45
46
|
};
|
|
46
|
-
export var findCardInfo = function findCardInfo(state) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
export var findCardInfo = function findCardInfo(state, cardActions) {
|
|
48
|
+
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
49
|
+
var _cardActions$getCardR, _cardActions$getCardR2;
|
|
50
|
+
var registrations = (_cardActions$getCardR = cardActions === null || cardActions === void 0 || (_cardActions$getCardR2 = cardActions.getCardRegistrations) === null || _cardActions$getCardR2 === void 0 ? void 0 : _cardActions$getCardR2.call(cardActions)) !== null && _cardActions$getCardR !== void 0 ? _cardActions$getCardR : {};
|
|
51
|
+
var card = Object.values(registrations).find(function (registration) {
|
|
52
|
+
return registration.getPos() === state.selection.from;
|
|
53
|
+
});
|
|
54
|
+
return card ? {
|
|
55
|
+
id: card.id,
|
|
56
|
+
title: card.title,
|
|
57
|
+
url: card.url,
|
|
58
|
+
pos: state.selection.from
|
|
59
|
+
} : undefined;
|
|
60
|
+
} else {
|
|
61
|
+
var pluginState = pluginKey.getState(state);
|
|
62
|
+
return pluginState === null || pluginState === void 0 ? void 0 : pluginState.cards.find(function (cardInfo) {
|
|
63
|
+
return cardInfo.pos === state.selection.from;
|
|
64
|
+
});
|
|
50
65
|
}
|
|
51
|
-
return pluginState.cards.find(function (cardInfo) {
|
|
52
|
-
return cardInfo.pos === state.selection.from;
|
|
53
|
-
});
|
|
54
66
|
};
|
|
55
67
|
var isAppearanceSupportedInParent = function isAppearanceSupportedInParent(currentNodePosition, editorState, fragment, currentAppearance) {
|
|
56
68
|
var resolvedPosition = editorState.doc.resolve(currentNodePosition);
|
|
@@ -13,6 +13,7 @@ import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDT
|
|
|
13
13
|
import { HyperlinkAddToolbar as HyperlinkToolbar } from '@atlaskit/editor-common/link/HyperlinkAddToolbar';
|
|
14
14
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages/link-toolbar';
|
|
15
15
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { hideLinkToolbar as _hideLinkToolbar, showLinkToolbar } from '../pm-plugins/actions';
|
|
17
18
|
import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
|
|
18
19
|
import { displayInfoForCard, findCardInfo } from '../pm-plugins/utils';
|
|
@@ -161,7 +162,7 @@ export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref2) {
|
|
|
161
162
|
if (!view || !providerFactory) {
|
|
162
163
|
return null;
|
|
163
164
|
}
|
|
164
|
-
var displayInfo = displayInfoForCard(node, findCardInfo(view.state));
|
|
165
|
+
var displayInfo = displayInfoForCard(node, findCardInfo(view.state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions));
|
|
165
166
|
return /*#__PURE__*/React.createElement(EditLinkToolbar, {
|
|
166
167
|
key: idx,
|
|
167
168
|
view: view,
|
|
@@ -175,8 +176,9 @@ export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref2) {
|
|
|
175
176
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
176
177
|
,
|
|
177
178
|
onSubmit: function onSubmit(newHref, newText, inputMethod, analytic) {
|
|
178
|
-
var
|
|
179
|
-
var
|
|
179
|
+
var currentDisplayInfo = isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? displayInfoForCard(node, findCardInfo(view.state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions)) : displayInfo;
|
|
180
|
+
var urlChanged = newHref !== currentDisplayInfo.url;
|
|
181
|
+
var titleChanged = newText !== currentDisplayInfo.title;
|
|
180
182
|
|
|
181
183
|
// If the title is changed in a smartlink, convert to standard blue hyperlink
|
|
182
184
|
// (even if the url was also changed) - we don't want to lose the custom title.
|
|
@@ -22,10 +22,13 @@ import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
|
22
22
|
import SmartLinkEmbedIcon from '@atlaskit/icon/core/smart-link-embed';
|
|
23
23
|
import SmartLinkInlineIcon from '@atlaskit/icon/core/smart-link-inline';
|
|
24
24
|
import { useSmartCardContext } from '@atlaskit/link-provider/use-smart-card-context';
|
|
25
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
26
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react/conditional-hooks-factory/conditional-hooks-factory';
|
|
25
27
|
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
26
28
|
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
27
29
|
import { Pressable } from '@atlaskit/primitives/compiled/pressable';
|
|
28
30
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
31
|
+
import { useCardRegistry } from '../actions/useCardRegistry';
|
|
29
32
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
30
33
|
import { getSingleSmartLinkUrlFromSlice } from './currentPastedSmartLink';
|
|
31
34
|
import { changeNativeEmbedAppearance, getNativeEmbedUrl, isNativeEmbedAppearanceSupported } from './nativeEmbedNode';
|
|
@@ -195,6 +198,17 @@ export var normalizeSelectionToLinkRangeForUrlAppearance = function normalizeSel
|
|
|
195
198
|
var linkRangeSelectionTr = editorView.state.tr.setSelection(TextSelection.create(editorView.state.doc, firstLinkRange.from, firstLinkRange.to));
|
|
196
199
|
editorView.dispatch(linkRangeSelectionTr);
|
|
197
200
|
};
|
|
201
|
+
// Remove with platform_editor_reduce_forced_layout_2 cleanup; call useCardRegistry(api?.card?.actions) directly.
|
|
202
|
+
var useCardStateWithRegistryExperiment = conditionalHooksFactory(function () {
|
|
203
|
+
return isExperimentEnabled('platform_editor_reduce_forced_layout_2');
|
|
204
|
+
}, function useRegisteredCardState(api) {
|
|
205
|
+
var _api$card;
|
|
206
|
+
return useCardRegistry(api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 ? void 0 : _api$card.actions);
|
|
207
|
+
}, function useLegacyCardState(api) {
|
|
208
|
+
return useSharedPluginStateWithSelector(api, ['card'], function (states) {
|
|
209
|
+
return states.cardState;
|
|
210
|
+
});
|
|
211
|
+
});
|
|
198
212
|
var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView(_ref8) {
|
|
199
213
|
var _smartCardContext$val, _cardAtPasteRange$app, _smartCardContext$val2;
|
|
200
214
|
var api = _ref8.api,
|
|
@@ -215,10 +229,8 @@ var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView
|
|
|
215
229
|
pasteStartPos: pluginState.pasteStartPos
|
|
216
230
|
} : undefined;
|
|
217
231
|
});
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
return states.cardState;
|
|
221
|
-
});
|
|
232
|
+
// platform_editor_reduce_forced_layout_2 selects the registry when enabled and shared state otherwise.
|
|
233
|
+
useCardStateWithRegistryExperiment(api);
|
|
222
234
|
var pastedLinkUrlFromSlice = getSingleSmartLinkUrlFromSlice(getCurrentPastedSlice(api));
|
|
223
235
|
var pastedLinkUrlFromCard = editorView && pasteRange ? getCardUrlAtPasteRange({
|
|
224
236
|
editorView: editorView,
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -29,6 +29,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
|
|
|
29
29
|
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
30
30
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
31
31
|
import CogIcon from '@atlaskit/icon/core/settings';
|
|
32
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
32
33
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
33
34
|
import { changeSelectedCardToText } from '../pm-plugins/doc';
|
|
34
35
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -122,6 +123,7 @@ export var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
|
|
|
122
123
|
};
|
|
123
124
|
export var floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker, linkPickerOptions, pluginInjectionApi, disableFloatingToolbar) {
|
|
124
125
|
return function (state, intl, providerFactory) {
|
|
126
|
+
var _pluginInjectionApi$c;
|
|
125
127
|
if (disableFloatingToolbar) {
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
@@ -150,6 +152,10 @@ export var floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker,
|
|
|
150
152
|
var isLinkPickerEnabled = !!lpLinkPicker;
|
|
151
153
|
return _objectSpread(_objectSpread({
|
|
152
154
|
title: intl.formatMessage(messages.card),
|
|
155
|
+
externalStore: isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions) && {
|
|
156
|
+
getSnapshot: pluginInjectionApi.card.actions.getCardRegistrations,
|
|
157
|
+
subscribe: pluginInjectionApi.card.actions.subscribeToCardRegistry
|
|
158
|
+
} : undefined,
|
|
153
159
|
className: className,
|
|
154
160
|
nodeType: nodeType,
|
|
155
161
|
preventPopupOverflow: isLinkPickerEnabled
|
|
@@ -181,17 +187,27 @@ export var floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker,
|
|
|
181
187
|
}, editLinkToolbarConfig(Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.showLinkingToolbar), isLinkPickerEnabled, linkPickerOptions));
|
|
182
188
|
};
|
|
183
189
|
};
|
|
184
|
-
var unlinkCard = function unlinkCard(node, state, editorAnalyticsApi) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
var unlinkCard = function unlinkCard(node, state, editorAnalyticsApi, pluginInjectionApi) {
|
|
191
|
+
if (isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
192
|
+
return function (currentState, dispatch, view) {
|
|
193
|
+
var displayInfo = displayInfoForCard(node, findCardInfo(currentState, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions));
|
|
194
|
+
var text = displayInfo.title || displayInfo.url;
|
|
195
|
+
return text ? commandWithMetadata(changeSelectedCardToText(text, editorAnalyticsApi), {
|
|
196
|
+
action: ACTION.UNLINK
|
|
197
|
+
})(currentState, dispatch, view) : false;
|
|
198
|
+
};
|
|
199
|
+
} else {
|
|
200
|
+
var displayInfo = displayInfoForCard(node, findCardInfo(state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions));
|
|
201
|
+
var text = displayInfo.title || displayInfo.url;
|
|
202
|
+
if (text) {
|
|
203
|
+
return commandWithMetadata(changeSelectedCardToText(text, editorAnalyticsApi), {
|
|
204
|
+
action: ACTION.UNLINK
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return function () {
|
|
208
|
+
return false;
|
|
209
|
+
};
|
|
191
210
|
}
|
|
192
|
-
return function () {
|
|
193
|
-
return false;
|
|
194
|
-
};
|
|
195
211
|
};
|
|
196
212
|
var buildAlignmentOptions = function buildAlignmentOptions(state, intl, widthPluginDependencyApi, analyticsApi, cardOptions, areAnyNewToolbarFlagsEnabled) {
|
|
197
213
|
if (areAnyNewToolbarFlagsEnabled) {
|
|
@@ -232,7 +248,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
232
248
|
if (url && !isSafeUrl(url)) {
|
|
233
249
|
return [];
|
|
234
250
|
} else {
|
|
235
|
-
var _displayInfoForCard = displayInfoForCard(node, findCardInfo(state)),
|
|
251
|
+
var _displayInfoForCard = displayInfoForCard(node, findCardInfo(state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions)),
|
|
236
252
|
title = _displayInfoForCard.title;
|
|
237
253
|
metadata = {
|
|
238
254
|
url: url,
|
|
@@ -282,7 +298,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
282
298
|
} else if (shouldRenderDatasourceToolbar) {
|
|
283
299
|
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
|
|
284
300
|
} else {
|
|
285
|
-
var _pluginInjectionApi$
|
|
301
|
+
var _pluginInjectionApi$c2, _pluginState$resolved;
|
|
286
302
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
287
303
|
var editItems = cardOptions.allowDatasource ? [{
|
|
288
304
|
type: 'custom',
|
|
@@ -320,7 +336,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
320
336
|
title: intl.formatMessage(annotationMessages.createComment),
|
|
321
337
|
showTitle: editorExperiment('platform_editor_controls', 'control') ? undefined : true,
|
|
322
338
|
onClick: onCommentButtonClick,
|
|
323
|
-
disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
339
|
+
disabled: isOfflineMode(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode)
|
|
324
340
|
}, {
|
|
325
341
|
type: 'separator'
|
|
326
342
|
}] : [];
|
|
@@ -390,7 +406,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
390
406
|
};
|
|
391
407
|
var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [openLinkToolbarItem, {
|
|
392
408
|
type: 'separator'
|
|
393
|
-
}], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
|
|
409
|
+
}], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled, pluginInjectionApi)), [{
|
|
394
410
|
type: 'copy-button',
|
|
395
411
|
items: [{
|
|
396
412
|
state: state,
|
|
@@ -414,7 +430,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
414
430
|
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
|
|
415
431
|
title: intl.formatMessage(commonMessages.remove),
|
|
416
432
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
417
|
-
}]) : [].concat(editButtonItems, _toConsumableArray([].concat(_toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
|
|
433
|
+
}]) : [].concat(editButtonItems, _toConsumableArray([].concat(_toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled, pluginInjectionApi)), [{
|
|
418
434
|
type: 'separator',
|
|
419
435
|
fullHeight: true
|
|
420
436
|
}])), openPreviewPanelItems, [openLinkToolbarItem], _toConsumableArray(commentItems.length > 1 ? [{
|
|
@@ -509,8 +525,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
509
525
|
options: [_objectSpread({
|
|
510
526
|
title: intl.formatMessage(commonMessages.copyToClipboard),
|
|
511
527
|
onClick: function onClick() {
|
|
512
|
-
var _pluginInjectionApi$
|
|
513
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
528
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$f;
|
|
529
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.core) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
|
|
514
530
|
return true;
|
|
515
531
|
},
|
|
516
532
|
icon: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
@@ -530,7 +546,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
530
546
|
}
|
|
531
547
|
};
|
|
532
548
|
};
|
|
533
|
-
var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, areAnyNewToolbarFlagsEnabled) {
|
|
549
|
+
var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, areAnyNewToolbarFlagsEnabled, pluginInjectionApi) {
|
|
534
550
|
return node.type === inlineCard ? [{
|
|
535
551
|
id: 'editor.link.unlink',
|
|
536
552
|
focusEditoronEnter: true,
|
|
@@ -538,7 +554,7 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
|
|
|
538
554
|
title: intl.formatMessage(linkToolbarMessages.unlink),
|
|
539
555
|
icon: LinkBrokenIcon,
|
|
540
556
|
iconFallback: LinkBrokenIcon,
|
|
541
|
-
onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi))
|
|
557
|
+
onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi, pluginInjectionApi))
|
|
542
558
|
}].concat(_toConsumableArray(areAnyNewToolbarFlagsEnabled ? [] : [{
|
|
543
559
|
type: 'separator'
|
|
544
560
|
}])) : [];
|
|
@@ -738,8 +754,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
738
754
|
options: [{
|
|
739
755
|
title: intl.formatMessage(commonMessages.copyToClipboard),
|
|
740
756
|
onClick: function onClick() {
|
|
741
|
-
var _pluginInjectionApi$
|
|
742
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
757
|
+
var _pluginInjectionApi$c4, _pluginInjectionApi$f2;
|
|
758
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 || _pluginInjectionApi$c4.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
|
|
743
759
|
return true;
|
|
744
760
|
},
|
|
745
761
|
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CardRegistration, CardRegistrations } from '@atlaskit/editor-common/card/types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a registry of resolved cards, for use with editor actions.
|
|
4
|
+
* Registration changes (insertion, deletion, and id/title/url updates) notify subscribers; live position changes do not.
|
|
5
|
+
*
|
|
6
|
+
* @returns A registry object with the following methods:
|
|
7
|
+
* - `getCardRegistrations`: Returns the current registrations, keyed by card ID.
|
|
8
|
+
* - `registerCard`: Adds or updates a card.
|
|
9
|
+
* - `removeCard`: Removes a card by ID.
|
|
10
|
+
* - `subscribe`: Registers a change listener and returns an unsubscribe function.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createCardRegistry: () => {
|
|
13
|
+
/**
|
|
14
|
+
* Reads the current registrations without copying them.
|
|
15
|
+
* @returns An immutable object keyed by card ID. Its identity changes only when
|
|
16
|
+
* registrations change. Each entry's `getPos()` reads its live position, or
|
|
17
|
+
* undefined after node removal.
|
|
18
|
+
*/
|
|
19
|
+
getCardRegistrations: () => CardRegistrations;
|
|
20
|
+
/**
|
|
21
|
+
* Adds or updates a card by ID and notifies subscribers when its registration changes.
|
|
22
|
+
* Ignores cards whose position is undefined.
|
|
23
|
+
* @param info - The card ID, metadata, and live position getter.
|
|
24
|
+
*/
|
|
25
|
+
registerCard: (info: CardRegistration) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a card and notifies subscribers. Does nothing for an unknown ID.
|
|
28
|
+
* @param id - The registered card ID.
|
|
29
|
+
*/
|
|
30
|
+
removeCard: (id: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a listener for registration changes, not position changes.
|
|
33
|
+
* @param listener - Called after the registration object is replaced.
|
|
34
|
+
* @returns A cleanup function to unsubscribe the listener.
|
|
35
|
+
*/
|
|
36
|
+
subscribe: (listener: () => void) => () => void;
|
|
37
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CardPluginActions, CardRegistrations } from '@atlaskit/editor-common/card/types';
|
|
2
|
+
/** Subscribe to resolved card metadata without observing every editor transaction. */
|
|
3
|
+
export declare const useCardRegistry: (actions: Pick<CardPluginActions, 'getCardRegistrations' | 'subscribeToCardRegistry'> | undefined) => CardRegistrations | undefined;
|
|
@@ -9,12 +9,12 @@ import type { CardContext } from '@atlaskit/link-provider/types';
|
|
|
9
9
|
import { Datasource } from '../nodeviews/datasource';
|
|
10
10
|
import type { SmartCardProps } from './genericCard';
|
|
11
11
|
export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
|
|
12
|
-
id
|
|
12
|
+
id: string;
|
|
13
13
|
}, unknown> {
|
|
14
14
|
private scrollContainer?;
|
|
15
15
|
private pendingRegisterCard?;
|
|
16
16
|
constructor(props: SmartCardProps & {
|
|
17
|
-
id
|
|
17
|
+
id: string;
|
|
18
18
|
});
|
|
19
19
|
onResolve: (data: {
|
|
20
20
|
title?: string;
|
|
@@ -28,12 +28,12 @@ export type EmbedCardState = {
|
|
|
28
28
|
liveHeight?: number;
|
|
29
29
|
};
|
|
30
30
|
export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
|
|
31
|
-
id
|
|
31
|
+
id: string;
|
|
32
32
|
}, EmbedCardState> {
|
|
33
33
|
private scrollContainer?;
|
|
34
34
|
private embedIframeRef;
|
|
35
35
|
constructor(props: SmartCardProps & {
|
|
36
|
-
id
|
|
36
|
+
id: string;
|
|
37
37
|
});
|
|
38
38
|
state: EmbedCardState;
|
|
39
39
|
private getPosSafely;
|
|
@@ -52,7 +52,7 @@ export interface SmartCardProps extends CardProps {
|
|
|
52
52
|
isHovered?: boolean;
|
|
53
53
|
isPageSSRed?: boolean;
|
|
54
54
|
onClick?: EventHandler<MouseEvent | KeyboardEvent> | undefined;
|
|
55
|
-
onResolve?: (tr: Transaction, title?: string) => void;
|
|
55
|
+
onResolve?: (tr: Transaction | undefined, title?: string) => void;
|
|
56
56
|
pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>;
|
|
57
57
|
provider?: Providers['cardProvider'];
|
|
58
58
|
smartCardContext?: CardContext;
|
|
@@ -63,6 +63,4 @@ export interface SmartCardProps extends CardProps {
|
|
|
63
63
|
* @param UnsupportedComponent
|
|
64
64
|
* @example
|
|
65
65
|
*/
|
|
66
|
-
export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<
|
|
67
|
-
id?: string;
|
|
68
|
-
}>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
|
|
66
|
+
export declare function Card<Props extends SmartCardProps>(SmartCardComponent: React.ComponentType<React.PropsWithChildren<Props>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<Props>>;
|
|
@@ -4,6 +4,7 @@ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { CardContext } from '@atlaskit/link-provider/types';
|
|
7
|
+
import type { CardPlugin } from '../cardPluginType';
|
|
7
8
|
import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
|
|
8
9
|
export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
|
|
9
10
|
export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
|
|
@@ -19,7 +20,7 @@ export declare const titleUrlPairFromNode: (node: Node) => TitleUrlPair;
|
|
|
19
20
|
*/
|
|
20
21
|
export declare const mergeCardInfo: (titleUrlPair: TitleUrlPair, info?: CardInfo) => TitleUrlPair;
|
|
21
22
|
export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleUrlPair;
|
|
22
|
-
export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
|
|
23
|
+
export declare const findCardInfo: (state: EditorState, cardActions?: Pick<ReturnType<CardPlugin>['actions'], 'getCardRegistrations'>) => CardInfo | undefined;
|
|
23
24
|
export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
|
|
24
25
|
export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
|
|
25
26
|
export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => Partial<ToolbarResolvedAttributes>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.1.2",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/adf-schema": "^57.7.0",
|
|
25
25
|
"@atlaskit/analytics-next": "^12.6.0",
|
|
26
|
-
"@atlaskit/button": "^25.
|
|
26
|
+
"@atlaskit/button": "^25.6.0",
|
|
27
27
|
"@atlaskit/css": "^1.1.0",
|
|
28
28
|
"@atlaskit/custom-steps": "^1.1.0",
|
|
29
29
|
"@atlaskit/editor-card-provider": "^8.1.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-plugin-user-intent": "^27.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-width": "^30.0.0",
|
|
45
45
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
46
|
-
"@atlaskit/editor-shared-styles": "^4.
|
|
46
|
+
"@atlaskit/editor-shared-styles": "^4.6.0",
|
|
47
47
|
"@atlaskit/editor-smart-link-draggable": "^1.2.0",
|
|
48
48
|
"@atlaskit/editor-toolbar": "^2.8.0",
|
|
49
49
|
"@atlaskit/editor-ui-control-model": "^2.10.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@atlaskit/primitives": "^22.6.0",
|
|
65
65
|
"@atlaskit/prosemirror-history": "^1.3.0",
|
|
66
66
|
"@atlaskit/smart-card": "^46.7.0",
|
|
67
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
68
|
-
"@atlaskit/tokens": "^20.
|
|
67
|
+
"@atlaskit/tmp-editor-statsig": "^245.0.0",
|
|
68
|
+
"@atlaskit/tokens": "^20.7.0",
|
|
69
69
|
"@babel/runtime": "^7.0.0",
|
|
70
70
|
"@emotion/react": "^11.7.1",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"uuid": "^11.1.1"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@atlaskit/editor-common": "^133.
|
|
77
|
+
"@atlaskit/editor-common": "^133.5.0",
|
|
78
78
|
"@atlaskit/link-provider": "^6.0.0",
|
|
79
79
|
"react": "^18.2.0 || ^19.2.0",
|
|
80
80
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -90,6 +90,9 @@
|
|
|
90
90
|
"platform_native_embeds_rollout_non_maui_experience": {
|
|
91
91
|
"type": "boolean"
|
|
92
92
|
},
|
|
93
|
+
"platform_native_embeds_rollout_all_products": {
|
|
94
|
+
"type": "boolean"
|
|
95
|
+
},
|
|
93
96
|
"confluence-issue-terminology-refresh": {
|
|
94
97
|
"type": "boolean"
|
|
95
98
|
},
|