@atlaskit/editor-plugin-table 7.6.3 → 7.6.5

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 (141) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/column-resize.js +62 -16
  3. package/dist/cjs/commands/go-to-next-cell.js +5 -2
  4. package/dist/cjs/commands/misc.js +3 -2
  5. package/dist/cjs/commands-with-analytics.js +8 -2
  6. package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -0
  7. package/dist/cjs/nodeviews/TableComponent.js +8 -6
  8. package/dist/cjs/nodeviews/TableContainer.js +32 -20
  9. package/dist/cjs/nodeviews/TableResizer.js +40 -28
  10. package/dist/cjs/plugin.js +60 -58
  11. package/dist/cjs/pm-plugins/keymap.js +26 -8
  12. package/dist/cjs/pm-plugins/main.js +15 -4
  13. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +4 -2
  14. package/dist/cjs/toolbar.js +5 -4
  15. package/dist/cjs/ui/DragHandle/index.js +2 -2
  16. package/dist/cjs/ui/DragPreview/index.js +2 -0
  17. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +10 -6
  18. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  19. package/dist/cjs/ui/FloatingDeleteButton/index.js +2 -0
  20. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
  21. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  22. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -0
  23. package/dist/cjs/ui/LayoutButton/index.js +2 -0
  24. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  25. package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  26. package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  27. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  28. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  29. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  30. package/dist/cjs/ui/common-styles.js +4 -0
  31. package/dist/cjs/ui/ui-styles.js +93 -37
  32. package/dist/cjs/utils/guidelines.js +1 -1
  33. package/dist/es2019/commands/column-resize.js +53 -4
  34. package/dist/es2019/commands/go-to-next-cell.js +5 -2
  35. package/dist/es2019/commands/misc.js +6 -2
  36. package/dist/es2019/commands-with-analytics.js +8 -2
  37. package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -0
  38. package/dist/es2019/nodeviews/TableComponent.js +9 -7
  39. package/dist/es2019/nodeviews/TableContainer.js +17 -3
  40. package/dist/es2019/nodeviews/TableResizer.js +27 -17
  41. package/dist/es2019/plugin.js +6 -3
  42. package/dist/es2019/pm-plugins/keymap.js +25 -9
  43. package/dist/es2019/pm-plugins/main.js +15 -4
  44. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +4 -2
  45. package/dist/es2019/toolbar.js +5 -4
  46. package/dist/es2019/ui/DragHandle/index.js +2 -2
  47. package/dist/es2019/ui/DragPreview/index.js +2 -0
  48. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +10 -6
  49. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  50. package/dist/es2019/ui/FloatingDeleteButton/index.js +2 -0
  51. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
  52. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
  53. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -0
  54. package/dist/es2019/ui/LayoutButton/index.js +2 -0
  55. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  56. package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  57. package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  58. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  59. package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  60. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  61. package/dist/es2019/ui/common-styles.js +4 -0
  62. package/dist/es2019/ui/ui-styles.js +66 -70
  63. package/dist/es2019/utils/guidelines.js +1 -1
  64. package/dist/esm/commands/column-resize.js +62 -16
  65. package/dist/esm/commands/go-to-next-cell.js +5 -2
  66. package/dist/esm/commands/misc.js +3 -2
  67. package/dist/esm/commands-with-analytics.js +8 -2
  68. package/dist/esm/nodeviews/ExternalDropTargets.js +2 -0
  69. package/dist/esm/nodeviews/TableComponent.js +9 -7
  70. package/dist/esm/nodeviews/TableContainer.js +32 -20
  71. package/dist/esm/nodeviews/TableResizer.js +41 -29
  72. package/dist/esm/plugin.js +60 -58
  73. package/dist/esm/pm-plugins/keymap.js +26 -8
  74. package/dist/esm/pm-plugins/main.js +15 -4
  75. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +4 -2
  76. package/dist/esm/toolbar.js +5 -4
  77. package/dist/esm/ui/DragHandle/index.js +2 -2
  78. package/dist/esm/ui/DragPreview/index.js +2 -0
  79. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +10 -6
  80. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  81. package/dist/esm/ui/FloatingDeleteButton/index.js +2 -0
  82. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
  83. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  84. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -0
  85. package/dist/esm/ui/LayoutButton/index.js +2 -0
  86. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  87. package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  88. package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  89. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  90. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  91. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  92. package/dist/esm/ui/common-styles.js +4 -0
  93. package/dist/esm/ui/ui-styles.js +93 -37
  94. package/dist/esm/utils/guidelines.js +1 -1
  95. package/dist/types/commands/column-resize.d.ts +23 -4
  96. package/dist/types/commands/go-to-next-cell.d.ts +2 -1
  97. package/dist/types/commands/misc.d.ts +2 -1
  98. package/dist/types/commands-with-analytics.d.ts +2 -1
  99. package/dist/types/nodeviews/TableResizer.d.ts +3 -1
  100. package/dist/types/pm-plugins/keymap.d.ts +3 -1
  101. package/dist/types/types.d.ts +13 -3
  102. package/dist/types-ts4.5/commands/column-resize.d.ts +23 -4
  103. package/dist/types-ts4.5/commands/go-to-next-cell.d.ts +2 -1
  104. package/dist/types-ts4.5/commands/misc.d.ts +2 -1
  105. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -1
  106. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +3 -1
  107. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -1
  108. package/dist/types-ts4.5/types.d.ts +13 -3
  109. package/package.json +3 -6
  110. package/src/commands/column-resize.ts +105 -29
  111. package/src/commands/go-to-next-cell.ts +10 -2
  112. package/src/commands/misc.ts +6 -3
  113. package/src/commands-with-analytics.ts +11 -5
  114. package/src/nodeviews/ExternalDropTargets.tsx +2 -0
  115. package/src/nodeviews/TableComponent.tsx +14 -16
  116. package/src/nodeviews/TableContainer.tsx +18 -3
  117. package/src/nodeviews/TableResizer.tsx +35 -21
  118. package/src/plugin.tsx +4 -1
  119. package/src/pm-plugins/keymap.ts +44 -6
  120. package/src/pm-plugins/main.ts +18 -4
  121. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -2
  122. package/src/toolbar.tsx +20 -19
  123. package/src/types.ts +14 -2
  124. package/src/ui/DragHandle/index.tsx +2 -2
  125. package/src/ui/DragPreview/index.tsx +2 -0
  126. package/src/ui/FloatingContextualButton/FixedButton.tsx +9 -6
  127. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
  128. package/src/ui/FloatingDeleteButton/index.tsx +2 -0
  129. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
  130. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
  131. package/src/ui/FloatingInsertButton/InsertButton.tsx +1 -0
  132. package/src/ui/LayoutButton/index.tsx +2 -0
  133. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -0
  134. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +3 -0
  135. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +1 -0
  136. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -0
  137. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -0
  138. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -1
  139. package/src/ui/common-styles.ts +2 -0
  140. package/src/ui/ui-styles.ts +90 -79
  141. package/src/utils/guidelines.ts +5 -4
@@ -1,3 +1,4 @@
1
+ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
1
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
3
  import { TableMap } from '@atlaskit/editor-tables';
3
4
  import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/utils';
@@ -60,25 +61,35 @@ var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosi
60
61
  return false;
61
62
  };
62
63
  };
63
- export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResizing(state, dispatch, view) {
64
- if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
64
+ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResizing(_ref) {
65
+ var ariaNotify = _ref.ariaNotify,
66
+ getIntl = _ref.getIntl;
67
+ return function (state, dispatch, view) {
68
+ if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
69
+ return false;
70
+ }
71
+ var selection = state.selection;
72
+ var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
73
+ var cell = findCellClosestToPos(selection.$from);
74
+ if (ariaNotify && getIntl) {
75
+ ariaNotify(getIntl().formatMessage(messages.startedColumnResize));
76
+ }
77
+ if (selectionRect && cell && view) {
78
+ return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
79
+ }
65
80
  return false;
66
- }
67
- var selection = state.selection;
68
- var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
69
- var cell = findCellClosestToPos(selection.$from);
70
- if (selectionRect && cell && view) {
71
- return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
72
- }
73
- return false;
81
+ };
74
82
  };
75
- export var activateNextResizeArea = function activateNextResizeArea(direction) {
83
+ export var activateNextResizeArea = function activateNextResizeArea(_ref2) {
84
+ var direction = _ref2.direction,
85
+ ariaNotify = _ref2.ariaNotify,
86
+ getIntl = _ref2.getIntl;
76
87
  return function (state, dispatch, view) {
77
88
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
78
89
  return false;
79
90
  }
80
- var _ref = getTableResizingPluginState(state) || {},
81
- resizeHandlePos = _ref.resizeHandlePos;
91
+ var _ref3 = getTableResizingPluginState(state) || {},
92
+ resizeHandlePos = _ref3.resizeHandlePos;
82
93
  // If No resizing has initiated, skip to regular handler
83
94
  if (!resizeHandlePos) {
84
95
  return false;
@@ -101,6 +112,18 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
101
112
  }
102
113
  var currentCellRect = tableMap.findCell($currentCell.pos - $currentCell.start(-1));
103
114
  var $nextCell = nextCell($currentCell, 'horiz', direction);
115
+ if (ariaNotify && getIntl) {
116
+ var columnDirection = '';
117
+ if (direction === 1) {
118
+ columnDirection = getIntl().formatMessage(messages.columnRightResize);
119
+ }
120
+ if (direction === -1) {
121
+ columnDirection = getIntl().formatMessage(messages.columnLeftResize);
122
+ }
123
+ ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
124
+ direction: columnDirection
125
+ }));
126
+ }
104
127
  if ($nextCell) {
105
128
  // we are somewhere in between the side columns of the table
106
129
  var offset = $nextCell.pos - $nextCell.start(-1);
@@ -121,8 +144,12 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
121
144
  return false;
122
145
  };
123
146
  };
124
- export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
125
- var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
147
+ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
148
+ var stepSize = _ref4.stepSize,
149
+ getEditorContainerWidth = _ref4.getEditorContainerWidth,
150
+ isTableScalingEnabled = _ref4.isTableScalingEnabled,
151
+ ariaNotify = _ref4.ariaNotify,
152
+ getIntl = _ref4.getIntl;
126
153
  return function (state, dispatch, view) {
127
154
  var customTr = state.tr;
128
155
  var fakeDispatch = function fakeDispatch(tr) {
@@ -184,10 +211,26 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
184
211
  if (dispatch) {
185
212
  dispatch(customTr);
186
213
  }
214
+ if (ariaNotify && getIntl) {
215
+ ariaNotify(getIntl().formatMessage(messages.changedColumnWidth, {
216
+ width: Math.floor(newResizeState.cols[colIndex].width)
217
+ }));
218
+ if (newResizeState.cols.length === colIndex + 1) {
219
+ if (newResizeState.overflow === true) {
220
+ ariaNotify(getIntl().formatMessage(messages.columnResizeLast));
221
+ }
222
+ if (newResizeState.overflow === false) {
223
+ ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow));
224
+ }
225
+ }
226
+ }
187
227
  return true;
188
228
  };
189
229
  };
190
- export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(originalTr) {
230
+ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(_ref5) {
231
+ var ariaNotify = _ref5.ariaNotify,
232
+ getIntl = _ref5.getIntl,
233
+ originalTr = _ref5.originalTr;
191
234
  return function (state, dispatch) {
192
235
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
193
236
  return false;
@@ -212,6 +255,9 @@ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(orig
212
255
  }, function () {
213
256
  return customTr.setMeta('scrollIntoView', false);
214
257
  })(state, fakeDispatch);
258
+ if (ariaNotify && getIntl) {
259
+ ariaNotify(getIntl().formatMessage(messages.columnResizeStop));
260
+ }
215
261
  if (dispatch) {
216
262
  dispatch(customTr);
217
263
  return true;
@@ -10,7 +10,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
10
10
  import { stopKeyboardColumnResizing } from './column-resize';
11
11
  var TAB_FORWARD_DIRECTION = 1;
12
12
  var TAB_BACKWARD_DIRECTION = -1;
13
- export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
13
+ export var goToNextCell = function goToNextCell(editorAnalyticsAPI, ariaNotify, getIntl) {
14
14
  return function (direction) {
15
15
  return function (state, dispatch, view) {
16
16
  var table = findTable(state.selection);
@@ -21,7 +21,10 @@ export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
21
21
  var _getPluginState;
22
22
  var isColumnResizing = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
23
23
  if (isColumnResizing) {
24
- stopKeyboardColumnResizing()(state, dispatch, view);
24
+ stopKeyboardColumnResizing({
25
+ ariaNotify: ariaNotify,
26
+ getIntl: getIntl
27
+ })(state, dispatch, view);
25
28
  return true;
26
29
  }
27
30
  }
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import isEqual from 'lodash/isEqual';
5
6
  import { closestElement, isParagraph, isTextSelection, mapSlice } from '@atlaskit/editor-common/utils';
6
7
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
7
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -559,13 +560,13 @@ export var updateWidthToWidest = function updateWidthToWidest(widthToWidest) {
559
560
  return createCommand(function (state) {
560
561
  var _getPluginState4 = getPluginState(state),
561
562
  prevWidthToWidest = _getPluginState4.widthToWidest;
562
- if (prevWidthToWidest === widthToWidest) {
563
+ if (isEqual(widthToWidest, prevWidthToWidest)) {
563
564
  return false;
564
565
  }
565
566
  return {
566
567
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST',
567
568
  data: {
568
- widthToWidest: widthToWidest
569
+ widthToWidest: _objectSpread(_objectSpread({}, prevWidthToWidest), widthToWidest)
569
570
  }
570
571
  };
571
572
  });
@@ -184,7 +184,7 @@ export var insertRowWithAnalytics = function insertRowWithAnalytics(editorAnalyt
184
184
  };
185
185
  };
186
186
  export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI) {
187
- return function (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod) {
187
+ return function (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod, ariaNotify, getIntl) {
188
188
  return withEditorAnalyticsAPI(function (state) {
189
189
  var _getSelectedTableInfo2 = getSelectedTableInfo(state.selection),
190
190
  table = _getSelectedTableInfo2.table,
@@ -206,7 +206,13 @@ export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthBySt
206
206
  totalColumnCount: totalColumnCount
207
207
  }
208
208
  };
209
- })(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth, isTableScalingEnabled));
209
+ })(editorAnalyticsAPI)(changeColumnWidthByStep({
210
+ stepSize: stepSize,
211
+ getEditorContainerWidth: getEditorContainerWidth,
212
+ isTableScalingEnabled: isTableScalingEnabled,
213
+ ariaNotify: ariaNotify,
214
+ getIntl: getIntl
215
+ }));
210
216
  };
211
217
  };
212
218
  export var insertColumnWithAnalytics = function insertColumnWithAnalytics(editorAnalyticsAPI) {
@@ -42,6 +42,7 @@ export var ExternalDropTargets = function ExternalDropTargets(_ref) {
42
42
  width: getTableWrapperWidth(),
43
43
  overflow: 'hidden',
44
44
  position: 'absolute',
45
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
45
46
  top: "-".concat(dropTargetExtendedWidth - tableMarginTop, "px"),
46
47
  pointerEvents: 'auto',
47
48
  zIndex: "".concat(dropTargetsZIndex)
@@ -51,6 +52,7 @@ export var ExternalDropTargets = function ExternalDropTargets(_ref) {
51
52
  style: {
52
53
  display: 'flex',
53
54
  // move drop targets based on table wrapper scroll
55
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
54
56
  marginLeft: "-".concat(getScrollOffset(), "px")
55
57
  }
56
58
  }, colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width, index) {
@@ -21,7 +21,7 @@ import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-commo
21
21
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
22
22
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
23
23
  import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
24
- import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
24
+ import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
25
25
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
26
26
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
27
27
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
@@ -35,7 +35,6 @@ import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup
35
35
  import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
36
36
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
37
37
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
38
- import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
39
38
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
40
39
  import TableFloatingControls from '../ui/TableFloatingControls';
41
40
  import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
@@ -741,7 +740,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
741
740
  style: {
742
741
  visibility: showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
743
742
  top: "".concat(topStickyShadowPosition, "px"),
744
- paddingBottom: "".concat(isDragAndDropEnabled ? '1px' : '')
743
+ paddingBottom: "".concat(isDragAndDropEnabled && "var(--ds-space-025, 2px)")
745
744
  }
746
745
  }), /*#__PURE__*/React.createElement("div", {
747
746
  className: classnames(ClassName.TABLE_NODE_WRAPPER),
@@ -760,10 +759,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
760
759
  }, allowControls && colControls), stickyScrollbar && /*#__PURE__*/React.createElement("div", {
761
760
  className: ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
762
761
  style: {
763
- height: MAX_BROWSER_SCROLLBAR_HEIGHT,
762
+ height: "var(--ds-space-250, 20px)",
763
+ // MAX_BROWSER_SCROLLBAR_HEIGHT
764
764
  display: 'none',
765
765
  // prevent unwanted scroll during table resize without removing scrollbar container from the dom
766
- width: isResizing ? '0px' : '100%'
766
+ width: isResizing ? "var(--ds-space-0, 0px)" : '100%'
767
767
  }
768
768
  }, /*#__PURE__*/React.createElement("div", {
769
769
  style: {
@@ -777,14 +777,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
777
777
  }), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
778
778
  style: {
779
779
  position: 'absolute',
780
- right: getBooleanFF('platform.editor.custom-table-width') ? "".concat(getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? tableOverflowShadowWidthWide : tableOverflowShadowWidth, "px") : '-2px'
780
+ right: getBooleanFF('platform.editor.custom-table-width') ? "".concat(getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? "var(--ds-space-400, 32px)" // tableOverflowShadowWidthWide
781
+ : "var(--ds-space-100, 8px)" // tableOverflowShadowWidth
782
+ ) : "var(--ds-space-negative-025, -2px)"
781
783
  }
782
784
  }, /*#__PURE__*/React.createElement("div", {
783
785
  className: "".concat(ClassName.TABLE_RIGHT_SHADOW, " ").concat(ClassName.TABLE_STICKY_SHADOW),
784
786
  style: {
785
787
  visibility: showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
786
788
  top: "".concat(topStickyShadowPosition, "px"),
787
- paddingBottom: "".concat(isDragAndDropEnabled ? '1px' : '')
789
+ paddingBottom: "".concat(isDragAndDropEnabled && "var(--ds-space-025, 2px)")
788
790
  }
789
791
  })), /*#__PURE__*/React.createElement("div", {
790
792
  className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM,
@@ -4,6 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import React, { forwardRef, useCallback, useRef, useState } from 'react';
6
6
  import classNames from 'classnames';
7
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
8
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
9
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
9
10
  import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
@@ -32,10 +33,11 @@ export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
33
  className: className,
33
34
  "data-number-column": node.attrs.isNumberColumnEnabled,
34
35
  "data-layout": node.attrs.layout,
35
- "data-test-id": "table-container"
36
+ "data-testid": "table-container"
36
37
  }, children);
37
38
  });
38
39
  export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
40
+ var _node$attrs$localId, _node$attrs;
39
41
  var children = _ref2.children,
40
42
  className = _ref2.className,
41
43
  node = _ref2.node,
@@ -107,9 +109,18 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
107
109
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
108
110
  }, [pluginInjectionApi]);
109
111
  var tableWidth = getTableContainerWidth(node);
112
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
113
+ tableState = _useSharedPluginState.tableState;
114
+ var _ref3 = tableState,
115
+ widthToWidest = _ref3.widthToWidest;
116
+ var currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
117
+
110
118
  // 76 is currently an accepted padding value considering the spacing for resizer handle
111
119
  var responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
112
120
  var width = Math.min(tableWidth, responsiveContainerWidth);
121
+ if (isTableScalingEnabled && currentTableNodeLocalId && widthToWidest && widthToWidest[currentTableNodeLocalId]) {
122
+ width = TABLE_MAX_WIDTH;
123
+ }
113
124
  if (!isResizing) {
114
125
  tableWidthRef.current = width;
115
126
  }
@@ -127,7 +138,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
127
138
  attachAnalyticsEvent: attachAnalyticsEvent,
128
139
  displayGapCursor: displayGapCursor,
129
140
  isTableScalingEnabled: isTableScalingEnabled,
130
- isWholeTableInDanger: isWholeTableInDanger
141
+ isWholeTableInDanger: isWholeTableInDanger,
142
+ pluginInjectionApi: pluginInjectionApi
131
143
  };
132
144
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
133
145
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -152,24 +164,24 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
152
164
  node: node
153
165
  }, children))));
154
166
  });
155
- export var TableContainer = function TableContainer(_ref3) {
156
- var children = _ref3.children,
157
- node = _ref3.node,
158
- className = _ref3.className,
159
- _ref3$containerWidth = _ref3.containerWidth,
160
- lineLength = _ref3$containerWidth.lineLength,
161
- editorWidth = _ref3$containerWidth.width,
162
- isTableResizingEnabled = _ref3.isTableResizingEnabled,
163
- isBreakoutEnabled = _ref3.isBreakoutEnabled,
164
- editorView = _ref3.editorView,
165
- getPos = _ref3.getPos,
166
- tableRef = _ref3.tableRef,
167
- isNested = _ref3.isNested,
168
- tableWrapperHeight = _ref3.tableWrapperHeight,
169
- isResizing = _ref3.isResizing,
170
- pluginInjectionApi = _ref3.pluginInjectionApi,
171
- isTableScalingEnabled = _ref3.isTableScalingEnabled,
172
- isWholeTableInDanger = _ref3.isWholeTableInDanger;
167
+ export var TableContainer = function TableContainer(_ref4) {
168
+ var children = _ref4.children,
169
+ node = _ref4.node,
170
+ className = _ref4.className,
171
+ _ref4$containerWidth = _ref4.containerWidth,
172
+ lineLength = _ref4$containerWidth.lineLength,
173
+ editorWidth = _ref4$containerWidth.width,
174
+ isTableResizingEnabled = _ref4.isTableResizingEnabled,
175
+ isBreakoutEnabled = _ref4.isBreakoutEnabled,
176
+ editorView = _ref4.editorView,
177
+ getPos = _ref4.getPos,
178
+ tableRef = _ref4.tableRef,
179
+ isNested = _ref4.isNested,
180
+ tableWrapperHeight = _ref4.tableWrapperHeight,
181
+ isResizing = _ref4.isResizing,
182
+ pluginInjectionApi = _ref4.pluginInjectionApi,
183
+ isTableScalingEnabled = _ref4.isTableScalingEnabled,
184
+ isWholeTableInDanger = _ref4.isWholeTableInDanger;
173
185
  if (isTableResizingEnabled && !isNested) {
174
186
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
175
187
  className: className,
@@ -8,17 +8,16 @@ import rafSchd from 'raf-schd';
8
8
  import { useIntl } from 'react-intl-next';
9
9
  import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
10
10
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
12
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
12
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
14
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
14
15
  import { browser } from '@atlaskit/editor-common/utils';
15
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
16
16
  import { findTable } from '@atlaskit/editor-tables/utils';
17
17
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
18
  import { updateWidthToWidest } from '../commands/misc';
19
- import { getPluginState } from '../pm-plugins/plugin-factory';
20
19
  import { META_KEYS } from '../pm-plugins/table-analytics';
21
- import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
20
+ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
22
21
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
23
22
  import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
24
23
  import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
@@ -31,7 +30,7 @@ var handles = {
31
30
  };
32
31
  var handleStyles = {
33
32
  right: {
34
- // eslint-disable-next-line
33
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
35
34
  right: '-14px',
36
35
  marginTop: "var(--ds-space-150, 12px)"
37
36
  }
@@ -91,28 +90,37 @@ export var TableResizer = function TableResizer(_ref) {
91
90
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
92
91
  displayGapCursor = _ref.displayGapCursor,
93
92
  isTableScalingEnabled = _ref.isTableScalingEnabled,
94
- isWholeTableInDanger = _ref.isWholeTableInDanger;
93
+ isWholeTableInDanger = _ref.isWholeTableInDanger,
94
+ pluginInjectionApi = _ref.pluginInjectionApi;
95
95
  var currentGap = useRef(0);
96
96
  // track resizing state - use ref over state to avoid re-render
97
97
  var isResizing = useRef(false);
98
98
  var areResizeMetaKeysPressed = useRef(false);
99
+ var _useState = useState(width),
100
+ _useState2 = _slicedToArray(_useState, 2),
101
+ localTableWidth = _useState2[0],
102
+ setLocalTableWidth = _useState2[1];
99
103
  var resizerRef = useRef(null);
104
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
105
+ tableState = _useSharedPluginState.tableState;
106
+ var _ref2 = tableState,
107
+ widthToWidest = _ref2.widthToWidest;
100
108
 
101
109
  // used to reposition tooltip when table is resizing via keyboard
102
110
  var updateTooltip = React.useRef();
103
- var _useState = useState(false),
104
- _useState2 = _slicedToArray(_useState, 2),
105
- snappingEnabled = _useState2[0],
106
- setSnappingEnabled = _useState2[1];
111
+ var _useState3 = useState(false),
112
+ _useState4 = _slicedToArray(_useState3, 2),
113
+ snappingEnabled = _useState4[0],
114
+ setSnappingEnabled = _useState4[1];
107
115
 
108
116
  // we don't want to update aria-live region on each width change, it might provide bad experience for screen reader users
109
- var _useState3 = useState({
117
+ var _useState5 = useState({
110
118
  type: 'none',
111
119
  width: width
112
120
  }),
113
- _useState4 = _slicedToArray(_useState3, 2),
114
- screenReaderResizeInformation = _useState4[0],
115
- setScreenReaderResizeInformation = _useState4[1];
121
+ _useState6 = _slicedToArray(_useState5, 2),
122
+ screenReaderResizeInformation = _useState6[0],
123
+ setScreenReaderResizeInformation = _useState6[1];
116
124
  var _useIntl = useIntl(),
117
125
  formatMessage = _useIntl.formatMessage;
118
126
  var screenReaderResizeAnnouncerMessages = {
@@ -131,9 +139,9 @@ export var TableResizer = function TableResizer(_ref) {
131
139
  startMeasure = _useMeasureFramerate.startMeasure,
132
140
  endMeasure = _useMeasureFramerate.endMeasure,
133
141
  countFrames = _useMeasureFramerate.countFrames;
134
- var updateActiveGuidelines = useCallback(function (_ref2) {
135
- var gap = _ref2.gap,
136
- keys = _ref2.keys;
142
+ var updateActiveGuidelines = useCallback(function (_ref3) {
143
+ var gap = _ref3.gap,
144
+ keys = _ref3.keys;
137
145
  if (gap !== currentGap.current) {
138
146
  currentGap.current = gap;
139
147
  var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
@@ -181,7 +189,7 @@ export var TableResizer = function TableResizer(_ref) {
181
189
  }
182
190
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
183
191
  var handleResize = useCallback(function (originalState, delta) {
184
- var _defaultGuidelinesFor;
192
+ var _node$attrs$localId, _node$attrs, _widestGuideline$posi;
185
193
  countFrames();
186
194
  var newWidth = originalState.width + delta.width;
187
195
  var pos;
@@ -206,25 +214,29 @@ export var TableResizer = function TableResizer(_ref) {
206
214
  // set the width of the table to 1800 pixels.
207
215
  var state = editorView.state,
208
216
  dispatch = editorView.dispatch;
209
- var widestGuideLineWidthString = (_defaultGuidelinesFor = defaultGuidelinesForPreserveTable(containerWidth)[16].key) === null || _defaultGuidelinesFor === void 0 || (_defaultGuidelinesFor = _defaultGuidelinesFor.match(/[\d]*[.]{0,1}[\d]+/g)) === null || _defaultGuidelinesFor === void 0 ? void 0 : _defaultGuidelinesFor.join('');
210
- var widestGuideLineWidth = parseInt(widestGuideLineWidthString || '', 10);
211
- var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && defaultGuidelinesForPreserveTable(containerWidth).length === 17 && widestGuideLineWidth - newWidth <= 1);
212
- updateWidthToWidest(shouldUpdateWidthToWidest)(state, dispatch);
213
- updateWidth(shouldUpdateWidthToWidest ? akEditorFullWidthLayoutWidth : newWidth);
217
+ var currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
218
+ var widestGuideline = defaultGuidelinesForPreserveTable(containerWidth).filter(function (guideline) {
219
+ return guideline.isFullWidth;
220
+ })[0];
221
+ var widestGuideLineWidth = widestGuideline ? (((_widestGuideline$posi = widestGuideline.position) === null || _widestGuideline$posi === void 0 ? void 0 : _widestGuideline$posi.x) || 0) * 2 : null;
222
+ var shouldUpdateWidthToWidest = !!(isTableScalingEnabled && widestGuideLineWidth && Math.abs(widestGuideLineWidth - newWidth) <= 1);
223
+ shouldUpdateWidthToWidest ? setLocalTableWidth(TABLE_MAX_WIDTH) : setLocalTableWidth(newWidth);
224
+ updateWidthToWidest(_defineProperty({}, currentTableNodeLocalId, shouldUpdateWidthToWidest))(state, dispatch);
225
+ updateWidth(shouldUpdateWidthToWidest ? TABLE_MAX_WIDTH : newWidth);
214
226
  return newWidth;
215
227
  }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
216
228
  var scheduleResize = useMemo(function () {
217
229
  return rafSchd(handleResize);
218
230
  }, [handleResize]);
219
231
  var handleResizeStop = useCallback(function (originalState, delta) {
232
+ var _node$attrs$localId2, _node$attrs2;
220
233
  isResizing.current = false;
221
234
  var newWidth = originalState.width + delta.width;
222
235
  var state = editorView.state,
223
236
  dispatch = editorView.dispatch;
224
237
  var pos = getPos();
225
- var _getPluginState = getPluginState(editorView.state),
226
- widthToWidest = _getPluginState.widthToWidest;
227
- newWidth = widthToWidest ? akEditorFullWidthLayoutWidth : newWidth;
238
+ var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
239
+ newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? TABLE_MAX_WIDTH : newWidth;
228
240
  var tr = state.tr.setMeta(tableWidthPluginKey, {
229
241
  resizing: false
230
242
  });
@@ -269,7 +281,7 @@ export var TableResizer = function TableResizer(_ref) {
269
281
  onResizeStop();
270
282
  }
271
283
  return newWidth;
272
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
284
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, widthToWidest]);
273
285
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
274
286
  var newWidth = width + step;
275
287
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -374,7 +386,7 @@ export var TableResizer = function TableResizer(_ref) {
374
386
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizerNext, {
375
387
  ref: resizerRef,
376
388
  enable: handles,
377
- width: width,
389
+ width: localTableWidth,
378
390
  handleAlignmentMethod: "sticky",
379
391
  handleSize: handleSize,
380
392
  handleStyles: handleStyles,
@@ -391,8 +403,8 @@ export var TableResizer = function TableResizer(_ref) {
391
403
  needExtendedResizeZone: !isTableSelected,
392
404
  appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
393
405
  handleHighlight: "shadow",
394
- handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref3) {
395
- var update = _ref3.update;
406
+ handleTooltipContent: getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? function (_ref4) {
407
+ var update = _ref4.update;
396
408
  updateTooltip.current = update;
397
409
  return /*#__PURE__*/React.createElement(ToolTipContent, {
398
410
  description: formatMessage(messages.resizeTable),