@atlaskit/editor-plugin-table 7.4.1 → 7.4.3

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +2 -4
  3. package/dist/cjs/nodeviews/TableContainer.js +5 -10
  4. package/dist/cjs/nodeviews/TableResizer.js +3 -7
  5. package/dist/cjs/ui/DragHandle/index.js +34 -2
  6. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -0
  7. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -0
  8. package/dist/cjs/utils/analytics.js +1 -2
  9. package/dist/cjs/utils/index.js +18 -0
  10. package/dist/cjs/utils/merged-cells.js +95 -1
  11. package/dist/es2019/nodeviews/TableComponent.js +2 -4
  12. package/dist/es2019/nodeviews/TableContainer.js +5 -10
  13. package/dist/es2019/nodeviews/TableResizer.js +3 -7
  14. package/dist/es2019/ui/DragHandle/index.js +36 -2
  15. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -0
  16. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +1 -0
  17. package/dist/es2019/utils/analytics.js +1 -2
  18. package/dist/es2019/utils/index.js +1 -1
  19. package/dist/es2019/utils/merged-cells.js +91 -0
  20. package/dist/esm/nodeviews/TableComponent.js +2 -4
  21. package/dist/esm/nodeviews/TableContainer.js +5 -10
  22. package/dist/esm/nodeviews/TableResizer.js +3 -7
  23. package/dist/esm/ui/DragHandle/index.js +35 -3
  24. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -0
  25. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +1 -0
  26. package/dist/esm/utils/analytics.js +1 -2
  27. package/dist/esm/utils/index.js +1 -1
  28. package/dist/esm/utils/merged-cells.js +94 -0
  29. package/dist/types/nodeviews/TableContainer.d.ts +2 -4
  30. package/dist/types/nodeviews/TableResizer.d.ts +1 -2
  31. package/dist/types/ui/DragHandle/index.d.ts +2 -1
  32. package/dist/types/utils/analytics.d.ts +0 -1
  33. package/dist/types/utils/index.d.ts +1 -1
  34. package/dist/types/utils/merged-cells.d.ts +28 -0
  35. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +2 -4
  36. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -2
  37. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +2 -1
  38. package/dist/types-ts4.5/utils/analytics.d.ts +0 -1
  39. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  40. package/dist/types-ts4.5/utils/merged-cells.d.ts +28 -0
  41. package/package.json +3 -3
  42. package/src/nodeviews/TableComponent.tsx +1 -2
  43. package/src/nodeviews/TableContainer.tsx +0 -9
  44. package/src/nodeviews/TableResizer.tsx +0 -6
  45. package/src/ui/DragHandle/index.tsx +64 -9
  46. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -0
  47. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +1 -0
  48. package/src/utils/analytics.ts +0 -2
  49. package/src/utils/index.ts +3 -0
  50. package/src/utils/merged-cells.ts +104 -0
@@ -564,8 +564,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
564
564
  var isNested = isTableNested(view.state, tablePos);
565
565
  var topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
566
566
  var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
567
- stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar,
568
- tableResizePerformance = _getEditorFeatureFlag3.tableResizePerformance;
567
+ stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar;
569
568
  return /*#__PURE__*/React.createElement(TableContainer, {
570
569
  className: classnames(ClassName.TABLE_CONTAINER, (_classnames = {}, _defineProperty(_classnames, ClassName.WITH_CONTROLS, allowControls && tableActive), _defineProperty(_classnames, ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), _defineProperty(_classnames, ClassName.HOVERED_DELETE_BUTTON, isInDanger), _defineProperty(_classnames, ClassName.TABLE_SELECTED, isTableSelected(view.state.selection)), _classnames)),
571
570
  editorView: view,
@@ -577,8 +576,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
577
576
  isNested: isNested,
578
577
  pluginInjectionApi: pluginInjectionApi,
579
578
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
580
- isResizing: isResizing,
581
- tableResizePerformance: tableResizePerformance
579
+ isResizing: isResizing
582
580
  }, /*#__PURE__*/React.createElement("div", {
583
581
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
584
582
  "data-testid": "sticky-sentinel-top"
@@ -43,8 +43,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
43
43
  getPos = _ref2.getPos,
44
44
  tableRef = _ref2.tableRef,
45
45
  isResizing = _ref2.isResizing,
46
- pluginInjectionApi = _ref2.pluginInjectionApi,
47
- tableResizePerformance = _ref2.tableResizePerformance;
46
+ pluginInjectionApi = _ref2.pluginInjectionApi;
48
47
  var containerRef = useRef(null);
49
48
  var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
50
49
  var updateContainerHeight = useCallback(function (height) {
@@ -125,8 +124,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
125
124
  tableRef: tableRef,
126
125
  displayGuideline: displayGuideline,
127
126
  attachAnalyticsEvent: attachAnalyticsEvent,
128
- displayGapCursor: displayGapCursor,
129
- tableResizePerformance: tableResizePerformance
127
+ displayGapCursor: displayGapCursor
130
128
  };
131
129
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
132
130
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -138,8 +136,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
138
136
  style: {
139
137
  display: 'flex',
140
138
  justifyContent: 'center'
141
- },
142
- contentEditable: tableResizePerformance && isResizing ? 'false' : undefined
139
+ }
143
140
  }, /*#__PURE__*/React.createElement("div", {
144
141
  style: {
145
142
  width: tableWidthRef.current
@@ -165,8 +162,7 @@ export var TableContainer = function TableContainer(_ref3) {
165
162
  tableRef = _ref3.tableRef,
166
163
  isNested = _ref3.isNested,
167
164
  isResizing = _ref3.isResizing,
168
- pluginInjectionApi = _ref3.pluginInjectionApi,
169
- tableResizePerformance = _ref3.tableResizePerformance;
165
+ pluginInjectionApi = _ref3.pluginInjectionApi;
170
166
  if (isTableResizingEnabled && !isNested) {
171
167
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
172
168
  className: className,
@@ -176,8 +172,7 @@ export var TableContainer = function TableContainer(_ref3) {
176
172
  getPos: getPos,
177
173
  tableRef: tableRef,
178
174
  isResizing: isResizing,
179
- pluginInjectionApi: pluginInjectionApi,
180
- tableResizePerformance: tableResizePerformance
175
+ pluginInjectionApi: pluginInjectionApi
181
176
  }, children);
182
177
  }
183
178
  var tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
@@ -87,8 +87,7 @@ export var TableResizer = function TableResizer(_ref) {
87
87
  tableRef = _ref.tableRef,
88
88
  displayGuideline = _ref.displayGuideline,
89
89
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
90
- displayGapCursor = _ref.displayGapCursor,
91
- tableResizePerformance = _ref.tableResizePerformance;
90
+ displayGapCursor = _ref.displayGapCursor;
92
91
  var currentGap = useRef(0);
93
92
  // track resizing state - use ref over state to avoid re-render
94
93
  var isResizing = useRef(false);
@@ -218,10 +217,7 @@ export var TableResizer = function TableResizer(_ref) {
218
217
  var resizeFrameRatePayloads = generateResizeFrameRatePayloads({
219
218
  docSize: state.doc.nodeSize,
220
219
  frameRateSamples: frameRateSamples,
221
- originalNode: node,
222
- experiments: {
223
- tableResizePerformance: tableResizePerformance
224
- }
220
+ originalNode: node
225
221
  });
226
222
  resizeFrameRatePayloads.forEach(function (payload) {
227
223
  var _attachAnalyticsEvent;
@@ -257,7 +253,7 @@ export var TableResizer = function TableResizer(_ref) {
257
253
  onResizeStop();
258
254
  }
259
255
  return newWidth;
260
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, tableResizePerformance]);
256
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
261
257
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
262
258
  var newWidth = width + step;
263
259
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -6,12 +6,14 @@ import ReactDOM from 'react-dom';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
8
8
  import { browser } from '@atlaskit/editor-common/utils';
9
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
10
+ import { findTable, TableMap } from '@atlaskit/editor-tables';
9
11
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
10
12
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
11
13
  import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
12
14
  import { getPluginState } from '../../pm-plugins/plugin-factory';
13
15
  import { TableCssClassName as ClassName } from '../../types';
14
- import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
16
+ import { findDuplicatePosition, hasMergedCellsInSelection } from '../../utils';
15
17
  import { dragTableInsertColumnButtonSize } from '../consts';
16
18
  import { DragPreview } from '../DragPreview';
17
19
  import { HandleIconComponent } from './HandleIconComponent';
@@ -30,6 +32,7 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
30
32
  onMouseOver = _ref.onMouseOver,
31
33
  onMouseOut = _ref.onMouseOut,
32
34
  toggleDragMenu = _ref.toggleDragMenu,
35
+ hoveredCell = _ref.hoveredCell,
33
36
  onClick = _ref.onClick,
34
37
  editorView = _ref.editorView,
35
38
  formatMessage = _ref.intl.formatMessage;
@@ -50,8 +53,37 @@ var DragHandleComponent = function DragHandleComponent(_ref) {
50
53
  var isRowHandleHovered = isRow && hoveredRows.length > 0;
51
54
  var isColumnHandleHovered = isColumn && hoveredColumns.length > 0;
52
55
  var hasMergedCells = useMemo(function () {
53
- return isRow ? hasMergedCellsInRow(indexes[0])(selection) : hasMergedCellsInColumn(indexes[0])(selection);
54
- }, [indexes, isRow, selection]);
56
+ var table = findTable(selection);
57
+ if (!table) {
58
+ return false;
59
+ }
60
+ var map = TableMap.get(table === null || table === void 0 ? void 0 : table.node);
61
+ if (!map.hasMergedCells() || indexes.length < 1) {
62
+ return false;
63
+ }
64
+ var mapByColumn = map.mapByColumn,
65
+ mapByRow = map.mapByRow;
66
+
67
+ // this handle when hover to first column or row which has merged cells.
68
+ if (hoveredCell && hoveredCell.rowIndex !== undefined && hoveredCell.colIndex !== undefined && selection instanceof TextSelection) {
69
+ var rowIndex = hoveredCell.rowIndex,
70
+ colIndex = hoveredCell.colIndex;
71
+ var mergedPositionInRow = findDuplicatePosition(mapByRow[rowIndex]);
72
+ var mergedPositionInCol = findDuplicatePosition(mapByColumn[colIndex]);
73
+ var hasMergedCellsInFirstRowOrColumn = direction === 'column' ? mergedPositionInRow.includes(mapByRow[0][colIndex]) : mergedPositionInCol.includes(mapByColumn[0][rowIndex]);
74
+ var isHoveredOnFirstRowOrColumn = direction === 'column' ? hoveredCell.rowIndex === 0 && hasMergedCellsInFirstRowOrColumn : hoveredCell.colIndex === 0 && hasMergedCellsInFirstRowOrColumn;
75
+ if (isHoveredOnFirstRowOrColumn) {
76
+ var mergedSizes = direction === 'column' ? mapByRow[0].filter(function (el) {
77
+ return el === mapByRow[0][colIndex];
78
+ }).length : mapByColumn[0].filter(function (el) {
79
+ return el === mapByColumn[0][rowIndex];
80
+ }).length;
81
+ var mergedSelection = hasMergedCellsInSelection(direction === 'column' ? [colIndex, colIndex + mergedSizes - 1] : [rowIndex, rowIndex + mergedSizes - 1], direction)(selection);
82
+ return mergedSelection;
83
+ }
84
+ }
85
+ return hasMergedCellsInSelection(indexes, direction)(selection);
86
+ }, [indexes, selection, direction, hoveredCell]);
55
87
  var handleIconProps = {
56
88
  forceDefaultHandle: forceDefaultHandle,
57
89
  isHandleHovered: isColumnHandleHovered || isRowHandleHovered,
@@ -139,6 +139,7 @@ export var ColumnControls = function ColumnControls(_ref) {
139
139
  direction: "column",
140
140
  tableLocalId: localId || '',
141
141
  indexes: indexes,
142
+ hoveredCell: hoveredCell,
142
143
  previewWidth: previewWidth,
143
144
  forceDefaultHandle: !isHover,
144
145
  previewHeight: previewHeight,
@@ -141,6 +141,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
141
141
  previewWidth: tableWidth,
142
142
  previewHeight: previewHeight,
143
143
  appearance: appearance,
144
+ hoveredCell: hoveredCell,
144
145
  onClick: handleClick,
145
146
  onMouseOver: handleMouseOver,
146
147
  onMouseOut: handleMouseOut,
@@ -107,8 +107,7 @@ export var generateResizeFrameRatePayloads = function generateResizeFrameRatePay
107
107
  frameRate: frameRateSample,
108
108
  nodeSize: props.originalNode.nodeSize,
109
109
  docSize: props.docSize,
110
- isInitialSample: index === 0,
111
- experiments: props.experiments
110
+ isInitialSample: index === 0
112
111
  }
113
112
  };
114
113
  });
@@ -8,4 +8,4 @@ export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getR
8
8
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
9
9
  export { getMergedCellsPositions } from './table';
10
10
  export { updatePluginStateDecorations } from './update-plugin-state-decorations';
11
- export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween } from './merged-cells';
11
+ export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells } from './merged-cells';
@@ -195,4 +195,98 @@ export var hasMergedCellsWithRowNextToRowIndex = function hasMergedCellsWithRowN
195
195
  }
196
196
  }
197
197
  return false;
198
+ };
199
+ export var hasMergedCellsInSelection = function hasMergedCellsInSelection(indexes, type) {
200
+ return function (selection) {
201
+ var table = findTable(selection);
202
+ if (!table) {
203
+ return false;
204
+ }
205
+ var map = TableMap.get(table.node);
206
+ if (!map.hasMergedCells()) {
207
+ return false;
208
+ }
209
+ return checkEdgeHasMergedCells(indexes, map, type);
210
+ };
211
+ };
212
+
213
+ /**
214
+ * handle table map by preprocess table's map row or column.
215
+ *
216
+ * @param map TableMap
217
+ * @returns object including mapByRow and mapByColumn
218
+ */
219
+ export var getTableMapByRowOrColumn = function getTableMapByRowOrColumn(map) {
220
+ var mapByRow = Array(map.height);
221
+ var mapByColumn = Array(map.width);
222
+ var mapCopy = _toConsumableArray(map.map);
223
+ for (var i = 0; i < mapCopy.length; i++) {
224
+ var _mapByColumn$columnIn, _mapByRow$rowIndex;
225
+ var columnIndex = i % map.width;
226
+ mapByColumn[columnIndex] = [].concat(_toConsumableArray((_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : []), [mapCopy[i]]);
227
+ var rowIndex = Math.trunc(i / map.width);
228
+ mapByRow[rowIndex] = [].concat(_toConsumableArray((_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : []), [mapCopy[i]]);
229
+ }
230
+ return {
231
+ mapByRow: mapByRow,
232
+ mapByColumn: mapByColumn
233
+ };
234
+ };
235
+
236
+ /**
237
+ * this check the selection has merged cells with previous/next col or row.
238
+ *
239
+ * @param indexes - this get the indexes of the selection,e.g. [0,1] for selecting first two rows or columns.
240
+ * @param tableMap - this return a TableMap object.
241
+ * @param direction - check selection is selected by row or column
242
+ * @returns boolean
243
+ */
244
+ export var checkEdgeHasMergedCells = function checkEdgeHasMergedCells(indexes, tableMap, direction) {
245
+ var _getTableMapByRowOrCo = getTableMapByRowOrColumn(tableMap),
246
+ mapByRow = _getTableMapByRowOrCo.mapByRow,
247
+ mapByColumn = _getTableMapByRowOrCo.mapByColumn;
248
+ var map = 'row' === direction ? mapByRow : mapByColumn;
249
+ var lengthLimiter = direction === 'row' ? tableMap.width : tableMap.height;
250
+ var minIndex = Math.min.apply(Math, _toConsumableArray(indexes));
251
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(indexes));
252
+ var isTopSideHaveMergedCells = false;
253
+ var isBottomSideHaveMergedCells = false;
254
+ var isOldMinIndex = !map[minIndex - 1] && !map[minIndex];
255
+ var isOldMaxIndex = !map[maxIndex + 1] && !map[maxIndex];
256
+ if (minIndex > 0 && !isOldMinIndex) {
257
+ var prevSelectionSet = map[minIndex - 1];
258
+ var minSelectionSet = map[minIndex];
259
+ for (var i = 0; i < lengthLimiter; i++) {
260
+ if (prevSelectionSet[i] === minSelectionSet[i]) {
261
+ isTopSideHaveMergedCells = true;
262
+ break;
263
+ }
264
+ }
265
+ }
266
+ if (maxIndex < map.length - 1 && !isOldMaxIndex) {
267
+ var afterSelectionSet = map[maxIndex + 1];
268
+ var maxSelectionSet = map[maxIndex];
269
+ for (var _i = 0; _i < lengthLimiter; _i++) {
270
+ if (afterSelectionSet[_i] === maxSelectionSet[_i]) {
271
+ isBottomSideHaveMergedCells = true;
272
+ break;
273
+ }
274
+ }
275
+ }
276
+ return isTopSideHaveMergedCells || isBottomSideHaveMergedCells;
277
+ };
278
+
279
+ /**
280
+ * this function will find the duplicate position in the array(table map position array).
281
+ *
282
+ * @param array this usually be the array including positions of the table map.
283
+ * @returns []
284
+ */
285
+ export var findDuplicatePosition = function findDuplicatePosition(array) {
286
+ if (!array) {
287
+ return [];
288
+ }
289
+ return array.filter(function (item, index) {
290
+ return array.indexOf(item) !== index;
291
+ });
198
292
  };
@@ -24,9 +24,8 @@ type ResizableTableContainerProps = {
24
24
  tableRef: HTMLTableElement;
25
25
  isResizing?: boolean;
26
26
  pluginInjectionApi?: PluginInjectionAPI;
27
- tableResizePerformance?: boolean;
28
27
  };
29
- export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableResizePerformance, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
28
+ export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
30
29
  type TableContainerProps = {
31
30
  node: PMNode;
32
31
  className: string;
@@ -39,7 +38,6 @@ type TableContainerProps = {
39
38
  isNested: boolean;
40
39
  isResizing?: boolean;
41
40
  pluginInjectionApi?: PluginInjectionAPI;
42
- tableResizePerformance?: boolean;
43
41
  };
44
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, tableResizePerformance, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
42
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
45
43
  export {};
@@ -16,11 +16,10 @@ interface TableResizerProps {
16
16
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
17
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
18
  displayGapCursor: (toggle: boolean) => boolean;
19
- tableResizePerformance?: boolean;
20
19
  }
21
20
  export interface TableResizerImprovementProps extends TableResizerProps {
22
21
  onResizeStop?: () => void;
23
22
  onResizeStart?: () => void;
24
23
  }
25
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, tableResizePerformance, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
24
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
26
25
  export {};
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
6
- import type { TableDirection } from '../../types';
6
+ import type { CellHoverMeta, TableDirection } from '../../types';
7
7
  export type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger' | 'placeholder';
8
8
  type DragHandleProps = {
9
9
  tableLocalId: string;
@@ -11,6 +11,7 @@ type DragHandleProps = {
11
11
  forceDefaultHandle?: boolean;
12
12
  previewWidth?: number;
13
13
  previewHeight?: number;
14
+ hoveredCell?: CellHoverMeta;
14
15
  direction?: TableDirection;
15
16
  appearance?: DragHandleAppearance;
16
17
  onClick?: MouseEventHandler;
@@ -33,7 +33,6 @@ export declare const generateResizeFrameRatePayloads: (props: {
33
33
  docSize: number;
34
34
  frameRateSamples: number[];
35
35
  originalNode: PMNode;
36
- experiments?: Record<string, boolean | undefined>;
37
36
  }) => TableEventPayload[];
38
37
  /**
39
38
  * Measures the framerate of a component over a given time period.
@@ -9,4 +9,4 @@ export type { RowParams } from './row-controls';
9
9
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
10
10
  export { getMergedCellsPositions } from './table';
11
11
  export { updatePluginStateDecorations } from './update-plugin-state-decorations';
12
- export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, } from './merged-cells';
12
+ export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells, } from './merged-cells';
@@ -1,8 +1,36 @@
1
1
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import { TableMap } from '@atlaskit/editor-tables';
2
3
  type MergeType = 'row' | 'column';
3
4
  export declare const hasMergedCellsInColumn: (columnIndexes: number | number[]) => (selection: Selection) => boolean;
4
5
  export declare const hasMergedCellsInRow: (rowIndexes: number | number[]) => (selection: Selection) => boolean;
5
6
  export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
6
7
  export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
7
8
  export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
9
+ export declare const hasMergedCellsInSelection: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
10
+ /**
11
+ * handle table map by preprocess table's map row or column.
12
+ *
13
+ * @param map TableMap
14
+ * @returns object including mapByRow and mapByColumn
15
+ */
16
+ export declare const getTableMapByRowOrColumn: (map: TableMap) => {
17
+ mapByRow: any[];
18
+ mapByColumn: any[];
19
+ };
20
+ /**
21
+ * this check the selection has merged cells with previous/next col or row.
22
+ *
23
+ * @param indexes - this get the indexes of the selection,e.g. [0,1] for selecting first two rows or columns.
24
+ * @param tableMap - this return a TableMap object.
25
+ * @param direction - check selection is selected by row or column
26
+ * @returns boolean
27
+ */
28
+ export declare const checkEdgeHasMergedCells: (indexes: number[], tableMap: TableMap, direction: 'row' | 'column') => boolean;
29
+ /**
30
+ * this function will find the duplicate position in the array(table map position array).
31
+ *
32
+ * @param array this usually be the array including positions of the table map.
33
+ * @returns []
34
+ */
35
+ export declare const findDuplicatePosition: (array: number[]) => number[];
8
36
  export {};
@@ -24,9 +24,8 @@ type ResizableTableContainerProps = {
24
24
  tableRef: HTMLTableElement;
25
25
  isResizing?: boolean;
26
26
  pluginInjectionApi?: PluginInjectionAPI;
27
- tableResizePerformance?: boolean;
28
27
  };
29
- export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, tableResizePerformance, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
28
+ export declare const ResizableTableContainer: React.MemoExoticComponent<({ children, className, node, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element>;
30
29
  type TableContainerProps = {
31
30
  node: PMNode;
32
31
  className: string;
@@ -39,7 +38,6 @@ type TableContainerProps = {
39
38
  isNested: boolean;
40
39
  isResizing?: boolean;
41
40
  pluginInjectionApi?: PluginInjectionAPI;
42
- tableResizePerformance?: boolean;
43
41
  };
44
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, tableResizePerformance, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
42
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
45
43
  export {};
@@ -16,11 +16,10 @@ interface TableResizerProps {
16
16
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
17
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
18
  displayGapCursor: (toggle: boolean) => boolean;
19
- tableResizePerformance?: boolean;
20
19
  }
21
20
  export interface TableResizerImprovementProps extends TableResizerProps {
22
21
  onResizeStop?: () => void;
23
22
  onResizeStart?: () => void;
24
23
  }
25
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, tableResizePerformance, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
24
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
26
25
  export {};
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
6
- import type { TableDirection } from '../../types';
6
+ import type { CellHoverMeta, TableDirection } from '../../types';
7
7
  export type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger' | 'placeholder';
8
8
  type DragHandleProps = {
9
9
  tableLocalId: string;
@@ -11,6 +11,7 @@ type DragHandleProps = {
11
11
  forceDefaultHandle?: boolean;
12
12
  previewWidth?: number;
13
13
  previewHeight?: number;
14
+ hoveredCell?: CellHoverMeta;
14
15
  direction?: TableDirection;
15
16
  appearance?: DragHandleAppearance;
16
17
  onClick?: MouseEventHandler;
@@ -33,7 +33,6 @@ export declare const generateResizeFrameRatePayloads: (props: {
33
33
  docSize: number;
34
34
  frameRateSamples: number[];
35
35
  originalNode: PMNode;
36
- experiments?: Record<string, boolean | undefined>;
37
36
  }) => TableEventPayload[];
38
37
  /**
39
38
  * Measures the framerate of a component over a given time period.
@@ -9,4 +9,4 @@ export type { RowParams } from './row-controls';
9
9
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
10
10
  export { getMergedCellsPositions } from './table';
11
11
  export { updatePluginStateDecorations } from './update-plugin-state-decorations';
12
- export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, } from './merged-cells';
12
+ export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells, } from './merged-cells';
@@ -1,8 +1,36 @@
1
1
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import { TableMap } from '@atlaskit/editor-tables';
2
3
  type MergeType = 'row' | 'column';
3
4
  export declare const hasMergedCellsInColumn: (columnIndexes: number | number[]) => (selection: Selection) => boolean;
4
5
  export declare const hasMergedCellsInRow: (rowIndexes: number | number[]) => (selection: Selection) => boolean;
5
6
  export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
6
7
  export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
7
8
  export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
9
+ export declare const hasMergedCellsInSelection: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
10
+ /**
11
+ * handle table map by preprocess table's map row or column.
12
+ *
13
+ * @param map TableMap
14
+ * @returns object including mapByRow and mapByColumn
15
+ */
16
+ export declare const getTableMapByRowOrColumn: (map: TableMap) => {
17
+ mapByRow: any[];
18
+ mapByColumn: any[];
19
+ };
20
+ /**
21
+ * this check the selection has merged cells with previous/next col or row.
22
+ *
23
+ * @param indexes - this get the indexes of the selection,e.g. [0,1] for selecting first two rows or columns.
24
+ * @param tableMap - this return a TableMap object.
25
+ * @param direction - check selection is selected by row or column
26
+ * @returns boolean
27
+ */
28
+ export declare const checkEdgeHasMergedCells: (indexes: number[], tableMap: TableMap, direction: 'row' | 'column') => boolean;
29
+ /**
30
+ * this function will find the duplicate position in the array(table map position array).
31
+ *
32
+ * @param array this usually be the array including positions of the table map.
33
+ * @returns []
34
+ */
35
+ export declare const findDuplicatePosition: (array: number[]) => number[];
8
36
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.4.1",
3
+ "version": "7.4.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.5.1",
32
32
  "@atlaskit/custom-steps": "^0.0.13",
33
- "@atlaskit/editor-common": "^78.7.0",
33
+ "@atlaskit/editor-common": "^78.8.0",
34
34
  "@atlaskit/editor-palette": "1.5.2",
35
35
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^1.0.0",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.0.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
49
- "@atlaskit/primitives": "^3.0.0",
49
+ "@atlaskit/primitives": "^3.1.0",
50
50
  "@atlaskit/theme": "^12.6.0",
51
51
  "@atlaskit/toggle": "^13.0.0",
52
52
  "@atlaskit/tokens": "^1.38.0",
@@ -535,7 +535,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
535
535
  shadowPadding +
536
536
  2;
537
537
 
538
- const { stickyScrollbar, tableResizePerformance } = getEditorFeatureFlags();
538
+ const { stickyScrollbar } = getEditorFeatureFlags();
539
539
 
540
540
  return (
541
541
  <TableContainer
@@ -555,7 +555,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
555
555
  pluginInjectionApi={pluginInjectionApi}
556
556
  isTableResizingEnabled={options?.isTableResizingEnabled}
557
557
  isResizing={isResizing}
558
- tableResizePerformance={tableResizePerformance}
559
558
  >
560
559
  <div
561
560
  className={ClassName.TABLE_STICKY_SENTINEL_TOP}
@@ -75,7 +75,6 @@ type ResizableTableContainerProps = {
75
75
  tableRef: HTMLTableElement;
76
76
  isResizing?: boolean;
77
77
  pluginInjectionApi?: PluginInjectionAPI;
78
- tableResizePerformance?: boolean;
79
78
  };
80
79
 
81
80
  export const ResizableTableContainer = React.memo(
@@ -89,7 +88,6 @@ export const ResizableTableContainer = React.memo(
89
88
  tableRef,
90
89
  isResizing,
91
90
  pluginInjectionApi,
92
- tableResizePerformance,
93
91
  }: PropsWithChildren<ResizableTableContainerProps>) => {
94
92
  const containerRef = useRef<HTMLDivElement | null>(null);
95
93
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
@@ -209,7 +207,6 @@ export const ResizableTableContainer = React.memo(
209
207
  displayGuideline,
210
208
  attachAnalyticsEvent,
211
209
  displayGapCursor,
212
- tableResizePerformance,
213
210
  };
214
211
 
215
212
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
@@ -226,9 +223,6 @@ export const ResizableTableContainer = React.memo(
226
223
  display: 'flex',
227
224
  justifyContent: 'center',
228
225
  }}
229
- contentEditable={
230
- tableResizePerformance && isResizing ? 'false' : undefined
231
- }
232
226
  >
233
227
  <div
234
228
  style={{
@@ -260,7 +254,6 @@ type TableContainerProps = {
260
254
  isNested: boolean;
261
255
  isResizing?: boolean;
262
256
  pluginInjectionApi?: PluginInjectionAPI;
263
- tableResizePerformance?: boolean;
264
257
  };
265
258
 
266
259
  export const TableContainer = ({
@@ -276,7 +269,6 @@ export const TableContainer = ({
276
269
  isNested,
277
270
  isResizing,
278
271
  pluginInjectionApi,
279
- tableResizePerformance,
280
272
  }: PropsWithChildren<TableContainerProps>) => {
281
273
  if (isTableResizingEnabled && !isNested) {
282
274
  return (
@@ -289,7 +281,6 @@ export const TableContainer = ({
289
281
  tableRef={tableRef}
290
282
  isResizing={isResizing}
291
283
  pluginInjectionApi={pluginInjectionApi}
292
- tableResizePerformance={tableResizePerformance}
293
284
  >
294
285
  {children}
295
286
  </ResizableTableContainer>
@@ -68,7 +68,6 @@ interface TableResizerProps {
68
68
  payload: TableEventPayload,
69
69
  ) => ((tr: Transaction) => boolean) | undefined;
70
70
  displayGapCursor: (toggle: boolean) => boolean;
71
- tableResizePerformance?: boolean;
72
71
  }
73
72
 
74
73
  export interface TableResizerImprovementProps extends TableResizerProps {
@@ -163,7 +162,6 @@ export const TableResizer = ({
163
162
  displayGuideline,
164
163
  attachAnalyticsEvent,
165
164
  displayGapCursor,
166
- tableResizePerformance,
167
165
  }: PropsWithChildren<TableResizerImprovementProps>) => {
168
166
  const currentGap = useRef(0);
169
167
  // track resizing state - use ref over state to avoid re-render
@@ -356,9 +354,6 @@ export const TableResizer = ({
356
354
  docSize: state.doc.nodeSize,
357
355
  frameRateSamples,
358
356
  originalNode: node,
359
- experiments: {
360
- tableResizePerformance,
361
- },
362
357
  });
363
358
  resizeFrameRatePayloads.forEach((payload) => {
364
359
  attachAnalyticsEvent(payload)?.(tr);
@@ -421,7 +416,6 @@ export const TableResizer = ({
421
416
  attachAnalyticsEvent,
422
417
  endMeasure,
423
418
  onResizeStop,
424
- tableResizePerformance,
425
419
  ],
426
420
  );
427
421