@atlaskit/editor-plugin-card 5.3.1 → 5.3.2
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/ui/DatasourceDropdownOption.js +101 -0
- package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +12 -5
- package/dist/cjs/ui/LinkToolbarAppearanceDropdown.js +12 -1
- package/dist/cjs/ui/toolbar.js +66 -71
- package/dist/es2019/ui/DatasourceDropdownOption.js +94 -0
- package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +12 -5
- package/dist/es2019/ui/LinkToolbarAppearanceDropdown.js +12 -1
- package/dist/es2019/ui/toolbar.js +59 -64
- package/dist/esm/ui/DatasourceDropdownOption.js +94 -0
- package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +12 -5
- package/dist/esm/ui/LinkToolbarAppearanceDropdown.js +12 -1
- package/dist/esm/ui/toolbar.js +66 -71
- package/dist/types/ui/DatasourceDropdownOption.d.ts +28 -0
- package/dist/types/ui/HyperlinkToolbarAppearanceDropdown.d.ts +3 -1
- package/dist/types/ui/LinkToolbarAppearanceDropdown.d.ts +7 -3
- package/dist/types-ts4.5/ui/DatasourceDropdownOption.d.ts +28 -0
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearanceDropdown.d.ts +3 -1
- package/dist/types-ts4.5/ui/LinkToolbarAppearanceDropdown.d.ts +7 -3
- package/package.json +3 -3
|
@@ -393,9 +393,11 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
393
393
|
allowEmbeds,
|
|
394
394
|
allowBlockCards: allowBlockCards,
|
|
395
395
|
editorAnalyticsApi,
|
|
396
|
+
allowDatasource: cardOptions.allowDatasource,
|
|
396
397
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
397
|
-
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)
|
|
398
|
-
|
|
398
|
+
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
|
|
399
|
+
isDatasourceView: isDatasource
|
|
400
|
+
}), ...(showDatasourceAppearance && editorExperiment('platform_editor_controls', 'control') ? [{
|
|
399
401
|
type: 'custom',
|
|
400
402
|
fallback: [],
|
|
401
403
|
render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
@@ -484,49 +486,57 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
484
486
|
const {
|
|
485
487
|
url
|
|
486
488
|
} = metadata;
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
489
|
+
if (editorExperiment('platform_editor_controls', 'control')) {
|
|
490
|
+
toolbarItems.push({
|
|
491
|
+
type: 'custom',
|
|
492
|
+
fallback: [],
|
|
493
|
+
render: editorView => {
|
|
494
|
+
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
495
|
+
key: "link-appearance",
|
|
496
|
+
url: url,
|
|
497
|
+
intl: intl,
|
|
498
|
+
currentAppearance: currentAppearance,
|
|
499
|
+
editorView: editorView,
|
|
500
|
+
editorState: state,
|
|
501
|
+
allowEmbeds: allowEmbeds,
|
|
502
|
+
allowBlockCards: allowBlockCards,
|
|
503
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
504
|
+
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
505
|
+
isDatasourceView: true
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}, {
|
|
509
|
+
type: 'custom',
|
|
510
|
+
fallback: [],
|
|
511
|
+
render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
494
512
|
intl: intl,
|
|
495
|
-
|
|
513
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
514
|
+
url: url,
|
|
496
515
|
editorView: editorView,
|
|
497
516
|
editorState: state,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
editorState: state,
|
|
510
|
-
allowEmbeds,
|
|
511
|
-
allowBlockCards: allowBlockCards,
|
|
512
|
-
editorAnalyticsApi,
|
|
513
|
-
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
514
|
-
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)
|
|
515
|
-
}), {
|
|
516
|
-
type: 'custom',
|
|
517
|
-
fallback: [],
|
|
518
|
-
render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
519
|
-
intl: intl,
|
|
520
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
521
|
-
url: url,
|
|
522
|
-
editorView: editorView,
|
|
517
|
+
selected: true,
|
|
518
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
519
|
+
})
|
|
520
|
+
}, {
|
|
521
|
+
type: 'separator'
|
|
522
|
+
});
|
|
523
|
+
} else {
|
|
524
|
+
toolbarItems.push(getLinkAppearanceDropdown({
|
|
525
|
+
url,
|
|
526
|
+
intl,
|
|
527
|
+
currentAppearance,
|
|
523
528
|
editorState: state,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
529
|
+
allowEmbeds,
|
|
530
|
+
allowBlockCards: allowBlockCards,
|
|
531
|
+
editorAnalyticsApi,
|
|
532
|
+
allowDatasource: cardOptions.allowDatasource,
|
|
533
|
+
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
534
|
+
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
|
|
535
|
+
isDatasourceView: true
|
|
536
|
+
}), {
|
|
537
|
+
type: 'separator'
|
|
538
|
+
});
|
|
539
|
+
}
|
|
530
540
|
}
|
|
531
541
|
toolbarItems.push({
|
|
532
542
|
type: 'custom',
|
|
@@ -635,27 +645,12 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
635
645
|
intl,
|
|
636
646
|
editorState: state,
|
|
637
647
|
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
648
|
+
allowDatasource: options.allowDatasource,
|
|
638
649
|
editorPluginApi: api,
|
|
639
650
|
cardOptions: options,
|
|
640
|
-
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)
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
fallback: [],
|
|
644
|
-
render: editorView => {
|
|
645
|
-
var _api$analytics4;
|
|
646
|
-
if (!editorView) {
|
|
647
|
-
return null;
|
|
648
|
-
}
|
|
649
|
-
return /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
650
|
-
intl: intl,
|
|
651
|
-
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
652
|
-
url: link,
|
|
653
|
-
editorView: editorView,
|
|
654
|
-
editorState: editorView.state,
|
|
655
|
-
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
}] : []), {
|
|
651
|
+
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),
|
|
652
|
+
isDatasourceView: false
|
|
653
|
+
}), {
|
|
659
654
|
type: 'separator'
|
|
660
655
|
}, ...editLinkItem];
|
|
661
656
|
}
|
|
@@ -672,7 +667,7 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
672
667
|
type: 'custom',
|
|
673
668
|
fallback: [],
|
|
674
669
|
render: editorView => {
|
|
675
|
-
var _api$
|
|
670
|
+
var _api$analytics4;
|
|
676
671
|
if (!editorView) {
|
|
677
672
|
return null;
|
|
678
673
|
}
|
|
@@ -683,7 +678,7 @@ export const getStartingToolbarItems = (options, api) => {
|
|
|
683
678
|
editorView: editorView,
|
|
684
679
|
editorState: editorView.state,
|
|
685
680
|
cardOptions: options,
|
|
686
|
-
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$
|
|
681
|
+
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
687
682
|
editorPluginApi: api
|
|
688
683
|
});
|
|
689
684
|
}
|
|
@@ -696,10 +691,10 @@ export const getEndingToolbarItems = (options, api) => (intl, link) => {
|
|
|
696
691
|
* Or explicit user preferences config in order to enable button
|
|
697
692
|
*/
|
|
698
693
|
if ((options.provider || options.userPreferencesLink) && editorExperiment('platform_editor_controls', 'control')) {
|
|
699
|
-
var _api$
|
|
694
|
+
var _api$analytics5;
|
|
700
695
|
return [{
|
|
701
696
|
type: 'separator'
|
|
702
|
-
}, getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$
|
|
697
|
+
}, 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)];
|
|
703
698
|
}
|
|
704
699
|
return [];
|
|
705
700
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import SmartLinkListIcon from '@atlaskit/icon/core/smart-link-list';
|
|
5
|
+
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
6
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
7
|
+
import { ButtonItem } from '@atlaskit/menu';
|
|
8
|
+
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
9
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
10
|
+
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
11
|
+
export var datasourceDisplayInformation = {
|
|
12
|
+
title: messages.datasourceAppearanceTitle,
|
|
13
|
+
icon: SmartLinkListIcon,
|
|
14
|
+
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
15
|
+
iconFallback: SmartLinkListIcon
|
|
16
|
+
};
|
|
17
|
+
export var DatasourceDropdownOption = function DatasourceDropdownOption(_ref) {
|
|
18
|
+
var allowDatasource = _ref.allowDatasource,
|
|
19
|
+
intl = _ref.intl,
|
|
20
|
+
url = _ref.url,
|
|
21
|
+
selected = _ref.selected,
|
|
22
|
+
inputMethod = _ref.inputMethod,
|
|
23
|
+
dispatchCommand = _ref.dispatchCommand;
|
|
24
|
+
var cardContext = useSmartLinkContext();
|
|
25
|
+
var _useFetchDatasourceIn = useFetchDatasourceInfo({
|
|
26
|
+
isRegularCardNode: true,
|
|
27
|
+
url: url,
|
|
28
|
+
cardContext: cardContext
|
|
29
|
+
}),
|
|
30
|
+
datasourceId = _useFetchDatasourceIn.datasourceId,
|
|
31
|
+
parameters = _useFetchDatasourceIn.parameters;
|
|
32
|
+
if (!allowDatasource || !datasourceId || !parameters) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
var onChangeAppearance = function onChangeAppearance(editorState, _dispatch, view) {
|
|
36
|
+
var _state$datasourceStas, _state$datasourceStas2;
|
|
37
|
+
if (!view || !datasourceId || !parameters) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
var state = pluginKey.getState(editorState);
|
|
41
|
+
var newAdf = buildDatasourceAdf({
|
|
42
|
+
id: datasourceId,
|
|
43
|
+
parameters: parameters,
|
|
44
|
+
views: (_state$datasourceStas = state === null || state === void 0 || (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
|
|
45
|
+
type: 'table'
|
|
46
|
+
}]
|
|
47
|
+
}, url);
|
|
48
|
+
var selection = editorState.selection;
|
|
49
|
+
var existingNode;
|
|
50
|
+
// Check if the selection contains a link mark
|
|
51
|
+
var $pos = editorState.doc.resolve(selection.from);
|
|
52
|
+
var isLinkMark = $pos.marks().some(function (mark) {
|
|
53
|
+
return mark.type === editorState.schema.marks.link;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
57
|
+
if (selection instanceof NodeSelection) {
|
|
58
|
+
existingNode = selection.node;
|
|
59
|
+
} else if (isLinkMark) {
|
|
60
|
+
var _editorState$doc$node;
|
|
61
|
+
existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
|
|
62
|
+
}
|
|
63
|
+
if (existingNode) {
|
|
64
|
+
updateCardViaDatasource({
|
|
65
|
+
state: editorState,
|
|
66
|
+
node: existingNode,
|
|
67
|
+
newAdf: newAdf,
|
|
68
|
+
view: view,
|
|
69
|
+
sourceEvent: undefined,
|
|
70
|
+
isDeletingConfig: true,
|
|
71
|
+
inputMethod: inputMethod
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
77
|
+
if (url) {
|
|
78
|
+
var _cardContext$store, _urlState$error;
|
|
79
|
+
var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
80
|
+
if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return /*#__PURE__*/React.createElement(ButtonItem, {
|
|
85
|
+
key: intl.formatMessage(messages.datasourceAppearanceTitle),
|
|
86
|
+
iconBefore: SmartLinkListIcon({
|
|
87
|
+
label: intl.formatMessage(messages.datasourceAppearanceTitle)
|
|
88
|
+
}),
|
|
89
|
+
onClick: function onClick() {
|
|
90
|
+
return dispatchCommand(onChangeAppearance);
|
|
91
|
+
},
|
|
92
|
+
isSelected: selected
|
|
93
|
+
}, intl.formatMessage(messages.datasourceAppearanceTitle));
|
|
94
|
+
};
|
|
@@ -15,8 +15,9 @@ var HyperlinkDropdown = function HyperlinkDropdown(props) {
|
|
|
15
15
|
intl = props.intl,
|
|
16
16
|
editorState = props.editorState,
|
|
17
17
|
cardOptions = props.cardOptions,
|
|
18
|
-
editorAnalyticsApi = props.editorAnalyticsApi
|
|
19
|
-
|
|
18
|
+
editorAnalyticsApi = props.editorAnalyticsApi,
|
|
19
|
+
allowDatasource = props.allowDatasource,
|
|
20
|
+
isDatasourceView = props.isDatasourceView;
|
|
20
21
|
// Ignored via go/ees005
|
|
21
22
|
// eslint-disable-next-line require-await
|
|
22
23
|
var getProvider = /*#__PURE__*/function () {
|
|
@@ -129,9 +130,11 @@ var HyperlinkDropdown = function HyperlinkDropdown(props) {
|
|
|
129
130
|
editorState: editorState,
|
|
130
131
|
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
131
132
|
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
133
|
+
allowDatasource: allowDatasource,
|
|
132
134
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
133
135
|
dispatchCommand: props.dispatchCommand,
|
|
134
|
-
settingsConfig: props.settingsConfig
|
|
136
|
+
settingsConfig: props.settingsConfig,
|
|
137
|
+
isDatasourceView: isDatasourceView
|
|
135
138
|
});
|
|
136
139
|
};
|
|
137
140
|
export var getHyperlinkAppearanceDropdown = function getHyperlinkAppearanceDropdown(_ref3) {
|
|
@@ -141,7 +144,9 @@ export var getHyperlinkAppearanceDropdown = function getHyperlinkAppearanceDropd
|
|
|
141
144
|
editorAnalyticsApi = _ref3.editorAnalyticsApi,
|
|
142
145
|
editorPluginApi = _ref3.editorPluginApi,
|
|
143
146
|
settingsConfig = _ref3.settingsConfig,
|
|
144
|
-
cardOptions = _ref3.cardOptions
|
|
147
|
+
cardOptions = _ref3.cardOptions,
|
|
148
|
+
allowDatasource = _ref3.allowDatasource,
|
|
149
|
+
isDatasourceView = _ref3.isDatasourceView;
|
|
145
150
|
var alignmentItemOptions = {
|
|
146
151
|
render: function render(props) {
|
|
147
152
|
if (!editorState) {
|
|
@@ -155,7 +160,9 @@ export var getHyperlinkAppearanceDropdown = function getHyperlinkAppearanceDropd
|
|
|
155
160
|
editorPluginApi: editorPluginApi,
|
|
156
161
|
dispatchCommand: props.dispatchCommand,
|
|
157
162
|
settingsConfig: settingsConfig,
|
|
158
|
-
cardOptions: cardOptions
|
|
163
|
+
cardOptions: cardOptions,
|
|
164
|
+
allowDatasource: allowDatasource,
|
|
165
|
+
isDatasourceView: isDatasourceView
|
|
159
166
|
});
|
|
160
167
|
},
|
|
161
168
|
width: 200,
|
|
@@ -10,6 +10,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
10
10
|
import { useSmartCardContext } from '@atlaskit/link-provider';
|
|
11
11
|
import { ButtonItem, LinkItem, MenuGroup, Section } from '@atlaskit/menu';
|
|
12
12
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
13
|
+
import { DatasourceDropdownOption, datasourceDisplayInformation } from './DatasourceDropdownOption';
|
|
13
14
|
import { getUnavailableMessage } from './LinkToolbarAppearance';
|
|
14
15
|
export var LinkAppearanceMenu = function LinkAppearanceMenu(_ref) {
|
|
15
16
|
var _cardContext$value, _setSelectedCardAppea, _setSelectedCardAppea2, _changeSelectedCardTo, _setSelectedCardAppea3;
|
|
@@ -20,6 +21,7 @@ export var LinkAppearanceMenu = function LinkAppearanceMenu(_ref) {
|
|
|
20
21
|
allowEmbeds = _ref.allowEmbeds,
|
|
21
22
|
_ref$allowBlockCards = _ref.allowBlockCards,
|
|
22
23
|
allowBlockCards = _ref$allowBlockCards === void 0 ? true : _ref$allowBlockCards,
|
|
24
|
+
allowDatasource = _ref.allowDatasource,
|
|
23
25
|
editorAnalyticsApi = _ref.editorAnalyticsApi,
|
|
24
26
|
_ref$showUpgradeDisco = _ref.showUpgradeDiscoverability,
|
|
25
27
|
showUpgradeDiscoverability = _ref$showUpgradeDisco === void 0 ? true : _ref$showUpgradeDisco,
|
|
@@ -102,6 +104,13 @@ export var LinkAppearanceMenu = function LinkAppearanceMenu(_ref) {
|
|
|
102
104
|
},
|
|
103
105
|
isSelected: option.selected
|
|
104
106
|
}, option.title);
|
|
107
|
+
}), /*#__PURE__*/React.createElement(DatasourceDropdownOption, {
|
|
108
|
+
allowDatasource: allowDatasource,
|
|
109
|
+
intl: intl,
|
|
110
|
+
url: url !== null && url !== void 0 ? url : '',
|
|
111
|
+
selected: Boolean(isDatasourceView),
|
|
112
|
+
inputMethod: INPUT_METHOD.FLOATING_TB,
|
|
113
|
+
dispatchCommand: dispatchCommand
|
|
105
114
|
})), /*#__PURE__*/React.createElement(Section, {
|
|
106
115
|
hasSeparator: true
|
|
107
116
|
}, /*#__PURE__*/React.createElement(LinkItem, {
|
|
@@ -120,6 +129,7 @@ export var getLinkAppearanceDropdown = function getLinkAppearanceDropdown(_ref2)
|
|
|
120
129
|
allowEmbeds = _ref2.allowEmbeds,
|
|
121
130
|
_ref2$allowBlockCards = _ref2.allowBlockCards,
|
|
122
131
|
allowBlockCards = _ref2$allowBlockCards === void 0 ? true : _ref2$allowBlockCards,
|
|
132
|
+
allowDatasource = _ref2.allowDatasource,
|
|
123
133
|
editorAnalyticsApi = _ref2.editorAnalyticsApi,
|
|
124
134
|
_ref2$showUpgradeDisc = _ref2.showUpgradeDiscoverability,
|
|
125
135
|
showUpgradeDiscoverability = _ref2$showUpgradeDisc === void 0 ? true : _ref2$showUpgradeDisc,
|
|
@@ -137,6 +147,7 @@ export var getLinkAppearanceDropdown = function getLinkAppearanceDropdown(_ref2)
|
|
|
137
147
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
138
148
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
139
149
|
isDatasourceView: isDatasourceView,
|
|
150
|
+
allowDatasource: allowDatasource,
|
|
140
151
|
dispatchCommand: props.dispatchCommand,
|
|
141
152
|
settingsConfig: settingsConfig
|
|
142
153
|
});
|
|
@@ -144,7 +155,7 @@ export var getLinkAppearanceDropdown = function getLinkAppearanceDropdown(_ref2)
|
|
|
144
155
|
width: 200,
|
|
145
156
|
height: 400
|
|
146
157
|
};
|
|
147
|
-
var currentAppearanceDisplayInformation = appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
|
|
158
|
+
var currentAppearanceDisplayInformation = isDatasourceView ? datasourceDisplayInformation : appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
|
|
148
159
|
var alignmentToolbarItem = {
|
|
149
160
|
id: 'card-appearance',
|
|
150
161
|
testId: 'card-appearance-dropdown',
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -391,9 +391,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
391
391
|
allowEmbeds: allowEmbeds,
|
|
392
392
|
allowBlockCards: allowBlockCards,
|
|
393
393
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
394
|
+
allowDatasource: cardOptions.allowDatasource,
|
|
394
395
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
395
|
-
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)
|
|
396
|
-
|
|
396
|
+
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
|
|
397
|
+
isDatasourceView: isDatasource
|
|
398
|
+
})], _toConsumableArray(showDatasourceAppearance && editorExperiment('platform_editor_controls', 'control') ? [{
|
|
397
399
|
type: 'custom',
|
|
398
400
|
fallback: [],
|
|
399
401
|
render: function render(editorView) {
|
|
@@ -481,51 +483,59 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
481
483
|
allowEmbeds = cardOptions.allowEmbeds,
|
|
482
484
|
showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
|
|
483
485
|
var url = metadata.url;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
486
|
+
if (editorExperiment('platform_editor_controls', 'control')) {
|
|
487
|
+
toolbarItems.push({
|
|
488
|
+
type: 'custom',
|
|
489
|
+
fallback: [],
|
|
490
|
+
render: function render(editorView) {
|
|
491
|
+
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
492
|
+
key: "link-appearance",
|
|
493
|
+
url: url,
|
|
494
|
+
intl: intl,
|
|
495
|
+
currentAppearance: currentAppearance,
|
|
496
|
+
editorView: editorView,
|
|
497
|
+
editorState: state,
|
|
498
|
+
allowEmbeds: allowEmbeds,
|
|
499
|
+
allowBlockCards: allowBlockCards,
|
|
500
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
501
|
+
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
502
|
+
isDatasourceView: true
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}, {
|
|
506
|
+
type: 'custom',
|
|
507
|
+
fallback: [],
|
|
508
|
+
render: function render(editorView) {
|
|
509
|
+
return /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
510
|
+
intl: intl,
|
|
511
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
512
|
+
url: url,
|
|
513
|
+
editorView: editorView,
|
|
514
|
+
editorState: state,
|
|
515
|
+
selected: true,
|
|
516
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}, {
|
|
520
|
+
type: 'separator'
|
|
521
|
+
});
|
|
522
|
+
} else {
|
|
523
|
+
toolbarItems.push(getLinkAppearanceDropdown({
|
|
524
|
+
url: url,
|
|
525
|
+
intl: intl,
|
|
526
|
+
currentAppearance: currentAppearance,
|
|
527
|
+
editorState: state,
|
|
528
|
+
allowEmbeds: allowEmbeds,
|
|
529
|
+
allowBlockCards: allowBlockCards,
|
|
530
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
531
|
+
allowDatasource: cardOptions.allowDatasource,
|
|
532
|
+
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
533
|
+
settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
|
|
534
|
+
isDatasourceView: true
|
|
535
|
+
}), {
|
|
536
|
+
type: 'separator'
|
|
537
|
+
});
|
|
538
|
+
}
|
|
529
539
|
}
|
|
530
540
|
toolbarItems.push({
|
|
531
541
|
type: 'custom',
|
|
@@ -638,29 +648,14 @@ export var getStartingToolbarItems = function getStartingToolbarItems(options, a
|
|
|
638
648
|
intl: intl,
|
|
639
649
|
editorState: state,
|
|
640
650
|
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
651
|
+
allowDatasource: options.allowDatasource,
|
|
641
652
|
editorPluginApi: api,
|
|
642
653
|
cardOptions: options,
|
|
643
|
-
settingsConfig: getSettingsButton(intl, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink)
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
fallback: [],
|
|
647
|
-
render: function render(editorView) {
|
|
648
|
-
var _api$analytics4;
|
|
649
|
-
if (!editorView) {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
return /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
653
|
-
intl: intl,
|
|
654
|
-
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
655
|
-
url: link,
|
|
656
|
-
editorView: editorView,
|
|
657
|
-
editorState: editorView.state,
|
|
658
|
-
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
}] : []), [{
|
|
654
|
+
settingsConfig: getSettingsButton(intl, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink),
|
|
655
|
+
isDatasourceView: false
|
|
656
|
+
}), {
|
|
662
657
|
type: 'separator'
|
|
663
|
-
}]
|
|
658
|
+
}].concat(editLinkItem);
|
|
664
659
|
}
|
|
665
660
|
return [{
|
|
666
661
|
type: 'custom',
|
|
@@ -677,7 +672,7 @@ export var getStartingToolbarItems = function getStartingToolbarItems(options, a
|
|
|
677
672
|
type: 'custom',
|
|
678
673
|
fallback: [],
|
|
679
674
|
render: function render(editorView) {
|
|
680
|
-
var _api$
|
|
675
|
+
var _api$analytics4;
|
|
681
676
|
if (!editorView) {
|
|
682
677
|
return null;
|
|
683
678
|
}
|
|
@@ -688,7 +683,7 @@ export var getStartingToolbarItems = function getStartingToolbarItems(options, a
|
|
|
688
683
|
editorView: editorView,
|
|
689
684
|
editorState: editorView.state,
|
|
690
685
|
cardOptions: options,
|
|
691
|
-
editorAnalyticsApi: api === null || api === void 0 || (_api$
|
|
686
|
+
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
692
687
|
editorPluginApi: api
|
|
693
688
|
});
|
|
694
689
|
}
|
|
@@ -702,10 +697,10 @@ export var getEndingToolbarItems = function getEndingToolbarItems(options, api)
|
|
|
702
697
|
* Or explicit user preferences config in order to enable button
|
|
703
698
|
*/
|
|
704
699
|
if ((options.provider || options.userPreferencesLink) && editorExperiment('platform_editor_controls', 'control')) {
|
|
705
|
-
var _api$
|
|
700
|
+
var _api$analytics5;
|
|
706
701
|
return [{
|
|
707
702
|
type: 'separator'
|
|
708
|
-
}, getSettingsButton(intl, api === null || api === void 0 || (_api$
|
|
703
|
+
}, getSettingsButton(intl, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, options.userPreferencesLink)];
|
|
709
704
|
}
|
|
710
705
|
return [];
|
|
711
706
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
interface Props {
|
|
5
|
+
allowDatasource?: boolean;
|
|
6
|
+
intl: IntlShape;
|
|
7
|
+
url: string;
|
|
8
|
+
selected: boolean;
|
|
9
|
+
inputMethod: string;
|
|
10
|
+
dispatchCommand: (command: Command) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const datasourceDisplayInformation: {
|
|
13
|
+
title: {
|
|
14
|
+
id: string;
|
|
15
|
+
defaultMessage: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
icon: {
|
|
19
|
+
(props: import("@atlaskit/icon").NewCoreIconProps): JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
iconFallback: {
|
|
23
|
+
(props: import("@atlaskit/icon").NewCoreIconProps): JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const DatasourceDropdownOption: ({ allowDatasource, intl, url, selected, inputMethod, dispatchCommand, }: Props) => React.JSX.Element | null;
|
|
28
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Command, FloatingToolbarDropdown, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { HyperlinkToolbarAppearanceProps } from './HyperlinkToolbarAppearance';
|
|
4
|
-
export declare const getHyperlinkAppearanceDropdown: ({ url, intl, editorState, editorAnalyticsApi, editorPluginApi, settingsConfig, cardOptions, }: Omit<HyperlinkToolbarAppearanceProps, "editorState"> & {
|
|
4
|
+
export declare const getHyperlinkAppearanceDropdown: ({ url, intl, editorState, editorAnalyticsApi, editorPluginApi, settingsConfig, cardOptions, allowDatasource, isDatasourceView, }: Omit<HyperlinkToolbarAppearanceProps, "editorState"> & {
|
|
5
5
|
settingsConfig: FloatingToolbarItem<Command>;
|
|
6
6
|
editorState?: EditorState | undefined;
|
|
7
|
+
allowDatasource?: boolean | undefined;
|
|
8
|
+
isDatasourceView?: boolean | undefined;
|
|
7
9
|
}) => FloatingToolbarDropdown<Command>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Command, FloatingToolbarDropdown, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
3
3
|
import { type LinkToolbarAppearanceProps } from './LinkToolbarAppearance';
|
|
4
|
-
|
|
4
|
+
type Props = LinkToolbarAppearanceProps & {
|
|
5
5
|
dispatchCommand: (command: Command) => void;
|
|
6
6
|
settingsConfig: FloatingToolbarItem<Command>;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
allowDatasource?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const LinkAppearanceMenu: ({ url, intl, currentAppearance, editorState, allowEmbeds, allowBlockCards, allowDatasource, editorAnalyticsApi, showUpgradeDiscoverability, isDatasourceView, dispatchCommand, settingsConfig, }: Props) => React.JSX.Element | null;
|
|
10
|
+
export declare const getLinkAppearanceDropdown: ({ url, intl, currentAppearance, editorState, allowEmbeds, allowBlockCards, allowDatasource, editorAnalyticsApi, showUpgradeDiscoverability, isDatasourceView, settingsConfig, }: LinkToolbarAppearanceProps & {
|
|
9
11
|
settingsConfig: FloatingToolbarItem<Command>;
|
|
12
|
+
allowDatasource?: boolean | undefined;
|
|
10
13
|
}) => FloatingToolbarDropdown<Command>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
interface Props {
|
|
5
|
+
allowDatasource?: boolean;
|
|
6
|
+
intl: IntlShape;
|
|
7
|
+
url: string;
|
|
8
|
+
selected: boolean;
|
|
9
|
+
inputMethod: string;
|
|
10
|
+
dispatchCommand: (command: Command) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const datasourceDisplayInformation: {
|
|
13
|
+
title: {
|
|
14
|
+
id: string;
|
|
15
|
+
defaultMessage: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
icon: {
|
|
19
|
+
(props: import("@atlaskit/icon").NewCoreIconProps): JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
iconFallback: {
|
|
23
|
+
(props: import("@atlaskit/icon").NewCoreIconProps): JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const DatasourceDropdownOption: ({ allowDatasource, intl, url, selected, inputMethod, dispatchCommand, }: Props) => React.JSX.Element | null;
|
|
28
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Command, FloatingToolbarDropdown, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { HyperlinkToolbarAppearanceProps } from './HyperlinkToolbarAppearance';
|
|
4
|
-
export declare const getHyperlinkAppearanceDropdown: ({ url, intl, editorState, editorAnalyticsApi, editorPluginApi, settingsConfig, cardOptions, }: Omit<HyperlinkToolbarAppearanceProps, "editorState"> & {
|
|
4
|
+
export declare const getHyperlinkAppearanceDropdown: ({ url, intl, editorState, editorAnalyticsApi, editorPluginApi, settingsConfig, cardOptions, allowDatasource, isDatasourceView, }: Omit<HyperlinkToolbarAppearanceProps, "editorState"> & {
|
|
5
5
|
settingsConfig: FloatingToolbarItem<Command>;
|
|
6
6
|
editorState?: EditorState | undefined;
|
|
7
|
+
allowDatasource?: boolean | undefined;
|
|
8
|
+
isDatasourceView?: boolean | undefined;
|
|
7
9
|
}) => FloatingToolbarDropdown<Command>;
|