@atlaskit/smart-card 44.23.2 → 44.23.4
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 +15 -0
- package/dist/cjs/extractors/action/extract-invoke-view-action.js +11 -1
- package/dist/cjs/extractors/flexible/actions/index.js +5 -2
- package/dist/cjs/extractors/flexible/extract-state.js +8 -5
- package/dist/cjs/extractors/flexible/index.js +6 -3
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +17 -2
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/click-helpers.js +30 -1
- package/dist/cjs/view/CardWithUrl/component.js +106 -42
- package/dist/cjs/view/FlexibleCard/index.js +12 -2
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +24 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/action/extract-invoke-view-action.js +10 -1
- package/dist/es2019/extractors/flexible/actions/index.js +5 -1
- package/dist/es2019/extractors/flexible/extract-state.js +8 -4
- package/dist/es2019/extractors/flexible/index.js +6 -2
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +13 -2
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/click-helpers.js +29 -0
- package/dist/es2019/view/CardWithUrl/component.js +108 -43
- package/dist/es2019/view/FlexibleCard/index.js +10 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +24 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/action/extract-invoke-view-action.js +11 -1
- package/dist/esm/extractors/flexible/actions/index.js +5 -2
- package/dist/esm/extractors/flexible/extract-state.js +8 -5
- package/dist/esm/extractors/flexible/index.js +6 -3
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +17 -2
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/click-helpers.js +29 -0
- package/dist/esm/view/CardWithUrl/component.js +107 -43
- package/dist/esm/view/FlexibleCard/index.js +13 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +24 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/action/extract-invoke-preview-action.d.ts +2 -1
- package/dist/types/extractors/action/extract-invoke-view-action.d.ts +5 -2
- package/dist/types/extractors/action/types.d.ts +1 -0
- package/dist/types/extractors/flexible/actions/index.d.ts +3 -1
- package/dist/types/extractors/flexible/extract-state.d.ts +2 -1
- package/dist/types/extractors/flexible/index.d.ts +1 -1
- package/dist/types/utils/click-helpers.d.ts +20 -0
- package/dist/types/view/FlexibleCard/types.d.ts +2 -0
- package/dist/types-ts4.5/extractors/action/extract-invoke-preview-action.d.ts +2 -1
- package/dist/types-ts4.5/extractors/action/extract-invoke-view-action.d.ts +5 -2
- package/dist/types-ts4.5/extractors/action/types.d.ts +1 -0
- package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +3 -1
- package/dist/types-ts4.5/extractors/flexible/extract-state.d.ts +2 -1
- package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/click-helpers.d.ts +20 -0
- package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +2 -0
- package/package.json +5 -5
|
@@ -6,6 +6,7 @@ import { useMemo } from 'react';
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
7
7
|
import uuid from 'uuid';
|
|
8
8
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
11
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
11
12
|
import { extractInvokeDownloadAction } from '../../extractors/action/extract-invoke-download-action';
|
|
@@ -15,6 +16,7 @@ import { messages } from '../../messages';
|
|
|
15
16
|
import { toAction } from '../../utils/actions/to-action';
|
|
16
17
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
17
18
|
import useResolve from '../hooks/use-resolve';
|
|
19
|
+
import { useSmartLinkCrossProductUrlWrapperGated } from '../hooks/use-smart-link-cross-product-url-wrapper';
|
|
18
20
|
import { useSmartCardState as useLinkState } from '../store';
|
|
19
21
|
export function useSmartLinkActions(_ref) {
|
|
20
22
|
var url = _ref.url,
|
|
@@ -36,6 +38,9 @@ export function useSmartLinkActions(_ref) {
|
|
|
36
38
|
fireEvent: fireEvent
|
|
37
39
|
});
|
|
38
40
|
var resolve = useResolve();
|
|
41
|
+
var appendCrossProductAnalyticsParams = useSmartLinkCrossProductUrlWrapperGated({
|
|
42
|
+
details: linkState.details
|
|
43
|
+
});
|
|
39
44
|
if (expValEquals('platform_hover_card_preview_panel', 'cohort', 'test') && prefetch && !linkState.details) {
|
|
40
45
|
resolve(url);
|
|
41
46
|
}
|
|
@@ -51,7 +56,12 @@ export function useSmartLinkActions(_ref) {
|
|
|
51
56
|
if (downloadActionProps) {
|
|
52
57
|
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
53
58
|
}
|
|
54
|
-
var viewActionProps = extractInvokeViewAction(invokeParam)
|
|
59
|
+
var viewActionProps = fg('platform_smartlink_xpc_url_wrapping') ? extractInvokeViewAction(_objectSpread(_objectSpread({}, invokeParam), {}, {
|
|
60
|
+
transformUrl: function transformUrl() {
|
|
61
|
+
var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
|
|
62
|
+
return appendCrossProductAnalyticsParams(destinationUrl);
|
|
63
|
+
}
|
|
64
|
+
})) : extractInvokeViewAction(invokeParam);
|
|
55
65
|
if (viewActionProps) {
|
|
56
66
|
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
57
67
|
}
|
|
@@ -60,7 +70,12 @@ export function useSmartLinkActions(_ref) {
|
|
|
60
70
|
origin: origin,
|
|
61
71
|
isPreviewPanelAvailable: isPreviewPanelAvailable,
|
|
62
72
|
openPreviewPanel: openPreviewPanel
|
|
63
|
-
})
|
|
73
|
+
}, fg('platform_smartlink_xpc_url_wrapping') ? {
|
|
74
|
+
transformUrl: function transformUrl() {
|
|
75
|
+
var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
|
|
76
|
+
return appendCrossProductAnalyticsParams(destinationUrl);
|
|
77
|
+
}
|
|
78
|
+
} : undefined));
|
|
64
79
|
if (previewActionProps) {
|
|
65
80
|
actions.push(toAction(previewActionProps.invokeAction, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
66
81
|
}
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card" || '',
|
|
7
|
-
packageVersion: "44.23.
|
|
7
|
+
packageVersion: "44.23.3" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -5,4 +5,33 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export var isAuxClick = function isAuxClick(e) {
|
|
7
7
|
return e.button === 1;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Extracts `href` and `target` from the anchor element that is the event's `currentTarget`.
|
|
12
|
+
*
|
|
13
|
+
* Smart Link click handlers are attached to multiple card renderers (InlineCard, BlockCard,
|
|
14
|
+
* EmbedCard, FlexibleCard). When the handler needs to manually open a link — for example,
|
|
15
|
+
* when native anchor navigation has been prevented — it uses this helper to read the
|
|
16
|
+
* anchor's resolved URL and intended target from the event rather than re-deriving them.
|
|
17
|
+
*
|
|
18
|
+
* Returns `{ href: undefined, target: '_self' }` when `currentTarget` is not an anchor
|
|
19
|
+
* element (e.g. a button or wrapper div), so callers can safely fall back to a default target.
|
|
20
|
+
*
|
|
21
|
+
* @param event - A React mouse or keyboard event whose `currentTarget` may be an anchor.
|
|
22
|
+
* @returns The resolved absolute `href` and `target` attribute of the anchor, or safe
|
|
23
|
+
* defaults if `currentTarget` is not an anchor.
|
|
24
|
+
*/
|
|
25
|
+
export var getAnchorAttributesFromEvent = function getAnchorAttributesFromEvent(event) {
|
|
26
|
+
var currentTarget = event.currentTarget;
|
|
27
|
+
if (!(currentTarget instanceof HTMLAnchorElement)) {
|
|
28
|
+
return {
|
|
29
|
+
href: undefined,
|
|
30
|
+
target: '_self'
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
href: currentTarget.href,
|
|
35
|
+
target: currentTarget.target || '_self'
|
|
36
|
+
};
|
|
8
37
|
};
|
|
@@ -19,7 +19,7 @@ import { isSpecialClick, isSpecialEvent, isSpecialKey } from '../../utils';
|
|
|
19
19
|
import { combineActionOptions } from '../../utils/actions/combine-action-options';
|
|
20
20
|
import { fireLinkClickedEvent } from '../../utils/analytics/click';
|
|
21
21
|
import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
|
|
22
|
-
import { isAuxClick } from '../../utils/click-helpers';
|
|
22
|
+
import { getAnchorAttributesFromEvent, isAuxClick } from '../../utils/click-helpers';
|
|
23
23
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
24
24
|
import * as measure from '../../utils/performance';
|
|
25
25
|
import { BlockCard } from '../BlockCard';
|
|
@@ -84,7 +84,7 @@ function Component(_ref) {
|
|
|
84
84
|
var services = getServices(state.details);
|
|
85
85
|
var thirdPartyARI = getThirdPartyARI(state.details);
|
|
86
86
|
var firstPartyIdentifier = getFirstPartyIdentifier();
|
|
87
|
-
var
|
|
87
|
+
var appendCrossProductAnalyticsParams = useSmartLinkCrossProductUrlWrapperGated({
|
|
88
88
|
details: state.details
|
|
89
89
|
});
|
|
90
90
|
var actionOptions = combineActionOptions({
|
|
@@ -118,56 +118,120 @@ function Component(_ref) {
|
|
|
118
118
|
var isDisablePreviewPanel = disablePreviewPanel && editorExperiment('platform_editor_preview_panel_linking_exp', true, {
|
|
119
119
|
exposure: true
|
|
120
120
|
});
|
|
121
|
+
if (fg('platform_smartlink_xpc_url_wrapping')) {
|
|
122
|
+
var _appendCrossProductAn;
|
|
123
|
+
// FIXME: InlineCard, BlockCard and EmbedCard call event.preventDefault() internally
|
|
124
|
+
// before the event bubbles up to this handler. This forces us to snapshot
|
|
125
|
+
// event.defaultPrevented before calling onClick to detect whether the consumer
|
|
126
|
+
// specifically prevented navigation. Ideally those components should not call
|
|
127
|
+
// preventDefault so this workaround can be removed.
|
|
128
|
+
var isEventDefaultPrevented = event.defaultPrevented;
|
|
129
|
+
var canOpenPreviewPanel = !isModifierKeyPressed && ari && name && openPreviewPanel && (isPreviewPanelAvailable === null || isPreviewPanelAvailable === void 0 ? void 0 : isPreviewPanelAvailable({
|
|
130
|
+
ari: ari
|
|
131
|
+
})) && !isDisablePreviewPanel;
|
|
121
132
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
return;
|
|
145
|
-
} else if (!onClick && !isFlexibleUi) {
|
|
146
|
-
var clickUrl = getClickUrl(url, state.details);
|
|
133
|
+
// Preview panel takes priority over link navigation when available.
|
|
134
|
+
if (canOpenPreviewPanel) {
|
|
135
|
+
var _extractSmartLinkEmbe;
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
event.stopPropagation();
|
|
138
|
+
openPreviewPanel({
|
|
139
|
+
url: url,
|
|
140
|
+
ari: ari,
|
|
141
|
+
name: name,
|
|
142
|
+
iconUrl: getObjectIconUrl(state.details),
|
|
143
|
+
panelData: {
|
|
144
|
+
embedUrl: expValEquals('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe = extractSmartLinkEmbed(state.details)) === null || _extractSmartLinkEmbe === void 0 ? void 0 : _extractSmartLinkEmbe.src : undefined
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, {
|
|
148
|
+
attributes: {
|
|
149
|
+
clickOutcome: 'previewPanel'
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
147
154
|
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var target = isSpecialEvent(event) ? '_blank' : '_self';
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
// For FlexibleCard, read target from the clicked anchor element (e.g. _blank for links
|
|
156
|
+
// rendered with explicit target). For classic cards, default to _self
|
|
157
|
+
var _getAnchorAttributesF = getAnchorAttributesFromEvent(event),
|
|
158
|
+
anchorTarget = _getAnchorAttributesF.target;
|
|
159
|
+
var target = isSpecialEvent(event) ? '_blank' : isFlexibleUi ? anchorTarget : '_self';
|
|
160
|
+
|
|
161
|
+
// FIXME: preferredUrl should be rendered in the DOM anchor href instead of derived at click time
|
|
162
|
+
var preferredUrl = getClickUrl(url, state.details);
|
|
163
|
+
var destinationUrl = (_appendCrossProductAn = appendCrossProductAnalyticsParams(preferredUrl)) !== null && _appendCrossProductAn !== void 0 ? _appendCrossProductAn : preferredUrl;
|
|
164
|
+
|
|
165
|
+
// FIXME: Consumer that handle click even themselves via callback won't have the decorated URL
|
|
166
|
+
onClick === null || onClick === void 0 || onClick(event);
|
|
167
|
+
|
|
168
|
+
// Check if the event is prevented via onClick callback
|
|
169
|
+
var consumerPreventedNavigation = event.defaultPrevented && !isEventDefaultPrevented;
|
|
170
|
+
|
|
171
|
+
// Classic cards (InlineCard, BlockCard, EmbedCard) rely on their own anchor navigation
|
|
172
|
+
// when onClick is provided, so this handler should not open the link for them.
|
|
173
|
+
// FlexibleCard's anchor is prevented from native navigation, so this handler always
|
|
174
|
+
// opens the link for FlexibleCard unless the consumer's onClick called preventDefault.
|
|
175
|
+
var shouldOpenLink = isFlexibleUi || !onClick;
|
|
176
|
+
var doOpenLink = shouldOpenLink && !consumerPreventedNavigation;
|
|
177
|
+
if (doOpenLink) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
window.open(destinationUrl, target);
|
|
158
180
|
}
|
|
159
|
-
|
|
181
|
+
|
|
182
|
+
// Only set clickOutcome when this handler actually opened the link.
|
|
183
|
+
// If a parent onClick handled navigation, fire a generic click event instead.
|
|
184
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, doOpenLink ? {
|
|
160
185
|
attributes: {
|
|
161
186
|
clickOutcome: target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
|
|
162
187
|
}
|
|
163
|
-
});
|
|
188
|
+
} : undefined);
|
|
164
189
|
} else {
|
|
165
|
-
|
|
166
|
-
|
|
190
|
+
// If preview panel is available and the user clicked on the link,
|
|
191
|
+
// delegate the click to the preview panel handler
|
|
192
|
+
if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
|
|
193
|
+
ari: ari
|
|
194
|
+
}) && !isDisablePreviewPanel) {
|
|
195
|
+
var _extractSmartLinkEmbe2;
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
event.stopPropagation();
|
|
198
|
+
openPreviewPanel({
|
|
199
|
+
url: url,
|
|
200
|
+
ari: ari,
|
|
201
|
+
name: name,
|
|
202
|
+
iconUrl: getObjectIconUrl(state.details),
|
|
203
|
+
panelData: {
|
|
204
|
+
embedUrl: expValEquals('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe2 = extractSmartLinkEmbed(state.details)) === null || _extractSmartLinkEmbe2 === void 0 ? void 0 : _extractSmartLinkEmbe2.src : undefined
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, {
|
|
208
|
+
attributes: {
|
|
209
|
+
clickOutcome: 'previewPanel'
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
} else if (!onClick && !isFlexibleUi) {
|
|
214
|
+
var clickUrl = getClickUrl(url, state.details);
|
|
215
|
+
|
|
216
|
+
// Ctrl+left click on mac typically doesn't trigger onClick
|
|
217
|
+
// The event could have potentially had `e.preventDefault()` called on it by now
|
|
218
|
+
// event by smart card internally
|
|
219
|
+
// If it has been called then only then can `isSpecialEvent` be true.
|
|
220
|
+
var _target = isSpecialEvent(event) ? '_blank' : '_self';
|
|
221
|
+
window.open(clickUrl, _target);
|
|
222
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, {
|
|
223
|
+
attributes: {
|
|
224
|
+
clickOutcome: _target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
if (onClick) {
|
|
229
|
+
onClick(event);
|
|
230
|
+
}
|
|
231
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
167
232
|
}
|
|
168
|
-
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
169
233
|
}
|
|
170
|
-
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url,
|
|
234
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, appendCrossProductAnalyticsParams, state.details, ari, name, fire3PClickEvent, shouldFire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, disablePreviewPanel]);
|
|
171
235
|
|
|
172
236
|
// Exposure fires once per eligible mount; click-time reads use no-exposure variant.
|
|
173
237
|
useEffect(function () {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import React, { useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import UFOHoldLoad from '@atlaskit/react-ufo/load-hold';
|
|
@@ -13,6 +13,7 @@ import { FlexibleCardContext } from '../../state/flexible-ui-context';
|
|
|
13
13
|
import { useAISummaryConfig } from '../../state/hooks/use-ai-summary-config';
|
|
14
14
|
import useResolve from '../../state/hooks/use-resolve';
|
|
15
15
|
import useRovoConfig from '../../state/hooks/use-rovo-config';
|
|
16
|
+
import { useSmartLinkCrossProductUrlWrapperGated } from '../../state/hooks/use-smart-link-cross-product-url-wrapper';
|
|
16
17
|
import Container from './components/container';
|
|
17
18
|
import { getContextByStatus } from './utils';
|
|
18
19
|
var PENDING_LINK_STATUSES = [SmartLinkStatus.Pending, SmartLinkStatus.Resolving];
|
|
@@ -59,6 +60,14 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
59
60
|
var cardType = cardState.status,
|
|
60
61
|
details = cardState.details;
|
|
61
62
|
var status = cardType;
|
|
63
|
+
var appendCrossProductAnalyticsParams = useSmartLinkCrossProductUrlWrapperGated({
|
|
64
|
+
details: details
|
|
65
|
+
});
|
|
66
|
+
var transformUrlCallback = useCallback(function () {
|
|
67
|
+
var destinationUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : url;
|
|
68
|
+
return appendCrossProductAnalyticsParams(destinationUrl);
|
|
69
|
+
}, [appendCrossProductAnalyticsParams, url]);
|
|
70
|
+
var transformUrl = fg('platform_smartlink_xpc_url_wrapping') ? transformUrlCallback : undefined;
|
|
62
71
|
|
|
63
72
|
// if we have placeholder state it means we can internally use it
|
|
64
73
|
// as temporary resolved data until the actual data comes back as one of the final statuses
|
|
@@ -88,9 +97,10 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
88
97
|
status: placeholderCardState ? placeHolderStatus : status,
|
|
89
98
|
url: url,
|
|
90
99
|
isPreviewPanelAvailable: isPreviewPanelAvailable,
|
|
91
|
-
openPreviewPanel: openPreviewPanel
|
|
100
|
+
openPreviewPanel: openPreviewPanel,
|
|
101
|
+
transformUrl: transformUrl
|
|
92
102
|
}));
|
|
93
|
-
}, [aiSummaryConfig, appearance, actionOptions, details, id, isPreviewPanelAvailable, onAuthorize, onClick, onAuxClick, onContextMenu, openPreviewPanel, origin, placeholderCardState, placeHolderStatus, product, renderers, resolve, rovoConfig, status, url, fireEvent]);
|
|
103
|
+
}, [aiSummaryConfig, appearance, actionOptions, details, id, isPreviewPanelAvailable, onAuthorize, onClick, onAuxClick, onContextMenu, openPreviewPanel, origin, placeholderCardState, placeHolderStatus, product, renderers, resolve, rovoConfig, status, transformUrl, url, fireEvent]);
|
|
94
104
|
var flexibleCardContext = useMemo(function () {
|
|
95
105
|
return {
|
|
96
106
|
data: context,
|
|
@@ -14,10 +14,12 @@ import { CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constant
|
|
|
14
14
|
import extractRovoChatAction from '../../../extractors/flexible/actions/extract-rovo-chat-action';
|
|
15
15
|
import { getDefinitionId, getExtensionKey, getServices } from '../../../state/helpers';
|
|
16
16
|
import useRovoConfig from '../../../state/hooks/use-rovo-config';
|
|
17
|
+
import { useSmartLinkCrossProductUrlWrapperGated } from '../../../state/hooks/use-smart-link-cross-product-url-wrapper';
|
|
17
18
|
import { useSmartCardState } from '../../../state/store';
|
|
18
19
|
import { isSpecialEvent } from '../../../utils';
|
|
19
20
|
import { getIsAISummaryEnabled } from '../../../utils/ai-summary';
|
|
20
21
|
import { fireLinkClickedEvent } from '../../../utils/analytics/click';
|
|
22
|
+
import { getAnchorAttributesFromEvent } from '../../../utils/click-helpers';
|
|
21
23
|
import { flexibleUiOptions } from '../styled';
|
|
22
24
|
import { getMetadata } from '../utils';
|
|
23
25
|
import ContentContainer from './ContentContainer';
|
|
@@ -86,6 +88,9 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
86
88
|
product = _useSmartLinkContext.product;
|
|
87
89
|
var isAISummaryEnabled = getIsAISummaryEnabled(isAdminHubAIEnabled, cardState.details);
|
|
88
90
|
var services = getServices(linkState.details);
|
|
91
|
+
var appendCrossProductAnalyticsParams = useSmartLinkCrossProductUrlWrapperGated({
|
|
92
|
+
details: linkState.details
|
|
93
|
+
});
|
|
89
94
|
var statusRef = useRef(linkStatus);
|
|
90
95
|
var fireEventRef = useRef(fireEvent);
|
|
91
96
|
var definitionIdRef = useRef(definitionId);
|
|
@@ -127,6 +132,24 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
127
132
|
};
|
|
128
133
|
}, []);
|
|
129
134
|
var onClick = useCallback(function (event) {
|
|
135
|
+
if (fg('platform_smartlink_xpc_url_wrapping')) {
|
|
136
|
+
// Prevent the anchor's native navigation so we can open the destination URL
|
|
137
|
+
// with cross-product analytics query parameters appended.
|
|
138
|
+
// The href is read from the anchor element at click time rather than at render
|
|
139
|
+
// time because the URL for the anchor may be different from original URL.
|
|
140
|
+
// The component may use the URL from the resolved response which can be a redirect URL
|
|
141
|
+
// or other preferred URL based on link extractor.
|
|
142
|
+
// The cross-product params are client-only and cannot be rendered
|
|
143
|
+
// server-side. Falls back to the original `url` prop if the event target is
|
|
144
|
+
// not an anchor element.
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
var _getAnchorAttributesF = getAnchorAttributesFromEvent(event),
|
|
147
|
+
_getAnchorAttributesF2 = _getAnchorAttributesF.href,
|
|
148
|
+
href = _getAnchorAttributesF2 === void 0 ? url : _getAnchorAttributesF2,
|
|
149
|
+
target = _getAnchorAttributesF.target;
|
|
150
|
+
var destinationUrl = appendCrossProductAnalyticsParams(href);
|
|
151
|
+
window.open(destinationUrl, target);
|
|
152
|
+
}
|
|
130
153
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
131
154
|
fireEvent('ui.smartLink.clicked.titleGoToLink', {
|
|
132
155
|
id: id,
|
|
@@ -135,7 +158,7 @@ var HoverCardContent = function HoverCardContent(_ref4) {
|
|
|
135
158
|
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null
|
|
136
159
|
});
|
|
137
160
|
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
138
|
-
}, [createAnalyticsEvent, id, fireEvent, definitionId]);
|
|
161
|
+
}, [createAnalyticsEvent, appendCrossProductAnalyticsParams, id, fireEvent, definitionId, url]);
|
|
139
162
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
140
163
|
var _getMetadata = getMetadata(extensionKey, data),
|
|
141
164
|
subtitle = _getMetadata.subtitle;
|
|
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
12
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
13
13
|
var PACKAGE_DATA = {
|
|
14
14
|
packageName: "@atlaskit/smart-card",
|
|
15
|
-
packageVersion: "44.23.
|
|
15
|
+
packageVersion: "44.23.3",
|
|
16
16
|
componentName: 'linkUrl'
|
|
17
17
|
};
|
|
18
18
|
var LinkUrl = function LinkUrl(_ref) {
|
|
@@ -2,7 +2,7 @@ import { type FireEventFunction } from '../../common/analytics/types';
|
|
|
2
2
|
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
3
3
|
import { type AnalyticsOrigin } from '../../utils/types';
|
|
4
4
|
import { type EmbedModalProps } from '../../view/EmbedModal/types';
|
|
5
|
-
import { type ExtractClientActionsParam } from './types';
|
|
5
|
+
import { type ExtractClientActionsParam, type TransformUrlFn } from './types';
|
|
6
6
|
export type ExtractInvokePreviewActionParam = ExtractClientActionsParam & {
|
|
7
7
|
fireEvent?: FireEventFunction;
|
|
8
8
|
isPreviewPanelAvailable?: (params: {
|
|
@@ -19,6 +19,7 @@ export type ExtractInvokePreviewActionParam = ExtractClientActionsParam & {
|
|
|
19
19
|
url: string;
|
|
20
20
|
}) => void;
|
|
21
21
|
origin?: AnalyticsOrigin;
|
|
22
|
+
transformUrl?: TransformUrlFn;
|
|
22
23
|
};
|
|
23
24
|
type ExtractInvokePreviewActionReturn = {
|
|
24
25
|
hasPreviewPanel?: boolean;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
-
import { type ExtractClientActionsParam } from './types';
|
|
3
|
-
export
|
|
2
|
+
import { type ExtractClientActionsParam, type TransformUrlFn } from './types';
|
|
3
|
+
export type ExtractInvokeViewActionParam = ExtractClientActionsParam & {
|
|
4
|
+
transformUrl?: TransformUrlFn;
|
|
5
|
+
};
|
|
6
|
+
export declare const extractInvokeViewAction: ({ actionOptions, appearance, transformUrl, id, response }: ExtractInvokeViewActionParam, force?: boolean) => InvokeClientActionProps | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JsonLd } from '@atlaskit/json-ld-types';
|
|
2
2
|
import type { InternalCardActionOptions as CardActionOptions } from '../../view/Card/types';
|
|
3
3
|
import type { FlexibleCardProps } from '../../view/FlexibleCard/types';
|
|
4
|
+
export type TransformUrlFn = (url?: string) => string | undefined;
|
|
4
5
|
export type ExtractClientActionsParam = {
|
|
5
6
|
actionOptions?: CardActionOptions;
|
|
6
7
|
appearance?: FlexibleCardProps['appearance'];
|
|
@@ -6,6 +6,7 @@ import { type AISummaryConfig } from '../../../state/hooks/use-ai-summary-config
|
|
|
6
6
|
import type { RovoConfig } from '../../../state/hooks/use-rovo-config';
|
|
7
7
|
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
8
8
|
import { type InternalCardActionOptions as CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
9
|
+
import { type TransformUrlFn } from '../../action/types';
|
|
9
10
|
export type ExtractActionsParam = {
|
|
10
11
|
actionOptions?: CardActionOptions;
|
|
11
12
|
aiSummaryConfig?: AISummaryConfig;
|
|
@@ -28,6 +29,7 @@ export type ExtractActionsParam = {
|
|
|
28
29
|
product?: ProductType;
|
|
29
30
|
response: JsonLd.Response;
|
|
30
31
|
rovoConfig?: RovoConfig;
|
|
32
|
+
transformUrl?: TransformUrlFn;
|
|
31
33
|
url?: string;
|
|
32
34
|
};
|
|
33
|
-
export declare const extractFlexibleCardActions: ({ actionOptions, aiSummaryConfig, appearance, fireEvent, id, origin, product, response, rovoConfig, url, isPreviewPanelAvailable, openPreviewPanel, }: ExtractActionsParam) => FlexibleUiActions | undefined;
|
|
35
|
+
export declare const extractFlexibleCardActions: ({ actionOptions, aiSummaryConfig, appearance, fireEvent, id, origin, product, response, rovoConfig, transformUrl, url, isPreviewPanelAvailable, openPreviewPanel, }: ExtractActionsParam) => FlexibleUiActions | undefined;
|
|
@@ -3,6 +3,7 @@ import { type FireEventFunction } from '../../common/analytics/types';
|
|
|
3
3
|
import { type ResolveFunction } from '../../state/hooks/use-resolve';
|
|
4
4
|
import { type AnalyticsOrigin } from '../../utils/types';
|
|
5
5
|
import { type InternalCardActionOptions as CardActionOptions, type CardInnerAppearance } from '../../view/Card/types';
|
|
6
|
+
import { type TransformUrlFn } from '../action/types';
|
|
6
7
|
import { type LinkLozenge } from '../common/lozenge/types';
|
|
7
8
|
declare const extractState: (response?: JsonLd.Response, actionOptions?: CardActionOptions, id?: string, appearance?: CardInnerAppearance, origin?: AnalyticsOrigin, fireEvent?: FireEventFunction, resolve?: ResolveFunction, isPreviewPanelAvailable?: (params: {
|
|
8
9
|
ari: string;
|
|
@@ -14,5 +15,5 @@ declare const extractState: (response?: JsonLd.Response, actionOptions?: CardAct
|
|
|
14
15
|
embedUrl?: string;
|
|
15
16
|
};
|
|
16
17
|
url: string;
|
|
17
|
-
}) => void) => LinkLozenge | undefined;
|
|
18
|
+
}) => void, transformUrl?: TransformUrlFn) => LinkLozenge | undefined;
|
|
18
19
|
export default extractState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type FlexibleUiDataContext } from '../../state/flexible-ui-context/types';
|
|
2
2
|
import { type ExtractFlexibleUiDataContextParams } from '../../view/FlexibleCard/types';
|
|
3
|
-
declare const extractFlexibleUiContext: ({ appearance, fireEvent, id, onClick, onAuxClick, onContextMenu, origin, product, resolve, rovoConfig, actionOptions, response, status, aiSummaryConfig, isPreviewPanelAvailable, openPreviewPanel, ...props }?: Partial<ExtractFlexibleUiDataContextParams>) => FlexibleUiDataContext | undefined;
|
|
3
|
+
declare const extractFlexibleUiContext: ({ appearance, fireEvent, id, onClick, onAuxClick, onContextMenu, origin, product, resolve, rovoConfig, actionOptions, response, status, aiSummaryConfig, isPreviewPanelAvailable, openPreviewPanel, transformUrl, ...props }?: Partial<ExtractFlexibleUiDataContextParams>) => FlexibleUiDataContext | undefined;
|
|
4
4
|
export default extractFlexibleUiContext;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type KeyboardEvent, type MouseEvent } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Returns true for genuine middle-clicks (button === 1).
|
|
3
4
|
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
@@ -6,3 +7,22 @@
|
|
|
6
7
|
export declare const isAuxClick: (e: {
|
|
7
8
|
button: number;
|
|
8
9
|
}) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Extracts `href` and `target` from the anchor element that is the event's `currentTarget`.
|
|
12
|
+
*
|
|
13
|
+
* Smart Link click handlers are attached to multiple card renderers (InlineCard, BlockCard,
|
|
14
|
+
* EmbedCard, FlexibleCard). When the handler needs to manually open a link — for example,
|
|
15
|
+
* when native anchor navigation has been prevented — it uses this helper to read the
|
|
16
|
+
* anchor's resolved URL and intended target from the event rather than re-deriving them.
|
|
17
|
+
*
|
|
18
|
+
* Returns `{ href: undefined, target: '_self' }` when `currentTarget` is not an anchor
|
|
19
|
+
* element (e.g. a button or wrapper div), so callers can safely fall back to a default target.
|
|
20
|
+
*
|
|
21
|
+
* @param event - A React mouse or keyboard event whose `currentTarget` may be an anchor.
|
|
22
|
+
* @returns The resolved absolute `href` and `target` attribute of the anchor, or safe
|
|
23
|
+
* defaults if `currentTarget` is not an anchor.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getAnchorAttributesFromEvent: (event: MouseEvent | KeyboardEvent) => {
|
|
26
|
+
href?: string;
|
|
27
|
+
target: string;
|
|
28
|
+
};
|
|
@@ -4,6 +4,7 @@ import { type CardState, type ProductType } from '@atlaskit/linking-common';
|
|
|
4
4
|
import { type SmartLinkResponse } from '@atlaskit/linking-types';
|
|
5
5
|
import { type FireEventFunction } from '../../common/analytics/types';
|
|
6
6
|
import { type SmartLinkSize, type SmartLinkStatus, type SmartLinkTheme } from '../../constants';
|
|
7
|
+
import type { TransformUrlFn } from '../../extractors/action/types';
|
|
7
8
|
import { type AISummaryConfig } from '../../state/hooks/use-ai-summary-config/types';
|
|
8
9
|
import { type ResolveFunction } from '../../state/hooks/use-resolve';
|
|
9
10
|
import type { RovoConfig } from '../../state/hooks/use-rovo-config';
|
|
@@ -197,6 +198,7 @@ export type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'appear
|
|
|
197
198
|
response?: SmartLinkResponse;
|
|
198
199
|
rovoConfig?: RovoConfig;
|
|
199
200
|
status?: SmartLinkStatus;
|
|
201
|
+
transformUrl?: TransformUrlFn;
|
|
200
202
|
};
|
|
201
203
|
/**
|
|
202
204
|
* Mark a specific props in the type as optional.
|
|
@@ -2,7 +2,7 @@ import { type FireEventFunction } from '../../common/analytics/types';
|
|
|
2
2
|
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
3
3
|
import { type AnalyticsOrigin } from '../../utils/types';
|
|
4
4
|
import { type EmbedModalProps } from '../../view/EmbedModal/types';
|
|
5
|
-
import { type ExtractClientActionsParam } from './types';
|
|
5
|
+
import { type ExtractClientActionsParam, type TransformUrlFn } from './types';
|
|
6
6
|
export type ExtractInvokePreviewActionParam = ExtractClientActionsParam & {
|
|
7
7
|
fireEvent?: FireEventFunction;
|
|
8
8
|
isPreviewPanelAvailable?: (params: {
|
|
@@ -19,6 +19,7 @@ export type ExtractInvokePreviewActionParam = ExtractClientActionsParam & {
|
|
|
19
19
|
url: string;
|
|
20
20
|
}) => void;
|
|
21
21
|
origin?: AnalyticsOrigin;
|
|
22
|
+
transformUrl?: TransformUrlFn;
|
|
22
23
|
};
|
|
23
24
|
type ExtractInvokePreviewActionReturn = {
|
|
24
25
|
hasPreviewPanel?: boolean;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
-
import { type ExtractClientActionsParam } from './types';
|
|
3
|
-
export
|
|
2
|
+
import { type ExtractClientActionsParam, type TransformUrlFn } from './types';
|
|
3
|
+
export type ExtractInvokeViewActionParam = ExtractClientActionsParam & {
|
|
4
|
+
transformUrl?: TransformUrlFn;
|
|
5
|
+
};
|
|
6
|
+
export declare const extractInvokeViewAction: ({ actionOptions, appearance, transformUrl, id, response }: ExtractInvokeViewActionParam, force?: boolean) => InvokeClientActionProps | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JsonLd } from '@atlaskit/json-ld-types';
|
|
2
2
|
import type { InternalCardActionOptions as CardActionOptions } from '../../view/Card/types';
|
|
3
3
|
import type { FlexibleCardProps } from '../../view/FlexibleCard/types';
|
|
4
|
+
export type TransformUrlFn = (url?: string) => string | undefined;
|
|
4
5
|
export type ExtractClientActionsParam = {
|
|
5
6
|
actionOptions?: CardActionOptions;
|
|
6
7
|
appearance?: FlexibleCardProps['appearance'];
|
|
@@ -6,6 +6,7 @@ import { type AISummaryConfig } from '../../../state/hooks/use-ai-summary-config
|
|
|
6
6
|
import type { RovoConfig } from '../../../state/hooks/use-rovo-config';
|
|
7
7
|
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
8
8
|
import { type InternalCardActionOptions as CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
9
|
+
import { type TransformUrlFn } from '../../action/types';
|
|
9
10
|
export type ExtractActionsParam = {
|
|
10
11
|
actionOptions?: CardActionOptions;
|
|
11
12
|
aiSummaryConfig?: AISummaryConfig;
|
|
@@ -28,6 +29,7 @@ export type ExtractActionsParam = {
|
|
|
28
29
|
product?: ProductType;
|
|
29
30
|
response: JsonLd.Response;
|
|
30
31
|
rovoConfig?: RovoConfig;
|
|
32
|
+
transformUrl?: TransformUrlFn;
|
|
31
33
|
url?: string;
|
|
32
34
|
};
|
|
33
|
-
export declare const extractFlexibleCardActions: ({ actionOptions, aiSummaryConfig, appearance, fireEvent, id, origin, product, response, rovoConfig, url, isPreviewPanelAvailable, openPreviewPanel, }: ExtractActionsParam) => FlexibleUiActions | undefined;
|
|
35
|
+
export declare const extractFlexibleCardActions: ({ actionOptions, aiSummaryConfig, appearance, fireEvent, id, origin, product, response, rovoConfig, transformUrl, url, isPreviewPanelAvailable, openPreviewPanel, }: ExtractActionsParam) => FlexibleUiActions | undefined;
|
|
@@ -3,6 +3,7 @@ import { type FireEventFunction } from '../../common/analytics/types';
|
|
|
3
3
|
import { type ResolveFunction } from '../../state/hooks/use-resolve';
|
|
4
4
|
import { type AnalyticsOrigin } from '../../utils/types';
|
|
5
5
|
import { type InternalCardActionOptions as CardActionOptions, type CardInnerAppearance } from '../../view/Card/types';
|
|
6
|
+
import { type TransformUrlFn } from '../action/types';
|
|
6
7
|
import { type LinkLozenge } from '../common/lozenge/types';
|
|
7
8
|
declare const extractState: (response?: JsonLd.Response, actionOptions?: CardActionOptions, id?: string, appearance?: CardInnerAppearance, origin?: AnalyticsOrigin, fireEvent?: FireEventFunction, resolve?: ResolveFunction, isPreviewPanelAvailable?: (params: {
|
|
8
9
|
ari: string;
|
|
@@ -14,5 +15,5 @@ declare const extractState: (response?: JsonLd.Response, actionOptions?: CardAct
|
|
|
14
15
|
embedUrl?: string;
|
|
15
16
|
};
|
|
16
17
|
url: string;
|
|
17
|
-
}) => void) => LinkLozenge | undefined;
|
|
18
|
+
}) => void, transformUrl?: TransformUrlFn) => LinkLozenge | undefined;
|
|
18
19
|
export default extractState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type FlexibleUiDataContext } from '../../state/flexible-ui-context/types';
|
|
2
2
|
import { type ExtractFlexibleUiDataContextParams } from '../../view/FlexibleCard/types';
|
|
3
|
-
declare const extractFlexibleUiContext: ({ appearance, fireEvent, id, onClick, onAuxClick, onContextMenu, origin, product, resolve, rovoConfig, actionOptions, response, status, aiSummaryConfig, isPreviewPanelAvailable, openPreviewPanel, ...props }?: Partial<ExtractFlexibleUiDataContextParams>) => FlexibleUiDataContext | undefined;
|
|
3
|
+
declare const extractFlexibleUiContext: ({ appearance, fireEvent, id, onClick, onAuxClick, onContextMenu, origin, product, resolve, rovoConfig, actionOptions, response, status, aiSummaryConfig, isPreviewPanelAvailable, openPreviewPanel, transformUrl, ...props }?: Partial<ExtractFlexibleUiDataContextParams>) => FlexibleUiDataContext | undefined;
|
|
4
4
|
export default extractFlexibleUiContext;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type KeyboardEvent, type MouseEvent } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Returns true for genuine middle-clicks (button === 1).
|
|
3
4
|
* Filters out Windows right-clicks, which fire onAuxClick with button === 2
|
|
@@ -6,3 +7,22 @@
|
|
|
6
7
|
export declare const isAuxClick: (e: {
|
|
7
8
|
button: number;
|
|
8
9
|
}) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Extracts `href` and `target` from the anchor element that is the event's `currentTarget`.
|
|
12
|
+
*
|
|
13
|
+
* Smart Link click handlers are attached to multiple card renderers (InlineCard, BlockCard,
|
|
14
|
+
* EmbedCard, FlexibleCard). When the handler needs to manually open a link — for example,
|
|
15
|
+
* when native anchor navigation has been prevented — it uses this helper to read the
|
|
16
|
+
* anchor's resolved URL and intended target from the event rather than re-deriving them.
|
|
17
|
+
*
|
|
18
|
+
* Returns `{ href: undefined, target: '_self' }` when `currentTarget` is not an anchor
|
|
19
|
+
* element (e.g. a button or wrapper div), so callers can safely fall back to a default target.
|
|
20
|
+
*
|
|
21
|
+
* @param event - A React mouse or keyboard event whose `currentTarget` may be an anchor.
|
|
22
|
+
* @returns The resolved absolute `href` and `target` attribute of the anchor, or safe
|
|
23
|
+
* defaults if `currentTarget` is not an anchor.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getAnchorAttributesFromEvent: (event: MouseEvent | KeyboardEvent) => {
|
|
26
|
+
href?: string;
|
|
27
|
+
target: string;
|
|
28
|
+
};
|