@atlaskit/editor-plugin-card 5.4.23 → 5.4.25

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.25
4
+
5
+ ### Patch Changes
6
+
7
+ - [#149184](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149184)
8
+ [`2df75499ccc98`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2df75499ccc98) -
9
+ Cleanup feature gate to fix plugin state on card plugin.
10
+ - [#149530](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149530)
11
+ [`a432884180253`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a432884180253) -
12
+ Sends SmartLink Visited event with additional input methods depending on the way the link was
13
+ opened.
14
+ - Updated dependencies
15
+
16
+ ## 5.4.24
17
+
18
+ ### Patch Changes
19
+
20
+ - [#148769](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/148769)
21
+ [`4d875576ce223`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4d875576ce223) -
22
+ [ux] Update link button to be an anchor
23
+ - Updated dependencies
24
+
3
25
  ## 5.4.23
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"
@@ -75,21 +75,23 @@ 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;
82
82
  }
83
83
  var type = state.selection.node.type;
84
- var _titleUrlPairFromNode = (0, _utils3.titleUrlPairFromNode)(state.selection.node),
85
- url = _titleUrlPairFromNode.url;
84
+ if (!(0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link')) {
85
+ var _titleUrlPairFromNode = (0, _utils3.titleUrlPairFromNode)(state.selection.node),
86
+ url = _titleUrlPairFromNode.url;
86
87
 
87
- // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
88
- // We are in edit mode here, open the smart card URL in a new window.
89
- window.open(url);
88
+ // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
89
+ // We are in edit mode here, open the smart card URL in a new window.
90
+ window.open(url);
91
+ }
90
92
  if (dispatch) {
91
93
  var tr = state.tr;
92
- 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);
93
95
  dispatch(tr);
94
96
  }
95
97
  return true;
@@ -303,7 +305,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
303
305
  }, {
304
306
  type: 'separator'
305
307
  }] : [];
306
- var toolbarItems = (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [{
308
+ var openLinkInputMethod = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR;
309
+ var toolbarItems = (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [_objectSpread({
307
310
  id: 'editor.link.openLink',
308
311
  type: 'button',
309
312
  icon: _linkExternal.default,
@@ -311,8 +314,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
311
314
  metadata: metadata,
312
315
  className: 'hyperlink-open-link',
313
316
  title: intl.formatMessage(_messages.linkMessages.openLink),
314
- onClick: visitCardLink(editorAnalyticsApi)
315
- }, {
317
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
318
+ }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
319
+ href: url,
320
+ target: '_blank'
321
+ }), {
316
322
  type: 'separator'
317
323
  }], (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
318
324
  type: 'copy-button',
@@ -349,7 +355,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
349
355
  onClick: (0, _EditLinkToolbar.getEditLinkCallback)(editorAnalyticsApi, true)
350
356
  }].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_6') ? [] : [{
351
357
  type: 'separator'
352
- }]), (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
358
+ }]), (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [_objectSpread({
353
359
  id: 'editor.link.openLink',
354
360
  type: 'button',
355
361
  icon: _linkExternal.default,
@@ -357,8 +363,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
357
363
  metadata: metadata,
358
364
  className: 'hyperlink-open-link',
359
365
  title: intl.formatMessage(_messages.linkMessages.openLink),
360
- onClick: visitCardLink(editorAnalyticsApi)
361
- }], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
366
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
367
+ }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
368
+ href: url,
369
+ target: '_blank'
370
+ })], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
362
371
  type: 'separator',
363
372
  fullHeight: true
364
373
  }, commentItems[0]] : commentItems));
@@ -559,6 +568,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
559
568
  });
560
569
  }
561
570
  }
571
+ var openLinkInputMethod = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR;
562
572
  toolbarItems.push({
563
573
  type: 'custom',
564
574
  fallback: [],
@@ -577,7 +587,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
577
587
  }
578
588
  });
579
589
  if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
580
- toolbarItems.push({
590
+ toolbarItems.push(_objectSpread({
581
591
  id: 'editor.link.openLink',
582
592
  type: 'button',
583
593
  icon: _linkExternal.default,
@@ -585,8 +595,11 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
585
595
  metadata: metadata,
586
596
  className: 'hyperlink-open-link',
587
597
  title: intl.formatMessage(_messages.linkMessages.openLink),
588
- onClick: visitCardLink(editorAnalyticsApi)
589
- });
598
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
599
+ }, (0, _platformFeatureFlags.fg)('smart_link_editor_update_toolbar_open_link') && {
600
+ href: node.attrs.url,
601
+ target: '_blank'
602
+ }));
590
603
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
591
604
  toolbarItems.push({
592
605
  type: 'separator'
@@ -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';
@@ -61,25 +61,27 @@ 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
  }
68
68
  const {
69
69
  type
70
70
  } = state.selection.node;
71
- const {
72
- url
73
- } = titleUrlPairFromNode(state.selection.node);
71
+ if (!fg('smart_link_editor_update_toolbar_open_link')) {
72
+ const {
73
+ url
74
+ } = titleUrlPairFromNode(state.selection.node);
74
75
 
75
- // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
76
- // We are in edit mode here, open the smart card URL in a new window.
77
- window.open(url);
76
+ // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
77
+ // We are in edit mode here, open the smart card URL in a new window.
78
+ window.open(url);
79
+ }
78
80
  if (dispatch) {
79
81
  const {
80
82
  tr
81
83
  } = state;
82
- 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);
83
85
  dispatch(tr);
84
86
  }
85
87
  return true;
@@ -295,6 +297,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
295
297
  }, {
296
298
  type: 'separator'
297
299
  }] : [];
300
+ const openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
298
301
  const toolbarItems = editorExperiment('platform_editor_controls', 'control') ? [...editItems, ...commentItems, {
299
302
  id: 'editor.link.openLink',
300
303
  type: 'button',
@@ -303,7 +306,11 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
303
306
  metadata: metadata,
304
307
  className: 'hyperlink-open-link',
305
308
  title: intl.formatMessage(linkMessages.openLink),
306
- onClick: visitCardLink(editorAnalyticsApi)
309
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
310
+ ...(fg('smart_link_editor_update_toolbar_open_link') && {
311
+ href: url,
312
+ target: '_blank'
313
+ })
307
314
  }, {
308
315
  type: 'separator'
309
316
  }, ...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi), {
@@ -349,7 +356,11 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
349
356
  metadata: metadata,
350
357
  className: 'hyperlink-open-link',
351
358
  title: intl.formatMessage(linkMessages.openLink),
352
- onClick: visitCardLink(editorAnalyticsApi)
359
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
360
+ ...(fg('smart_link_editor_update_toolbar_open_link') && {
361
+ href: url,
362
+ target: '_blank'
363
+ })
353
364
  }, ...(commentItems.length > 1 ? [{
354
365
  type: 'separator',
355
366
  fullHeight: true
@@ -550,6 +561,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
550
561
  });
551
562
  }
552
563
  }
564
+ const openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
553
565
  toolbarItems.push({
554
566
  type: 'custom',
555
567
  fallback: [],
@@ -574,7 +586,11 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
574
586
  metadata: metadata,
575
587
  className: 'hyperlink-open-link',
576
588
  title: intl.formatMessage(linkMessages.openLink),
577
- onClick: visitCardLink(editorAnalyticsApi)
589
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod),
590
+ ...(fg('smart_link_editor_update_toolbar_open_link') && {
591
+ href: node.attrs.url,
592
+ target: '_blank'
593
+ })
578
594
  });
579
595
  if (editorExperiment('platform_editor_controls', 'control')) {
580
596
  toolbarItems.push({
@@ -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';
@@ -65,21 +65,23 @@ 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;
72
72
  }
73
73
  var type = state.selection.node.type;
74
- var _titleUrlPairFromNode = titleUrlPairFromNode(state.selection.node),
75
- url = _titleUrlPairFromNode.url;
74
+ if (!fg('smart_link_editor_update_toolbar_open_link')) {
75
+ var _titleUrlPairFromNode = titleUrlPairFromNode(state.selection.node),
76
+ url = _titleUrlPairFromNode.url;
76
77
 
77
- // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
78
- // We are in edit mode here, open the smart card URL in a new window.
79
- window.open(url);
78
+ // All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
79
+ // We are in edit mode here, open the smart card URL in a new window.
80
+ window.open(url);
81
+ }
80
82
  if (dispatch) {
81
83
  var tr = state.tr;
82
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildVisitedLinkPayload(type.name))(tr);
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildVisitedNonHyperLinkPayload(type.name, inputMethod))(tr);
83
85
  dispatch(tr);
84
86
  }
85
87
  return true;
@@ -293,7 +295,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
293
295
  }, {
294
296
  type: 'separator'
295
297
  }] : [];
296
- var toolbarItems = editorExperiment('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [{
298
+ var openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
299
+ var toolbarItems = editorExperiment('platform_editor_controls', 'control') ? [].concat(editItems, commentItems, [_objectSpread({
297
300
  id: 'editor.link.openLink',
298
301
  type: 'button',
299
302
  icon: LinkExternalIcon,
@@ -301,8 +304,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
301
304
  metadata: metadata,
302
305
  className: 'hyperlink-open-link',
303
306
  title: intl.formatMessage(linkMessages.openLink),
304
- onClick: visitCardLink(editorAnalyticsApi)
305
- }, {
307
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
308
+ }, fg('smart_link_editor_update_toolbar_open_link') && {
309
+ href: url,
310
+ target: '_blank'
311
+ }), {
306
312
  type: 'separator'
307
313
  }], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
308
314
  type: 'copy-button',
@@ -339,7 +345,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
339
345
  onClick: getEditLinkCallback(editorAnalyticsApi, true)
340
346
  }].concat(_toConsumableArray(fg('platform_editor_controls_patch_6') ? [] : [{
341
347
  type: 'separator'
342
- }]), _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [{
348
+ }]), _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi)), [_objectSpread({
343
349
  id: 'editor.link.openLink',
344
350
  type: 'button',
345
351
  icon: LinkExternalIcon,
@@ -347,8 +353,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
347
353
  metadata: metadata,
348
354
  className: 'hyperlink-open-link',
349
355
  title: intl.formatMessage(linkMessages.openLink),
350
- onClick: visitCardLink(editorAnalyticsApi)
351
- }], _toConsumableArray(commentItems.length > 1 ? [{
356
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
357
+ }, fg('smart_link_editor_update_toolbar_open_link') && {
358
+ href: url,
359
+ target: '_blank'
360
+ })], _toConsumableArray(commentItems.length > 1 ? [{
352
361
  type: 'separator',
353
362
  fullHeight: true
354
363
  }, commentItems[0]] : commentItems));
@@ -549,6 +558,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
549
558
  });
550
559
  }
551
560
  }
561
+ var openLinkInputMethod = fg('platform_editor_controls_patch_analytics') ? INPUT_METHOD.FLOATING_TB : INPUT_METHOD.TOOLBAR;
552
562
  toolbarItems.push({
553
563
  type: 'custom',
554
564
  fallback: [],
@@ -567,7 +577,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
567
577
  }
568
578
  });
569
579
  if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
570
- toolbarItems.push({
580
+ toolbarItems.push(_objectSpread({
571
581
  id: 'editor.link.openLink',
572
582
  type: 'button',
573
583
  icon: LinkExternalIcon,
@@ -575,8 +585,11 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
575
585
  metadata: metadata,
576
586
  className: 'hyperlink-open-link',
577
587
  title: intl.formatMessage(linkMessages.openLink),
578
- onClick: visitCardLink(editorAnalyticsApi)
579
- });
588
+ onClick: visitCardLink(editorAnalyticsApi, openLinkInputMethod)
589
+ }, fg('smart_link_editor_update_toolbar_open_link') && {
590
+ href: node.attrs.url,
591
+ target: '_blank'
592
+ }));
580
593
  if (editorExperiment('platform_editor_controls', 'control')) {
581
594
  toolbarItems.push({
582
595
  type: 'separator'
@@ -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.23",
3
+ "version": "5.4.25",
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.21.0",
40
+ "@atlaskit/editor-common": "^103.22.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",
@@ -54,13 +54,13 @@
54
54
  "@atlaskit/icon": "^25.6.0",
55
55
  "@atlaskit/link-analytics": "^9.1.0",
56
56
  "@atlaskit/link-client-extension": "^4.0.0",
57
- "@atlaskit/link-datasource": "^4.8.0",
57
+ "@atlaskit/link-datasource": "^4.9.0",
58
58
  "@atlaskit/linking-common": "^8.0.0",
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.4.0",
63
- "@atlaskit/smart-card": "^36.12.0",
62
+ "@atlaskit/primitives": "^14.7.0",
63
+ "@atlaskit/smart-card": "^36.14.0",
64
64
  "@atlaskit/theme": "^18.0.0",
65
65
  "@atlaskit/tmp-editor-statsig": "^4.15.0",
66
66
  "@atlaskit/tokens": "^4.8.0",
@@ -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
  },
@@ -142,6 +139,12 @@
142
139
  },
143
140
  "platform_editor_controls_patch_6": {
144
141
  "type": "boolean"
142
+ },
143
+ "smart_link_editor_update_toolbar_open_link": {
144
+ "type": "boolean"
145
+ },
146
+ "platform_editor_controls_patch_analytics": {
147
+ "type": "boolean"
145
148
  }
146
149
  },
147
150
  "stricter": {