@atlaskit/editor-plugin-card 5.4.11 → 5.4.13
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 +18 -0
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +9 -3
- package/dist/cjs/ui/AwarenessWrapper/index.js +3 -17
- package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +19 -194
- package/dist/cjs/ui/OpenButtonOverlay/index.js +28 -48
- package/dist/cjs/ui/OpenButtonOverlay/types.js +5 -1
- package/dist/cjs/ui/toolbar.js +9 -22
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +9 -3
- package/dist/es2019/ui/AwarenessWrapper/index.js +3 -13
- package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +6 -118
- package/dist/es2019/ui/OpenButtonOverlay/index.js +23 -43
- package/dist/es2019/ui/OpenButtonOverlay/types.js +1 -0
- package/dist/es2019/ui/toolbar.js +10 -23
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +9 -3
- package/dist/esm/ui/AwarenessWrapper/index.js +3 -17
- package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +18 -193
- package/dist/esm/ui/OpenButtonOverlay/index.js +28 -48
- package/dist/esm/ui/OpenButtonOverlay/types.js +1 -0
- package/dist/esm/ui/toolbar.js +10 -23
- package/dist/types/ui/HyperlinkToolbarAppearanceDropdown.d.ts +1 -8
- package/dist/types/ui/OpenButtonOverlay/index.d.ts +1 -1
- package/dist/types/ui/OpenButtonOverlay/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearanceDropdown.d.ts +1 -8
- package/dist/types-ts4.5/ui/OpenButtonOverlay/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/OpenButtonOverlay/types.d.ts +2 -0
- package/package.json +19 -16
|
@@ -7,13 +7,11 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
11
|
import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
|
|
13
12
|
import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
|
|
14
13
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
15
14
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../local-storage';
|
|
16
|
-
import OpenButtonOverlay from '../OpenButtonOverlay';
|
|
17
15
|
import { DiscoveryPulse } from '../Pulse';
|
|
18
16
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
19
17
|
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
@@ -77,7 +75,7 @@ export const AwarenessWrapper = ({
|
|
|
77
75
|
setOverlayHoveredStyles(isHovered);
|
|
78
76
|
}, [setOverlayHoveredStyles]);
|
|
79
77
|
const cardWithOverlay = useMemo(() => {
|
|
80
|
-
if (shouldShowLinkOverlay && !
|
|
78
|
+
if (shouldShowLinkOverlay && !editorExperiment('platform_editor_controls', 'variant1')) {
|
|
81
79
|
return jsx(InlineCardOverlay, {
|
|
82
80
|
isSelected: isSelected,
|
|
83
81
|
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
@@ -88,14 +86,6 @@ export const AwarenessWrapper = ({
|
|
|
88
86
|
}
|
|
89
87
|
return children;
|
|
90
88
|
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
91
|
-
const cardWithOpenButtonOverlay = useMemo(() => {
|
|
92
|
-
return jsx(OpenButtonOverlay, {
|
|
93
|
-
isVisible: isResolvedViewRendered && isHovered,
|
|
94
|
-
onMouseEnter: () => handleOverlayChange(true),
|
|
95
|
-
onMouseLeave: () => handleOverlayChange(false),
|
|
96
|
-
url: url
|
|
97
|
-
}, children);
|
|
98
|
-
}, [children, isHovered, url, handleOverlayChange, isResolvedViewRendered]);
|
|
99
89
|
const isInline = appearance === 'inline';
|
|
100
90
|
return useMemo(() => {
|
|
101
91
|
var _cardContext$value;
|
|
@@ -115,7 +105,7 @@ export const AwarenessWrapper = ({
|
|
|
115
105
|
shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
|
|
116
106
|
testId: "link-discovery-pulse",
|
|
117
107
|
isInline: isInline
|
|
118
|
-
},
|
|
108
|
+
}, cardWithOverlay)))
|
|
119
109
|
);
|
|
120
|
-
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay,
|
|
110
|
+
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline]);
|
|
121
111
|
};
|
|
@@ -5,18 +5,21 @@ import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlask
|
|
|
5
5
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
6
6
|
import { Flex } from '@atlaskit/primitives';
|
|
7
7
|
import { LinkAppearanceMenu } from './LinkToolbarAppearanceDropdown';
|
|
8
|
-
const
|
|
8
|
+
const CustomHyperlinkDropdown = props => {
|
|
9
9
|
var _props$cardOptions3;
|
|
10
10
|
const [supportedUrlsMap, setSupportedUrlsMap] = useState(new Map());
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
12
|
const cardProvider = useRef(undefined);
|
|
13
|
+
const containerRef = useRef(undefined);
|
|
12
14
|
const {
|
|
13
15
|
url,
|
|
14
16
|
intl,
|
|
15
|
-
|
|
17
|
+
editorView,
|
|
16
18
|
cardOptions,
|
|
17
19
|
editorAnalyticsApi,
|
|
18
20
|
allowDatasource,
|
|
19
|
-
isDatasourceView
|
|
21
|
+
isDatasourceView,
|
|
22
|
+
settingsConfig
|
|
20
23
|
} = props;
|
|
21
24
|
// Ignored via go/ees005
|
|
22
25
|
// eslint-disable-next-line require-await
|
|
@@ -61,121 +64,6 @@ const HyperlinkDropdown = props => {
|
|
|
61
64
|
if (!supportedUrlsMap.get(url)) {
|
|
62
65
|
return null;
|
|
63
66
|
}
|
|
64
|
-
return /*#__PURE__*/React.createElement(LinkAppearanceMenu, {
|
|
65
|
-
url: url,
|
|
66
|
-
intl: intl,
|
|
67
|
-
editorState: editorState,
|
|
68
|
-
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
69
|
-
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
70
|
-
allowDatasource: allowDatasource,
|
|
71
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
72
|
-
dispatchCommand: props.dispatchCommand,
|
|
73
|
-
settingsConfig: props.settingsConfig,
|
|
74
|
-
isDatasourceView: isDatasourceView
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
export const getHyperlinkAppearanceDropdown = ({
|
|
78
|
-
url,
|
|
79
|
-
intl,
|
|
80
|
-
editorState,
|
|
81
|
-
editorAnalyticsApi,
|
|
82
|
-
editorPluginApi,
|
|
83
|
-
settingsConfig,
|
|
84
|
-
cardOptions,
|
|
85
|
-
allowDatasource,
|
|
86
|
-
isDatasourceView
|
|
87
|
-
}) => {
|
|
88
|
-
const alignmentItemOptions = {
|
|
89
|
-
render: props => {
|
|
90
|
-
if (!editorState) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
return /*#__PURE__*/React.createElement(HyperlinkDropdown, {
|
|
94
|
-
intl: intl,
|
|
95
|
-
editorState: editorState,
|
|
96
|
-
url: url,
|
|
97
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
98
|
-
editorPluginApi: editorPluginApi,
|
|
99
|
-
dispatchCommand: props.dispatchCommand,
|
|
100
|
-
settingsConfig: settingsConfig,
|
|
101
|
-
cardOptions: cardOptions,
|
|
102
|
-
allowDatasource: allowDatasource,
|
|
103
|
-
isDatasourceView: isDatasourceView
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
width: 200,
|
|
107
|
-
height: 400
|
|
108
|
-
};
|
|
109
|
-
const currentAppearanceDisplayInformation = appearancePropsMap['url'];
|
|
110
|
-
const alignmentToolbarItem = {
|
|
111
|
-
id: 'hyperlink-appearance',
|
|
112
|
-
testId: 'hyperlink-appearance-dropdown',
|
|
113
|
-
type: 'dropdown',
|
|
114
|
-
options: alignmentItemOptions,
|
|
115
|
-
title: intl.formatMessage(currentAppearanceDisplayInformation.title),
|
|
116
|
-
iconBefore: currentAppearanceDisplayInformation.icon
|
|
117
|
-
};
|
|
118
|
-
return alignmentToolbarItem;
|
|
119
|
-
};
|
|
120
|
-
const CustomHyperlinkDropdown = props => {
|
|
121
|
-
var _props$cardOptions6;
|
|
122
|
-
const [supportedUrlsMap, setSupportedUrlsMap] = useState(new Map());
|
|
123
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
124
|
-
const cardProvider = useRef(undefined);
|
|
125
|
-
const containerRef = useRef(undefined);
|
|
126
|
-
const {
|
|
127
|
-
url,
|
|
128
|
-
intl,
|
|
129
|
-
editorView,
|
|
130
|
-
cardOptions,
|
|
131
|
-
editorAnalyticsApi,
|
|
132
|
-
allowDatasource,
|
|
133
|
-
isDatasourceView,
|
|
134
|
-
settingsConfig
|
|
135
|
-
} = props;
|
|
136
|
-
// Ignored via go/ees005
|
|
137
|
-
// eslint-disable-next-line require-await
|
|
138
|
-
const getProvider = async () => {
|
|
139
|
-
var _props$cardOptions4;
|
|
140
|
-
if ((_props$cardOptions4 = props.cardOptions) !== null && _props$cardOptions4 !== void 0 && _props$cardOptions4.provider) {
|
|
141
|
-
var _props$cardOptions5;
|
|
142
|
-
return (_props$cardOptions5 = props.cardOptions) === null || _props$cardOptions5 === void 0 ? void 0 : _props$cardOptions5.provider;
|
|
143
|
-
}
|
|
144
|
-
if (cardProvider.current) {
|
|
145
|
-
return cardProvider.current;
|
|
146
|
-
}
|
|
147
|
-
return new Promise(resolve => {
|
|
148
|
-
var _props$editorPluginAp5, _props$editorPluginAp6, _props$editorPluginAp7, _props$editorPluginAp8;
|
|
149
|
-
const cardProvider = (_props$editorPluginAp5 = props.editorPluginApi) === null || _props$editorPluginAp5 === void 0 ? void 0 : (_props$editorPluginAp6 = _props$editorPluginAp5.card) === null || _props$editorPluginAp6 === void 0 ? void 0 : (_props$editorPluginAp7 = _props$editorPluginAp6.sharedState) === null || _props$editorPluginAp7 === void 0 ? void 0 : (_props$editorPluginAp8 = _props$editorPluginAp7.currentState()) === null || _props$editorPluginAp8 === void 0 ? void 0 : _props$editorPluginAp8.provider;
|
|
150
|
-
if (cardProvider) {
|
|
151
|
-
resolve(cardProvider);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
const resolveUrl = async url => {
|
|
156
|
-
if (supportedUrlsMap.has(url)) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
let isUrlSupported = false;
|
|
160
|
-
try {
|
|
161
|
-
var _await$provider$findP2;
|
|
162
|
-
const provider = await getProvider();
|
|
163
|
-
isUrlSupported = (_await$provider$findP2 = await (provider === null || provider === void 0 ? void 0 : provider.findPattern(url))) !== null && _await$provider$findP2 !== void 0 ? _await$provider$findP2 : false;
|
|
164
|
-
} catch (error) {
|
|
165
|
-
isUrlSupported = false;
|
|
166
|
-
}
|
|
167
|
-
const newMap = new Map(supportedUrlsMap);
|
|
168
|
-
newMap.set(url, isUrlSupported);
|
|
169
|
-
setSupportedUrlsMap(newMap);
|
|
170
|
-
};
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
resolveUrl(url);
|
|
173
|
-
// before migrating from a class to a functional component, we were only reacting to changes in the url
|
|
174
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
175
|
-
}, [url, (_props$cardOptions6 = props.cardOptions) === null || _props$cardOptions6 === void 0 ? void 0 : _props$cardOptions6.provider, props.editorPluginApi]);
|
|
176
|
-
if (!supportedUrlsMap.get(url)) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
67
|
if (!editorView) {
|
|
180
68
|
return null;
|
|
181
69
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
3
2
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
4
3
|
/**
|
|
@@ -50,6 +49,9 @@ const linkStyles = xcss({
|
|
|
50
49
|
textDecoration: 'none'
|
|
51
50
|
}
|
|
52
51
|
});
|
|
52
|
+
const linkStylesFix = xcss({
|
|
53
|
+
whiteSpace: 'nowrap'
|
|
54
|
+
});
|
|
53
55
|
const MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY = 45;
|
|
54
56
|
const ICON_WIDTH = 16;
|
|
55
57
|
const DEFAULT_OPEN_TEXT_WIDTH = 28; // Default open text width in English
|
|
@@ -58,6 +60,7 @@ const OpenButtonOverlay = ({
|
|
|
58
60
|
children,
|
|
59
61
|
isVisible = false,
|
|
60
62
|
url,
|
|
63
|
+
editorAppearance,
|
|
61
64
|
...props
|
|
62
65
|
}) => {
|
|
63
66
|
// TODO: ED-26961 - add translation
|
|
@@ -108,52 +111,29 @@ const OpenButtonOverlay = ({
|
|
|
108
111
|
const handleOverlayChange = isHovered => {
|
|
109
112
|
setHovered(isHovered);
|
|
110
113
|
};
|
|
111
|
-
if (fg('platform_editor_controls_patch_1')) {
|
|
112
|
-
return (
|
|
113
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
114
|
-
jsx("span", {
|
|
115
|
-
ref: containerRef,
|
|
116
|
-
css: containerStyles,
|
|
117
|
-
onDoubleClick: handleDoubleClick,
|
|
118
|
-
onMouseEnter: () => handleOverlayChange(true),
|
|
119
|
-
onMouseLeave: () => handleOverlayChange(false)
|
|
120
|
-
}, children, fg('platform_editor_controls_patch_2') && jsx("span", {
|
|
121
|
-
css: hiddenTextStyle,
|
|
122
|
-
"aria-hidden": "true"
|
|
123
|
-
}, jsx(Text, {
|
|
124
|
-
ref: hiddenTextRef,
|
|
125
|
-
size: "small",
|
|
126
|
-
maxLines: 1
|
|
127
|
-
}, label)), isHovered && jsx(Anchor, {
|
|
128
|
-
ref: openButtonRef,
|
|
129
|
-
xcss: linkStyles,
|
|
130
|
-
href: url,
|
|
131
|
-
target: "_blank"
|
|
132
|
-
}, jsx(Box, {
|
|
133
|
-
xcss: iconWrapperStyles,
|
|
134
|
-
"data-inlinecard-button-overlay": "icon-wrapper-line-height"
|
|
135
|
-
}, jsx(LinkExternalIcon, {
|
|
136
|
-
label: ""
|
|
137
|
-
})), showLabel && jsx(Text, {
|
|
138
|
-
size: "small",
|
|
139
|
-
color: "color.text.subtle",
|
|
140
|
-
maxLines: 1
|
|
141
|
-
}, label)))
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
114
|
return (
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
ref: containerRef
|
|
149
|
-
}, props, {
|
|
115
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
116
|
+
jsx("span", {
|
|
117
|
+
ref: containerRef,
|
|
150
118
|
css: containerStyles,
|
|
151
|
-
onDoubleClick: handleDoubleClick
|
|
152
|
-
|
|
119
|
+
onDoubleClick: handleDoubleClick,
|
|
120
|
+
onMouseEnter: () => handleOverlayChange(true),
|
|
121
|
+
onMouseLeave: () => handleOverlayChange(false)
|
|
122
|
+
}, children, fg('platform_editor_controls_patch_2') && jsx("span", {
|
|
123
|
+
css: hiddenTextStyle,
|
|
124
|
+
"aria-hidden": "true"
|
|
125
|
+
}, jsx(Text, {
|
|
126
|
+
ref: hiddenTextRef,
|
|
127
|
+
size: "small",
|
|
128
|
+
maxLines: 1
|
|
129
|
+
}, label)), isHovered && jsx(Anchor, {
|
|
153
130
|
ref: openButtonRef,
|
|
154
|
-
xcss: linkStyles,
|
|
131
|
+
xcss: [linkStyles, fg('platform_editor_controls_patch_5') && linkStylesFix],
|
|
155
132
|
href: url,
|
|
156
|
-
target: "_blank"
|
|
133
|
+
target: "_blank",
|
|
134
|
+
style: {
|
|
135
|
+
paddingBlock: editorAppearance === 'comment' && fg('platform_editor_controls_patch_6') ? '1px' : "var(--ds-space-025, 2px)"
|
|
136
|
+
}
|
|
157
137
|
}, jsx(Box, {
|
|
158
138
|
xcss: iconWrapperStyles,
|
|
159
139
|
"data-inlinecard-button-overlay": "icon-wrapper-line-height"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -21,7 +21,6 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
21
21
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
22
22
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
23
23
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
24
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
25
24
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
26
25
|
import { changeSelectedCardToText } from '../pm-plugins/doc';
|
|
27
26
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -30,7 +29,7 @@ import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
|
|
|
30
29
|
import { buildEditLinkToolbar, editLinkToolbarConfig, getEditLinkCallback } from './EditLinkToolbar';
|
|
31
30
|
import { EditToolbarButton } from './EditToolbarButton';
|
|
32
31
|
import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
|
|
33
|
-
import { getCustomHyperlinkAppearanceDropdown
|
|
32
|
+
import { getCustomHyperlinkAppearanceDropdown } from './HyperlinkToolbarAppearanceDropdown';
|
|
34
33
|
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
35
34
|
import { getLinkAppearanceDropdown } from './LinkToolbarAppearanceDropdown';
|
|
36
35
|
import { ToolbarViewedEvent } from './ToolbarViewedEvent';
|
|
@@ -414,12 +413,12 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
414
413
|
});
|
|
415
414
|
}
|
|
416
415
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
417
|
-
const hoverDecorationProps = (nodeType, className) =>
|
|
416
|
+
const hoverDecorationProps = (nodeType, className) => ({
|
|
418
417
|
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
419
418
|
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
|
|
420
419
|
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
421
420
|
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
|
|
422
|
-
}
|
|
421
|
+
});
|
|
423
422
|
const overflowMenuConfig = [{
|
|
424
423
|
type: 'separator',
|
|
425
424
|
fullHeight: true
|
|
@@ -680,8 +679,8 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
680
679
|
type: 'separator'
|
|
681
680
|
}];
|
|
682
681
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
683
|
-
var _api$analytics2, _api$analytics3
|
|
684
|
-
const hyperlinkAppearance =
|
|
682
|
+
var _api$analytics2, _api$analytics3;
|
|
683
|
+
const hyperlinkAppearance = [getCustomHyperlinkAppearanceDropdown({
|
|
685
684
|
url: link,
|
|
686
685
|
intl,
|
|
687
686
|
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
@@ -690,19 +689,7 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
690
689
|
cardOptions: options,
|
|
691
690
|
settingsConfig: getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink),
|
|
692
691
|
isDatasourceView: false
|
|
693
|
-
})]
|
|
694
|
-
url: link,
|
|
695
|
-
intl,
|
|
696
|
-
editorState: state,
|
|
697
|
-
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
698
|
-
allowDatasource: options.allowDatasource,
|
|
699
|
-
editorPluginApi: api,
|
|
700
|
-
cardOptions: options,
|
|
701
|
-
settingsConfig: getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, options.userPreferencesLink),
|
|
702
|
-
isDatasourceView: false
|
|
703
|
-
}), {
|
|
704
|
-
type: 'separator'
|
|
705
|
-
}];
|
|
692
|
+
})];
|
|
706
693
|
return [{
|
|
707
694
|
type: 'custom',
|
|
708
695
|
fallback: [],
|
|
@@ -727,7 +714,7 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
727
714
|
type: 'custom',
|
|
728
715
|
fallback: [],
|
|
729
716
|
render: editorView => {
|
|
730
|
-
var _api$
|
|
717
|
+
var _api$analytics4;
|
|
731
718
|
if (!editorView) {
|
|
732
719
|
return null;
|
|
733
720
|
}
|
|
@@ -738,7 +725,7 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
738
725
|
editorView: editorView,
|
|
739
726
|
editorState: editorView.state,
|
|
740
727
|
cardOptions: options,
|
|
741
|
-
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$
|
|
728
|
+
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
742
729
|
editorPluginApi: api
|
|
743
730
|
});
|
|
744
731
|
}
|
|
@@ -751,10 +738,10 @@ export const getEndingToolbarItems = (options, api) => (intl, link) => {
|
|
|
751
738
|
* Or explicit user preferences config in order to enable button
|
|
752
739
|
*/
|
|
753
740
|
if ((options.provider || options.userPreferencesLink) && editorExperiment('platform_editor_controls', 'control')) {
|
|
754
|
-
var _api$
|
|
741
|
+
var _api$analytics5;
|
|
755
742
|
return [{
|
|
756
743
|
type: 'separator'
|
|
757
|
-
}, getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$
|
|
744
|
+
}, getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, options.userPreferencesLink)];
|
|
758
745
|
}
|
|
759
746
|
return [];
|
|
760
747
|
};
|
|
@@ -9,6 +9,7 @@ import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
|
9
9
|
import OpenButtonOverlay from '../ui/OpenButtonOverlay';
|
|
10
10
|
import { InlineCard } from './inlineCard';
|
|
11
11
|
export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var _pluginInjectionApi$c;
|
|
12
13
|
var node = _ref.node,
|
|
13
14
|
cardContext = _ref.cardContext,
|
|
14
15
|
actionOptions = _ref.actionOptions,
|
|
@@ -34,6 +35,7 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
34
35
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
36
|
isResolvedViewRendered = _useState6[0],
|
|
36
37
|
setIsResolvedViewRendered = _useState6[1];
|
|
38
|
+
var editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
|
|
37
39
|
var onResolve = useCallback(function (tr, title) {
|
|
38
40
|
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
39
41
|
var metadata = tr.getMeta(pluginKey);
|
|
@@ -70,7 +72,8 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
70
72
|
var innerCardWithOpenButtonOverlay = useMemo(function () {
|
|
71
73
|
return /*#__PURE__*/React.createElement(OpenButtonOverlay, {
|
|
72
74
|
isVisible: isResolvedViewRendered,
|
|
73
|
-
url: node.attrs.url
|
|
75
|
+
url: node.attrs.url,
|
|
76
|
+
editorAppearance: editorAppearance
|
|
74
77
|
}, /*#__PURE__*/React.createElement(InlineCard, {
|
|
75
78
|
node: node,
|
|
76
79
|
view: view,
|
|
@@ -83,7 +86,7 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
83
86
|
isHovered: isHovered,
|
|
84
87
|
isPageSSRed: isPageSSRed
|
|
85
88
|
}));
|
|
86
|
-
}, [isResolvedViewRendered, node, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed]);
|
|
89
|
+
}, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed]);
|
|
87
90
|
var innerCardOriginal = useMemo(function () {
|
|
88
91
|
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
89
92
|
node: node,
|
|
@@ -98,7 +101,10 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
98
101
|
isPageSSRed: isPageSSRed
|
|
99
102
|
});
|
|
100
103
|
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed]);
|
|
101
|
-
var
|
|
104
|
+
var shouldShowOpenButtonOverlay = useMemo(function () {
|
|
105
|
+
return ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit' || editorAppearance === 'comment' && fg('platform_editor_controls_patch_6')) && editorExperiment('platform_editor_controls', 'variant1');
|
|
106
|
+
}, [editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode, editorAppearance]);
|
|
107
|
+
var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
102
108
|
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
103
109
|
isOverlayEnabled: isOverlayEnabled,
|
|
104
110
|
isPulseEnabled: isPulseEnabled,
|
|
@@ -8,13 +8,11 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
|
|
14
13
|
import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
|
|
15
14
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
16
15
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../local-storage';
|
|
17
|
-
import OpenButtonOverlay from '../OpenButtonOverlay';
|
|
18
16
|
import { DiscoveryPulse } from '../Pulse';
|
|
19
17
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
20
18
|
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
@@ -79,7 +77,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
79
77
|
setOverlayHoveredStyles(isHovered);
|
|
80
78
|
}, [setOverlayHoveredStyles]);
|
|
81
79
|
var cardWithOverlay = useMemo(function () {
|
|
82
|
-
if (shouldShowLinkOverlay && !
|
|
80
|
+
if (shouldShowLinkOverlay && !editorExperiment('platform_editor_controls', 'variant1')) {
|
|
83
81
|
return jsx(InlineCardOverlay, {
|
|
84
82
|
isSelected: isSelected,
|
|
85
83
|
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
@@ -94,18 +92,6 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
94
92
|
}
|
|
95
93
|
return children;
|
|
96
94
|
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
97
|
-
var cardWithOpenButtonOverlay = useMemo(function () {
|
|
98
|
-
return jsx(OpenButtonOverlay, {
|
|
99
|
-
isVisible: isResolvedViewRendered && isHovered,
|
|
100
|
-
onMouseEnter: function onMouseEnter() {
|
|
101
|
-
return handleOverlayChange(true);
|
|
102
|
-
},
|
|
103
|
-
onMouseLeave: function onMouseLeave() {
|
|
104
|
-
return handleOverlayChange(false);
|
|
105
|
-
},
|
|
106
|
-
url: url
|
|
107
|
-
}, children);
|
|
108
|
-
}, [children, isHovered, url, handleOverlayChange, isResolvedViewRendered]);
|
|
109
95
|
var isInline = appearance === 'inline';
|
|
110
96
|
return useMemo(function () {
|
|
111
97
|
var _cardContext$value;
|
|
@@ -125,7 +111,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
125
111
|
shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
|
|
126
112
|
testId: "link-discovery-pulse",
|
|
127
113
|
isInline: isInline
|
|
128
|
-
},
|
|
114
|
+
}, cardWithOverlay)))
|
|
129
115
|
);
|
|
130
|
-
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay,
|
|
116
|
+
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, isInline]);
|
|
131
117
|
};
|