@atlaskit/editor-plugin-table 15.0.10 → 15.0.12

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,24 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 15.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c0ef0bedb49c0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c0ef0bedb49c0) -
8
+ EDITOR-1391 only send table width information events if there are tables, add enums and boolean
9
+ values for table width, editor width and scrollbar existence for ingestion in signalfx
10
+ - Updated dependencies
11
+
12
+ ## 15.0.11
13
+
14
+ ### Patch Changes
15
+
16
+ - [`ef001bf65d48f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef001bf65d48f) -
17
+ Remove usage of `platform_editor_toolbar_aifc` inside editor packages - instead rely on checking
18
+ for new toolbar plugin option, make `enableNewToolbarExperience` mandatory for consumers to opt in
19
+ to new toolbar experience
20
+ - Updated dependencies
21
+
3
22
  ## 15.0.10
4
23
 
5
24
  ### Patch Changes
@@ -120,7 +120,7 @@ var selector = function selector(states) {
120
120
  };
121
121
  };
122
122
  var TableResizer = exports.TableResizer = function TableResizer(_ref) {
123
- var _editorView$state, _pluginInjectionApi$a2;
123
+ var _editorView$state, _pluginInjectionApi$a2, _pluginInjectionApi$u2;
124
124
  var children = _ref.children,
125
125
  width = _ref.width,
126
126
  maxWidth = _ref.maxWidth,
@@ -162,6 +162,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
162
162
  setSnappingEnabled = _useState2[1];
163
163
  var _useIntl = (0, _reactIntlNext.useIntl)(),
164
164
  formatMessage = _useIntl.formatMessage;
165
+ var isToolbarAIFCEnabled = Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar);
165
166
  var currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
166
167
  var tableFromSelection = (0, _react.useMemo)(function () {
167
168
  return (0, _utils.findTable)(currentSelection);
@@ -265,7 +266,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
265
266
  tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
266
267
  name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
267
268
  });
268
- if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true)) {
269
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
269
270
  var _pluginInjectionApi$u;
270
271
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u === void 0 || _pluginInjectionApi$u.commands.setCurrentUserIntent('resizing')({
271
272
  tr: tr
@@ -277,7 +278,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
277
278
  if (onResizeStart) {
278
279
  onResizeStart();
279
280
  }
280
- }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isTableScalingEnabled, excludeGuidelineConfig, containerWidth, lineLength, displayGuideline, onResizeStart, isFullWidthModeEnabled, pluginInjectionApi]);
281
+ }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isToolbarAIFCEnabled, isTableScalingEnabled, isFullWidthModeEnabled, lineLength, containerWidth, excludeGuidelineConfig, displayGuideline, onResizeStart, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 ? void 0 : _pluginInjectionApi$u2.commands]);
281
282
  var handleResize = (0, _react.useCallback)(
282
283
  // Ignored via go/ees005
283
284
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -342,9 +343,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
342
343
  tableRef: null
343
344
  });
344
345
  tr.setMeta('is-resizer-resizing', false);
345
- if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true)) {
346
- var _pluginInjectionApi$u2;
347
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 || _pluginInjectionApi$u2.commands.setCurrentUserIntent('default')({
346
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
347
+ var _pluginInjectionApi$u3;
348
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u3 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u3 === void 0 || _pluginInjectionApi$u3.commands.setCurrentUserIntent('default')({
348
349
  tr: tr
349
350
  });
350
351
  }
@@ -414,7 +415,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
414
415
  (_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('tableResize');
415
416
  }
416
417
  return newWidth;
417
- }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
418
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, isToolbarAIFCEnabled, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
418
419
  var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
419
420
  var newWidth = width + step;
420
421
  if ((0, _expValEquals.expValEquals)('platform_editor_tables_scaling_css', 'isEnabled', true)) {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -7,8 +8,10 @@ exports.generateResizedPayload = exports.generateResizeFrameRatePayloads = void
7
8
  exports.getSelectedCellInfo = getSelectedCellInfo;
8
9
  exports.getSelectedTableInfo = getSelectedTableInfo;
9
10
  exports.withEditorAnalyticsAPI = exports.useMeasureFramerate = exports.reduceResizeFrameRateSamples = exports.getWidthInfoPayload = void 0;
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
12
  var _react = require("react");
11
13
  var _analytics = require("@atlaskit/editor-common/analytics");
14
+ var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
12
15
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
16
  var _utils = require("@atlaskit/editor-tables/utils");
14
17
  var _colgroup = require("../table-resizing/utils/colgroup");
@@ -229,11 +232,25 @@ var getWidthInfoPayload = exports.getWidthInfoPayload = function getWidthInfoPay
229
232
  }
230
233
  }
231
234
  });
235
+
236
+ // only send the event if there are tables on the page
237
+ if (tablesInfo.length === 0) {
238
+ return undefined;
239
+ }
240
+ var maxTableWidth = Math.max.apply(Math, (0, _toConsumableArray2.default)(tablesInfo.map(function (table) {
241
+ return table.tableWidth;
242
+ })));
232
243
  return {
233
244
  action: _analytics.TABLE_ACTION.TABLE_WIDTH_INFO,
234
245
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
235
246
  attributes: {
236
247
  editorWidth: editorWidth,
248
+ editorWidthBreakpoint: (0, _analytics2.getBreakpointKey)(editorWidth),
249
+ hasTableWithScrollbar: tablesInfo.some(function (table) {
250
+ return table.hasScrollbar;
251
+ }),
252
+ hasTableWiderThanEditor: maxTableWidth > editorWidth,
253
+ maxTableWidthBreakpoint: (0, _analytics2.getBreakpointKey)(maxTableWidth),
237
254
  tableWidthInfo: tablesInfo,
238
255
  mode: 'editor'
239
256
  },
@@ -431,7 +431,10 @@ var tablePlugin = function tablePlugin(_ref) {
431
431
  var _api$width$sharedStat2;
432
432
  var editorWidth = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
433
433
  if (editorWidth && editorViewRef.current) {
434
- dispatchAnalyticsEvent((0, _analytics2.getWidthInfoPayload)(editorViewRef.current, editorWidth));
434
+ var payload = (0, _analytics2.getWidthInfoPayload)(editorViewRef.current, editorWidth);
435
+ if (payload) {
436
+ dispatchAnalyticsEvent(payload);
437
+ }
435
438
  }
436
439
  };
437
440
  if (window && typeof window.requestIdleCallback === 'function') {
@@ -25,7 +25,6 @@ var _utils2 = require("@atlaskit/editor-tables/utils");
25
25
  var _paintBucketEditorBackgroundColor = _interopRequireDefault(require("@atlaskit/icon/core/migration/paint-bucket--editor-background-color"));
26
26
  var _primitives = require("@atlaskit/primitives");
27
27
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
28
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
29
28
  var _toggle = _interopRequireDefault(require("@atlaskit/toggle"));
30
29
  var _commands = require("../../pm-plugins/commands");
31
30
  var _commandsWithAnalytics = require("../../pm-plugins/commands/commands-with-analytics");
@@ -239,6 +238,7 @@ var DragMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
239
238
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
240
239
  menuItems = _convertToDropdownIte.menuItems,
241
240
  menuCallback = _convertToDropdownIte.menuCallback;
241
+ var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
242
242
  var handleSubMenuRef = function handleSubMenuRef(ref) {
243
243
  var parent = (0, _utils.closestElement)(
244
244
  // Ignored via go/ees005
@@ -526,7 +526,7 @@ var DragMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
526
526
  boundariesElement: boundariesElement,
527
527
  scrollableElement: scrollableElement
528
528
  });
529
- return (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) ? (0, _react2.jsx)(_userIntent.UserIntentPopupWrapper, {
529
+ return isToolbarAIFCEnabled ? (0, _react2.jsx)(_userIntent.UserIntentPopupWrapper, {
530
530
  api: api
531
531
  }, Menu) : Menu;
532
532
  });
@@ -115,7 +115,6 @@ var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMen
115
115
  id: 'editor.table.tableOptions',
116
116
  type: 'dropdown',
117
117
  testId: 'table_options',
118
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
119
118
  icon: (0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') ? undefined : _customizePreferences.default,
120
119
  iconBefore: (0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') ? _customizePreferences.default : undefined,
121
120
  title: formatMessage(_messages.tableMessages.tableOptions),
@@ -132,7 +132,7 @@ export const TableResizer = ({
132
132
  isCommentEditor,
133
133
  disabled
134
134
  }) => {
135
- var _editorView$state, _pluginInjectionApi$a2;
135
+ var _editorView$state, _pluginInjectionApi$a2, _pluginInjectionApi$u2;
136
136
  const currentGap = useRef(0);
137
137
  // track resizing state - use ref over state to avoid re-render
138
138
  const isResizing = useRef(false);
@@ -149,6 +149,7 @@ export const TableResizer = ({
149
149
  const {
150
150
  formatMessage
151
151
  } = useIntl();
152
+ const isToolbarAIFCEnabled = Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar);
152
153
  const currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
153
154
  const tableFromSelection = useMemo(() => {
154
155
  return findTable(currentSelection);
@@ -258,7 +259,7 @@ export const TableResizer = ({
258
259
  tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
259
260
  name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
260
261
  });
261
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || editorExperiment('platform_editor_toolbar_aifc', true)) {
262
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
262
263
  var _pluginInjectionApi$u;
263
264
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$u = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u === void 0 ? void 0 : _pluginInjectionApi$u.commands.setCurrentUserIntent('resizing')({
264
265
  tr
@@ -270,7 +271,7 @@ export const TableResizer = ({
270
271
  if (onResizeStart) {
271
272
  onResizeStart();
272
273
  }
273
- }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isTableScalingEnabled, excludeGuidelineConfig, containerWidth, lineLength, displayGuideline, onResizeStart, isFullWidthModeEnabled, pluginInjectionApi]);
274
+ }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isToolbarAIFCEnabled, isTableScalingEnabled, isFullWidthModeEnabled, lineLength, containerWidth, excludeGuidelineConfig, displayGuideline, onResizeStart, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 ? void 0 : _pluginInjectionApi$u2.commands]);
274
275
  const handleResize = useCallback(
275
276
  // Ignored via go/ees005
276
277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -337,9 +338,9 @@ export const TableResizer = ({
337
338
  tableRef: null
338
339
  });
339
340
  tr.setMeta('is-resizer-resizing', false);
340
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || editorExperiment('platform_editor_toolbar_aifc', true)) {
341
- var _pluginInjectionApi$u2;
342
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 ? void 0 : _pluginInjectionApi$u2.commands.setCurrentUserIntent('default')({
341
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
342
+ var _pluginInjectionApi$u3;
343
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$u3 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u3 === void 0 ? void 0 : _pluginInjectionApi$u3.commands.setCurrentUserIntent('default')({
343
344
  tr
344
345
  });
345
346
  }
@@ -410,7 +411,7 @@ export const TableResizer = ({
410
411
  (_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableResize');
411
412
  }
412
413
  return newWidth;
413
- }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
414
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, isToolbarAIFCEnabled, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
414
415
  const handleTableSizeChangeOnKeypress = useCallback(step => {
415
416
  const newWidth = width + step;
416
417
  if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
3
+ import { getBreakpointKey } from '@atlaskit/editor-common/utils/analytics';
3
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
5
  import { findTable, getSelectionRect } from '@atlaskit/editor-tables/utils';
5
6
  import { hasTableBeenResized } from '../table-resizing/utils/colgroup';
@@ -206,11 +207,21 @@ export const getWidthInfoPayload = (editorView, editorWidth) => {
206
207
  }
207
208
  }
208
209
  });
210
+
211
+ // only send the event if there are tables on the page
212
+ if (tablesInfo.length === 0) {
213
+ return undefined;
214
+ }
215
+ const maxTableWidth = Math.max(...tablesInfo.map(table => table.tableWidth));
209
216
  return {
210
217
  action: TABLE_ACTION.TABLE_WIDTH_INFO,
211
218
  actionSubject: ACTION_SUBJECT.TABLE,
212
219
  attributes: {
213
- editorWidth: editorWidth,
220
+ editorWidth,
221
+ editorWidthBreakpoint: getBreakpointKey(editorWidth),
222
+ hasTableWithScrollbar: tablesInfo.some(table => table.hasScrollbar),
223
+ hasTableWiderThanEditor: maxTableWidth > editorWidth,
224
+ maxTableWidthBreakpoint: getBreakpointKey(maxTableWidth),
214
225
  tableWidthInfo: tablesInfo,
215
226
  mode: 'editor'
216
227
  },
@@ -420,7 +420,10 @@ const tablePlugin = ({
420
420
  var _api$width$sharedStat2;
421
421
  const editorWidth = api === null || api === void 0 ? void 0 : (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
422
422
  if (editorWidth && editorViewRef.current) {
423
- dispatchAnalyticsEvent(getWidthInfoPayload(editorViewRef.current, editorWidth));
423
+ const payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
424
+ if (payload) {
425
+ dispatchAnalyticsEvent(payload);
426
+ }
424
427
  }
425
428
  };
426
429
  if (window && typeof window.requestIdleCallback === 'function') {
@@ -24,7 +24,6 @@ import PaintBucketIcon from '@atlaskit/icon/core/migration/paint-bucket--editor-
24
24
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
25
25
  import { Box, xcss } from '@atlaskit/primitives';
26
26
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
27
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
28
27
  import Toggle from '@atlaskit/toggle';
29
28
  import { clearHoverSelection, hoverColumns, hoverRows } from '../../pm-plugins/commands';
30
29
  import { setColorWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
@@ -229,6 +228,7 @@ const DragMenu = /*#__PURE__*/React.memo(({
229
228
  menuItems,
230
229
  menuCallback
231
230
  } = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect);
231
+ const isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
232
232
  const handleSubMenuRef = ref => {
233
233
  const parent = closestElement(
234
234
  // Ignored via go/ees005
@@ -525,7 +525,7 @@ const DragMenu = /*#__PURE__*/React.memo(({
525
525
  boundariesElement: boundariesElement,
526
526
  scrollableElement: scrollableElement
527
527
  });
528
- return editorExperiment('platform_editor_toolbar_aifc', true) ? jsx(UserIntentPopupWrapper, {
528
+ return isToolbarAIFCEnabled ? jsx(UserIntentPopupWrapper, {
529
529
  api: api
530
530
  }, Menu) : Menu;
531
531
  });
@@ -103,7 +103,6 @@ export const getToolbarMenuConfig = (config, state, {
103
103
  id: 'editor.table.tableOptions',
104
104
  type: 'dropdown',
105
105
  testId: 'table_options',
106
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
107
106
  icon: fg('platform-visual-refresh-icons') ? undefined : CustomizeIcon,
108
107
  iconBefore: fg('platform-visual-refresh-icons') ? CustomizeIcon : undefined,
109
108
  title: formatMessage(messages.tableOptions),
@@ -111,7 +111,7 @@ var selector = function selector(states) {
111
111
  };
112
112
  };
113
113
  export var TableResizer = function TableResizer(_ref) {
114
- var _editorView$state, _pluginInjectionApi$a2;
114
+ var _editorView$state, _pluginInjectionApi$a2, _pluginInjectionApi$u2;
115
115
  var children = _ref.children,
116
116
  width = _ref.width,
117
117
  maxWidth = _ref.maxWidth,
@@ -153,6 +153,7 @@ export var TableResizer = function TableResizer(_ref) {
153
153
  setSnappingEnabled = _useState2[1];
154
154
  var _useIntl = useIntl(),
155
155
  formatMessage = _useIntl.formatMessage;
156
+ var isToolbarAIFCEnabled = Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar);
156
157
  var currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
157
158
  var tableFromSelection = useMemo(function () {
158
159
  return findTable(currentSelection);
@@ -256,7 +257,7 @@ export var TableResizer = function TableResizer(_ref) {
256
257
  tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
257
258
  name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
258
259
  });
259
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || editorExperiment('platform_editor_toolbar_aifc', true)) {
260
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
260
261
  var _pluginInjectionApi$u;
261
262
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u === void 0 || _pluginInjectionApi$u.commands.setCurrentUserIntent('resizing')({
262
263
  tr: tr
@@ -268,7 +269,7 @@ export var TableResizer = function TableResizer(_ref) {
268
269
  if (onResizeStart) {
269
270
  onResizeStart();
270
271
  }
271
- }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isTableScalingEnabled, excludeGuidelineConfig, containerWidth, lineLength, displayGuideline, onResizeStart, isFullWidthModeEnabled, pluginInjectionApi]);
272
+ }, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isToolbarAIFCEnabled, isTableScalingEnabled, isFullWidthModeEnabled, lineLength, containerWidth, excludeGuidelineConfig, displayGuideline, onResizeStart, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 ? void 0 : _pluginInjectionApi$u2.commands]);
272
273
  var handleResize = useCallback(
273
274
  // Ignored via go/ees005
274
275
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -333,9 +334,9 @@ export var TableResizer = function TableResizer(_ref) {
333
334
  tableRef: null
334
335
  });
335
336
  tr.setMeta('is-resizer-resizing', false);
336
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || editorExperiment('platform_editor_toolbar_aifc', true)) {
337
- var _pluginInjectionApi$u2;
338
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u2 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u2 === void 0 || _pluginInjectionApi$u2.commands.setCurrentUserIntent('default')({
337
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isToolbarAIFCEnabled) {
338
+ var _pluginInjectionApi$u3;
339
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$u3 = pluginInjectionApi.userIntent) === null || _pluginInjectionApi$u3 === void 0 || _pluginInjectionApi$u3.commands.setCurrentUserIntent('default')({
339
340
  tr: tr
340
341
  });
341
342
  }
@@ -405,7 +406,7 @@ export var TableResizer = function TableResizer(_ref) {
405
406
  (_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('tableResize');
406
407
  }
407
408
  return newWidth;
408
- }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
409
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, isToolbarAIFCEnabled, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
409
410
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
410
411
  var newWidth = width + step;
411
412
  if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
@@ -1,5 +1,7 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import { useEffect, useRef } from 'react';
2
3
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
+ import { getBreakpointKey } from '@atlaskit/editor-common/utils/analytics';
3
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
6
  import { findTable, getSelectionRect } from '@atlaskit/editor-tables/utils';
5
7
  import { hasTableBeenResized } from '../table-resizing/utils/colgroup';
@@ -220,11 +222,25 @@ export var getWidthInfoPayload = function getWidthInfoPayload(editorView, editor
220
222
  }
221
223
  }
222
224
  });
225
+
226
+ // only send the event if there are tables on the page
227
+ if (tablesInfo.length === 0) {
228
+ return undefined;
229
+ }
230
+ var maxTableWidth = Math.max.apply(Math, _toConsumableArray(tablesInfo.map(function (table) {
231
+ return table.tableWidth;
232
+ })));
223
233
  return {
224
234
  action: TABLE_ACTION.TABLE_WIDTH_INFO,
225
235
  actionSubject: ACTION_SUBJECT.TABLE,
226
236
  attributes: {
227
237
  editorWidth: editorWidth,
238
+ editorWidthBreakpoint: getBreakpointKey(editorWidth),
239
+ hasTableWithScrollbar: tablesInfo.some(function (table) {
240
+ return table.hasScrollbar;
241
+ }),
242
+ hasTableWiderThanEditor: maxTableWidth > editorWidth,
243
+ maxTableWidthBreakpoint: getBreakpointKey(maxTableWidth),
228
244
  tableWidthInfo: tablesInfo,
229
245
  mode: 'editor'
230
246
  },
@@ -422,7 +422,10 @@ var tablePlugin = function tablePlugin(_ref) {
422
422
  var _api$width$sharedStat2;
423
423
  var editorWidth = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width;
424
424
  if (editorWidth && editorViewRef.current) {
425
- dispatchAnalyticsEvent(getWidthInfoPayload(editorViewRef.current, editorWidth));
425
+ var payload = getWidthInfoPayload(editorViewRef.current, editorWidth);
426
+ if (payload) {
427
+ dispatchAnalyticsEvent(payload);
428
+ }
426
429
  }
427
430
  };
428
431
  if (window && typeof window.requestIdleCallback === 'function') {
@@ -26,7 +26,6 @@ import PaintBucketIcon from '@atlaskit/icon/core/migration/paint-bucket--editor-
26
26
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
27
27
  import { Box, xcss } from '@atlaskit/primitives';
28
28
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
29
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
29
  import Toggle from '@atlaskit/toggle';
31
30
  import { clearHoverSelection, hoverColumns, hoverRows } from '../../pm-plugins/commands';
32
31
  import { setColorWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics } from '../../pm-plugins/commands/commands-with-analytics';
@@ -228,6 +227,7 @@ var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
228
227
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
229
228
  menuItems = _convertToDropdownIte.menuItems,
230
229
  menuCallback = _convertToDropdownIte.menuCallback;
230
+ var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
231
231
  var handleSubMenuRef = function handleSubMenuRef(ref) {
232
232
  var parent = closestElement(
233
233
  // Ignored via go/ees005
@@ -515,7 +515,7 @@ var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
515
515
  boundariesElement: boundariesElement,
516
516
  scrollableElement: scrollableElement
517
517
  });
518
- return editorExperiment('platform_editor_toolbar_aifc', true) ? jsx(UserIntentPopupWrapper, {
518
+ return isToolbarAIFCEnabled ? jsx(UserIntentPopupWrapper, {
519
519
  api: api
520
520
  }, Menu) : Menu;
521
521
  });
@@ -108,7 +108,6 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
108
108
  id: 'editor.table.tableOptions',
109
109
  type: 'dropdown',
110
110
  testId: 'table_options',
111
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
112
111
  icon: fg('platform-visual-refresh-icons') ? undefined : CustomizeIcon,
113
112
  iconBefore: fg('platform-visual-refresh-icons') ? CustomizeIcon : undefined,
114
113
  title: formatMessage(messages.tableOptions),
@@ -44,5 +44,5 @@ export declare const useMeasureFramerate: (config?: UseMeasureFramerateConfig) =
44
44
  endMeasure: () => number[];
45
45
  countFrames: () => void;
46
46
  };
47
- export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload;
47
+ export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload | undefined;
48
48
  export {};
@@ -44,5 +44,5 @@ export declare const useMeasureFramerate: (config?: UseMeasureFramerateConfig) =
44
44
  endMeasure: () => number[];
45
45
  countFrames: () => void;
46
46
  };
47
- export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload;
47
+ export declare const getWidthInfoPayload: (editorView: EditorView, editorWidth: number) => TableEventPayload | undefined;
48
48
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "15.0.10",
3
+ "version": "15.0.12",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -42,11 +42,11 @@
42
42
  "@atlaskit/editor-plugin-interaction": "^8.0.0",
43
43
  "@atlaskit/editor-plugin-limited-mode": "^3.0.0",
44
44
  "@atlaskit/editor-plugin-selection": "^6.1.0",
45
- "@atlaskit/editor-plugin-toolbar": "^3.1.0",
45
+ "@atlaskit/editor-plugin-toolbar": "^3.2.0",
46
46
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
47
47
  "@atlaskit/editor-plugin-width": "^7.0.0",
48
48
  "@atlaskit/editor-prosemirror": "7.0.0",
49
- "@atlaskit/editor-shared-styles": "^3.6.0",
49
+ "@atlaskit/editor-shared-styles": "^3.7.0",
50
50
  "@atlaskit/editor-tables": "^2.9.0",
51
51
  "@atlaskit/icon": "^28.5.0",
52
52
  "@atlaskit/insm": "^0.1.0",
@@ -59,7 +59,7 @@
59
59
  "@atlaskit/primitives": "^14.15.0",
60
60
  "@atlaskit/react-ufo": "^4.11.0",
61
61
  "@atlaskit/theme": "^21.0.0",
62
- "@atlaskit/tmp-editor-statsig": "^13.6.0",
62
+ "@atlaskit/tmp-editor-statsig": "^13.10.0",
63
63
  "@atlaskit/toggle": "^15.1.0",
64
64
  "@atlaskit/tokens": "^6.4.0",
65
65
  "@atlaskit/tooltip": "^20.5.0",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^3.1.0"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^110.10.0",
75
+ "@atlaskit/editor-common": "^110.11.0",
76
76
  "react": "^18.2.0",
77
77
  "react-dom": "^18.2.0",
78
78
  "react-intl-next": "npm:react-intl@^5.18.1"