@atlaskit/editor-plugin-card 14.0.0 → 14.0.2

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/pm-plugins/actions.js +10 -1
  3. package/dist/cjs/pm-plugins/main.js +1 -0
  4. package/dist/cjs/pm-plugins/reducers.js +7 -0
  5. package/dist/cjs/pm-plugins/utils.js +1 -3
  6. package/dist/cjs/ui/ResizableEmbedCard.js +33 -17
  7. package/dist/cjs/ui/ToolbarViewedEvent.js +22 -4
  8. package/dist/cjs/ui/toolbar.js +38 -19
  9. package/dist/es2019/pm-plugins/actions.js +5 -0
  10. package/dist/es2019/pm-plugins/main.js +1 -0
  11. package/dist/es2019/pm-plugins/reducers.js +11 -0
  12. package/dist/es2019/pm-plugins/utils.js +1 -3
  13. package/dist/es2019/ui/ResizableEmbedCard.js +17 -0
  14. package/dist/es2019/ui/ToolbarViewedEvent.js +20 -4
  15. package/dist/es2019/ui/toolbar.js +35 -19
  16. package/dist/esm/pm-plugins/actions.js +9 -0
  17. package/dist/esm/pm-plugins/main.js +1 -0
  18. package/dist/esm/pm-plugins/reducers.js +7 -0
  19. package/dist/esm/pm-plugins/utils.js +1 -3
  20. package/dist/esm/ui/ResizableEmbedCard.js +33 -17
  21. package/dist/esm/ui/ToolbarViewedEvent.js +22 -4
  22. package/dist/esm/ui/toolbar.js +38 -19
  23. package/dist/types/pm-plugins/actions.d.ts +2 -1
  24. package/dist/types/pm-plugins/util/state.d.ts +2 -1
  25. package/dist/types/pm-plugins/utils.d.ts +2 -2
  26. package/dist/types/types/index.d.ts +13 -1
  27. package/dist/types/ui/ResizableEmbedCard.d.ts +1 -0
  28. package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
  29. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +2 -1
  30. package/dist/types-ts4.5/pm-plugins/utils.d.ts +2 -2
  31. package/dist/types-ts4.5/types/index.d.ts +13 -1
  32. package/dist/types-ts4.5/ui/ResizableEmbedCard.d.ts +1 -0
  33. package/package.json +6 -3
@@ -18,6 +18,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
18
18
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
19
19
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
20
20
  import CogIcon from '@atlaskit/icon/core/settings';
21
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { changeSelectedCardToText } from '../pm-plugins/doc';
23
24
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -74,6 +75,27 @@ export const visitCardLinkAnalytics = (editorAnalyticsApi, inputMethod) => (stat
74
75
  }
75
76
  return true;
76
77
  };
78
+ const fireOpenLinkToolbarAnalytics = (editorAnalyticsApi, inputMethod, resolvedAttributes = {}) => (state, dispatch) => {
79
+ const linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
80
+ if (!linkAnalyticsRecorded) {
81
+ return false;
82
+ }
83
+ if (expValEquals('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
84
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.fireAnalyticsEvent({
85
+ action: ACTION.CLICKED,
86
+ actionSubject: ACTION_SUBJECT.BUTTON,
87
+ actionSubjectId: ACTION_SUBJECTID.OPEN_LINK,
88
+ attributes: {
89
+ displayCategory: resolvedAttributes.displayCategory,
90
+ extensionKey: resolvedAttributes.extensionKey,
91
+ status: resolvedAttributes.status,
92
+ statusDetails: resolvedAttributes.statusDetails
93
+ },
94
+ eventType: EVENT_TYPE.UI
95
+ });
96
+ }
97
+ return true;
98
+ };
77
99
  export const openLinkSettings = editorAnalyticsApi => (state, dispatch) => {
78
100
  if (!(state.selection instanceof NodeSelection)) {
79
101
  return false;
@@ -253,7 +275,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
253
275
  } else if (shouldRenderDatasourceToolbar) {
254
276
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
255
277
  } else {
256
- var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3;
278
+ var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3, _pluginState$resolved;
257
279
  const {
258
280
  inlineCard
259
281
  } = state.schema.nodes;
@@ -331,7 +353,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
331
353
  areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
332
354
  })
333
355
  }] : [];
334
- const toolbarItems = areAllNewToolbarFlagsDisabled ? [...editItems, ...commentItems, ...openPreviewPanelItems, {
356
+ const resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
357
+ const openLinkToolbarItem = {
335
358
  id: 'editor.link.openLink',
336
359
  type: 'button',
337
360
  icon: LinkExternalIcon,
@@ -339,10 +362,11 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
339
362
  metadata: metadata,
340
363
  className: 'hyperlink-open-link',
341
364
  title: intl.formatMessage(linkMessages.openLink),
342
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
365
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
343
366
  href: url,
344
367
  target: '_blank'
345
- }, {
368
+ };
369
+ const toolbarItems = areAllNewToolbarFlagsDisabled ? [...editItems, ...commentItems, ...openPreviewPanelItems, openLinkToolbarItem, {
346
370
  type: 'separator'
347
371
  }, ...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled), {
348
372
  type: 'copy-button',
@@ -371,18 +395,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
371
395
  }] : [...editButtonItems, ...[...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled), {
372
396
  type: 'separator',
373
397
  fullHeight: true
374
- }], ...openPreviewPanelItems, {
375
- id: 'editor.link.openLink',
376
- type: 'button',
377
- icon: LinkExternalIcon,
378
- iconFallback: LinkExternalIcon,
379
- metadata: metadata,
380
- className: 'hyperlink-open-link',
381
- title: intl.formatMessage(linkMessages.openLink),
382
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
383
- href: url,
384
- target: '_blank'
385
- }, ...(commentItems.length > 1 ? [{
398
+ }], ...openPreviewPanelItems, openLinkToolbarItem, ...(commentItems.length > 1 ? [{
386
399
  type: 'separator',
387
400
  fullHeight: true
388
401
  }, commentItems[0]] : commentItems)];
@@ -519,8 +532,9 @@ export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink)
519
532
  };
520
533
  };
521
534
  const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) => {
522
- var _node$attrs2;
535
+ var _node$attrs2, _node$attrs3;
523
536
  const toolbarItems = [];
537
+ toolbarItems.push(...getToolbarViewedItem(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'));
524
538
  const areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
525
539
  const canShowAppearanceSwitch = () => {
526
540
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -594,6 +608,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
594
608
  }
595
609
  }
596
610
  const openLinkInputMethod = INPUT_METHOD.FLOATING_TB;
611
+ const pluginState = pluginKey.getState(state);
597
612
  toolbarItems.push({
598
613
  type: 'custom',
599
614
  fallback: [],
@@ -610,7 +625,8 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
610
625
  areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
611
626
  })
612
627
  });
613
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
628
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
629
+ var _pluginState$resolved2;
614
630
  toolbarItems.push({
615
631
  id: 'editor.link.openLink',
616
632
  type: 'button',
@@ -619,7 +635,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
619
635
  metadata: metadata,
620
636
  className: 'hyperlink-open-link',
621
637
  title: intl.formatMessage(linkMessages.openLink),
622
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
638
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
623
639
  href: node.attrs.url,
624
640
  target: '_blank'
625
641
  });
@@ -67,6 +67,15 @@ export var setDatasourceTableRef = function setDatasourceTableRef(datasourceTabl
67
67
  });
68
68
  };
69
69
  };
70
+ export var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(url, attributes) {
71
+ return function (tr) {
72
+ return cardAction(tr, {
73
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
74
+ url: url,
75
+ attributes: attributes
76
+ });
77
+ };
78
+ };
70
79
  export var setCardLayout = function setCardLayout(layout) {
71
80
  return function (tr) {
72
81
  return cardAction(tr, {
@@ -75,6 +75,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
75
75
  provider: null,
76
76
  cards: [],
77
77
  datasourceStash: {},
78
+ resolvedToolbarAttributesByUrl: {},
78
79
  showLinkingToolbar: false,
79
80
  smartLinkEvents: undefined,
80
81
  editorAppearance: editorAppearance,
@@ -50,6 +50,11 @@ var setDatasourceTableRef = function setDatasourceTableRef(state, action) {
50
50
  datasourceTableRef: action.datasourceTableRef
51
51
  });
52
52
  };
53
+ var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(state, action) {
54
+ return _objectSpread(_objectSpread({}, state), {}, {
55
+ resolvedToolbarAttributesByUrl: _objectSpread(_objectSpread({}, state.resolvedToolbarAttributesByUrl), {}, _defineProperty({}, action.url, action.attributes))
56
+ });
57
+ };
53
58
  var setCardLayoutDatasourceTableRef = function setCardLayoutDatasourceTableRef(state, action) {
54
59
  return _objectSpread(_objectSpread({}, state), {}, {
55
60
  datasourceTableRef: action.datasourceTableRef,
@@ -124,6 +129,8 @@ export default (function (state, action) {
124
129
  return registerEvents(state, action);
125
130
  case 'SET_DATASOURCE_TABLE_REF':
126
131
  return setDatasourceTableRef(state, action);
132
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
133
+ return setResolvedToolbarAttributes(state, action);
127
134
  case 'SET_CARD_LAYOUT':
128
135
  return setCardLayout(state, action);
129
136
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -61,9 +61,7 @@ export var isEmbedSupportedAtPosition = function isEmbedSupportedAtPosition(curr
61
61
  export var isBlockSupportedAtPosition = function isBlockSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
62
62
  return isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
63
63
  };
64
- export var getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store
65
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
66
- ) {
64
+ export var getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store) {
67
65
  if (!store) {
68
66
  return {};
69
67
  }
@@ -18,8 +18,10 @@ import React from 'react';
18
18
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
19
19
  import { jsx } from '@emotion/react';
20
20
  import { calcColumnsFromPx, calcMediaPxWidth, calcPctFromPx, calcPxFromColumns, handleSides, imageAlignmentMap, Resizer, snapTo, wrappedLayouts, wrapperStyle } from '@atlaskit/editor-common/ui';
21
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
21
22
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
22
23
  import { akEditorBreakoutPadding, akEditorMediaResizeHandlerPadding, akEditorWideLayoutWidth, breakoutWideScaleRatio, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
24
+ import { fg } from '@atlaskit/platform-feature-flags';
23
25
  import { embedHeaderHeight } from '@atlaskit/smart-card';
24
26
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
25
27
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -97,6 +99,19 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
97
99
  resizedPctWidth: resizedPctWidth
98
100
  });
99
101
  });
102
+ _defineProperty(_this, "handleResizeStart", function () {
103
+ var _this$props3 = _this.props,
104
+ view = _this$props3.view,
105
+ getPos = _this$props3.getPos;
106
+ if (typeof getPos === 'function') {
107
+ var pos = getPos();
108
+ if (typeof pos === 'number') {
109
+ var tr = view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos));
110
+ tr.setMeta('scrollIntoView', false);
111
+ view.dispatch(tr);
112
+ }
113
+ }
114
+ });
100
115
  _defineProperty(_this, "highlights", function (newWidth, snapPoints) {
101
116
  var snapWidth = snapTo(newWidth, snapPoints);
102
117
  var _this$props$view$stat = _this.props.view.state.schema.nodes,
@@ -113,10 +128,10 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
113
128
  if (snapWidth > _this.wideLayoutWidth) {
114
129
  return ['full-width'];
115
130
  }
116
- var _this$props3 = _this.props,
117
- layout = _this$props3.layout,
118
- lineLength = _this$props3.lineLength,
119
- gridSize = _this$props3.gridSize;
131
+ var _this$props4 = _this.props,
132
+ layout = _this$props4.layout,
133
+ lineLength = _this$props4.lineLength,
134
+ gridSize = _this$props4.gridSize;
120
135
  var columns = calcColumnsFromPx(snapWidth, lineLength, gridSize);
121
136
  var columnWidth = Math.round(columns);
122
137
  var highlight = [];
@@ -227,9 +242,9 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
227
242
  key: "calcSnapPoints",
228
243
  value: function calcSnapPoints() {
229
244
  var offsetLeft = this.state.offsetLeft;
230
- var _this$props4 = this.props,
231
- containerWidth = _this$props4.containerWidth,
232
- lineLength = _this$props4.lineLength;
245
+ var _this$props5 = this.props,
246
+ containerWidth = _this$props5.containerWidth,
247
+ lineLength = _this$props5.lineLength;
233
248
  var snapTargets = [];
234
249
  for (var i = 0; i < this.gridWidth; i++) {
235
250
  snapTargets.push(calcPxFromColumns(i, lineLength, this.gridWidth) - offsetLeft);
@@ -279,9 +294,9 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
279
294
  * and hence we use `style` prop.
280
295
  */
281
296
  function getHeightDefiningComponent() {
282
- var _this$props5 = this.props,
283
- height = _this$props5.height,
284
- aspectRatio = _this$props5.aspectRatio;
297
+ var _this$props6 = this.props,
298
+ height = _this$props6.height,
299
+ aspectRatio = _this$props6.aspectRatio;
285
300
  var heightDefiningStyles;
286
301
  if (height) {
287
302
  heightDefiningStyles = {
@@ -325,13 +340,13 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
325
340
  key: "render",
326
341
  value: function render() {
327
342
  var _this2 = this;
328
- var _this$props6 = this.props,
329
- layout = _this$props6.layout,
330
- pctWidth = _this$props6.pctWidth,
331
- containerWidth = _this$props6.containerWidth,
332
- fullWidthMode = _this$props6.fullWidthMode,
333
- isResizeDisabled = _this$props6.isResizeDisabled,
334
- children = _this$props6.children;
343
+ var _this$props7 = this.props,
344
+ layout = _this$props7.layout,
345
+ pctWidth = _this$props7.pctWidth,
346
+ containerWidth = _this$props7.containerWidth,
347
+ fullWidthMode = _this$props7.fullWidthMode,
348
+ isResizeDisabled = _this$props7.isResizeDisabled,
349
+ children = _this$props7.children;
335
350
  var resizerProps = {
336
351
  width: this.calcPxWidth(),
337
352
  innerPadding: akEditorMediaResizeHandlerPadding
@@ -386,6 +401,7 @@ var ResizableEmbedCard = /*#__PURE__*/function (_React$Component) {
386
401
  scaleFactor: !this.wrappedLayout && !this.insideInlineLike ? 2 : 1,
387
402
  highlights: this.highlights,
388
403
  nodeType: "embed",
404
+ onResizeStart: editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_9') ? this.handleResizeStart : undefined,
389
405
  handleStyles: nestedInTableHandleStyles(this.isNestedInTable())
390
406
  // Ignored via go/ees005
391
407
  // eslint-disable-next-line react/jsx-props-no-spreading
@@ -4,29 +4,46 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React, { useEffect } from 'react';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
6
6
  import { useSmartLinkContext } from '@atlaskit/link-provider';
7
+ import { setResolvedToolbarAttributes } from '../pm-plugins/actions';
8
+ import { getPluginState } from '../pm-plugins/util/state';
7
9
  import { getResolvedAttributesFromStore } from '../pm-plugins/utils';
8
10
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
11
+ var areResolvedAttributesEqual = function areResolvedAttributesEqual(current, next) {
12
+ return (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
13
+ };
14
+
9
15
  /**
10
16
  * Handles firing the toolbar viewed event
11
17
  */
12
18
  var ToolbarViewedEventBase = function ToolbarViewedEventBase(_ref) {
13
19
  var url = _ref.url,
14
20
  display = _ref.display,
15
- cardContext = _ref.cardContext;
21
+ cardContext = _ref.cardContext,
22
+ editorView = _ref.editorView;
16
23
  var _useAnalyticsEvents = useAnalyticsEvents(),
17
24
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
18
25
  var store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
19
26
  useEffect(function () {
27
+ var _getPluginState;
28
+ var resolvedAttributes = getResolvedAttributesFromStore(url, display, store);
20
29
  createAnalyticsEvent({
21
30
  action: 'viewed',
22
31
  actionSubject: 'inlineDialog',
23
32
  actionSubjectId: 'editLinkToolbar',
24
33
  eventType: 'ui',
25
- attributes: _objectSpread(_objectSpread({}, getResolvedAttributesFromStore(url, display, store)), {}, {
34
+ attributes: _objectSpread(_objectSpread({}, resolvedAttributes), {}, {
26
35
  display: display
27
36
  })
28
37
  }).fire('media');
29
- }, [createAnalyticsEvent, display, url, store]);
38
+ if (!editorView) {
39
+ return;
40
+ }
41
+ var currentResolvedAttributes = (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
42
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
43
+ return;
44
+ }
45
+ editorView.dispatch(setResolvedToolbarAttributes(url, resolvedAttributes)(editorView.state.tr));
46
+ }, [createAnalyticsEvent, display, editorView, url, store]);
30
47
  return null;
31
48
  };
32
49
 
@@ -43,6 +60,7 @@ export var ToolbarViewedEvent = function ToolbarViewedEvent(_ref2) {
43
60
  }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
44
61
  url: url,
45
62
  display: display,
46
- cardContext: cardContext
63
+ cardContext: cardContext,
64
+ editorView: editorView
47
65
  }) : null);
48
66
  };
@@ -22,6 +22,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
22
22
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
23
23
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
24
24
  import CogIcon from '@atlaskit/icon/core/settings';
25
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
25
26
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
26
27
  import { changeSelectedCardToText } from '../pm-plugins/doc';
27
28
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -76,6 +77,30 @@ export var visitCardLinkAnalytics = function visitCardLinkAnalytics(editorAnalyt
76
77
  return true;
77
78
  };
78
79
  };
80
+ var fireOpenLinkToolbarAnalytics = function fireOpenLinkToolbarAnalytics(editorAnalyticsApi, inputMethod) {
81
+ var resolvedAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
82
+ return function (state, dispatch) {
83
+ var linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
84
+ if (!linkAnalyticsRecorded) {
85
+ return false;
86
+ }
87
+ if (expValEquals('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
88
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.fireAnalyticsEvent({
89
+ action: ACTION.CLICKED,
90
+ actionSubject: ACTION_SUBJECT.BUTTON,
91
+ actionSubjectId: ACTION_SUBJECTID.OPEN_LINK,
92
+ attributes: {
93
+ displayCategory: resolvedAttributes.displayCategory,
94
+ extensionKey: resolvedAttributes.extensionKey,
95
+ status: resolvedAttributes.status,
96
+ statusDetails: resolvedAttributes.statusDetails
97
+ },
98
+ eventType: EVENT_TYPE.UI
99
+ });
100
+ }
101
+ return true;
102
+ };
103
+ };
79
104
  export var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
80
105
  return function (state, dispatch) {
81
106
  if (!(state.selection instanceof NodeSelection)) {
@@ -252,7 +277,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
252
277
  } else if (shouldRenderDatasourceToolbar) {
253
278
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
254
279
  } else {
255
- var _pluginInjectionApi$c;
280
+ var _pluginInjectionApi$c, _pluginState$resolved;
256
281
  var inlineCard = state.schema.nodes.inlineCard;
257
282
  var editItems = cardOptions.allowDatasource ? [{
258
283
  type: 'custom',
@@ -334,7 +359,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
334
359
  });
335
360
  }
336
361
  }] : [];
337
- var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [{
362
+ var resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
363
+ var openLinkToolbarItem = {
338
364
  id: 'editor.link.openLink',
339
365
  type: 'button',
340
366
  icon: LinkExternalIcon,
@@ -342,10 +368,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
342
368
  metadata: metadata,
343
369
  className: 'hyperlink-open-link',
344
370
  title: intl.formatMessage(linkMessages.openLink),
345
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
371
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
346
372
  href: url,
347
373
  target: '_blank'
348
- }, {
374
+ };
375
+ var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [openLinkToolbarItem, {
349
376
  type: 'separator'
350
377
  }], _toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
351
378
  type: 'copy-button',
@@ -374,18 +401,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
374
401
  }]) : [].concat(editButtonItems, _toConsumableArray([].concat(_toConsumableArray(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
375
402
  type: 'separator',
376
403
  fullHeight: true
377
- }])), openPreviewPanelItems, [{
378
- id: 'editor.link.openLink',
379
- type: 'button',
380
- icon: LinkExternalIcon,
381
- iconFallback: LinkExternalIcon,
382
- metadata: metadata,
383
- className: 'hyperlink-open-link',
384
- title: intl.formatMessage(linkMessages.openLink),
385
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
386
- href: url,
387
- target: '_blank'
388
- }], _toConsumableArray(commentItems.length > 1 ? [{
404
+ }])), openPreviewPanelItems, [openLinkToolbarItem], _toConsumableArray(commentItems.length > 1 ? [{
389
405
  type: 'separator',
390
406
  fullHeight: true
391
407
  }, commentItems[0]] : commentItems));
@@ -525,8 +541,9 @@ export var getSettingsButton = function getSettingsButton(intl, editorAnalyticsA
525
541
  };
526
542
  };
527
543
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) {
528
- var _node$attrs2;
544
+ var _node$attrs2, _node$attrs3;
529
545
  var toolbarItems = [];
546
+ toolbarItems.push.apply(toolbarItems, _toConsumableArray(getToolbarViewedItem(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url')));
530
547
  var areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
531
548
  var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
532
549
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -598,6 +615,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
598
615
  }
599
616
  }
600
617
  var openLinkInputMethod = INPUT_METHOD.FLOATING_TB;
618
+ var pluginState = pluginKey.getState(state);
601
619
  toolbarItems.push({
602
620
  type: 'custom',
603
621
  fallback: [],
@@ -616,7 +634,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
616
634
  });
617
635
  }
618
636
  });
619
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
637
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
638
+ var _pluginState$resolved2;
620
639
  toolbarItems.push({
621
640
  id: 'editor.link.openLink',
622
641
  type: 'button',
@@ -625,7 +644,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
625
644
  metadata: metadata,
626
645
  className: 'hyperlink-open-link',
627
646
  title: intl.formatMessage(linkMessages.openLink),
628
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
647
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
629
648
  href: node.attrs.url,
630
649
  target: '_blank'
631
650
  });
@@ -3,7 +3,7 @@ import type { DatasourceModalType } from '@atlaskit/editor-common/types';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
5
5
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
6
- import type { CardInfo, CardPluginAction, Request } from '../types';
6
+ import type { CardInfo, CardPluginAction, Request, ToolbarResolvedAttributes } from '../types';
7
7
  import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
8
8
  export declare const cardAction: (tr: Transaction, action: CardPluginAction) => Transaction;
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
@@ -14,6 +14,7 @@ export declare const registerRemoveOverlay: (callback: () => void, info?: CardIn
14
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
15
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
16
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
17
+ export declare const setResolvedToolbarAttributes: (url: string, attributes: ToolbarResolvedAttributes) => (tr: Transaction) => Transaction;
17
18
  export declare const setCardLayout: (layout: DatasourceTableLayout) => (tr: Transaction) => Transaction;
18
19
  export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTableRef, }: {
19
20
  datasourceTableRef?: HTMLElement;
@@ -6,7 +6,7 @@ import type { DatasourceModalType, EditorAppearance } from '@atlaskit/editor-com
6
6
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
8
8
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
9
- import type { CardPluginState, Request } from '../../types';
9
+ import type { CardPluginState, Request, ToolbarResolvedAttributes } from '../../types';
10
10
  import type { DatasourceTableLayout } from '../../ui/LayoutButton/types';
11
11
  export declare const getPluginState: (editorState: EditorState) => CardPluginState | undefined;
12
12
  export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState, tr: ReadonlyTransaction) => {
@@ -42,6 +42,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
42
42
  sourceEvent?: UIAnalyticsEvent | null | undefined;
43
43
  url: string;
44
44
  }[];
45
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
45
46
  selectedInlineLinkPosition?: number;
46
47
  showDatasourceModal: boolean;
47
48
  showLinkingToolbar: boolean;
@@ -4,7 +4,7 @@ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- import type { CardInfo, DatasourceNode } from '../types';
7
+ import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
8
8
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
9
9
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
10
10
  export type TitleUrlPair = {
@@ -22,7 +22,7 @@ export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleU
22
22
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
23
23
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
24
24
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
25
- export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => {};
25
+ export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => Partial<ToolbarResolvedAttributes>;
26
26
  export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
27
27
  /**
28
28
  * Typeguard that checks node attributes are datasource node attributes
@@ -20,6 +20,12 @@ export type CardInfo = {
20
20
  title?: string;
21
21
  url?: string;
22
22
  };
23
+ export type ToolbarResolvedAttributes = {
24
+ displayCategory?: 'smartLink' | 'link';
25
+ extensionKey?: string | null;
26
+ status?: string | null;
27
+ statusDetails?: string | null;
28
+ };
23
29
  export type Request = {
24
30
  /**
25
31
  * Analytics action to be used when disaptching
@@ -95,6 +101,7 @@ export type CardPluginState = {
95
101
  provider: CardProvider | null;
96
102
  removeOverlay?: () => void;
97
103
  requests: Request[];
104
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
98
105
  selectedInlineLinkPosition?: number;
99
106
  showDatasourceModal: boolean;
100
107
  showLinkingToolbar: boolean;
@@ -156,6 +163,11 @@ export type SetDatasourceTableRef = {
156
163
  datasourceTableRef?: HTMLElement;
157
164
  type: 'SET_DATASOURCE_TABLE_REF';
158
165
  };
166
+ export type SetResolvedToolbarAttributes = {
167
+ attributes: ToolbarResolvedAttributes;
168
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES';
169
+ url: string;
170
+ };
159
171
  export type SetCardLayout = {
160
172
  layout: DatasourceTableLayout;
161
173
  type: 'SET_CARD_LAYOUT';
@@ -184,5 +196,5 @@ export type RemoveDatasourceStash = {
184
196
  type: 'REMOVE_DATASOURCE_STASH';
185
197
  url: string;
186
198
  };
187
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
199
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetResolvedToolbarAttributes | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
188
200
  export {};
@@ -47,6 +47,7 @@ export default class ResizableEmbedCard extends React.Component<Props, State> {
47
47
  calcSnapPoints(): number[];
48
48
  calcPxWidth: (useLayout?: RichMediaLayout) => number;
49
49
  get insideInlineLike(): boolean;
50
+ private handleResizeStart;
50
51
  highlights: (newWidth: number, snapPoints: number[]) => string[] | number[];
51
52
  /**
52
53
  * Previously height of the box was controlled with paddingTop/paddingBottom trick inside Wrapper.
@@ -3,7 +3,7 @@ import type { DatasourceModalType } from '@atlaskit/editor-common/types';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
5
5
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
6
- import type { CardInfo, CardPluginAction, Request } from '../types';
6
+ import type { CardInfo, CardPluginAction, Request, ToolbarResolvedAttributes } from '../types';
7
7
  import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
8
8
  export declare const cardAction: (tr: Transaction, action: CardPluginAction) => Transaction;
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
@@ -14,6 +14,7 @@ export declare const registerRemoveOverlay: (callback: () => void, info?: CardIn
14
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
15
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
16
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
17
+ export declare const setResolvedToolbarAttributes: (url: string, attributes: ToolbarResolvedAttributes) => (tr: Transaction) => Transaction;
17
18
  export declare const setCardLayout: (layout: DatasourceTableLayout) => (tr: Transaction) => Transaction;
18
19
  export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTableRef, }: {
19
20
  datasourceTableRef?: HTMLElement;
@@ -6,7 +6,7 @@ import type { DatasourceModalType, EditorAppearance } from '@atlaskit/editor-com
6
6
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { DatasourceAdfView } from '@atlaskit/linking-common';
8
8
  import type { SmartLinkEvents } from '@atlaskit/smart-card';
9
- import type { CardPluginState, Request } from '../../types';
9
+ import type { CardPluginState, Request, ToolbarResolvedAttributes } from '../../types';
10
10
  import type { DatasourceTableLayout } from '../../ui/LayoutButton/types';
11
11
  export declare const getPluginState: (editorState: EditorState) => CardPluginState | undefined;
12
12
  export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState, tr: ReadonlyTransaction) => {
@@ -42,6 +42,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
42
42
  sourceEvent?: UIAnalyticsEvent | null | undefined;
43
43
  url: string;
44
44
  }[];
45
+ resolvedToolbarAttributesByUrl: Record<string, ToolbarResolvedAttributes>;
45
46
  selectedInlineLinkPosition?: number;
46
47
  showDatasourceModal: boolean;
47
48
  showLinkingToolbar: boolean;
@@ -4,7 +4,7 @@ import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { CardContext } from '@atlaskit/link-provider';
7
- import type { CardInfo, DatasourceNode } from '../types';
7
+ import type { CardInfo, DatasourceNode, ToolbarResolvedAttributes } from '../types';
8
8
  export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
9
9
  export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
10
10
  export type TitleUrlPair = {
@@ -22,7 +22,7 @@ export declare const displayInfoForCard: (node: Node, info?: CardInfo) => TitleU
22
22
  export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
23
23
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
24
24
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
25
- export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => {};
25
+ export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext["store"]) => Partial<ToolbarResolvedAttributes>;
26
26
  export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
27
27
  /**
28
28
  * Typeguard that checks node attributes are datasource node attributes