@atlaskit/editor-plugin-table 14.2.7 → 14.3.0

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 +14 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +24 -65
  3. package/dist/cjs/nodeviews/table.js +14 -128
  4. package/dist/cjs/pm-plugins/utils/analytics.js +33 -1
  5. package/dist/cjs/tablePlugin.js +50 -13
  6. package/dist/cjs/ui/DragHandle/index.js +21 -8
  7. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -18
  8. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  9. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -18
  10. package/dist/cjs/ui/TableFloatingControls/index.js +3 -45
  11. package/dist/es2019/nodeviews/TableComponent.js +18 -62
  12. package/dist/es2019/nodeviews/table.js +14 -129
  13. package/dist/es2019/pm-plugins/utils/analytics.js +32 -0
  14. package/dist/es2019/tablePlugin.js +39 -1
  15. package/dist/es2019/ui/DragHandle/index.js +15 -5
  16. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -19
  17. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  18. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +2 -19
  19. package/dist/es2019/ui/TableFloatingControls/index.js +5 -47
  20. package/dist/esm/nodeviews/TableComponent.js +24 -65
  21. package/dist/esm/nodeviews/table.js +14 -128
  22. package/dist/esm/pm-plugins/utils/analytics.js +32 -0
  23. package/dist/esm/tablePlugin.js +50 -13
  24. package/dist/esm/ui/DragHandle/index.js +20 -7
  25. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -19
  26. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  27. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +2 -19
  28. package/dist/esm/ui/TableFloatingControls/index.js +5 -47
  29. package/dist/types/pm-plugins/utils/analytics.d.ts +2 -0
  30. package/dist/types/ui/DragHandle/index.d.ts +1 -4
  31. package/dist/types-ts4.5/pm-plugins/utils/analytics.d.ts +2 -0
  32. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +1 -4
  33. package/package.json +10 -22
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 14.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`f3461c712ac67`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f3461c712ac67) -
8
+ Remove platform_editor_table_use_shared_state_hook_fg FG, add
9
+ platform_editor_table_drag_handle_hover experiments
10
+ - [`687c1b8fa7801`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/687c1b8fa7801) -
11
+ EDITOR-1566 bump adf-schema + update validator
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 14.2.7
4
18
 
5
19
  ### Patch Changes
@@ -33,7 +33,6 @@ var _loadHold = _interopRequireDefault(require("@atlaskit/react-ufo/load-hold"))
33
33
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
34
34
  var _commands = require("../pm-plugins/commands");
35
35
  var _autoscrollers = require("../pm-plugins/drag-and-drop/utils/autoscrollers");
36
- var _pluginFactory = require("../pm-plugins/plugin-factory");
37
36
  var _pluginKey = require("../pm-plugins/sticky-headers/plugin-key");
38
37
  var _util = require("../pm-plugins/sticky-headers/util");
39
38
  var _tableAnalytics = require("../pm-plugins/table-analytics");
@@ -529,14 +528,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
529
528
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
530
529
  passive: true
531
530
  });
532
- if ((0, _platformFeatureFlags.fg)('disable-sticky-scrollbar-for-nested-tables')) {
533
- if (this.table && !this.isNestedInTable) {
534
- this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
535
- }
536
- } else {
537
- if (this.table) {
538
- this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
539
- }
531
+ if (this.table && !this.isNestedInTable) {
532
+ this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
540
533
  }
541
534
  if (isDragAndDropEnabled) {
542
535
  this.dragAndDropCleanupFn = _combine.combine.apply(void 0, (0, _toConsumableArray2.default)((0, _autoscrollers.autoScrollerFactory)({
@@ -809,13 +802,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
809
802
  options = _this$props1.options,
810
803
  isTableScalingEnabled = _this$props1.isTableScalingEnabled,
811
804
  getPos = _this$props1.getPos,
812
- getEditorFeatureFlags = _this$props1.getEditorFeatureFlags;
813
- var isInDanger = this.props.isInDanger;
805
+ getEditorFeatureFlags = _this$props1.getEditorFeatureFlags,
806
+ isInDanger = _this$props1.isInDanger;
814
807
  var table = (0, _utils2.findTable)(view.state.selection);
815
- if (!(0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg')) {
816
- var pluginState = (0, _pluginFactory.getPluginState)(view.state);
817
- isInDanger = pluginState.isInDanger;
818
- }
819
808
  var shouldScale = false;
820
809
  var shouldHandleColgroupUpdates = false;
821
810
  var _getEditorFeatureFlag5 = getEditorFeatureFlags(),
@@ -837,14 +826,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
837
826
  if (shouldHandleColgroupUpdates) {
838
827
  this.handleColgroupUpdates();
839
828
  }
840
- if (isInDanger && !table) {
841
- (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
829
+
830
+ // table is always defined so this never runs
831
+ if (!(0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
832
+ if (isInDanger && !table) {
833
+ (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
834
+ }
842
835
  }
843
836
  if ((_this$props$options1 = this.props.options) !== null && _this$props$options1 !== void 0 && _this$props$options1.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
844
837
  this.removeInlineTableWidth();
845
838
  }
846
839
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
847
- if (this.props.isDragAndDropEnabled) {
840
+ // isDragAndDropEnabled will be false when the editorViewMode is 'live' and so the fix below is never triggered
841
+ // but the shadow observer must run async so its initial state is correct.
842
+ // note: when cleaning up platform_editor_table_drag_handle_hover entirely remove this nested if check incl. this.props.isDragAndDropEnabled
843
+ if (this.props.isDragAndDropEnabled || (0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
848
844
  // requestAnimationFrame is used here to fix a race condition issue
849
845
  // that happens when a table is nested in expand and expand's width is
850
846
  // changed via breakout button
@@ -950,25 +946,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
950
946
  isTableScalingEnabled = _this$props10.isTableScalingEnabled,
951
947
  allowTableResizing = _this$props10.allowTableResizing,
952
948
  allowTableAlignment = _this$props10.allowTableAlignment,
953
- selection = _this$props10.selection;
954
- var _this$props11 = this.props,
955
- isInDanger = _this$props11.isInDanger,
956
- hoveredRows = _this$props11.hoveredRows,
957
- hoveredCell = _this$props11.hoveredCell,
958
- isTableHovered = _this$props11.isTableHovered,
959
- isWholeTableInDanger = _this$props11.isWholeTableInDanger;
949
+ selection = _this$props10.selection,
950
+ isInDanger = _this$props10.isInDanger,
951
+ hoveredRows = _this$props10.hoveredRows,
952
+ hoveredCell = _this$props10.hoveredCell,
953
+ isTableHovered = _this$props10.isTableHovered,
954
+ isWholeTableInDanger = _this$props10.isWholeTableInDanger;
960
955
  var _this$state3 = this.state,
961
956
  showBeforeShadow = _this$state3.showBeforeShadow,
962
957
  showAfterShadow = _this$state3.showAfterShadow;
963
958
  var node = getNode();
964
- if (!(0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg')) {
965
- var pluginState = (0, _pluginFactory.getPluginState)(view.state);
966
- isInDanger = pluginState.isInDanger;
967
- hoveredRows = pluginState.hoveredRows;
968
- hoveredCell = pluginState.hoveredCell;
969
- isTableHovered = pluginState.isTableHovered;
970
- isWholeTableInDanger = pluginState.isWholeTableInDanger;
971
- }
972
959
  var tableRef = this.table || undefined;
973
960
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
974
961
  var hasHeaderRow = (0, _nodes.containsHeaderRow)(node);
@@ -1082,11 +1069,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
1082
1069
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1083
1070
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
1084
1071
  "data-testid": "sticky-sentinel-top"
1085
- }), (0, _platformFeatureFlags.fg)('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
1086
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1087
- className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
1088
- "data-testid": "sticky-scrollbar-sentinel-top"
1089
- }) : /*#__PURE__*/_react.default.createElement("div", {
1072
+ }), !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
1090
1073
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1091
1074
  className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
1092
1075
  "data-testid": "sticky-scrollbar-sentinel-top"
@@ -1132,7 +1115,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
1132
1115
  }
1133
1116
  }
1134
1117
  }
1135
- }, allowControls && colControls), (0, _platformFeatureFlags.fg)('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable ? /*#__PURE__*/_react.default.createElement("div", {
1118
+ }, allowControls && colControls), !this.isNestedInTable ? /*#__PURE__*/_react.default.createElement("div", {
1136
1119
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1137
1120
  className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
1138
1121
  "data-vc-nvs": "true",
@@ -1159,27 +1142,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
1159
1142
  height: '100%'
1160
1143
  },
1161
1144
  "data-vc-nvs": "true"
1162
- }) : /*#__PURE__*/_react.default.createElement("div", {
1163
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1164
- className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
1165
- style: {
1166
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1167
- height: "var(--ds-space-250, 20px)",
1168
- // MAX_BROWSER_SCROLLBAR_HEIGHT
1169
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1170
- display: 'none',
1171
- // prevent unwanted scroll during table resize without removing scrollbar container from the dom
1172
- width: isResizing ? "var(--ds-space-0, 0px)" : '100%'
1173
- },
1174
- "data-vc-nvs": "true"
1175
- }, /*#__PURE__*/_react.default.createElement("div", {
1176
- style: {
1177
- width: tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth,
1178
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1179
- height: '100%'
1180
- },
1181
- "data-vc-nvs": "true"
1182
- })), /*#__PURE__*/_react.default.createElement("div", {
1145
+ }), /*#__PURE__*/_react.default.createElement("div", {
1183
1146
  contentEditable: false
1184
1147
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1185
1148
  ,
@@ -1206,11 +1169,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
1206
1169
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1207
1170
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM,
1208
1171
  "data-testid": "sticky-sentinel-bottom"
1209
- }), (0, _platformFeatureFlags.fg)('disable-sticky-scrollbar-for-nested-tables') ? !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
1210
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1211
- className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
1212
- "data-testid": "sticky-scrollbar-sentinel-bottom"
1213
- }) : /*#__PURE__*/_react.default.createElement("div", {
1172
+ }), !this.isNestedInTable && /*#__PURE__*/_react.default.createElement("div", {
1214
1173
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
1215
1174
  className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
1216
1175
  "data-testid": "sticky-scrollbar-sentinel-bottom"
@@ -16,20 +16,15 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
18
18
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
19
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
20
19
  var _model = require("@atlaskit/editor-prosemirror/model");
21
20
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
21
  var _tableMap = require("@atlaskit/editor-tables/table-map");
23
22
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
24
  var _createPluginConfig = require("../pm-plugins/create-plugin-config");
26
- var _pluginKey = require("../pm-plugins/drag-and-drop/plugin-key");
27
25
  var _pluginFactory = require("../pm-plugins/plugin-factory");
28
- var _pluginKey2 = require("../pm-plugins/plugin-key");
29
- var _pluginKey3 = require("../pm-plugins/table-resizing/plugin-key");
30
26
  var _tableWidth = require("../pm-plugins/table-width");
31
27
  var _nodes = require("../pm-plugins/utils/nodes");
32
- var _TableComponent = _interopRequireDefault(require("./TableComponent"));
33
28
  var _TableComponentWithSharedState = require("./TableComponentWithSharedState");
34
29
  var _toDOM = require("./toDOM");
35
30
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -218,129 +213,20 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
218
213
  }, {
219
214
  key: "render",
220
215
  value: function render(props, forwardRef) {
221
- var _props$pluginInjectio,
222
- _this4 = this;
223
- if ((0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg')) {
224
- return /*#__PURE__*/_react.default.createElement(_TableComponentWithSharedState.TableComponentWithSharedState, {
225
- forwardRef: forwardRef,
226
- getNode: this.getNode,
227
- view: props.view,
228
- options: props.options,
229
- eventDispatcher: props.eventDispatcher,
230
- api: props.pluginInjectionApi,
231
- allowColumnResizing: props.allowColumnResizing,
232
- allowTableAlignment: props.allowTableAlignment,
233
- allowTableResizing: props.allowTableResizing,
234
- allowControls: props.allowControls,
235
- getPos: props.getPos,
236
- getEditorFeatureFlags: props.getEditorFeatureFlags,
237
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
238
- });
239
- }
240
- // Please, do not copy or use this kind of code below
241
- // @ts-ignore
242
- var fakePluginKey = {
243
- key: 'widthPlugin$',
244
- getState: function getState(state) {
245
- // Ignored via go/ees005
246
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
247
- return state['widthPlugin$'];
248
- }
249
- };
250
-
251
- // Please, do not copy or use this kind of code below
252
- // @ts-ignore
253
- var fakeMediaPluginKey = {
254
- key: 'mediaPlugin$',
255
- getState: function getState(state) {
256
- // Ignored via go/ees005
257
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
- return state['mediaPlugin$'];
259
- }
260
- };
261
- return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
262
- plugins: {
263
- pluginState: _pluginKey2.pluginKey,
264
- tableResizingPluginState: _pluginKey3.pluginKey,
265
- tableWidthPluginState: _tableWidth.pluginKey,
266
- widthPlugin: fakePluginKey,
267
- mediaState: fakeMediaPluginKey,
268
- tableDragAndDropState: _pluginKey.pluginKey,
269
- limitedModePlugin: (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 || (_props$pluginInjectio = _props$pluginInjectio.limitedMode) === null || _props$pluginInjectio === void 0 || (_props$pluginInjectio = _props$pluginInjectio.sharedState.currentState()) === null || _props$pluginInjectio === void 0 ? void 0 : _props$pluginInjectio.limitedModePluginKey
270
- },
271
- editorView: props.view,
272
- render: function render(pluginStates) {
273
- var _props$options, _pluginStates$limited, _pluginStates$limited2;
274
- var tableResizingPluginState = pluginStates.tableResizingPluginState,
275
- tableWidthPluginState = pluginStates.tableWidthPluginState,
276
- pluginState = pluginStates.pluginState,
277
- mediaState = pluginStates.mediaState;
278
- var containerWidth = props.getEditorContainerWidth();
279
- var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
280
- var isResizing = Boolean((tableResizingPluginState === null || tableResizingPluginState === void 0 ? void 0 : tableResizingPluginState.dragging) || isTableResizing);
281
-
282
- /**
283
- * ED-19810
284
- * There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
285
- * directly to confluence since this bug is now in production.
286
- */
287
- var tablePos;
288
- try {
289
- tablePos = props.getPos ? props.getPos() : undefined;
290
- } catch (e) {
291
- tablePos = undefined;
292
- }
293
-
294
- // Ignored via go/ees005
295
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
296
- var tableActive = tablePos === pluginState.tablePos && !isTableResizing;
297
- return /*#__PURE__*/_react.default.createElement(_TableComponent.default, {
298
- view: props.view,
299
- allowColumnResizing: props.allowColumnResizing,
300
- eventDispatcher: props.eventDispatcher,
301
- getPos: props.getPos,
302
- isMediaFullscreen: mediaState === null || mediaState === void 0 ? void 0 : mediaState.isFullscreen,
303
- options: props.options
304
- // Ignored via go/ees005
305
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
306
- // Ignored via go/ees005
307
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
308
- ,
309
- allowControls: pluginState.pluginConfig.allowControls
310
- // Ignored via go/ees005
311
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
312
- ,
313
- isHeaderRowEnabled: pluginState.isHeaderRowEnabled
314
- // Ignored via go/ees005
315
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
316
- ,
317
- isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled
318
- // Ignored via go/ees005
319
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
320
- ,
321
- isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
322
- isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
323
- ,
324
- allowTableAlignment: props.allowTableAlignment,
325
- allowTableResizing: props.allowTableResizing,
326
- tableActive: tableActive
327
- // Ignored via go/ees005
328
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
329
- ,
330
- ordering: pluginState.ordering,
331
- isResizing: isResizing,
332
- getNode: _this4.getNode
333
- // Ignored via go/ees005
334
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
335
- ,
336
- containerWidth: containerWidth,
337
- contentDOM: forwardRef,
338
- getEditorFeatureFlags: props.getEditorFeatureFlags,
339
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
340
- pluginInjectionApi: props.pluginInjectionApi,
341
- limitedMode: (_pluginStates$limited = (_pluginStates$limited2 = pluginStates.limitedModePlugin) === null || _pluginStates$limited2 === void 0 ? void 0 : _pluginStates$limited2.documentSizeBreachesThreshold) !== null && _pluginStates$limited !== void 0 ? _pluginStates$limited : false
342
- });
343
- }
216
+ return /*#__PURE__*/_react.default.createElement(_TableComponentWithSharedState.TableComponentWithSharedState, {
217
+ forwardRef: forwardRef,
218
+ getNode: this.getNode,
219
+ view: props.view,
220
+ options: props.options,
221
+ eventDispatcher: props.eventDispatcher,
222
+ api: props.pluginInjectionApi,
223
+ allowColumnResizing: props.allowColumnResizing,
224
+ allowTableAlignment: props.allowTableAlignment,
225
+ allowTableResizing: props.allowTableResizing,
226
+ allowControls: props.allowControls,
227
+ getPos: props.getPos,
228
+ getEditorFeatureFlags: props.getEditorFeatureFlags,
229
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent
344
230
  });
345
231
  }
346
232
  }, {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.generateResizedPayload = exports.generateResizeFrameRatePayloads = void 0;
7
7
  exports.getSelectedCellInfo = getSelectedCellInfo;
8
8
  exports.getSelectedTableInfo = getSelectedTableInfo;
9
- exports.withEditorAnalyticsAPI = exports.useMeasureFramerate = exports.reduceResizeFrameRateSamples = void 0;
9
+ exports.withEditorAnalyticsAPI = exports.useMeasureFramerate = exports.reduceResizeFrameRateSamples = exports.getWidthInfoPayload = void 0;
10
10
  var _react = require("react");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _tableMap = require("@atlaskit/editor-tables/table-map");
@@ -207,4 +207,36 @@ var useMeasureFramerate = exports.useMeasureFramerate = function useMeasureFrame
207
207
  endMeasure: endMeasure,
208
208
  countFrames: countFrames
209
209
  };
210
+ };
211
+ var tableContainerNodes = new Set(['layoutSection', 'layoutColumn', 'expand', 'nestedExpand', 'extension', 'bodiedExtension', 'multiBodiedExtension', 'extensionFrame', 'table', 'tableCell', 'tableHeader', 'tableRow']);
212
+ var getWidthInfoPayload = exports.getWidthInfoPayload = function getWidthInfoPayload(editorView, editorWidth) {
213
+ var tablesInfo = [];
214
+ editorView.state.doc.nodesBetween(0, editorView.state.doc.content.size, function (node, pos, parent) {
215
+ if (!tableContainerNodes.has(node.type.name)) {
216
+ return false;
217
+ }
218
+ if (node.type.name === 'table') {
219
+ var _domAtPos$node;
220
+ var domAtPos = editorView.domAtPos(pos + 1);
221
+ var table = (_domAtPos$node = domAtPos.node) === null || _domAtPos$node === void 0 ? void 0 : _domAtPos$node.parentElement;
222
+ var isNestedTable = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableCell' || (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'tableHeader';
223
+ if (table instanceof HTMLTableElement) {
224
+ tablesInfo.push({
225
+ tableWidth: table.scrollWidth,
226
+ isNestedTable: isNestedTable,
227
+ hasScrollbar: table.parentElement ? (table === null || table === void 0 ? void 0 : table.parentElement.clientWidth) < table.scrollWidth : false
228
+ });
229
+ }
230
+ }
231
+ });
232
+ return {
233
+ action: _analytics.TABLE_ACTION.TABLE_WIDTH_INFO,
234
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
235
+ attributes: {
236
+ editorWidth: editorWidth,
237
+ tableWidthInfo: tablesInfo,
238
+ mode: 'editor'
239
+ },
240
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
241
+ };
210
242
  };
@@ -21,6 +21,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
21
21
  var _utils = require("@atlaskit/editor-prosemirror/utils");
22
22
  var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
23
23
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
24
25
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
25
26
  var _toDOM = require("./nodeviews/toDOM");
26
27
  var _plugin = require("./pm-plugins/analytics/plugin");
@@ -44,6 +45,7 @@ var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
44
45
  var _tableSizeSelector = require("./pm-plugins/table-size-selector");
45
46
  var _tableWidth = require("./pm-plugins/table-width");
46
47
  var _tableWidthInCommentFix = require("./pm-plugins/table-width-in-comment-fix");
48
+ var _analytics2 = require("./pm-plugins/utils/analytics");
47
49
  var _create = require("./pm-plugins/utils/create");
48
50
  var _viewModeSort = require("./pm-plugins/view-mode-sort");
49
51
  var _ContentComponent = require("./ui/ContentComponent");
@@ -55,6 +57,9 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
55
57
  return {};
56
58
  };
57
59
 
60
+ // we want to calculate all the table widths (which causes reflows) after the editor has finished loading to mitigate performance impact
61
+ var TABLE_WIDTH_INFO_TIMEOUT = 10000;
62
+
58
63
  /**
59
64
  * Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
60
65
  * from `@atlaskit/editor-core`.
@@ -410,13 +415,45 @@ var tablePlugin = function tablePlugin(_ref) {
410
415
  }
411
416
  }, {
412
417
  name: 'tableGetEditorViewReferencePlugin',
413
- plugin: function plugin() {
418
+ plugin: function plugin(_ref17) {
419
+ var dispatchAnalyticsEvent = _ref17.dispatchAnalyticsEvent;
414
420
  return new _safePlugin.SafePlugin({
415
421
  view: function view(editorView) {
416
422
  editorViewRef.current = editorView;
423
+ var setTimeoutID;
424
+ var rafID;
425
+ var ricID;
426
+ if ((0, _expValEquals.expValEquals)('platform_editor_editor_width_analytics', 'isEnabled', true)) {
427
+ // send statistics about the widths of the tables on the page for alerting
428
+ // only send this event once, after the editorView is first initialised
429
+ setTimeoutID = setTimeout(function () {
430
+ var requestIdleCallbackFn = function requestIdleCallbackFn() {
431
+ var _api$width$sharedStat2;
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
+ if (editorWidth && editorViewRef.current) {
434
+ dispatchAnalyticsEvent((0, _analytics2.getWidthInfoPayload)(editorViewRef.current, editorWidth));
435
+ }
436
+ };
437
+ if (window && typeof window.requestIdleCallback === 'function') {
438
+ ricID = window.requestIdleCallback(requestIdleCallbackFn);
439
+ } else if (window && typeof window.requestAnimationFrame === 'function') {
440
+ // requestIdleCallback is not supported in safari, fallback to requestAnimationFrame
441
+ rafID = window.requestAnimationFrame(requestIdleCallbackFn);
442
+ }
443
+ }, TABLE_WIDTH_INFO_TIMEOUT);
444
+ }
417
445
  return {
418
446
  destroy: function destroy() {
419
447
  editorViewRef.current = null;
448
+ if (setTimeoutID) {
449
+ clearTimeout(setTimeoutID);
450
+ }
451
+ if (rafID) {
452
+ window.cancelAnimationFrame(rafID);
453
+ }
454
+ if (ricID) {
455
+ window.cancelIdleCallback(ricID);
456
+ }
420
457
  }
421
458
  };
422
459
  }
@@ -424,8 +461,8 @@ var tablePlugin = function tablePlugin(_ref) {
424
461
  }
425
462
  }, {
426
463
  name: 'tableSizeSelectorPlugin',
427
- plugin: function plugin(_ref17) {
428
- var dispatch = _ref17.dispatch;
464
+ plugin: function plugin(_ref18) {
465
+ var dispatch = _ref18.dispatch;
429
466
  return isTableSelectorEnabled ? (0, _tableSizeSelector.createPlugin)(dispatch) : undefined;
430
467
  }
431
468
  }];
@@ -442,12 +479,12 @@ var tablePlugin = function tablePlugin(_ref) {
442
479
  }
443
480
  return plugins;
444
481
  },
445
- contentComponent: function contentComponent(_ref18) {
446
- var editorView = _ref18.editorView,
447
- popupsMountPoint = _ref18.popupsMountPoint,
448
- popupsBoundariesElement = _ref18.popupsBoundariesElement,
449
- popupsScrollableElement = _ref18.popupsScrollableElement,
450
- dispatchAnalyticsEvent = _ref18.dispatchAnalyticsEvent;
482
+ contentComponent: function contentComponent(_ref19) {
483
+ var editorView = _ref19.editorView,
484
+ popupsMountPoint = _ref19.popupsMountPoint,
485
+ popupsBoundariesElement = _ref19.popupsBoundariesElement,
486
+ popupsScrollableElement = _ref19.popupsScrollableElement,
487
+ dispatchAnalyticsEvent = _ref19.dispatchAnalyticsEvent;
451
488
  return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
452
489
  api: api,
453
490
  editorView: editorView,
@@ -462,8 +499,8 @@ var tablePlugin = function tablePlugin(_ref) {
462
499
  });
463
500
  },
464
501
  pluginsOptions: {
465
- quickInsert: function quickInsert(_ref19) {
466
- var formatMessage = _ref19.formatMessage;
502
+ quickInsert: function quickInsert(_ref20) {
503
+ var formatMessage = _ref20.formatMessage;
467
504
  return [{
468
505
  id: 'table',
469
506
  title: formatMessage(_messages.toolbarInsertBlockMessages.table),
@@ -534,8 +571,8 @@ var tablePlugin = function tablePlugin(_ref) {
534
571
  return editorViewRef.current;
535
572
  }, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
536
573
  },
537
- usePluginHook: function usePluginHook(_ref20) {
538
- var editorView = _ref20.editorView;
574
+ usePluginHook: function usePluginHook(_ref21) {
575
+ var editorView = _ref21.editorView;
539
576
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorViewMode'], function (states) {
540
577
  var _states$editorViewMod;
541
578
  return {
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.DragHandleWithSharedState = exports.DragHandle = void 0;
8
+ exports.DragHandle = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _react = _interopRequireWildcard(require("react"));
@@ -42,8 +42,8 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
42
42
  forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
43
43
  previewWidth = _ref.previewWidth,
44
44
  previewHeight = _ref.previewHeight,
45
- onMouseOver = _ref.onMouseOver,
46
- onMouseOut = _ref.onMouseOut,
45
+ _onMouseOver = _ref.onMouseOver,
46
+ _onMouseOut = _ref.onMouseOut,
47
47
  toggleDragMenu = _ref.toggleDragMenu,
48
48
  hoveredCell = _ref.hoveredCell,
49
49
  onClick = _ref.onClick,
@@ -68,6 +68,10 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
68
68
  var _getDnDPluginState = (0, _pluginFactory.getPluginState)(state),
69
69
  _getDnDPluginState$is = _getDnDPluginState.isDragMenuOpen,
70
70
  isDragMenuOpen = _getDnDPluginState$is === void 0 ? false : _getDnDPluginState$is;
71
+ var _useState3 = (0, _react.useState)(false),
72
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
73
+ isHovered = _useState4[0],
74
+ setIsHovered = _useState4[1];
71
75
  var isRow = direction === 'row';
72
76
  var isColumn = direction === 'column';
73
77
 
@@ -109,7 +113,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
109
113
  }, [indexes, selection, direction, hoveredCell]);
110
114
  var handleIconProps = {
111
115
  forceDefaultHandle: forceDefaultHandle,
112
- isHandleHovered: isColumnHandleHovered || isRowHandleHovered,
116
+ isHandleHovered: (0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true) ? isHovered : isColumnHandleHovered || isRowHandleHovered,
113
117
  hasMergedCells: hasMergedCells
114
118
  };
115
119
  (0, _react.useEffect)(function () {
@@ -216,10 +220,20 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
216
220
  "aria-haspopup": "menu"
217
221
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
218
222
  ,
219
- onMouseOver: onMouseOver
223
+ onMouseOver: function onMouseOver(e) {
224
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
225
+ setIsHovered(true);
226
+ }
227
+ _onMouseOver && _onMouseOver(e);
228
+ }
220
229
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
221
230
  ,
222
- onMouseOut: onMouseOut,
231
+ onMouseOut: function onMouseOut(e) {
232
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_drag_handle_hover', 'isEnabled', true)) {
233
+ setIsHovered(false);
234
+ }
235
+ _onMouseOut && _onMouseOut(e);
236
+ },
223
237
  onMouseUp: function onMouseUp(e) {
224
238
  // return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
225
239
  // -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
@@ -300,5 +314,4 @@ var DragHandleComponentWithSharedState = function DragHandleComponentWithSharedS
300
314
  hoveredRows: hoveredRows
301
315
  });
302
316
  };
303
- var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponent);
304
- var DragHandleWithSharedState = exports.DragHandleWithSharedState = (0, _reactIntlNext.injectIntl)(DragHandleComponentWithSharedState);
317
+ var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleComponentWithSharedState);
@@ -11,7 +11,6 @@ var _styles = require("@atlaskit/editor-common/styles");
11
11
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var _editorTables = require("@atlaskit/editor-tables");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
14
  var _commands = require("../../../pm-plugins/commands");
16
15
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
17
16
  var _rowControls = require("../../../pm-plugins/utils/row-controls");
@@ -176,23 +175,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
176
175
  position: 'relative'
177
176
  },
178
177
  "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0], "-drag-handle")
179
- }, (0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandleWithSharedState, {
180
- isDragMenuTarget: !isHover,
181
- direction: "column",
182
- tableLocalId: localId || '',
183
- indexes: indexes,
184
- hoveredCell: hoveredCell,
185
- previewWidth: previewWidth,
186
- forceDefaultHandle: !isHover,
187
- previewHeight: previewHeight,
188
- appearance: appearance,
189
- onClick: handleClick,
190
- onMouseOver: handleMouseOver,
191
- onMouseOut: handleMouseOut,
192
- toggleDragMenu: toggleDragMenuHandler,
193
- editorView: editorView,
194
- api: api
195
- }) : /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
178
+ }, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
196
179
  isDragMenuTarget: !isHover,
197
180
  direction: "column",
198
181
  tableLocalId: localId || '',
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
13
12
  var _columnControls = require("../../pm-plugins/utils/column-controls");
14
13
  var _nodes = require("../../pm-plugins/utils/nodes");
@@ -103,7 +102,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
103
102
  isNumberColumnEnabled: isNumberColumnEnabled,
104
103
  isDragging: isDragging,
105
104
  getScrollOffset: getScrollOffset,
106
- api: (0, _platformFeatureFlags.fg)('platform_editor_table_use_shared_state_hook_fg') ? api : undefined
105
+ api: api
107
106
  }), isDragging && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
108
107
  tableRef: tableRef,
109
108
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,