@atlaskit/editor-plugin-card 1.6.1 → 1.7.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 +25 -0
- package/dist/cjs/pm-plugins/mountHyperlink.js +21 -0
- package/dist/cjs/toolbar.js +33 -11
- package/dist/cjs/ui/EditDatasourceButton.js +2 -1
- package/dist/es2019/pm-plugins/mountHyperlink.js +21 -0
- package/dist/es2019/toolbar.js +32 -10
- package/dist/es2019/ui/EditDatasourceButton.js +3 -2
- package/dist/esm/pm-plugins/mountHyperlink.js +21 -0
- package/dist/esm/toolbar.js +32 -10
- package/dist/esm/ui/EditDatasourceButton.js +3 -2
- package/dist/types/toolbar.d.ts +6 -2
- package/dist/types-ts4.5/toolbar.d.ts +6 -2
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#89386](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89386) [`91d0fdc31828`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/91d0fdc31828) - Updates card plugin to leverage hyperlink plugins addToolbarItems action in order to inject link preferences button into the hyperlink floating toolbar. Also adds support to configure the link via card plugin options (smart links). Requires platform feature flag `platform.editor.card.inject-settings-button`.
|
|
8
|
+
|
|
9
|
+
Example usage:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<Editor
|
|
13
|
+
linking={{ smartLinks: { userPreferencesLink: 'https://example.com' } }}
|
|
14
|
+
{...restProps}
|
|
15
|
+
/>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
22
|
+
## 1.6.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [#89921](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89921) [`411822b4d808`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/411822b4d808) - The changes here updates the datasource toolbar to display smart-link icons for config and non-config based datasources.
|
|
27
|
+
|
|
3
28
|
## 1.6.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -8,6 +8,8 @@ exports.mountHyperlinkPlugin = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _toolbar = require("../toolbar");
|
|
11
13
|
var _HyperlinkToolbarAppearance = require("../ui/HyperlinkToolbarAppearance");
|
|
12
14
|
var _ToolbarViewedEvent = require("../ui/ToolbarViewedEvent");
|
|
13
15
|
var getToolbarViewedItem = function getToolbarViewedItem(link) {
|
|
@@ -56,6 +58,25 @@ var mountHyperlinkPlugin = exports.mountHyperlinkPlugin = function mountHyperlin
|
|
|
56
58
|
view: editorView,
|
|
57
59
|
skipAnalytics: true
|
|
58
60
|
});
|
|
61
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.card.inject-settings-button')) {
|
|
62
|
+
/**
|
|
63
|
+
* Require either provider to be supplied (controls link preferences)
|
|
64
|
+
* Or explicit user preferences config in order to enable button
|
|
65
|
+
*/
|
|
66
|
+
if (options.provider || options.userPreferencesLink) {
|
|
67
|
+
var _pluginInjectionApi$h2;
|
|
68
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h2 = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h2 === void 0 || _pluginInjectionApi$h2.actions.addToolbarItems({
|
|
69
|
+
items: function items(_, intl) {
|
|
70
|
+
var _pluginInjectionApi$a2;
|
|
71
|
+
return [{
|
|
72
|
+
type: 'separator'
|
|
73
|
+
}, (0, _toolbar.getHyperlinkToolbarSettingsButton)(intl, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions, options.userPreferencesLink)];
|
|
74
|
+
},
|
|
75
|
+
placement: 'end',
|
|
76
|
+
view: editorView
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
59
80
|
});
|
|
60
81
|
return {};
|
|
61
82
|
}
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.visitCardLink = exports.shouldRenderToolbarPulse = exports.removeCard = exports.openLinkSettings = exports.floatingToolbar = void 0;
|
|
8
|
+
exports.visitCardLink = exports.shouldRenderToolbarPulse = exports.removeCard = exports.openLinkSettings = exports.getSettingsButtonGroup = exports.getSettingsButton = exports.getHyperlinkToolbarSettingsButton = exports.floatingToolbar = void 0;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -83,12 +83,12 @@ var visitCardLink = exports.visitCardLink = function visitCardLink(editorAnalyti
|
|
|
83
83
|
return true;
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
var openLinkSettings = exports.openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
|
|
86
|
+
var openLinkSettings = exports.openLinkSettings = function openLinkSettings(editorAnalyticsApi, userPreferencesLink) {
|
|
87
87
|
return function (state, dispatch) {
|
|
88
88
|
if (!(state.selection instanceof _state.NodeSelection)) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
|
-
window.open((0, _link.getLinkPreferencesURLFromENV)());
|
|
91
|
+
window.open(userPreferencesLink || (0, _link.getLinkPreferencesURLFromENV)());
|
|
92
92
|
if (dispatch) {
|
|
93
93
|
var tr = state.tr,
|
|
94
94
|
type = state.selection.node.type;
|
|
@@ -255,7 +255,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
255
255
|
}, {
|
|
256
256
|
type: 'separator'
|
|
257
257
|
}]
|
|
258
|
-
}], (0, _toConsumableArray2.default)(getSettingsButtonGroup(intl, editorAnalyticsApi)), [{
|
|
258
|
+
}], (0, _toConsumableArray2.default)(getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions.userPreferencesLink)), [{
|
|
259
259
|
id: 'editor.link.delete',
|
|
260
260
|
focusEditoronEnter: true,
|
|
261
261
|
type: 'button',
|
|
@@ -355,14 +355,28 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
|
|
|
355
355
|
type: 'separator'
|
|
356
356
|
}] : [];
|
|
357
357
|
};
|
|
358
|
-
var
|
|
359
|
-
return
|
|
358
|
+
var getHyperlinkToolbarSettingsButton = exports.getHyperlinkToolbarSettingsButton = function getHyperlinkToolbarSettingsButton(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
359
|
+
return {
|
|
360
360
|
id: 'editor.link.settings',
|
|
361
361
|
type: 'button',
|
|
362
362
|
icon: _settings.default,
|
|
363
363
|
title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
|
|
364
|
-
onClick: openLinkSettings(editorAnalyticsApi)
|
|
365
|
-
|
|
364
|
+
onClick: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined),
|
|
365
|
+
href: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.card.inject-settings-button') ? userPreferencesLink || (0, _link.getLinkPreferencesURLFromENV)() : (0, _link.getLinkPreferencesURLFromENV)(),
|
|
366
|
+
target: '_blank'
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
var getSettingsButton = exports.getSettingsButton = function getSettingsButton(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
370
|
+
return {
|
|
371
|
+
id: 'editor.link.settings',
|
|
372
|
+
type: 'button',
|
|
373
|
+
icon: _settings.default,
|
|
374
|
+
title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
|
|
375
|
+
onClick: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.card.inject-settings-button') ? openLinkSettings(editorAnalyticsApi, userPreferencesLink) : openLinkSettings(editorAnalyticsApi, undefined)
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
var getSettingsButtonGroup = exports.getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyticsApi, userPreferencesLink) {
|
|
379
|
+
return [getSettingsButton(intl, editorAnalyticsApi, userPreferencesLink), {
|
|
366
380
|
type: 'separator'
|
|
367
381
|
}];
|
|
368
382
|
};
|
|
@@ -383,9 +397,17 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
383
397
|
type: 'separator'
|
|
384
398
|
});
|
|
385
399
|
}
|
|
400
|
+
var canShowMainToolbar = function canShowMainToolbar() {
|
|
401
|
+
if (
|
|
402
|
+
// FF that controls visibily of the additional toolbar buttons
|
|
403
|
+
!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
386
406
|
|
|
387
|
-
|
|
388
|
-
|
|
407
|
+
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
408
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !(0, _utils3.isDatasourceConfigEditable)(datasourceId);
|
|
409
|
+
};
|
|
410
|
+
if (canShowMainToolbar()) {
|
|
389
411
|
var allowBlockCards = cardOptions.allowBlockCards,
|
|
390
412
|
allowEmbeds = cardOptions.allowEmbeds,
|
|
391
413
|
showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
|
|
@@ -450,7 +472,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
450
472
|
}, {
|
|
451
473
|
type: 'separator'
|
|
452
474
|
}]
|
|
453
|
-
}].concat((0, _toConsumableArray2.default)(getSettingsButtonGroup(intl, editorAnalyticsApi)), [{
|
|
475
|
+
}].concat((0, _toConsumableArray2.default)(getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink)), [{
|
|
454
476
|
id: 'editor.link.delete',
|
|
455
477
|
focusEditoronEnter: true,
|
|
456
478
|
type: 'button',
|
|
@@ -10,6 +10,7 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _primitives = require("@atlaskit/primitives");
|
|
12
12
|
var _actions = require("../pm-plugins/actions");
|
|
13
|
+
var _utils2 = require("../utils");
|
|
13
14
|
var _CardContextProvider = require("./CardContextProvider");
|
|
14
15
|
var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
|
|
15
16
|
/** @jsx jsx */
|
|
@@ -33,7 +34,7 @@ var EditDatasourceButtonWithCardContext = function EditDatasourceButtonWithCardC
|
|
|
33
34
|
cardContext: cardContext
|
|
34
35
|
}),
|
|
35
36
|
datasourceId = _useFetchDatasourceIn.datasourceId;
|
|
36
|
-
if (!datasourceId || !(0,
|
|
37
|
+
if (!datasourceId || !(0, _utils2.isDatasourceConfigEditable)(datasourceId)) {
|
|
37
38
|
return null;
|
|
38
39
|
}
|
|
39
40
|
if (url) {
|
|
@@ -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
|
};
|
|
@@ -374,9 +388,17 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
374
388
|
type: 'separator'
|
|
375
389
|
});
|
|
376
390
|
}
|
|
391
|
+
const canShowMainToolbar = () => {
|
|
392
|
+
if (
|
|
393
|
+
// FF that controls visibily of the additional toolbar buttons
|
|
394
|
+
!getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
377
397
|
|
|
378
|
-
|
|
379
|
-
|
|
398
|
+
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
399
|
+
return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
|
|
400
|
+
};
|
|
401
|
+
if (canShowMainToolbar()) {
|
|
380
402
|
const {
|
|
381
403
|
allowBlockCards,
|
|
382
404
|
allowEmbeds,
|
|
@@ -443,7 +465,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
443
465
|
}, {
|
|
444
466
|
type: 'separator'
|
|
445
467
|
}]
|
|
446
|
-
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi), {
|
|
468
|
+
}, ...getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink), {
|
|
447
469
|
id: 'editor.link.delete',
|
|
448
470
|
focusEditoronEnter: true,
|
|
449
471
|
type: 'button',
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator, SmallerEditIcon } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import {
|
|
5
|
+
import { getDatasourceType } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { Flex } from '@atlaskit/primitives';
|
|
7
7
|
import { showDatasourceModal } from '../pm-plugins/actions';
|
|
8
|
+
import { isDatasourceConfigEditable } from '../utils';
|
|
8
9
|
import { CardContextProvider } from './CardContextProvider';
|
|
9
10
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
10
11
|
const buttonStyles = css({
|
|
@@ -28,7 +29,7 @@ const EditDatasourceButtonWithCardContext = ({
|
|
|
28
29
|
url,
|
|
29
30
|
cardContext
|
|
30
31
|
});
|
|
31
|
-
if (!datasourceId || !
|
|
32
|
+
if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
|
|
32
33
|
return null;
|
|
33
34
|
}
|
|
34
35
|
if (url) {
|
|
@@ -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
|
};
|
|
@@ -373,9 +387,17 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
373
387
|
type: 'separator'
|
|
374
388
|
});
|
|
375
389
|
}
|
|
390
|
+
var canShowMainToolbar = function canShowMainToolbar() {
|
|
391
|
+
if (
|
|
392
|
+
// FF that controls visibily of the additional toolbar buttons
|
|
393
|
+
!getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
376
396
|
|
|
377
|
-
|
|
378
|
-
|
|
397
|
+
// FF to enable additional toolbar buttons based on if the datasource is configurable or not
|
|
398
|
+
return getBooleanFF('platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources') ? true : !isDatasourceConfigEditable(datasourceId);
|
|
399
|
+
};
|
|
400
|
+
if (canShowMainToolbar()) {
|
|
379
401
|
var allowBlockCards = cardOptions.allowBlockCards,
|
|
380
402
|
allowEmbeds = cardOptions.allowEmbeds,
|
|
381
403
|
showUpgradeDiscoverability = cardOptions.showUpgradeDiscoverability;
|
|
@@ -440,7 +462,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
440
462
|
}, {
|
|
441
463
|
type: 'separator'
|
|
442
464
|
}]
|
|
443
|
-
}].concat(_toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi)), [{
|
|
465
|
+
}].concat(_toConsumableArray(getSettingsButtonGroup(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink)), [{
|
|
444
466
|
id: 'editor.link.delete',
|
|
445
467
|
focusEditoronEnter: true,
|
|
446
468
|
type: 'button',
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator, SmallerEditIcon } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import {
|
|
5
|
+
import { getDatasourceType } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { Flex } from '@atlaskit/primitives';
|
|
7
7
|
import { showDatasourceModal } from '../pm-plugins/actions';
|
|
8
|
+
import { isDatasourceConfigEditable } from '../utils';
|
|
8
9
|
import { CardContextProvider } from './CardContextProvider';
|
|
9
10
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
10
11
|
var buttonStyles = css({
|
|
@@ -26,7 +27,7 @@ var EditDatasourceButtonWithCardContext = function EditDatasourceButtonWithCardC
|
|
|
26
27
|
cardContext: cardContext
|
|
27
28
|
}),
|
|
28
29
|
datasourceId = _useFetchDatasourceIn.datasourceId;
|
|
29
|
-
if (!datasourceId || !
|
|
30
|
+
if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
33
|
if (url) {
|
package/dist/types/toolbar.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
-
import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { CardPlatform } from '@atlaskit/smart-card';
|
|
5
6
|
import type { cardPlugin } from './index';
|
|
6
7
|
export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
7
8
|
export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
8
|
-
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
9
|
+
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => Command;
|
|
9
10
|
export declare const floatingToolbar: (cardOptions: CardOptions, lpLinkPicker: boolean, platform?: CardPlatform, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>, disableFloatingToolbar?: boolean) => FloatingToolbarHandler;
|
|
11
|
+
export declare const getHyperlinkToolbarSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink?: string) => FloatingToolbarItem<Command>;
|
|
12
|
+
export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>;
|
|
13
|
+
export declare const getSettingsButtonGroup: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>[];
|
|
10
14
|
export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
|
-
import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { CardPlatform } from '@atlaskit/smart-card';
|
|
5
6
|
import type { cardPlugin } from './index';
|
|
6
7
|
export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
7
8
|
export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
8
|
-
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
9
|
+
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => Command;
|
|
9
10
|
export declare const floatingToolbar: (cardOptions: CardOptions, lpLinkPicker: boolean, platform?: CardPlatform, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>, disableFloatingToolbar?: boolean) => FloatingToolbarHandler;
|
|
11
|
+
export declare const getHyperlinkToolbarSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink?: string) => FloatingToolbarItem<Command>;
|
|
12
|
+
export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>;
|
|
13
|
+
export declare const getSettingsButtonGroup: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>[];
|
|
10
14
|
export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^35.8.0",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
37
37
|
"@atlaskit/custom-steps": "^0.0.17",
|
|
38
|
-
"@atlaskit/editor-common": "^78.
|
|
38
|
+
"@atlaskit/editor-common": "^78.27.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-decorations": "^1.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-floating-toolbar": "^1.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-grid": "^1.0.0",
|
|
44
|
-
"@atlaskit/editor-plugin-hyperlink": "^1.
|
|
44
|
+
"@atlaskit/editor-plugin-hyperlink": "^1.5.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^1.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/linking-types": "^8.8.0",
|
|
55
55
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
56
56
|
"@atlaskit/primitives": "^5.5.0",
|
|
57
|
-
"@atlaskit/smart-card": "^26.
|
|
57
|
+
"@atlaskit/smart-card": "^26.55.0",
|
|
58
58
|
"@atlaskit/theme": "^12.7.0",
|
|
59
59
|
"@atlaskit/tokens": "^1.43.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
@@ -113,6 +113,9 @@
|
|
|
113
113
|
"platform.linking-platform.enable-datasource-appearance-toolbar": {
|
|
114
114
|
"type": "boolean"
|
|
115
115
|
},
|
|
116
|
+
"platform.linking-platform.datasource-enable-toolbar-buttons-for-all-datasources": {
|
|
117
|
+
"type": "boolean"
|
|
118
|
+
},
|
|
116
119
|
"platform.editor.card.fix-embed-card-select-all": {
|
|
117
120
|
"type": "boolean"
|
|
118
121
|
},
|
|
@@ -121,6 +124,9 @@
|
|
|
121
124
|
},
|
|
122
125
|
"platform.linking-platform.datasource-assets_objects_remove_beta": {
|
|
123
126
|
"type": "boolean"
|
|
127
|
+
},
|
|
128
|
+
"platform.editor.card.inject-settings-button": {
|
|
129
|
+
"type": "boolean"
|
|
124
130
|
}
|
|
125
131
|
},
|
|
126
132
|
"stricter": {
|