@atlaskit/editor-plugin-card 0.13.3 → 0.13.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43379](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43379) [`482c025520d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/482c025520d) - ED-20763 Upgrade ADF schema version to 33.2.3 for MBE nodes.
8
+ - [#43352](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43352) [`087515ab3ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/087515ab3ea) - [ux] Added on selection behaviour for inline link
9
+ - Updated dependencies
10
+
3
11
  ## 0.13.3
4
12
 
5
13
  ### Patch Changes
@@ -8,7 +8,7 @@ var _frontendUtilities = require("@atlaskit/frontend-utilities");
8
8
  var LOCAL_STORAGE_CLIENT_KEY = exports.LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
9
9
  var LOCAL_STORAGE_DISCOVERED_KEY = exports.LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
10
10
  var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = exports.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
11
- var LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = exports.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'link-toolbar-button-group';
11
+ var LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = exports.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'toolbar-upgrade-pulse';
12
12
  var ONE_DAY_IN_MILLISECONDS = exports.ONE_DAY_IN_MILLISECONDS = 86400000;
13
13
  var storageClient = new _frontendUtilities.StorageClient(LOCAL_STORAGE_CLIENT_KEY);
14
14
  var isLocalStorageKeyDiscovered = exports.isLocalStorageKeyDiscovered = function isLocalStorageKeyDiscovered(key) {
@@ -4,7 +4,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.DiscoveryPulse = void 0;
7
+ exports.DiscoveryPulse = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _linkingCommon = require("@atlaskit/linking-common");
10
10
  var _localStorage = require("../local-storage");
@@ -29,5 +29,4 @@ var DiscoveryPulse = exports.DiscoveryPulse = function DiscoveryPulse(_ref) {
29
29
  isDiscovered: discovered
30
30
  };
31
31
  return /*#__PURE__*/_react.default.createElement(_linkingCommon.Pulse, pulseProps, children);
32
- };
33
- var _default = exports.default = _linkingCommon.Pulse;
32
+ };
@@ -17,6 +17,7 @@ var _react = _interopRequireDefault(require("react"));
17
17
  var _propTypes = _interopRequireDefault(require("prop-types"));
18
18
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
19
  var _ui = require("@atlaskit/editor-common/ui");
20
+ var _state = require("@atlaskit/editor-prosemirror/state");
20
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  var _smartCard = require("@atlaskit/smart-card");
22
23
  var _actions = require("../pm-plugins/actions");
@@ -120,6 +121,7 @@ var InlineCardComponent = exports.InlineCardComponent = /*#__PURE__*/function (_
120
121
  var WrappedInlineCard = (0, _genericCard.Card)(InlineCardComponent, _ui.UnsupportedInline);
121
122
  var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
122
123
  function InlineCardNodeView(props) {
124
+ var _view$state$selection, _view$state$selection2;
123
125
  var useAlternativePreloader = props.useAlternativePreloader,
124
126
  node = props.node,
125
127
  view = props.view,
@@ -144,6 +146,7 @@ function InlineCardNodeView(props) {
144
146
  var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? (0, _utils.isBlockSupportedAtPosition)(linkPosition, editorState, 'inline') : false;
145
147
  var isPulseEnabled = enableInlineUpgradeFeatures && canBeUpgradedToEmbed;
146
148
  var isOverlayEnabled = enableInlineUpgradeFeatures && (canBeUpgradedToEmbed || canBeUpgradedToBlock);
149
+ var isSelected = view.state.selection instanceof _state.NodeSelection && ((_view$state$selection = view.state.selection) === null || _view$state$selection === void 0 || (_view$state$selection = _view$state$selection.node) === null || _view$state$selection === void 0 ? void 0 : _view$state$selection.type) === view.state.schema.nodes.inlineCard && ((_view$state$selection2 = view.state.selection) === null || _view$state$selection2 === void 0 ? void 0 : _view$state$selection2.from) === getPos();
147
150
  return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, {
148
151
  node: node,
149
152
  view: view,
@@ -152,6 +155,7 @@ function InlineCardNodeView(props) {
152
155
  useAlternativePreloader: useAlternativePreloader,
153
156
  isOverlayEnabled: isOverlayEnabled,
154
157
  isPulseEnabled: isPulseEnabled,
155
- pluginInjectionApi: pluginInjectionApi
158
+ pluginInjectionApi: pluginInjectionApi,
159
+ isSelected: isSelected
156
160
  });
157
161
  }
@@ -36,7 +36,8 @@ var InlineCard = function InlineCard(_ref) {
36
36
  getPos = _ref.getPos,
37
37
  isOverlayEnabled = _ref.isOverlayEnabled,
38
38
  isPulseEnabled = _ref.isPulseEnabled,
39
- pluginInjectionApi = _ref.pluginInjectionApi;
39
+ pluginInjectionApi = _ref.pluginInjectionApi,
40
+ isSelected = _ref.isSelected;
40
41
  var _node$attrs = node.attrs,
41
42
  url = _node$attrs.url,
42
43
  data = _node$attrs.data;
@@ -63,7 +64,14 @@ var InlineCard = function InlineCard(_ref) {
63
64
  isPulseEnabled: isPulseEnabled
64
65
  }),
65
66
  shouldShowLinkPulse = _useLinkUpgradeDiscov.shouldShowLinkPulse,
67
+ shouldShowToolbarPulse = _useLinkUpgradeDiscov.shouldShowToolbarPulse,
66
68
  shouldShowLinkOverlay = _useLinkUpgradeDiscov.shouldShowLinkOverlay;
69
+
70
+ // If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
71
+ // we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
72
+ if (isSelected && shouldShowToolbarPulse && !(0, _localStorage.isLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
73
+ (0, _localStorage.markLocalStorageKeyDiscovered)(_localStorage.LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
74
+ }
67
75
  var scrollContainer = (0, _react.useMemo)(function () {
68
76
  return (0, _ui.findOverflowScrollParent)(view.dom) || undefined;
69
77
  }, [view.dom]);
@@ -54,7 +54,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
54
54
  editorAnalyticsApi = _this$props.editorAnalyticsApi,
55
55
  cardActions = _this$props.cardActions,
56
56
  _this$props$showUpgra = _this$props.showUpgradeDiscoverability,
57
- showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? false : _this$props$showUpgra;
57
+ showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra;
58
58
  var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
59
59
  var defaultCommand = function defaultCommand() {
60
60
  return false;
@@ -115,7 +115,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
115
115
  options.push(embedOption);
116
116
  }
117
117
  var LinkToolbarButtons = /*#__PURE__*/_react.default.createElement(_card.LinkToolbarButtonGroup, {
118
- key: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR,
118
+ key: "link-toolbar-button-group",
119
119
  options: options.map(function (option) {
120
120
  return (0, _card.getButtonGroupOption)(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
121
121
  onClick: (0, _card.commandWithMetadata)(option.onClick, {
@@ -127,13 +127,9 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = /*#__PURE__*/functio
127
127
  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 : '';
128
128
  var embedEnabled = embedOption ? !embedOption.disabled : false;
129
129
  if ((0, _toolbar.shouldRenderToolbarPulse)(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showUpgradeDiscoverability)) {
130
- return (
131
- /*#__PURE__*/
132
- // This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
133
- _react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_pulse.DiscoveryPulse, {
134
- localStorageKey: "toolbar-upgrade-pulse"
135
- }, LinkToolbarButtons))
136
- );
130
+ return /*#__PURE__*/_react.default.createElement(_pulse.DiscoveryPulse, {
131
+ localStorageKey: _localStorage.LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR
132
+ }, LinkToolbarButtons);
137
133
  }
138
134
  return LinkToolbarButtons;
139
135
  });
@@ -2,7 +2,7 @@ import { StorageClient } from '@atlaskit/frontend-utilities';
2
2
  export const LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
3
3
  export const LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
4
4
  export const LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
5
- export const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'link-toolbar-button-group';
5
+ export const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'toolbar-upgrade-pulse';
6
6
  export const ONE_DAY_IN_MILLISECONDS = 86400000;
7
7
  const storageClient = new StorageClient(LOCAL_STORAGE_CLIENT_KEY);
8
8
  export const isLocalStorageKeyDiscovered = key => {
@@ -20,5 +20,4 @@ export const DiscoveryPulse = ({
20
20
  isDiscovered: discovered
21
21
  };
22
22
  return /*#__PURE__*/React.createElement(Pulse, pulseProps, children);
23
- };
24
- export default Pulse;
23
+ };
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import rafSchedule from 'raf-schd';
5
5
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
6
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
  import { Card as SmartCard } from '@atlaskit/smart-card';
8
9
  import { registerCard } from '../pm-plugins/actions';
@@ -100,6 +101,7 @@ _defineProperty(InlineCardComponent, "contextTypes", {
100
101
  const WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
101
102
  const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
102
103
  export function InlineCardNodeView(props) {
104
+ var _view$state$selection, _view$state$selection2, _view$state$selection3;
103
105
  const {
104
106
  useAlternativePreloader,
105
107
  node,
@@ -126,6 +128,7 @@ export function InlineCardNodeView(props) {
126
128
  const canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
127
129
  const isPulseEnabled = enableInlineUpgradeFeatures && canBeUpgradedToEmbed;
128
130
  const isOverlayEnabled = enableInlineUpgradeFeatures && (canBeUpgradedToEmbed || canBeUpgradedToBlock);
131
+ const isSelected = view.state.selection instanceof NodeSelection && ((_view$state$selection = view.state.selection) === null || _view$state$selection === void 0 ? void 0 : (_view$state$selection2 = _view$state$selection.node) === null || _view$state$selection2 === void 0 ? void 0 : _view$state$selection2.type) === view.state.schema.nodes.inlineCard && ((_view$state$selection3 = view.state.selection) === null || _view$state$selection3 === void 0 ? void 0 : _view$state$selection3.from) === getPos();
129
132
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, {
130
133
  node: node,
131
134
  view: view,
@@ -134,6 +137,7 @@ export function InlineCardNodeView(props) {
134
137
  useAlternativePreloader: useAlternativePreloader,
135
138
  isOverlayEnabled: isOverlayEnabled,
136
139
  isPulseEnabled: isPulseEnabled,
137
- pluginInjectionApi: pluginInjectionApi
140
+ pluginInjectionApi: pluginInjectionApi,
141
+ isSelected: isSelected
138
142
  });
139
143
  }
@@ -6,7 +6,7 @@ import rafSchedule from 'raf-schd';
6
6
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
7
7
  import { Card as SmartCard } from '@atlaskit/smart-card';
8
8
  import useLinkUpgradeDiscoverability from '../common/hooks/useLinkUpgradeDiscoverability';
9
- import { LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, ONE_DAY_IN_MILLISECONDS } from '../common/local-storage';
9
+ import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../common/local-storage';
10
10
  import { DiscoveryPulse } from '../common/pulse';
11
11
  import { registerCard } from '../pm-plugins/actions';
12
12
  import InlineCardOverlay from '../ui/InlineCardOverlay';
@@ -27,7 +27,8 @@ const InlineCard = ({
27
27
  getPos,
28
28
  isOverlayEnabled,
29
29
  isPulseEnabled,
30
- pluginInjectionApi
30
+ pluginInjectionApi,
31
+ isSelected
31
32
  }) => {
32
33
  const {
33
34
  url,
@@ -46,6 +47,7 @@ const InlineCard = ({
46
47
  }, [getPos]);
47
48
  const {
48
49
  shouldShowLinkPulse,
50
+ shouldShowToolbarPulse,
49
51
  shouldShowLinkOverlay
50
52
  } = useLinkUpgradeDiscoverability({
51
53
  url,
@@ -55,6 +57,12 @@ const InlineCard = ({
55
57
  isOverlayEnabled,
56
58
  isPulseEnabled
57
59
  });
60
+
61
+ // If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
62
+ // we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
63
+ if (isSelected && shouldShowToolbarPulse && !isLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
64
+ markLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
65
+ }
58
66
  const scrollContainer = useMemo(() => findOverflowScrollParent(view.dom) || undefined, [view.dom]);
59
67
  const onResolve = useCallback(data => {
60
68
  if (!getPos || typeof getPos === 'boolean') {
@@ -25,7 +25,7 @@ export class LinkToolbarAppearance extends React.Component {
25
25
  platform,
26
26
  editorAnalyticsApi,
27
27
  cardActions,
28
- showUpgradeDiscoverability = false
28
+ showUpgradeDiscoverability = true
29
29
  } = this.props;
30
30
  const preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
31
31
  const defaultCommand = () => false;
@@ -85,7 +85,7 @@ export class LinkToolbarAppearance extends React.Component {
85
85
  options.push(embedOption);
86
86
  }
87
87
  const LinkToolbarButtons = /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
88
- key: LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR,
88
+ key: "link-toolbar-button-group",
89
89
  options: options.map(option => getButtonGroupOption(intl, dispatchCommand, {
90
90
  ...option,
91
91
  onClick: commandWithMetadata(option.onClick, {
@@ -96,13 +96,9 @@ export class LinkToolbarAppearance extends React.Component {
96
96
  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 : '';
97
97
  const embedEnabled = embedOption ? !embedOption.disabled : false;
98
98
  if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showUpgradeDiscoverability)) {
99
- return (
100
- /*#__PURE__*/
101
- // This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
102
- React.createElement("div", null, /*#__PURE__*/React.createElement(DiscoveryPulse, {
103
- localStorageKey: "toolbar-upgrade-pulse"
104
- }, LinkToolbarButtons))
105
- );
99
+ return /*#__PURE__*/React.createElement(DiscoveryPulse, {
100
+ localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR
101
+ }, LinkToolbarButtons);
106
102
  }
107
103
  return LinkToolbarButtons;
108
104
  });
@@ -2,7 +2,7 @@ import { StorageClient } from '@atlaskit/frontend-utilities';
2
2
  export var LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
3
3
  export var LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
4
4
  export var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
5
- export var LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'link-toolbar-button-group';
5
+ export var LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = 'toolbar-upgrade-pulse';
6
6
  export var ONE_DAY_IN_MILLISECONDS = 86400000;
7
7
  var storageClient = new StorageClient(LOCAL_STORAGE_CLIENT_KEY);
8
8
  export var isLocalStorageKeyDiscovered = function isLocalStorageKeyDiscovered(key) {
@@ -20,5 +20,4 @@ export var DiscoveryPulse = function DiscoveryPulse(_ref) {
20
20
  isDiscovered: discovered
21
21
  };
22
22
  return /*#__PURE__*/React.createElement(Pulse, pulseProps, children);
23
- };
24
- export default Pulse;
23
+ };
@@ -11,6 +11,7 @@ import React from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import rafSchedule from 'raf-schd';
13
13
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
14
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
15
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
16
  import { Card as SmartCard } from '@atlaskit/smart-card';
16
17
  import { registerCard } from '../pm-plugins/actions';
@@ -113,6 +114,7 @@ _defineProperty(InlineCardComponent, "contextTypes", {
113
114
  var WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
114
115
  var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
115
116
  export function InlineCardNodeView(props) {
117
+ var _view$state$selection, _view$state$selection2;
116
118
  var useAlternativePreloader = props.useAlternativePreloader,
117
119
  node = props.node,
118
120
  view = props.view,
@@ -137,6 +139,7 @@ export function InlineCardNodeView(props) {
137
139
  var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
138
140
  var isPulseEnabled = enableInlineUpgradeFeatures && canBeUpgradedToEmbed;
139
141
  var isOverlayEnabled = enableInlineUpgradeFeatures && (canBeUpgradedToEmbed || canBeUpgradedToBlock);
142
+ var isSelected = view.state.selection instanceof NodeSelection && ((_view$state$selection = view.state.selection) === null || _view$state$selection === void 0 || (_view$state$selection = _view$state$selection.node) === null || _view$state$selection === void 0 ? void 0 : _view$state$selection.type) === view.state.schema.nodes.inlineCard && ((_view$state$selection2 = view.state.selection) === null || _view$state$selection2 === void 0 ? void 0 : _view$state$selection2.from) === getPos();
140
143
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, {
141
144
  node: node,
142
145
  view: view,
@@ -145,6 +148,7 @@ export function InlineCardNodeView(props) {
145
148
  useAlternativePreloader: useAlternativePreloader,
146
149
  isOverlayEnabled: isOverlayEnabled,
147
150
  isPulseEnabled: isPulseEnabled,
148
- pluginInjectionApi: pluginInjectionApi
151
+ pluginInjectionApi: pluginInjectionApi,
152
+ isSelected: isSelected
149
153
  });
150
154
  }
@@ -7,7 +7,7 @@ import rafSchedule from 'raf-schd';
7
7
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
8
8
  import { Card as SmartCard } from '@atlaskit/smart-card';
9
9
  import useLinkUpgradeDiscoverability from '../common/hooks/useLinkUpgradeDiscoverability';
10
- import { LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, ONE_DAY_IN_MILLISECONDS } from '../common/local-storage';
10
+ import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../common/local-storage';
11
11
  import { DiscoveryPulse } from '../common/pulse';
12
12
  import { registerCard } from '../pm-plugins/actions';
13
13
  import InlineCardOverlay from '../ui/InlineCardOverlay';
@@ -28,7 +28,8 @@ var InlineCard = function InlineCard(_ref) {
28
28
  getPos = _ref.getPos,
29
29
  isOverlayEnabled = _ref.isOverlayEnabled,
30
30
  isPulseEnabled = _ref.isPulseEnabled,
31
- pluginInjectionApi = _ref.pluginInjectionApi;
31
+ pluginInjectionApi = _ref.pluginInjectionApi,
32
+ isSelected = _ref.isSelected;
32
33
  var _node$attrs = node.attrs,
33
34
  url = _node$attrs.url,
34
35
  data = _node$attrs.data;
@@ -55,7 +56,14 @@ var InlineCard = function InlineCard(_ref) {
55
56
  isPulseEnabled: isPulseEnabled
56
57
  }),
57
58
  shouldShowLinkPulse = _useLinkUpgradeDiscov.shouldShowLinkPulse,
59
+ shouldShowToolbarPulse = _useLinkUpgradeDiscov.shouldShowToolbarPulse,
58
60
  shouldShowLinkOverlay = _useLinkUpgradeDiscov.shouldShowLinkOverlay;
61
+
62
+ // If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
63
+ // we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
64
+ if (isSelected && shouldShowToolbarPulse && !isLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
65
+ markLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
66
+ }
59
67
  var scrollContainer = useMemo(function () {
60
68
  return findOverflowScrollParent(view.dom) || undefined;
61
69
  }, [view.dom]);
@@ -44,7 +44,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
44
44
  editorAnalyticsApi = _this$props.editorAnalyticsApi,
45
45
  cardActions = _this$props.cardActions,
46
46
  _this$props$showUpgra = _this$props.showUpgradeDiscoverability,
47
- showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? false : _this$props$showUpgra;
47
+ showUpgradeDiscoverability = _this$props$showUpgra === void 0 ? true : _this$props$showUpgra;
48
48
  var preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
49
49
  var defaultCommand = function defaultCommand() {
50
50
  return false;
@@ -105,7 +105,7 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
105
105
  options.push(embedOption);
106
106
  }
107
107
  var LinkToolbarButtons = /*#__PURE__*/React.createElement(LinkToolbarButtonGroup, {
108
- key: LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR,
108
+ key: "link-toolbar-button-group",
109
109
  options: options.map(function (option) {
110
110
  return getButtonGroupOption(intl, dispatchCommand, _objectSpread(_objectSpread({}, option), {}, {
111
111
  onClick: commandWithMetadata(option.onClick, {
@@ -117,13 +117,9 @@ export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
117
117
  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 : '';
118
118
  var embedEnabled = embedOption ? !embedOption.disabled : false;
119
119
  if (shouldRenderToolbarPulse(embedEnabled, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : '', status !== null && status !== void 0 ? status : '', showUpgradeDiscoverability)) {
120
- return (
121
- /*#__PURE__*/
122
- // This div is necessary because the toolbar uses :first-child to add margins and can't add margins to the pulse element
123
- React.createElement("div", null, /*#__PURE__*/React.createElement(DiscoveryPulse, {
124
- localStorageKey: "toolbar-upgrade-pulse"
125
- }, LinkToolbarButtons))
126
- );
120
+ return /*#__PURE__*/React.createElement(DiscoveryPulse, {
121
+ localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR
122
+ }, LinkToolbarButtons);
127
123
  }
128
124
  return LinkToolbarButtons;
129
125
  });
@@ -1,7 +1,7 @@
1
1
  export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
2
  export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
3
  export declare const LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = "smart-link-upgrade-pulse";
4
- export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "link-toolbar-button-group";
4
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "toolbar-upgrade-pulse";
5
5
  export declare const ONE_DAY_IN_MILLISECONDS = 86400000;
6
6
  export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
7
7
  export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { Pulse } from '@atlaskit/linking-common';
3
2
  export type PulseDiscoveryMode = 'start' | 'iteration';
4
3
  export interface PulseProps {
5
4
  /**
@@ -25,4 +24,3 @@ export interface PulseProps {
25
24
  discoveryMode?: PulseDiscoveryMode;
26
25
  }
27
26
  export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, discoveryMode, }: PulseProps) => JSX.Element;
28
- export default Pulse;
@@ -33,6 +33,7 @@ export interface CardProps extends CardNodeViewProps {
33
33
  isOverlayEnabled?: boolean;
34
34
  isPulseEnabled?: boolean;
35
35
  linkPosition?: number;
36
+ isSelected?: boolean;
36
37
  }
37
38
  export interface SmartCardProps extends CardProps {
38
39
  cardContext?: EditorContext<CardContext | undefined>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { SmartCardProps } from './genericCard';
4
- export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, }: SmartCardProps) => jsx.JSX.Element | null>;
4
+ export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => jsx.JSX.Element | null>;
@@ -1,7 +1,7 @@
1
1
  export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
2
  export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
3
  export declare const LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = "smart-link-upgrade-pulse";
4
- export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "link-toolbar-button-group";
4
+ export declare const LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR = "toolbar-upgrade-pulse";
5
5
  export declare const ONE_DAY_IN_MILLISECONDS = 86400000;
6
6
  export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
7
7
  export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { Pulse } from '@atlaskit/linking-common';
3
2
  export type PulseDiscoveryMode = 'start' | 'iteration';
4
3
  export interface PulseProps {
5
4
  /**
@@ -25,4 +24,3 @@ export interface PulseProps {
25
24
  discoveryMode?: PulseDiscoveryMode;
26
25
  }
27
26
  export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, localStorageKeyExpirationInMs, discoveryMode, }: PulseProps) => JSX.Element;
28
- export default Pulse;
@@ -33,6 +33,7 @@ export interface CardProps extends CardNodeViewProps {
33
33
  isOverlayEnabled?: boolean;
34
34
  isPulseEnabled?: boolean;
35
35
  linkPosition?: number;
36
+ isSelected?: boolean;
36
37
  }
37
38
  export interface SmartCardProps extends CardProps {
38
39
  cardContext?: EditorContext<CardContext | undefined>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { jsx } from '@emotion/react';
3
3
  import type { SmartCardProps } from './genericCard';
4
- export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, }: SmartCardProps) => jsx.JSX.Element | null>;
4
+ export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => jsx.JSX.Element | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,10 +31,10 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^32.0.0",
34
+ "@atlaskit/adf-schema": "^33.2.3",
35
35
  "@atlaskit/analytics-next": "^9.1.0",
36
- "@atlaskit/custom-steps": "^0.0.2",
37
- "@atlaskit/editor-common": "^76.20.0",
36
+ "@atlaskit/custom-steps": "^0.0.3",
37
+ "@atlaskit/editor-common": "^76.22.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
39
39
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
40
40
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",