@atlaskit/editor-plugin-card 0.10.9 → 0.11.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 +16 -0
- package/dist/cjs/common/pulse/index.js +6 -14
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/toolbar.js +4 -1
- package/dist/cjs/ui/EditorLinkingPlatformAnalytics/index.js +3 -2
- package/dist/cjs/ui/LinkToolbarAppearance.js +19 -3
- package/dist/es2019/common/pulse/index.js +8 -14
- package/dist/es2019/plugin.js +2 -2
- package/dist/es2019/toolbar.js +3 -0
- package/dist/es2019/ui/EditorLinkingPlatformAnalytics/index.js +3 -2
- package/dist/es2019/ui/LinkToolbarAppearance.js +18 -3
- package/dist/esm/common/pulse/index.js +8 -16
- package/dist/esm/plugin.js +2 -2
- package/dist/esm/toolbar.js +3 -0
- package/dist/esm/ui/EditorLinkingPlatformAnalytics/index.js +3 -2
- package/dist/esm/ui/LinkToolbarAppearance.js +19 -3
- package/dist/types/common/pulse/index.d.ts +1 -5
- package/dist/types/toolbar.d.ts +1 -0
- package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
- package/dist/types/ui/LinkToolbarAppearance.d.ts +9 -8
- package/dist/types-ts4.5/common/pulse/index.d.ts +1 -5
- package/dist/types-ts4.5/toolbar.d.ts +1 -0
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +9 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#42755](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42755) [`97f9fcba5a5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/97f9fcba5a5) - [ux] Add a discovery pulse to smart link view switcher under certain conditions and behind a feature flag
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 0.10.10
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#42151](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42151) [`192b62f6d36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/192b62f6d36) - Cleans up editor feature flag 'lp-analytics-events-next'. Card plugin will now always dispatch link tracking events.
|
|
18
|
+
|
|
3
19
|
## 0.10.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -14,24 +14,16 @@ var DiscoveryPulse = exports.DiscoveryPulse = function DiscoveryPulse(_ref) {
|
|
|
14
14
|
var children = _ref.children,
|
|
15
15
|
localStorageKey = _ref.localStorageKey,
|
|
16
16
|
isDiscovered = _ref.isDiscovered,
|
|
17
|
-
timeToDiscoverInMs = _ref.timeToDiscoverInMs,
|
|
18
17
|
localStorageKeyExpirationInMs = _ref.localStorageKeyExpirationInMs;
|
|
18
|
+
var discovered = isDiscovered || (0, _localStorage.isLocalStorageKeyDiscovered)(localStorageKey);
|
|
19
19
|
var onDiscovery = (0, _react.useCallback)(function () {
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
(0, _react.useEffect)(function () {
|
|
23
|
-
if (timeToDiscoverInMs) {
|
|
24
|
-
var timeoutUntilDiscovery = setTimeout(function () {
|
|
25
|
-
onDiscovery();
|
|
26
|
-
}, timeToDiscoverInMs);
|
|
27
|
-
return function () {
|
|
28
|
-
return clearTimeout(timeoutUntilDiscovery);
|
|
29
|
-
};
|
|
20
|
+
if (!discovered) {
|
|
21
|
+
(0, _localStorage.markLocalStorageKeyDiscovered)(localStorageKey, localStorageKeyExpirationInMs);
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
}, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
|
|
23
|
+
}, [discovered, localStorageKey, localStorageKeyExpirationInMs]);
|
|
33
24
|
return /*#__PURE__*/_react.default.createElement(_linkingCommon.Pulse, {
|
|
34
|
-
|
|
25
|
+
onAnimationIteration: onDiscovery,
|
|
26
|
+
isDiscovered: discovered
|
|
35
27
|
}, children);
|
|
36
28
|
};
|
|
37
29
|
var _default = exports.default = _linkingCommon.Pulse;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -35,7 +35,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
35
35
|
var options = _ref.config,
|
|
36
36
|
api = _ref.api;
|
|
37
37
|
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
38
|
-
var cardPluginEvents =
|
|
38
|
+
var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
|
|
39
39
|
return {
|
|
40
40
|
name: 'card',
|
|
41
41
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -101,7 +101,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
101
101
|
popupsBoundariesElement = _ref3.popupsBoundariesElement;
|
|
102
102
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EditorSmartCardEvents.EditorSmartCardEvents, {
|
|
103
103
|
editorView: editorView
|
|
104
|
-
}),
|
|
104
|
+
}), /*#__PURE__*/_react.default.createElement(_EditorLinkingPlatformAnalytics.EditorLinkingPlatformAnalytics, {
|
|
105
105
|
cardPluginEvents: cardPluginEvents,
|
|
106
106
|
editorView: editorView
|
|
107
107
|
}), /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
|
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.removeCard = exports.openLinkSettings = exports.floatingToolbar = void 0;
|
|
8
|
+
exports.visitCardLink = exports.shouldRenderToolbarPulse = exports.removeCard = exports.openLinkSettings = 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"));
|
|
@@ -407,4 +407,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
407
407
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
408
408
|
});
|
|
409
409
|
return toolbarItems;
|
|
410
|
+
};
|
|
411
|
+
var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
|
|
412
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher');
|
|
410
413
|
};
|
|
@@ -29,14 +29,15 @@ var EditorLinkingPlatformAnalytics = exports.EditorLinkingPlatformAnalytics = /*
|
|
|
29
29
|
(0, _createClass2.default)(EditorLinkingPlatformAnalytics, [{
|
|
30
30
|
key: "render",
|
|
31
31
|
value: function render() {
|
|
32
|
-
var
|
|
32
|
+
var _this$context;
|
|
33
|
+
var cardContext = (_this$context = this.context) === null || _this$context === void 0 || (_this$context = _this$context.contextAdapter) === null || _this$context === void 0 ? void 0 : _this$context.card;
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* The analytics hook needs to be able to communicate with the card context
|
|
36
37
|
* If we can't access it, don't mount the event bindings
|
|
37
38
|
* This effectively entirely disables all tracking behaviour
|
|
38
39
|
*/
|
|
39
|
-
if (!cardContext) {
|
|
40
|
+
if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
43
|
return /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
@@ -20,6 +20,8 @@ var _card = require("@atlaskit/editor-common/card");
|
|
|
20
20
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
22
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
23
|
+
var _pulse = require("../common/pulse");
|
|
24
|
+
var _toolbar = require("../toolbar");
|
|
23
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
27
|
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; }
|
|
@@ -38,7 +40,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
|
|
|
38
40
|
}
|
|
39
41
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
40
42
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderDropdown", function (view, cardContext) {
|
|
41
|
-
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3;
|
|
43
|
+
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3, _cardContext$store2;
|
|
42
44
|
var _this$props = _this.props,
|
|
43
45
|
url = _this$props.url,
|
|
44
46
|
intl = _this$props.intl,
|
|
@@ -49,7 +51,9 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
|
|
|
49
51
|
allowBlockCards = _this$props$allowBloc === void 0 ? true : _this$props$allowBloc,
|
|
50
52
|
platform = _this$props.platform,
|
|
51
53
|
editorAnalyticsApi = _this$props.editorAnalyticsApi,
|
|
52
|
-
cardActions = _this$props.cardActions
|
|
54
|
+
cardActions = _this$props.cardActions,
|
|
55
|
+
_this$props$showInlin = _this$props.showInlineUpgradeDiscoverability,
|
|
56
|
+
showInlineUpgradeDiscoverability = _this$props$showInlin === void 0 ? false : _this$props$showInlin;
|
|
53
57
|
var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
|
|
54
58
|
var defaultCommand = function defaultCommand() {
|
|
55
59
|
return false;
|
|
@@ -109,7 +113,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
|
|
|
109
113
|
if (embedOption) {
|
|
110
114
|
options.push(embedOption);
|
|
111
115
|
}
|
|
112
|
-
|
|
116
|
+
var LinkToolbarButtons = /*#__PURE__*/_react.default.createElement(_card.LinkToolbarButtonGroup, {
|
|
113
117
|
key: "link-toolbar-button-group",
|
|
114
118
|
options: options.map(function (option) {
|
|
115
119
|
return (0, _card.getButtonGroupOption)(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
|
|
@@ -119,6 +123,18 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
|
|
|
119
123
|
}));
|
|
120
124
|
})
|
|
121
125
|
});
|
|
126
|
+
var status = url ? cardContext === null || cardContext === void 0 || (_cardContext$store2 = cardContext.store) === null || _cardContext$store2 === void 0 || (_cardContext$store2 = _cardContext$store2.getState()[url]) === null || _cardContext$store2 === void 0 ? void 0 : _cardContext$store2.status : '';
|
|
127
|
+
var embedEnabled = embedOption ? !embedOption.disabled : false;
|
|
128
|
+
if ((0, _toolbar.shouldRenderToolbarPulse)(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showInlineUpgradeDiscoverability)) {
|
|
129
|
+
return (
|
|
130
|
+
/*#__PURE__*/
|
|
131
|
+
// This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
|
|
132
|
+
_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_pulse.DiscoveryPulse, {
|
|
133
|
+
localStorageKey: "toolbar-upgrade-pulse"
|
|
134
|
+
}, LinkToolbarButtons))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return LinkToolbarButtons;
|
|
122
138
|
});
|
|
123
139
|
return _this;
|
|
124
140
|
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import React, { useCallback
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { Pulse } from '@atlaskit/linking-common';
|
|
3
|
-
import { markLocalStorageKeyDiscovered } from '../local-storage';
|
|
3
|
+
import { isLocalStorageKeyDiscovered, markLocalStorageKeyDiscovered } from '../local-storage';
|
|
4
4
|
export const DiscoveryPulse = ({
|
|
5
5
|
children,
|
|
6
6
|
localStorageKey,
|
|
7
7
|
isDiscovered,
|
|
8
|
-
timeToDiscoverInMs,
|
|
9
8
|
localStorageKeyExpirationInMs
|
|
10
9
|
}) => {
|
|
10
|
+
const discovered = isDiscovered || isLocalStorageKeyDiscovered(localStorageKey);
|
|
11
11
|
const onDiscovery = useCallback(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (timeToDiscoverInMs) {
|
|
16
|
-
const timeoutUntilDiscovery = setTimeout(() => {
|
|
17
|
-
onDiscovery();
|
|
18
|
-
}, timeToDiscoverInMs);
|
|
19
|
-
return () => clearTimeout(timeoutUntilDiscovery);
|
|
12
|
+
if (!discovered) {
|
|
13
|
+
markLocalStorageKeyDiscovered(localStorageKey, localStorageKeyExpirationInMs);
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
}, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
|
|
15
|
+
}, [discovered, localStorageKey, localStorageKeyExpirationInMs]);
|
|
23
16
|
return /*#__PURE__*/React.createElement(Pulse, {
|
|
24
|
-
|
|
17
|
+
onAnimationIteration: onDiscovery,
|
|
18
|
+
isDiscovered: discovered
|
|
25
19
|
}, children);
|
|
26
20
|
};
|
|
27
21
|
export default Pulse;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -26,7 +26,7 @@ export const cardPlugin = ({
|
|
|
26
26
|
}) => {
|
|
27
27
|
var _api$featureFlags;
|
|
28
28
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
29
|
-
const cardPluginEvents =
|
|
29
|
+
const cardPluginEvents = createEventsQueue();
|
|
30
30
|
return {
|
|
31
31
|
name: 'card',
|
|
32
32
|
getSharedState(editorState) {
|
|
@@ -93,7 +93,7 @@ export const cardPlugin = ({
|
|
|
93
93
|
}) {
|
|
94
94
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
95
95
|
editorView: editorView
|
|
96
|
-
}),
|
|
96
|
+
}), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
|
|
97
97
|
cardPluginEvents: cardPluginEvents,
|
|
98
98
|
editorView: editorView
|
|
99
99
|
}), /*#__PURE__*/React.createElement(LayoutButton, {
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -402,4 +402,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
402
402
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
403
403
|
});
|
|
404
404
|
return toolbarItems;
|
|
405
|
+
};
|
|
406
|
+
export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled) => {
|
|
407
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && getBooleanFF('platform.linking-platform.smart-card.inline-switcher');
|
|
405
408
|
};
|
|
@@ -8,14 +8,15 @@ import { LinkEventsBinding } from './LinkEvents';
|
|
|
8
8
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
9
9
|
export class EditorLinkingPlatformAnalytics extends React.PureComponent {
|
|
10
10
|
render() {
|
|
11
|
-
|
|
11
|
+
var _this$context, _this$context$context;
|
|
12
|
+
const cardContext = (_this$context = this.context) === null || _this$context === void 0 ? void 0 : (_this$context$context = _this$context.contextAdapter) === null || _this$context$context === void 0 ? void 0 : _this$context$context.card;
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The analytics hook needs to be able to communicate with the card context
|
|
15
16
|
* If we can't access it, don't mount the event bindings
|
|
16
17
|
* This effectively entirely disables all tracking behaviour
|
|
17
18
|
*/
|
|
18
|
-
if (!cardContext) {
|
|
19
|
+
if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
22
|
return /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
@@ -6,12 +6,14 @@ import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } fro
|
|
|
6
6
|
import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
9
|
+
import { DiscoveryPulse } from '../common/pulse';
|
|
10
|
+
import { shouldRenderToolbarPulse } from '../toolbar';
|
|
9
11
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
10
12
|
export class LinkToolbarAppearance extends React.Component {
|
|
11
13
|
constructor(...args) {
|
|
12
14
|
super(...args);
|
|
13
15
|
_defineProperty(this, "renderDropdown", (view, cardContext) => {
|
|
14
|
-
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3;
|
|
16
|
+
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3, _cardContext$store2, _cardContext$store2$g;
|
|
15
17
|
const {
|
|
16
18
|
url,
|
|
17
19
|
intl,
|
|
@@ -21,7 +23,8 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
21
23
|
allowBlockCards = true,
|
|
22
24
|
platform,
|
|
23
25
|
editorAnalyticsApi,
|
|
24
|
-
cardActions
|
|
26
|
+
cardActions,
|
|
27
|
+
showInlineUpgradeDiscoverability = false
|
|
25
28
|
} = this.props;
|
|
26
29
|
const preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
|
|
27
30
|
const defaultCommand = () => false;
|
|
@@ -80,7 +83,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
80
83
|
if (embedOption) {
|
|
81
84
|
options.push(embedOption);
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
const LinkToolbarButtons = /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
|
|
84
87
|
key: "link-toolbar-button-group",
|
|
85
88
|
options: options.map(option => getButtonGroupOption(intl, dispatchCommand, {
|
|
86
89
|
...option,
|
|
@@ -89,6 +92,18 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
89
92
|
})
|
|
90
93
|
}))
|
|
91
94
|
});
|
|
95
|
+
const status = url ? cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$store2 = cardContext.store) === null || _cardContext$store2 === void 0 ? void 0 : (_cardContext$store2$g = _cardContext$store2.getState()[url]) === null || _cardContext$store2$g === void 0 ? void 0 : _cardContext$store2$g.status : '';
|
|
96
|
+
const embedEnabled = embedOption ? !embedOption.disabled : false;
|
|
97
|
+
if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showInlineUpgradeDiscoverability)) {
|
|
98
|
+
return (
|
|
99
|
+
/*#__PURE__*/
|
|
100
|
+
// This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
|
|
101
|
+
React.createElement("div", null, /*#__PURE__*/React.createElement(DiscoveryPulse, {
|
|
102
|
+
localStorageKey: "toolbar-upgrade-pulse"
|
|
103
|
+
}, LinkToolbarButtons))
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return LinkToolbarButtons;
|
|
92
107
|
});
|
|
93
108
|
}
|
|
94
109
|
render() {
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import React, { useCallback
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { Pulse } from '@atlaskit/linking-common';
|
|
3
|
-
import { markLocalStorageKeyDiscovered } from '../local-storage';
|
|
3
|
+
import { isLocalStorageKeyDiscovered, markLocalStorageKeyDiscovered } from '../local-storage';
|
|
4
4
|
export var DiscoveryPulse = function DiscoveryPulse(_ref) {
|
|
5
5
|
var children = _ref.children,
|
|
6
6
|
localStorageKey = _ref.localStorageKey,
|
|
7
7
|
isDiscovered = _ref.isDiscovered,
|
|
8
|
-
timeToDiscoverInMs = _ref.timeToDiscoverInMs,
|
|
9
8
|
localStorageKeyExpirationInMs = _ref.localStorageKeyExpirationInMs;
|
|
9
|
+
var discovered = isDiscovered || isLocalStorageKeyDiscovered(localStorageKey);
|
|
10
10
|
var onDiscovery = useCallback(function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
useEffect(function () {
|
|
14
|
-
if (timeToDiscoverInMs) {
|
|
15
|
-
var timeoutUntilDiscovery = setTimeout(function () {
|
|
16
|
-
onDiscovery();
|
|
17
|
-
}, timeToDiscoverInMs);
|
|
18
|
-
return function () {
|
|
19
|
-
return clearTimeout(timeoutUntilDiscovery);
|
|
20
|
-
};
|
|
11
|
+
if (!discovered) {
|
|
12
|
+
markLocalStorageKeyDiscovered(localStorageKey, localStorageKeyExpirationInMs);
|
|
21
13
|
}
|
|
22
|
-
|
|
23
|
-
}, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
|
|
14
|
+
}, [discovered, localStorageKey, localStorageKeyExpirationInMs]);
|
|
24
15
|
return /*#__PURE__*/React.createElement(Pulse, {
|
|
25
|
-
|
|
16
|
+
onAnimationIteration: onDiscovery,
|
|
17
|
+
isDiscovered: discovered
|
|
26
18
|
}, children);
|
|
27
19
|
};
|
|
28
20
|
export default Pulse;
|
package/dist/esm/plugin.js
CHANGED
|
@@ -28,7 +28,7 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
28
28
|
var options = _ref.config,
|
|
29
29
|
api = _ref.api;
|
|
30
30
|
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
31
|
-
var cardPluginEvents =
|
|
31
|
+
var cardPluginEvents = createEventsQueue();
|
|
32
32
|
return {
|
|
33
33
|
name: 'card',
|
|
34
34
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -94,7 +94,7 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
94
94
|
popupsBoundariesElement = _ref3.popupsBoundariesElement;
|
|
95
95
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
96
96
|
editorView: editorView
|
|
97
|
-
}),
|
|
97
|
+
}), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
|
|
98
98
|
cardPluginEvents: cardPluginEvents,
|
|
99
99
|
editorView: editorView
|
|
100
100
|
}), /*#__PURE__*/React.createElement(LayoutButton, {
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -397,4 +397,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
397
397
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
398
398
|
});
|
|
399
399
|
return toolbarItems;
|
|
400
|
+
};
|
|
401
|
+
export var shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
|
|
402
|
+
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && getBooleanFF('platform.linking-platform.smart-card.inline-switcher');
|
|
400
403
|
};
|
|
@@ -23,14 +23,15 @@ export var EditorLinkingPlatformAnalytics = /*#__PURE__*/function (_React$PureCo
|
|
|
23
23
|
_createClass(EditorLinkingPlatformAnalytics, [{
|
|
24
24
|
key: "render",
|
|
25
25
|
value: function render() {
|
|
26
|
-
var
|
|
26
|
+
var _this$context;
|
|
27
|
+
var cardContext = (_this$context = this.context) === null || _this$context === void 0 || (_this$context = _this$context.contextAdapter) === null || _this$context === void 0 ? void 0 : _this$context.card;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* The analytics hook needs to be able to communicate with the card context
|
|
30
31
|
* If we can't access it, don't mount the event bindings
|
|
31
32
|
* This effectively entirely disables all tracking behaviour
|
|
32
33
|
*/
|
|
33
|
-
if (!cardContext) {
|
|
34
|
+
if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
37
|
return /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
@@ -16,6 +16,8 @@ import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } fro
|
|
|
16
16
|
import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
17
|
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
18
18
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
19
|
+
import { DiscoveryPulse } from '../common/pulse';
|
|
20
|
+
import { shouldRenderToolbarPulse } from '../toolbar';
|
|
19
21
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
20
22
|
export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
21
23
|
_inherits(LinkToolbarAppearance, _React$Component);
|
|
@@ -28,7 +30,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
28
30
|
}
|
|
29
31
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
32
|
_defineProperty(_assertThisInitialized(_this), "renderDropdown", function (view, cardContext) {
|
|
31
|
-
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3;
|
|
33
|
+
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3, _cardContext$store2;
|
|
32
34
|
var _this$props = _this.props,
|
|
33
35
|
url = _this$props.url,
|
|
34
36
|
intl = _this$props.intl,
|
|
@@ -39,7 +41,9 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
39
41
|
allowBlockCards = _this$props$allowBloc === void 0 ? true : _this$props$allowBloc,
|
|
40
42
|
platform = _this$props.platform,
|
|
41
43
|
editorAnalyticsApi = _this$props.editorAnalyticsApi,
|
|
42
|
-
cardActions = _this$props.cardActions
|
|
44
|
+
cardActions = _this$props.cardActions,
|
|
45
|
+
_this$props$showInlin = _this$props.showInlineUpgradeDiscoverability,
|
|
46
|
+
showInlineUpgradeDiscoverability = _this$props$showInlin === void 0 ? false : _this$props$showInlin;
|
|
43
47
|
var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
|
|
44
48
|
var defaultCommand = function defaultCommand() {
|
|
45
49
|
return false;
|
|
@@ -99,7 +103,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
99
103
|
if (embedOption) {
|
|
100
104
|
options.push(embedOption);
|
|
101
105
|
}
|
|
102
|
-
|
|
106
|
+
var LinkToolbarButtons = /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
|
|
103
107
|
key: "link-toolbar-button-group",
|
|
104
108
|
options: options.map(function (option) {
|
|
105
109
|
return getButtonGroupOption(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
|
|
@@ -109,6 +113,18 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
|
|
|
109
113
|
}));
|
|
110
114
|
})
|
|
111
115
|
});
|
|
116
|
+
var status = url ? cardContext === null || cardContext === void 0 || (_cardContext$store2 = cardContext.store) === null || _cardContext$store2 === void 0 || (_cardContext$store2 = _cardContext$store2.getState()[url]) === null || _cardContext$store2 === void 0 ? void 0 : _cardContext$store2.status : '';
|
|
117
|
+
var embedEnabled = embedOption ? !embedOption.disabled : false;
|
|
118
|
+
if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showInlineUpgradeDiscoverability)) {
|
|
119
|
+
return (
|
|
120
|
+
/*#__PURE__*/
|
|
121
|
+
// This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
|
|
122
|
+
React.createElement("div", null, /*#__PURE__*/React.createElement(DiscoveryPulse, {
|
|
123
|
+
localStorageKey: "toolbar-upgrade-pulse"
|
|
124
|
+
}, LinkToolbarButtons))
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return LinkToolbarButtons;
|
|
112
128
|
});
|
|
113
129
|
return _this;
|
|
114
130
|
}
|
|
@@ -13,14 +13,10 @@ export interface PulseProps {
|
|
|
13
13
|
* The time in ms after which the key in local storage will be considered expired and the Pulse will be shown again
|
|
14
14
|
*/
|
|
15
15
|
localStorageKeyExpirationInMs?: number;
|
|
16
|
-
/**
|
|
17
|
-
* The time in ms since the Pulse has started after which the key will be stored in local storage.
|
|
18
|
-
*/
|
|
19
|
-
timeToDiscoverInMs?: number;
|
|
20
16
|
/**
|
|
21
17
|
* And indicator that the feature was discovered externally and the pulsation needs to stop.
|
|
22
18
|
*/
|
|
23
19
|
isDiscovered?: boolean;
|
|
24
20
|
}
|
|
25
|
-
export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered,
|
|
21
|
+
export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
|
|
26
22
|
export default Pulse;
|
package/dist/types/toolbar.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undef
|
|
|
7
7
|
export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
8
8
|
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
9
9
|
export declare const floatingToolbar: (cardOptions: CardOptions, featureFlags: FeatureFlags, platform?: CardPlatform, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>) => FloatingToolbarHandler;
|
|
10
|
+
export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { AnalyticsBindingsProps } from './common';
|
|
3
|
+
import type { AnalyticsBindingsProps } from './common';
|
|
4
4
|
export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
|
|
5
5
|
static contextTypes: {
|
|
6
6
|
contextAdapter: PropTypes.Requireable<object>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { IntlShape } from 'react-intl-next';
|
|
4
|
-
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
6
|
-
import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
-
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { CardContext } from '@atlaskit/link-provider';
|
|
10
|
-
import { CardPlatform } from '@atlaskit/smart-card';
|
|
3
|
+
import type { IntlShape } from 'react-intl-next';
|
|
4
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
6
|
+
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import type { CardContext } from '@atlaskit/link-provider';
|
|
10
|
+
import type { CardPlatform } from '@atlaskit/smart-card';
|
|
11
11
|
export interface LinkToolbarAppearanceProps {
|
|
12
12
|
intl: IntlShape;
|
|
13
13
|
editorAnalyticsApi: EditorAnalyticsAPI | undefined;
|
|
@@ -19,6 +19,7 @@ export interface LinkToolbarAppearanceProps {
|
|
|
19
19
|
allowBlockCards?: boolean;
|
|
20
20
|
platform?: CardPlatform;
|
|
21
21
|
cardActions: CardPluginActions | undefined;
|
|
22
|
+
showInlineUpgradeDiscoverability?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
|
|
24
25
|
static contextTypes: {
|
|
@@ -13,14 +13,10 @@ export interface PulseProps {
|
|
|
13
13
|
* The time in ms after which the key in local storage will be considered expired and the Pulse will be shown again
|
|
14
14
|
*/
|
|
15
15
|
localStorageKeyExpirationInMs?: number;
|
|
16
|
-
/**
|
|
17
|
-
* The time in ms since the Pulse has started after which the key will be stored in local storage.
|
|
18
|
-
*/
|
|
19
|
-
timeToDiscoverInMs?: number;
|
|
20
16
|
/**
|
|
21
17
|
* And indicator that the feature was discovered externally and the pulsation needs to stop.
|
|
22
18
|
*/
|
|
23
19
|
isDiscovered?: boolean;
|
|
24
20
|
}
|
|
25
|
-
export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered,
|
|
21
|
+
export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
|
|
26
22
|
export default Pulse;
|
|
@@ -7,3 +7,4 @@ export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undef
|
|
|
7
7
|
export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
8
8
|
export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
|
|
9
9
|
export declare const floatingToolbar: (cardOptions: CardOptions, featureFlags: FeatureFlags, platform?: CardPlatform, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>) => FloatingToolbarHandler;
|
|
10
|
+
export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { AnalyticsBindingsProps } from './common';
|
|
3
|
+
import type { AnalyticsBindingsProps } from './common';
|
|
4
4
|
export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
|
|
5
5
|
static contextTypes: {
|
|
6
6
|
contextAdapter: PropTypes.Requireable<object>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { IntlShape } from 'react-intl-next';
|
|
4
|
-
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
6
|
-
import { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
-
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { CardContext } from '@atlaskit/link-provider';
|
|
10
|
-
import { CardPlatform } from '@atlaskit/smart-card';
|
|
3
|
+
import type { IntlShape } from 'react-intl-next';
|
|
4
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
6
|
+
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import type { CardContext } from '@atlaskit/link-provider';
|
|
10
|
+
import type { CardPlatform } from '@atlaskit/smart-card';
|
|
11
11
|
export interface LinkToolbarAppearanceProps {
|
|
12
12
|
intl: IntlShape;
|
|
13
13
|
editorAnalyticsApi: EditorAnalyticsAPI | undefined;
|
|
@@ -19,6 +19,7 @@ export interface LinkToolbarAppearanceProps {
|
|
|
19
19
|
allowBlockCards?: boolean;
|
|
20
20
|
platform?: CardPlatform;
|
|
21
21
|
cardActions: CardPluginActions | undefined;
|
|
22
|
+
showInlineUpgradeDiscoverability?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare class LinkToolbarAppearance extends React.Component<LinkToolbarAppearanceProps, {}> {
|
|
24
25
|
static contextTypes: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
48
48
|
"@atlaskit/icon": "^21.12.0",
|
|
49
49
|
"@atlaskit/link-analytics": "^8.3.0",
|
|
50
|
-
"@atlaskit/link-datasource": "^1.
|
|
51
|
-
"@atlaskit/linking-common": "^4.
|
|
50
|
+
"@atlaskit/link-datasource": "^1.14.0",
|
|
51
|
+
"@atlaskit/linking-common": "^4.17.0",
|
|
52
52
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
53
|
-
"@atlaskit/smart-card": "^26.
|
|
53
|
+
"@atlaskit/smart-card": "^26.42.0",
|
|
54
54
|
"@atlaskit/theme": "^12.6.0",
|
|
55
55
|
"@atlaskit/tokens": "^1.28.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|