@atlaskit/editor-plugin-table 22.1.3 → 22.2.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 (54) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +6 -5
  3. package/dist/cjs/nodeviews/table-node-views.js +1 -2
  4. package/dist/cjs/pm-plugins/commands/column-resize.js +2 -3
  5. package/dist/cjs/pm-plugins/commands/hover.js +6 -14
  6. package/dist/cjs/pm-plugins/commands/misc.js +13 -17
  7. package/dist/cjs/pm-plugins/decorations/plugin.js +2 -10
  8. package/dist/cjs/pm-plugins/decorations/utils/column-controls.js +9 -26
  9. package/dist/cjs/pm-plugins/utils/decoration.js +6 -10
  10. package/dist/cjs/pm-plugins/utils/sticky-header.js +2 -2
  11. package/dist/cjs/pm-plugins/utils/tableMode.js +52 -20
  12. package/dist/cjs/tablePlugin.js +1 -2
  13. package/dist/cjs/ui/FloatingContextualButton/index.js +1 -2
  14. package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -15
  15. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -1
  16. package/dist/es2019/nodeviews/TableComponent.js +6 -5
  17. package/dist/es2019/nodeviews/table-node-views.js +1 -2
  18. package/dist/es2019/pm-plugins/commands/column-resize.js +2 -3
  19. package/dist/es2019/pm-plugins/commands/hover.js +4 -16
  20. package/dist/es2019/pm-plugins/commands/misc.js +1 -6
  21. package/dist/es2019/pm-plugins/decorations/plugin.js +2 -9
  22. package/dist/es2019/pm-plugins/decorations/utils/column-controls.js +3 -21
  23. package/dist/es2019/pm-plugins/utils/decoration.js +6 -10
  24. package/dist/es2019/pm-plugins/utils/sticky-header.js +2 -2
  25. package/dist/es2019/pm-plugins/utils/tableMode.js +46 -18
  26. package/dist/es2019/tablePlugin.js +1 -2
  27. package/dist/es2019/ui/FloatingContextualButton/index.js +1 -2
  28. package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -15
  29. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -1
  30. package/dist/esm/nodeviews/TableComponent.js +6 -5
  31. package/dist/esm/nodeviews/table-node-views.js +1 -2
  32. package/dist/esm/pm-plugins/commands/column-resize.js +2 -3
  33. package/dist/esm/pm-plugins/commands/hover.js +6 -14
  34. package/dist/esm/pm-plugins/commands/misc.js +14 -18
  35. package/dist/esm/pm-plugins/decorations/plugin.js +2 -10
  36. package/dist/esm/pm-plugins/decorations/utils/column-controls.js +10 -27
  37. package/dist/esm/pm-plugins/utils/decoration.js +6 -10
  38. package/dist/esm/pm-plugins/utils/sticky-header.js +2 -2
  39. package/dist/esm/pm-plugins/utils/tableMode.js +51 -19
  40. package/dist/esm/tablePlugin.js +1 -2
  41. package/dist/esm/ui/FloatingContextualButton/index.js +1 -2
  42. package/dist/esm/ui/FloatingContextualMenu/index.js +2 -15
  43. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -1
  44. package/dist/types/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
  45. package/dist/types/pm-plugins/decorations/utils/types.d.ts +1 -7
  46. package/dist/types/pm-plugins/utils/decoration.d.ts +2 -2
  47. package/dist/types/pm-plugins/utils/sticky-header.d.ts +1 -1
  48. package/dist/types/pm-plugins/utils/tableMode.d.ts +7 -0
  49. package/dist/types-ts4.5/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
  50. package/dist/types-ts4.5/pm-plugins/decorations/utils/types.d.ts +1 -7
  51. package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +2 -2
  52. package/dist/types-ts4.5/pm-plugins/utils/sticky-header.d.ts +1 -1
  53. package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +7 -0
  54. package/package.json +5 -5
@@ -24,8 +24,7 @@ const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHan
24
24
  pluginConfig: {
25
25
  allowColumnResizing
26
26
  },
27
- getIntl,
28
- isDragAndDropEnabled
27
+ getIntl
29
28
  } = getPluginState(state);
30
29
  const fakeDispatch = tr => {
31
30
  customTr = tr;
@@ -39,7 +38,7 @@ const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHan
39
38
  });
40
39
  const decorationsWithWidgetAndHandle = updateDecorations(customTr.doc, decorationsWithWidget, createColumnLineResize(state.selection, {
41
40
  right: columnIndex
42
- }, isDragAndDropEnabled), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
41
+ }), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
43
42
  getTablePluginCommand({
44
43
  type: 'START_KEYBOARD_COLUMN_RESIZE',
45
44
  data: {
@@ -33,13 +33,10 @@ export const hoverMergedCells = () => createCommand(state => {
33
33
  }, tr => tr.setMeta('addToHistory', false));
34
34
  export const hoverColumns = (hoveredColumns, isInDanger) => createCommand(state => {
35
35
  const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
36
- const {
37
- isDragAndDropEnabled
38
- } = getPluginState(state);
39
36
  if (!cells) {
40
37
  return false;
41
38
  }
42
- const decorations = createControlsHoverDecoration(cells, 'column', state.tr, isDragAndDropEnabled, hoveredColumns, isInDanger);
39
+ const decorations = createControlsHoverDecoration(cells, 'column', state.tr, hoveredColumns, isInDanger);
43
40
  return {
44
41
  type: 'HOVER_COLUMNS',
45
42
  data: {
@@ -54,10 +51,7 @@ export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
54
51
  if (!cells) {
55
52
  return false;
56
53
  }
57
- const {
58
- isDragAndDropEnabled
59
- } = getPluginState(state);
60
- const decorations = createControlsHoverDecoration(cells, 'row', state.tr, isDragAndDropEnabled, hoveredRows, isInDanger);
54
+ const decorations = createControlsHoverDecoration(cells, 'row', state.tr, hoveredRows, isInDanger);
61
55
  return {
62
56
  type: 'HOVER_ROWS',
63
57
  data: {
@@ -79,10 +73,7 @@ export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
79
73
  if (!cells) {
80
74
  return false;
81
75
  }
82
- const {
83
- isDragAndDropEnabled
84
- } = getPluginState(state);
85
- const decorations = createControlsHoverDecoration(cells, 'table', state.tr, isDragAndDropEnabled, [], isInDanger, isSelected);
76
+ const decorations = createControlsHoverDecoration(cells, 'table', state.tr, [], isInDanger, isSelected);
86
77
  return {
87
78
  type: 'HOVER_TABLE',
88
79
  data: {
@@ -103,13 +94,10 @@ export const clearHoverSelection = () => createCommand(state => ({
103
94
  }
104
95
  }));
105
96
  export const showResizeHandleLine = cellColumnPositioning => createCommand(state => {
106
- const {
107
- isDragAndDropEnabled
108
- } = getPluginState(state);
109
97
  return {
110
98
  type: 'SHOW_RESIZE_HANDLE_LINE',
111
99
  data: {
112
- decorationSet: updatePluginStateDecorations(state, createColumnLineResize(state.selection, cellColumnPositioning, isDragAndDropEnabled), TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
100
+ decorationSet: updatePluginStateDecorations(state, createColumnLineResize(state.selection, cellColumnPositioning), TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
113
101
  }
114
102
  };
115
103
  });
@@ -10,7 +10,7 @@ import { getDecorations } from '../decorations/plugin';
10
10
  import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../decorations/utils/column-resizing';
11
11
  import { createCommand, getPluginState } from '../plugin-factory';
12
12
  import { fixAutoSizedTable } from '../transforms/fix-tables';
13
- import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
13
+ import { createColumnSelectedDecoration } from '../utils/decoration';
14
14
  import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isIsolating } from '../utils/nodes';
15
15
  import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
16
16
  const DARK_MODE_CELL_COLOR = '#1f1f21';
@@ -27,9 +27,6 @@ export const setTableRef = ref => createCommand(state => {
27
27
  const tableNode = ref && foundTable ? foundTable.node : undefined;
28
28
  const tablePos = ref && foundTable ? foundTable.pos : undefined;
29
29
  const tableWrapperTarget = closestElement(tableRef, `.${ClassName.TABLE_NODE_WRAPPER}`) || undefined;
30
- const {
31
- isDragAndDropEnabled
32
- } = getPluginState(state);
33
30
  return {
34
31
  type: 'SET_TABLE_REF',
35
32
  data: {
@@ -40,8 +37,6 @@ export const setTableRef = ref => createCommand(state => {
40
37
  isNumberColumnEnabled: checkIfNumberColumnEnabled(state.selection),
41
38
  isHeaderRowEnabled: checkIfHeaderRowEnabled(state.selection),
42
39
  isHeaderColumnEnabled: checkIfHeaderColumnEnabled(state.selection),
43
- // decoration set is drawn by the decoration plugin, skip this for DnD as all controls are floating
44
- decorationSet: !isDragAndDropEnabled ? updatePluginStateDecorations(state, createColumnControlsDecoration(state.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS) : undefined,
45
40
  resizeHandleRowIndex: undefined,
46
41
  resizeHandleColumnIndex: undefined
47
42
  }
@@ -14,7 +14,6 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
14
14
  const isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
15
15
  const wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
16
16
  const {
17
- isDragAndDropEnabled = false,
18
17
  isInDanger,
19
18
  isTableHovered
20
19
  } = tablePluginKey.getState(newState) || {};
@@ -26,10 +25,7 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
26
25
  } else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
27
26
  return buildColumnControlsDecorations({
28
27
  decorationSet,
29
- tr,
30
- options: {
31
- isDragAndDropEnabled
32
- }
28
+ tr
33
29
  });
34
30
  } else if (tr.selectionSet) {
35
31
  var _findTable, _findTable2;
@@ -44,10 +40,7 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
44
40
  if ((isInDanger || isTableHovered) && (!insideTable(newState) || ((_findTable = findTable(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = findTable(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
45
41
  return buildColumnControlsDecorations({
46
42
  decorationSet,
47
- tr,
48
- options: {
49
- isDragAndDropEnabled
50
- }
43
+ tr
51
44
  });
52
45
  }
53
46
  }
@@ -1,9 +1,8 @@
1
1
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
2
2
 
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
- import { findTable } from '@atlaskit/editor-tables/utils';
5
4
  import { TableDecorations } from '../../../types';
6
- import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../utils/decoration';
5
+ import { createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../utils/decoration';
7
6
  import { composeDecorations } from './compose-decorations';
8
7
  const isColumnSelected = tr => tr.selection instanceof CellSelection && tr.selection.isColSelection();
9
8
 
@@ -20,16 +19,6 @@ const maybeUpdateColumnSelectedDecoration = ({
20
19
  }
21
20
  return updateDecorations(tr.doc, decorationSet, createColumnSelectedDecoration(tr), TableDecorations.COLUMN_SELECTED);
22
21
  };
23
- const maybeUpdateColumnControlsDecoration = ({
24
- decorationSet,
25
- tr
26
- }) => {
27
- const table = findTable(tr.selection);
28
- if (!table) {
29
- return decorationSet;
30
- }
31
- return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
32
- };
33
22
 
34
23
  // @see: https://product-fabric.atlassian.net/browse/ED-7304
35
24
  const removeColumnControlsSelectedDecoration = ({
@@ -50,16 +39,9 @@ export const maybeUpdateColumnControlsSelectedDecoration = ({
50
39
  };
51
40
  export const buildColumnControlsDecorations = ({
52
41
  decorationSet,
53
- tr,
54
- options
42
+ tr
55
43
  }) => {
56
- if (options.isDragAndDropEnabled) {
57
- return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
58
- decorationSet,
59
- tr
60
- });
61
- }
62
- return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
44
+ return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
63
45
  decorationSet,
64
46
  tr
65
47
  });
@@ -20,7 +20,7 @@ export const createCellHoverDecoration = cells => cells.map(cell => Decoration.n
20
20
  }, {
21
21
  key: TableDecorations.CELL_CONTROLS_HOVER
22
22
  }));
23
- export const createControlsHoverDecoration = (cells, type, tr, isDragAndDropEnable, hoveredIndexes, danger, selected) => {
23
+ export const createControlsHoverDecoration = (cells, type, tr, hoveredIndexes, danger, selected) => {
24
24
  const table = findTable(tr.selection);
25
25
  if (!table) {
26
26
  return [];
@@ -64,13 +64,9 @@ export const createControlsHoverDecoration = (cells, type, tr, isDragAndDropEnab
64
64
  if (selected) {
65
65
  classes.push(ClassName.SELECTED_CELL);
66
66
  }
67
- if (isDragAndDropEnable) {
68
- if (type === 'column' || type === 'row') {
69
- classes.pop();
70
- classes.push(ClassName.HOVERED_NO_HIGHLIGHT);
71
- }
72
- } else {
73
- classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
67
+ if (type === 'column' || type === 'row') {
68
+ classes.pop();
69
+ classes.push(ClassName.HOVERED_NO_HIGHLIGHT);
74
70
  }
75
71
  let key;
76
72
  switch (type) {
@@ -366,7 +362,7 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
366
362
  * this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
367
363
  * only on the cells: `C1` and `D1`.
368
364
  */
369
- export const createColumnLineResize = (selection, cellColumnPositioning, isDragAndDropEnabled) => {
365
+ export const createColumnLineResize = (selection, cellColumnPositioning) => {
370
366
  const table = findTable(selection);
371
367
  if (!table || cellColumnPositioning.right === null) {
372
368
  return [];
@@ -377,7 +373,7 @@ export const createColumnLineResize = (selection, cellColumnPositioning, isDragA
377
373
  if (isLastColumn) {
378
374
  columnIndex -= 1;
379
375
  }
380
- const decorationClassName = isDragAndDropEnabled ? isLastColumn ? ClassName.WITH_DRAG_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_DRAG_RESIZE_LINE : isLastColumn ? ClassName.WITH_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_RESIZE_LINE;
376
+ const decorationClassName = isLastColumn ? ClassName.WITH_DRAG_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_DRAG_RESIZE_LINE;
381
377
  const cellPositions = makeArray(map.height).map(rowIndex => map.map[map.width * rowIndex + columnIndex]).filter((cellPosition, rowIndex) => {
382
378
  if (isLastColumn) {
383
379
  return true; // If is the last column no filter applied
@@ -6,11 +6,11 @@ export const isAnchorSupported = memorizeOne(() => {
6
6
  }
7
7
  return false;
8
8
  });
9
- export const isNativeStickySupported = isDragAndDropEnabled => {
9
+ export const isNativeStickySupported = () => {
10
10
  const safariVersion = getBrowserInfo().safari_version;
11
11
  const isBrowserSafari = !Number.isNaN(safariVersion);
12
12
  return (
13
13
  // Safari has a bug with position: sticky and content editable, so we don't support it
14
- !isBrowserSafari && isAnchorSupported() && isDragAndDropEnabled
14
+ !isBrowserSafari && isAnchorSupported()
15
15
  );
16
16
  };
@@ -77,6 +77,49 @@ export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
77
77
  }
78
78
  };
79
79
 
80
+ /**
81
+ * Temporarily overrides inline styles on the table and its surrounding containers so the browser
82
+ * lays columns out with `table-layout: auto`, takes a content-width measurement, and then
83
+ * **resets every modified style** so no temporary overrides leak into the rendered output.
84
+ */
85
+ export const measureTableWithAutoLayout = tableRef => {
86
+ const cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
87
+ const contentWrap = tableRef.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`);
88
+ const resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(`.${TableSharedCssClassName.TABLE_RESIZER_CONTAINER}`);
89
+ const resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
90
+
91
+ // Capture current inline styles so we can restore them after measurement
92
+ const prevTableWidth = tableRef.style.width;
93
+ const prevTableLayout = tableRef.style.tableLayout;
94
+ const prevColWidths = cols.map(col => col.style.width);
95
+ const prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
96
+
97
+ // Apply temporary styles for content-based measurement
98
+ tableRef.style.width = '';
99
+ tableRef.style.tableLayout = 'auto';
100
+ cols.forEach(col => col.style.width = '');
101
+ if (resizerContainer) {
102
+ // favour CSS var to align with the table first render state, which gets reset
103
+ // once resized by user. By doing this we avoid the need to any 'reset' work after
104
+ // measurement and ensures it works if the table has been resized or not in the session.
105
+ resizerContainer.style.width = 'var(--ak-editor-table-width)';
106
+ resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
107
+ }
108
+ if (resizerItem) {
109
+ resizerItem.style.width = 'max-content';
110
+ }
111
+ const measurement = getTableMeasurement(tableRef);
112
+
113
+ // Reset all inline styles back to their previous values
114
+ tableRef.style.width = prevTableWidth;
115
+ tableRef.style.tableLayout = prevTableLayout;
116
+ cols.forEach((col, i) => col.style.width = prevColWidths[i]);
117
+ if (resizerItem) {
118
+ resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
119
+ }
120
+ return measurement;
121
+ };
122
+
80
123
  /**
81
124
  * Used to measure a selected table width with it's content being laid out natively by the browser
82
125
  */
@@ -94,26 +137,11 @@ export const applyMeasuredWidthToSelectedTable = (view, api) => {
94
137
  if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
95
138
  return;
96
139
  }
97
- const tableRef = tableState.tableRef;
98
140
 
99
141
  // Instead of dispatching a transaction to "strip widths" and then waiting
100
- // for a rAF to measure natural column widths, instea directly update the DOM elements and
101
- // take a measurement.
102
- const cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
103
- const contentWrap = tableRef.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`);
104
- const resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(`.${TableSharedCssClassName.TABLE_RESIZER_CONTAINER}`);
105
- const resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
106
- tableRef.style.width = '';
107
- tableRef.style.tableLayout = 'auto';
108
- cols.forEach(col => col.style.width = '');
109
- if (resizerContainer) {
110
- resizerContainer.style.width = 'max-content';
111
- resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
112
- }
113
- if (resizerItem) {
114
- resizerItem.style.width = 'max-content';
115
- }
116
- const measurement = getTableMeasurement(tableRef);
142
+ // for a rAF to measure natural column widths, directly update the DOM elements,
143
+ // take a measurement, and reset styles so no temporary overrides persist.
144
+ const measurement = measureTableWithAutoLayout(tableState.tableRef);
117
145
  const tr = applyTableMeasurement(view.state.tr, node, measurement, pos);
118
146
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
119
147
  action: TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
@@ -347,8 +347,7 @@ const tablePlugin = ({
347
347
  },
348
348
  eventType: EVENT_TYPE.TRACK
349
349
  })(tr);
350
- },
351
- dragAndDropEnabled: true
350
+ }
352
351
  });
353
352
  }
354
353
  }, {
@@ -42,7 +42,6 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
42
42
  tableWrapper,
43
43
  targetCellPosition,
44
44
  isCellMenuOpenByKeyboard,
45
- isDragAndDropEnabled,
46
45
  intl: {
47
46
  formatMessage
48
47
  }
@@ -102,7 +101,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
102
101
  }));
103
102
  const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
104
103
  const parentStickyNative = targetCellRef.parentElement && (fg('platform_editor_table_sticky_header_patch_4') ? tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW) : targetCellRef.parentElement.classList.contains(ClassName.NATIVE_STICKY));
105
- if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
104
+ if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
106
105
  var _targetCellRef$parent;
107
106
  /* We need to default to checking the anchor style because there may be a conflict with the block controls
108
107
  plugin not using the data attribute value and setting the `anchor-name` style property independently of the data attribute.
@@ -8,7 +8,6 @@ import { Popup } from '@atlaskit/editor-common/ui';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
11
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
11
  import { getPluginState } from '../../pm-plugins/plugin-factory';
13
12
  import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
14
13
 
@@ -31,25 +30,18 @@ const FloatingContextualMenu = ({
31
30
  api,
32
31
  isDragMenuOpen
33
32
  }) => {
34
- if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
33
+ if (!editorView) {
35
34
  return null;
36
35
  }
37
36
 
38
37
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
39
- // Remove ! during platform_editor_hydratable_ui cleanup
40
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
41
38
  const {
42
39
  targetCellPosition,
43
40
  isDragAndDropEnabled
44
41
  } = getPluginState(editorView.state);
45
- // Remove ! during platform_editor_hydratable_ui cleanup
46
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
47
42
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
48
43
  return null;
49
44
  }
50
-
51
- // Remove ! during platform_editor_hydratable_ui cleanup
52
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
53
45
  const {
54
46
  selection
55
47
  } = editorView.state;
@@ -60,8 +52,6 @@ const FloatingContextualMenu = ({
60
52
  if (!selectionRect) {
61
53
  return null;
62
54
  }
63
- // Remove ! during platform_editor_hydratable_ui cleanup
64
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
65
55
  const domAtPos = editorView.domAtPos.bind(editorView);
66
56
  const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
67
57
  if (!targetCellRef) {
@@ -91,10 +81,7 @@ const FloatingContextualMenu = ({
91
81
  stick: true
92
82
  }, jsx("div", {
93
83
  css: tablePopupStyles(isDragAndDropEnabled)
94
- }, jsx(ContextualMenu
95
- // Remove ! during platform_editor_hydratable_ui cleanup
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- , {
84
+ }, jsx(ContextualMenu, {
98
85
  editorView: editorView
99
86
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
100
87
  ,
@@ -74,7 +74,7 @@ const TableFloatingColumnControls = ({
74
74
  containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.removeProperty('top');
75
75
  }
76
76
  let anchorStyles = {};
77
- if (isNativeStickySupported(isDragAndDropEnabled !== null && isDragAndDropEnabled !== void 0 ? isDragAndDropEnabled : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
77
+ if (isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
78
78
  var _tableRef$querySelect, _tableRef$querySelect2;
79
79
  const rowAnchorName = (_tableRef$querySelect = tableRef.querySelector('tr')) === null || _tableRef$querySelect === void 0 ? void 0 : _tableRef$querySelect.style.getPropertyValue('anchor-name');
80
80
  // cast here is due to CSSProperties missing valid positionAnchor property
@@ -134,18 +134,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
134
134
  var prevNode = _this.node;
135
135
  var node = getNode();
136
136
  var prevAttrs = prevNode.attrs;
137
- var isNested = isTableNested(_this.props.view.state, _this.props.getPos());
138
137
  var tablePos = _this.props.getPos();
138
+ var isNested = isTableNested(_this.props.view.state, tablePos);
139
139
  var parentWidth = _this.getParentNodeWidth();
140
140
  var useMeasuredWidthForBodiedSyncBlock = isNested && typeof tablePos === 'number' && isTableNestedUnderBodiedSyncBlock(_this.props.view.state, tablePos) && fg('platform_synced_block_patch_9');
141
141
  if (useMeasuredWidthForBodiedSyncBlock) {
142
142
  // Prefer the live DOM measurement (`clientWidth`) over the ResizeObserver-cached
143
143
  // value (`wrapperWidth`) because clientWidth is synchronous and more up-to-date
144
144
  // at the time this handler runs. Fall back to `wrapperWidth` if the wrapper ref
145
- // is not yet available. Both are guarded by `> 1` to ignore degenerate values
146
- // that can appear before the element has been laid out.
145
+ // is not yet available.
146
+ // The clientWidth > 0 since DOM clientWidth is 0 before layout
147
+ // The > 1 guard for wrapperWidth was intentional to filter out the degenerate value of 1 that ResizeObserver reports during element unmounting.
147
148
  var measuredWrapperWidth;
148
- if (_this.wrapper && _this.wrapper.clientWidth > 1) {
149
+ if (_this.wrapper && _this.wrapper.clientWidth > 0) {
149
150
  measuredWrapperWidth = _this.wrapper.clientWidth;
150
151
  } else if (_this.wrapperWidth && _this.wrapperWidth > 1) {
151
152
  measuredWrapperWidth = _this.wrapperWidth;
@@ -156,7 +157,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
156
157
  parentWidth = measuredWrapperWidth;
157
158
  }
158
159
  }
159
- if (!useMeasuredWidthForBodiedSyncBlock && isNested && isTableNestedInMoreThanOneNode(_this.props.view.state, _this.props.getPos())) {
160
+ if (!useMeasuredWidthForBodiedSyncBlock && isNested && isTableNestedInMoreThanOneNode(_this.props.view.state, tablePos)) {
160
161
  var resizeObsWrapperWidth = _this.wrapperWidth || 0;
161
162
  var wrapperWidthDiffBetweenRerenders = Math.abs(resizeObsWrapperWidth - (_this.state.parentWidth || 0));
162
163
  var isOusideOfThreshold = wrapperWidthDiffBetweenRerenders <= NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MIN_THRESHOLD || wrapperWidthDiffBetweenRerenders > NESTED_TABLE_IN_NESTED_PARENT_WIDTH_DIFF_MAX_THRESHOLD;
@@ -24,8 +24,7 @@ export var tableHeaderView = function tableHeaderView(options) {
24
24
  };
25
25
  export var tableRowView = function tableRowView(options) {
26
26
  return function (node, view, getPos) {
27
- var _options$isDragAndDro;
28
- if (isNativeStickySupported((_options$isDragAndDro = options.isDragAndDropEnabled) !== null && _options$isDragAndDro !== void 0 ? _options$isDragAndDro : false) && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
27
+ if (isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
29
28
  return new TableRowNativeStickyWithFallback(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
30
29
  } else {
31
30
  return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
@@ -27,8 +27,7 @@ var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosi
27
27
  var customTr = state.tr;
28
28
  var _getPluginState = getPluginState(state),
29
29
  allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
30
- getIntl = _getPluginState.getIntl,
31
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
30
+ getIntl = _getPluginState.getIntl;
32
31
  var fakeDispatch = function fakeDispatch(tr) {
33
32
  customTr = tr;
34
33
  };
@@ -41,7 +40,7 @@ var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosi
41
40
  });
42
41
  var decorationsWithWidgetAndHandle = updateDecorations(customTr.doc, decorationsWithWidget, createColumnLineResize(state.selection, {
43
42
  right: columnIndex
44
- }, isDragAndDropEnabled), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
43
+ }), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
45
44
  getTablePluginCommand({
46
45
  type: 'START_KEYBOARD_COLUMN_RESIZE',
47
46
  data: {
@@ -42,12 +42,10 @@ export var hoverMergedCells = function hoverMergedCells() {
42
42
  export var hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
43
43
  return createCommand(function (state) {
44
44
  var cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
45
- var _getPluginState = getPluginState(state),
46
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
47
45
  if (!cells) {
48
46
  return false;
49
47
  }
50
- var decorations = createControlsHoverDecoration(cells, 'column', state.tr, isDragAndDropEnabled, hoveredColumns, isInDanger);
48
+ var decorations = createControlsHoverDecoration(cells, 'column', state.tr, hoveredColumns, isInDanger);
51
49
  return {
52
50
  type: 'HOVER_COLUMNS',
53
51
  data: {
@@ -66,9 +64,7 @@ export var hoverRows = function hoverRows(hoveredRows, isInDanger) {
66
64
  if (!cells) {
67
65
  return false;
68
66
  }
69
- var _getPluginState2 = getPluginState(state),
70
- isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
71
- var decorations = createControlsHoverDecoration(cells, 'row', state.tr, isDragAndDropEnabled, hoveredRows, isInDanger);
67
+ var decorations = createControlsHoverDecoration(cells, 'row', state.tr, hoveredRows, isInDanger);
72
68
  return {
73
69
  type: 'HOVER_ROWS',
74
70
  data: {
@@ -94,9 +90,7 @@ export var hoverTable = function hoverTable(isInDanger, isSelected) {
94
90
  if (!cells) {
95
91
  return false;
96
92
  }
97
- var _getPluginState3 = getPluginState(state),
98
- isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
99
- var decorations = createControlsHoverDecoration(cells, 'table', state.tr, isDragAndDropEnabled, [], isInDanger, isSelected);
93
+ var decorations = createControlsHoverDecoration(cells, 'table', state.tr, [], isInDanger, isSelected);
100
94
  return {
101
95
  type: 'HOVER_TABLE',
102
96
  data: {
@@ -125,12 +119,10 @@ export var clearHoverSelection = function clearHoverSelection() {
125
119
  };
126
120
  export var showResizeHandleLine = function showResizeHandleLine(cellColumnPositioning) {
127
121
  return createCommand(function (state) {
128
- var _getPluginState4 = getPluginState(state),
129
- isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
130
122
  return {
131
123
  type: 'SHOW_RESIZE_HANDLE_LINE',
132
124
  data: {
133
- decorationSet: updatePluginStateDecorations(state, createColumnLineResize(state.selection, cellColumnPositioning, isDragAndDropEnabled), TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
125
+ decorationSet: updatePluginStateDecorations(state, createColumnLineResize(state.selection, cellColumnPositioning), TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
134
126
  }
135
127
  };
136
128
  });
@@ -159,8 +151,8 @@ export var setTableHovered = function setTableHovered(hovered) {
159
151
  };
160
152
  export var hoverCell = function hoverCell(rowIndex, colIndex) {
161
153
  return createCommand(function (state) {
162
- var _getPluginState5 = getPluginState(state),
163
- prevHoveredCell = _getPluginState5.hoveredCell;
154
+ var _getPluginState = getPluginState(state),
155
+ prevHoveredCell = _getPluginState.hoveredCell;
164
156
 
165
157
  // If no arguments have been passed then the intention it to reset the hover cell data
166
158
  var clear = rowIndex === undefined && colIndex === undefined;
@@ -14,7 +14,7 @@ import { getDecorations } from '../decorations/plugin';
14
14
  import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../decorations/utils/column-resizing';
15
15
  import { createCommand, getPluginState } from '../plugin-factory';
16
16
  import { fixAutoSizedTable } from '../transforms/fix-tables';
17
- import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
17
+ import { createColumnSelectedDecoration } from '../utils/decoration';
18
18
  import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isIsolating } from '../utils/nodes';
19
19
  import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
20
20
  var DARK_MODE_CELL_COLOR = '#1f1f21';
@@ -34,8 +34,6 @@ export var setTableRef = function setTableRef(ref) {
34
34
  var tableNode = ref && foundTable ? foundTable.node : undefined;
35
35
  var tablePos = ref && foundTable ? foundTable.pos : undefined;
36
36
  var tableWrapperTarget = closestElement(tableRef, ".".concat(ClassName.TABLE_NODE_WRAPPER)) || undefined;
37
- var _getPluginState = getPluginState(state),
38
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
39
37
  return {
40
38
  type: 'SET_TABLE_REF',
41
39
  data: {
@@ -46,8 +44,6 @@ export var setTableRef = function setTableRef(ref) {
46
44
  isNumberColumnEnabled: checkIfNumberColumnEnabled(state.selection),
47
45
  isHeaderRowEnabled: checkIfHeaderRowEnabled(state.selection),
48
46
  isHeaderColumnEnabled: checkIfHeaderColumnEnabled(state.selection),
49
- // decoration set is drawn by the decoration plugin, skip this for DnD as all controls are floating
50
- decorationSet: !isDragAndDropEnabled ? updatePluginStateDecorations(state, createColumnControlsDecoration(state.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS) : undefined,
51
47
  resizeHandleRowIndex: undefined,
52
48
  resizeHandleColumnIndex: undefined
53
49
  }
@@ -332,8 +328,8 @@ export var setMultipleCellAttrs = function setMultipleCellAttrs(attrs, editorVie
332
328
  return function (state, dispatch) {
333
329
  var cursorPos;
334
330
  var tr = state.tr;
335
- var _getPluginState2 = getPluginState(state),
336
- targetCellPosition = _getPluginState2.targetCellPosition;
331
+ var _getPluginState = getPluginState(state),
332
+ targetCellPosition = _getPluginState.targetCellPosition;
337
333
  if (isSelectionType(tr.selection, 'cell')) {
338
334
  // Ignored via go/ees005
339
335
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -494,9 +490,9 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
494
490
  export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, nodeViewPortalProviderAPI, isKeyboardResize) {
495
491
  return createCommand(function (state) {
496
492
  var tableNode = findTable(state.selection);
497
- var _getPluginState3 = getPluginState(state),
498
- allowColumnResizing = _getPluginState3.pluginConfig.allowColumnResizing,
499
- getIntl = _getPluginState3.getIntl;
493
+ var _getPluginState2 = getPluginState(state),
494
+ allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
495
+ getIntl = _getPluginState2.getIntl;
500
496
  if (!tableNode || !allowColumnResizing) {
501
497
  return false;
502
498
  }
@@ -520,12 +516,12 @@ export var addResizeHandleDecorations = function addResizeHandleDecorations(rowI
520
516
  export var updateResizeHandleDecorations = function updateResizeHandleDecorations(nodeViewPortalProviderAPI, rowIndex, columnIndex, includeTooltip) {
521
517
  return createCommand(function (state) {
522
518
  var tableNode = findTable(state.selection);
523
- var _getPluginState4 = getPluginState(state),
524
- resizeHandleRowIndex = _getPluginState4.resizeHandleRowIndex,
525
- resizeHandleColumnIndex = _getPluginState4.resizeHandleColumnIndex,
526
- resizeHandleIncludeTooltip = _getPluginState4.resizeHandleIncludeTooltip,
527
- allowColumnResizing = _getPluginState4.pluginConfig.allowColumnResizing,
528
- getIntl = _getPluginState4.getIntl;
519
+ var _getPluginState3 = getPluginState(state),
520
+ resizeHandleRowIndex = _getPluginState3.resizeHandleRowIndex,
521
+ resizeHandleColumnIndex = _getPluginState3.resizeHandleColumnIndex,
522
+ resizeHandleIncludeTooltip = _getPluginState3.resizeHandleIncludeTooltip,
523
+ allowColumnResizing = _getPluginState3.pluginConfig.allowColumnResizing,
524
+ getIntl = _getPluginState3.getIntl;
529
525
  if (!tableNode || !allowColumnResizing) {
530
526
  return false;
531
527
  }
@@ -599,8 +595,8 @@ export var addBoldInEmptyHeaderCells = function addBoldInEmptyHeaderCells(tableC
599
595
  };
600
596
  export var updateWidthToWidest = function updateWidthToWidest(widthToWidest) {
601
597
  return createCommand(function (state) {
602
- var _getPluginState5 = getPluginState(state),
603
- prevWidthToWidest = _getPluginState5.widthToWidest;
598
+ var _getPluginState4 = getPluginState(state),
599
+ prevWidthToWidest = _getPluginState4.widthToWidest;
604
600
  if (isEqual(widthToWidest, prevWidthToWidest)) {
605
601
  return false;
606
602
  }