@atlaskit/editor-plugin-card 13.1.20 → 14.0.1

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,25 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 14.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1bd6f56c55358`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bd6f56c55358) -
8
+ Add gated analytics for Smart Link go-to-link actions, including extensionKey, status, and
9
+ statusDetails, with supporting editor/card test updates.
10
+ - Updated dependencies
11
+
12
+ ## 14.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [`6bdbecda5afa7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6bdbecda5afa7) -
17
+ Clean up editor_fix_embed_width_expand
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 13.1.20
4
24
 
5
25
  ### Patch Changes
@@ -28,7 +28,6 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
28
28
  var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
29
29
  var _smartCard = require("@atlaskit/smart-card");
30
30
  var _ssr = require("@atlaskit/smart-card/ssr");
31
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
32
31
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
33
32
  var _actions = require("../pm-plugins/actions");
34
33
  var _ResizableEmbedCard = _interopRequireDefault(require("../ui/ResizableEmbedCard"));
@@ -224,7 +223,7 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
224
223
  }
225
224
  if (domNode instanceof HTMLElement) {
226
225
  var measuredWidth = domNode.offsetWidth;
227
- if (measuredWidth <= 1 && (0, _expValEquals.expValEquals)('editor_fix_embed_width_expand', 'isEnabled', true)) {
226
+ if (measuredWidth <= 1) {
228
227
  _this.scheduleLineLengthRemeasureRaf(view);
229
228
  return originalLineLength;
230
229
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
6
+ exports.showLinkToolbar = exports.showDatasourceModal = exports.setResolvedToolbarAttributes = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
7
7
  var _pluginKey = require("./plugin-key");
8
8
  var cardAction = exports.cardAction = function cardAction(tr, action) {
9
9
  return tr.setMeta(_pluginKey.pluginKey, action);
@@ -73,6 +73,15 @@ var setDatasourceTableRef = exports.setDatasourceTableRef = function setDatasour
73
73
  });
74
74
  };
75
75
  };
76
+ var setResolvedToolbarAttributes = exports.setResolvedToolbarAttributes = function setResolvedToolbarAttributes(url, attributes) {
77
+ return function (tr) {
78
+ return cardAction(tr, {
79
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
80
+ url: url,
81
+ attributes: attributes
82
+ });
83
+ };
84
+ };
76
85
  var setCardLayout = exports.setCardLayout = function setCardLayout(layout) {
77
86
  return function (tr) {
78
87
  return cardAction(tr, {
@@ -82,6 +82,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
82
82
  provider: null,
83
83
  cards: [],
84
84
  datasourceStash: {},
85
+ resolvedToolbarAttributesByUrl: {},
85
86
  showLinkingToolbar: false,
86
87
  smartLinkEvents: undefined,
87
88
  editorAppearance: editorAppearance,
@@ -57,6 +57,11 @@ var setDatasourceTableRef = function setDatasourceTableRef(state, action) {
57
57
  datasourceTableRef: action.datasourceTableRef
58
58
  });
59
59
  };
60
+ var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(state, action) {
61
+ return _objectSpread(_objectSpread({}, state), {}, {
62
+ resolvedToolbarAttributesByUrl: _objectSpread(_objectSpread({}, state.resolvedToolbarAttributesByUrl), {}, (0, _defineProperty2.default)({}, action.url, action.attributes))
63
+ });
64
+ };
60
65
  var setCardLayoutDatasourceTableRef = function setCardLayoutDatasourceTableRef(state, action) {
61
66
  return _objectSpread(_objectSpread({}, state), {}, {
62
67
  datasourceTableRef: action.datasourceTableRef,
@@ -131,6 +136,8 @@ var _default = exports.default = function _default(state, action) {
131
136
  return registerEvents(state, action);
132
137
  case 'SET_DATASOURCE_TABLE_REF':
133
138
  return setDatasourceTableRef(state, action);
139
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
140
+ return setResolvedToolbarAttributes(state, action);
134
141
  case 'SET_CARD_LAYOUT':
135
142
  return setCardLayout(state, action);
136
143
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -68,9 +68,7 @@ var isEmbedSupportedAtPosition = exports.isEmbedSupportedAtPosition = function i
68
68
  var isBlockSupportedAtPosition = exports.isBlockSupportedAtPosition = function isBlockSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
69
69
  return isAppearanceSupportedInParent(currentNodePosition, editorState, _model.Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
70
70
  };
71
- var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store
72
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
73
- ) {
71
+ var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store) {
74
72
  if (!store) {
75
73
  return {};
76
74
  }
@@ -10,32 +10,49 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _useAnalyticsEvents2 = require("@atlaskit/analytics-next/useAnalyticsEvents");
12
12
  var _linkProvider = require("@atlaskit/link-provider");
13
+ var _actions = require("../pm-plugins/actions");
14
+ var _state = require("../pm-plugins/util/state");
13
15
  var _utils = require("../pm-plugins/utils");
14
16
  var _EditorAnalyticsContext = require("./EditorAnalyticsContext");
15
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
18
  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; }
17
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ var areResolvedAttributesEqual = function areResolvedAttributesEqual(current, next) {
21
+ return (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
22
+ };
23
+
18
24
  /**
19
25
  * Handles firing the toolbar viewed event
20
26
  */
21
27
  var ToolbarViewedEventBase = function ToolbarViewedEventBase(_ref) {
22
28
  var url = _ref.url,
23
29
  display = _ref.display,
24
- cardContext = _ref.cardContext;
30
+ cardContext = _ref.cardContext,
31
+ editorView = _ref.editorView;
25
32
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
26
33
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
27
34
  var store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
28
35
  (0, _react.useEffect)(function () {
36
+ var _getPluginState;
37
+ var resolvedAttributes = (0, _utils.getResolvedAttributesFromStore)(url, display, store);
29
38
  createAnalyticsEvent({
30
39
  action: 'viewed',
31
40
  actionSubject: 'inlineDialog',
32
41
  actionSubjectId: 'editLinkToolbar',
33
42
  eventType: 'ui',
34
- attributes: _objectSpread(_objectSpread({}, (0, _utils.getResolvedAttributesFromStore)(url, display, store)), {}, {
43
+ attributes: _objectSpread(_objectSpread({}, resolvedAttributes), {}, {
35
44
  display: display
36
45
  })
37
46
  }).fire('media');
38
- }, [createAnalyticsEvent, display, url, store]);
47
+ if (!editorView) {
48
+ return;
49
+ }
50
+ var currentResolvedAttributes = (_getPluginState = (0, _state.getPluginState)(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
51
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
52
+ return;
53
+ }
54
+ editorView.dispatch((0, _actions.setResolvedToolbarAttributes)(url, resolvedAttributes)(editorView.state.tr));
55
+ }, [createAnalyticsEvent, display, editorView, url, store]);
39
56
  return null;
40
57
  };
41
58
 
@@ -52,6 +69,7 @@ var ToolbarViewedEvent = exports.ToolbarViewedEvent = function ToolbarViewedEven
52
69
  }, url ? /*#__PURE__*/_react.default.createElement(ToolbarViewedEventBase, {
53
70
  url: url,
54
71
  display: display,
55
- cardContext: cardContext
72
+ cardContext: cardContext,
73
+ editorView: editorView
56
74
  }) : null);
57
75
  };
@@ -28,6 +28,7 @@ var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
28
28
  var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
29
29
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
30
30
  var _settings = _interopRequireDefault(require("@atlaskit/icon/core/settings"));
31
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
31
32
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
32
33
  var _doc = require("../pm-plugins/doc");
33
34
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -85,6 +86,30 @@ var visitCardLinkAnalytics = exports.visitCardLinkAnalytics = function visitCard
85
86
  return true;
86
87
  };
87
88
  };
89
+ var fireOpenLinkToolbarAnalytics = function fireOpenLinkToolbarAnalytics(editorAnalyticsApi, inputMethod) {
90
+ var resolvedAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
91
+ return function (state, dispatch) {
92
+ var linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
93
+ if (!linkAnalyticsRecorded) {
94
+ return false;
95
+ }
96
+ if ((0, _expValEquals.expValEquals)('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
97
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.fireAnalyticsEvent({
98
+ action: _analytics.ACTION.CLICKED,
99
+ actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
100
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.OPEN_LINK,
101
+ attributes: {
102
+ displayCategory: resolvedAttributes.displayCategory,
103
+ extensionKey: resolvedAttributes.extensionKey,
104
+ status: resolvedAttributes.status,
105
+ statusDetails: resolvedAttributes.statusDetails
106
+ },
107
+ eventType: _analytics.EVENT_TYPE.UI
108
+ });
109
+ }
110
+ return true;
111
+ };
112
+ };
88
113
  var openLinkSettings = exports.openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
89
114
  return function (state, dispatch) {
90
115
  if (!(state.selection instanceof _state2.NodeSelection)) {
@@ -261,7 +286,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
261
286
  } else if (shouldRenderDatasourceToolbar) {
262
287
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
263
288
  } else {
264
- var _pluginInjectionApi$c;
289
+ var _pluginInjectionApi$c, _pluginState$resolved;
265
290
  var inlineCard = state.schema.nodes.inlineCard;
266
291
  var editItems = cardOptions.allowDatasource ? [{
267
292
  type: 'custom',
@@ -343,7 +368,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
343
368
  });
344
369
  }
345
370
  }] : [];
346
- var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [{
371
+ var resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
372
+ var openLinkToolbarItem = {
347
373
  id: 'editor.link.openLink',
348
374
  type: 'button',
349
375
  icon: _linkExternal.default,
@@ -351,10 +377,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
351
377
  metadata: metadata,
352
378
  className: 'hyperlink-open-link',
353
379
  title: intl.formatMessage(_messages.linkMessages.openLink),
354
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
380
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
355
381
  href: url,
356
382
  target: '_blank'
357
- }, {
383
+ };
384
+ var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [openLinkToolbarItem, {
358
385
  type: 'separator'
359
386
  }], (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
360
387
  type: 'copy-button',
@@ -383,18 +410,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
383
410
  }]) : [].concat(editButtonItems, (0, _toConsumableArray2.default)([].concat((0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
384
411
  type: 'separator',
385
412
  fullHeight: true
386
- }])), openPreviewPanelItems, [{
387
- id: 'editor.link.openLink',
388
- type: 'button',
389
- icon: _linkExternal.default,
390
- iconFallback: _linkExternal.default,
391
- metadata: metadata,
392
- className: 'hyperlink-open-link',
393
- title: intl.formatMessage(_messages.linkMessages.openLink),
394
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
395
- href: url,
396
- target: '_blank'
397
- }], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
413
+ }])), openPreviewPanelItems, [openLinkToolbarItem], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
398
414
  type: 'separator',
399
415
  fullHeight: true
400
416
  }, commentItems[0]] : commentItems));
@@ -534,8 +550,9 @@ var getSettingsButton = exports.getSettingsButton = function getSettingsButton(i
534
550
  };
535
551
  };
536
552
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) {
537
- var _node$attrs2;
553
+ var _node$attrs2, _node$attrs3;
538
554
  var toolbarItems = [];
555
+ toolbarItems.push.apply(toolbarItems, (0, _toConsumableArray2.default)(getToolbarViewedItem(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url')));
539
556
  var areAllNewToolbarFlagsDisabled = !(0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
540
557
  var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
541
558
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -607,6 +624,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
607
624
  }
608
625
  }
609
626
  var openLinkInputMethod = _analytics.INPUT_METHOD.FLOATING_TB;
627
+ var pluginState = _pluginKey.pluginKey.getState(state);
610
628
  toolbarItems.push({
611
629
  type: 'custom',
612
630
  fallback: [],
@@ -625,7 +643,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
625
643
  });
626
644
  }
627
645
  });
628
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
646
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
647
+ var _pluginState$resolved2;
629
648
  toolbarItems.push({
630
649
  id: 'editor.link.openLink',
631
650
  type: 'button',
@@ -634,7 +653,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
634
653
  metadata: metadata,
635
654
  className: 'hyperlink-open-link',
636
655
  title: intl.formatMessage(_messages.linkMessages.openLink),
637
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
656
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
638
657
  href: node.attrs.url,
639
658
  target: '_blank'
640
659
  });
@@ -16,7 +16,6 @@ import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
17
17
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
18
18
  import { CardSSR } from '@atlaskit/smart-card/ssr';
19
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
19
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
20
  import { registerCard, removeCard } from '../pm-plugins/actions';
22
21
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
@@ -216,7 +215,7 @@ export class EmbedCardComponent extends React.PureComponent {
216
215
  }
217
216
  if (domNode instanceof HTMLElement) {
218
217
  const measuredWidth = domNode.offsetWidth;
219
- if (measuredWidth <= 1 && expValEquals('editor_fix_embed_width_expand', 'isEnabled', true)) {
218
+ if (measuredWidth <= 1) {
220
219
  this.scheduleLineLengthRemeasureRaf(view);
221
220
  return originalLineLength;
222
221
  }
@@ -35,6 +35,11 @@ export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr,
35
35
  type: 'SET_DATASOURCE_TABLE_REF',
36
36
  datasourceTableRef
37
37
  });
38
+ export const setResolvedToolbarAttributes = (url, attributes) => tr => cardAction(tr, {
39
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
40
+ url,
41
+ attributes
42
+ });
38
43
  export const setCardLayout = layout => tr => cardAction(tr, {
39
44
  type: 'SET_CARD_LAYOUT',
40
45
  layout
@@ -72,6 +72,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
72
72
  provider: null,
73
73
  cards: [],
74
74
  datasourceStash: {},
75
+ resolvedToolbarAttributesByUrl: {},
75
76
  showLinkingToolbar: false,
76
77
  smartLinkEvents: undefined,
77
78
  editorAppearance,
@@ -46,6 +46,15 @@ const setDatasourceTableRef = (state, action) => {
46
46
  datasourceTableRef: action.datasourceTableRef
47
47
  };
48
48
  };
49
+ const setResolvedToolbarAttributes = (state, action) => {
50
+ return {
51
+ ...state,
52
+ resolvedToolbarAttributesByUrl: {
53
+ ...state.resolvedToolbarAttributesByUrl,
54
+ [action.url]: action.attributes
55
+ }
56
+ };
57
+ };
49
58
  const setCardLayoutDatasourceTableRef = (state, action) => {
50
59
  return {
51
60
  ...state,
@@ -132,6 +141,8 @@ export default ((state, action) => {
132
141
  return registerEvents(state, action);
133
142
  case 'SET_DATASOURCE_TABLE_REF':
134
143
  return setDatasourceTableRef(state, action);
144
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
145
+ return setResolvedToolbarAttributes(state, action);
135
146
  case 'SET_CARD_LAYOUT':
136
147
  return setCardLayout(state, action);
137
148
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -54,9 +54,7 @@ const isAppearanceSupportedInParent = (currentNodePosition, editorState, fragmen
54
54
  };
55
55
  export const isEmbedSupportedAtPosition = (currentNodePosition, editorState, currentAppearance) => isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance);
56
56
  export const isBlockSupportedAtPosition = (currentNodePosition, editorState, currentAppearance) => isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
57
- export const getResolvedAttributesFromStore = (url, display, store
58
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
59
- ) => {
57
+ export const getResolvedAttributesFromStore = (url, display, store) => {
60
58
  if (!store) {
61
59
  return {};
62
60
  }
@@ -1,32 +1,47 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
3
3
  import { useSmartLinkContext } from '@atlaskit/link-provider';
4
+ import { setResolvedToolbarAttributes } from '../pm-plugins/actions';
5
+ import { getPluginState } from '../pm-plugins/util/state';
4
6
  import { getResolvedAttributesFromStore } from '../pm-plugins/utils';
5
7
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
8
+ const areResolvedAttributesEqual = (current, next) => (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
9
+
6
10
  /**
7
11
  * Handles firing the toolbar viewed event
8
12
  */
9
13
  const ToolbarViewedEventBase = ({
10
14
  url,
11
15
  display,
12
- cardContext
16
+ cardContext,
17
+ editorView
13
18
  }) => {
14
19
  const {
15
20
  createAnalyticsEvent
16
21
  } = useAnalyticsEvents();
17
22
  const store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
18
23
  useEffect(() => {
24
+ var _getPluginState;
25
+ const resolvedAttributes = getResolvedAttributesFromStore(url, display, store);
19
26
  createAnalyticsEvent({
20
27
  action: 'viewed',
21
28
  actionSubject: 'inlineDialog',
22
29
  actionSubjectId: 'editLinkToolbar',
23
30
  eventType: 'ui',
24
31
  attributes: {
25
- ...getResolvedAttributesFromStore(url, display, store),
32
+ ...resolvedAttributes,
26
33
  display
27
34
  }
28
35
  }).fire('media');
29
- }, [createAnalyticsEvent, display, url, store]);
36
+ if (!editorView) {
37
+ return;
38
+ }
39
+ const currentResolvedAttributes = (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
40
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
41
+ return;
42
+ }
43
+ editorView.dispatch(setResolvedToolbarAttributes(url, resolvedAttributes)(editorView.state.tr));
44
+ }, [createAnalyticsEvent, display, editorView, url, store]);
30
45
  return null;
31
46
  };
32
47
 
@@ -44,6 +59,7 @@ export const ToolbarViewedEvent = ({
44
59
  }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
45
60
  url: url,
46
61
  display: display,
47
- cardContext: cardContext
62
+ cardContext: cardContext,
63
+ editorView: editorView
48
64
  }) : null);
49
65
  };
@@ -18,6 +18,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
18
18
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
19
19
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
20
20
  import CogIcon from '@atlaskit/icon/core/settings';
21
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { changeSelectedCardToText } from '../pm-plugins/doc';
23
24
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -74,6 +75,27 @@ export const visitCardLinkAnalytics = (editorAnalyticsApi, inputMethod) => (stat
74
75
  }
75
76
  return true;
76
77
  };
78
+ const fireOpenLinkToolbarAnalytics = (editorAnalyticsApi, inputMethod, resolvedAttributes = {}) => (state, dispatch) => {
79
+ const linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
80
+ if (!linkAnalyticsRecorded) {
81
+ return false;
82
+ }
83
+ if (expValEquals('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.fireAnalyticsEvent({
85
+ action: ACTION.CLICKED,
86
+ actionSubject: ACTION_SUBJECT.BUTTON,
87
+ actionSubjectId: ACTION_SUBJECTID.OPEN_LINK,
88
+ attributes: {
89
+ displayCategory: resolvedAttributes.displayCategory,
90
+ extensionKey: resolvedAttributes.extensionKey,
91
+ status: resolvedAttributes.status,
92
+ statusDetails: resolvedAttributes.statusDetails
93
+ },
94
+ eventType: EVENT_TYPE.UI
95
+ });
96
+ }
97
+ return true;
98
+ };
77
99
  export const openLinkSettings = editorAnalyticsApi => (state, dispatch) => {
78
100
  if (!(state.selection instanceof NodeSelection)) {
79
101
  return false;
@@ -253,7 +275,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
253
275
  } else if (shouldRenderDatasourceToolbar) {
254
276
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
255
277
  } else {
256
- var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3;
278
+ var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3, _pluginState$resolved;
257
279
  const {
258
280
  inlineCard
259
281
  } = state.schema.nodes;
@@ -331,7 +353,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
331
353
  areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
332
354
  })
333
355
  }] : [];
334
- const toolbarItems = areAllNewToolbarFlagsDisabled ? [...editItems, ...commentItems, ...openPreviewPanelItems, {
356
+ const resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
357
+ const openLinkToolbarItem = {
335
358
  id: 'editor.link.openLink',
336
359
  type: 'button',
337
360
  icon: LinkExternalIcon,
@@ -339,10 +362,11 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
339
362
  metadata: metadata,
340
363
  className: 'hyperlink-open-link',
341
364
  title: intl.formatMessage(linkMessages.openLink),
342
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
365
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
343
366
  href: url,
344
367
  target: '_blank'
345
- }, {
368
+ };
369
+ const toolbarItems = areAllNewToolbarFlagsDisabled ? [...editItems, ...commentItems, ...openPreviewPanelItems, openLinkToolbarItem, {
346
370
  type: 'separator'
347
371
  }, ...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled), {
348
372
  type: 'copy-button',
@@ -371,18 +395,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
371
395
  }] : [...editButtonItems, ...[...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled), {
372
396
  type: 'separator',
373
397
  fullHeight: true
374
- }], ...openPreviewPanelItems, {
375
- id: 'editor.link.openLink',
376
- type: 'button',
377
- icon: LinkExternalIcon,
378
- iconFallback: LinkExternalIcon,
379
- metadata: metadata,
380
- className: 'hyperlink-open-link',
381
- title: intl.formatMessage(linkMessages.openLink),
382
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
383
- href: url,
384
- target: '_blank'
385
- }, ...(commentItems.length > 1 ? [{
398
+ }], ...openPreviewPanelItems, openLinkToolbarItem, ...(commentItems.length > 1 ? [{
386
399
  type: 'separator',
387
400
  fullHeight: true
388
401
  }, commentItems[0]] : commentItems)];
@@ -519,8 +532,9 @@ export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink)
519
532
  };
520
533
  };
521
534
  const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) => {
522
- var _node$attrs2;
535
+ var _node$attrs2, _node$attrs3;
523
536
  const toolbarItems = [];
537
+ toolbarItems.push(...getToolbarViewedItem(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'));
524
538
  const areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
525
539
  const canShowAppearanceSwitch = () => {
526
540
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -594,6 +608,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
594
608
  }
595
609
  }
596
610
  const openLinkInputMethod = INPUT_METHOD.FLOATING_TB;
611
+ const pluginState = pluginKey.getState(state);
597
612
  toolbarItems.push({
598
613
  type: 'custom',
599
614
  fallback: [],
@@ -610,7 +625,8 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
610
625
  areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
611
626
  })
612
627
  });
613
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
628
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
629
+ var _pluginState$resolved2;
614
630
  toolbarItems.push({
615
631
  id: 'editor.link.openLink',
616
632
  type: 'button',
@@ -619,7 +635,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
619
635
  metadata: metadata,
620
636
  className: 'hyperlink-open-link',
621
637
  title: intl.formatMessage(linkMessages.openLink),
622
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
638
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
623
639
  href: node.attrs.url,
624
640
  target: '_blank'
625
641
  });
@@ -27,7 +27,6 @@ import { fg } from '@atlaskit/platform-feature-flags';
27
27
  import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
28
28
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
29
29
  import { CardSSR } from '@atlaskit/smart-card/ssr';
30
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
31
30
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
32
31
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
33
32
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
@@ -218,7 +217,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
218
217
  }
219
218
  if (domNode instanceof HTMLElement) {
220
219
  var measuredWidth = domNode.offsetWidth;
221
- if (measuredWidth <= 1 && expValEquals('editor_fix_embed_width_expand', 'isEnabled', true)) {
220
+ if (measuredWidth <= 1) {
222
221
  _this.scheduleLineLengthRemeasureRaf(view);
223
222
  return originalLineLength;
224
223
  }
@@ -67,6 +67,15 @@ export var setDatasourceTableRef = function setDatasourceTableRef(datasourceTabl
67
67
  });
68
68
  };
69
69
  };
70
+ export var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(url, attributes) {
71
+ return function (tr) {
72
+ return cardAction(tr, {
73
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
74
+ url: url,
75
+ attributes: attributes
76
+ });
77
+ };
78
+ };
70
79
  export var setCardLayout = function setCardLayout(layout) {
71
80
  return function (tr) {
72
81
  return cardAction(tr, {
@@ -75,6 +75,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
75
75
  provider: null,
76
76
  cards: [],
77
77
  datasourceStash: {},
78
+ resolvedToolbarAttributesByUrl: {},
78
79
  showLinkingToolbar: false,
79
80
  smartLinkEvents: undefined,
80
81
  editorAppearance: editorAppearance,
@@ -50,6 +50,11 @@ var setDatasourceTableRef = function setDatasourceTableRef(state, action) {
50
50
  datasourceTableRef: action.datasourceTableRef
51
51
  });
52
52
  };
53
+ var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(state, action) {
54
+ return _objectSpread(_objectSpread({}, state), {}, {
55
+ resolvedToolbarAttributesByUrl: _objectSpread(_objectSpread({}, state.resolvedToolbarAttributesByUrl), {}, _defineProperty({}, action.url, action.attributes))
56
+ });
57
+ };
53
58
  var setCardLayoutDatasourceTableRef = function setCardLayoutDatasourceTableRef(state, action) {
54
59
  return _objectSpread(_objectSpread({}, state), {}, {
55
60
  datasourceTableRef: action.datasourceTableRef,
@@ -124,6 +129,8 @@ export default (function (state, action) {
124
129
  return registerEvents(state, action);
125
130
  case 'SET_DATASOURCE_TABLE_REF':
126
131
  return setDatasourceTableRef(state, action);
132
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
133
+ return setResolvedToolbarAttributes(state, action);
127
134
  case 'SET_CARD_LAYOUT':
128
135
  return setCardLayout(state, action);
129
136
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -61,9 +61,7 @@ export var isEmbedSupportedAtPosition = function isEmbedSupportedAtPosition(curr
61
61
  export var isBlockSupportedAtPosition = function isBlockSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
62
62
  return isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
63
63
  };
64
- export var getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store
65
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
66
- ) {
64
+ export var getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store) {
67
65
  if (!store) {
68
66
  return {};
69
67
  }
@@ -4,29 +4,46 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React, { useEffect } from 'react';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
6
6
  import { useSmartLinkContext } from '@atlaskit/link-provider';
7
+ import { setResolvedToolbarAttributes } from '../pm-plugins/actions';
8
+ import { getPluginState } from '../pm-plugins/util/state';
7
9
  import { getResolvedAttributesFromStore } from '../pm-plugins/utils';
8
10
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
11
+ var areResolvedAttributesEqual = function areResolvedAttributesEqual(current, next) {
12
+ return (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
13
+ };
14
+
9
15
  /**
10
16
  * Handles firing the toolbar viewed event
11
17
  */
12
18
  var ToolbarViewedEventBase = function ToolbarViewedEventBase(_ref) {
13
19
  var url = _ref.url,
14
20
  display = _ref.display,
15
- cardContext = _ref.cardContext;
21
+ cardContext = _ref.cardContext,
22
+ editorView = _ref.editorView;
16
23
  var _useAnalyticsEvents = useAnalyticsEvents(),
17
24
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
18
25
  var store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
19
26
  useEffect(function () {
27
+ var _getPluginState;
28
+ var resolvedAttributes = getResolvedAttributesFromStore(url, display, store);
20
29
  createAnalyticsEvent({
21
30
  action: 'viewed',
22
31
  actionSubject: 'inlineDialog',
23
32
  actionSubjectId: 'editLinkToolbar',
24
33
  eventType: 'ui',
25
- attributes: _objectSpread(_objectSpread({}, getResolvedAttributesFromStore(url, display, store)), {}, {
34
+ attributes: _objectSpread(_objectSpread({}, resolvedAttributes), {}, {
26
35
  display: display
27
36
  })
28
37
  }).fire('media');
29
- }, [createAnalyticsEvent, display, url, store]);
38
+ if (!editorView) {
39
+ return;
40
+ }
41
+ var currentResolvedAttributes = (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
42
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
43
+ return;
44
+ }
45
+ editorView.dispatch(setResolvedToolbarAttributes(url, resolvedAttributes)(editorView.state.tr));
46
+ }, [createAnalyticsEvent, display, editorView, url, store]);
30
47
  return null;
31
48
  };
32
49
 
@@ -43,6 +60,7 @@ export var ToolbarViewedEvent = function ToolbarViewedEvent(_ref2) {
43
60
  }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
44
61
  url: url,
45
62
  display: display,
46
- cardContext: cardContext
63
+ cardContext: cardContext,
64
+ editorView: editorView
47
65
  }) : null);
48
66
  };
@@ -22,6 +22,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
22
22
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
23
23
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
24
24
  import CogIcon from '@atlaskit/icon/core/settings';
25
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
25
26
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
26
27
  import { changeSelectedCardToText } from '../pm-plugins/doc';
27
28
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -76,6 +77,30 @@ export var visitCardLinkAnalytics = function visitCardLinkAnalytics(editorAnalyt
76
77
  return true;
77
78
  };
78
79
  };
80
+ var fireOpenLinkToolbarAnalytics = function fireOpenLinkToolbarAnalytics(editorAnalyticsApi, inputMethod) {
81
+ var resolvedAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
82
+ return function (state, dispatch) {
83
+ var linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
84
+ if (!linkAnalyticsRecorded) {
85
+ return false;
86
+ }
87
+ if (expValEquals('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
88
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.fireAnalyticsEvent({
89
+ action: ACTION.CLICKED,
90
+ actionSubject: ACTION_SUBJECT.BUTTON,
91
+ actionSubjectId: ACTION_SUBJECTID.OPEN_LINK,
92
+ attributes: {
93
+ displayCategory: resolvedAttributes.displayCategory,
94
+ extensionKey: resolvedAttributes.extensionKey,
95
+ status: resolvedAttributes.status,
96
+ statusDetails: resolvedAttributes.statusDetails
97
+ },
98
+ eventType: EVENT_TYPE.UI
99
+ });
100
+ }
101
+ return true;
102
+ };
103
+ };
79
104
  export var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
80
105
  return function (state, dispatch) {
81
106
  if (!(state.selection instanceof NodeSelection)) {
@@ -252,7 +277,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
252
277
  } else if (shouldRenderDatasourceToolbar) {
253
278
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
254
279
  } else {
255
- var _pluginInjectionApi$c;
280
+ var _pluginInjectionApi$c, _pluginState$resolved;
256
281
  var inlineCard = state.schema.nodes.inlineCard;
257
282
  var editItems = cardOptions.allowDatasource ? [{
258
283
  type: 'custom',
@@ -334,7 +359,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
334
359
  });
335
360
  }
336
361
  }] : [];
337
- var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [{
362
+ var resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
363
+ var openLinkToolbarItem = {
338
364
  id: 'editor.link.openLink',
339
365
  type: 'button',
340
366
  icon: LinkExternalIcon,
@@ -342,10 +368,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
342
368
  metadata: metadata,
343
369
  className: 'hyperlink-open-link',
344
370
  title: intl.formatMessage(linkMessages.openLink),
345
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
371
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
346
372
  href: url,
347
373
  target: '_blank'
348
- }, {
374
+ };
375
+ var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [openLinkToolbarItem, {
349
376
  type: 'separator'
350
377
  }], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
351
378
  type: 'copy-button',
@@ -374,18 +401,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
374
401
  }]) : [].concat(editButtonItems, _toConsumableArray([].concat(_toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
375
402
  type: 'separator',
376
403
  fullHeight: true
377
- }])), openPreviewPanelItems, [{
378
- id: 'editor.link.openLink',
379
- type: 'button',
380
- icon: LinkExternalIcon,
381
- iconFallback: LinkExternalIcon,
382
- metadata: metadata,
383
- className: 'hyperlink-open-link',
384
- title: intl.formatMessage(linkMessages.openLink),
385
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
386
- href: url,
387
- target: '_blank'
388
- }], _toConsumableArray(commentItems.length > 1 ? [{
404
+ }])), openPreviewPanelItems, [openLinkToolbarItem], _toConsumableArray(commentItems.length > 1 ? [{
389
405
  type: 'separator',
390
406
  fullHeight: true
391
407
  }, commentItems[0]] : commentItems));
@@ -525,8 +541,9 @@ export var getSettingsButton = function getSettingsButton(intl, editorAnalyticsA
525
541
  };
526
542
  };
527
543
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) {
528
- var _node$attrs2;
544
+ var _node$attrs2, _node$attrs3;
529
545
  var toolbarItems = [];
546
+ toolbarItems.push.apply(toolbarItems, _toConsumableArray(getToolbarViewedItem(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url')));
530
547
  var areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
531
548
  var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
532
549
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -598,6 +615,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
598
615
  }
599
616
  }
600
617
  var openLinkInputMethod = INPUT_METHOD.FLOATING_TB;
618
+ var pluginState = pluginKey.getState(state);
601
619
  toolbarItems.push({
602
620
  type: 'custom',
603
621
  fallback: [],
@@ -616,7 +634,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
616
634
  });
617
635
  }
618
636
  });
619
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
637
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
638
+ var _pluginState$resolved2;
620
639
  toolbarItems.push({
621
640
  id: 'editor.link.openLink',
622
641
  type: 'button',
@@ -625,7 +644,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
625
644
  metadata: metadata,
626
645
  className: 'hyperlink-open-link',
627
646
  title: intl.formatMessage(linkMessages.openLink),
628
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
647
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
629
648
  href: node.attrs.url,
630
649
  target: '_blank'
631
650
  });
@@ -3,7 +3,7 @@ import type { DatasourceModalType } from '@atlaskit/editor-common/types';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
5
5
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
6
- import type { CardInfo, CardPluginAction, Request } from '../types';
6
+ import type { CardInfo, CardPluginAction, Request, ToolbarResolvedAttributes } from '../types';
7
7
  import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
8
8
  export declare const cardAction: (tr: Transaction, action: CardPluginAction) => Transaction;
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
@@ -14,6 +14,7 @@ export declare const registerRemoveOverlay: (callback: () => void, info?: CardIn
14
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
15
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
16
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
17
+ export declare const setResolvedToolbarAttributes: (url: string, attributes: ToolbarResolvedAttributes) => (tr: Transaction) => Transaction;
17
18
  export declare const setCardLayout: (layout: DatasourceTableLayout) => (tr: Transaction) => Transaction;
18
19
  export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTableRef, }: {
19
20
  datasourceTableRef?: HTMLElement;
@@ -6,7 +6,7 @@ import type { DatasourceModalType, EditorAppearance } from '@atlaskit/editor-com
6
6
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
8
8
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
9
- import type { CardPluginState, Request } from '../../types';
9
+ import type { CardPluginState, Request, ToolbarResolvedAttributes } from '../../types';
10
10
  import type { DatasourceTableLayout } from '../../ui/LayoutButton/types';
11
11
  export declare const getPluginState: (editorState: EditorState) => CardPluginState | undefined;
12
12
  export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState, tr: ReadonlyTransaction) => {
@@ -42,6 +42,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
42
42
  sourceEvent?: UIAnalyticsEvent | null | undefined;
43
43
  url: string;
44
44
  }[];
45
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
45
46
  selectedInlineLinkPosition?: number;
46
47
  showDatasourceModal: boolean;
47
48
  showLinkingToolbar: boolean;
@@ -4,7 +4,7 @@ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- import type { CardInfo, DatasourceNode } from '../types';
7
+ import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
8
8
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
9
9
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
10
10
  export type TitleUrlPair = {
@@ -22,7 +22,7 @@ export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleU
22
22
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
23
23
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
24
24
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
25
- export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => {};
25
+ export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => Partial<ToolbarResolvedAttributes>;
26
26
  export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
27
27
  /**
28
28
  * Typeguard that checks node attributes are datasource node attributes
@@ -20,6 +20,12 @@ export type CardInfo = {
20
20
  title?: string;
21
21
  url?: string;
22
22
  };
23
+ export type ToolbarResolvedAttributes = {
24
+ displayCategory?: 'smartLink' | 'link';
25
+ extensionKey?: string | null;
26
+ status?: string | null;
27
+ statusDetails?: string | null;
28
+ };
23
29
  export type Request = {
24
30
  /**
25
31
  * Analytics action to be used when disaptching
@@ -95,6 +101,7 @@ export type CardPluginState = {
95
101
  provider: CardProvider | null;
96
102
  removeOverlay?: () => void;
97
103
  requests: Request[];
104
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
98
105
  selectedInlineLinkPosition?: number;
99
106
  showDatasourceModal: boolean;
100
107
  showLinkingToolbar: boolean;
@@ -156,6 +163,11 @@ export type SetDatasourceTableRef = {
156
163
  datasourceTableRef?: HTMLElement;
157
164
  type: 'SET_DATASOURCE_TABLE_REF';
158
165
  };
166
+ export type SetResolvedToolbarAttributes = {
167
+ attributes: ToolbarResolvedAttributes;
168
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES';
169
+ url: string;
170
+ };
159
171
  export type SetCardLayout = {
160
172
  layout: DatasourceTableLayout;
161
173
  type: 'SET_CARD_LAYOUT';
@@ -184,5 +196,5 @@ export type RemoveDatasourceStash = {
184
196
  type: 'REMOVE_DATASOURCE_STASH';
185
197
  url: string;
186
198
  };
187
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
199
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetResolvedToolbarAttributes | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
188
200
  export {};
@@ -3,7 +3,7 @@ import type { DatasourceModalType } from '@atlaskit/editor-common/types';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
5
5
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
6
- import type { CardInfo, CardPluginAction, Request } from '../types';
6
+ import type { CardInfo, CardPluginAction, Request, ToolbarResolvedAttributes } from '../types';
7
7
  import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
8
8
  export declare const cardAction: (tr: Transaction, action: CardPluginAction) => Transaction;
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
@@ -14,6 +14,7 @@ export declare const registerRemoveOverlay: (callback: () => void, info?: CardIn
14
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
15
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
16
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
17
+ export declare const setResolvedToolbarAttributes: (url: string, attributes: ToolbarResolvedAttributes) => (tr: Transaction) => Transaction;
17
18
  export declare const setCardLayout: (layout: DatasourceTableLayout) => (tr: Transaction) => Transaction;
18
19
  export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTableRef, }: {
19
20
  datasourceTableRef?: HTMLElement;
@@ -6,7 +6,7 @@ import type { DatasourceModalType, EditorAppearance } from '@atlaskit/editor-com
6
6
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
8
8
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
9
- import type { CardPluginState, Request } from '../../types';
9
+ import type { CardPluginState, Request, ToolbarResolvedAttributes } from '../../types';
10
10
  import type { DatasourceTableLayout } from '../../ui/LayoutButton/types';
11
11
  export declare const getPluginState: (editorState: EditorState) => CardPluginState | undefined;
12
12
  export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState, tr: ReadonlyTransaction) => {
@@ -42,6 +42,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
42
42
  sourceEvent?: UIAnalyticsEvent | null | undefined;
43
43
  url: string;
44
44
  }[];
45
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
45
46
  selectedInlineLinkPosition?: number;
46
47
  showDatasourceModal: boolean;
47
48
  showLinkingToolbar: boolean;
@@ -4,7 +4,7 @@ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- import type { CardInfo, DatasourceNode } from '../types';
7
+ import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
8
8
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
9
9
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
10
10
  export type TitleUrlPair = {
@@ -22,7 +22,7 @@ export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleU
22
22
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
23
23
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
24
24
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
25
- export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => {};
25
+ export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => Partial<ToolbarResolvedAttributes>;
26
26
  export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
27
27
  /**
28
28
  * Typeguard that checks node attributes are datasource node attributes
@@ -20,6 +20,12 @@ export type CardInfo = {
20
20
  title?: string;
21
21
  url?: string;
22
22
  };
23
+ export type ToolbarResolvedAttributes = {
24
+ displayCategory?: 'smartLink' | 'link';
25
+ extensionKey?: string | null;
26
+ status?: string | null;
27
+ statusDetails?: string | null;
28
+ };
23
29
  export type Request = {
24
30
  /**
25
31
  * Analytics action to be used when disaptching
@@ -95,6 +101,7 @@ export type CardPluginState = {
95
101
  provider: CardProvider | null;
96
102
  removeOverlay?: () => void;
97
103
  requests: Request[];
104
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
98
105
  selectedInlineLinkPosition?: number;
99
106
  showDatasourceModal: boolean;
100
107
  showLinkingToolbar: boolean;
@@ -156,6 +163,11 @@ export type SetDatasourceTableRef = {
156
163
  datasourceTableRef?: HTMLElement;
157
164
  type: 'SET_DATASOURCE_TABLE_REF';
158
165
  };
166
+ export type SetResolvedToolbarAttributes = {
167
+ attributes: ToolbarResolvedAttributes;
168
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES';
169
+ url: string;
170
+ };
159
171
  export type SetCardLayout = {
160
172
  layout: DatasourceTableLayout;
161
173
  type: 'SET_CARD_LAYOUT';
@@ -184,5 +196,5 @@ export type RemoveDatasourceStash = {
184
196
  type: 'REMOVE_DATASOURCE_STASH';
185
197
  url: string;
186
198
  };
187
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
199
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetResolvedToolbarAttributes | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
188
200
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "13.1.20",
3
+ "version": "14.0.1",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/primitives": "^18.1.0",
62
62
  "@atlaskit/prosemirror-history": "^0.2.0",
63
63
  "@atlaskit/smart-card": "^43.31.0",
64
- "@atlaskit/tmp-editor-statsig": "^55.1.0",
64
+ "@atlaskit/tmp-editor-statsig": "^56.2.0",
65
65
  "@atlaskit/tokens": "^12.0.0",
66
66
  "@babel/runtime": "^7.0.0",
67
67
  "@emotion/react": "^11.7.1",