@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 14.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`24dad72901730`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/24dad72901730) -
8
+ Editor-6083: Fix border no shown when resize embed inside synced block
9
+ - Updated dependencies
10
+
11
+ ## 14.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`1bd6f56c55358`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bd6f56c55358) -
16
+ Add gated analytics for Smart Link go-to-link actions, including extensionKey, status, and
17
+ statusDetails, with supporting editor/card test updates.
18
+ - Updated dependencies
19
+
3
20
  ## 14.0.0
4
21
 
5
22
  ### Major Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
6
+ exports.showLinkToolbar = exports.showDatasourceModal = exports.setResolvedToolbarAttributes = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
7
7
  var _pluginKey = require("./plugin-key");
8
8
  var cardAction = exports.cardAction = function cardAction(tr, action) {
9
9
  return tr.setMeta(_pluginKey.pluginKey, action);
@@ -73,6 +73,15 @@ var setDatasourceTableRef = exports.setDatasourceTableRef = function setDatasour
73
73
  });
74
74
  };
75
75
  };
76
+ var setResolvedToolbarAttributes = exports.setResolvedToolbarAttributes = function setResolvedToolbarAttributes(url, attributes) {
77
+ return function (tr) {
78
+ return cardAction(tr, {
79
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
80
+ url: url,
81
+ attributes: attributes
82
+ });
83
+ };
84
+ };
76
85
  var setCardLayout = exports.setCardLayout = function setCardLayout(layout) {
77
86
  return function (tr) {
78
87
  return cardAction(tr, {
@@ -82,6 +82,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
82
82
  provider: null,
83
83
  cards: [],
84
84
  datasourceStash: {},
85
+ resolvedToolbarAttributesByUrl: {},
85
86
  showLinkingToolbar: false,
86
87
  smartLinkEvents: undefined,
87
88
  editorAppearance: editorAppearance,
@@ -57,6 +57,11 @@ var setDatasourceTableRef = function setDatasourceTableRef(state, action) {
57
57
  datasourceTableRef: action.datasourceTableRef
58
58
  });
59
59
  };
60
+ var setResolvedToolbarAttributes = function setResolvedToolbarAttributes(state, action) {
61
+ return _objectSpread(_objectSpread({}, state), {}, {
62
+ resolvedToolbarAttributesByUrl: _objectSpread(_objectSpread({}, state.resolvedToolbarAttributesByUrl), {}, (0, _defineProperty2.default)({}, action.url, action.attributes))
63
+ });
64
+ };
60
65
  var setCardLayoutDatasourceTableRef = function setCardLayoutDatasourceTableRef(state, action) {
61
66
  return _objectSpread(_objectSpread({}, state), {}, {
62
67
  datasourceTableRef: action.datasourceTableRef,
@@ -131,6 +136,8 @@ var _default = exports.default = function _default(state, action) {
131
136
  return registerEvents(state, action);
132
137
  case 'SET_DATASOURCE_TABLE_REF':
133
138
  return setDatasourceTableRef(state, action);
139
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
140
+ return setResolvedToolbarAttributes(state, action);
134
141
  case 'SET_CARD_LAYOUT':
135
142
  return setCardLayout(state, action);
136
143
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -68,9 +68,7 @@ var isEmbedSupportedAtPosition = exports.isEmbedSupportedAtPosition = function i
68
68
  var isBlockSupportedAtPosition = exports.isBlockSupportedAtPosition = function isBlockSupportedAtPosition(currentNodePosition, editorState, currentAppearance) {
69
69
  return isAppearanceSupportedInParent(currentNodePosition, editorState, _model.Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
70
70
  };
71
- var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store
72
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
73
- ) {
71
+ var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = function getResolvedAttributesFromStore(url, display, store) {
74
72
  if (!store) {
75
73
  return {};
76
74
  }
@@ -15,8 +15,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
  var _react = _interopRequireDefault(require("react"));
16
16
  var _react2 = require("@emotion/react");
17
17
  var _ui = require("@atlaskit/editor-common/ui");
18
+ var _state = require("@atlaskit/editor-prosemirror/state");
18
19
  var _utils = require("@atlaskit/editor-prosemirror/utils");
19
20
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
22
  var _smartCard = require("@atlaskit/smart-card");
21
23
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
22
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -101,6 +103,19 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
101
103
  resizedPctWidth: resizedPctWidth
102
104
  });
103
105
  });
106
+ (0, _defineProperty2.default)(_this, "handleResizeStart", function () {
107
+ var _this$props3 = _this.props,
108
+ view = _this$props3.view,
109
+ getPos = _this$props3.getPos;
110
+ if (typeof getPos === 'function') {
111
+ var pos = getPos();
112
+ if (typeof pos === 'number') {
113
+ var tr = view.state.tr.setSelection(_state.NodeSelection.create(view.state.doc, pos));
114
+ tr.setMeta('scrollIntoView', false);
115
+ view.dispatch(tr);
116
+ }
117
+ }
118
+ });
104
119
  (0, _defineProperty2.default)(_this, "highlights", function (newWidth, snapPoints) {
105
120
  var snapWidth = (0, _ui.snapTo)(newWidth, snapPoints);
106
121
  var _this$props$view$stat = _this.props.view.state.schema.nodes,
@@ -117,10 +132,10 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
117
132
  if (snapWidth > _this.wideLayoutWidth) {
118
133
  return ['full-width'];
119
134
  }
120
- var _this$props3 = _this.props,
121
- layout = _this$props3.layout,
122
- lineLength = _this$props3.lineLength,
123
- gridSize = _this$props3.gridSize;
135
+ var _this$props4 = _this.props,
136
+ layout = _this$props4.layout,
137
+ lineLength = _this$props4.lineLength,
138
+ gridSize = _this$props4.gridSize;
124
139
  var columns = (0, _ui.calcColumnsFromPx)(snapWidth, lineLength, gridSize);
125
140
  var columnWidth = Math.round(columns);
126
141
  var highlight = [];
@@ -231,9 +246,9 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
231
246
  key: "calcSnapPoints",
232
247
  value: function calcSnapPoints() {
233
248
  var offsetLeft = this.state.offsetLeft;
234
- var _this$props4 = this.props,
235
- containerWidth = _this$props4.containerWidth,
236
- lineLength = _this$props4.lineLength;
249
+ var _this$props5 = this.props,
250
+ containerWidth = _this$props5.containerWidth,
251
+ lineLength = _this$props5.lineLength;
237
252
  var snapTargets = [];
238
253
  for (var i = 0; i < this.gridWidth; i++) {
239
254
  snapTargets.push((0, _ui.calcPxFromColumns)(i, lineLength, this.gridWidth) - offsetLeft);
@@ -283,9 +298,9 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
283
298
  * and hence we use `style` prop.
284
299
  */
285
300
  function getHeightDefiningComponent() {
286
- var _this$props5 = this.props,
287
- height = _this$props5.height,
288
- aspectRatio = _this$props5.aspectRatio;
301
+ var _this$props6 = this.props,
302
+ height = _this$props6.height,
303
+ aspectRatio = _this$props6.aspectRatio;
289
304
  var heightDefiningStyles;
290
305
  if (height) {
291
306
  heightDefiningStyles = {
@@ -329,13 +344,13 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
329
344
  key: "render",
330
345
  value: function render() {
331
346
  var _this2 = this;
332
- var _this$props6 = this.props,
333
- layout = _this$props6.layout,
334
- pctWidth = _this$props6.pctWidth,
335
- containerWidth = _this$props6.containerWidth,
336
- fullWidthMode = _this$props6.fullWidthMode,
337
- isResizeDisabled = _this$props6.isResizeDisabled,
338
- children = _this$props6.children;
347
+ var _this$props7 = this.props,
348
+ layout = _this$props7.layout,
349
+ pctWidth = _this$props7.pctWidth,
350
+ containerWidth = _this$props7.containerWidth,
351
+ fullWidthMode = _this$props7.fullWidthMode,
352
+ isResizeDisabled = _this$props7.isResizeDisabled,
353
+ children = _this$props7.children;
339
354
  var resizerProps = {
340
355
  width: this.calcPxWidth(),
341
356
  innerPadding: _editorSharedStyles.akEditorMediaResizeHandlerPadding
@@ -390,6 +405,7 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
390
405
  scaleFactor: !this.wrappedLayout && !this.insideInlineLike ? 2 : 1,
391
406
  highlights: this.highlights,
392
407
  nodeType: "embed",
408
+ onResizeStart: (0, _experiments.editorExperiment)('platform_synced_block', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_9') ? this.handleResizeStart : undefined,
393
409
  handleStyles: nestedInTableHandleStyles(this.isNestedInTable())
394
410
  // Ignored via go/ees005
395
411
  // eslint-disable-next-line react/jsx-props-no-spreading
@@ -10,32 +10,49 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _useAnalyticsEvents2 = require("@atlaskit/analytics-next/useAnalyticsEvents");
12
12
  var _linkProvider = require("@atlaskit/link-provider");
13
+ var _actions = require("../pm-plugins/actions");
14
+ var _state = require("../pm-plugins/util/state");
13
15
  var _utils = require("../pm-plugins/utils");
14
16
  var _EditorAnalyticsContext = require("./EditorAnalyticsContext");
15
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ var areResolvedAttributesEqual = function areResolvedAttributesEqual(current, next) {
21
+ return (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
22
+ };
23
+
18
24
  /**
19
25
  * Handles firing the toolbar viewed event
20
26
  */
21
27
  var ToolbarViewedEventBase = function ToolbarViewedEventBase(_ref) {
22
28
  var url = _ref.url,
23
29
  display = _ref.display,
24
- cardContext = _ref.cardContext;
30
+ cardContext = _ref.cardContext,
31
+ editorView = _ref.editorView;
25
32
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
26
33
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
27
34
  var store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
28
35
  (0, _react.useEffect)(function () {
36
+ var _getPluginState;
37
+ var resolvedAttributes = (0, _utils.getResolvedAttributesFromStore)(url, display, store);
29
38
  createAnalyticsEvent({
30
39
  action: 'viewed',
31
40
  actionSubject: 'inlineDialog',
32
41
  actionSubjectId: 'editLinkToolbar',
33
42
  eventType: 'ui',
34
- attributes: _objectSpread(_objectSpread({}, (0, _utils.getResolvedAttributesFromStore)(url, display, store)), {}, {
43
+ attributes: _objectSpread(_objectSpread({}, resolvedAttributes), {}, {
35
44
  display: display
36
45
  })
37
46
  }).fire('media');
38
- }, [createAnalyticsEvent, display, url, store]);
47
+ if (!editorView) {
48
+ return;
49
+ }
50
+ var currentResolvedAttributes = (_getPluginState = (0, _state.getPluginState)(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
51
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
52
+ return;
53
+ }
54
+ editorView.dispatch((0, _actions.setResolvedToolbarAttributes)(url, resolvedAttributes)(editorView.state.tr));
55
+ }, [createAnalyticsEvent, display, editorView, url, store]);
39
56
  return null;
40
57
  };
41
58
 
@@ -52,6 +69,7 @@ var ToolbarViewedEvent = exports.ToolbarViewedEvent = function ToolbarViewedEven
52
69
  }, url ? /*#__PURE__*/_react.default.createElement(ToolbarViewedEventBase, {
53
70
  url: url,
54
71
  display: display,
55
- cardContext: cardContext
72
+ cardContext: cardContext,
73
+ editorView: editorView
56
74
  }) : null);
57
75
  };
@@ -28,6 +28,7 @@ var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
28
28
  var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
29
29
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
30
30
  var _settings = _interopRequireDefault(require("@atlaskit/icon/core/settings"));
31
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
31
32
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
32
33
  var _doc = require("../pm-plugins/doc");
33
34
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -85,6 +86,30 @@ var visitCardLinkAnalytics = exports.visitCardLinkAnalytics = function visitCard
85
86
  return true;
86
87
  };
87
88
  };
89
+ var fireOpenLinkToolbarAnalytics = function fireOpenLinkToolbarAnalytics(editorAnalyticsApi, inputMethod) {
90
+ var resolvedAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
91
+ return function (state, dispatch) {
92
+ var linkAnalyticsRecorded = visitCardLinkAnalytics(editorAnalyticsApi, inputMethod)(state, dispatch);
93
+ if (!linkAnalyticsRecorded) {
94
+ return false;
95
+ }
96
+ if ((0, _expValEquals.expValEquals)('cc_integrations_editor_open_link_click_analytics', 'isEnabled', true)) {
97
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.fireAnalyticsEvent({
98
+ action: _analytics.ACTION.CLICKED,
99
+ actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
100
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.OPEN_LINK,
101
+ attributes: {
102
+ displayCategory: resolvedAttributes.displayCategory,
103
+ extensionKey: resolvedAttributes.extensionKey,
104
+ status: resolvedAttributes.status,
105
+ statusDetails: resolvedAttributes.statusDetails
106
+ },
107
+ eventType: _analytics.EVENT_TYPE.UI
108
+ });
109
+ }
110
+ return true;
111
+ };
112
+ };
88
113
  var openLinkSettings = exports.openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
89
114
  return function (state, dispatch) {
90
115
  if (!(state.selection instanceof _state2.NodeSelection)) {
@@ -261,7 +286,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
261
286
  } else if (shouldRenderDatasourceToolbar) {
262
287
  return getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, node.attrs.datasource.id, state, cardOptions, currentAppearance, pluginInjectionApi);
263
288
  } else {
264
- var _pluginInjectionApi$c;
289
+ var _pluginInjectionApi$c, _pluginState$resolved;
265
290
  var inlineCard = state.schema.nodes.inlineCard;
266
291
  var editItems = cardOptions.allowDatasource ? [{
267
292
  type: 'custom',
@@ -343,7 +368,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
343
368
  });
344
369
  }
345
370
  }] : [];
346
- var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [{
371
+ var resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
372
+ var openLinkToolbarItem = {
347
373
  id: 'editor.link.openLink',
348
374
  type: 'button',
349
375
  icon: _linkExternal.default,
@@ -351,10 +377,11 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
351
377
  metadata: metadata,
352
378
  className: 'hyperlink-open-link',
353
379
  title: intl.formatMessage(_messages.linkMessages.openLink),
354
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
380
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
355
381
  href: url,
356
382
  target: '_blank'
357
- }, {
383
+ };
384
+ var toolbarItems = areAllNewToolbarFlagsDisabled ? [].concat(editItems, commentItems, openPreviewPanelItems, [openLinkToolbarItem, {
358
385
  type: 'separator'
359
386
  }], (0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
360
387
  type: 'copy-button',
@@ -383,18 +410,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
383
410
  }]) : [].concat(editButtonItems, (0, _toConsumableArray2.default)([].concat((0, _toConsumableArray2.default)(getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled)), [{
384
411
  type: 'separator',
385
412
  fullHeight: true
386
- }])), openPreviewPanelItems, [{
387
- id: 'editor.link.openLink',
388
- type: 'button',
389
- icon: _linkExternal.default,
390
- iconFallback: _linkExternal.default,
391
- metadata: metadata,
392
- className: 'hyperlink-open-link',
393
- title: intl.formatMessage(_messages.linkMessages.openLink),
394
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
395
- href: url,
396
- target: '_blank'
397
- }], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
413
+ }])), openPreviewPanelItems, [openLinkToolbarItem], (0, _toConsumableArray2.default)(commentItems.length > 1 ? [{
398
414
  type: 'separator',
399
415
  fullHeight: true
400
416
  }, commentItems[0]] : commentItems));
@@ -534,8 +550,9 @@ var getSettingsButton = exports.getSettingsButton = function getSettingsButton(i
534
550
  };
535
551
  };
536
552
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, pluginInjectionApi) {
537
- var _node$attrs2;
553
+ var _node$attrs2, _node$attrs3;
538
554
  var toolbarItems = [];
555
+ toolbarItems.push.apply(toolbarItems, (0, _toConsumableArray2.default)(getToolbarViewedItem(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url')));
539
556
  var areAllNewToolbarFlagsDisabled = !(0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
540
557
  var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
541
558
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
@@ -607,6 +624,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
607
624
  }
608
625
  }
609
626
  var openLinkInputMethod = _analytics.INPUT_METHOD.FLOATING_TB;
627
+ var pluginState = _pluginKey.pluginKey.getState(state);
610
628
  toolbarItems.push({
611
629
  type: 'custom',
612
630
  fallback: [],
@@ -625,7 +643,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
625
643
  });
626
644
  }
627
645
  });
628
- if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
646
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
647
+ var _pluginState$resolved2;
629
648
  toolbarItems.push({
630
649
  id: 'editor.link.openLink',
631
650
  type: 'button',
@@ -634,7 +653,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
634
653
  metadata: metadata,
635
654
  className: 'hyperlink-open-link',
636
655
  title: intl.formatMessage(_messages.linkMessages.openLink),
637
- onClick: visitCardLinkAnalytics(editorAnalyticsApi, openLinkInputMethod),
656
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved2 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved2 !== void 0 ? _pluginState$resolved2 : {}),
638
657
  href: node.attrs.url,
639
658
  target: '_blank'
640
659
  });
@@ -35,6 +35,11 @@ export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr,
35
35
  type: 'SET_DATASOURCE_TABLE_REF',
36
36
  datasourceTableRef
37
37
  });
38
+ export const setResolvedToolbarAttributes = (url, attributes) => tr => cardAction(tr, {
39
+ type: 'SET_RESOLVED_TOOLBAR_ATTRIBUTES',
40
+ url,
41
+ attributes
42
+ });
38
43
  export const setCardLayout = layout => tr => cardAction(tr, {
39
44
  type: 'SET_CARD_LAYOUT',
40
45
  layout
@@ -72,6 +72,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
72
72
  provider: null,
73
73
  cards: [],
74
74
  datasourceStash: {},
75
+ resolvedToolbarAttributesByUrl: {},
75
76
  showLinkingToolbar: false,
76
77
  smartLinkEvents: undefined,
77
78
  editorAppearance,
@@ -46,6 +46,15 @@ const setDatasourceTableRef = (state, action) => {
46
46
  datasourceTableRef: action.datasourceTableRef
47
47
  };
48
48
  };
49
+ const setResolvedToolbarAttributes = (state, action) => {
50
+ return {
51
+ ...state,
52
+ resolvedToolbarAttributesByUrl: {
53
+ ...state.resolvedToolbarAttributesByUrl,
54
+ [action.url]: action.attributes
55
+ }
56
+ };
57
+ };
49
58
  const setCardLayoutDatasourceTableRef = (state, action) => {
50
59
  return {
51
60
  ...state,
@@ -132,6 +141,8 @@ export default ((state, action) => {
132
141
  return registerEvents(state, action);
133
142
  case 'SET_DATASOURCE_TABLE_REF':
134
143
  return setDatasourceTableRef(state, action);
144
+ case 'SET_RESOLVED_TOOLBAR_ATTRIBUTES':
145
+ return setResolvedToolbarAttributes(state, action);
135
146
  case 'SET_CARD_LAYOUT':
136
147
  return setCardLayout(state, action);
137
148
  case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
@@ -54,9 +54,7 @@ const isAppearanceSupportedInParent = (currentNodePosition, editorState, fragmen
54
54
  };
55
55
  export const isEmbedSupportedAtPosition = (currentNodePosition, editorState, currentAppearance) => isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.embedCard.createChecked({})), currentAppearance);
56
56
  export const isBlockSupportedAtPosition = (currentNodePosition, editorState, currentAppearance) => isAppearanceSupportedInParent(currentNodePosition, editorState, Fragment.from(editorState.schema.nodes.blockCard.createChecked({})), currentAppearance);
57
- export const getResolvedAttributesFromStore = (url, display, store
58
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
59
- ) => {
57
+ export const getResolvedAttributesFromStore = (url, display, store) => {
60
58
  if (!store) {
61
59
  return {};
62
60
  }
@@ -9,8 +9,10 @@ import React from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
10
10
  import { jsx } from '@emotion/react';
11
11
  import { calcColumnsFromPx, calcMediaPxWidth, calcPctFromPx, calcPxFromColumns, handleSides, imageAlignmentMap, Resizer, snapTo, wrappedLayouts, wrapperStyle } from '@atlaskit/editor-common/ui';
12
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
13
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
13
14
  import { akEditorBreakoutPadding, akEditorMediaResizeHandlerPadding, akEditorWideLayoutWidth, breakoutWideScaleRatio, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
14
16
  import { embedHeaderHeight } from '@atlaskit/smart-card';
15
17
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
18
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -93,6 +95,20 @@ export default class ResizableEmbedCard extends React.Component {
93
95
  resizedPctWidth
94
96
  });
95
97
  });
98
+ _defineProperty(this, "handleResizeStart", () => {
99
+ const {
100
+ view,
101
+ getPos
102
+ } = this.props;
103
+ if (typeof getPos === 'function') {
104
+ const pos = getPos();
105
+ if (typeof pos === 'number') {
106
+ const tr = view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos));
107
+ tr.setMeta('scrollIntoView', false);
108
+ view.dispatch(tr);
109
+ }
110
+ }
111
+ });
96
112
  _defineProperty(this, "highlights", (newWidth, snapPoints) => {
97
113
  const snapWidth = snapTo(newWidth, snapPoints);
98
114
  const {
@@ -371,6 +387,7 @@ export default class ResizableEmbedCard extends React.Component {
371
387
  scaleFactor: !this.wrappedLayout && !this.insideInlineLike ? 2 : 1,
372
388
  highlights: this.highlights,
373
389
  nodeType: "embed",
390
+ onResizeStart: editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_9') ? this.handleResizeStart : undefined,
374
391
  handleStyles: nestedInTableHandleStyles(this.isNestedInTable())
375
392
  // Ignored via go/ees005
376
393
  // eslint-disable-next-line react/jsx-props-no-spreading
@@ -1,32 +1,47 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
3
3
  import { useSmartLinkContext } from '@atlaskit/link-provider';
4
+ import { setResolvedToolbarAttributes } from '../pm-plugins/actions';
5
+ import { getPluginState } from '../pm-plugins/util/state';
4
6
  import { getResolvedAttributesFromStore } from '../pm-plugins/utils';
5
7
  import { EditorAnalyticsContext } from './EditorAnalyticsContext';
8
+ const areResolvedAttributesEqual = (current, next) => (current === null || current === void 0 ? void 0 : current.displayCategory) === (next === null || next === void 0 ? void 0 : next.displayCategory) && (current === null || current === void 0 ? void 0 : current.extensionKey) === (next === null || next === void 0 ? void 0 : next.extensionKey) && (current === null || current === void 0 ? void 0 : current.status) === (next === null || next === void 0 ? void 0 : next.status) && (current === null || current === void 0 ? void 0 : current.statusDetails) === (next === null || next === void 0 ? void 0 : next.statusDetails);
9
+
6
10
  /**
7
11
  * Handles firing the toolbar viewed event
8
12
  */
9
13
  const ToolbarViewedEventBase = ({
10
14
  url,
11
15
  display,
12
- cardContext
16
+ cardContext,
17
+ editorView
13
18
  }) => {
14
19
  const {
15
20
  createAnalyticsEvent
16
21
  } = useAnalyticsEvents();
17
22
  const store = cardContext === null || cardContext === void 0 ? void 0 : cardContext.store;
18
23
  useEffect(() => {
24
+ var _getPluginState;
25
+ const resolvedAttributes = getResolvedAttributesFromStore(url, display, store);
19
26
  createAnalyticsEvent({
20
27
  action: 'viewed',
21
28
  actionSubject: 'inlineDialog',
22
29
  actionSubjectId: 'editLinkToolbar',
23
30
  eventType: 'ui',
24
31
  attributes: {
25
- ...getResolvedAttributesFromStore(url, display, store),
32
+ ...resolvedAttributes,
26
33
  display
27
34
  }
28
35
  }).fire('media');
29
- }, [createAnalyticsEvent, display, url, store]);
36
+ if (!editorView) {
37
+ return;
38
+ }
39
+ const currentResolvedAttributes = (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.resolvedToolbarAttributesByUrl[url];
40
+ if (areResolvedAttributesEqual(currentResolvedAttributes, resolvedAttributes)) {
41
+ return;
42
+ }
43
+ editorView.dispatch(setResolvedToolbarAttributes(url, resolvedAttributes)(editorView.state.tr));
44
+ }, [createAnalyticsEvent, display, editorView, url, store]);
30
45
  return null;
31
46
  };
32
47
 
@@ -44,6 +59,7 @@ export const ToolbarViewedEvent = ({
44
59
  }, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
45
60
  url: url,
46
61
  display: display,
47
- cardContext: cardContext
62
+ cardContext: cardContext,
63
+ editorView: editorView
48
64
  }) : null);
49
65
  };