@atlaskit/editor-plugin-card 5.4.11 → 5.4.12
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 +9 -0
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +1 -1
- package/dist/cjs/ui/AwarenessWrapper/index.js +3 -17
- package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +19 -194
- package/dist/cjs/ui/OpenButtonOverlay/index.js +18 -45
- package/dist/cjs/ui/toolbar.js +9 -22
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +1 -1
- package/dist/es2019/ui/AwarenessWrapper/index.js +3 -13
- package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +6 -118
- package/dist/es2019/ui/OpenButtonOverlay/index.js +14 -41
- package/dist/es2019/ui/toolbar.js +10 -23
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +1 -1
- package/dist/esm/ui/AwarenessWrapper/index.js +3 -17
- package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +18 -193
- package/dist/esm/ui/OpenButtonOverlay/index.js +18 -45
- package/dist/esm/ui/toolbar.js +10 -23
- package/dist/types/ui/HyperlinkToolbarAppearanceDropdown.d.ts +1 -8
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearanceDropdown.d.ts +1 -8
- package/package.json +9 -12
|
@@ -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
|
/**
|
|
@@ -108,48 +107,22 @@ const OpenButtonOverlay = ({
|
|
|
108
107
|
const handleOverlayChange = isHovered => {
|
|
109
108
|
setHovered(isHovered);
|
|
110
109
|
};
|
|
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
110
|
return (
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
ref: containerRef
|
|
149
|
-
}, props, {
|
|
111
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
112
|
+
jsx("span", {
|
|
113
|
+
ref: containerRef,
|
|
150
114
|
css: containerStyles,
|
|
151
|
-
onDoubleClick: handleDoubleClick
|
|
152
|
-
|
|
115
|
+
onDoubleClick: handleDoubleClick,
|
|
116
|
+
onMouseEnter: () => handleOverlayChange(true),
|
|
117
|
+
onMouseLeave: () => handleOverlayChange(false)
|
|
118
|
+
}, children, fg('platform_editor_controls_patch_2') && jsx("span", {
|
|
119
|
+
css: hiddenTextStyle,
|
|
120
|
+
"aria-hidden": "true"
|
|
121
|
+
}, jsx(Text, {
|
|
122
|
+
ref: hiddenTextRef,
|
|
123
|
+
size: "small",
|
|
124
|
+
maxLines: 1
|
|
125
|
+
}, label)), isHovered && jsx(Anchor, {
|
|
153
126
|
ref: openButtonRef,
|
|
154
127
|
xcss: linkStyles,
|
|
155
128
|
href: url,
|
|
@@ -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
|
};
|
|
@@ -98,7 +98,7 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
98
98
|
isPageSSRed: isPageSSRed
|
|
99
99
|
});
|
|
100
100
|
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed]);
|
|
101
|
-
var innerCard = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit' && editorExperiment('platform_editor_controls', 'variant1')
|
|
101
|
+
var innerCard = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit' && editorExperiment('platform_editor_controls', 'variant1') ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
102
102
|
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
103
103
|
isOverlayEnabled: isOverlayEnabled,
|
|
104
104
|
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
|
};
|
|
@@ -8,20 +8,26 @@ import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlask
|
|
|
8
8
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
9
9
|
import { Flex } from '@atlaskit/primitives';
|
|
10
10
|
import { LinkAppearanceMenu } from './LinkToolbarAppearanceDropdown';
|
|
11
|
-
var
|
|
11
|
+
var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
12
12
|
var _props$cardOptions3;
|
|
13
13
|
var _useState = useState(new Map()),
|
|
14
14
|
_useState2 = _slicedToArray(_useState, 2),
|
|
15
15
|
supportedUrlsMap = _useState2[0],
|
|
16
16
|
setSupportedUrlsMap = _useState2[1];
|
|
17
|
+
var _useState3 = useState(false),
|
|
18
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19
|
+
isOpen = _useState4[0],
|
|
20
|
+
setIsOpen = _useState4[1];
|
|
17
21
|
var cardProvider = useRef(undefined);
|
|
22
|
+
var containerRef = useRef(undefined);
|
|
18
23
|
var url = props.url,
|
|
19
24
|
intl = props.intl,
|
|
20
|
-
|
|
25
|
+
editorView = props.editorView,
|
|
21
26
|
cardOptions = props.cardOptions,
|
|
22
27
|
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
23
28
|
allowDatasource = props.allowDatasource,
|
|
24
|
-
isDatasourceView = props.isDatasourceView
|
|
29
|
+
isDatasourceView = props.isDatasourceView,
|
|
30
|
+
settingsConfig = props.settingsConfig;
|
|
25
31
|
// Ignored via go/ees005
|
|
26
32
|
// eslint-disable-next-line require-await
|
|
27
33
|
var getProvider = /*#__PURE__*/function () {
|
|
@@ -128,187 +134,6 @@ var HyperlinkDropdown = function HyperlinkDropdown(props) {
|
|
|
128
134
|
if (!supportedUrlsMap.get(url)) {
|
|
129
135
|
return null;
|
|
130
136
|
}
|
|
131
|
-
return /*#__PURE__*/React.createElement(LinkAppearanceMenu, {
|
|
132
|
-
url: url,
|
|
133
|
-
intl: intl,
|
|
134
|
-
editorState: editorState,
|
|
135
|
-
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
136
|
-
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
137
|
-
allowDatasource: allowDatasource,
|
|
138
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
139
|
-
dispatchCommand: props.dispatchCommand,
|
|
140
|
-
settingsConfig: props.settingsConfig,
|
|
141
|
-
isDatasourceView: isDatasourceView
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
export var getHyperlinkAppearanceDropdown = function getHyperlinkAppearanceDropdown(_ref3) {
|
|
145
|
-
var url = _ref3.url,
|
|
146
|
-
intl = _ref3.intl,
|
|
147
|
-
editorState = _ref3.editorState,
|
|
148
|
-
editorAnalyticsApi = _ref3.editorAnalyticsApi,
|
|
149
|
-
editorPluginApi = _ref3.editorPluginApi,
|
|
150
|
-
settingsConfig = _ref3.settingsConfig,
|
|
151
|
-
cardOptions = _ref3.cardOptions,
|
|
152
|
-
allowDatasource = _ref3.allowDatasource,
|
|
153
|
-
isDatasourceView = _ref3.isDatasourceView;
|
|
154
|
-
var alignmentItemOptions = {
|
|
155
|
-
render: function render(props) {
|
|
156
|
-
if (!editorState) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
return /*#__PURE__*/React.createElement(HyperlinkDropdown, {
|
|
160
|
-
intl: intl,
|
|
161
|
-
editorState: editorState,
|
|
162
|
-
url: url,
|
|
163
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
164
|
-
editorPluginApi: editorPluginApi,
|
|
165
|
-
dispatchCommand: props.dispatchCommand,
|
|
166
|
-
settingsConfig: settingsConfig,
|
|
167
|
-
cardOptions: cardOptions,
|
|
168
|
-
allowDatasource: allowDatasource,
|
|
169
|
-
isDatasourceView: isDatasourceView
|
|
170
|
-
});
|
|
171
|
-
},
|
|
172
|
-
width: 200,
|
|
173
|
-
height: 400
|
|
174
|
-
};
|
|
175
|
-
var currentAppearanceDisplayInformation = appearancePropsMap['url'];
|
|
176
|
-
var alignmentToolbarItem = {
|
|
177
|
-
id: 'hyperlink-appearance',
|
|
178
|
-
testId: 'hyperlink-appearance-dropdown',
|
|
179
|
-
type: 'dropdown',
|
|
180
|
-
options: alignmentItemOptions,
|
|
181
|
-
title: intl.formatMessage(currentAppearanceDisplayInformation.title),
|
|
182
|
-
iconBefore: currentAppearanceDisplayInformation.icon
|
|
183
|
-
};
|
|
184
|
-
return alignmentToolbarItem;
|
|
185
|
-
};
|
|
186
|
-
var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
187
|
-
var _props$cardOptions6;
|
|
188
|
-
var _useState3 = useState(new Map()),
|
|
189
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
190
|
-
supportedUrlsMap = _useState4[0],
|
|
191
|
-
setSupportedUrlsMap = _useState4[1];
|
|
192
|
-
var _useState5 = useState(false),
|
|
193
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
194
|
-
isOpen = _useState6[0],
|
|
195
|
-
setIsOpen = _useState6[1];
|
|
196
|
-
var cardProvider = useRef(undefined);
|
|
197
|
-
var containerRef = useRef(undefined);
|
|
198
|
-
var url = props.url,
|
|
199
|
-
intl = props.intl,
|
|
200
|
-
editorView = props.editorView,
|
|
201
|
-
cardOptions = props.cardOptions,
|
|
202
|
-
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
203
|
-
allowDatasource = props.allowDatasource,
|
|
204
|
-
isDatasourceView = props.isDatasourceView,
|
|
205
|
-
settingsConfig = props.settingsConfig;
|
|
206
|
-
// Ignored via go/ees005
|
|
207
|
-
// eslint-disable-next-line require-await
|
|
208
|
-
var getProvider = /*#__PURE__*/function () {
|
|
209
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
210
|
-
var _props$cardOptions4;
|
|
211
|
-
var _props$cardOptions5;
|
|
212
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
213
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
214
|
-
case 0:
|
|
215
|
-
if (!((_props$cardOptions4 = props.cardOptions) !== null && _props$cardOptions4 !== void 0 && _props$cardOptions4.provider)) {
|
|
216
|
-
_context3.next = 2;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
return _context3.abrupt("return", (_props$cardOptions5 = props.cardOptions) === null || _props$cardOptions5 === void 0 ? void 0 : _props$cardOptions5.provider);
|
|
220
|
-
case 2:
|
|
221
|
-
if (!cardProvider.current) {
|
|
222
|
-
_context3.next = 4;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
return _context3.abrupt("return", cardProvider.current);
|
|
226
|
-
case 4:
|
|
227
|
-
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
228
|
-
var _props$editorPluginAp2;
|
|
229
|
-
var cardProvider = (_props$editorPluginAp2 = props.editorPluginApi) === null || _props$editorPluginAp2 === void 0 || (_props$editorPluginAp2 = _props$editorPluginAp2.card) === null || _props$editorPluginAp2 === void 0 || (_props$editorPluginAp2 = _props$editorPluginAp2.sharedState) === null || _props$editorPluginAp2 === void 0 || (_props$editorPluginAp2 = _props$editorPluginAp2.currentState()) === null || _props$editorPluginAp2 === void 0 ? void 0 : _props$editorPluginAp2.provider;
|
|
230
|
-
if (cardProvider) {
|
|
231
|
-
resolve(cardProvider);
|
|
232
|
-
}
|
|
233
|
-
}));
|
|
234
|
-
case 5:
|
|
235
|
-
case "end":
|
|
236
|
-
return _context3.stop();
|
|
237
|
-
}
|
|
238
|
-
}, _callee3);
|
|
239
|
-
}));
|
|
240
|
-
return function getProvider() {
|
|
241
|
-
return _ref4.apply(this, arguments);
|
|
242
|
-
};
|
|
243
|
-
}();
|
|
244
|
-
var resolveUrl = /*#__PURE__*/function () {
|
|
245
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url) {
|
|
246
|
-
var isUrlSupported, _yield$provider$findP2, provider, newMap;
|
|
247
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
248
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
249
|
-
case 0:
|
|
250
|
-
if (!supportedUrlsMap.has(url)) {
|
|
251
|
-
_context4.next = 2;
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
return _context4.abrupt("return");
|
|
255
|
-
case 2:
|
|
256
|
-
isUrlSupported = false;
|
|
257
|
-
_context4.prev = 3;
|
|
258
|
-
_context4.next = 6;
|
|
259
|
-
return getProvider();
|
|
260
|
-
case 6:
|
|
261
|
-
provider = _context4.sent;
|
|
262
|
-
_context4.next = 9;
|
|
263
|
-
return provider === null || provider === void 0 ? void 0 : provider.findPattern(url);
|
|
264
|
-
case 9:
|
|
265
|
-
_context4.t1 = _yield$provider$findP2 = _context4.sent;
|
|
266
|
-
_context4.t0 = _context4.t1 !== null;
|
|
267
|
-
if (!_context4.t0) {
|
|
268
|
-
_context4.next = 13;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
_context4.t0 = _yield$provider$findP2 !== void 0;
|
|
272
|
-
case 13:
|
|
273
|
-
if (!_context4.t0) {
|
|
274
|
-
_context4.next = 17;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
_context4.t2 = _yield$provider$findP2;
|
|
278
|
-
_context4.next = 18;
|
|
279
|
-
break;
|
|
280
|
-
case 17:
|
|
281
|
-
_context4.t2 = false;
|
|
282
|
-
case 18:
|
|
283
|
-
isUrlSupported = _context4.t2;
|
|
284
|
-
_context4.next = 24;
|
|
285
|
-
break;
|
|
286
|
-
case 21:
|
|
287
|
-
_context4.prev = 21;
|
|
288
|
-
_context4.t3 = _context4["catch"](3);
|
|
289
|
-
isUrlSupported = false;
|
|
290
|
-
case 24:
|
|
291
|
-
newMap = new Map(supportedUrlsMap);
|
|
292
|
-
newMap.set(url, isUrlSupported);
|
|
293
|
-
setSupportedUrlsMap(newMap);
|
|
294
|
-
case 27:
|
|
295
|
-
case "end":
|
|
296
|
-
return _context4.stop();
|
|
297
|
-
}
|
|
298
|
-
}, _callee4, null, [[3, 21]]);
|
|
299
|
-
}));
|
|
300
|
-
return function resolveUrl(_x2) {
|
|
301
|
-
return _ref5.apply(this, arguments);
|
|
302
|
-
};
|
|
303
|
-
}();
|
|
304
|
-
useEffect(function () {
|
|
305
|
-
resolveUrl(url);
|
|
306
|
-
// before migrating from a class to a functional component, we were only reacting to changes in the url
|
|
307
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
308
|
-
}, [url, (_props$cardOptions6 = props.cardOptions) === null || _props$cardOptions6 === void 0 ? void 0 : _props$cardOptions6.provider, props.editorPluginApi]);
|
|
309
|
-
if (!supportedUrlsMap.get(url)) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
137
|
if (!editorView) {
|
|
313
138
|
return null;
|
|
314
139
|
}
|
|
@@ -373,15 +198,15 @@ var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
|
373
198
|
settingsConfig: settingsConfig
|
|
374
199
|
})), /*#__PURE__*/React.createElement(Separator, null));
|
|
375
200
|
};
|
|
376
|
-
export var getCustomHyperlinkAppearanceDropdown = function getCustomHyperlinkAppearanceDropdown(
|
|
377
|
-
var url =
|
|
378
|
-
intl =
|
|
379
|
-
editorAnalyticsApi =
|
|
380
|
-
editorPluginApi =
|
|
381
|
-
settingsConfig =
|
|
382
|
-
cardOptions =
|
|
383
|
-
allowDatasource =
|
|
384
|
-
isDatasourceView =
|
|
201
|
+
export var getCustomHyperlinkAppearanceDropdown = function getCustomHyperlinkAppearanceDropdown(_ref3) {
|
|
202
|
+
var url = _ref3.url,
|
|
203
|
+
intl = _ref3.intl,
|
|
204
|
+
editorAnalyticsApi = _ref3.editorAnalyticsApi,
|
|
205
|
+
editorPluginApi = _ref3.editorPluginApi,
|
|
206
|
+
settingsConfig = _ref3.settingsConfig,
|
|
207
|
+
cardOptions = _ref3.cardOptions,
|
|
208
|
+
allowDatasource = _ref3.allowDatasource,
|
|
209
|
+
isDatasourceView = _ref3.isDatasourceView;
|
|
385
210
|
return {
|
|
386
211
|
type: 'custom',
|
|
387
212
|
fallback: [],
|