@atlaskit/editor-plugin-card 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/toolbar.js +26 -24
- package/dist/cjs/ui/EditToolbarButton.js +97 -65
- package/dist/es2019/toolbar.js +22 -20
- package/dist/es2019/ui/EditToolbarButton.js +95 -62
- package/dist/esm/toolbar.js +26 -24
- package/dist/esm/ui/EditToolbarButton.js +98 -66
- package/dist/types/ui/EditToolbarButton.d.ts +3 -2
- package/dist/types-ts4.5/ui/EditToolbarButton.d.ts +3 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 2.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#108600](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108600)
|
|
8
|
+
[`ab0ef9cd9d368`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab0ef9cd9d368) -
|
|
9
|
+
[ux] Fixed the toolbar edit button in the new dropdown button for assets.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.0.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -226,7 +226,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
226
226
|
} else {
|
|
227
227
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
228
228
|
var isEditDropdownEnabled = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
|
|
229
|
-
var
|
|
229
|
+
var editItems = isEditDropdownEnabled ? [{
|
|
230
230
|
type: 'custom',
|
|
231
231
|
fallback: [],
|
|
232
232
|
render: function render(editorView) {
|
|
@@ -239,7 +239,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
239
239
|
onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
} : {
|
|
242
|
+
}] : [{
|
|
243
243
|
id: 'editor.link.edit',
|
|
244
244
|
type: 'button',
|
|
245
245
|
selected: false,
|
|
@@ -250,7 +250,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
250
250
|
onClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
|
|
251
251
|
}, {
|
|
252
252
|
type: 'separator'
|
|
253
|
-
}
|
|
253
|
+
}];
|
|
254
|
+
var toolbarItems = [].concat(editItems, [{
|
|
254
255
|
id: 'editor.link.openLink',
|
|
255
256
|
type: 'button',
|
|
256
257
|
icon: _shortcut.default,
|
|
@@ -260,7 +261,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
260
261
|
onClick: visitCardLink(editorAnalyticsApi)
|
|
261
262
|
}, {
|
|
262
263
|
type: 'separator'
|
|
263
|
-
}]
|
|
264
|
+
}], (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
|
|
264
265
|
type: 'copy-button',
|
|
265
266
|
supportsViewMode: true,
|
|
266
267
|
items: [{
|
|
@@ -410,23 +411,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
410
411
|
type: 'separator'
|
|
411
412
|
});
|
|
412
413
|
}
|
|
413
|
-
var
|
|
414
|
-
type: 'custom',
|
|
415
|
-
fallback: [],
|
|
416
|
-
render: function render(editorView) {
|
|
417
|
-
return /*#__PURE__*/_react.default.createElement(_EditToolbarButton.EditToolbarButton, {
|
|
418
|
-
key: "edit-toolbar-item",
|
|
419
|
-
url: metadata.url,
|
|
420
|
-
intl: intl,
|
|
421
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
422
|
-
editorView: editorView,
|
|
423
|
-
onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
}, {
|
|
427
|
-
type: 'separator'
|
|
428
|
-
}];
|
|
429
|
-
var canShowMainToolbar = function canShowMainToolbar() {
|
|
414
|
+
var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
|
|
430
415
|
// we do not show smart-link or the datasource icons when the node does not have a url to resolve
|
|
431
416
|
if (!metadata.url) {
|
|
432
417
|
return false;
|
|
@@ -440,12 +425,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
440
425
|
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
441
426
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !(0, _utils3.isDatasourceConfigEditable)(datasourceId);
|
|
442
427
|
};
|
|
443
|
-
if (
|
|
428
|
+
if (canShowAppearanceSwitch()) {
|
|
444
429
|
var allowBlockCards = cardOptions.allowBlockCards,
|
|
445
430
|
allowEmbeds = cardOptions.allowEmbeds,
|
|
446
431
|
showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
|
|
447
432
|
var url = metadata.url;
|
|
448
|
-
toolbarItems.push
|
|
433
|
+
toolbarItems.push({
|
|
449
434
|
type: 'custom',
|
|
450
435
|
fallback: [],
|
|
451
436
|
render: function render(editorView) {
|
|
@@ -480,7 +465,24 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
480
465
|
}
|
|
481
466
|
}, {
|
|
482
467
|
type: 'separator'
|
|
483
|
-
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
471
|
+
toolbarItems.push({
|
|
472
|
+
type: 'custom',
|
|
473
|
+
fallback: [],
|
|
474
|
+
render: function render(editorView) {
|
|
475
|
+
return /*#__PURE__*/_react.default.createElement(_EditToolbarButton.EditToolbarButton, {
|
|
476
|
+
datasourceId: datasourceId,
|
|
477
|
+
key: "edit-toolbar-item",
|
|
478
|
+
url: metadata.url,
|
|
479
|
+
intl: intl,
|
|
480
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
481
|
+
editorView: editorView,
|
|
482
|
+
onLinkEditClick: (0, _EditLinkToolbar.editLink)(editorAnalyticsApi)
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
});
|
|
484
486
|
}
|
|
485
487
|
if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
|
|
486
488
|
toolbarItems.push({
|
|
@@ -24,19 +24,20 @@ var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
|
|
|
24
24
|
var dropdownExpandContainer = (0, _react2.css)({
|
|
25
25
|
margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
|
|
26
26
|
});
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext(props) {
|
|
28
|
+
var _response$datasourceI;
|
|
29
|
+
var url = props.url,
|
|
30
|
+
cardContext = props.cardContext,
|
|
31
|
+
intl = props.intl,
|
|
32
|
+
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
33
|
+
editorView = props.editorView,
|
|
34
|
+
onLinkEditClick = props.onLinkEditClick;
|
|
35
|
+
var response = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
|
|
36
|
+
isRegularCardNode: true,
|
|
37
|
+
url: url,
|
|
38
|
+
cardContext: cardContext
|
|
39
|
+
});
|
|
40
|
+
var datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
|
|
40
41
|
var _useState = (0, _react.useState)(false),
|
|
41
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
43
|
isOpen = _useState2[0],
|
|
@@ -61,73 +62,104 @@ var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
|
|
|
61
62
|
var onEditLink = (0, _react.useCallback)(function () {
|
|
62
63
|
dispatchCommand(onLinkEditClick);
|
|
63
64
|
}, [dispatchCommand, onLinkEditClick]);
|
|
64
|
-
var
|
|
65
|
+
var editVariant = (0, _react.useMemo)(function () {
|
|
66
|
+
var hasUrl = url !== null && url !== undefined;
|
|
65
67
|
if (!datasourceId || !(0, _utils.isDatasourceConfigEditable)(datasourceId)) {
|
|
66
|
-
|
|
68
|
+
if (hasUrl) {
|
|
69
|
+
return 'edit-link';
|
|
70
|
+
}
|
|
71
|
+
return 'none';
|
|
67
72
|
}
|
|
68
|
-
if (
|
|
73
|
+
if (hasUrl) {
|
|
69
74
|
var _cardContext$store, _urlState$error;
|
|
70
75
|
var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
71
76
|
if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
|
|
72
|
-
return
|
|
77
|
+
return 'edit-link';
|
|
73
78
|
}
|
|
79
|
+
return 'edit-dropdown';
|
|
80
|
+
} else {
|
|
81
|
+
return 'edit-datasource';
|
|
74
82
|
}
|
|
75
|
-
return false;
|
|
76
83
|
}, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
|
|
77
84
|
var onEditDatasource = (0, _react.useCallback)(function () {
|
|
78
85
|
if (datasourceId) {
|
|
79
86
|
dispatchCommand((0, _doc.editDatasource)(datasourceId, editorAnalyticsApi));
|
|
80
87
|
}
|
|
81
88
|
}, [dispatchCommand, datasourceId, editorAnalyticsApi]);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
switch (editVariant) {
|
|
90
|
+
case 'edit-link':
|
|
91
|
+
{
|
|
92
|
+
return (0, _react2.jsx)(_primitives.Flex, {
|
|
93
|
+
gap: "space.050"
|
|
94
|
+
}, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
95
|
+
testId: "edit-link",
|
|
96
|
+
onClick: onEditLink
|
|
97
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.linkToolbarMessages.editLink)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
|
|
98
|
+
}
|
|
99
|
+
case 'edit-datasource':
|
|
100
|
+
{
|
|
101
|
+
return (0, _react2.jsx)(_primitives.Flex, {
|
|
102
|
+
gap: "space.050"
|
|
103
|
+
}, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
104
|
+
testId: "edit-datasource",
|
|
105
|
+
tooltipContent: intl.formatMessage(_messages.linkToolbarMessages.editDatasourceStandaloneTooltip),
|
|
106
|
+
onClick: onEditDatasource
|
|
107
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.linkToolbarMessages.editDatasourceStandalone)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
|
|
108
|
+
}
|
|
109
|
+
case 'edit-dropdown':
|
|
110
|
+
{
|
|
111
|
+
var trigger = (0, _react2.jsx)(_primitives.Flex, {
|
|
112
|
+
gap: "space.050"
|
|
113
|
+
}, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
114
|
+
testId: "edit-dropdown-trigger",
|
|
115
|
+
iconAfter: (0, _react2.jsx)("span", {
|
|
116
|
+
css: dropdownExpandContainer
|
|
117
|
+
}, (0, _react2.jsx)(_chevronDown.default, {
|
|
118
|
+
label: intl.formatMessage(_messages.cardMessages.editDropdownTriggerTitle)
|
|
119
|
+
})),
|
|
120
|
+
onClick: toggleOpen,
|
|
121
|
+
selected: isOpen,
|
|
122
|
+
disabled: false,
|
|
123
|
+
ariaHasPopup: true
|
|
124
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownTriggerTitle)), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
|
|
125
|
+
return (0, _react2.jsx)(_primitives.Flex, {
|
|
126
|
+
ref: containerRef
|
|
127
|
+
}, (0, _react2.jsx)(_uiMenu.DropdownContainer, {
|
|
128
|
+
mountTo: containerRef.current,
|
|
129
|
+
isOpen: isOpen,
|
|
130
|
+
handleClickOutside: onClose,
|
|
131
|
+
handleEscapeKeydown: onClose,
|
|
132
|
+
trigger: trigger,
|
|
133
|
+
scrollableElement: containerRef.current,
|
|
134
|
+
arrowKeyNavigationProviderOptions: {
|
|
135
|
+
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
136
|
+
}
|
|
137
|
+
}, (0, _react2.jsx)(_menu.ButtonItem, {
|
|
138
|
+
key: "edit.link",
|
|
139
|
+
onClick: onEditLink,
|
|
140
|
+
testId: "edit-dropdown-edit-link-item"
|
|
141
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditLinkTitle)), (0, _react2.jsx)(_menu.ButtonItem, {
|
|
142
|
+
key: "edit.datasource",
|
|
143
|
+
onClick: onEditDatasource,
|
|
144
|
+
testId: "edit-dropdown-edit-datasource-item"
|
|
145
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditDatasourceTitle))));
|
|
146
|
+
}
|
|
147
|
+
case 'none':
|
|
148
|
+
default:
|
|
149
|
+
return null;
|
|
87
150
|
}
|
|
88
|
-
var trigger = (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
89
|
-
testId: "edit-dropdown-trigger",
|
|
90
|
-
iconAfter: (0, _react2.jsx)("span", {
|
|
91
|
-
css: dropdownExpandContainer
|
|
92
|
-
}, (0, _react2.jsx)(_chevronDown.default, {
|
|
93
|
-
label: intl.formatMessage(_messages.cardMessages.editDropdownTriggerTitle)
|
|
94
|
-
})),
|
|
95
|
-
onClick: toggleOpen,
|
|
96
|
-
selected: isOpen,
|
|
97
|
-
disabled: false,
|
|
98
|
-
ariaHasPopup: true
|
|
99
|
-
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownTriggerTitle));
|
|
100
|
-
return (0, _react2.jsx)(_primitives.Flex, {
|
|
101
|
-
ref: containerRef
|
|
102
|
-
}, (0, _react2.jsx)(_uiMenu.DropdownContainer, {
|
|
103
|
-
mountTo: containerRef.current,
|
|
104
|
-
isOpen: isOpen,
|
|
105
|
-
handleClickOutside: onClose,
|
|
106
|
-
handleEscapeKeydown: onClose,
|
|
107
|
-
trigger: trigger,
|
|
108
|
-
scrollableElement: containerRef.current,
|
|
109
|
-
arrowKeyNavigationProviderOptions: {
|
|
110
|
-
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
111
|
-
}
|
|
112
|
-
}, (0, _react2.jsx)(_menu.ButtonItem, {
|
|
113
|
-
key: "edit.link",
|
|
114
|
-
onClick: onEditLink,
|
|
115
|
-
testId: "edit-dropdown-edit-link-item"
|
|
116
|
-
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditLinkTitle)), (0, _react2.jsx)(_menu.ButtonItem, {
|
|
117
|
-
key: "edit.datasource",
|
|
118
|
-
onClick: onEditDatasource,
|
|
119
|
-
testId: "edit-dropdown-edit-datasource-item"
|
|
120
|
-
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.cardMessages.editDropdownEditDatasourceTitle))));
|
|
121
151
|
};
|
|
122
|
-
var EditToolbarButton = exports.EditToolbarButton = function EditToolbarButton(
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
152
|
+
var EditToolbarButton = exports.EditToolbarButton = function EditToolbarButton(props) {
|
|
153
|
+
var datasourceId = props.datasourceId,
|
|
154
|
+
intl = props.intl,
|
|
155
|
+
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
156
|
+
url = props.url,
|
|
157
|
+
editorView = props.editorView,
|
|
158
|
+
onLinkEditClick = props.onLinkEditClick;
|
|
159
|
+
return (0, _react2.jsx)(_CardContextProvider.CardContextProvider, null, function (_ref) {
|
|
160
|
+
var cardContext = _ref.cardContext;
|
|
161
|
+
return (0, _react2.jsx)(EditToolbarButtonWithCardContext, {
|
|
162
|
+
datasourceId: datasourceId,
|
|
131
163
|
url: url,
|
|
132
164
|
intl: intl,
|
|
133
165
|
editorAnalyticsApi: editorAnalyticsApi,
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -220,7 +220,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
220
220
|
inlineCard
|
|
221
221
|
} = state.schema.nodes;
|
|
222
222
|
const isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
|
|
223
|
-
const
|
|
223
|
+
const editItems = isEditDropdownEnabled ? [{
|
|
224
224
|
type: 'custom',
|
|
225
225
|
fallback: [],
|
|
226
226
|
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
@@ -231,7 +231,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
231
231
|
editorView: editorView,
|
|
232
232
|
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
233
233
|
})
|
|
234
|
-
} : {
|
|
234
|
+
}] : [{
|
|
235
235
|
id: 'editor.link.edit',
|
|
236
236
|
type: 'button',
|
|
237
237
|
selected: false,
|
|
@@ -242,7 +242,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
242
242
|
onClick: editLink(editorAnalyticsApi)
|
|
243
243
|
}, {
|
|
244
244
|
type: 'separator'
|
|
245
|
-
}
|
|
245
|
+
}];
|
|
246
|
+
const toolbarItems = [...editItems, {
|
|
246
247
|
id: 'editor.link.openLink',
|
|
247
248
|
type: 'button',
|
|
248
249
|
icon: OpenIcon,
|
|
@@ -397,21 +398,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
397
398
|
type: 'separator'
|
|
398
399
|
});
|
|
399
400
|
}
|
|
400
|
-
const
|
|
401
|
-
type: 'custom',
|
|
402
|
-
fallback: [],
|
|
403
|
-
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
404
|
-
key: "edit-toolbar-item",
|
|
405
|
-
url: metadata.url,
|
|
406
|
-
intl: intl,
|
|
407
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
408
|
-
editorView: editorView,
|
|
409
|
-
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
410
|
-
})
|
|
411
|
-
}, {
|
|
412
|
-
type: 'separator'
|
|
413
|
-
}];
|
|
414
|
-
const canShowMainToolbar = () => {
|
|
401
|
+
const canShowAppearanceSwitch = () => {
|
|
415
402
|
// we do not show smart-link or the datasource icons when the node does not have a url to resolve
|
|
416
403
|
if (!metadata.url) {
|
|
417
404
|
return false;
|
|
@@ -425,7 +412,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
425
412
|
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
426
413
|
return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
|
|
427
414
|
};
|
|
428
|
-
if (
|
|
415
|
+
if (canShowAppearanceSwitch()) {
|
|
429
416
|
const {
|
|
430
417
|
allowBlockCards,
|
|
431
418
|
allowEmbeds,
|
|
@@ -467,7 +454,22 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
467
454
|
})
|
|
468
455
|
}, {
|
|
469
456
|
type: 'separator'
|
|
470
|
-
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
460
|
+
toolbarItems.push({
|
|
461
|
+
type: 'custom',
|
|
462
|
+
fallback: [],
|
|
463
|
+
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
464
|
+
datasourceId: datasourceId,
|
|
465
|
+
key: "edit-toolbar-item",
|
|
466
|
+
url: metadata.url,
|
|
467
|
+
intl: intl,
|
|
468
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
469
|
+
editorView: editorView,
|
|
470
|
+
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
471
|
+
})
|
|
472
|
+
});
|
|
471
473
|
}
|
|
472
474
|
if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
|
|
473
475
|
toolbarItems.push({
|
|
@@ -3,7 +3,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
5
|
import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
-
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
6
|
+
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
|
|
8
8
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
9
9
|
import { ButtonItem } from '@atlaskit/menu';
|
|
@@ -15,21 +15,22 @@ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
|
15
15
|
const dropdownExpandContainer = css({
|
|
16
16
|
margin: `0px ${"var(--ds-space-negative-050, -4px)"}`
|
|
17
17
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
intl,
|
|
21
|
-
editorAnalyticsApi,
|
|
22
|
-
url,
|
|
23
|
-
editorView,
|
|
24
|
-
onLinkEditClick
|
|
25
|
-
}) => {
|
|
18
|
+
const EditToolbarButtonWithCardContext = props => {
|
|
19
|
+
var _response$datasourceI;
|
|
26
20
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
url,
|
|
22
|
+
cardContext,
|
|
23
|
+
intl,
|
|
24
|
+
editorAnalyticsApi,
|
|
25
|
+
editorView,
|
|
26
|
+
onLinkEditClick
|
|
27
|
+
} = props;
|
|
28
|
+
const response = useFetchDatasourceInfo({
|
|
29
29
|
isRegularCardNode: true,
|
|
30
30
|
url,
|
|
31
31
|
cardContext
|
|
32
32
|
});
|
|
33
|
+
const datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
|
|
33
34
|
const [isOpen, setIsOpen] = useState(false);
|
|
34
35
|
const containerRef = useRef();
|
|
35
36
|
const toggleOpen = () => setIsOpen(open => !open);
|
|
@@ -45,74 +46,106 @@ const EditButtonWithCardContext = ({
|
|
|
45
46
|
const onEditLink = useCallback(() => {
|
|
46
47
|
dispatchCommand(onLinkEditClick);
|
|
47
48
|
}, [dispatchCommand, onLinkEditClick]);
|
|
48
|
-
const
|
|
49
|
+
const editVariant = useMemo(() => {
|
|
50
|
+
const hasUrl = url !== null && url !== undefined;
|
|
49
51
|
if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
|
|
50
|
-
|
|
52
|
+
if (hasUrl) {
|
|
53
|
+
return 'edit-link';
|
|
54
|
+
}
|
|
55
|
+
return 'none';
|
|
51
56
|
}
|
|
52
|
-
if (
|
|
57
|
+
if (hasUrl) {
|
|
53
58
|
var _cardContext$store, _urlState$error;
|
|
54
59
|
const urlState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
55
60
|
if ((urlState === null || urlState === void 0 ? void 0 : (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
|
|
56
|
-
return
|
|
61
|
+
return 'edit-link';
|
|
57
62
|
}
|
|
63
|
+
return 'edit-dropdown';
|
|
64
|
+
} else {
|
|
65
|
+
return 'edit-datasource';
|
|
58
66
|
}
|
|
59
|
-
return false;
|
|
60
67
|
}, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
|
|
61
68
|
const onEditDatasource = useCallback(() => {
|
|
62
69
|
if (datasourceId) {
|
|
63
70
|
dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
|
|
64
71
|
}
|
|
65
72
|
}, [dispatchCommand, datasourceId, editorAnalyticsApi]);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
switch (editVariant) {
|
|
74
|
+
case 'edit-link':
|
|
75
|
+
{
|
|
76
|
+
return jsx(Flex, {
|
|
77
|
+
gap: "space.050"
|
|
78
|
+
}, jsx(Button, {
|
|
79
|
+
testId: "edit-link",
|
|
80
|
+
onClick: onEditLink
|
|
81
|
+
}, jsx(FormattedMessage, linkToolbarMessages.editLink)), jsx(Separator, null));
|
|
82
|
+
}
|
|
83
|
+
case 'edit-datasource':
|
|
84
|
+
{
|
|
85
|
+
return jsx(Flex, {
|
|
86
|
+
gap: "space.050"
|
|
87
|
+
}, jsx(Button, {
|
|
88
|
+
testId: "edit-datasource",
|
|
89
|
+
tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
|
|
90
|
+
onClick: onEditDatasource
|
|
91
|
+
}, jsx(FormattedMessage, linkToolbarMessages.editDatasourceStandalone)), jsx(Separator, null));
|
|
92
|
+
}
|
|
93
|
+
case 'edit-dropdown':
|
|
94
|
+
{
|
|
95
|
+
const trigger = jsx(Flex, {
|
|
96
|
+
gap: "space.050"
|
|
97
|
+
}, jsx(Button, {
|
|
98
|
+
testId: "edit-dropdown-trigger",
|
|
99
|
+
iconAfter: jsx("span", {
|
|
100
|
+
css: dropdownExpandContainer
|
|
101
|
+
}, jsx(ExpandIcon, {
|
|
102
|
+
label: intl.formatMessage(messages.editDropdownTriggerTitle)
|
|
103
|
+
})),
|
|
104
|
+
onClick: toggleOpen,
|
|
105
|
+
selected: isOpen,
|
|
106
|
+
disabled: false,
|
|
107
|
+
ariaHasPopup: true
|
|
108
|
+
}, jsx(FormattedMessage, messages.editDropdownTriggerTitle)), jsx(Separator, null));
|
|
109
|
+
return jsx(Flex, {
|
|
110
|
+
ref: containerRef
|
|
111
|
+
}, jsx(UiDropdown, {
|
|
112
|
+
mountTo: containerRef.current,
|
|
113
|
+
isOpen: isOpen,
|
|
114
|
+
handleClickOutside: onClose,
|
|
115
|
+
handleEscapeKeydown: onClose,
|
|
116
|
+
trigger: trigger,
|
|
117
|
+
scrollableElement: containerRef.current,
|
|
118
|
+
arrowKeyNavigationProviderOptions: {
|
|
119
|
+
type: ArrowKeyNavigationType.MENU
|
|
120
|
+
}
|
|
121
|
+
}, jsx(ButtonItem, {
|
|
122
|
+
key: "edit.link",
|
|
123
|
+
onClick: onEditLink,
|
|
124
|
+
testId: "edit-dropdown-edit-link-item"
|
|
125
|
+
}, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
|
|
126
|
+
key: "edit.datasource",
|
|
127
|
+
onClick: onEditDatasource,
|
|
128
|
+
testId: "edit-dropdown-edit-datasource-item"
|
|
129
|
+
}, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
|
|
130
|
+
}
|
|
131
|
+
case 'none':
|
|
132
|
+
default:
|
|
133
|
+
return null;
|
|
71
134
|
}
|
|
72
|
-
const trigger = jsx(Button, {
|
|
73
|
-
testId: "edit-dropdown-trigger",
|
|
74
|
-
iconAfter: jsx("span", {
|
|
75
|
-
css: dropdownExpandContainer
|
|
76
|
-
}, jsx(ExpandIcon, {
|
|
77
|
-
label: intl.formatMessage(messages.editDropdownTriggerTitle)
|
|
78
|
-
})),
|
|
79
|
-
onClick: toggleOpen,
|
|
80
|
-
selected: isOpen,
|
|
81
|
-
disabled: false,
|
|
82
|
-
ariaHasPopup: true
|
|
83
|
-
}, jsx(FormattedMessage, messages.editDropdownTriggerTitle));
|
|
84
|
-
return jsx(Flex, {
|
|
85
|
-
ref: containerRef
|
|
86
|
-
}, jsx(UiDropdown, {
|
|
87
|
-
mountTo: containerRef.current,
|
|
88
|
-
isOpen: isOpen,
|
|
89
|
-
handleClickOutside: onClose,
|
|
90
|
-
handleEscapeKeydown: onClose,
|
|
91
|
-
trigger: trigger,
|
|
92
|
-
scrollableElement: containerRef.current,
|
|
93
|
-
arrowKeyNavigationProviderOptions: {
|
|
94
|
-
type: ArrowKeyNavigationType.MENU
|
|
95
|
-
}
|
|
96
|
-
}, jsx(ButtonItem, {
|
|
97
|
-
key: "edit.link",
|
|
98
|
-
onClick: onEditLink,
|
|
99
|
-
testId: "edit-dropdown-edit-link-item"
|
|
100
|
-
}, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
|
|
101
|
-
key: "edit.datasource",
|
|
102
|
-
onClick: onEditDatasource,
|
|
103
|
-
testId: "edit-dropdown-edit-datasource-item"
|
|
104
|
-
}, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
|
|
105
135
|
};
|
|
106
|
-
export const EditToolbarButton =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
136
|
+
export const EditToolbarButton = props => {
|
|
137
|
+
const {
|
|
138
|
+
datasourceId,
|
|
139
|
+
intl,
|
|
140
|
+
editorAnalyticsApi,
|
|
141
|
+
url,
|
|
142
|
+
editorView,
|
|
143
|
+
onLinkEditClick
|
|
144
|
+
} = props;
|
|
113
145
|
return jsx(CardContextProvider, null, ({
|
|
114
146
|
cardContext
|
|
115
|
-
}) => jsx(
|
|
147
|
+
}) => jsx(EditToolbarButtonWithCardContext, {
|
|
148
|
+
datasourceId: datasourceId,
|
|
116
149
|
url: url,
|
|
117
150
|
intl: intl,
|
|
118
151
|
editorAnalyticsApi: editorAnalyticsApi,
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -216,7 +216,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
216
216
|
} else {
|
|
217
217
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
218
218
|
var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
|
|
219
|
-
var
|
|
219
|
+
var editItems = isEditDropdownEnabled ? [{
|
|
220
220
|
type: 'custom',
|
|
221
221
|
fallback: [],
|
|
222
222
|
render: function render(editorView) {
|
|
@@ -229,7 +229,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
229
229
|
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
|
-
} : {
|
|
232
|
+
}] : [{
|
|
233
233
|
id: 'editor.link.edit',
|
|
234
234
|
type: 'button',
|
|
235
235
|
selected: false,
|
|
@@ -240,7 +240,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
240
240
|
onClick: editLink(editorAnalyticsApi)
|
|
241
241
|
}, {
|
|
242
242
|
type: 'separator'
|
|
243
|
-
}
|
|
243
|
+
}];
|
|
244
|
+
var toolbarItems = [].concat(editItems, [{
|
|
244
245
|
id: 'editor.link.openLink',
|
|
245
246
|
type: 'button',
|
|
246
247
|
icon: OpenIcon,
|
|
@@ -250,7 +251,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
250
251
|
onClick: visitCardLink(editorAnalyticsApi)
|
|
251
252
|
}, {
|
|
252
253
|
type: 'separator'
|
|
253
|
-
}]
|
|
254
|
+
}], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
|
|
254
255
|
type: 'copy-button',
|
|
255
256
|
supportsViewMode: true,
|
|
256
257
|
items: [{
|
|
@@ -400,23 +401,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
400
401
|
type: 'separator'
|
|
401
402
|
});
|
|
402
403
|
}
|
|
403
|
-
var
|
|
404
|
-
type: 'custom',
|
|
405
|
-
fallback: [],
|
|
406
|
-
render: function render(editorView) {
|
|
407
|
-
return /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
408
|
-
key: "edit-toolbar-item",
|
|
409
|
-
url: metadata.url,
|
|
410
|
-
intl: intl,
|
|
411
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
412
|
-
editorView: editorView,
|
|
413
|
-
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}, {
|
|
417
|
-
type: 'separator'
|
|
418
|
-
}];
|
|
419
|
-
var canShowMainToolbar = function canShowMainToolbar() {
|
|
404
|
+
var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
|
|
420
405
|
// we do not show smart-link or the datasource icons when the node does not have a url to resolve
|
|
421
406
|
if (!metadata.url) {
|
|
422
407
|
return false;
|
|
@@ -430,12 +415,12 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
430
415
|
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
431
416
|
return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
|
|
432
417
|
};
|
|
433
|
-
if (
|
|
418
|
+
if (canShowAppearanceSwitch()) {
|
|
434
419
|
var allowBlockCards = cardOptions.allowBlockCards,
|
|
435
420
|
allowEmbeds = cardOptions.allowEmbeds,
|
|
436
421
|
showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
|
|
437
422
|
var url = metadata.url;
|
|
438
|
-
toolbarItems.push
|
|
423
|
+
toolbarItems.push({
|
|
439
424
|
type: 'custom',
|
|
440
425
|
fallback: [],
|
|
441
426
|
render: function render(editorView) {
|
|
@@ -470,7 +455,24 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
470
455
|
}
|
|
471
456
|
}, {
|
|
472
457
|
type: 'separator'
|
|
473
|
-
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
461
|
+
toolbarItems.push({
|
|
462
|
+
type: 'custom',
|
|
463
|
+
fallback: [],
|
|
464
|
+
render: function render(editorView) {
|
|
465
|
+
return /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
466
|
+
datasourceId: datasourceId,
|
|
467
|
+
key: "edit-toolbar-item",
|
|
468
|
+
url: metadata.url,
|
|
469
|
+
intl: intl,
|
|
470
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
471
|
+
editorView: editorView,
|
|
472
|
+
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
});
|
|
474
476
|
}
|
|
475
477
|
if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
|
|
476
478
|
toolbarItems.push({
|
|
@@ -4,7 +4,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
|
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
6
6
|
import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
7
|
+
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
8
8
|
import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
|
|
9
9
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
10
10
|
import { ButtonItem } from '@atlaskit/menu';
|
|
@@ -16,19 +16,20 @@ import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
|
16
16
|
var dropdownExpandContainer = css({
|
|
17
17
|
margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
|
|
18
18
|
});
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext(props) {
|
|
20
|
+
var _response$datasourceI;
|
|
21
|
+
var url = props.url,
|
|
22
|
+
cardContext = props.cardContext,
|
|
23
|
+
intl = props.intl,
|
|
24
|
+
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
25
|
+
editorView = props.editorView,
|
|
26
|
+
onLinkEditClick = props.onLinkEditClick;
|
|
27
|
+
var response = useFetchDatasourceInfo({
|
|
28
|
+
isRegularCardNode: true,
|
|
29
|
+
url: url,
|
|
30
|
+
cardContext: cardContext
|
|
31
|
+
});
|
|
32
|
+
var datasourceId = (_response$datasourceI = response.datasourceId) !== null && _response$datasourceI !== void 0 ? _response$datasourceI : props.datasourceId;
|
|
32
33
|
var _useState = useState(false),
|
|
33
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
35
|
isOpen = _useState2[0],
|
|
@@ -53,73 +54,104 @@ var EditButtonWithCardContext = function EditButtonWithCardContext(_ref) {
|
|
|
53
54
|
var onEditLink = useCallback(function () {
|
|
54
55
|
dispatchCommand(onLinkEditClick);
|
|
55
56
|
}, [dispatchCommand, onLinkEditClick]);
|
|
56
|
-
var
|
|
57
|
+
var editVariant = useMemo(function () {
|
|
58
|
+
var hasUrl = url !== null && url !== undefined;
|
|
57
59
|
if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
|
|
58
|
-
|
|
60
|
+
if (hasUrl) {
|
|
61
|
+
return 'edit-link';
|
|
62
|
+
}
|
|
63
|
+
return 'none';
|
|
59
64
|
}
|
|
60
|
-
if (
|
|
65
|
+
if (hasUrl) {
|
|
61
66
|
var _cardContext$store, _urlState$error;
|
|
62
67
|
var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
63
68
|
if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
|
|
64
|
-
return
|
|
69
|
+
return 'edit-link';
|
|
65
70
|
}
|
|
71
|
+
return 'edit-dropdown';
|
|
72
|
+
} else {
|
|
73
|
+
return 'edit-datasource';
|
|
66
74
|
}
|
|
67
|
-
return false;
|
|
68
75
|
}, [cardContext === null || cardContext === void 0 ? void 0 : cardContext.store, datasourceId, url]);
|
|
69
76
|
var onEditDatasource = useCallback(function () {
|
|
70
77
|
if (datasourceId) {
|
|
71
78
|
dispatchCommand(editDatasource(datasourceId, editorAnalyticsApi));
|
|
72
79
|
}
|
|
73
80
|
}, [dispatchCommand, datasourceId, editorAnalyticsApi]);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
switch (editVariant) {
|
|
82
|
+
case 'edit-link':
|
|
83
|
+
{
|
|
84
|
+
return jsx(Flex, {
|
|
85
|
+
gap: "space.050"
|
|
86
|
+
}, jsx(Button, {
|
|
87
|
+
testId: "edit-link",
|
|
88
|
+
onClick: onEditLink
|
|
89
|
+
}, jsx(FormattedMessage, linkToolbarMessages.editLink)), jsx(Separator, null));
|
|
90
|
+
}
|
|
91
|
+
case 'edit-datasource':
|
|
92
|
+
{
|
|
93
|
+
return jsx(Flex, {
|
|
94
|
+
gap: "space.050"
|
|
95
|
+
}, jsx(Button, {
|
|
96
|
+
testId: "edit-datasource",
|
|
97
|
+
tooltipContent: intl.formatMessage(linkToolbarMessages.editDatasourceStandaloneTooltip),
|
|
98
|
+
onClick: onEditDatasource
|
|
99
|
+
}, jsx(FormattedMessage, linkToolbarMessages.editDatasourceStandalone)), jsx(Separator, null));
|
|
100
|
+
}
|
|
101
|
+
case 'edit-dropdown':
|
|
102
|
+
{
|
|
103
|
+
var trigger = jsx(Flex, {
|
|
104
|
+
gap: "space.050"
|
|
105
|
+
}, jsx(Button, {
|
|
106
|
+
testId: "edit-dropdown-trigger",
|
|
107
|
+
iconAfter: jsx("span", {
|
|
108
|
+
css: dropdownExpandContainer
|
|
109
|
+
}, jsx(ExpandIcon, {
|
|
110
|
+
label: intl.formatMessage(messages.editDropdownTriggerTitle)
|
|
111
|
+
})),
|
|
112
|
+
onClick: toggleOpen,
|
|
113
|
+
selected: isOpen,
|
|
114
|
+
disabled: false,
|
|
115
|
+
ariaHasPopup: true
|
|
116
|
+
}, jsx(FormattedMessage, messages.editDropdownTriggerTitle)), jsx(Separator, null));
|
|
117
|
+
return jsx(Flex, {
|
|
118
|
+
ref: containerRef
|
|
119
|
+
}, jsx(UiDropdown, {
|
|
120
|
+
mountTo: containerRef.current,
|
|
121
|
+
isOpen: isOpen,
|
|
122
|
+
handleClickOutside: onClose,
|
|
123
|
+
handleEscapeKeydown: onClose,
|
|
124
|
+
trigger: trigger,
|
|
125
|
+
scrollableElement: containerRef.current,
|
|
126
|
+
arrowKeyNavigationProviderOptions: {
|
|
127
|
+
type: ArrowKeyNavigationType.MENU
|
|
128
|
+
}
|
|
129
|
+
}, jsx(ButtonItem, {
|
|
130
|
+
key: "edit.link",
|
|
131
|
+
onClick: onEditLink,
|
|
132
|
+
testId: "edit-dropdown-edit-link-item"
|
|
133
|
+
}, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
|
|
134
|
+
key: "edit.datasource",
|
|
135
|
+
onClick: onEditDatasource,
|
|
136
|
+
testId: "edit-dropdown-edit-datasource-item"
|
|
137
|
+
}, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
|
|
138
|
+
}
|
|
139
|
+
case 'none':
|
|
140
|
+
default:
|
|
141
|
+
return null;
|
|
79
142
|
}
|
|
80
|
-
var trigger = jsx(Button, {
|
|
81
|
-
testId: "edit-dropdown-trigger",
|
|
82
|
-
iconAfter: jsx("span", {
|
|
83
|
-
css: dropdownExpandContainer
|
|
84
|
-
}, jsx(ExpandIcon, {
|
|
85
|
-
label: intl.formatMessage(messages.editDropdownTriggerTitle)
|
|
86
|
-
})),
|
|
87
|
-
onClick: toggleOpen,
|
|
88
|
-
selected: isOpen,
|
|
89
|
-
disabled: false,
|
|
90
|
-
ariaHasPopup: true
|
|
91
|
-
}, jsx(FormattedMessage, messages.editDropdownTriggerTitle));
|
|
92
|
-
return jsx(Flex, {
|
|
93
|
-
ref: containerRef
|
|
94
|
-
}, jsx(UiDropdown, {
|
|
95
|
-
mountTo: containerRef.current,
|
|
96
|
-
isOpen: isOpen,
|
|
97
|
-
handleClickOutside: onClose,
|
|
98
|
-
handleEscapeKeydown: onClose,
|
|
99
|
-
trigger: trigger,
|
|
100
|
-
scrollableElement: containerRef.current,
|
|
101
|
-
arrowKeyNavigationProviderOptions: {
|
|
102
|
-
type: ArrowKeyNavigationType.MENU
|
|
103
|
-
}
|
|
104
|
-
}, jsx(ButtonItem, {
|
|
105
|
-
key: "edit.link",
|
|
106
|
-
onClick: onEditLink,
|
|
107
|
-
testId: "edit-dropdown-edit-link-item"
|
|
108
|
-
}, jsx(FormattedMessage, messages.editDropdownEditLinkTitle)), jsx(ButtonItem, {
|
|
109
|
-
key: "edit.datasource",
|
|
110
|
-
onClick: onEditDatasource,
|
|
111
|
-
testId: "edit-dropdown-edit-datasource-item"
|
|
112
|
-
}, jsx(FormattedMessage, messages.editDropdownEditDatasourceTitle))));
|
|
113
143
|
};
|
|
114
|
-
export var EditToolbarButton = function EditToolbarButton(
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
144
|
+
export var EditToolbarButton = function EditToolbarButton(props) {
|
|
145
|
+
var datasourceId = props.datasourceId,
|
|
146
|
+
intl = props.intl,
|
|
147
|
+
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
148
|
+
url = props.url,
|
|
149
|
+
editorView = props.editorView,
|
|
150
|
+
onLinkEditClick = props.onLinkEditClick;
|
|
151
|
+
return jsx(CardContextProvider, null, function (_ref) {
|
|
152
|
+
var cardContext = _ref.cardContext;
|
|
153
|
+
return jsx(EditToolbarButtonWithCardContext, {
|
|
154
|
+
datasourceId: datasourceId,
|
|
123
155
|
url: url,
|
|
124
156
|
intl: intl,
|
|
125
157
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
@@ -4,7 +4,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { CardContext } from '@atlaskit/link-provider';
|
|
7
|
-
export interface
|
|
7
|
+
export interface EditDatasourceToolbarButtonProps {
|
|
8
|
+
datasourceId?: string;
|
|
8
9
|
intl: IntlShape;
|
|
9
10
|
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
10
11
|
url?: string;
|
|
@@ -12,4 +13,4 @@ export interface EditToolbarButtonProps {
|
|
|
12
13
|
cardContext?: CardContext;
|
|
13
14
|
onLinkEditClick: Command;
|
|
14
15
|
}
|
|
15
|
-
export declare const EditToolbarButton: (
|
|
16
|
+
export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
|
|
@@ -4,7 +4,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { CardContext } from '@atlaskit/link-provider';
|
|
7
|
-
export interface
|
|
7
|
+
export interface EditDatasourceToolbarButtonProps {
|
|
8
|
+
datasourceId?: string;
|
|
8
9
|
intl: IntlShape;
|
|
9
10
|
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
10
11
|
url?: string;
|
|
@@ -12,4 +13,4 @@ export interface EditToolbarButtonProps {
|
|
|
12
13
|
cardContext?: CardContext;
|
|
13
14
|
onLinkEditClick: Command;
|
|
14
15
|
}
|
|
15
|
-
export declare const EditToolbarButton: (
|
|
16
|
+
export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/button": "^17.17.1",
|
|
38
38
|
"@atlaskit/custom-steps": "^0.2.0",
|
|
39
39
|
"@atlaskit/dropdown-menu": "^12.10.2",
|
|
40
|
-
"@atlaskit/editor-common": "^82.
|
|
40
|
+
"@atlaskit/editor-common": "^82.2.0",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
42
42
|
"@atlaskit/editor-plugin-decorations": "^1.1.0",
|
|
43
43
|
"@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
51
51
|
"@atlaskit/icon": "^22.3.0",
|
|
52
52
|
"@atlaskit/link-analytics": "^8.3.0",
|
|
53
|
-
"@atlaskit/link-client-extension": "^1.
|
|
53
|
+
"@atlaskit/link-client-extension": "^1.9.0",
|
|
54
54
|
"@atlaskit/link-datasource": "^2.3.0",
|
|
55
55
|
"@atlaskit/linking-common": "^5.7.0",
|
|
56
56
|
"@atlaskit/linking-types": "^8.9.0",
|