@atlaskit/editor-plugin-table 9.1.3 → 9.2.1

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 (211) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/nodeviews/TableCell.js +0 -2
  3. package/dist/cjs/nodeviews/TableComponent.js +5 -5
  4. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
  5. package/dist/cjs/nodeviews/TableContainer.js +13 -2
  6. package/dist/cjs/nodeviews/TableNodeViewBase.js +0 -2
  7. package/dist/cjs/nodeviews/TableResizer.js +5 -10
  8. package/dist/cjs/nodeviews/TableRow.js +0 -2
  9. package/dist/cjs/nodeviews/lazy-node-views.js +4 -16
  10. package/dist/cjs/nodeviews/table.js +3 -10
  11. package/dist/cjs/pm-plugins/commands/column-resize.js +1 -4
  12. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +4 -16
  13. package/dist/cjs/pm-plugins/commands/insert.js +4 -19
  14. package/dist/cjs/pm-plugins/commands/misc.js +3 -12
  15. package/dist/cjs/pm-plugins/decorations/plugin.js +1 -6
  16. package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +1 -4
  17. package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  18. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -12
  19. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
  20. package/dist/cjs/pm-plugins/keymap.js +0 -2
  21. package/dist/cjs/pm-plugins/main.js +1 -6
  22. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -4
  23. package/dist/cjs/pm-plugins/table-resizing/plugin.js +0 -2
  24. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +1 -7
  25. package/dist/cjs/pm-plugins/table-resizing/utils/column-state.js +1 -4
  26. package/dist/cjs/pm-plugins/table-resizing/utils/content-width.js +0 -8
  27. package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  28. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -4
  29. package/dist/cjs/pm-plugins/table-width.js +1 -6
  30. package/dist/cjs/pm-plugins/transforms/column-width.js +1 -4
  31. package/dist/cjs/pm-plugins/transforms/fix-tables.js +3 -15
  32. package/dist/cjs/pm-plugins/transforms/replace-table.js +1 -4
  33. package/dist/cjs/pm-plugins/transforms/split.js +0 -2
  34. package/dist/cjs/pm-plugins/utils/alignment.js +1 -4
  35. package/dist/cjs/pm-plugins/utils/decoration.js +4 -16
  36. package/dist/cjs/pm-plugins/utils/drag-menu.js +1 -4
  37. package/dist/cjs/pm-plugins/utils/nodes.js +0 -3
  38. package/dist/cjs/pm-plugins/utils/paste.js +4 -0
  39. package/dist/cjs/pm-plugins/utils/row-controls.js +1 -4
  40. package/dist/cjs/tablePlugin.js +1 -0
  41. package/dist/cjs/ui/DragHandle/index.js +55 -6
  42. package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  43. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -6
  44. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  45. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
  46. package/dist/cjs/ui/TableFloatingControls/index.js +25 -8
  47. package/dist/cjs/ui/toolbar.js +3 -12
  48. package/dist/es2019/nodeviews/TableCell.js +0 -2
  49. package/dist/es2019/nodeviews/TableComponent.js +5 -5
  50. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
  51. package/dist/es2019/nodeviews/TableContainer.js +13 -2
  52. package/dist/es2019/nodeviews/TableNodeViewBase.js +0 -2
  53. package/dist/es2019/nodeviews/TableResizer.js +5 -10
  54. package/dist/es2019/nodeviews/TableRow.js +0 -2
  55. package/dist/es2019/nodeviews/lazy-node-views.js +4 -16
  56. package/dist/es2019/nodeviews/table.js +3 -10
  57. package/dist/es2019/pm-plugins/commands/column-resize.js +1 -4
  58. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +6 -24
  59. package/dist/es2019/pm-plugins/commands/delete.js +1 -4
  60. package/dist/es2019/pm-plugins/commands/insert.js +5 -23
  61. package/dist/es2019/pm-plugins/commands/misc.js +3 -12
  62. package/dist/es2019/pm-plugins/decorations/plugin.js +1 -6
  63. package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +1 -4
  64. package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  65. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +4 -16
  66. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -8
  67. package/dist/es2019/pm-plugins/keymap.js +0 -3
  68. package/dist/es2019/pm-plugins/main.js +1 -6
  69. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -4
  70. package/dist/es2019/pm-plugins/table-resizing/plugin.js +0 -3
  71. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -11
  72. package/dist/es2019/pm-plugins/table-resizing/utils/column-state.js +1 -4
  73. package/dist/es2019/pm-plugins/table-resizing/utils/content-width.js +0 -8
  74. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  75. package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  76. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +2 -8
  77. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -16
  78. package/dist/es2019/pm-plugins/table-width.js +1 -6
  79. package/dist/es2019/pm-plugins/transforms/column-width.js +2 -8
  80. package/dist/es2019/pm-plugins/transforms/delete-columns.js +1 -4
  81. package/dist/es2019/pm-plugins/transforms/fix-tables.js +3 -15
  82. package/dist/es2019/pm-plugins/transforms/replace-table.js +1 -4
  83. package/dist/es2019/pm-plugins/transforms/split.js +0 -2
  84. package/dist/es2019/pm-plugins/utils/alignment.js +1 -4
  85. package/dist/es2019/pm-plugins/utils/decoration.js +4 -16
  86. package/dist/es2019/pm-plugins/utils/drag-menu.js +2 -8
  87. package/dist/es2019/pm-plugins/utils/nodes.js +0 -3
  88. package/dist/es2019/pm-plugins/utils/paste.js +5 -4
  89. package/dist/es2019/pm-plugins/utils/row-controls.js +1 -4
  90. package/dist/es2019/pm-plugins/utils/snapping.js +1 -4
  91. package/dist/es2019/tablePlugin.js +1 -0
  92. package/dist/es2019/ui/DragHandle/index.js +57 -6
  93. package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  94. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
  95. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  96. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +63 -11
  97. package/dist/es2019/ui/TableFloatingControls/index.js +26 -10
  98. package/dist/es2019/ui/event-handlers.js +1 -4
  99. package/dist/es2019/ui/toolbar.js +9 -36
  100. package/dist/esm/nodeviews/TableCell.js +0 -2
  101. package/dist/esm/nodeviews/TableComponent.js +5 -5
  102. package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
  103. package/dist/esm/nodeviews/TableContainer.js +13 -2
  104. package/dist/esm/nodeviews/TableNodeViewBase.js +0 -2
  105. package/dist/esm/nodeviews/TableResizer.js +5 -10
  106. package/dist/esm/nodeviews/TableRow.js +0 -2
  107. package/dist/esm/nodeviews/lazy-node-views.js +4 -16
  108. package/dist/esm/nodeviews/table.js +3 -10
  109. package/dist/esm/pm-plugins/commands/column-resize.js +1 -4
  110. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +4 -16
  111. package/dist/esm/pm-plugins/commands/insert.js +4 -19
  112. package/dist/esm/pm-plugins/commands/misc.js +3 -12
  113. package/dist/esm/pm-plugins/decorations/plugin.js +1 -6
  114. package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +1 -4
  115. package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
  116. package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -12
  117. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
  118. package/dist/esm/pm-plugins/keymap.js +0 -3
  119. package/dist/esm/pm-plugins/main.js +1 -6
  120. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -4
  121. package/dist/esm/pm-plugins/table-resizing/plugin.js +0 -3
  122. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +1 -7
  123. package/dist/esm/pm-plugins/table-resizing/utils/column-state.js +1 -4
  124. package/dist/esm/pm-plugins/table-resizing/utils/content-width.js +0 -8
  125. package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
  126. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -4
  127. package/dist/esm/pm-plugins/table-width.js +1 -6
  128. package/dist/esm/pm-plugins/transforms/column-width.js +1 -4
  129. package/dist/esm/pm-plugins/transforms/fix-tables.js +3 -15
  130. package/dist/esm/pm-plugins/transforms/replace-table.js +1 -4
  131. package/dist/esm/pm-plugins/transforms/split.js +0 -2
  132. package/dist/esm/pm-plugins/utils/alignment.js +1 -4
  133. package/dist/esm/pm-plugins/utils/decoration.js +4 -16
  134. package/dist/esm/pm-plugins/utils/drag-menu.js +1 -4
  135. package/dist/esm/pm-plugins/utils/nodes.js +0 -3
  136. package/dist/esm/pm-plugins/utils/paste.js +4 -0
  137. package/dist/esm/pm-plugins/utils/row-controls.js +1 -4
  138. package/dist/esm/tablePlugin.js +1 -0
  139. package/dist/esm/ui/DragHandle/index.js +54 -5
  140. package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +0 -6
  141. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
  142. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  143. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
  144. package/dist/esm/ui/TableFloatingControls/index.js +26 -9
  145. package/dist/esm/ui/toolbar.js +3 -12
  146. package/dist/types/nodeviews/TableComponent.d.ts +3 -1
  147. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  148. package/dist/types/types/index.d.ts +1 -1
  149. package/dist/types/ui/DragHandle/index.d.ts +21 -0
  150. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  151. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  152. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
  153. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  154. package/dist/types-ts4.5/types/index.d.ts +1 -1
  155. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
  156. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  157. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  158. package/package.json +15 -6
  159. package/src/nodeviews/TableCell.ts +0 -2
  160. package/src/nodeviews/TableComponent.tsx +8 -6
  161. package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
  162. package/src/nodeviews/TableContainer.tsx +12 -1
  163. package/src/nodeviews/TableNodeViewBase.ts +0 -2
  164. package/src/nodeviews/TableResizer.tsx +9 -5
  165. package/src/nodeviews/TableRow.ts +0 -2
  166. package/src/nodeviews/lazy-node-views.ts +0 -8
  167. package/src/nodeviews/table.tsx +1 -6
  168. package/src/pm-plugins/commands/column-resize.ts +0 -2
  169. package/src/pm-plugins/commands/commands-with-analytics.ts +0 -12
  170. package/src/pm-plugins/commands/delete.ts +0 -2
  171. package/src/pm-plugins/commands/insert.ts +0 -12
  172. package/src/pm-plugins/commands/misc.ts +0 -6
  173. package/src/pm-plugins/decorations/plugin.ts +0 -4
  174. package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -2
  175. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -6
  176. package/src/pm-plugins/drag-and-drop/commands.ts +0 -8
  177. package/src/pm-plugins/drag-and-drop/plugin.ts +0 -4
  178. package/src/pm-plugins/keymap.ts +0 -2
  179. package/src/pm-plugins/main.ts +0 -4
  180. package/src/pm-plugins/table-resizing/event-handlers.ts +0 -2
  181. package/src/pm-plugins/table-resizing/plugin.ts +0 -2
  182. package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -6
  183. package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -2
  184. package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -6
  185. package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -2
  186. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -6
  187. package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -4
  188. package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -8
  189. package/src/pm-plugins/table-width.ts +0 -4
  190. package/src/pm-plugins/transforms/column-width.ts +0 -4
  191. package/src/pm-plugins/transforms/delete-columns.ts +0 -2
  192. package/src/pm-plugins/transforms/fix-tables.ts +0 -8
  193. package/src/pm-plugins/transforms/replace-table.ts +0 -2
  194. package/src/pm-plugins/transforms/split.ts +0 -2
  195. package/src/pm-plugins/utils/alignment.ts +0 -2
  196. package/src/pm-plugins/utils/decoration.ts +0 -8
  197. package/src/pm-plugins/utils/drag-menu.ts +0 -4
  198. package/src/pm-plugins/utils/nodes.ts +0 -2
  199. package/src/pm-plugins/utils/paste.ts +4 -2
  200. package/src/pm-plugins/utils/row-controls.ts +0 -2
  201. package/src/pm-plugins/utils/snapping.ts +0 -2
  202. package/src/tablePlugin.tsx +1 -0
  203. package/src/types/index.ts +1 -0
  204. package/src/ui/DragHandle/index.tsx +67 -2
  205. package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -4
  206. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +37 -20
  207. package/src/ui/TableFloatingColumnControls/index.tsx +1 -4
  208. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -27
  209. package/src/ui/TableFloatingControls/index.tsx +55 -32
  210. package/src/ui/event-handlers.ts +0 -2
  211. package/src/ui/toolbar.tsx +0 -18
@@ -2,9 +2,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
3
3
 
4
4
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
5
- import { injectIntl } from 'react-intl-next';
5
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import { CellSelection } from '@atlaskit/editor-tables';
7
7
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
9
10
  import { clearHoverSelection } from '../../../pm-plugins/commands';
10
11
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
@@ -13,7 +14,7 @@ import { getRowHeights, getRowsParams } from '../../../pm-plugins/utils/row-cont
13
14
  import { getSelectedRowIndexes } from '../../../pm-plugins/utils/selection';
14
15
  import { TableCssClassName as ClassName } from '../../../types';
15
16
  import { dropTargetExtendedWidth } from '../../consts';
16
- import { DragHandle } from '../../DragHandle';
17
+ import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
17
18
  import RowDropTarget from '../RowDropTarget';
18
19
  var getSelectedRows = function getSelectedRows(selection) {
19
20
  if (selection instanceof CellSelection && selection.isRowSelection()) {
@@ -25,7 +26,7 @@ var getSelectedRows = function getSelectedRows(selection) {
25
26
  }
26
27
  return [];
27
28
  };
28
- var DragControlsComponent = function DragControlsComponent(_ref) {
29
+ export var DragControls = function DragControls(_ref) {
29
30
  var _tableNode$attrs$loca, _tableNode$attrs;
30
31
  var tableRef = _ref.tableRef,
31
32
  tableNode = _ref.tableNode,
@@ -39,7 +40,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
39
40
  hoverRows = _ref.hoverRows,
40
41
  selectRow = _ref.selectRow,
41
42
  selectRows = _ref.selectRows,
42
- updateCellHoverLocation = _ref.updateCellHoverLocation;
43
+ updateCellHoverLocation = _ref.updateCellHoverLocation,
44
+ api = _ref.api,
45
+ selection = _ref.selection;
43
46
  var _useState = useState(false),
44
47
  _useState2 = _slicedToArray(_useState, 2),
45
48
  isDragging = _useState2[0],
@@ -49,7 +52,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
49
52
  var heights = rowHeights.map(function (height) {
50
53
  return "".concat(height - 1, "px");
51
54
  }).join(' ');
52
- var selectedRowIndexes = getSelectedRows(editorView.state.selection);
55
+ var selectedRowIndexes = getSelectedRows(selection !== null && selection !== void 0 ? selection : editorView.state.selection);
53
56
  var currentNodeLocalId = (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 || (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '';
54
57
  useEffect(function () {
55
58
  return monitorForElements({
@@ -128,10 +131,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
128
131
  selectRows(selectedRowIndexes);
129
132
  }
130
133
  }, [rowIndex, selectRow, selectRows, selectedRowIndexes]);
131
- var generateHandleByType = function generateHandleByType(type, appearance, gridRow, indexes
132
- // Ignored via go/ees005
133
- // eslint-disable-next-line @typescript-eslint/max-params
134
- ) {
134
+ var generateHandleByType = function generateHandleByType(type, appearance, gridRow, indexes) {
135
135
  var isHover = type === 'hover';
136
136
  var previewHeight = rowHeights.reduce(function (sum, v, i) {
137
137
  return sum + v * (indexes.includes(i) ? 1 : 0);
@@ -157,7 +157,23 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
157
157
  pointerEvents: 'none'
158
158
  },
159
159
  "data-testid": "table-floating-row-".concat(isHover ? rowIndex : selectedRowIndexes[0], "-drag-handle")
160
- }, /*#__PURE__*/React.createElement(DragHandle, {
160
+ }, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(DragHandleWithSharedState, {
161
+ isDragMenuTarget: !isHover,
162
+ direction: "row",
163
+ tableLocalId: currentNodeLocalId,
164
+ indexes: indexes,
165
+ forceDefaultHandle: !isHover,
166
+ previewWidth: tableWidth,
167
+ previewHeight: previewHeight,
168
+ appearance: appearance,
169
+ hoveredCell: hoveredCell,
170
+ onClick: handleClick,
171
+ onMouseOver: handleMouseOver,
172
+ onMouseOut: handleMouseOut,
173
+ toggleDragMenu: toggleDragMenuHandler,
174
+ editorView: editorView,
175
+ api: api
176
+ }) : /*#__PURE__*/React.createElement(DragHandle, {
161
177
  isDragMenuTarget: !isHover,
162
178
  direction: "row",
163
179
  tableLocalId: currentNodeLocalId,
@@ -261,4 +277,38 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
261
277
  }), rowHandles())
262
278
  );
263
279
  };
264
- export var DragControls = injectIntl(DragControlsComponent);
280
+ export var DragControlsWithSelection = function DragControlsWithSelection(_ref5) {
281
+ var editorView = _ref5.editorView,
282
+ tableRef = _ref5.tableRef,
283
+ tableNode = _ref5.tableNode,
284
+ tableWidth = _ref5.tableWidth,
285
+ tableActive = _ref5.tableActive,
286
+ hoveredCell = _ref5.hoveredCell,
287
+ isInDanger = _ref5.isInDanger,
288
+ isTableHovered = _ref5.isTableHovered,
289
+ isResizing = _ref5.isResizing,
290
+ hoverRows = _ref5.hoverRows,
291
+ selectRow = _ref5.selectRow,
292
+ selectRows = _ref5.selectRows,
293
+ updateCellHoverLocation = _ref5.updateCellHoverLocation,
294
+ api = _ref5.api;
295
+ var _useSharedPluginState = useSharedPluginState(api, ['selection']),
296
+ selectionState = _useSharedPluginState.selectionState;
297
+ return /*#__PURE__*/React.createElement(DragControls, {
298
+ editorView: editorView,
299
+ tableRef: tableRef,
300
+ tableNode: tableNode,
301
+ tableWidth: tableWidth,
302
+ tableActive: tableActive,
303
+ hoveredCell: hoveredCell,
304
+ isInDanger: isInDanger,
305
+ isTableHovered: isTableHovered,
306
+ isResizing: isResizing,
307
+ hoverRows: hoverRows,
308
+ selectRow: selectRow,
309
+ selectRows: selectRows,
310
+ updateCellHoverLocation: updateCellHoverLocation,
311
+ api: api,
312
+ selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
313
+ });
314
+ };
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { browser } from '@atlaskit/editor-common/browser';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
6
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
7
7
  import { isTableNested } from '../../pm-plugins/utils/nodes';
@@ -11,7 +11,8 @@ import { DragCornerControls, DragCornerControlsWithSelection } from './CornerCon
11
11
  import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
12
12
  import NumberColumn from './NumberColumn';
13
13
  import { RowControls } from './RowControls/ClassicControls';
14
- import { DragControls } from './RowControls/DragControls';
14
+ import { DragControls, DragControlsWithSelection } from './RowControls/DragControls';
15
+ // Row controls
15
16
  export var TableFloatingControls = function TableFloatingControls(_ref) {
16
17
  var _findTable;
17
18
  var editorView = _ref.editorView,
@@ -72,8 +73,6 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
72
73
  hoverCell(rowIndex, 0)(state, dispatch);
73
74
  }
74
75
  }, [editorView, tableActive]);
75
- var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
76
- featureFlagsState = _useSharedPluginState.featureFlagsState;
77
76
  if (!tableRef) {
78
77
  return null;
79
78
  }
@@ -83,7 +82,7 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
83
82
  // Ignored via go/ees005
84
83
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
85
84
  var isNested = tablePos !== undefined && isTableNested(editorView.state, tablePos);
86
- var shouldShowCornerControls = !(featureFlagsState !== null && featureFlagsState !== void 0 && featureFlagsState.elementDragAndDrop) || isNested && !editorExperiment('nested-dnd', true);
85
+ var shouldShowCornerControls = isNested && !editorExperiment('nested-dnd', true);
87
86
  return (
88
87
  /*#__PURE__*/
89
88
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -106,18 +105,36 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
106
105
  updateCellHoverLocation: updateCellHoverLocation,
107
106
  stickyTop: stickyTop,
108
107
  isDragAndDropEnabled: isDragAndDropEnabled
109
- }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && (editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
108
+ }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
110
109
  editorView: editorView,
111
110
  tableRef: tableRef,
112
111
  isInDanger: isInDanger,
113
112
  isResizing: isResizing,
114
113
  api: api
115
- }) : /*#__PURE__*/React.createElement(DragCornerControls, {
114
+ }), /*#__PURE__*/React.createElement(DragControlsWithSelection, {
115
+ tableRef: tableRef,
116
+ tableNode: tableNode,
117
+ hoveredCell: hoveredCell,
118
+ isTableHovered: isTableHovered,
119
+ editorView: editorView,
120
+ tableActive: tableActive,
121
+ isInDanger: isInDanger,
122
+ isResizing: isResizing
123
+ // Ignored via go/ees005
124
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
125
+ ,
126
+ tableWidth: tableWrapperWidth,
127
+ hoverRows: _hoverRows,
128
+ selectRow: _selectRow,
129
+ selectRows: _selectRows,
130
+ updateCellHoverLocation: updateCellHoverLocation,
131
+ api: api
132
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControls, {
116
133
  editorView: editorView,
117
134
  tableRef: tableRef,
118
135
  isInDanger: isInDanger,
119
136
  isResizing: isResizing
120
- })), /*#__PURE__*/React.createElement(DragControls, {
137
+ }), /*#__PURE__*/React.createElement(DragControls, {
121
138
  tableRef: tableRef,
122
139
  tableNode: tableNode,
123
140
  hoveredCell: hoveredCell,
@@ -134,7 +151,7 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
134
151
  selectRow: _selectRow,
135
152
  selectRows: _selectRows,
136
153
  updateCellHoverLocation: updateCellHoverLocation
137
- })) : editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
154
+ }))) : fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
138
155
  editorView: editorView,
139
156
  tableRef: tableRef,
140
157
  isInDanger: isInDanger,
@@ -543,10 +543,7 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
543
543
  }
544
544
  return items;
545
545
  };
546
- var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI, getEditorView
547
- // Ignored via go/ees005
548
- // eslint-disable-next-line @typescript-eslint/max-params
549
- ) {
546
+ var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI, getEditorView) {
550
547
  var _node$attrs;
551
548
  var formatMessage = _ref5.formatMessage;
552
549
  var _getPluginState2 = getPluginState(state),
@@ -609,10 +606,7 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
609
606
  }
610
607
  return false;
611
608
  };
612
- var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor, isCommentEditor
613
- // Ignored via go/ees005
614
- // eslint-disable-next-line @typescript-eslint/max-params
615
- ) {
609
+ var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor, isCommentEditor) {
616
610
  var formatMessage = _ref6.formatMessage;
617
611
  var tableObject = findTable(editorState.selection);
618
612
  if (!tableObject) {
@@ -691,10 +685,7 @@ var getSelectedAlignmentIcon = function getSelectedAlignmentIcon(alignmentIcons,
691
685
  return icon.value === normaliseAlignment(selectedAlignment);
692
686
  });
693
687
  };
694
- var isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor
695
- // Ignored via go/ees005
696
- // eslint-disable-next-line @typescript-eslint/max-params
697
- ) {
688
+ var isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor) {
698
689
  var _getEditorContainerWi = getEditorContainerWidth(),
699
690
  lineLength = _getEditorContainerWi.lineLength;
700
691
  var tableContainerWidth = getTableContainerWidth(selectedNode);
@@ -5,6 +5,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
5
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
6
6
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
10
  import type { CellHoverMeta, PluginInjectionAPI } from '../types';
10
11
  import type { TableOptions } from './types';
@@ -17,7 +18,7 @@ interface ComponentProps {
17
18
  options?: TableOptions;
18
19
  contentDOM: (node: HTMLElement | null) => void;
19
20
  containerWidth: EditorContainerWidth;
20
- allowControls: boolean;
21
+ allowControls?: boolean;
21
22
  allowTableResizing?: boolean;
22
23
  allowTableAlignment?: boolean;
23
24
  isHeaderRowEnabled: boolean;
@@ -37,6 +38,7 @@ interface ComponentProps {
37
38
  hoveredCell?: CellHoverMeta;
38
39
  isTableHovered?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ selection?: Selection;
40
42
  }
41
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
42
44
  WrappedComponent: React.ComponentType<ComponentProps>;
@@ -28,6 +28,7 @@ interface TableResizerProps {
28
28
  isCommentEditor?: boolean;
29
29
  onResizeStop?: () => void;
30
30
  onResizeStart?: () => void;
31
+ disabled?: boolean;
31
32
  }
32
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, lineLength, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, isWholeTableInDanger, shouldUseIncreasedScalingPercent, pluginInjectionApi, isFullWidthModeEnabled, isCommentEditor, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
33
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, lineLength, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, isWholeTableInDanger, shouldUseIncreasedScalingPercent, pluginInjectionApi, isFullWidthModeEnabled, isCommentEditor, disabled, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
33
34
  export {};
@@ -33,7 +33,7 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
33
  };
34
34
  };
35
35
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
37
  isResizing: boolean;
38
38
  isTableResizing?: boolean;
39
39
  isWholeTableInDanger?: boolean;
@@ -20,8 +20,29 @@ type DragHandleProps = {
20
20
  toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
21
21
  editorView: EditorView;
22
22
  isDragMenuTarget: boolean;
23
+ hoveredColumns?: number[];
24
+ hoveredRows?: number[];
23
25
  };
24
26
  export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
25
27
  WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
26
28
  };
29
+ export declare const DragHandleWithSharedState: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
30
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
31
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
32
+ actions: import("../../tablePluginType").TablePluginActions;
33
+ sharedState?: import("../../types").TableSharedState | undefined;
34
+ commands: import("../../tablePluginType").TablePluginCommands;
35
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
36
+ }> | undefined;
37
+ } & WrappedComponentProps>> & {
38
+ WrappedComponent: React.ComponentType<DragHandleProps & {
39
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
40
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
41
+ actions: import("../../tablePluginType").TablePluginActions;
42
+ sharedState?: import("../../types").TableSharedState | undefined;
43
+ commands: import("../../tablePluginType").TablePluginCommands;
44
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
45
+ }> | undefined;
46
+ } & WrappedComponentProps>;
47
+ };
27
48
  export {};
@@ -20,7 +20,7 @@ interface ColumnControlsProps {
20
20
  isDragging?: boolean;
21
21
  getScrollOffset?: () => number;
22
22
  }
23
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
23
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
24
24
  api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
25
25
  pluginConfiguration: import("../../../tablePluginType").TablePluginOptions | undefined;
26
26
  actions: import("../../../tablePluginType").TablePluginActions;
@@ -1,7 +1,9 @@
1
- import React from 'react';
2
- import type { WrappedComponentProps } from 'react-intl-next';
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TablePlugin } from '../../../tablePluginType';
5
7
  import type { CellHoverMeta } from '../../../types';
6
8
  type DragControlsProps = {
7
9
  editorView: EditorView;
@@ -17,8 +19,9 @@ type DragControlsProps = {
17
19
  selectRow: (row: number, expand: boolean) => void;
18
20
  selectRows: (rowIndexes: number[]) => void;
19
21
  updateCellHoverLocation: (rowIndex: number) => void;
22
+ api?: ExtractInjectionAPI<TablePlugin>;
23
+ selection?: Selection;
20
24
  };
21
- export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps>> & {
22
- WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps>;
23
- };
25
+ export declare const DragControls: ({ tableRef, tableNode, tableWidth, hoveredCell, tableActive, editorView, isInDanger, isResizing, isTableHovered, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, selection, }: DragControlsProps) => JSX.Element | null;
26
+ export declare const DragControlsWithSelection: ({ editorView, tableRef, tableNode, tableWidth, tableActive, hoveredCell, isInDanger, isTableHovered, isResizing, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, }: Exclude<DragControlsProps, 'selection'>) => JSX.Element;
24
27
  export {};
@@ -5,6 +5,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
5
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
6
6
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
10
  import type { CellHoverMeta, PluginInjectionAPI } from '../types';
10
11
  import type { TableOptions } from './types';
@@ -17,7 +18,7 @@ interface ComponentProps {
17
18
  options?: TableOptions;
18
19
  contentDOM: (node: HTMLElement | null) => void;
19
20
  containerWidth: EditorContainerWidth;
20
- allowControls: boolean;
21
+ allowControls?: boolean;
21
22
  allowTableResizing?: boolean;
22
23
  allowTableAlignment?: boolean;
23
24
  isHeaderRowEnabled: boolean;
@@ -37,6 +38,7 @@ interface ComponentProps {
37
38
  hoveredCell?: CellHoverMeta;
38
39
  isTableHovered?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ selection?: Selection;
40
42
  }
41
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
42
44
  WrappedComponent: React.ComponentType<ComponentProps>;
@@ -28,6 +28,7 @@ interface TableResizerProps {
28
28
  isCommentEditor?: boolean;
29
29
  onResizeStop?: () => void;
30
30
  onResizeStart?: () => void;
31
+ disabled?: boolean;
31
32
  }
32
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, lineLength, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, isWholeTableInDanger, shouldUseIncreasedScalingPercent, pluginInjectionApi, isFullWidthModeEnabled, isCommentEditor, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
33
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, lineLength, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, isWholeTableInDanger, shouldUseIncreasedScalingPercent, pluginInjectionApi, isFullWidthModeEnabled, isCommentEditor, disabled, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
33
34
  export {};
@@ -33,7 +33,7 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
33
  };
34
34
  };
35
35
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
37
  isResizing: boolean;
38
38
  isTableResizing?: boolean;
39
39
  isWholeTableInDanger?: boolean;
@@ -20,8 +20,29 @@ type DragHandleProps = {
20
20
  toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
21
21
  editorView: EditorView;
22
22
  isDragMenuTarget: boolean;
23
+ hoveredColumns?: number[];
24
+ hoveredRows?: number[];
23
25
  };
24
26
  export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
25
27
  WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
26
28
  };
29
+ export declare const DragHandleWithSharedState: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
30
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
31
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
32
+ actions: import("../../tablePluginType").TablePluginActions;
33
+ sharedState?: import("../../types").TableSharedState | undefined;
34
+ commands: import("../../tablePluginType").TablePluginCommands;
35
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
36
+ }> | undefined;
37
+ } & WrappedComponentProps>> & {
38
+ WrappedComponent: React.ComponentType<DragHandleProps & {
39
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
40
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
41
+ actions: import("../../tablePluginType").TablePluginActions;
42
+ sharedState?: import("../../types").TableSharedState | undefined;
43
+ commands: import("../../tablePluginType").TablePluginCommands;
44
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
45
+ }> | undefined;
46
+ } & WrappedComponentProps>;
47
+ };
27
48
  export {};
@@ -20,7 +20,7 @@ interface ColumnControlsProps {
20
20
  isDragging?: boolean;
21
21
  getScrollOffset?: () => number;
22
22
  }
23
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
23
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
24
24
  api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
25
25
  pluginConfiguration: import("../../../tablePluginType").TablePluginOptions | undefined;
26
26
  actions: import("../../../tablePluginType").TablePluginActions;
@@ -1,7 +1,9 @@
1
- import React from 'react';
2
- import type { WrappedComponentProps } from 'react-intl-next';
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TablePlugin } from '../../../tablePluginType';
5
7
  import type { CellHoverMeta } from '../../../types';
6
8
  type DragControlsProps = {
7
9
  editorView: EditorView;
@@ -17,8 +19,9 @@ type DragControlsProps = {
17
19
  selectRow: (row: number, expand: boolean) => void;
18
20
  selectRows: (rowIndexes: number[]) => void;
19
21
  updateCellHoverLocation: (rowIndex: number) => void;
22
+ api?: ExtractInjectionAPI<TablePlugin>;
23
+ selection?: Selection;
20
24
  };
21
- export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps>> & {
22
- WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps>;
23
- };
25
+ export declare const DragControls: ({ tableRef, tableNode, tableWidth, hoveredCell, tableActive, editorView, isInDanger, isResizing, isTableHovered, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, selection, }: DragControlsProps) => JSX.Element | null;
26
+ export declare const DragControlsWithSelection: ({ editorView, tableRef, tableNode, tableWidth, tableActive, hoveredCell, isInDanger, isTableHovered, isResizing, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, }: Exclude<DragControlsProps, 'selection'>) => JSX.Element;
24
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "9.1.3",
3
+ "version": "9.2.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,10 +30,10 @@
30
30
  "@atlaskit/adf-schema": "^46.1.0",
31
31
  "@atlaskit/button": "^20.3.0",
32
32
  "@atlaskit/custom-steps": "^0.9.0",
33
- "@atlaskit/editor-common": "^99.1.0",
33
+ "@atlaskit/editor-common": "^99.5.0",
34
34
  "@atlaskit/editor-palette": "1.6.4",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
- "@atlaskit/editor-plugin-analytics": "^1.10.0",
36
+ "@atlaskit/editor-plugin-analytics": "^1.11.0",
37
37
  "@atlaskit/editor-plugin-batch-attribute-updates": "1.1.11",
38
38
  "@atlaskit/editor-plugin-content-insertion": "^1.11.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-prosemirror": "6.2.1",
44
44
  "@atlaskit/editor-shared-styles": "^3.2.0",
45
45
  "@atlaskit/editor-tables": "^2.8.0",
46
- "@atlaskit/icon": "^23.3.0",
46
+ "@atlaskit/icon": "^23.4.0",
47
47
  "@atlaskit/menu": "^2.13.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
@@ -51,9 +51,9 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
52
  "@atlaskit/primitives": "^13.3.0",
53
53
  "@atlaskit/theme": "^14.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^2.34.0",
54
+ "@atlaskit/tmp-editor-statsig": "^2.41.0",
55
55
  "@atlaskit/toggle": "^14.0.0",
56
- "@atlaskit/tokens": "^3.0.0",
56
+ "@atlaskit/tokens": "^3.2.0",
57
57
  "@atlaskit/tooltip": "^19.0.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
@@ -134,6 +134,15 @@
134
134
  },
135
135
  "platform_editor_table_overflow_in_full_width_fix": {
136
136
  "type": "boolean"
137
+ },
138
+ "platform_editor_table_use_shared_state_hook_fg": {
139
+ "type": "boolean"
140
+ },
141
+ "platform_editor_live_page_prevent_table_recreation": {
142
+ "type": "boolean"
143
+ },
144
+ "platform_editor_nested_tables_paste_dupe_fix": {
145
+ "type": "boolean"
137
146
  }
138
147
  }
139
148
  }
@@ -37,8 +37,6 @@ const cssVariablePattern = /^VAR\(--.*\)$/;
37
37
  export default class TableCell extends TableNodeView<HTMLElement> implements NodeView {
38
38
  private delayHandle: number | undefined;
39
39
 
40
- // Ignored via go/ees005
41
- // eslint-disable-next-line @typescript-eslint/max-params
42
40
  constructor(
43
41
  node: PMNode,
44
42
  view: EditorView,
@@ -17,6 +17,7 @@ import { tableMarginSides } from '@atlaskit/editor-common/styles';
17
17
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
18
18
  import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
19
19
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
20
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
20
21
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
21
22
  import {
22
23
  akEditorTableNumberColumnWidth,
@@ -26,7 +27,6 @@ import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
26
27
  import { fg } from '@atlaskit/platform-feature-flags';
27
28
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
28
29
  import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
29
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
30
  import { token } from '@atlaskit/tokens';
31
31
 
32
32
  import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
@@ -107,7 +107,7 @@ interface ComponentProps {
107
107
 
108
108
  contentDOM: (node: HTMLElement | null) => void;
109
109
  containerWidth: EditorContainerWidth;
110
- allowControls: boolean;
110
+ allowControls?: boolean;
111
111
 
112
112
  allowTableResizing?: boolean;
113
113
  allowTableAlignment?: boolean;
@@ -125,12 +125,13 @@ interface ComponentProps {
125
125
  pluginInjectionApi?: PluginInjectionAPI;
126
126
  intl: IntlShape;
127
127
 
128
- // marking props as option to ensure backward compatibility when platform_editor_table_use_shared_state_hook disabled
128
+ // marking props as optional to ensure backward compatibility when platform_editor_table_use_shared_state_hook_fg disabled
129
129
  isInDanger?: boolean;
130
130
  hoveredRows?: number[];
131
131
  hoveredCell?: CellHoverMeta;
132
132
  isTableHovered?: boolean;
133
133
  isWholeTableInDanger?: boolean;
134
+ selection?: Selection;
134
135
  }
135
136
 
136
137
  interface TableState {
@@ -598,7 +599,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
598
599
 
599
600
  const table = findTable(view.state.selection);
600
601
 
601
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
602
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
602
603
  const pluginState = getPluginState(view.state);
603
604
  isInDanger = pluginState.isInDanger;
604
605
  }
@@ -809,6 +810,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
809
810
  isTableScalingEnabled, // here we can use options.isTableScalingEnabled
810
811
  allowTableResizing,
811
812
  allowTableAlignment,
813
+ selection,
812
814
  } = this.props;
813
815
 
814
816
  let { isInDanger, hoveredRows, hoveredCell, isTableHovered, isWholeTableInDanger } = this.props;
@@ -816,7 +818,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
816
818
  const { showBeforeShadow, showAfterShadow } = this.state;
817
819
  const node = getNode();
818
820
 
819
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
821
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
820
822
  const pluginState = getPluginState(view.state);
821
823
  isInDanger = pluginState.isInDanger;
822
824
  hoveredRows = pluginState.hoveredRows;
@@ -926,7 +928,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
926
928
  [ClassName.WITH_CONTROLS]: allowControls && tableActive,
927
929
  [ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
928
930
  [ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
929
- [ClassName.TABLE_SELECTED]: isTableSelected(view.state.selection),
931
+ [ClassName.TABLE_SELECTED]: isTableSelected(selection ?? view.state.selection),
930
932
  })}
931
933
  editorView={view}
932
934
  getPos={getPos}