@atlaskit/editor-plugin-card 5.4.24 → 5.4.26

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,27 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 5.4.26
4
+
5
+ ### Patch Changes
6
+
7
+ - [#149482](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149482)
8
+ [`1f1f73876c3c8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f1f73876c3c8) -
9
+ ED-27860 Add analytics for copy and delete button in floating toolbars
10
+ - Updated dependencies
11
+
12
+ ## 5.4.25
13
+
14
+ ### Patch Changes
15
+
16
+ - [#149184](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149184)
17
+ [`2df75499ccc98`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2df75499ccc98) -
18
+ Cleanup feature gate to fix plugin state on card plugin.
19
+ - [#149530](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149530)
20
+ [`a432884180253`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a432884180253) -
21
+ Sends SmartLink Visited event with additional input methods depending on the way the link was
22
+ opened.
23
+ - Updated dependencies
24
+
3
25
  ## 5.4.24
4
26
 
5
27
  ### Patch Changes
@@ -18,7 +18,6 @@ var _v = _interopRequireDefault(require("uuid/v4"));
18
18
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
19
19
  var _ui = require("@atlaskit/editor-common/ui");
20
20
  var _utils = require("@atlaskit/editor-common/utils");
21
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
21
  var _smartCard = require("@atlaskit/smart-card");
23
22
  var _datasource = require("../nodeviews/datasource");
24
23
  var _actions = require("../pm-plugins/actions");
@@ -186,9 +185,7 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
186
185
  value: function destroy() {
187
186
  var _this$unsubscribe;
188
187
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
189
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
190
- this.removeCard();
191
- }
188
+ this.removeCard();
192
189
  }
193
190
  }, {
194
191
  key: "removeCard",
@@ -22,7 +22,6 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
22
22
  var _ui = require("@atlaskit/editor-common/ui");
23
23
  var _utils = require("@atlaskit/editor-common/utils");
24
24
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
25
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
26
25
  var _smartCard = require("@atlaskit/smart-card");
27
26
  var _actions = require("../pm-plugins/actions");
28
27
  var _ResizableEmbedCard = _interopRequireDefault(require("../ui/ResizableEmbedCard"));
@@ -401,9 +400,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
401
400
  value: function destroy() {
402
401
  var _this$unsubscribe;
403
402
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
404
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
405
- this.removeCard();
406
- }
403
+ this.removeCard();
407
404
  }
408
405
  }, {
409
406
  key: "removeCard",
@@ -48,13 +48,11 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
48
48
  (0, _react.useEffect)(function () {
49
49
  var id = refId.current;
50
50
  return function () {
51
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
52
- var tr = view.state.tr;
53
- (0, _actions.removeCard)({
54
- id: id
55
- })(tr);
56
- view.dispatch(tr);
57
- }
51
+ var tr = view.state.tr;
52
+ (0, _actions.removeCard)({
53
+ id: id
54
+ })(tr);
55
+ view.dispatch(tr);
58
56
  };
59
57
  }, [getPos, view]);
60
58
  var scrollContainer = (0, _react.useMemo)(
@@ -19,7 +19,7 @@ var _inlineCard = require("./inlineCard");
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0, _react.memo)(function (_ref) {
22
- var _pluginInjectionApi$c;
22
+ var _pluginInjectionApi$c, _pluginInjectionApi$a;
23
23
  var node = _ref.node,
24
24
  cardContext = _ref.cardContext,
25
25
  actionOptions = _ref.actionOptions,
@@ -46,18 +46,14 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
46
46
  isResolvedViewRendered = _useState6[0],
47
47
  setIsResolvedViewRendered = _useState6[1];
48
48
  var editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
49
+ var _ref2 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
50
+ editorAnalyticsApi = _ref2.actions;
49
51
  var onResolve = (0, _react.useCallback)(function (tr, title) {
50
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
51
- var metadata = tr.getMeta(_pluginKey.pluginKey);
52
- if (metadata && metadata.type === 'REGISTER') {
53
- (0, _actions.registerRemoveOverlay)(function () {
54
- return setIsInserted(false);
55
- }, metadata.info)(tr);
56
- } else {
57
- (0, _actions.registerRemoveOverlay)(function () {
58
- return setIsInserted(false);
59
- })(tr);
60
- }
52
+ var metadata = tr.getMeta(_pluginKey.pluginKey);
53
+ if (metadata && metadata.type === 'REGISTER') {
54
+ (0, _actions.registerRemoveOverlay)(function () {
55
+ return setIsInserted(false);
56
+ }, metadata.info)(tr);
61
57
  } else {
62
58
  (0, _actions.registerRemoveOverlay)(function () {
63
59
  return setIsInserted(false);
@@ -83,7 +79,9 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
83
79
  return /*#__PURE__*/_react.default.createElement(_OpenButtonOverlay.default, {
84
80
  isVisible: isResolvedViewRendered,
85
81
  url: node.attrs.url,
86
- editorAppearance: editorAppearance
82
+ editorAppearance: editorAppearance,
83
+ editorAnalyticsApi: editorAnalyticsApi,
84
+ view: view
87
85
  }, /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
88
86
  node: node,
89
87
  view: view,
@@ -96,7 +94,7 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
96
94
  isHovered: isHovered,
97
95
  isPageSSRed: isPageSSRed
98
96
  }));
99
- }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed]);
97
+ }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, editorAnalyticsApi]);
100
98
  var innerCardOriginal = (0, _react.useMemo)(function () {
101
99
  return /*#__PURE__*/_react.default.createElement(_inlineCard.InlineCard, {
102
100
  node: node,
@@ -7,23 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
10
  var _react = _interopRequireWildcard(require("react"));
12
11
  var _react2 = require("@emotion/react");
12
+ var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
14
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
15
  var _primitives = require("@atlaskit/primitives");
16
- var _excluded = ["children", "isVisible", "url", "editorAppearance"];
16
+ var _toolbar = require("../toolbar");
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
19
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
18
20
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
19
21
  /**
20
22
  * @jsxRuntime classic
21
23
  * @jsx jsx
22
24
  */
25
+
23
26
  // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
27
+
24
28
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
+
27
30
  var containerStyles = (0, _react2.css)({
28
31
  position: 'relative'
29
32
  });
@@ -75,7 +78,8 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
75
78
  isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
76
79
  url = _ref.url,
77
80
  editorAppearance = _ref.editorAppearance,
78
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
81
+ editorAnalyticsApi = _ref.editorAnalyticsApi,
82
+ view = _ref.view;
79
83
  // TODO: ED-26961 - add translation
80
84
  var label = 'Open';
81
85
  var containerRef = (0, _react.useRef)(null);
@@ -90,10 +94,6 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
90
94
  isHovered = _useState4[0],
91
95
  setHovered = _useState4[1];
92
96
  var openTextWidthRef = (0, _react.useRef)(DEFAULT_OPEN_TEXT_WIDTH);
93
- var handleDoubleClick = function handleDoubleClick() {
94
- // Double click opens the link in a new tab
95
- window.open(url, '_blank');
96
- };
97
97
  (0, _react.useLayoutEffect)(function () {
98
98
  var hiddenText = hiddenTextRef.current;
99
99
  if (!hiddenText) {
@@ -130,6 +130,22 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
130
130
  var handleOverlayChange = function handleOverlayChange(isHovered) {
131
131
  setHovered(isHovered);
132
132
  };
133
+ var sendVisitLinkAnalytics = function sendVisitLinkAnalytics(inputMethod) {
134
+ if (editorAnalyticsApi && view) {
135
+ (0, _toolbar.visitCardLink)(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
136
+ }
137
+ };
138
+ var handleDoubleClick = function handleDoubleClick() {
139
+ if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics')) {
140
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.DOUBLE_CLICK);
141
+ }
142
+
143
+ // Double click opens the link in a new tab
144
+ window.open(url, '_blank');
145
+ };
146
+ var handleClick = function handleClick() {
147
+ sendVisitLinkAnalytics(_analytics.INPUT_METHOD.BUTTON);
148
+ };
133
149
  return (
134
150
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
135
151
  (0, _react2.jsx)("span", {
@@ -156,7 +172,8 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
156
172
  target: "_blank",
157
173
  style: {
158
174
  paddingBlock: editorAppearance === 'comment' && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_6') ? '1px' : "var(--ds-space-025, 2px)"
159
- }
175
+ },
176
+ onClick: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? handleClick : undefined
160
177
  }, (0, _react2.jsx)(_primitives.Box, {
161
178
  xcss: iconWrapperStyles,
162
179
  "data-inlinecard-button-overlay": "icon-wrapper-line-height"
@@ -59,7 +59,7 @@ var removeCard = exports.removeCard = function removeCard(editorAnalyticsApi) {
59
59
  actionSubject: _analytics.ACTION_SUBJECT.SMART_LINK,
60
60
  actionSubjectId: type,
61
61
  attributes: {
62
- inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
62
+ inputMethod: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics_2') ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR,
63
63
  displayMode: type
64
64
  },
65
65
  eventType: _analytics.EVENT_TYPE.TRACK
@@ -75,7 +75,7 @@ var removeCard = exports.removeCard = function removeCard(editorAnalyticsApi) {
75
75
  action: _analytics.ACTION.DELETED
76
76
  });
77
77
  };
78
- var visitCardLink = exports.visitCardLink = function visitCardLink(editorAnalyticsApi) {
78
+ var visitCardLink = exports.visitCardLink = function visitCardLink(editorAnalyticsApi, inputMethod) {
79
79
  return function (state, dispatch) {
80
80
  if (!(state.selection instanceof _state.NodeSelection)) {
81
81
  return false;
@@ -91,7 +91,7 @@ var visitCardLink = exports.visitCardLink = function visitCardLink(editorAnalyti
91
91
  }
92
92
  if (dispatch) {
93
93
  var tr = state.tr;
94
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.buildVisitedLinkPayload)(type.name))(tr);
94
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.buildVisitedNonHyperLinkPayload)(type.name, inputMethod))(tr);
95
95
  dispatch(tr);
96
96
  }
97
97
  return true;
@@ -305,6 +305,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
305
305
  }, {
306
306
  type: 'separator'
307
307
  }] : [];
308
+ var openLinkInputMethod = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR;
308
309
  var toolbarItems = (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [_objectSpread({
309
310
  id: 'editor.link.openLink',
310
311
  type: 'button',
@@ -313,7 +314,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
313
314
  metadata: metadata,
314
315
  className: 'hyperlink-open-link',
315
316
  title: intl.formatMessage(_messages.linkMessages.openLink),
316
- onClick: visitCardLink(editorAnalyticsApi)
317
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
317
318
  }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
318
319
  href: url,
319
320
  target: '_blank'
@@ -362,7 +363,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
362
363
  metadata: metadata,
363
364
  className: 'hyperlink-open-link',
364
365
  title: intl.formatMessage(_messages.linkMessages.openLink),
365
- onClick: visitCardLink(editorAnalyticsApi)
366
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
366
367
  }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
367
368
  href: url,
368
369
  target: '_blank'
@@ -453,7 +454,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
453
454
  onClick: function onClick() {
454
455
  var _pluginInjectionApi$c2, _pluginInjectionApi$f;
455
456
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.actions.execute( // @ts-ignore
456
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type));
457
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, _analytics.INPUT_METHOD.FLOATING_TB));
457
458
  return true;
458
459
  },
459
460
  icon: /*#__PURE__*/_react.default.createElement(_copy.default, {
@@ -567,6 +568,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
567
568
  });
568
569
  }
569
570
  }
571
+ var openLinkInputMethod = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR;
570
572
  toolbarItems.push({
571
573
  type: 'custom',
572
574
  fallback: [],
@@ -593,7 +595,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
593
595
  metadata: metadata,
594
596
  className: 'hyperlink-open-link',
595
597
  title: intl.formatMessage(_messages.linkMessages.openLink),
596
- onClick: visitCardLink(editorAnalyticsApi)
598
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
597
599
  }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
598
600
  href: node.attrs.url,
599
601
  target: '_blank'
@@ -643,7 +645,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
643
645
  onClick: function onClick() {
644
646
  var _pluginInjectionApi$c3, _pluginInjectionApi$f2;
645
647
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.core) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.actions.execute( // @ts-ignore
646
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type));
648
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, _analytics.INPUT_METHOD.FLOATING_TB));
647
649
  return true;
648
650
  },
649
651
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, _editorSharedStyles.akEditorSelectedNodeClassName),
@@ -5,7 +5,6 @@ import uuid from 'uuid/v4';
5
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
6
6
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
7
7
  import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { Card as SmartCard } from '@atlaskit/smart-card';
10
9
  import { Datasource } from '../nodeviews/datasource';
11
10
  import { registerCard, removeCard } from '../pm-plugins/actions';
@@ -150,9 +149,7 @@ export class BlockCard extends ReactNodeView {
150
149
  destroy() {
151
150
  var _this$unsubscribe;
152
151
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
153
- if (fg('platform_editor_fix_card_plugin_state')) {
154
- this.removeCard();
155
- }
152
+ this.removeCard();
156
153
  }
157
154
  removeCard() {
158
155
  const {
@@ -9,7 +9,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
9
9
  import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
10
10
  import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
11
11
  import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
14
13
  import { registerCard, removeCard } from '../pm-plugins/actions';
15
14
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
@@ -376,9 +375,7 @@ export class EmbedCard extends ReactNodeView {
376
375
  destroy() {
377
376
  var _this$unsubscribe;
378
377
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
379
- if (fg('platform_editor_fix_card_plugin_state')) {
380
- this.removeCard();
381
- }
378
+ this.removeCard();
382
379
  }
383
380
  removeCard() {
384
381
  const {
@@ -37,15 +37,13 @@ export const InlineCard = /*#__PURE__*/memo(({
37
37
  useEffect(() => {
38
38
  const id = refId.current;
39
39
  return () => {
40
- if (fg('platform_editor_fix_card_plugin_state')) {
41
- const {
42
- tr
43
- } = view.state;
44
- removeCard({
45
- id
46
- })(tr);
47
- view.dispatch(tr);
48
- }
40
+ const {
41
+ tr
42
+ } = view.state;
43
+ removeCard({
44
+ id
45
+ })(tr);
46
+ view.dispatch(tr);
49
47
  };
50
48
  }, [getPos, view]);
51
49
  const scrollContainer = useMemo(
@@ -22,19 +22,18 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
22
22
  isPageSSRed,
23
23
  appearance
24
24
  }) => {
25
- var _pluginInjectionApi$c;
25
+ var _pluginInjectionApi$c, _pluginInjectionApi$a;
26
26
  const [isHovered, setIsHovered] = useState(false);
27
27
  const [isInserted, setIsInserted] = useState(false);
28
28
  const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
29
29
  const editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
30
+ const {
31
+ actions: editorAnalyticsApi
32
+ } = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {};
30
33
  const onResolve = useCallback((tr, title) => {
31
- if (fg('platform_editor_fix_card_plugin_state')) {
32
- const metadata = tr.getMeta(pluginKey);
33
- if (metadata && metadata.type === 'REGISTER') {
34
- registerRemoveOverlay(() => setIsInserted(false), metadata.info)(tr);
35
- } else {
36
- registerRemoveOverlay(() => setIsInserted(false))(tr);
37
- }
34
+ const metadata = tr.getMeta(pluginKey);
35
+ if (metadata && metadata.type === 'REGISTER') {
36
+ registerRemoveOverlay(() => setIsInserted(false), metadata.info)(tr);
38
37
  } else {
39
38
  registerRemoveOverlay(() => setIsInserted(false))(tr);
40
39
  }
@@ -58,7 +57,9 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
58
57
  const innerCardWithOpenButtonOverlay = useMemo(() => /*#__PURE__*/React.createElement(OpenButtonOverlay, {
59
58
  isVisible: isResolvedViewRendered,
60
59
  url: node.attrs.url,
61
- editorAppearance: editorAppearance
60
+ editorAppearance: editorAppearance,
61
+ editorAnalyticsApi: editorAnalyticsApi,
62
+ view: view
62
63
  }, /*#__PURE__*/React.createElement(InlineCard, {
63
64
  node: node,
64
65
  view: view,
@@ -70,7 +71,7 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
70
71
  cardContext: cardContext,
71
72
  isHovered: isHovered,
72
73
  isPageSSRed: isPageSSRed
73
- })), [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed]);
74
+ })), [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, editorAnalyticsApi]);
74
75
  const innerCardOriginal = useMemo(() => /*#__PURE__*/React.createElement(InlineCard, {
75
76
  node: node,
76
77
  view: view,
@@ -7,10 +7,12 @@
7
7
  import React, { useLayoutEffect, useRef, useState } from 'react';
8
8
  import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
9
9
 
10
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
12
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
12
13
  import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { Anchor, Box, Text, xcss } from '@atlaskit/primitives';
15
+ import { visitCardLink } from '../toolbar';
14
16
  const containerStyles = css({
15
17
  position: 'relative'
16
18
  });
@@ -61,7 +63,8 @@ const OpenButtonOverlay = ({
61
63
  isVisible = false,
62
64
  url,
63
65
  editorAppearance,
64
- ...props
66
+ editorAnalyticsApi,
67
+ view
65
68
  }) => {
66
69
  // TODO: ED-26961 - add translation
67
70
  const label = 'Open';
@@ -71,10 +74,6 @@ const OpenButtonOverlay = ({
71
74
  const [showLabel, setShowLabel] = useState(true);
72
75
  const [isHovered, setHovered] = useState(false);
73
76
  const openTextWidthRef = useRef(DEFAULT_OPEN_TEXT_WIDTH);
74
- const handleDoubleClick = () => {
75
- // Double click opens the link in a new tab
76
- window.open(url, '_blank');
77
- };
78
77
  useLayoutEffect(() => {
79
78
  const hiddenText = hiddenTextRef.current;
80
79
  if (!hiddenText) {
@@ -111,6 +110,22 @@ const OpenButtonOverlay = ({
111
110
  const handleOverlayChange = isHovered => {
112
111
  setHovered(isHovered);
113
112
  };
113
+ const sendVisitLinkAnalytics = inputMethod => {
114
+ if (editorAnalyticsApi && view) {
115
+ visitCardLink(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
116
+ }
117
+ };
118
+ const handleDoubleClick = () => {
119
+ if (fg('platform_editor_controls_patch_analytics')) {
120
+ sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
121
+ }
122
+
123
+ // Double click opens the link in a new tab
124
+ window.open(url, '_blank');
125
+ };
126
+ const handleClick = () => {
127
+ sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
128
+ };
114
129
  return (
115
130
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
116
131
  jsx("span", {
@@ -133,7 +148,8 @@ const OpenButtonOverlay = ({
133
148
  target: "_blank",
134
149
  style: {
135
150
  paddingBlock: editorAppearance === 'comment' && fg('platform_editor_controls_patch_6') ? '1px' : "var(--ds-space-025, 2px)"
136
- }
151
+ },
152
+ onClick: fg('platform_editor_controls_patch_analytics') ? handleClick : undefined
137
153
  }, jsx(Box, {
138
154
  xcss: iconWrapperStyles,
139
155
  "data-inlinecard-button-overlay": "icon-wrapper-line-height"
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { isSafeUrl } from '@atlaskit/adf-schema';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID as ACTION_SUBJECTID, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID as ACTION_SUBJECTID, buildOpenedSettingsPayload, buildVisitedNonHyperLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { buildLayoutButtons, buildLayoutDropdown, commandWithMetadata } from '@atlaskit/editor-common/card';
5
5
  import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
6
6
  import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
@@ -44,7 +44,7 @@ export const removeCard = editorAnalyticsApi => commandWithMetadata((state, disp
44
44
  actionSubject: ACTION_SUBJECT.SMART_LINK,
45
45
  actionSubjectId: type,
46
46
  attributes: {
47
- inputMethod: INPUT_METHOD.TOOLBAR,
47
+ inputMethod: fg('platform_editor_controls_patch_analytics_2') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR,
48
48
  displayMode: type
49
49
  },
50
50
  eventType: EVENT_TYPE.TRACK
@@ -61,7 +61,7 @@ export const removeCard = editorAnalyticsApi => commandWithMetadata((state, disp
61
61
  }, {
62
62
  action: ACTION.DELETED
63
63
  });
64
- export const visitCardLink = editorAnalyticsApi => (state, dispatch) => {
64
+ export const visitCardLink = (editorAnalyticsApi, inputMethod) => (state, dispatch) => {
65
65
  if (!(state.selection instanceof NodeSelection)) {
66
66
  return false;
67
67
  }
@@ -81,7 +81,7 @@ export const visitCardLink = editorAnalyticsApi => (state, dispatch) => {
81
81
  const {
82
82
  tr
83
83
  } = state;
84
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(buildVisitedLinkPayload(type.name))(tr);
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(buildVisitedNonHyperLinkPayload(type.name, inputMethod))(tr);
85
85
  dispatch(tr);
86
86
  }
87
87
  return true;
@@ -297,6 +297,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
297
297
  }, {
298
298
  type: 'separator'
299
299
  }] : [];
300
+ const openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
300
301
  const toolbarItems = editorExperiment('platform_editor_controls', 'control') ? [...editItems, ...commentItems, {
301
302
  id: 'editor.link.openLink',
302
303
  type: 'button',
@@ -305,7 +306,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
305
306
  metadata: metadata,
306
307
  className: 'hyperlink-open-link',
307
308
  title: intl.formatMessage(linkMessages.openLink),
308
- onClick: visitCardLink(editorAnalyticsApi),
309
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
309
310
  ...(fg('smart_link_editor_update_toolbar_open_link') && {
310
311
  href: url,
311
312
  target: '_blank'
@@ -355,7 +356,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
355
356
  metadata: metadata,
356
357
  className: 'hyperlink-open-link',
357
358
  title: intl.formatMessage(linkMessages.openLink),
358
- onClick: visitCardLink(editorAnalyticsApi),
359
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
359
360
  ...(fg('smart_link_editor_update_toolbar_open_link') && {
360
361
  href: url,
361
362
  target: '_blank'
@@ -443,7 +444,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
443
444
  onClick: () => {
444
445
  var _pluginInjectionApi$c4, _pluginInjectionApi$f;
445
446
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.actions.execute( // @ts-ignore
446
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type));
447
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
447
448
  return true;
448
449
  },
449
450
  icon: /*#__PURE__*/React.createElement(CopyIcon, {
@@ -560,6 +561,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
560
561
  });
561
562
  }
562
563
  }
564
+ const openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
563
565
  toolbarItems.push({
564
566
  type: 'custom',
565
567
  fallback: [],
@@ -584,7 +586,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
584
586
  metadata: metadata,
585
587
  className: 'hyperlink-open-link',
586
588
  title: intl.formatMessage(linkMessages.openLink),
587
- onClick: visitCardLink(editorAnalyticsApi),
589
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
588
590
  ...(fg('smart_link_editor_update_toolbar_open_link') && {
589
591
  href: node.attrs.url,
590
592
  target: '_blank'
@@ -635,7 +637,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
635
637
  onClick: () => {
636
638
  var _pluginInjectionApi$c5, _pluginInjectionApi$f2;
637
639
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c5 = pluginInjectionApi.core) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : _pluginInjectionApi$c5.actions.execute( // @ts-ignore
638
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type));
640
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
639
641
  return true;
640
642
  },
641
643
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
@@ -14,7 +14,6 @@ import uuid from 'uuid/v4';
14
14
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
15
15
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
16
16
  import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
17
- import { fg } from '@atlaskit/platform-feature-flags';
18
17
  import { Card as SmartCard } from '@atlaskit/smart-card';
19
18
  import { Datasource } from '../nodeviews/datasource';
20
19
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
@@ -180,9 +179,7 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
180
179
  value: function destroy() {
181
180
  var _this$unsubscribe;
182
181
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
183
- if (fg('platform_editor_fix_card_plugin_state')) {
184
- this.removeCard();
185
- }
182
+ this.removeCard();
186
183
  }
187
184
  }, {
188
185
  key: "removeCard",
@@ -20,7 +20,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
20
20
  import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
21
21
  import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
22
22
  import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
23
- import { fg } from '@atlaskit/platform-feature-flags';
24
23
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
25
24
  import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
26
25
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
@@ -394,9 +393,7 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
394
393
  value: function destroy() {
395
394
  var _this$unsubscribe;
396
395
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
397
- if (fg('platform_editor_fix_card_plugin_state')) {
398
- this.removeCard();
399
- }
396
+ this.removeCard();
400
397
  }
401
398
  }, {
402
399
  key: "removeCard",
@@ -36,13 +36,11 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
36
36
  useEffect(function () {
37
37
  var id = refId.current;
38
38
  return function () {
39
- if (fg('platform_editor_fix_card_plugin_state')) {
40
- var tr = view.state.tr;
41
- removeCard({
42
- id: id
43
- })(tr);
44
- view.dispatch(tr);
45
- }
39
+ var tr = view.state.tr;
40
+ removeCard({
41
+ id: id
42
+ })(tr);
43
+ view.dispatch(tr);
46
44
  };
47
45
  }, [getPos, view]);
48
46
  var scrollContainer = useMemo(
@@ -9,7 +9,7 @@ import { AwarenessWrapper } from '../ui/AwarenessWrapper';
9
9
  import OpenButtonOverlay from '../ui/OpenButtonOverlay';
10
10
  import { InlineCard } from './inlineCard';
11
11
  export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
12
- var _pluginInjectionApi$c;
12
+ var _pluginInjectionApi$c, _pluginInjectionApi$a;
13
13
  var node = _ref.node,
14
14
  cardContext = _ref.cardContext,
15
15
  actionOptions = _ref.actionOptions,
@@ -36,18 +36,14 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
36
36
  isResolvedViewRendered = _useState6[0],
37
37
  setIsResolvedViewRendered = _useState6[1];
38
38
  var editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
39
+ var _ref2 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
40
+ editorAnalyticsApi = _ref2.actions;
39
41
  var onResolve = useCallback(function (tr, title) {
40
- if (fg('platform_editor_fix_card_plugin_state')) {
41
- var metadata = tr.getMeta(pluginKey);
42
- if (metadata && metadata.type === 'REGISTER') {
43
- registerRemoveOverlay(function () {
44
- return setIsInserted(false);
45
- }, metadata.info)(tr);
46
- } else {
47
- registerRemoveOverlay(function () {
48
- return setIsInserted(false);
49
- })(tr);
50
- }
42
+ var metadata = tr.getMeta(pluginKey);
43
+ if (metadata && metadata.type === 'REGISTER') {
44
+ registerRemoveOverlay(function () {
45
+ return setIsInserted(false);
46
+ }, metadata.info)(tr);
51
47
  } else {
52
48
  registerRemoveOverlay(function () {
53
49
  return setIsInserted(false);
@@ -73,7 +69,9 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
73
69
  return /*#__PURE__*/React.createElement(OpenButtonOverlay, {
74
70
  isVisible: isResolvedViewRendered,
75
71
  url: node.attrs.url,
76
- editorAppearance: editorAppearance
72
+ editorAppearance: editorAppearance,
73
+ editorAnalyticsApi: editorAnalyticsApi,
74
+ view: view
77
75
  }, /*#__PURE__*/React.createElement(InlineCard, {
78
76
  node: node,
79
77
  view: view,
@@ -86,7 +84,7 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
86
84
  isHovered: isHovered,
87
85
  isPageSSRed: isPageSSRed
88
86
  }));
89
- }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed]);
87
+ }, [isResolvedViewRendered, node, editorAppearance, view, getPos, useAlternativePreloader, actionOptions, onResolve, onClick, cardContext, isHovered, isPageSSRed, editorAnalyticsApi]);
90
88
  var innerCardOriginal = useMemo(function () {
91
89
  return /*#__PURE__*/React.createElement(InlineCard, {
92
90
  node: node,
@@ -1,6 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "isVisible", "url", "editorAppearance"];
4
2
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
5
3
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
6
4
  /**
@@ -10,10 +8,12 @@ var _excluded = ["children", "isVisible", "url", "editorAppearance"];
10
8
  import React, { useLayoutEffect, useRef, useState } from 'react';
11
9
  import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
12
10
 
11
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
13
12
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
14
13
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
15
14
  import { fg } from '@atlaskit/platform-feature-flags';
16
15
  import { Anchor, Box, Text, xcss } from '@atlaskit/primitives';
16
+ import { visitCardLink } from '../toolbar';
17
17
  var containerStyles = css({
18
18
  position: 'relative'
19
19
  });
@@ -65,7 +65,8 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
65
65
  isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
66
66
  url = _ref.url,
67
67
  editorAppearance = _ref.editorAppearance,
68
- props = _objectWithoutProperties(_ref, _excluded);
68
+ editorAnalyticsApi = _ref.editorAnalyticsApi,
69
+ view = _ref.view;
69
70
  // TODO: ED-26961 - add translation
70
71
  var label = 'Open';
71
72
  var containerRef = useRef(null);
@@ -80,10 +81,6 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
80
81
  isHovered = _useState4[0],
81
82
  setHovered = _useState4[1];
82
83
  var openTextWidthRef = useRef(DEFAULT_OPEN_TEXT_WIDTH);
83
- var handleDoubleClick = function handleDoubleClick() {
84
- // Double click opens the link in a new tab
85
- window.open(url, '_blank');
86
- };
87
84
  useLayoutEffect(function () {
88
85
  var hiddenText = hiddenTextRef.current;
89
86
  if (!hiddenText) {
@@ -120,6 +117,22 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
120
117
  var handleOverlayChange = function handleOverlayChange(isHovered) {
121
118
  setHovered(isHovered);
122
119
  };
120
+ var sendVisitLinkAnalytics = function sendVisitLinkAnalytics(inputMethod) {
121
+ if (editorAnalyticsApi && view) {
122
+ visitCardLink(editorAnalyticsApi, inputMethod)(view.state, view.dispatch);
123
+ }
124
+ };
125
+ var handleDoubleClick = function handleDoubleClick() {
126
+ if (fg('platform_editor_controls_patch_analytics')) {
127
+ sendVisitLinkAnalytics(INPUT_METHOD.DOUBLE_CLICK);
128
+ }
129
+
130
+ // Double click opens the link in a new tab
131
+ window.open(url, '_blank');
132
+ };
133
+ var handleClick = function handleClick() {
134
+ sendVisitLinkAnalytics(INPUT_METHOD.BUTTON);
135
+ };
123
136
  return (
124
137
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
125
138
  jsx("span", {
@@ -146,7 +159,8 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
146
159
  target: "_blank",
147
160
  style: {
148
161
  paddingBlock: editorAppearance === 'comment' && fg('platform_editor_controls_patch_6') ? '1px' : "var(--ds-space-025, 2px)"
149
- }
162
+ },
163
+ onClick: fg('platform_editor_controls_patch_analytics') ? handleClick : undefined
150
164
  }, jsx(Box, {
151
165
  xcss: iconWrapperStyles,
152
166
  "data-inlinecard-button-overlay": "icon-wrapper-line-height"
@@ -4,7 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  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) { _defineProperty(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; }
5
5
  import React from 'react';
6
6
  import { isSafeUrl } from '@atlaskit/adf-schema';
7
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID as ACTION_SUBJECTID, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID as ACTION_SUBJECTID, buildOpenedSettingsPayload, buildVisitedNonHyperLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { buildLayoutButtons, buildLayoutDropdown, commandWithMetadata } from '@atlaskit/editor-common/card';
9
9
  import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
10
10
  import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
@@ -49,7 +49,7 @@ export var removeCard = function removeCard(editorAnalyticsApi) {
49
49
  actionSubject: ACTION_SUBJECT.SMART_LINK,
50
50
  actionSubjectId: type,
51
51
  attributes: {
52
- inputMethod: INPUT_METHOD.TOOLBAR,
52
+ inputMethod: fg('platform_editor_controls_patch_analytics_2') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR,
53
53
  displayMode: type
54
54
  },
55
55
  eventType: EVENT_TYPE.TRACK
@@ -65,7 +65,7 @@ export var removeCard = function removeCard(editorAnalyticsApi) {
65
65
  action: ACTION.DELETED
66
66
  });
67
67
  };
68
- export var visitCardLink = function visitCardLink(editorAnalyticsApi) {
68
+ export var visitCardLink = function visitCardLink(editorAnalyticsApi, inputMethod) {
69
69
  return function (state, dispatch) {
70
70
  if (!(state.selection instanceof NodeSelection)) {
71
71
  return false;
@@ -81,7 +81,7 @@ export var visitCardLink = function visitCardLink(editorAnalyticsApi) {
81
81
  }
82
82
  if (dispatch) {
83
83
  var tr = state.tr;
84
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildVisitedLinkPayload(type.name))(tr);
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildVisitedNonHyperLinkPayload(type.name, inputMethod))(tr);
85
85
  dispatch(tr);
86
86
  }
87
87
  return true;
@@ -295,6 +295,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
295
295
  }, {
296
296
  type: 'separator'
297
297
  }] : [];
298
+ var openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
298
299
  var toolbarItems = editorExperiment('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [_objectSpread({
299
300
  id: 'editor.link.openLink',
300
301
  type: 'button',
@@ -303,7 +304,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
303
304
  metadata: metadata,
304
305
  className: 'hyperlink-open-link',
305
306
  title: intl.formatMessage(linkMessages.openLink),
306
- onClick: visitCardLink(editorAnalyticsApi)
307
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
307
308
  }, fg('smart_link_editor_update_toolbar_open_link') && {
308
309
  href: url,
309
310
  target: '_blank'
@@ -352,7 +353,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
352
353
  metadata: metadata,
353
354
  className: 'hyperlink-open-link',
354
355
  title: intl.formatMessage(linkMessages.openLink),
355
- onClick: visitCardLink(editorAnalyticsApi)
356
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
356
357
  }, fg('smart_link_editor_update_toolbar_open_link') && {
357
358
  href: url,
358
359
  target: '_blank'
@@ -443,7 +444,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
443
444
  onClick: function onClick() {
444
445
  var _pluginInjectionApi$c2, _pluginInjectionApi$f;
445
446
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.actions.execute( // @ts-ignore
446
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type));
447
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
447
448
  return true;
448
449
  },
449
450
  icon: /*#__PURE__*/React.createElement(CopyIcon, {
@@ -557,6 +558,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
557
558
  });
558
559
  }
559
560
  }
561
+ var openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
560
562
  toolbarItems.push({
561
563
  type: 'custom',
562
564
  fallback: [],
@@ -583,7 +585,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
583
585
  metadata: metadata,
584
586
  className: 'hyperlink-open-link',
585
587
  title: intl.formatMessage(linkMessages.openLink),
586
- onClick: visitCardLink(editorAnalyticsApi)
588
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
587
589
  }, fg('smart_link_editor_update_toolbar_open_link') && {
588
590
  href: node.attrs.url,
589
591
  target: '_blank'
@@ -633,7 +635,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
633
635
  onClick: function onClick() {
634
636
  var _pluginInjectionApi$c3, _pluginInjectionApi$f2;
635
637
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.core) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.actions.execute( // @ts-ignore
636
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type));
638
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
637
639
  return true;
638
640
  },
639
641
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
@@ -5,5 +5,5 @@
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import type { OpenButtonOverlayProps } from './types';
8
- declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, ...props }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
8
+ declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
9
9
  export default OpenButtonOverlay;
@@ -1,7 +1,11 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import { EditorAppearance } from '@atlaskit/editor-common/types';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
5
  export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
4
6
  isVisible?: boolean;
5
7
  url: string;
6
8
  editorAppearance?: EditorAppearance;
9
+ editorAnalyticsApi?: EditorAnalyticsAPI;
10
+ view?: EditorView;
7
11
  };
@@ -1,12 +1,13 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { CardOptions } from '@atlaskit/editor-common/card';
4
5
  import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
5
6
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
7
  import type { cardPlugin } from '../index';
7
8
  import type { CardPluginOptions } from '../types';
8
9
  export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
9
- export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
10
+ export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, inputMethod: INPUT_METHOD.BUTTON | INPUT_METHOD.DOUBLE_CLICK | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TOOLBAR) => Command;
10
11
  export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
11
12
  export declare const floatingToolbar: (cardOptions: CardOptions, lpLinkPicker: boolean, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>, disableFloatingToolbar?: boolean) => FloatingToolbarHandler;
12
13
  export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink?: string) => FloatingToolbarItem<Command>;
@@ -5,5 +5,5 @@
5
5
  import React from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import type { OpenButtonOverlayProps } from './types';
8
- declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, ...props }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
8
+ declare const OpenButtonOverlay: ({ children, isVisible, url, editorAppearance, editorAnalyticsApi, view, }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
9
9
  export default OpenButtonOverlay;
@@ -1,7 +1,11 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import { EditorAppearance } from '@atlaskit/editor-common/types';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
5
  export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
4
6
  isVisible?: boolean;
5
7
  url: string;
6
8
  editorAppearance?: EditorAppearance;
9
+ editorAnalyticsApi?: EditorAnalyticsAPI;
10
+ view?: EditorView;
7
11
  };
@@ -1,12 +1,13 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { CardOptions } from '@atlaskit/editor-common/card';
4
5
  import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
5
6
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
7
  import type { cardPlugin } from '../index';
7
8
  import type { CardPluginOptions } from '../types';
8
9
  export declare const removeCard: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
9
- export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
10
+ export declare const visitCardLink: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, inputMethod: INPUT_METHOD.BUTTON | INPUT_METHOD.DOUBLE_CLICK | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TOOLBAR) => Command;
10
11
  export declare const openLinkSettings: (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
11
12
  export declare const floatingToolbar: (cardOptions: CardOptions, lpLinkPicker: boolean, linkPickerOptions?: LinkPickerOptions, pluginInjectionApi?: ExtractInjectionAPI<typeof cardPlugin>, disableFloatingToolbar?: boolean) => FloatingToolbarHandler;
12
13
  export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink?: string) => FloatingToolbarItem<Command>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "5.4.24",
3
+ "version": "5.4.26",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/analytics-next": "^11.0.0",
38
38
  "@atlaskit/button": "^23.0.0",
39
39
  "@atlaskit/custom-steps": "^0.11.0",
40
- "@atlaskit/editor-common": "^103.22.0",
40
+ "@atlaskit/editor-common": "^104.0.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
42
42
  "@atlaskit/editor-plugin-base": "^2.3.0",
43
43
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
46
46
  "@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
47
47
  "@atlaskit/editor-plugin-feature-flags": "^1.4.0",
48
- "@atlaskit/editor-plugin-floating-toolbar": "^4.0.0",
48
+ "@atlaskit/editor-plugin-floating-toolbar": "^4.1.0",
49
49
  "@atlaskit/editor-plugin-grid": "^2.0.0",
50
50
  "@atlaskit/editor-plugin-width": "^3.0.0",
51
51
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -59,10 +59,10 @@
59
59
  "@atlaskit/linking-types": "^9.10.0",
60
60
  "@atlaskit/menu": "^5.0.0",
61
61
  "@atlaskit/platform-feature-flags": "^1.1.0",
62
- "@atlaskit/primitives": "^14.6.0",
63
- "@atlaskit/smart-card": "^36.13.0",
62
+ "@atlaskit/primitives": "^14.7.0",
63
+ "@atlaskit/smart-card": "^36.15.0",
64
64
  "@atlaskit/theme": "^18.0.0",
65
- "@atlaskit/tmp-editor-statsig": "^4.15.0",
65
+ "@atlaskit/tmp-editor-statsig": "^4.16.0",
66
66
  "@atlaskit/tokens": "^4.8.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@emotion/react": "^11.7.1",
@@ -122,9 +122,6 @@
122
122
  "linking_platform_smart_links_in_live_pages": {
123
123
  "type": "boolean"
124
124
  },
125
- "platform_editor_fix_card_plugin_state": {
126
- "type": "boolean"
127
- },
128
125
  "confluence-issue-terminology-refresh": {
129
126
  "type": "boolean"
130
127
  },
@@ -143,6 +140,12 @@
143
140
  "platform_editor_controls_patch_6": {
144
141
  "type": "boolean"
145
142
  },
143
+ "platform_editor_controls_patch_analytics": {
144
+ "type": "boolean"
145
+ },
146
+ "platform_editor_controls_patch_analytics_2": {
147
+ "type": "boolean"
148
+ },
146
149
  "smart_link_editor_update_toolbar_open_link": {
147
150
  "type": "boolean"
148
151
  }