@atlaskit/editor-plugin-card 1.6.2 → 1.8.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 +30 -0
- package/dist/cjs/nodeviews/blockCard.js +9 -5
- package/dist/cjs/nodeviews/embedCard.js +7 -5
- package/dist/cjs/nodeviews/genericCard.js +58 -9
- package/dist/cjs/nodeviews/inlineCard.js +10 -6
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +4 -3
- package/dist/cjs/pm-plugins/main.js +9 -4
- package/dist/cjs/pm-plugins/mountHyperlink.js +21 -0
- package/dist/cjs/toolbar.js +23 -9
- package/dist/es2019/nodeviews/blockCard.js +9 -5
- package/dist/es2019/nodeviews/embedCard.js +7 -5
- package/dist/es2019/nodeviews/genericCard.js +50 -3
- package/dist/es2019/nodeviews/inlineCard.js +10 -6
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +4 -3
- package/dist/es2019/pm-plugins/main.js +9 -4
- package/dist/es2019/pm-plugins/mountHyperlink.js +21 -0
- package/dist/es2019/toolbar.js +22 -8
- package/dist/esm/nodeviews/blockCard.js +9 -5
- package/dist/esm/nodeviews/embedCard.js +7 -5
- package/dist/esm/nodeviews/genericCard.js +55 -9
- package/dist/esm/nodeviews/inlineCard.js +10 -6
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +4 -3
- package/dist/esm/pm-plugins/main.js +9 -4
- package/dist/esm/pm-plugins/mountHyperlink.js +21 -0
- package/dist/esm/toolbar.js +22 -8
- package/dist/types/nodeviews/blockCard.d.ts +1 -2
- package/dist/types/nodeviews/embedCard.d.ts +1 -2
- package/dist/types/nodeviews/genericCard.d.ts +6 -1
- package/dist/types/nodeviews/inlineCard.d.ts +1 -2
- package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +1 -1
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/toolbar.d.ts +6 -2
- package/dist/types/types.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +6 -1
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/toolbar.d.ts +6 -2
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/package.json +13 -6
|
@@ -16,7 +16,6 @@ import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
|
16
16
|
export class InlineCardComponent extends React.PureComponent {
|
|
17
17
|
constructor(...args) {
|
|
18
18
|
super(...args);
|
|
19
|
-
_defineProperty(this, "onClick", () => {});
|
|
20
19
|
_defineProperty(this, "onResolve", data => {
|
|
21
20
|
const {
|
|
22
21
|
getPos,
|
|
@@ -72,7 +71,8 @@ export class InlineCardComponent extends React.PureComponent {
|
|
|
72
71
|
cardContext,
|
|
73
72
|
actionOptions,
|
|
74
73
|
showServerActions,
|
|
75
|
-
useAlternativePreloader
|
|
74
|
+
useAlternativePreloader,
|
|
75
|
+
onClick
|
|
76
76
|
} = this.props;
|
|
77
77
|
const {
|
|
78
78
|
url,
|
|
@@ -85,7 +85,7 @@ export class InlineCardComponent extends React.PureComponent {
|
|
|
85
85
|
url: url,
|
|
86
86
|
data: data,
|
|
87
87
|
appearance: "inline",
|
|
88
|
-
onClick:
|
|
88
|
+
onClick: onClick,
|
|
89
89
|
container: this.scrollContainer,
|
|
90
90
|
onResolve: this.onResolve,
|
|
91
91
|
onError: this.onError,
|
|
@@ -116,7 +116,8 @@ export function InlineCardNodeView(props) {
|
|
|
116
116
|
allowEmbeds,
|
|
117
117
|
allowBlockCards,
|
|
118
118
|
enableInlineUpgradeFeatures,
|
|
119
|
-
pluginInjectionApi
|
|
119
|
+
pluginInjectionApi,
|
|
120
|
+
onClickCallback
|
|
120
121
|
} = props;
|
|
121
122
|
if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
|
|
122
123
|
return /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
@@ -125,7 +126,9 @@ export function InlineCardNodeView(props) {
|
|
|
125
126
|
getPos: getPos,
|
|
126
127
|
actionOptions: actionOptions,
|
|
127
128
|
showServerActions: showServerActions,
|
|
128
|
-
useAlternativePreloader: useAlternativePreloader
|
|
129
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
130
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
131
|
+
onClickCallback: onClickCallback
|
|
129
132
|
});
|
|
130
133
|
}
|
|
131
134
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
@@ -135,7 +138,8 @@ export function InlineCardNodeView(props) {
|
|
|
135
138
|
actionOptions: actionOptions,
|
|
136
139
|
showServerActions: showServerActions,
|
|
137
140
|
useAlternativePreloader: useAlternativePreloader,
|
|
138
|
-
pluginInjectionApi: pluginInjectionApi
|
|
141
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
142
|
+
onClickCallback: onClickCallback
|
|
139
143
|
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
140
144
|
}
|
|
141
145
|
const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards) => {
|
|
@@ -15,7 +15,8 @@ const InlineCard = ({
|
|
|
15
15
|
isOverlayEnabled,
|
|
16
16
|
isPulseEnabled,
|
|
17
17
|
pluginInjectionApi,
|
|
18
|
-
isSelected = false
|
|
18
|
+
isSelected = false,
|
|
19
|
+
onClick
|
|
19
20
|
}) => {
|
|
20
21
|
const {
|
|
21
22
|
url,
|
|
@@ -85,7 +86,7 @@ const InlineCard = ({
|
|
|
85
86
|
url: url,
|
|
86
87
|
data: data,
|
|
87
88
|
appearance: "inline",
|
|
88
|
-
onClick:
|
|
89
|
+
onClick: onClick,
|
|
89
90
|
container: scrollContainer,
|
|
90
91
|
onResolve: onResolve,
|
|
91
92
|
onError: onError,
|
|
@@ -93,7 +94,7 @@ const InlineCard = ({
|
|
|
93
94
|
actionOptions: actionOptions,
|
|
94
95
|
showServerActions: showServerActions,
|
|
95
96
|
isHovered: isHovered
|
|
96
|
-
}), [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions]);
|
|
97
|
+
}), [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
|
|
97
98
|
const card = useMemo(() => {
|
|
98
99
|
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
99
100
|
isOverlayEnabled: isOverlayEnabled,
|
|
@@ -43,7 +43,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
43
43
|
cardPluginEvents,
|
|
44
44
|
showUpgradeDiscoverability,
|
|
45
45
|
allowEmbeds,
|
|
46
|
-
allowBlockCards
|
|
46
|
+
allowBlockCards,
|
|
47
|
+
onClickCallback
|
|
47
48
|
} = options;
|
|
48
49
|
const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
49
50
|
const shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
@@ -57,7 +58,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
57
58
|
enableInlineUpgradeFeatures,
|
|
58
59
|
allowEmbeds,
|
|
59
60
|
allowBlockCards,
|
|
60
|
-
pluginInjectionApi
|
|
61
|
+
pluginInjectionApi,
|
|
62
|
+
onClickCallback
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
return new SafePlugin({
|
|
@@ -226,7 +228,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
226
228
|
const reactComponentProps = {
|
|
227
229
|
platform,
|
|
228
230
|
actionOptions,
|
|
229
|
-
showServerActions
|
|
231
|
+
showServerActions,
|
|
232
|
+
pluginInjectionApi,
|
|
233
|
+
onClickCallback: options.onClickCallback
|
|
230
234
|
};
|
|
231
235
|
const hasIntlContext = true;
|
|
232
236
|
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
@@ -266,7 +270,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
266
270
|
dispatchAnalyticsEvent,
|
|
267
271
|
pluginInjectionApi,
|
|
268
272
|
actionOptions,
|
|
269
|
-
showServerActions
|
|
273
|
+
showServerActions,
|
|
274
|
+
onClickCallback: options.onClickCallback
|
|
270
275
|
};
|
|
271
276
|
const hasIntlContext = true;
|
|
272
277
|
return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { getHyperlinkToolbarSettingsButton } from '../toolbar';
|
|
3
5
|
import { HyperlinkToolbarAppearance } from '../ui/HyperlinkToolbarAppearance';
|
|
4
6
|
import { ToolbarViewedEvent } from '../ui/ToolbarViewedEvent';
|
|
5
7
|
const getToolbarViewedItem = link => {
|
|
@@ -44,6 +46,25 @@ export const mountHyperlinkPlugin = (pluginInjectionApi, options) => {
|
|
|
44
46
|
view: editorView,
|
|
45
47
|
skipAnalytics: true
|
|
46
48
|
});
|
|
49
|
+
if (getBooleanFF('platform.editor.card.inject-settings-button')) {
|
|
50
|
+
/**
|
|
51
|
+
* Require either provider to be supplied (controls link preferences)
|
|
52
|
+
* Or explicit user preferences config in order to enable button
|
|
53
|
+
*/
|
|
54
|
+
if (options.provider || options.userPreferencesLink) {
|
|
55
|
+
var _pluginInjectionApi$h3;
|
|
56
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$h3 = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h3 === void 0 ? void 0 : _pluginInjectionApi$h3.actions.addToolbarItems({
|
|
57
|
+
items: (_, intl) => {
|
|
58
|
+
var _pluginInjectionApi$a2;
|
|
59
|
+
return [{
|
|
60
|
+
type: 'separator'
|
|
61
|
+
}, getHyperlinkToolbarSettingsButton(intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions, options.userPreferencesLink)];
|
|
62
|
+
},
|
|
63
|
+
placement: 'end',
|
|
64
|
+
view: editorView
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
47
68
|
});
|
|
48
69
|
return {};
|
|
49
70
|
}
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -72,11 +72,11 @@ export const visitCardLink = editorAnalyticsApi => (state, dispatch) => {
|
|
|
72
72
|
}
|
|
73
73
|
return true;
|
|
74
74
|
};
|
|
75
|
-
export const openLinkSettings = editorAnalyticsApi => (state, dispatch) => {
|
|
75
|
+
export const openLinkSettings = (editorAnalyticsApi, userPreferencesLink) => (state, dispatch) => {
|
|
76
76
|
if (!(state.selection instanceof NodeSelection)) {
|
|
77
77
|
return false;
|
|
78
78
|
}
|
|
79
|
-
window.open(getLinkPreferencesURLFromENV());
|
|
79
|
+
window.open(userPreferencesLink || getLinkPreferencesURLFromENV());
|
|
80
80
|
if (dispatch) {
|
|
81
81
|
const {
|
|
82
82
|
tr,
|
|
@@ -249,7 +249,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
249
249
|
}, {
|
|
250
250
|
type: 'separator'
|
|
251
251
|
}]
|
|
252
|
-
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi), {
|
|
252
|
+
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions.userPreferencesLink), {
|
|
253
253
|
id: 'editor.link.delete',
|
|
254
254
|
focusEditoronEnter: true,
|
|
255
255
|
type: 'button',
|
|
@@ -346,14 +346,28 @@ const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi)
|
|
|
346
346
|
type: 'separator'
|
|
347
347
|
}] : [];
|
|
348
348
|
};
|
|
349
|
-
const
|
|
350
|
-
return
|
|
349
|
+
export const getHyperlinkToolbarSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink) => {
|
|
350
|
+
return {
|
|
351
351
|
id: 'editor.link.settings',
|
|
352
352
|
type: 'button',
|
|
353
353
|
icon: CogIcon,
|
|
354
354
|
title: intl.formatMessage(linkToolbarMessages.settingsLink),
|
|
355
|
-
onClick: openLinkSettings(editorAnalyticsApi)
|
|
356
|
-
|
|
355
|
+
onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
|
|
356
|
+
href: getBooleanFF('platform.editor.card.inject-settings-button') ? userPreferencesLink || getLinkPreferencesURLFromENV() : getLinkPreferencesURLFromENV(),
|
|
357
|
+
target: '_blank'
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink) => {
|
|
361
|
+
return {
|
|
362
|
+
id: 'editor.link.settings',
|
|
363
|
+
type: 'button',
|
|
364
|
+
icon: CogIcon,
|
|
365
|
+
title: intl.formatMessage(linkToolbarMessages.settingsLink),
|
|
366
|
+
onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
export const getSettingsButtonGroup = (intl, editorAnalyticsApi, userPreferencesLink) => {
|
|
370
|
+
return [getSettingsButton(intl, editorAnalyticsApi, userPreferencesLink), {
|
|
357
371
|
type: 'separator'
|
|
358
372
|
}];
|
|
359
373
|
};
|
|
@@ -451,7 +465,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
451
465
|
}, {
|
|
452
466
|
type: 'separator'
|
|
453
467
|
}]
|
|
454
|
-
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi), {
|
|
468
|
+
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink), {
|
|
455
469
|
id: 'editor.link.delete',
|
|
456
470
|
focusEditoronEnter: true,
|
|
457
471
|
type: 'button',
|
|
@@ -29,7 +29,6 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
29
29
|
args[_key] = arguments[_key];
|
|
30
30
|
}
|
|
31
31
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function () {});
|
|
33
32
|
_defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
|
|
34
33
|
var _this$props = _this.props,
|
|
35
34
|
getPos = _this$props.getPos,
|
|
@@ -90,7 +89,8 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
90
89
|
cardContext = _this$props2.cardContext,
|
|
91
90
|
platform = _this$props2.platform,
|
|
92
91
|
actionOptions = _this$props2.actionOptions,
|
|
93
|
-
showServerActions = _this$props2.showServerActions
|
|
92
|
+
showServerActions = _this$props2.showServerActions,
|
|
93
|
+
onClick = _this$props2.onClick;
|
|
94
94
|
var _node$attrs = node.attrs,
|
|
95
95
|
url = _node$attrs.url,
|
|
96
96
|
data = _node$attrs.data;
|
|
@@ -100,7 +100,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
100
100
|
data: data,
|
|
101
101
|
container: this.scrollContainer,
|
|
102
102
|
appearance: "block",
|
|
103
|
-
onClick:
|
|
103
|
+
onClick: onClick,
|
|
104
104
|
onResolve: this.onResolve,
|
|
105
105
|
onError: this.onError,
|
|
106
106
|
platform: platform,
|
|
@@ -164,14 +164,18 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
164
164
|
var _this$reactComponentP = this.reactComponentProps,
|
|
165
165
|
platform = _this$reactComponentP.platform,
|
|
166
166
|
actionOptions = _this$reactComponentP.actionOptions,
|
|
167
|
-
showServerActions = _this$reactComponentP.showServerActions
|
|
167
|
+
showServerActions = _this$reactComponentP.showServerActions,
|
|
168
|
+
pluginInjectionApi = _this$reactComponentP.pluginInjectionApi,
|
|
169
|
+
onClickCallback = _this$reactComponentP.onClickCallback;
|
|
168
170
|
return /*#__PURE__*/React.createElement(WrappedBlockCard, {
|
|
169
171
|
node: this.node,
|
|
170
172
|
view: this.view,
|
|
171
173
|
getPos: this.getPos,
|
|
172
174
|
platform: platform,
|
|
173
175
|
actionOptions: actionOptions,
|
|
174
|
-
showServerActions: showServerActions
|
|
176
|
+
showServerActions: showServerActions,
|
|
177
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
178
|
+
onClickCallback: onClickCallback
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
}]);
|
|
@@ -104,7 +104,6 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
104
104
|
}
|
|
105
105
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
106
106
|
_defineProperty(_assertThisInitialized(_this), "embedIframeRef", /*#__PURE__*/React.createRef());
|
|
107
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function () {});
|
|
108
107
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
109
108
|
hasPreview: true
|
|
110
109
|
});
|
|
@@ -265,7 +264,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
265
264
|
getPos = _this$props.getPos,
|
|
266
265
|
pluginInjectionApi = _this$props.pluginInjectionApi,
|
|
267
266
|
actionOptions = _this$props.actionOptions,
|
|
268
|
-
showServerActions = _this$props.showServerActions
|
|
267
|
+
showServerActions = _this$props.showServerActions,
|
|
268
|
+
onClick = _this$props.onClick;
|
|
269
269
|
var _node$attrs = node.attrs,
|
|
270
270
|
url = _node$attrs.url,
|
|
271
271
|
pctWidth = _node$attrs.width,
|
|
@@ -296,7 +296,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
296
296
|
key: url,
|
|
297
297
|
url: url,
|
|
298
298
|
appearance: "embed",
|
|
299
|
-
onClick:
|
|
299
|
+
onClick: onClick,
|
|
300
300
|
onResolve: this.onResolve,
|
|
301
301
|
onError: this.onError,
|
|
302
302
|
frameStyle: "show",
|
|
@@ -382,7 +382,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
382
382
|
platform = _this$reactComponentP.platform,
|
|
383
383
|
fullWidthMode = _this$reactComponentP.fullWidthMode,
|
|
384
384
|
dispatchAnalyticsEvent = _this$reactComponentP.dispatchAnalyticsEvent,
|
|
385
|
-
pluginInjectionApi = _this$reactComponentP.pluginInjectionApi
|
|
385
|
+
pluginInjectionApi = _this$reactComponentP.pluginInjectionApi,
|
|
386
|
+
onClickCallback = _this$reactComponentP.onClickCallback;
|
|
386
387
|
return /*#__PURE__*/React.createElement(WrappedBlockCard, {
|
|
387
388
|
node: this.node,
|
|
388
389
|
view: this.view,
|
|
@@ -392,7 +393,8 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
392
393
|
platform: platform,
|
|
393
394
|
fullWidthMode: fullWidthMode,
|
|
394
395
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
395
|
-
pluginInjectionApi: pluginInjectionApi
|
|
396
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
397
|
+
onClickCallback: onClickCallback
|
|
396
398
|
});
|
|
397
399
|
}
|
|
398
400
|
}]);
|
|
@@ -8,14 +8,41 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
-
import React from 'react';
|
|
11
|
+
import React, { useCallback } from 'react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
14
14
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
15
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
15
16
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
16
18
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
17
19
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
18
20
|
import { titleUrlPairFromNode } from '../utils';
|
|
21
|
+
var WithClickHandler = function WithClickHandler(_ref) {
|
|
22
|
+
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
23
|
+
url = _ref.url,
|
|
24
|
+
onClickCallback = _ref.onClickCallback,
|
|
25
|
+
children = _ref.children;
|
|
26
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
|
|
27
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
28
|
+
var onClick = useCallback(function (event) {
|
|
29
|
+
if (typeof onClickCallback === 'function') {
|
|
30
|
+
try {
|
|
31
|
+
onClickCallback({
|
|
32
|
+
event: event,
|
|
33
|
+
url: url
|
|
34
|
+
});
|
|
35
|
+
} catch (_unused) {}
|
|
36
|
+
}
|
|
37
|
+
}, [url, onClickCallback]);
|
|
38
|
+
|
|
39
|
+
// Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
|
|
40
|
+
// If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
|
|
41
|
+
var allowNavigation = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' && !onClickCallback;
|
|
42
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children({
|
|
43
|
+
onClick: allowNavigation ? undefined : onClick
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
19
46
|
export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
20
47
|
var _class;
|
|
21
48
|
return _class = /*#__PURE__*/function (_React$Component) {
|
|
@@ -31,12 +58,17 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
31
58
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
32
59
|
isError: false
|
|
33
60
|
});
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this), "onClick", function () {});
|
|
34
62
|
return _this;
|
|
35
63
|
}
|
|
36
64
|
_createClass(_class, [{
|
|
37
65
|
key: "render",
|
|
38
66
|
value: function render() {
|
|
39
|
-
var _getPluginState
|
|
67
|
+
var _getPluginState,
|
|
68
|
+
_this2 = this;
|
|
69
|
+
var _this$props = this.props,
|
|
70
|
+
pluginInjectionApi = _this$props.pluginInjectionApi,
|
|
71
|
+
onClickCallback = _this$props.onClickCallback;
|
|
40
72
|
var _titleUrlPairFromNode = titleUrlPairFromNode(this.props.node),
|
|
41
73
|
url = _titleUrlPairFromNode.url;
|
|
42
74
|
if (url && !isSafeUrl(url)) {
|
|
@@ -65,10 +97,24 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
65
97
|
// Below is added for the future implementation of Linking Platform namespaced analytics context
|
|
66
98
|
location: analyticsEditorAppearance
|
|
67
99
|
}
|
|
68
|
-
}, /*#__PURE__*/React.createElement(
|
|
100
|
+
}, getBooleanFF('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
|
|
101
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
102
|
+
onClickCallback: onClickCallback,
|
|
103
|
+
url: url
|
|
104
|
+
}, function (_ref2) {
|
|
105
|
+
var onClick = _ref2.onClick;
|
|
106
|
+
return /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
|
|
107
|
+
key: url,
|
|
108
|
+
cardContext: cardContext
|
|
109
|
+
}, _this2.props, {
|
|
110
|
+
onClick: onClick
|
|
111
|
+
}));
|
|
112
|
+
}) : /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
|
|
69
113
|
key: url,
|
|
70
114
|
cardContext: cardContext
|
|
71
|
-
}, this.props
|
|
115
|
+
}, this.props, {
|
|
116
|
+
onClick: this.onClick
|
|
117
|
+
})));
|
|
72
118
|
}
|
|
73
119
|
}, {
|
|
74
120
|
key: "componentDidCatch",
|
|
@@ -84,11 +130,11 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
84
130
|
this.setState({
|
|
85
131
|
isError: true
|
|
86
132
|
});
|
|
87
|
-
var _this$
|
|
88
|
-
view = _this$
|
|
89
|
-
node = _this$
|
|
90
|
-
getPos = _this$
|
|
91
|
-
pluginInjectionApi = _this$
|
|
133
|
+
var _this$props2 = this.props,
|
|
134
|
+
view = _this$props2.view,
|
|
135
|
+
node = _this$props2.node,
|
|
136
|
+
getPos = _this$props2.getPos,
|
|
137
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi;
|
|
92
138
|
var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
|
|
93
139
|
url = _titleUrlPairFromNode2.url;
|
|
94
140
|
if (!getPos || typeof getPos === 'boolean') {
|
|
@@ -31,7 +31,6 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
31
31
|
args[_key] = arguments[_key];
|
|
32
32
|
}
|
|
33
33
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function () {});
|
|
35
34
|
_defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
|
|
36
35
|
var _this$props = _this.props,
|
|
37
36
|
getPos = _this$props.getPos,
|
|
@@ -85,7 +84,8 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
85
84
|
cardContext = _this$props2.cardContext,
|
|
86
85
|
actionOptions = _this$props2.actionOptions,
|
|
87
86
|
showServerActions = _this$props2.showServerActions,
|
|
88
|
-
useAlternativePreloader = _this$props2.useAlternativePreloader
|
|
87
|
+
useAlternativePreloader = _this$props2.useAlternativePreloader,
|
|
88
|
+
onClick = _this$props2.onClick;
|
|
89
89
|
var _node$attrs = node.attrs,
|
|
90
90
|
url = _node$attrs.url,
|
|
91
91
|
data = _node$attrs.data;
|
|
@@ -96,7 +96,7 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
96
96
|
url: url,
|
|
97
97
|
data: data,
|
|
98
98
|
appearance: "inline",
|
|
99
|
-
onClick:
|
|
99
|
+
onClick: onClick,
|
|
100
100
|
container: this.scrollContainer,
|
|
101
101
|
onResolve: this.onResolve,
|
|
102
102
|
onError: this.onError,
|
|
@@ -128,7 +128,8 @@ export function InlineCardNodeView(props) {
|
|
|
128
128
|
allowEmbeds = props.allowEmbeds,
|
|
129
129
|
allowBlockCards = props.allowBlockCards,
|
|
130
130
|
enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
|
|
131
|
-
pluginInjectionApi = props.pluginInjectionApi
|
|
131
|
+
pluginInjectionApi = props.pluginInjectionApi,
|
|
132
|
+
onClickCallback = props.onClickCallback;
|
|
132
133
|
if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
|
|
133
134
|
return /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
134
135
|
node: node,
|
|
@@ -136,7 +137,9 @@ export function InlineCardNodeView(props) {
|
|
|
136
137
|
getPos: getPos,
|
|
137
138
|
actionOptions: actionOptions,
|
|
138
139
|
showServerActions: showServerActions,
|
|
139
|
-
useAlternativePreloader: useAlternativePreloader
|
|
140
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
141
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
142
|
+
onClickCallback: onClickCallback
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
@@ -146,7 +149,8 @@ export function InlineCardNodeView(props) {
|
|
|
146
149
|
actionOptions: actionOptions,
|
|
147
150
|
showServerActions: showServerActions,
|
|
148
151
|
useAlternativePreloader: useAlternativePreloader,
|
|
149
|
-
pluginInjectionApi: pluginInjectionApi
|
|
152
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
153
|
+
onClickCallback: onClickCallback
|
|
150
154
|
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
151
155
|
}
|
|
152
156
|
var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
|
|
@@ -17,7 +17,8 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
17
17
|
isPulseEnabled = _ref.isPulseEnabled,
|
|
18
18
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
19
19
|
_ref$isSelected = _ref.isSelected,
|
|
20
|
-
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected
|
|
20
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
21
|
+
onClick = _ref.onClick;
|
|
21
22
|
var _node$attrs = node.attrs,
|
|
22
23
|
url = _node$attrs.url,
|
|
23
24
|
data = _node$attrs.data;
|
|
@@ -95,7 +96,7 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
95
96
|
url: url,
|
|
96
97
|
data: data,
|
|
97
98
|
appearance: "inline",
|
|
98
|
-
onClick:
|
|
99
|
+
onClick: onClick,
|
|
99
100
|
container: scrollContainer,
|
|
100
101
|
onResolve: onResolve,
|
|
101
102
|
onError: onError,
|
|
@@ -104,7 +105,7 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
104
105
|
showServerActions: showServerActions,
|
|
105
106
|
isHovered: isHovered
|
|
106
107
|
});
|
|
107
|
-
}, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions]);
|
|
108
|
+
}, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
|
|
108
109
|
var card = useMemo(function () {
|
|
109
110
|
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
110
111
|
isOverlayEnabled: isOverlayEnabled,
|
|
@@ -47,7 +47,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
47
47
|
cardPluginEvents = options.cardPluginEvents,
|
|
48
48
|
showUpgradeDiscoverability = options.showUpgradeDiscoverability,
|
|
49
49
|
allowEmbeds = options.allowEmbeds,
|
|
50
|
-
allowBlockCards = options.allowBlockCards
|
|
50
|
+
allowBlockCards = options.allowBlockCards,
|
|
51
|
+
onClickCallback = options.onClickCallback;
|
|
51
52
|
var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
|
|
52
53
|
var shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
|
|
53
54
|
var inlineCardViewProducer = getInlineNodeViewProducer({
|
|
@@ -60,7 +61,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
60
61
|
enableInlineUpgradeFeatures: enableInlineUpgradeFeatures,
|
|
61
62
|
allowEmbeds: allowEmbeds,
|
|
62
63
|
allowBlockCards: allowBlockCards,
|
|
63
|
-
pluginInjectionApi: pluginInjectionApi
|
|
64
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
65
|
+
onClickCallback: onClickCallback
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
68
|
return new SafePlugin({
|
|
@@ -222,7 +224,9 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
222
224
|
var reactComponentProps = {
|
|
223
225
|
platform: platform,
|
|
224
226
|
actionOptions: actionOptions,
|
|
225
|
-
showServerActions: showServerActions
|
|
227
|
+
showServerActions: showServerActions,
|
|
228
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
229
|
+
onClickCallback: options.onClickCallback
|
|
226
230
|
};
|
|
227
231
|
var hasIntlContext = true;
|
|
228
232
|
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
@@ -260,7 +264,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
260
264
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
261
265
|
pluginInjectionApi: pluginInjectionApi,
|
|
262
266
|
actionOptions: actionOptions,
|
|
263
|
-
showServerActions: showServerActions
|
|
267
|
+
showServerActions: showServerActions,
|
|
268
|
+
onClickCallback: options.onClickCallback
|
|
264
269
|
};
|
|
265
270
|
var hasIntlContext = true;
|
|
266
271
|
return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { getHyperlinkToolbarSettingsButton } from '../toolbar';
|
|
4
6
|
import { HyperlinkToolbarAppearance } from '../ui/HyperlinkToolbarAppearance';
|
|
5
7
|
import { ToolbarViewedEvent } from '../ui/ToolbarViewedEvent';
|
|
6
8
|
var getToolbarViewedItem = function getToolbarViewedItem(link) {
|
|
@@ -49,6 +51,25 @@ export var mountHyperlinkPlugin = function mountHyperlinkPlugin(pluginInjectionA
|
|
|
49
51
|
view: editorView,
|
|
50
52
|
skipAnalytics: true
|
|
51
53
|
});
|
|
54
|
+
if (getBooleanFF('platform.editor.card.inject-settings-button')) {
|
|
55
|
+
/**
|
|
56
|
+
* Require either provider to be supplied (controls link preferences)
|
|
57
|
+
* Or explicit user preferences config in order to enable button
|
|
58
|
+
*/
|
|
59
|
+
if (options.provider || options.userPreferencesLink) {
|
|
60
|
+
var _pluginInjectionApi$h2;
|
|
61
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h2 = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h2 === void 0 || _pluginInjectionApi$h2.actions.addToolbarItems({
|
|
62
|
+
items: function items(_, intl) {
|
|
63
|
+
var _pluginInjectionApi$a2;
|
|
64
|
+
return [{
|
|
65
|
+
type: 'separator'
|
|
66
|
+
}, getHyperlinkToolbarSettingsButton(intl, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions, options.userPreferencesLink)];
|
|
67
|
+
},
|
|
68
|
+
placement: 'end',
|
|
69
|
+
view: editorView
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
52
73
|
});
|
|
53
74
|
return {};
|
|
54
75
|
}
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -73,12 +73,12 @@ export var visitCardLink = function visitCardLink(editorAnalyticsApi) {
|
|
|
73
73
|
return true;
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
export var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
|
|
76
|
+
export var openLinkSettings = function openLinkSettings(editorAnalyticsApi, userPreferencesLink) {
|
|
77
77
|
return function (state, dispatch) {
|
|
78
78
|
if (!(state.selection instanceof NodeSelection)) {
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
|
-
window.open(getLinkPreferencesURLFromENV());
|
|
81
|
+
window.open(userPreferencesLink || getLinkPreferencesURLFromENV());
|
|
82
82
|
if (dispatch) {
|
|
83
83
|
var tr = state.tr,
|
|
84
84
|
type = state.selection.node.type;
|
|
@@ -245,7 +245,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
245
245
|
}, {
|
|
246
246
|
type: 'separator'
|
|
247
247
|
}]
|
|
248
|
-
}], _toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi)), [{
|
|
248
|
+
}], _toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)), [{
|
|
249
249
|
id: 'editor.link.delete',
|
|
250
250
|
focusEditoronEnter: true,
|
|
251
251
|
type: 'button',
|
|
@@ -345,14 +345,28 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
|
|
|
345
345
|
type: 'separator'
|
|
346
346
|
}] : [];
|
|
347
347
|
};
|
|
348
|
-
var
|
|
349
|
-
return
|
|
348
|
+
export var getHyperlinkToolbarSettingsButton = function getHyperlinkToolbarSettingsButton(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
349
|
+
return {
|
|
350
350
|
id: 'editor.link.settings',
|
|
351
351
|
type: 'button',
|
|
352
352
|
icon: CogIcon,
|
|
353
353
|
title: intl.formatMessage(linkToolbarMessages.settingsLink),
|
|
354
|
-
onClick: openLinkSettings(editorAnalyticsApi)
|
|
355
|
-
|
|
354
|
+
onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
|
|
355
|
+
href: getBooleanFF('platform.editor.card.inject-settings-button') ? userPreferencesLink || getLinkPreferencesURLFromENV() : getLinkPreferencesURLFromENV(),
|
|
356
|
+
target: '_blank'
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
export var getSettingsButton = function getSettingsButton(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
360
|
+
return {
|
|
361
|
+
id: 'editor.link.settings',
|
|
362
|
+
type: 'button',
|
|
363
|
+
icon: CogIcon,
|
|
364
|
+
title: intl.formatMessage(linkToolbarMessages.settingsLink),
|
|
365
|
+
onClick: getBooleanFF('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
369
|
+
return [getSettingsButton(intl, editorAnalyticsApi, userPreferencesLink), {
|
|
356
370
|
type: 'separator'
|
|
357
371
|
}];
|
|
358
372
|
};
|
|
@@ -448,7 +462,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
448
462
|
}, {
|
|
449
463
|
type: 'separator'
|
|
450
464
|
}]
|
|
451
|
-
}].concat(_toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi)), [{
|
|
465
|
+
}].concat(_toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink)), [{
|
|
452
466
|
id: 'editor.link.delete',
|
|
453
467
|
focusEditoronEnter: true,
|
|
454
468
|
type: 'button',
|