@atlaskit/editor-plugin-card 37.0.1 → 39.0.0
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 +22 -0
- package/dist/cjs/nodeviews/blockCard.js +4 -8
- package/dist/cjs/nodeviews/inlineCardBase.js +4 -8
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +2 -6
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/pm-plugins/reducers.js +6 -13
- package/dist/cjs/ui/DatasourceAppearanceButton.js +4 -8
- package/dist/cjs/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
- package/dist/cjs/ui/EditToolbarButton/index.js +12 -24
- package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
- package/dist/cjs/ui/LinkToolbarAppearanceDropdown.js +39 -13
- package/dist/cjs/ui/OpenLinkToolbarButton/index.js +1 -3
- package/dist/cjs/ui/OpenPreviewButton/index.js +3 -26
- package/dist/cjs/ui/toolbar.js +127 -364
- package/dist/es2019/nodeviews/blockCard.js +4 -8
- package/dist/es2019/nodeviews/inlineCardBase.js +4 -8
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +2 -4
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/pm-plugins/reducers.js +5 -14
- package/dist/es2019/ui/DatasourceAppearanceButton.js +4 -8
- package/dist/es2019/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
- package/dist/es2019/ui/EditToolbarButton/index.js +12 -24
- package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
- package/dist/es2019/ui/LinkToolbarAppearanceDropdown.js +36 -10
- package/dist/es2019/ui/OpenLinkToolbarButton/index.js +1 -3
- package/dist/es2019/ui/OpenPreviewButton/index.js +3 -26
- package/dist/es2019/ui/toolbar.js +125 -352
- package/dist/esm/nodeviews/blockCard.js +4 -8
- package/dist/esm/nodeviews/inlineCardBase.js +4 -8
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +2 -6
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/pm-plugins/reducers.js +6 -13
- package/dist/esm/ui/DatasourceAppearanceButton.js +4 -8
- package/dist/esm/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
- package/dist/esm/ui/EditToolbarButton/index.js +12 -24
- package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
- package/dist/esm/ui/LinkToolbarAppearanceDropdown.js +36 -10
- package/dist/esm/ui/OpenLinkToolbarButton/index.js +1 -3
- package/dist/esm/ui/OpenPreviewButton/index.js +3 -26
- package/dist/esm/ui/toolbar.js +126 -361
- package/dist/types/ui/DatasourceAppearanceButton.d.ts +1 -2
- package/dist/types/ui/EditToolbarButton/EditToolbarButtonPresentation.d.ts +1 -1
- package/dist/types/ui/EditToolbarButton/types.d.ts +0 -1
- package/dist/types/ui/HyperlinkToolbarAppearanceDropdown.d.ts +16 -1
- package/dist/types/ui/LinkToolbarAppearanceDropdown.d.ts +24 -2
- package/dist/types/ui/OpenLinkToolbarButton/index.d.ts +1 -2
- package/dist/types/ui/OpenPreviewButton/index.d.ts +1 -2
- package/dist/types/ui/toolbar.d.ts +1 -2
- package/package.json +21 -21
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +0 -162
- package/dist/cjs/ui/LinkToolbarAppearance.js +0 -174
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +0 -86
- package/dist/es2019/ui/LinkToolbarAppearance.js +0 -145
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +0 -153
- package/dist/esm/ui/LinkToolbarAppearance.js +0 -167
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +0 -18
- package/dist/types/ui/LinkToolbarAppearance.d.ts +0 -25
|
@@ -67,9 +67,7 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
67
67
|
})(view.state.tr));
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
-
|
|
71
|
-
this.pendingRegisterCard = scheduleRegisterCard;
|
|
72
|
-
}
|
|
70
|
+
this.pendingRegisterCard = scheduleRegisterCard;
|
|
73
71
|
scheduleRegisterCard();
|
|
74
72
|
});
|
|
75
73
|
_defineProperty(this, "removeCardDispatched", false);
|
|
@@ -99,11 +97,9 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
99
97
|
findOverflowScrollParent(props.view.dom) || undefined;
|
|
100
98
|
}
|
|
101
99
|
componentWillUnmount() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.pendingRegisterCard = undefined;
|
|
106
|
-
}
|
|
100
|
+
var _this$pendingRegister;
|
|
101
|
+
(_this$pendingRegister = this.pendingRegisterCard) === null || _this$pendingRegister === void 0 ? void 0 : _this$pendingRegister.cancel();
|
|
102
|
+
this.pendingRegisterCard = undefined;
|
|
107
103
|
this.removeCard();
|
|
108
104
|
}
|
|
109
105
|
removeCard() {
|
|
@@ -37,11 +37,9 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
37
37
|
const pendingRegisterCard = useRef(null);
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
return () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
pendingRegisterCard.current = null;
|
|
44
|
-
}
|
|
40
|
+
var _pendingRegisterCard$;
|
|
41
|
+
(_pendingRegisterCard$ = pendingRegisterCard.current) === null || _pendingRegisterCard$ === void 0 ? void 0 : _pendingRegisterCard$.cancel();
|
|
42
|
+
pendingRegisterCard.current = null;
|
|
45
43
|
};
|
|
46
44
|
}, []);
|
|
47
45
|
const cardActions = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions;
|
|
@@ -115,9 +113,7 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
115
113
|
view.dispatch(tr);
|
|
116
114
|
}
|
|
117
115
|
});
|
|
118
|
-
|
|
119
|
-
pendingRegisterCard.current = scheduleRegisterCard;
|
|
120
|
-
}
|
|
116
|
+
pendingRegisterCard.current = scheduleRegisterCard;
|
|
121
117
|
scheduleRegisterCard();
|
|
122
118
|
}, [getPos, isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? undefined : view, onRes, isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? registerResolvedCard : undefined]);
|
|
123
119
|
const onError = useCallback(data => {
|
|
@@ -49,9 +49,7 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
49
49
|
const setIsInsertedRef = useRef(setIsInserted);
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
return () => {
|
|
52
|
-
|
|
53
|
-
setIsInsertedRef.current = undefined;
|
|
54
|
-
}
|
|
52
|
+
setIsInsertedRef.current = undefined;
|
|
55
53
|
};
|
|
56
54
|
}, []);
|
|
57
55
|
const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
|
|
@@ -62,7 +60,7 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
62
60
|
const onResolve = useCallback((tr, title) => {
|
|
63
61
|
if (tr) {
|
|
64
62
|
const metadata = tr.getMeta(pluginKey);
|
|
65
|
-
const removeOverlay =
|
|
63
|
+
const removeOverlay = createRemoveOverlay(setIsInsertedRef);
|
|
66
64
|
if (metadata && metadata.type === 'REGISTER') {
|
|
67
65
|
registerRemoveOverlay(removeOverlay, metadata.info)(tr);
|
|
68
66
|
} else {
|
|
@@ -251,11 +251,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
251
251
|
*/
|
|
252
252
|
const invoke = rafSchedule(() => {
|
|
253
253
|
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _pluginInjectionApi$a4, _currentState$embedCa;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
rafCancellationCallbacks.splice(index, 1);
|
|
258
|
-
}
|
|
254
|
+
const index = rafCancellationCallbacks.indexOf(invoke.cancel);
|
|
255
|
+
if (index !== -1) {
|
|
256
|
+
rafCancellationCallbacks.splice(index, 1);
|
|
259
257
|
}
|
|
260
258
|
resolveWithProvider(view, provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 ? void 0 : (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
261
259
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
1
|
import { removePastedInlineLink } from './util/pasted-inline-link';
|
|
3
2
|
const queue = (state, action) => {
|
|
4
3
|
return {
|
|
@@ -26,7 +25,7 @@ const register = (state, action) => {
|
|
|
26
25
|
};
|
|
27
26
|
const removeCard = (state, action) => {
|
|
28
27
|
const cards = state.cards.filter(card => card.id !== action.info.id);
|
|
29
|
-
if (
|
|
28
|
+
if (state.removeOverlayCardId !== undefined && state.removeOverlayCardId === action.info.id) {
|
|
30
29
|
return {
|
|
31
30
|
...state,
|
|
32
31
|
cards,
|
|
@@ -100,17 +99,11 @@ const hideDatasourceModal = state => {
|
|
|
100
99
|
};
|
|
101
100
|
};
|
|
102
101
|
const clearOverlayCandidate = state => {
|
|
103
|
-
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
104
|
-
return {
|
|
105
|
-
...state,
|
|
106
|
-
overlayCandidatePosition: undefined,
|
|
107
|
-
removeOverlay: undefined,
|
|
108
|
-
removeOverlayCardId: undefined
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
102
|
return {
|
|
112
103
|
...state,
|
|
113
|
-
overlayCandidatePosition: undefined
|
|
104
|
+
overlayCandidatePosition: undefined,
|
|
105
|
+
removeOverlay: undefined,
|
|
106
|
+
removeOverlayCardId: undefined
|
|
114
107
|
};
|
|
115
108
|
};
|
|
116
109
|
const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
@@ -122,9 +115,7 @@ const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
|
122
115
|
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
123
116
|
}).concat(action.info) : state.cards,
|
|
124
117
|
removeOverlay: action.callback,
|
|
125
|
-
|
|
126
|
-
removeOverlayCardId: (_action$info2 = action.info) === null || _action$info2 === void 0 ? void 0 : _action$info2.id
|
|
127
|
-
} : {})
|
|
118
|
+
removeOverlayCardId: (_action$info2 = action.info) === null || _action$info2 === void 0 ? void 0 : _action$info2.id
|
|
128
119
|
};
|
|
129
120
|
};
|
|
130
121
|
const setDatasourceStash = (state, action) => {
|
|
@@ -27,8 +27,7 @@ const DatasourceAppearanceButtonWithCardContext = ({
|
|
|
27
27
|
editorView,
|
|
28
28
|
editorState,
|
|
29
29
|
selected,
|
|
30
|
-
inputMethod
|
|
31
|
-
areAnyNewToolbarFlagsEnabled
|
|
30
|
+
inputMethod
|
|
32
31
|
}) => {
|
|
33
32
|
const {
|
|
34
33
|
datasourceId,
|
|
@@ -97,8 +96,7 @@ const DatasourceAppearanceButtonWithCardContext = ({
|
|
|
97
96
|
}),
|
|
98
97
|
selected: selected,
|
|
99
98
|
onClick: onChangeAppearance,
|
|
100
|
-
testId: 'card-datasource-appearance-button'
|
|
101
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
99
|
+
testId: 'card-datasource-appearance-button'
|
|
102
100
|
}));
|
|
103
101
|
};
|
|
104
102
|
export const DatasourceAppearanceButton = ({
|
|
@@ -108,8 +106,7 @@ export const DatasourceAppearanceButton = ({
|
|
|
108
106
|
editorView,
|
|
109
107
|
editorState,
|
|
110
108
|
selected,
|
|
111
|
-
inputMethod
|
|
112
|
-
areAnyNewToolbarFlagsEnabled
|
|
109
|
+
inputMethod
|
|
113
110
|
}) => {
|
|
114
111
|
const cardContext = useSmartLinkContext();
|
|
115
112
|
return jsx(DatasourceAppearanceButtonWithCardContext, {
|
|
@@ -120,7 +117,6 @@ export const DatasourceAppearanceButton = ({
|
|
|
120
117
|
editorState: editorState,
|
|
121
118
|
cardContext: cardContext,
|
|
122
119
|
selected: selected,
|
|
123
|
-
inputMethod: inputMethod
|
|
124
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
120
|
+
inputMethod: inputMethod
|
|
125
121
|
});
|
|
126
122
|
};
|
|
@@ -8,7 +8,6 @@ import { useCallback, useRef, useState } from 'react';
|
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { FormattedMessage } from 'react-intl';
|
|
10
10
|
import Button from '@atlaskit/editor-common/FloatingToolbar/Button';
|
|
11
|
-
import Separator from '@atlaskit/editor-common/FloatingToolbar/Separator';
|
|
12
11
|
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
13
12
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages/link-toolbar';
|
|
14
13
|
import { ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu/ArrowKeyNavigationProvider/types';
|
|
@@ -30,8 +29,7 @@ const EditToolbarButtonPresentation = ({
|
|
|
30
29
|
editorView,
|
|
31
30
|
extensionKey,
|
|
32
31
|
onLinkEditClick,
|
|
33
|
-
intl
|
|
34
|
-
areAnyNewToolbarFlagsEnabled
|
|
32
|
+
intl
|
|
35
33
|
}) => {
|
|
36
34
|
const [isOpen, setIsOpen] = useState(false);
|
|
37
35
|
const containerRef = useRef();
|
|
@@ -49,10 +47,7 @@ const EditToolbarButtonPresentation = ({
|
|
|
49
47
|
focusEditorView(editorView);
|
|
50
48
|
}
|
|
51
49
|
}, [currentAppearance, datasourceId, editorAnalyticsApi, editorView, extensionKey]);
|
|
52
|
-
const
|
|
53
|
-
label: ""
|
|
54
|
-
}) : undefined;
|
|
55
|
-
const tooltipContent = areAnyNewToolbarFlagsEnabled ? intl.formatMessage(linkToolbarMessages.editLink) : undefined;
|
|
50
|
+
const editLinkLabel = intl.formatMessage(linkToolbarMessages.editLink);
|
|
56
51
|
switch (editVariant) {
|
|
57
52
|
case 'edit-link':
|
|
58
53
|
{
|
|
@@ -61,15 +56,11 @@ const EditToolbarButtonPresentation = ({
|
|
|
61
56
|
}, jsx(Button, {
|
|
62
57
|
testId: "edit-link",
|
|
63
58
|
onClick: onEditLink,
|
|
64
|
-
icon:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Ignored via go/ees005
|
|
70
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
71
|
-
, linkToolbarMessages.editLink)), !areAnyNewToolbarFlagsEnabled && jsx(Separator, {
|
|
72
|
-
areAnyNewToolbarFlagsEnabled: false
|
|
59
|
+
icon: jsx(EditIcon, {
|
|
60
|
+
label: ""
|
|
61
|
+
}),
|
|
62
|
+
ariaLabel: editLinkLabel,
|
|
63
|
+
tooltipContent: editLinkLabel
|
|
73
64
|
}));
|
|
74
65
|
}
|
|
75
66
|
case 'edit-datasource':
|
|
@@ -79,14 +70,11 @@ const EditToolbarButtonPresentation = ({
|
|
|
79
70
|
}, jsx(Button, {
|
|
80
71
|
testId: "edit-datasource",
|
|
81
72
|
tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
|
|
82
|
-
onClick: onEditDatasource
|
|
83
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
73
|
+
onClick: onEditDatasource
|
|
84
74
|
}, jsx(FormattedMessage
|
|
85
75
|
// Ignored via go/ees005
|
|
86
76
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
87
|
-
, linkToolbarMessages.editDatasourceStandalone))
|
|
88
|
-
areAnyNewToolbarFlagsEnabled: false
|
|
89
|
-
}));
|
|
77
|
+
, linkToolbarMessages.editDatasourceStandalone)));
|
|
90
78
|
}
|
|
91
79
|
case 'edit-dropdown':
|
|
92
80
|
{
|
|
@@ -103,14 +91,11 @@ const EditToolbarButtonPresentation = ({
|
|
|
103
91
|
onClick: toggleOpen,
|
|
104
92
|
selected: isOpen,
|
|
105
93
|
disabled: false,
|
|
106
|
-
ariaHasPopup: true
|
|
107
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
94
|
+
ariaHasPopup: true
|
|
108
95
|
}, jsx(FormattedMessage
|
|
109
96
|
// Ignored via go/ees005
|
|
110
97
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
111
|
-
, messages.editDropdownTriggerTitle))
|
|
112
|
-
areAnyNewToolbarFlagsEnabled: false
|
|
113
|
-
}));
|
|
98
|
+
, messages.editDropdownTriggerTitle)));
|
|
114
99
|
return jsx(Flex, {
|
|
115
100
|
ref: containerRef
|
|
116
101
|
}, jsx(UiDropdown, {
|
|
@@ -33,8 +33,7 @@ const EditToolbarButtonWithCardContext = props => {
|
|
|
33
33
|
editorView,
|
|
34
34
|
intl,
|
|
35
35
|
onLinkEditClick,
|
|
36
|
-
url
|
|
37
|
-
areAnyNewToolbarFlagsEnabled
|
|
36
|
+
url
|
|
38
37
|
} = props;
|
|
39
38
|
const {
|
|
40
39
|
extensionKey,
|
|
@@ -87,8 +86,7 @@ const EditToolbarButtonWithCardContext = props => {
|
|
|
87
86
|
gap: "space.050"
|
|
88
87
|
}, jsx(Button, {
|
|
89
88
|
testId: "edit-link",
|
|
90
|
-
onClick: onEditLink
|
|
91
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
89
|
+
onClick: onEditLink
|
|
92
90
|
}, jsx(FormattedMessage
|
|
93
91
|
// Ignored via go/ees005
|
|
94
92
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -101,8 +99,7 @@ const EditToolbarButtonWithCardContext = props => {
|
|
|
101
99
|
}, jsx(Button, {
|
|
102
100
|
testId: "edit-datasource",
|
|
103
101
|
tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
|
|
104
|
-
onClick: onEditDatasource
|
|
105
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
102
|
+
onClick: onEditDatasource
|
|
106
103
|
}, jsx(FormattedMessage
|
|
107
104
|
// Ignored via go/ees005
|
|
108
105
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -123,8 +120,7 @@ const EditToolbarButtonWithCardContext = props => {
|
|
|
123
120
|
onClick: toggleOpen,
|
|
124
121
|
selected: isOpen,
|
|
125
122
|
disabled: false,
|
|
126
|
-
ariaHasPopup: true
|
|
127
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
123
|
+
ariaHasPopup: true
|
|
128
124
|
}, jsx(FormattedMessage
|
|
129
125
|
// Ignored via go/ees005
|
|
130
126
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -173,8 +169,7 @@ const EditToolbarButtonWithUrl = props => {
|
|
|
173
169
|
editorView,
|
|
174
170
|
intl,
|
|
175
171
|
onLinkEditClick,
|
|
176
|
-
url
|
|
177
|
-
areAnyNewToolbarFlagsEnabled
|
|
172
|
+
url
|
|
178
173
|
} = props;
|
|
179
174
|
const {
|
|
180
175
|
extensionKey,
|
|
@@ -204,8 +199,7 @@ const EditToolbarButtonWithUrl = props => {
|
|
|
204
199
|
editorView: editorView,
|
|
205
200
|
extensionKey: extensionKey,
|
|
206
201
|
onLinkEditClick: onLinkEditClick,
|
|
207
|
-
intl: intl
|
|
208
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
202
|
+
intl: intl
|
|
209
203
|
});
|
|
210
204
|
};
|
|
211
205
|
const EditToolbarButtonWithDatasourceId = props => {
|
|
@@ -216,8 +210,7 @@ const EditToolbarButtonWithDatasourceId = props => {
|
|
|
216
210
|
intl,
|
|
217
211
|
onLinkEditClick,
|
|
218
212
|
datasourceId,
|
|
219
|
-
node
|
|
220
|
-
areAnyNewToolbarFlagsEnabled
|
|
213
|
+
node
|
|
221
214
|
} = props;
|
|
222
215
|
const fetchData = useMemo(() => {
|
|
223
216
|
try {
|
|
@@ -255,8 +248,7 @@ const EditToolbarButtonWithDatasourceId = props => {
|
|
|
255
248
|
editorView: editorView,
|
|
256
249
|
extensionKey: extensionKey,
|
|
257
250
|
onLinkEditClick: onLinkEditClick,
|
|
258
|
-
intl: intl
|
|
259
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
251
|
+
intl: intl
|
|
260
252
|
});
|
|
261
253
|
};
|
|
262
254
|
export const EditToolbarButton = props => {
|
|
@@ -267,8 +259,7 @@ export const EditToolbarButton = props => {
|
|
|
267
259
|
editorView,
|
|
268
260
|
intl,
|
|
269
261
|
onLinkEditClick,
|
|
270
|
-
url
|
|
271
|
-
areAnyNewToolbarFlagsEnabled
|
|
262
|
+
url
|
|
272
263
|
} = props;
|
|
273
264
|
const cardContext = useSmartLinkContext();
|
|
274
265
|
if (props.url) {
|
|
@@ -280,8 +271,7 @@ export const EditToolbarButton = props => {
|
|
|
280
271
|
editorView: editorView,
|
|
281
272
|
cardContext: cardContext,
|
|
282
273
|
onLinkEditClick: onLinkEditClick,
|
|
283
|
-
currentAppearance: currentAppearance
|
|
284
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
274
|
+
currentAppearance: currentAppearance
|
|
285
275
|
});
|
|
286
276
|
}
|
|
287
277
|
if (props.datasourceId && props.node) {
|
|
@@ -292,8 +282,7 @@ export const EditToolbarButton = props => {
|
|
|
292
282
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
293
283
|
editorView: editorView,
|
|
294
284
|
onLinkEditClick: onLinkEditClick,
|
|
295
|
-
currentAppearance: currentAppearance
|
|
296
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
285
|
+
currentAppearance: currentAppearance
|
|
297
286
|
});
|
|
298
287
|
}
|
|
299
288
|
return jsx(EditToolbarButtonWithCardContext, {
|
|
@@ -304,7 +293,6 @@ export const EditToolbarButton = props => {
|
|
|
304
293
|
editorView: editorView,
|
|
305
294
|
cardContext: cardContext,
|
|
306
295
|
onLinkEditClick: onLinkEditClick,
|
|
307
|
-
currentAppearance: currentAppearance
|
|
308
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
296
|
+
currentAppearance: currentAppearance
|
|
309
297
|
});
|
|
310
298
|
};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { appearancePropsMap } from '@atlaskit/editor-common/card';
|
|
3
3
|
import Button from '@atlaskit/editor-common/FloatingToolbar/Button';
|
|
4
|
-
import Separator from '@atlaskit/editor-common/FloatingToolbar/Separator';
|
|
5
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
6
4
|
import { ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu/ArrowKeyNavigationProvider/types';
|
|
7
5
|
import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu/DropdownContainer';
|
|
8
6
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
9
7
|
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
10
8
|
import { LinkAppearanceMenu } from './LinkToolbarAppearanceDropdown';
|
|
11
9
|
const CustomHyperlinkDropdown = props => {
|
|
12
|
-
var _props$
|
|
10
|
+
var _props$cardOptions3;
|
|
13
11
|
const [supportedUrlsMap, setSupportedUrlsMap] = useState(new Map());
|
|
14
12
|
const [isOpen, setIsOpen] = useState(false);
|
|
15
13
|
const cardProvider = useRef(undefined);
|
|
16
14
|
const containerRef = useRef(undefined);
|
|
17
|
-
const areAnyNewToolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean((_props$editorPluginAp = props.editorPluginApi) === null || _props$editorPluginAp === void 0 ? void 0 : _props$editorPluginAp.toolbar));
|
|
18
15
|
const {
|
|
19
16
|
url,
|
|
20
17
|
intl,
|
|
@@ -37,8 +34,8 @@ const CustomHyperlinkDropdown = props => {
|
|
|
37
34
|
return cardProvider.current;
|
|
38
35
|
}
|
|
39
36
|
return new Promise(resolve => {
|
|
40
|
-
var _props$
|
|
41
|
-
const cardProvider = (_props$
|
|
37
|
+
var _props$editorPluginAp, _props$editorPluginAp2, _props$editorPluginAp3, _props$editorPluginAp4;
|
|
38
|
+
const cardProvider = (_props$editorPluginAp = props.editorPluginApi) === null || _props$editorPluginAp === void 0 ? void 0 : (_props$editorPluginAp2 = _props$editorPluginAp.card) === null || _props$editorPluginAp2 === void 0 ? void 0 : (_props$editorPluginAp3 = _props$editorPluginAp2.sharedState) === null || _props$editorPluginAp3 === void 0 ? void 0 : (_props$editorPluginAp4 = _props$editorPluginAp3.currentState()) === null || _props$editorPluginAp4 === void 0 ? void 0 : _props$editorPluginAp4.provider;
|
|
42
39
|
if (cardProvider) {
|
|
43
40
|
resolve(cardProvider);
|
|
44
41
|
}
|
|
@@ -97,8 +94,7 @@ const CustomHyperlinkDropdown = props => {
|
|
|
97
94
|
label: "",
|
|
98
95
|
spacing: "compact",
|
|
99
96
|
size: "small"
|
|
100
|
-
})
|
|
101
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
97
|
+
})
|
|
102
98
|
}, title);
|
|
103
99
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
104
100
|
ref: containerRef,
|
|
@@ -128,11 +124,8 @@ const CustomHyperlinkDropdown = props => {
|
|
|
128
124
|
isDatasourceView: isDatasourceView,
|
|
129
125
|
allowDatasource: allowDatasource,
|
|
130
126
|
dispatchCommand: dispatchCommand,
|
|
131
|
-
settingsConfig: settingsConfig
|
|
132
|
-
|
|
133
|
-
})), !areToolbarFlagsEnabled(Boolean((_props$editorPluginAp6 = props.editorPluginApi) === null || _props$editorPluginAp6 === void 0 ? void 0 : _props$editorPluginAp6.toolbar)) && /*#__PURE__*/React.createElement(Separator, {
|
|
134
|
-
areAnyNewToolbarFlagsEnabled: areToolbarFlagsEnabled(Boolean((_props$editorPluginAp7 = props.editorPluginApi) === null || _props$editorPluginAp7 === void 0 ? void 0 : _props$editorPluginAp7.toolbar))
|
|
135
|
-
}));
|
|
127
|
+
settingsConfig: settingsConfig
|
|
128
|
+
})));
|
|
136
129
|
};
|
|
137
130
|
export const getCustomHyperlinkAppearanceDropdown = ({
|
|
138
131
|
url,
|
|
@@ -3,6 +3,7 @@ import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/en
|
|
|
3
3
|
import { appearancePropsMap } from '@atlaskit/editor-common/card';
|
|
4
4
|
import { getDropdownOption } from '@atlaskit/editor-common/card/link-toolbar-dropdown-options';
|
|
5
5
|
import { commandWithMetadata } from '@atlaskit/editor-common/card/utils';
|
|
6
|
+
import nodeNames from '@atlaskit/editor-common/messages';
|
|
6
7
|
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
7
8
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages/link-toolbar';
|
|
8
9
|
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
@@ -12,11 +13,38 @@ import ButtonItem from '@atlaskit/menu/button-item';
|
|
|
12
13
|
import LinkItem from '@atlaskit/menu/link-item';
|
|
13
14
|
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
14
15
|
import Section from '@atlaskit/menu/section';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
17
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
16
18
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
17
19
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
20
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
18
21
|
import { DatasourceDropdownOption, datasourceDisplayInformation } from './DatasourceDropdownOption';
|
|
19
|
-
|
|
22
|
+
export const getUnavailableMessage = (state, intl) => {
|
|
23
|
+
try {
|
|
24
|
+
const parentNode = state.selection.$from.node(1);
|
|
25
|
+
const parentName = intl.formatMessage(nodeNames[parentNode.type.name]);
|
|
26
|
+
const tooltip = intl.formatMessage(messages.displayOptionUnavailableInParentNode, {
|
|
27
|
+
node: parentName
|
|
28
|
+
});
|
|
29
|
+
return tooltip;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// eslint-disable-line no-unused-vars
|
|
32
|
+
return intl.formatMessage(messages.displayOptionUnavailableInParentNode, {
|
|
33
|
+
node: intl.formatMessage(nodeNames.defaultBlockNode)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the node a registered embed transformer (for example native embeds) would insert for the
|
|
40
|
+
* selected card is allowed in its parent. That node can be allowed where `embedCard` is not.
|
|
41
|
+
*/
|
|
42
|
+
export const isTransformedEmbedSupportedInParent = (editorState, currentAppearance) => {
|
|
43
|
+
var _cardState$embedCardT, _cardState$embedCardT2;
|
|
44
|
+
const cardState = pluginKey.getState(editorState);
|
|
45
|
+
const transformedNode = cardState === null || cardState === void 0 ? void 0 : (_cardState$embedCardT = cardState.embedCardTransformers) === null || _cardState$embedCardT === void 0 ? void 0 : (_cardState$embedCardT2 = _cardState$embedCardT.getEmbedCardTransformNode) === null || _cardState$embedCardT2 === void 0 ? void 0 : _cardState$embedCardT2.call(_cardState$embedCardT, editorState);
|
|
46
|
+
return transformedNode ? isSupportedInParent(editorState, Fragment.from(transformedNode), currentAppearance) : false;
|
|
47
|
+
};
|
|
20
48
|
export const LinkAppearanceMenu = ({
|
|
21
49
|
url,
|
|
22
50
|
intl,
|
|
@@ -41,8 +69,9 @@ export const LinkAppearanceMenu = ({
|
|
|
41
69
|
return null;
|
|
42
70
|
}
|
|
43
71
|
}
|
|
72
|
+
const showUnsupportedOptionsDisabled = fg('platform_editor_link_appearance_disabled_options');
|
|
44
73
|
const isBlockCardLinkSupportedInParent = allowBlockCards ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance) : false;
|
|
45
|
-
const isEmbedCardLinkSupportedInParent = allowEmbeds ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance) : false;
|
|
74
|
+
const isEmbedCardLinkSupportedInParent = allowEmbeds ? isSupportedInParent(editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance) || showUnsupportedOptionsDisabled && isTransformedEmbedSupportedInParent(editorState, currentAppearance) : false;
|
|
46
75
|
const embedOption = allowEmbeds && preview && {
|
|
47
76
|
appearance: 'embed',
|
|
48
77
|
title: intl.formatMessage(messages.embed),
|
|
@@ -96,8 +125,7 @@ export const LinkAppearanceMenu = ({
|
|
|
96
125
|
Icon = settingsConfig.icon;
|
|
97
126
|
}
|
|
98
127
|
|
|
99
|
-
// TODO: ED-26961 -
|
|
100
|
-
// this implementation doesn't
|
|
128
|
+
// TODO: ED-26961 - this implementation does not support change boarding via pulse
|
|
101
129
|
return /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(Section, null, finalOptions.map(option => {
|
|
102
130
|
const item = /*#__PURE__*/React.createElement(ButtonItem, {
|
|
103
131
|
key: option.title,
|
|
@@ -106,11 +134,11 @@ export const LinkAppearanceMenu = ({
|
|
|
106
134
|
,
|
|
107
135
|
onClick: () => option.onClick(),
|
|
108
136
|
isSelected: option.selected,
|
|
109
|
-
isDisabled: option.disabled,
|
|
137
|
+
isDisabled: showUnsupportedOptionsDisabled && option.disabled,
|
|
110
138
|
description: option.description,
|
|
111
139
|
shouldDescriptionWrap: true
|
|
112
140
|
}, option.title);
|
|
113
|
-
return option.tooltip ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
141
|
+
return showUnsupportedOptionsDisabled && option.tooltip ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
114
142
|
key: option.title,
|
|
115
143
|
content: option.tooltip
|
|
116
144
|
}, item) : item;
|
|
@@ -142,8 +170,7 @@ export const getLinkAppearanceDropdown = ({
|
|
|
142
170
|
editorAnalyticsApi,
|
|
143
171
|
showUpgradeDiscoverability = true,
|
|
144
172
|
isDatasourceView,
|
|
145
|
-
settingsConfig
|
|
146
|
-
areAnyNewToolbarFlagsEnabled
|
|
173
|
+
settingsConfig
|
|
147
174
|
}) => {
|
|
148
175
|
const alignmentItemOptions = {
|
|
149
176
|
render: props => {
|
|
@@ -159,8 +186,7 @@ export const getLinkAppearanceDropdown = ({
|
|
|
159
186
|
isDatasourceView: isDatasourceView,
|
|
160
187
|
allowDatasource: allowDatasource,
|
|
161
188
|
dispatchCommand: props.dispatchCommand,
|
|
162
|
-
settingsConfig: settingsConfig
|
|
163
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
189
|
+
settingsConfig: settingsConfig
|
|
164
190
|
});
|
|
165
191
|
},
|
|
166
192
|
width: 200,
|
|
@@ -11,7 +11,6 @@ import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-
|
|
|
11
11
|
*/
|
|
12
12
|
export const OpenLinkToolbarButton = ({
|
|
13
13
|
url,
|
|
14
|
-
areAnyNewToolbarFlagsEnabled,
|
|
15
14
|
editorView,
|
|
16
15
|
onClick,
|
|
17
16
|
title
|
|
@@ -30,7 +29,6 @@ export const OpenLinkToolbarButton = ({
|
|
|
30
29
|
}),
|
|
31
30
|
href: destinationUrl,
|
|
32
31
|
target: "_blank",
|
|
33
|
-
onClick: handleClick
|
|
34
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
32
|
+
onClick: handleClick
|
|
35
33
|
});
|
|
36
34
|
};
|
|
@@ -5,9 +5,7 @@ import { linkMessages } from '@atlaskit/editor-common/messages/link';
|
|
|
5
5
|
import PanelRightIcon from '@atlaskit/icon/core/panel-right';
|
|
6
6
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors/extract-smart-link-embed';
|
|
7
7
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
8
|
-
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
9
8
|
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
10
|
-
import { Inline } from '@atlaskit/primitives/compiled/inline';
|
|
11
9
|
import { getObjectAri, getObjectIconUrl, getObjectName } from '@atlaskit/smart-card';
|
|
12
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
11
|
import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
|
|
@@ -15,7 +13,6 @@ import { appearanceForLink } from '../analytics/utils';
|
|
|
15
13
|
export const OpenPreviewPanelToolbarButton = ({
|
|
16
14
|
node,
|
|
17
15
|
intl,
|
|
18
|
-
areAnyNewToolbarFlagsEnabled,
|
|
19
16
|
editorAnalyticsApi,
|
|
20
17
|
editorView
|
|
21
18
|
}) => {
|
|
@@ -59,29 +56,10 @@ export const OpenPreviewPanelToolbarButton = ({
|
|
|
59
56
|
});
|
|
60
57
|
};
|
|
61
58
|
const title = intl.formatMessage(linkMessages.openPreviewPanel);
|
|
62
|
-
const icon =
|
|
59
|
+
const icon = /*#__PURE__*/React.createElement(PanelRightIcon, {
|
|
63
60
|
label: "",
|
|
64
61
|
spacing: "spacious"
|
|
65
|
-
})
|
|
66
|
-
/*#__PURE__*/
|
|
67
|
-
// This is a hack required for Jira until areToolbarFlagsEnabled are enabled to ensure the icon has padding
|
|
68
|
-
// Padding is removed when areToolbarFlagsEnabled for a button with icon only in platform/packages/editor/editor-common/src/ui/FloatingToolbar/Button.tsx
|
|
69
|
-
React.createElement(Inline, {
|
|
70
|
-
as: "span",
|
|
71
|
-
space: "space.050",
|
|
72
|
-
alignBlock: "center"
|
|
73
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
74
|
-
as: "span",
|
|
75
|
-
"aria-hidden": true,
|
|
76
|
-
role: "presentation"
|
|
77
|
-
}), /*#__PURE__*/React.createElement(PanelRightIcon, {
|
|
78
|
-
label: "",
|
|
79
|
-
spacing: "spacious"
|
|
80
|
-
}), /*#__PURE__*/React.createElement(Box, {
|
|
81
|
-
as: "span",
|
|
82
|
-
"aria-hidden": true,
|
|
83
|
-
role: "presentation"
|
|
84
|
-
}));
|
|
62
|
+
});
|
|
85
63
|
if (openPreviewPanel && isPanelAvailable) {
|
|
86
64
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
87
65
|
gap: "space.050"
|
|
@@ -89,8 +67,7 @@ export const OpenPreviewPanelToolbarButton = ({
|
|
|
89
67
|
testId: "open-preview-panel-floating-toolbar-button",
|
|
90
68
|
onClick: handleOpenGlancePanelClick,
|
|
91
69
|
icon: icon,
|
|
92
|
-
title: title
|
|
93
|
-
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
70
|
+
title: title
|
|
94
71
|
}));
|
|
95
72
|
}
|
|
96
73
|
}
|