@atlaskit/editor-plugin-card 1.15.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/plugin.js +2 -12
- package/dist/cjs/pm-plugins/doc.js +88 -2
- package/dist/cjs/toolbar.js +4 -7
- package/dist/cjs/ui/EditLinkToolbar.js +3 -15
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +3 -5
- package/dist/cjs/ui/LinkToolbarAppearance.js +6 -6
- package/dist/cjs/utils.js +1 -4
- package/dist/es2019/plugin.js +3 -11
- package/dist/es2019/pm-plugins/doc.js +84 -1
- package/dist/es2019/toolbar.js +18 -23
- package/dist/es2019/ui/EditLinkToolbar.js +3 -16
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +3 -5
- package/dist/es2019/ui/LinkToolbarAppearance.js +6 -6
- package/dist/es2019/utils.js +0 -3
- package/dist/esm/plugin.js +3 -13
- package/dist/esm/pm-plugins/doc.js +88 -1
- package/dist/esm/toolbar.js +5 -8
- package/dist/esm/ui/EditLinkToolbar.js +3 -15
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +3 -5
- package/dist/esm/ui/LinkToolbarAppearance.js +6 -6
- package/dist/esm/utils.js +0 -3
- package/dist/types/plugin.d.ts +1 -7
- package/dist/types/pm-plugins/doc.d.ts +11 -4
- package/dist/types/ui/EditLinkToolbar.d.ts +4 -8
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +1 -2
- package/dist/types/ui/LinkToolbarAppearance.d.ts +0 -2
- package/dist/types/utils.d.ts +0 -2
- package/dist/types-ts4.5/plugin.d.ts +1 -7
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +11 -4
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +4 -8
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +1 -2
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +0 -2
- package/dist/types-ts4.5/utils.d.ts +0 -2
- package/package.json +5 -6
- package/dist/cjs/pm-plugins/mountHyperlink.js +0 -84
- package/dist/es2019/pm-plugins/mountHyperlink.js +0 -72
- package/dist/esm/pm-plugins/mountHyperlink.js +0 -77
- package/dist/types/pm-plugins/mountHyperlink.d.ts +0 -5
- package/dist/types-ts4.5/pm-plugins/mountHyperlink.d.ts +0 -5
package/dist/es2019/toolbar.js
CHANGED
|
@@ -22,7 +22,7 @@ import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/Edit
|
|
|
22
22
|
import { EditToolbarButton } from './ui/EditToolbarButton';
|
|
23
23
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
24
24
|
import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
|
|
25
|
-
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode,
|
|
25
|
+
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
|
|
26
26
|
export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
|
|
27
27
|
if (!(state.selection instanceof NodeSelection)) {
|
|
28
28
|
return false;
|
|
@@ -214,13 +214,13 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
214
214
|
lpLinkPicker
|
|
215
215
|
})];
|
|
216
216
|
} else if (shouldRenderDatasourceToolbar) {
|
|
217
|
-
|
|
218
|
-
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions);
|
|
217
|
+
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform);
|
|
219
218
|
} else {
|
|
220
219
|
const {
|
|
221
220
|
inlineCard
|
|
222
221
|
} = state.schema.nodes;
|
|
223
|
-
const
|
|
222
|
+
const isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
|
|
223
|
+
const toolbarItems = [isEditDropdownEnabled ? {
|
|
224
224
|
type: 'custom',
|
|
225
225
|
fallback: [],
|
|
226
226
|
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
@@ -298,23 +298,19 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
298
298
|
toolbarItems.unshift(...getToolbarViewedItem(url, currentAppearance), {
|
|
299
299
|
type: 'custom',
|
|
300
300
|
fallback: [],
|
|
301
|
-
render: editorView => {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions,
|
|
315
|
-
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
316
|
-
});
|
|
317
|
-
}
|
|
301
|
+
render: editorView => /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
302
|
+
key: "link-appearance",
|
|
303
|
+
url: url,
|
|
304
|
+
intl: intl,
|
|
305
|
+
currentAppearance: currentAppearance,
|
|
306
|
+
editorView: editorView,
|
|
307
|
+
editorState: state,
|
|
308
|
+
allowEmbeds: allowEmbeds,
|
|
309
|
+
allowBlockCards: allowBlockCards,
|
|
310
|
+
platform: platform,
|
|
311
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
312
|
+
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
313
|
+
})
|
|
318
314
|
}, ...(showDatasourceAppearance ? [{
|
|
319
315
|
type: 'custom',
|
|
320
316
|
fallback: [],
|
|
@@ -384,7 +380,7 @@ export const getSettingsButtonGroup = (intl, editorAnalyticsApi, userPreferences
|
|
|
384
380
|
type: 'separator'
|
|
385
381
|
}];
|
|
386
382
|
};
|
|
387
|
-
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform
|
|
383
|
+
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) => {
|
|
388
384
|
var _node$attrs3;
|
|
389
385
|
const toolbarItems = [];
|
|
390
386
|
if (isDatasourceConfigEditable(datasourceId) && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
@@ -453,7 +449,6 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
453
449
|
allowBlockCards: allowBlockCards,
|
|
454
450
|
platform: platform,
|
|
455
451
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
456
|
-
cardActions: cardActions,
|
|
457
452
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
458
453
|
isDatasourceView: true
|
|
459
454
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, buildEditLinkPayload, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
4
|
import { HyperlinkAddToolbar as HyperlinkToolbar } from '@atlaskit/editor-common/link';
|
|
6
5
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
7
6
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
@@ -21,12 +20,8 @@ export function HyperlinkAddToolbarWithState({
|
|
|
21
20
|
lpLinkPicker,
|
|
22
21
|
onClose,
|
|
23
22
|
onEscapeCallback,
|
|
24
|
-
onClickAwayCallback
|
|
25
|
-
pluginInjectionApi
|
|
23
|
+
onClickAwayCallback
|
|
26
24
|
}) {
|
|
27
|
-
const {
|
|
28
|
-
hyperlinkState
|
|
29
|
-
} = useSharedPluginState(pluginInjectionApi, ['hyperlink']);
|
|
30
25
|
return /*#__PURE__*/React.createElement(HyperlinkToolbar, {
|
|
31
26
|
linkPickerOptions: linkPickerOptions,
|
|
32
27
|
onSubmit: onSubmit,
|
|
@@ -39,8 +34,7 @@ export function HyperlinkAddToolbarWithState({
|
|
|
39
34
|
lpLinkPicker: lpLinkPicker,
|
|
40
35
|
onClose: onClose,
|
|
41
36
|
onEscapeCallback: onEscapeCallback,
|
|
42
|
-
onClickAwayCallback: onClickAwayCallback
|
|
43
|
-
hyperlinkPluginState: hyperlinkState
|
|
37
|
+
onClickAwayCallback: onClickAwayCallback
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
|
|
@@ -68,12 +62,10 @@ export class EditLinkToolbar extends React.Component {
|
|
|
68
62
|
text,
|
|
69
63
|
view,
|
|
70
64
|
onSubmit,
|
|
71
|
-
pluginInjectionApi,
|
|
72
65
|
forceFocusSelector,
|
|
73
66
|
lpLinkPicker
|
|
74
67
|
} = this.props;
|
|
75
68
|
return /*#__PURE__*/React.createElement(HyperlinkAddToolbarWithState, {
|
|
76
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
77
69
|
view: view,
|
|
78
70
|
linkPickerOptions: linkPickerOptions,
|
|
79
71
|
providerFactory: providerFactory,
|
|
@@ -91,11 +83,9 @@ export class EditLinkToolbar extends React.Component {
|
|
|
91
83
|
}
|
|
92
84
|
},
|
|
93
85
|
onEscapeCallback: (state, dispatch) => {
|
|
94
|
-
var _pluginInjectionApi$h;
|
|
95
86
|
const {
|
|
96
87
|
tr
|
|
97
88
|
} = state;
|
|
98
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$h = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h === void 0 ? void 0 : _pluginInjectionApi$h.actions.hideLinkToolbar(tr);
|
|
99
89
|
hideLinkToolbar(tr);
|
|
100
90
|
forceFocusSelector === null || forceFocusSelector === void 0 ? void 0 : forceFocusSelector(`[aria-label="${linkToolbarMessages.editLink.defaultMessage}"]`)(tr);
|
|
101
91
|
if (dispatch) {
|
|
@@ -105,11 +95,9 @@ export class EditLinkToolbar extends React.Component {
|
|
|
105
95
|
return false;
|
|
106
96
|
},
|
|
107
97
|
onClickAwayCallback: (state, dispatch) => {
|
|
108
|
-
var _pluginInjectionApi$h2;
|
|
109
98
|
const {
|
|
110
99
|
tr
|
|
111
100
|
} = state;
|
|
112
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$h2 = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h2 === void 0 ? void 0 : _pluginInjectionApi$h2.actions.hideLinkToolbar(tr);
|
|
113
101
|
if (dispatch) {
|
|
114
102
|
dispatch(tr);
|
|
115
103
|
return true;
|
|
@@ -138,8 +126,8 @@ export const editLink = editorAnalyticsApi => (state, dispatch) => {
|
|
|
138
126
|
export const buildEditLinkToolbar = ({
|
|
139
127
|
providerFactory,
|
|
140
128
|
node,
|
|
141
|
-
linkPicker,
|
|
142
129
|
pluginInjectionApi,
|
|
130
|
+
linkPicker,
|
|
143
131
|
lpLinkPicker
|
|
144
132
|
}) => {
|
|
145
133
|
return {
|
|
@@ -153,7 +141,6 @@ export const buildEditLinkToolbar = ({
|
|
|
153
141
|
}
|
|
154
142
|
const displayInfo = displayInfoForCard(node, findCardInfo(view.state));
|
|
155
143
|
return /*#__PURE__*/React.createElement(EditLinkToolbar, {
|
|
156
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
157
144
|
key: idx,
|
|
158
145
|
view: view,
|
|
159
146
|
linkPickerOptions: linkPicker,
|
|
@@ -67,8 +67,7 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
67
67
|
editorState,
|
|
68
68
|
cardOptions,
|
|
69
69
|
platform,
|
|
70
|
-
editorAnalyticsApi
|
|
71
|
-
cardActions
|
|
70
|
+
editorAnalyticsApi
|
|
72
71
|
} = this.props;
|
|
73
72
|
const {
|
|
74
73
|
supportedUrlsMap
|
|
@@ -76,7 +75,7 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
76
75
|
if (!supportedUrlsMap.get(url)) {
|
|
77
76
|
return null;
|
|
78
77
|
}
|
|
79
|
-
return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(EditDatasourceButton, {
|
|
78
|
+
return /*#__PURE__*/React.createElement(Flex, null, !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && /*#__PURE__*/React.createElement(EditDatasourceButton, {
|
|
80
79
|
url: url,
|
|
81
80
|
intl: intl,
|
|
82
81
|
editorState: editorState,
|
|
@@ -91,8 +90,7 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
91
90
|
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
92
91
|
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
93
92
|
platform: platform,
|
|
94
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
95
|
-
cardActions: cardActions
|
|
93
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
96
94
|
}), getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && (cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowDatasource) && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
97
95
|
intl: intl,
|
|
98
96
|
url: url,
|
|
@@ -8,6 +8,7 @@ import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/mes
|
|
|
8
8
|
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import { LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR } from '../common/local-storage';
|
|
11
|
+
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
11
12
|
import { shouldRenderToolbarPulse } from '../toolbar';
|
|
12
13
|
import { getResolvedAttributesFromStore } from '../utils';
|
|
13
14
|
import { DiscoveryPulse } from './Pulse';
|
|
@@ -16,7 +17,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
16
17
|
constructor(...args) {
|
|
17
18
|
super(...args);
|
|
18
19
|
_defineProperty(this, "renderDropdown", (view, cardContext) => {
|
|
19
|
-
var
|
|
20
|
+
var _setSelectedCardAppea, _setSelectedCardAppea2, _changeSelectedCardTo, _setSelectedCardAppea3, _cardContext$store2, _cardContext$store2$g;
|
|
20
21
|
const {
|
|
21
22
|
url,
|
|
22
23
|
intl,
|
|
@@ -26,7 +27,6 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
26
27
|
allowBlockCards = true,
|
|
27
28
|
platform,
|
|
28
29
|
editorAnalyticsApi,
|
|
29
|
-
cardActions,
|
|
30
30
|
showUpgradeDiscoverability = true,
|
|
31
31
|
isDatasourceView
|
|
32
32
|
} = this.props;
|
|
@@ -44,7 +44,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
44
44
|
const embedOption = allowEmbeds && preview && {
|
|
45
45
|
appearance: 'embed',
|
|
46
46
|
title: intl.formatMessage(messages.embed),
|
|
47
|
-
onClick: (
|
|
47
|
+
onClick: (_setSelectedCardAppea = setSelectedCardAppearance('embed', editorAnalyticsApi)) !== null && _setSelectedCardAppea !== void 0 ? _setSelectedCardAppea : defaultCommand,
|
|
48
48
|
selected: currentAppearance === 'embed',
|
|
49
49
|
hidden: false,
|
|
50
50
|
testId: 'embed-appearance',
|
|
@@ -54,7 +54,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
54
54
|
const blockCardOption = allowBlockCards && {
|
|
55
55
|
appearance: 'block',
|
|
56
56
|
title: intl.formatMessage(messages.block),
|
|
57
|
-
onClick: (
|
|
57
|
+
onClick: (_setSelectedCardAppea2 = setSelectedCardAppearance('block', editorAnalyticsApi)) !== null && _setSelectedCardAppea2 !== void 0 ? _setSelectedCardAppea2 : defaultCommand,
|
|
58
58
|
selected: currentAppearance === 'block' && !isDatasourceView,
|
|
59
59
|
testId: 'block-appearance',
|
|
60
60
|
disabled: !isBlockCardLinkSupportedInParent,
|
|
@@ -62,7 +62,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
62
62
|
};
|
|
63
63
|
const options = [{
|
|
64
64
|
title: intl.formatMessage(messages.url),
|
|
65
|
-
onClick: commandWithMetadata((
|
|
65
|
+
onClick: commandWithMetadata((_changeSelectedCardTo = changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi)) !== null && _changeSelectedCardTo !== void 0 ? _changeSelectedCardTo : defaultCommand, {
|
|
66
66
|
action: ACTION.CHANGED_TYPE
|
|
67
67
|
}),
|
|
68
68
|
selected: !currentAppearance && !isDatasourceView,
|
|
@@ -70,7 +70,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
70
70
|
}, {
|
|
71
71
|
appearance: 'inline',
|
|
72
72
|
title: intl.formatMessage(messages.inline),
|
|
73
|
-
onClick: (
|
|
73
|
+
onClick: (_setSelectedCardAppea3 = setSelectedCardAppearance('inline', editorAnalyticsApi)) !== null && _setSelectedCardAppea3 !== void 0 ? _setSelectedCardAppea3 : defaultCommand,
|
|
74
74
|
selected: currentAppearance === 'inline',
|
|
75
75
|
testId: 'inline-appearance'
|
|
76
76
|
}];
|
package/dist/es2019/utils.js
CHANGED
|
@@ -73,9 +73,6 @@ export const isDatasourceConfigEditable = datasourceId => {
|
|
|
73
73
|
}
|
|
74
74
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
75
75
|
};
|
|
76
|
-
export const isEditDropdownEnabled = platform => {
|
|
77
|
-
return getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile';
|
|
78
|
-
};
|
|
79
76
|
|
|
80
77
|
/**
|
|
81
78
|
* Typeguard that checks node attributes are datasource node attributes
|
package/dist/esm/plugin.js
CHANGED
|
@@ -10,10 +10,9 @@ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } f
|
|
|
10
10
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { createEventsQueue } from './analytics/create-events-queue';
|
|
12
12
|
import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
|
|
13
|
-
import {
|
|
13
|
+
import { getEndingToolbarItems, getStartingToolbarItems, queueCardsFromChangedTr } from './pm-plugins/doc';
|
|
14
14
|
import { cardKeymap } from './pm-plugins/keymap';
|
|
15
15
|
import { createPlugin } from './pm-plugins/main';
|
|
16
|
-
import { mountHyperlinkPlugin } from './pm-plugins/mountHyperlink';
|
|
17
16
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
18
17
|
import { floatingToolbar } from './toolbar';
|
|
19
18
|
import DatasourceModalWithState from './ui/DatasourceModal/ModalWithState';
|
|
@@ -21,10 +20,6 @@ import { EditorLinkingPlatformAnalytics } from './ui/EditorLinkingPlatformAnalyt
|
|
|
21
20
|
import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
22
21
|
import LayoutButton from './ui/LayoutButton';
|
|
23
22
|
import { isDatasourceConfigEditable } from './utils';
|
|
24
|
-
/**
|
|
25
|
-
* Card plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
26
|
-
* from `@atlaskit/editor-core`.
|
|
27
|
-
*/
|
|
28
23
|
export var cardPlugin = function cardPlugin(_ref) {
|
|
29
24
|
var _options$lpLinkPicker;
|
|
30
25
|
var options = _ref.config,
|
|
@@ -75,11 +70,6 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
75
70
|
cardPluginEvents: cardPluginEvents,
|
|
76
71
|
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
77
72
|
}), api)
|
|
78
|
-
}, {
|
|
79
|
-
name: 'cardHyperlink',
|
|
80
|
-
plugin: function plugin() {
|
|
81
|
-
return mountHyperlinkPlugin(api, options);
|
|
82
|
-
}
|
|
83
73
|
}];
|
|
84
74
|
plugins.push({
|
|
85
75
|
name: 'cardKeymap',
|
|
@@ -115,8 +105,8 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
115
105
|
actions: {
|
|
116
106
|
hideLinkToolbar: hideLinkToolbar,
|
|
117
107
|
queueCardsFromChangedTr: queueCardsFromChangedTr,
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
getStartingToolbarItems: getStartingToolbarItems(options, api),
|
|
109
|
+
getEndingToolbarItems: getEndingToolbarItems(options, api)
|
|
120
110
|
},
|
|
121
111
|
pluginsOptions: {
|
|
122
112
|
floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.platform, options.linkPicker, api, options.disableFloatingToolbar),
|
|
@@ -2,18 +2,25 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
import React from 'react';
|
|
5
6
|
import isEqual from 'lodash/isEqual';
|
|
6
7
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
7
8
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE, unlinkPayload } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
10
|
+
import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
9
11
|
import { getDatasourceType, getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
|
|
10
12
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
11
13
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
14
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
|
+
import { getHyperlinkToolbarSettingsButton } from '../toolbar';
|
|
16
|
+
import { EditToolbarButton } from '../ui/EditToolbarButton';
|
|
17
|
+
import { HyperlinkToolbarAppearance } from '../ui/HyperlinkToolbarAppearance';
|
|
18
|
+
import { ToolbarViewedEvent } from '../ui/ToolbarViewedEvent';
|
|
13
19
|
import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, selectedCardAppearance } from '../utils';
|
|
14
20
|
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash, showDatasourceModal } from './actions';
|
|
15
21
|
import { pluginKey } from './plugin-key';
|
|
16
22
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Attempt to replace the link into the respective card.
|
|
19
26
|
*/
|
|
@@ -561,7 +568,7 @@ var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
|
561
568
|
}
|
|
562
569
|
}
|
|
563
570
|
};
|
|
564
|
-
export var editDatasource = function editDatasource(datasourceId,
|
|
571
|
+
export var editDatasource = function editDatasource(datasourceId, editorAnalyticsApi) {
|
|
565
572
|
return function (state, dispatch) {
|
|
566
573
|
var datasourceType = getDatasourceType(datasourceId);
|
|
567
574
|
if (dispatch && datasourceType) {
|
|
@@ -580,4 +587,84 @@ export var editDatasource = function editDatasource(datasourceId, _editorAnalyti
|
|
|
580
587
|
}
|
|
581
588
|
return false;
|
|
582
589
|
};
|
|
590
|
+
};
|
|
591
|
+
export var getStartingToolbarItems = function getStartingToolbarItems(options, api) {
|
|
592
|
+
return function (intl, link, providerFactory, onEditLink, metadata) {
|
|
593
|
+
var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && options.platform !== 'mobile' && options.allowDatasource;
|
|
594
|
+
var editLinkItem = isEditDropdownEnabled ? [{
|
|
595
|
+
type: 'custom',
|
|
596
|
+
fallback: [],
|
|
597
|
+
render: function render(editorView) {
|
|
598
|
+
var _api$analytics;
|
|
599
|
+
if (!editorView) {
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
return /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
603
|
+
key: "edit-toolbar-button",
|
|
604
|
+
intl: intl,
|
|
605
|
+
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
606
|
+
url: link,
|
|
607
|
+
editorView: editorView,
|
|
608
|
+
onLinkEditClick: onEditLink
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}] : [{
|
|
612
|
+
id: 'editor.link.edit',
|
|
613
|
+
testId: 'editor.link.edit',
|
|
614
|
+
type: 'button',
|
|
615
|
+
onClick: onEditLink,
|
|
616
|
+
title: intl.formatMessage(linkToolbarMessages.editLink),
|
|
617
|
+
showTitle: true,
|
|
618
|
+
metadata: metadata
|
|
619
|
+
}];
|
|
620
|
+
return [{
|
|
621
|
+
type: 'custom',
|
|
622
|
+
fallback: [],
|
|
623
|
+
render: function render(editorView) {
|
|
624
|
+
return /*#__PURE__*/React.createElement(ToolbarViewedEvent, {
|
|
625
|
+
key: "edit.link.menu.viewed",
|
|
626
|
+
url: link,
|
|
627
|
+
display: "url",
|
|
628
|
+
editorView: editorView
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}, {
|
|
632
|
+
type: 'custom',
|
|
633
|
+
fallback: [],
|
|
634
|
+
render: function render(editorView) {
|
|
635
|
+
var _api$analytics2;
|
|
636
|
+
if (!editorView) {
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearance, {
|
|
640
|
+
key: "link-appearance",
|
|
641
|
+
url: link,
|
|
642
|
+
intl: intl,
|
|
643
|
+
editorView: editorView,
|
|
644
|
+
editorState: editorView.state,
|
|
645
|
+
cardOptions: options,
|
|
646
|
+
providerFactory: providerFactory,
|
|
647
|
+
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
648
|
+
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}].concat(editLinkItem);
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
export var getEndingToolbarItems = function getEndingToolbarItems(options, api) {
|
|
655
|
+
return function (intl, link) {
|
|
656
|
+
if (getBooleanFF('platform.editor.card.inject-settings-button')) {
|
|
657
|
+
/**
|
|
658
|
+
* Require either provider to be supplied (controls link preferences)
|
|
659
|
+
* Or explicit user preferences config in order to enable button
|
|
660
|
+
*/
|
|
661
|
+
if (options.provider || options.userPreferencesLink) {
|
|
662
|
+
var _api$analytics3;
|
|
663
|
+
return [{
|
|
664
|
+
type: 'separator'
|
|
665
|
+
}, getHyperlinkToolbarSettingsButton(intl, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink)];
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return [];
|
|
669
|
+
};
|
|
583
670
|
};
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -26,7 +26,7 @@ import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/Edit
|
|
|
26
26
|
import { EditToolbarButton } from './ui/EditToolbarButton';
|
|
27
27
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
28
28
|
import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
|
|
29
|
-
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode,
|
|
29
|
+
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
|
|
30
30
|
export var removeCard = function removeCard(editorAnalyticsApi) {
|
|
31
31
|
return commandWithMetadata(function (state, dispatch) {
|
|
32
32
|
if (!(state.selection instanceof NodeSelection)) {
|
|
@@ -212,11 +212,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
212
212
|
lpLinkPicker: lpLinkPicker
|
|
213
213
|
})];
|
|
214
214
|
} else if (shouldRenderDatasourceToolbar) {
|
|
215
|
-
|
|
216
|
-
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions);
|
|
215
|
+
return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, platform);
|
|
217
216
|
} else {
|
|
218
217
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
219
|
-
var
|
|
218
|
+
var isEditDropdownEnabled = getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile' && cardOptions.allowDatasource;
|
|
219
|
+
var toolbarItems = [isEditDropdownEnabled ? {
|
|
220
220
|
type: 'custom',
|
|
221
221
|
fallback: [],
|
|
222
222
|
render: function render(editorView) {
|
|
@@ -295,7 +295,6 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
295
295
|
type: 'custom',
|
|
296
296
|
fallback: [],
|
|
297
297
|
render: function render(editorView) {
|
|
298
|
-
var _pluginInjectionApi$c2;
|
|
299
298
|
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
300
299
|
key: "link-appearance",
|
|
301
300
|
url: url,
|
|
@@ -307,7 +306,6 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
307
306
|
allowBlockCards: allowBlockCards,
|
|
308
307
|
platform: platform,
|
|
309
308
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
310
|
-
cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions,
|
|
311
309
|
showUpgradeDiscoverability: showUpgradeDiscoverability
|
|
312
310
|
});
|
|
313
311
|
}
|
|
@@ -385,7 +383,7 @@ export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editor
|
|
|
385
383
|
type: 'separator'
|
|
386
384
|
}];
|
|
387
385
|
};
|
|
388
|
-
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform
|
|
386
|
+
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) {
|
|
389
387
|
var _node$attrs3;
|
|
390
388
|
var toolbarItems = [];
|
|
391
389
|
if (isDatasourceConfigEditable(datasourceId) && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
@@ -452,7 +450,6 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
452
450
|
allowBlockCards: allowBlockCards,
|
|
453
451
|
platform: platform,
|
|
454
452
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
455
|
-
cardActions: cardActions,
|
|
456
453
|
showUpgradeDiscoverability: showUpgradeDiscoverability,
|
|
457
454
|
isDatasourceView: true
|
|
458
455
|
});
|
|
@@ -8,7 +8,6 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ACTION, buildEditLinkPayload, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
10
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
11
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
11
|
import { HyperlinkAddToolbar as HyperlinkToolbar } from '@atlaskit/editor-common/link';
|
|
13
12
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
14
13
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
@@ -29,10 +28,7 @@ export function HyperlinkAddToolbarWithState(_ref) {
|
|
|
29
28
|
lpLinkPicker = _ref.lpLinkPicker,
|
|
30
29
|
onClose = _ref.onClose,
|
|
31
30
|
onEscapeCallback = _ref.onEscapeCallback,
|
|
32
|
-
onClickAwayCallback = _ref.onClickAwayCallback
|
|
33
|
-
pluginInjectionApi = _ref.pluginInjectionApi;
|
|
34
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink']),
|
|
35
|
-
hyperlinkState = _useSharedPluginState.hyperlinkState;
|
|
31
|
+
onClickAwayCallback = _ref.onClickAwayCallback;
|
|
36
32
|
return /*#__PURE__*/React.createElement(HyperlinkToolbar, {
|
|
37
33
|
linkPickerOptions: linkPickerOptions,
|
|
38
34
|
onSubmit: onSubmit,
|
|
@@ -45,8 +41,7 @@ export function HyperlinkAddToolbarWithState(_ref) {
|
|
|
45
41
|
lpLinkPicker: lpLinkPicker,
|
|
46
42
|
onClose: onClose,
|
|
47
43
|
onEscapeCallback: onEscapeCallback,
|
|
48
|
-
onClickAwayCallback: onClickAwayCallback
|
|
49
|
-
hyperlinkPluginState: hyperlinkState
|
|
44
|
+
onClickAwayCallback: onClickAwayCallback
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
47
|
|
|
@@ -87,11 +82,9 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
87
82
|
text = _this$props.text,
|
|
88
83
|
view = _this$props.view,
|
|
89
84
|
_onSubmit = _this$props.onSubmit,
|
|
90
|
-
pluginInjectionApi = _this$props.pluginInjectionApi,
|
|
91
85
|
forceFocusSelector = _this$props.forceFocusSelector,
|
|
92
86
|
lpLinkPicker = _this$props.lpLinkPicker;
|
|
93
87
|
return /*#__PURE__*/React.createElement(HyperlinkAddToolbarWithState, {
|
|
94
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
95
88
|
view: view,
|
|
96
89
|
linkPickerOptions: linkPickerOptions,
|
|
97
90
|
providerFactory: providerFactory,
|
|
@@ -109,9 +102,7 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
109
102
|
}
|
|
110
103
|
},
|
|
111
104
|
onEscapeCallback: function onEscapeCallback(state, dispatch) {
|
|
112
|
-
var _pluginInjectionApi$h;
|
|
113
105
|
var tr = state.tr;
|
|
114
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h === void 0 || _pluginInjectionApi$h.actions.hideLinkToolbar(tr);
|
|
115
106
|
_hideLinkToolbar(tr);
|
|
116
107
|
forceFocusSelector === null || forceFocusSelector === void 0 || forceFocusSelector("[aria-label=\"".concat(linkToolbarMessages.editLink.defaultMessage, "\"]"))(tr);
|
|
117
108
|
if (dispatch) {
|
|
@@ -121,9 +112,7 @@ export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
121
112
|
return false;
|
|
122
113
|
},
|
|
123
114
|
onClickAwayCallback: function onClickAwayCallback(state, dispatch) {
|
|
124
|
-
var _pluginInjectionApi$h2;
|
|
125
115
|
var tr = state.tr;
|
|
126
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h2 = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h2 === void 0 || _pluginInjectionApi$h2.actions.hideLinkToolbar(tr);
|
|
127
116
|
if (dispatch) {
|
|
128
117
|
dispatch(tr);
|
|
129
118
|
return true;
|
|
@@ -154,8 +143,8 @@ export var editLink = function editLink(editorAnalyticsApi) {
|
|
|
154
143
|
export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref2) {
|
|
155
144
|
var providerFactory = _ref2.providerFactory,
|
|
156
145
|
node = _ref2.node,
|
|
157
|
-
linkPicker = _ref2.linkPicker,
|
|
158
146
|
pluginInjectionApi = _ref2.pluginInjectionApi,
|
|
147
|
+
linkPicker = _ref2.linkPicker,
|
|
159
148
|
lpLinkPicker = _ref2.lpLinkPicker;
|
|
160
149
|
return {
|
|
161
150
|
type: 'custom',
|
|
@@ -168,7 +157,6 @@ export var buildEditLinkToolbar = function buildEditLinkToolbar(_ref2) {
|
|
|
168
157
|
}
|
|
169
158
|
var displayInfo = displayInfoForCard(node, findCardInfo(view.state));
|
|
170
159
|
return /*#__PURE__*/React.createElement(EditLinkToolbar, {
|
|
171
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
172
160
|
key: idx,
|
|
173
161
|
view: view,
|
|
174
162
|
linkPickerOptions: linkPicker,
|
|
@@ -145,13 +145,12 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
|
|
|
145
145
|
editorState = _this$props.editorState,
|
|
146
146
|
cardOptions = _this$props.cardOptions,
|
|
147
147
|
platform = _this$props.platform,
|
|
148
|
-
editorAnalyticsApi = _this$props.editorAnalyticsApi
|
|
149
|
-
cardActions = _this$props.cardActions;
|
|
148
|
+
editorAnalyticsApi = _this$props.editorAnalyticsApi;
|
|
150
149
|
var supportedUrlsMap = this.state.supportedUrlsMap;
|
|
151
150
|
if (!supportedUrlsMap.get(url)) {
|
|
152
151
|
return null;
|
|
153
152
|
}
|
|
154
|
-
return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(EditDatasourceButton, {
|
|
153
|
+
return /*#__PURE__*/React.createElement(Flex, null, !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && /*#__PURE__*/React.createElement(EditDatasourceButton, {
|
|
155
154
|
url: url,
|
|
156
155
|
intl: intl,
|
|
157
156
|
editorState: editorState,
|
|
@@ -166,8 +165,7 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
|
|
|
166
165
|
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
167
166
|
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
168
167
|
platform: platform,
|
|
169
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
170
|
-
cardActions: cardActions
|
|
168
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
171
169
|
}), getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && (cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowDatasource) && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
172
170
|
intl: intl,
|
|
173
171
|
url: url,
|