@atlaskit/editor-plugin-card 5.3.1 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/nodeviews/embedCard.js +2 -6
- 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/ResizableEmbedCard.js +1 -2
- package/dist/cjs/ui/toolbar.js +66 -71
- package/dist/es2019/nodeviews/embedCard.js +2 -6
- 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/ResizableEmbedCard.js +1 -2
- package/dist/es2019/ui/toolbar.js +59 -64
- package/dist/esm/nodeviews/embedCard.js +2 -6
- 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/ResizableEmbedCard.js +1 -2
- 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 -6
|
@@ -7,6 +7,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
7
7
|
import { useSmartCardContext } from '@atlaskit/link-provider';
|
|
8
8
|
import { ButtonItem, LinkItem, MenuGroup, Section } from '@atlaskit/menu';
|
|
9
9
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
10
|
+
import { DatasourceDropdownOption, datasourceDisplayInformation } from './DatasourceDropdownOption';
|
|
10
11
|
import { getUnavailableMessage } from './LinkToolbarAppearance';
|
|
11
12
|
export const LinkAppearanceMenu = ({
|
|
12
13
|
url,
|
|
@@ -15,6 +16,7 @@ export const LinkAppearanceMenu = ({
|
|
|
15
16
|
editorState,
|
|
16
17
|
allowEmbeds,
|
|
17
18
|
allowBlockCards = true,
|
|
19
|
+
allowDatasource,
|
|
18
20
|
editorAnalyticsApi,
|
|
19
21
|
showUpgradeDiscoverability = true,
|
|
20
22
|
isDatasourceView,
|
|
@@ -93,6 +95,13 @@ export const LinkAppearanceMenu = ({
|
|
|
93
95
|
onClick: () => option.onClick(),
|
|
94
96
|
isSelected: option.selected
|
|
95
97
|
}, option.title);
|
|
98
|
+
}), /*#__PURE__*/React.createElement(DatasourceDropdownOption, {
|
|
99
|
+
allowDatasource: allowDatasource,
|
|
100
|
+
intl: intl,
|
|
101
|
+
url: url !== null && url !== void 0 ? url : '',
|
|
102
|
+
selected: Boolean(isDatasourceView),
|
|
103
|
+
inputMethod: INPUT_METHOD.FLOATING_TB,
|
|
104
|
+
dispatchCommand: dispatchCommand
|
|
96
105
|
})), /*#__PURE__*/React.createElement(Section, {
|
|
97
106
|
hasSeparator: true
|
|
98
107
|
}, /*#__PURE__*/React.createElement(LinkItem, {
|
|
@@ -110,6 +119,7 @@ export const getLinkAppearanceDropdown = ({
|
|
|
110
119
|
editorState,
|
|
111
120
|
allowEmbeds,
|
|
112
121
|
allowBlockCards = true,
|
|
122
|
+
allowDatasource,
|
|
113
123
|
editorAnalyticsApi,
|
|
114
124
|
showUpgradeDiscoverability = true,
|
|
115
125
|
isDatasourceView,
|
|
@@ -127,6 +137,7 @@ export const getLinkAppearanceDropdown = ({
|
|
|
127
137
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
128
138
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
129
139
|
isDatasourceView: isDatasourceView,
|
|
140
|
+
allowDatasource: allowDatasource,
|
|
130
141
|
dispatchCommand: props.dispatchCommand,
|
|
131
142
|
settingsConfig: settingsConfig
|
|
132
143
|
});
|
|
@@ -134,7 +145,7 @@ export const getLinkAppearanceDropdown = ({
|
|
|
134
145
|
width: 200,
|
|
135
146
|
height: 400
|
|
136
147
|
};
|
|
137
|
-
const currentAppearanceDisplayInformation = appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
|
|
148
|
+
const currentAppearanceDisplayInformation = isDatasourceView ? datasourceDisplayInformation : appearancePropsMap[currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'];
|
|
138
149
|
const alignmentToolbarItem = {
|
|
139
150
|
id: 'card-appearance',
|
|
140
151
|
testId: 'card-appearance-dropdown',
|
|
@@ -11,7 +11,6 @@ import { jsx } from '@emotion/react';
|
|
|
11
11
|
import { calcColumnsFromPx, calcMediaPxWidth, calcPctFromPx, calcPxFromColumns, handleSides, imageAlignmentMap, Resizer, snapTo, wrappedLayouts, wrapperStyle } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { akEditorBreakoutPadding, akEditorMediaResizeHandlerPadding, akEditorWideLayoutWidth, breakoutWideScaleRatio, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { embedHeaderHeight } from '@atlaskit/smart-card';
|
|
16
15
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
17
16
|
export default class ResizableEmbedCard extends React.Component {
|
|
@@ -320,7 +319,7 @@ export default class ResizableEmbedCard extends React.Component {
|
|
|
320
319
|
};
|
|
321
320
|
const enable = {};
|
|
322
321
|
handleSides.forEach(side => {
|
|
323
|
-
if (isResizeDisabled
|
|
322
|
+
if (isResizeDisabled) {
|
|
324
323
|
enable[side] = false;
|
|
325
324
|
return;
|
|
326
325
|
}
|
|
@@ -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
|
};
|
|
@@ -51,8 +51,7 @@ var CardInner = function CardInner(_ref) {
|
|
|
51
51
|
}
|
|
52
52
|
var lineLength = getLineLength(view, pos, widthStateLineLength);
|
|
53
53
|
var containerWidth = isRichMediaInsideOfBlockNode(view, pos) ? lineLength : widthStateWidth;
|
|
54
|
-
|
|
55
|
-
if (!allowResizing || !hasPreview || editorDisabledWhenGateDisabled) {
|
|
54
|
+
if (!allowResizing || !hasPreview) {
|
|
56
55
|
// There are two ways `width` and `height` can be defined here:
|
|
57
56
|
// 1) Either as `heightAlone` as height value and no width
|
|
58
57
|
// 2) or as `1` for height and aspectRation (defined or a default one) as a width
|
|
@@ -97,10 +96,7 @@ var CardInner = function CardInner(_ref) {
|
|
|
97
96
|
containerWidth: containerWidth,
|
|
98
97
|
displayGrid: displayGrid,
|
|
99
98
|
updateSize: updateSize,
|
|
100
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
101
|
-
// Ignored via go/ees005
|
|
102
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
103
|
-
}, fg('platform_fix_embedded_card_re-rendering') && {
|
|
99
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
104
100
|
isResizeDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
|
|
105
101
|
}), smartCard);
|
|
106
102
|
};
|
|
@@ -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',
|
|
@@ -20,7 +20,6 @@ import { jsx } from '@emotion/react';
|
|
|
20
20
|
import { calcColumnsFromPx, calcMediaPxWidth, calcPctFromPx, calcPxFromColumns, handleSides, imageAlignmentMap, Resizer, snapTo, wrappedLayouts, wrapperStyle } from '@atlaskit/editor-common/ui';
|
|
21
21
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
22
22
|
import { akEditorBreakoutPadding, akEditorMediaResizeHandlerPadding, akEditorWideLayoutWidth, breakoutWideScaleRatio, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
23
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
24
23
|
import { embedHeaderHeight } from '@atlaskit/smart-card';
|
|
25
24
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
26
25
|
var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
|
|
@@ -335,7 +334,7 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
|
|
|
335
334
|
};
|
|
336
335
|
var enable = {};
|
|
337
336
|
handleSides.forEach(function (side) {
|
|
338
|
-
if (isResizeDisabled
|
|
337
|
+
if (isResizeDisabled) {
|
|
339
338
|
enable[side] = false;
|
|
340
339
|
return;
|
|
341
340
|
}
|