@atlaskit/editor-plugin-table 2.10.1 → 2.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +9 -3
  3. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +9 -2
  4. package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
  5. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +9 -3
  6. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +10 -3
  7. package/dist/es2019/plugins/table/nodeviews/table.js +3 -1
  8. package/dist/esm/plugins/table/nodeviews/TableComponent.js +9 -3
  9. package/dist/esm/plugins/table/nodeviews/TableContainer.js +10 -3
  10. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  11. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +4 -2
  12. package/dist/types/plugins/table/nodeviews/table.d.ts +4 -4
  13. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +4 -2
  14. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +4 -4
  15. package/package.json +3 -3
  16. package/src/__tests__/unit/commands/go-to-next-cell.ts +5 -5
  17. package/src/__tests__/unit/commands/insert.ts +5 -5
  18. package/src/__tests__/unit/commands/misc.ts +6 -8
  19. package/src/__tests__/unit/copy-paste.ts +10 -13
  20. package/src/__tests__/unit/event-handlers/index.ts +6 -6
  21. package/src/__tests__/unit/handlers.ts +6 -5
  22. package/src/__tests__/unit/hover-selection.ts +7 -6
  23. package/src/__tests__/unit/layout.ts +6 -6
  24. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +23 -23
  25. package/src/__tests__/unit/sort-column.ts +5 -5
  26. package/src/__tests__/unit/transforms/delete-columns.ts +6 -6
  27. package/src/__tests__/unit/transforms/delete-rows.ts +6 -6
  28. package/src/__tests__/unit/transforms/merging.ts +5 -5
  29. package/src/__tests__/unit/ui/TableFloatingControls.tsx +5 -5
  30. package/src/__tests__/unit/utils.ts +5 -5
  31. package/src/plugins/table/nodeviews/TableComponent.tsx +20 -3
  32. package/src/plugins/table/nodeviews/TableContainer.tsx +19 -3
  33. package/src/plugins/table/nodeviews/table.tsx +14 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 2.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`31031f52f80`](https://bitbucket.org/atlassian/atlassian-frontend/commits/31031f52f80) - Fix table shift when two users resize the same table in collab mode
8
+ - Updated dependencies
9
+
3
10
  ## 2.10.1
4
11
 
5
12
  ### Patch Changes
@@ -320,7 +320,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
320
320
  view = _this$props8.view,
321
321
  getNode = _this$props8.getNode,
322
322
  isMediaFullscreen = _this$props8.isMediaFullscreen,
323
- allowColumnResizing = _this$props8.allowColumnResizing;
323
+ allowColumnResizing = _this$props8.allowColumnResizing,
324
+ isResizing = _this$props8.isResizing,
325
+ options = _this$props8.options;
324
326
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
325
327
  isInDanger = _getPluginState.isInDanger;
326
328
  var table = (0, _utils2.findTable)(view.state.selection);
@@ -347,7 +349,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
347
349
  var previousTable = this.node;
348
350
  if ((0, _utils4.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || (0, _utils4.tablesHaveDifferentNoOfColumns)(currentTable, previousTable)) {
349
351
  var _view = this.props.view;
350
- (0, _utils3.insertColgroupFromNode)(this.table, currentTable);
352
+ var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || (0, _utils4.tablesHaveDifferentNoOfColumns)(currentTable, previousTable) && isResizing;
353
+ if (shouldRecreateResizeCols) {
354
+ (0, _utils3.insertColgroupFromNode)(this.table, currentTable);
355
+ }
351
356
  (0, _dom.updateControls)()(_view.state);
352
357
  }
353
358
  this.handleTableResizingDebounced();
@@ -421,7 +426,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
421
426
  isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
422
427
  isNested: isNested,
423
428
  pluginInjectionApi: pluginInjectionApi,
424
- isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
429
+ isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
430
+ isResizing: isResizing
425
431
  }, /*#__PURE__*/_react.default.createElement("div", {
426
432
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
427
433
  "data-testid": "sticky-sentinel-top"
@@ -50,9 +50,11 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
50
50
  editorView = _ref2.editorView,
51
51
  getPos = _ref2.getPos,
52
52
  tableRef = _ref2.tableRef,
53
+ isResizing = _ref2.isResizing,
53
54
  pluginInjectionApi = _ref2.pluginInjectionApi;
54
55
  var containerRef = (0, _react.useRef)(null);
55
56
  var marginLeftRef = (0, _react.useRef)(0);
57
+ var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
56
58
  var updateWidth = (0, _react.useCallback)(function (width) {
57
59
  if (!containerRef.current) {
58
60
  return;
@@ -87,12 +89,15 @@ var ResizableTableContainer = function ResizableTableContainer(_ref2) {
87
89
  // 76 is currently an accepted padding value considering the spacing for resizer handle
88
90
  var responsiveContainerWidth = containerWidth - 76;
89
91
  var width = Math.min(tableWidth, responsiveContainerWidth);
90
- marginLeftRef.current = getMarginLeft(lineLength, width);
92
+ if (!isResizing) {
93
+ tableWidthRef.current = width;
94
+ marginLeftRef.current = getMarginLeft(lineLength, width);
95
+ }
91
96
  var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
92
97
  return /*#__PURE__*/_react.default.createElement("div", {
93
98
  style: {
94
99
  marginLeft: marginLeftRef.current,
95
- width: width
100
+ width: tableWidthRef.current
96
101
  },
97
102
  className: _types.TableCssClassName.TABLE_RESIZER_CONTAINER,
98
103
  ref: containerRef
@@ -126,6 +131,7 @@ var TableContainer = function TableContainer(_ref3) {
126
131
  getPos = _ref3.getPos,
127
132
  tableRef = _ref3.tableRef,
128
133
  isNested = _ref3.isNested,
134
+ isResizing = _ref3.isResizing,
129
135
  pluginInjectionApi = _ref3.pluginInjectionApi;
130
136
  if (isTableResizingEnabled && !isNested) {
131
137
  return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
@@ -136,6 +142,7 @@ var TableContainer = function TableContainer(_ref3) {
136
142
  editorView: editorView,
137
143
  getPos: getPos,
138
144
  tableRef: tableRef,
145
+ isResizing: isResizing,
139
146
  pluginInjectionApi: pluginInjectionApi
140
147
  }, children);
141
148
  }
@@ -96,7 +96,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
96
96
  }, {
97
97
  key: "setDomAttrs",
98
98
  value: function setDomAttrs(node) {
99
- var _this2 = this;
99
+ var _this2 = this,
100
+ _tableWidthPluginKey$;
100
101
  if (!this.table) {
101
102
  return;
102
103
  }
@@ -107,7 +108,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
107
108
 
108
109
  // handle inline style when table been resized
109
110
  var tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
110
- if (tableInlineWidth) {
111
+ var isTableResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
112
+ if (!isTableResizing && tableInlineWidth) {
111
113
  handleInlineTableWidth(this.table, tableInlineWidth);
112
114
  }
113
115
  }
@@ -312,7 +312,9 @@ class TableComponent extends React.Component {
312
312
  view,
313
313
  getNode,
314
314
  isMediaFullscreen,
315
- allowColumnResizing
315
+ allowColumnResizing,
316
+ isResizing,
317
+ options
316
318
  } = this.props;
317
319
  const {
318
320
  isInDanger
@@ -343,7 +345,10 @@ class TableComponent extends React.Component {
343
345
  const {
344
346
  view
345
347
  } = this.props;
346
- recreateResizeColsByNode(this.table, currentTable);
348
+ const shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
349
+ if (shouldRecreateResizeCols) {
350
+ recreateResizeColsByNode(this.table, currentTable);
351
+ }
347
352
  updateControls()(view.state);
348
353
  }
349
354
  this.handleTableResizingDebounced();
@@ -418,7 +423,8 @@ class TableComponent extends React.Component {
418
423
  isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
419
424
  isNested: isNested,
420
425
  pluginInjectionApi: pluginInjectionApi,
421
- isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
426
+ isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
427
+ isResizing: isResizing
422
428
  }, /*#__PURE__*/React.createElement("div", {
423
429
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
424
430
  "data-testid": "sticky-sentinel-top"
@@ -2,7 +2,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
- import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
6
6
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
7
  import { TableCssClassName as ClassName } from '../types';
8
8
  import { TableResizer } from './TableResizer';
@@ -40,10 +40,12 @@ export const ResizableTableContainer = ({
40
40
  editorView,
41
41
  getPos,
42
42
  tableRef,
43
+ isResizing,
43
44
  pluginInjectionApi
44
45
  }) => {
45
46
  const containerRef = useRef(null);
46
47
  const marginLeftRef = useRef(0);
48
+ const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
47
49
  const updateWidth = useCallback(width => {
48
50
  if (!containerRef.current) {
49
51
  return;
@@ -78,12 +80,15 @@ export const ResizableTableContainer = ({
78
80
  // 76 is currently an accepted padding value considering the spacing for resizer handle
79
81
  const responsiveContainerWidth = containerWidth - 76;
80
82
  const width = Math.min(tableWidth, responsiveContainerWidth);
81
- marginLeftRef.current = getMarginLeft(lineLength, width);
83
+ if (!isResizing) {
84
+ tableWidthRef.current = width;
85
+ marginLeftRef.current = getMarginLeft(lineLength, width);
86
+ }
82
87
  const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
83
88
  return /*#__PURE__*/React.createElement("div", {
84
89
  style: {
85
90
  marginLeft: marginLeftRef.current,
86
- width
91
+ width: tableWidthRef.current
87
92
  },
88
93
  className: ClassName.TABLE_RESIZER_CONTAINER,
89
94
  ref: containerRef
@@ -117,6 +122,7 @@ export const TableContainer = ({
117
122
  getPos,
118
123
  tableRef,
119
124
  isNested,
125
+ isResizing,
120
126
  pluginInjectionApi
121
127
  }) => {
122
128
  if (isTableResizingEnabled && !isNested) {
@@ -128,6 +134,7 @@ export const TableContainer = ({
128
134
  editorView: editorView,
129
135
  getPos: getPos,
130
136
  tableRef: tableRef,
137
+ isResizing: isResizing,
131
138
  pluginInjectionApi: pluginInjectionApi
132
139
  }, children);
133
140
  }
@@ -69,6 +69,7 @@ export default class TableView extends ReactNodeView {
69
69
  return rendered;
70
70
  }
71
71
  setDomAttrs(node) {
72
+ var _tableWidthPluginKey$;
72
73
  if (!this.table) {
73
74
  return;
74
75
  }
@@ -79,7 +80,8 @@ export default class TableView extends ReactNodeView {
79
80
 
80
81
  // handle inline style when table been resized
81
82
  const tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
82
- if (tableInlineWidth) {
83
+ const isTableResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
84
+ if (!isTableResizing && tableInlineWidth) {
83
85
  handleInlineTableWidth(this.table, tableInlineWidth);
84
86
  }
85
87
  }
@@ -313,7 +313,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
313
313
  view = _this$props8.view,
314
314
  getNode = _this$props8.getNode,
315
315
  isMediaFullscreen = _this$props8.isMediaFullscreen,
316
- allowColumnResizing = _this$props8.allowColumnResizing;
316
+ allowColumnResizing = _this$props8.allowColumnResizing,
317
+ isResizing = _this$props8.isResizing,
318
+ options = _this$props8.options;
317
319
  var _getPluginState = getPluginState(view.state),
318
320
  isInDanger = _getPluginState.isInDanger;
319
321
  var table = findTable(view.state.selection);
@@ -340,7 +342,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
340
342
  var previousTable = this.node;
341
343
  if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || tablesHaveDifferentNoOfColumns(currentTable, previousTable)) {
342
344
  var _view = this.props.view;
343
- recreateResizeColsByNode(this.table, currentTable);
345
+ var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
346
+ if (shouldRecreateResizeCols) {
347
+ recreateResizeColsByNode(this.table, currentTable);
348
+ }
344
349
  updateControls()(_view.state);
345
350
  }
346
351
  this.handleTableResizingDebounced();
@@ -414,7 +419,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
414
419
  isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
415
420
  isNested: isNested,
416
421
  pluginInjectionApi: pluginInjectionApi,
417
- isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
422
+ isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
423
+ isResizing: isResizing
418
424
  }, /*#__PURE__*/React.createElement("div", {
419
425
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
420
426
  "data-testid": "sticky-sentinel-top"
@@ -2,7 +2,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
- import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
6
6
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
7
  import { TableCssClassName as ClassName } from '../types';
8
8
  import { TableResizer } from './TableResizer';
@@ -39,9 +39,11 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
39
39
  editorView = _ref2.editorView,
40
40
  getPos = _ref2.getPos,
41
41
  tableRef = _ref2.tableRef,
42
+ isResizing = _ref2.isResizing,
42
43
  pluginInjectionApi = _ref2.pluginInjectionApi;
43
44
  var containerRef = useRef(null);
44
45
  var marginLeftRef = useRef(0);
46
+ var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
45
47
  var updateWidth = useCallback(function (width) {
46
48
  if (!containerRef.current) {
47
49
  return;
@@ -76,12 +78,15 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
76
78
  // 76 is currently an accepted padding value considering the spacing for resizer handle
77
79
  var responsiveContainerWidth = containerWidth - 76;
78
80
  var width = Math.min(tableWidth, responsiveContainerWidth);
79
- marginLeftRef.current = getMarginLeft(lineLength, width);
81
+ if (!isResizing) {
82
+ tableWidthRef.current = width;
83
+ marginLeftRef.current = getMarginLeft(lineLength, width);
84
+ }
80
85
  var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
81
86
  return /*#__PURE__*/React.createElement("div", {
82
87
  style: {
83
88
  marginLeft: marginLeftRef.current,
84
- width: width
89
+ width: tableWidthRef.current
85
90
  },
86
91
  className: ClassName.TABLE_RESIZER_CONTAINER,
87
92
  ref: containerRef
@@ -114,6 +119,7 @@ export var TableContainer = function TableContainer(_ref3) {
114
119
  getPos = _ref3.getPos,
115
120
  tableRef = _ref3.tableRef,
116
121
  isNested = _ref3.isNested,
122
+ isResizing = _ref3.isResizing,
117
123
  pluginInjectionApi = _ref3.pluginInjectionApi;
118
124
  if (isTableResizingEnabled && !isNested) {
119
125
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
@@ -124,6 +130,7 @@ export var TableContainer = function TableContainer(_ref3) {
124
130
  editorView: editorView,
125
131
  getPos: getPos,
126
132
  tableRef: tableRef,
133
+ isResizing: isResizing,
127
134
  pluginInjectionApi: pluginInjectionApi
128
135
  }, children);
129
136
  }
@@ -89,7 +89,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
89
89
  }, {
90
90
  key: "setDomAttrs",
91
91
  value: function setDomAttrs(node) {
92
- var _this2 = this;
92
+ var _this2 = this,
93
+ _tableWidthPluginKey$;
93
94
  if (!this.table) {
94
95
  return;
95
96
  }
@@ -100,7 +101,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
100
101
 
101
102
  // handle inline style when table been resized
102
103
  var tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
103
- if (tableInlineWidth) {
104
+ var isTableResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
105
+ if (!isTableResizing && tableInlineWidth) {
104
106
  handleInlineTableWidth(this.table, tableInlineWidth);
105
107
  }
106
108
  }
@@ -23,9 +23,10 @@ type ResizableTableContainerProps = {
23
23
  editorView: EditorView;
24
24
  getPos: () => number | undefined;
25
25
  tableRef: HTMLTableElement;
26
+ isResizing?: boolean;
26
27
  pluginInjectionApi?: PluginInjectionAPI;
27
28
  };
28
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
29
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
29
30
  type TableContainerProps = {
30
31
  node: PMNode;
31
32
  className: string;
@@ -36,7 +37,8 @@ type TableContainerProps = {
36
37
  getPos: () => number | undefined;
37
38
  tableRef: HTMLTableElement;
38
39
  isNested: boolean;
40
+ isResizing?: boolean;
39
41
  pluginInjectionApi?: PluginInjectionAPI;
40
42
  };
41
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
43
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
42
44
  export {};
@@ -3,10 +3,10 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import type { GetEditorContainerWidth, GetEditorFeatureFlags, getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
6
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
- import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
- import { PluginInjectionAPI } from '../types';
9
- import { Props, TableOptions } from './types';
6
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
+ import type { PluginInjectionAPI } from '../types';
9
+ import type { Props, TableOptions } from './types';
10
10
  type ForwardRef = (node: HTMLElement | null) => void;
11
11
  export default class TableView extends ReactNodeView<Props> {
12
12
  private table;
@@ -23,9 +23,10 @@ type ResizableTableContainerProps = {
23
23
  editorView: EditorView;
24
24
  getPos: () => number | undefined;
25
25
  tableRef: HTMLTableElement;
26
+ isResizing?: boolean;
26
27
  pluginInjectionApi?: PluginInjectionAPI;
27
28
  };
28
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
29
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, isResizing, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
29
30
  type TableContainerProps = {
30
31
  node: PMNode;
31
32
  className: string;
@@ -36,7 +37,8 @@ type TableContainerProps = {
36
37
  getPos: () => number | undefined;
37
38
  tableRef: HTMLTableElement;
38
39
  isNested: boolean;
40
+ isResizing?: boolean;
39
41
  pluginInjectionApi?: PluginInjectionAPI;
40
42
  };
41
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
43
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isTableResizingEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, isResizing, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
42
44
  export {};
@@ -3,10 +3,10 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import type { GetEditorContainerWidth, GetEditorFeatureFlags, getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
6
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
- import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
- import { PluginInjectionAPI } from '../types';
9
- import { Props, TableOptions } from './types';
6
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
+ import type { PluginInjectionAPI } from '../types';
9
+ import type { Props, TableOptions } from './types';
10
10
  type ForwardRef = (node: HTMLElement | null) => void;
11
11
  export default class TableView extends ReactNodeView<Props> {
12
12
  private table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.10.1",
3
+ "version": "2.10.2",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^28.1.0",
31
- "@atlaskit/editor-common": "^74.48.0",
31
+ "@atlaskit/editor-common": "^74.49.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.1.0",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.8",
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/icon": "^21.12.0",
39
39
  "@atlaskit/platform-feature-flags": "^0.2.1",
40
40
  "@atlaskit/theme": "^12.5.0",
41
- "@atlaskit/tokens": "^1.14.0",
41
+ "@atlaskit/tokens": "^1.15.0",
42
42
  "@atlaskit/tooltip": "^17.8.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@emotion/react": "^11.7.1",
@@ -4,15 +4,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
8
9
  import {
9
10
  createProsemirrorEditorFactory,
10
- LightEditorPlugin,
11
11
  Preset,
12
12
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
13
14
  import {
14
15
  doc,
15
- DocBuilder,
16
16
  p,
17
17
  table,
18
18
  td,
@@ -24,7 +24,7 @@ import {
24
24
  import tablePlugin from '../../../plugins/table';
25
25
  import { goToNextCell } from '../../../plugins/table/commands/go-to-next-cell';
26
26
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
27
- import { TablePluginState } from '../../../plugins/table/types';
27
+ import type { TablePluginState } from '../../../plugins/table/types';
28
28
 
29
29
  const TABLE_LOCAL_ID = 'test-table-local-id';
30
30
 
@@ -43,7 +43,7 @@ describe('table plugin: goToNextCell', () => {
43
43
  .add(guidelinePlugin)
44
44
  .add(tablePlugin);
45
45
  const editor = (doc: DocBuilder) =>
46
- createEditor<TablePluginState, PluginKey>({
46
+ createEditor<TablePluginState, PluginKey, typeof preset>({
47
47
  doc,
48
48
  preset,
49
49
  pluginKey,
@@ -4,15 +4,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
8
9
  import {
9
10
  createProsemirrorEditorFactory,
10
- LightEditorPlugin,
11
11
  Preset,
12
12
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
13
14
  import {
14
15
  doc,
15
- DocBuilder,
16
16
  p,
17
17
  table,
18
18
  td,
@@ -23,7 +23,7 @@ import {
23
23
  import tablePlugin from '../../../plugins/table';
24
24
  import { addColumnAt } from '../../../plugins/table/commands/insert';
25
25
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
26
- import { TablePluginState } from '../../../plugins/table/types';
26
+ import type { TablePluginState } from '../../../plugins/table/types';
27
27
 
28
28
  const TABLE_LOCAL_ID = 'test-table-local-id';
29
29
 
@@ -54,7 +54,7 @@ describe('table plugin: insert', () => {
54
54
  ]);
55
55
 
56
56
  const editor = (doc: DocBuilder) =>
57
- createEditor<TablePluginState, PluginKey>({
57
+ createEditor<TablePluginState, PluginKey, typeof preset>({
58
58
  doc,
59
59
  preset,
60
60
  pluginKey,
@@ -4,16 +4,16 @@ import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
8
  import { isColumnSelected } from '@atlaskit/editor-tables/utils';
9
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
9
10
  import {
10
11
  createProsemirrorEditorFactory,
11
- LightEditorPlugin,
12
12
  Preset,
13
13
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
14
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
14
15
  import {
15
16
  doc,
16
- DocBuilder,
17
17
  p,
18
18
  table,
19
19
  td,
@@ -29,10 +29,8 @@ import {
29
29
  import { getDecorations } from '../../../plugins/table/pm-plugins/decorations/plugin';
30
30
  import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
31
31
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
32
- import {
33
- TableDecorations,
34
- TablePluginState,
35
- } from '../../../plugins/table/types';
32
+ import type { TablePluginState } from '../../../plugins/table/types';
33
+ import { TableDecorations } from '../../../plugins/table/types';
36
34
 
37
35
  describe('table plugin: commands', () => {
38
36
  const createEditor = createProsemirrorEditorFactory();
@@ -50,7 +48,7 @@ describe('table plugin: commands', () => {
50
48
  },
51
49
  ]);
52
50
  const editor = (doc: DocBuilder) =>
53
- createEditor<TablePluginState, PluginKey>({
51
+ createEditor<TablePluginState, PluginKey, typeof preset>({
54
52
  doc,
55
53
  preset,
56
54
  pluginKey,
@@ -7,38 +7,35 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
7
7
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
8
8
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
9
9
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
10
- import {
11
- Fragment,
10
+ import type {
12
11
  Node as ProsemirrorNode,
13
12
  Schema,
14
- Slice,
15
13
  } from '@atlaskit/editor-prosemirror/model';
16
- import {
14
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
15
+ import type {
17
16
  PluginKey,
18
- TextSelection,
19
17
  Transaction,
20
18
  } from '@atlaskit/editor-prosemirror/state';
21
- import {
22
- __serializeForClipboard,
23
- EditorView,
24
- } from '@atlaskit/editor-prosemirror/view';
19
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
20
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
21
+ import { __serializeForClipboard } from '@atlaskit/editor-prosemirror/view';
25
22
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
26
23
  import {
27
24
  getCellsInTable,
28
25
  selectColumn,
29
26
  selectTable,
30
27
  } from '@atlaskit/editor-tables/utils';
28
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
31
29
  import {
32
30
  createProsemirrorEditorFactory,
33
- LightEditorPlugin,
34
31
  Preset,
35
32
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
36
33
  import dispatchPasteEvent from '@atlaskit/editor-test-helpers/dispatch-paste-event';
34
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
37
35
  import {
38
36
  br,
39
37
  code_block,
40
38
  doc,
41
- DocBuilder,
42
39
  expand,
43
40
  p,
44
41
  panel,
@@ -51,7 +48,7 @@ import defaultSchema from '@atlaskit/editor-test-helpers/schema';
51
48
 
52
49
  import tablePlugin from '../../plugins/table-plugin';
53
50
  import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
54
- import { PluginConfig, TablePluginState } from '../../plugins/table/types';
51
+ import type { PluginConfig, TablePluginState } from '../../plugins/table/types';
55
52
  import {
56
53
  removeTableFromFirstChild,
57
54
  removeTableFromLastChild,
@@ -125,7 +122,7 @@ describe('table plugin', () => {
125
122
  .add([tablePlugin, { tableOptions }]);
126
123
 
127
124
  const editor = (doc: DocBuilder) => {
128
- return createEditor<TablePluginState, PluginKey>({
125
+ return createEditor<TablePluginState, PluginKey, typeof preset>({
129
126
  doc,
130
127
  preset,
131
128
  pluginKey: tablePluginKey,
@@ -3,15 +3,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
3
3
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
5
5
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
6
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
7
8
  import {
8
9
  createProsemirrorEditorFactory,
9
- LightEditorPlugin,
10
10
  Preset,
11
11
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
12
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
12
13
  import {
13
14
  doc,
14
- DocBuilder,
15
15
  table,
16
16
  tdCursor,
17
17
  tdEmpty,
@@ -22,7 +22,7 @@ import tablePlugin from '../../../plugins/table-plugin';
22
22
  import { whenTableInFocus } from '../../../plugins/table/event-handlers';
23
23
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
24
24
  import { setDragging } from '../../../plugins/table/pm-plugins/table-resizing/commands';
25
- import { TablePluginState } from '../../../plugins/table/types';
25
+ import type { TablePluginState } from '../../../plugins/table/types';
26
26
 
27
27
  describe('event-handlers', () => {
28
28
  let editor: any;
@@ -39,7 +39,7 @@ describe('event-handlers', () => {
39
39
  .add(guidelinePlugin)
40
40
  .add([tablePlugin, { tableOptions: { allowColumnResizing: false } }]);
41
41
  editor = (doc: DocBuilder) =>
42
- createEditor<TablePluginState, PluginKey>({
42
+ createEditor<TablePluginState, PluginKey, typeof preset>({
43
43
  doc,
44
44
  preset,
45
45
  pluginKey,
@@ -72,7 +72,7 @@ describe('event-handlers', () => {
72
72
  .add(guidelinePlugin)
73
73
  .add([tablePlugin, { tableOptions: { allowColumnResizing: false } }]);
74
74
  editor = (doc: DocBuilder) =>
75
- createEditor<TablePluginState, PluginKey>({
75
+ createEditor<TablePluginState, PluginKey, typeof preset>({
76
76
  doc,
77
77
  preset,
78
78
  pluginKey,
@@ -3,15 +3,16 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
3
3
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
5
5
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
6
- import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
7
9
  import {
8
10
  createProsemirrorEditorFactory,
9
- LightEditorPlugin,
10
11
  Preset,
11
12
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
12
14
  import {
13
15
  doc,
14
- DocBuilder,
15
16
  table,
16
17
  tdCursor,
17
18
  tdEmpty,
@@ -22,7 +23,7 @@ import tablePlugin from '../../plugins/table-plugin';
22
23
  import { handleDocOrSelectionChanged } from '../../plugins/table/handlers';
23
24
  import { defaultTableSelection } from '../../plugins/table/pm-plugins/default-table-selection';
24
25
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
25
- import { TablePluginState } from '../../plugins/table/types';
26
+ import type { TablePluginState } from '../../plugins/table/types';
26
27
 
27
28
  describe('table action handlers', () => {
28
29
  let editor: any;
@@ -39,7 +40,7 @@ describe('table action handlers', () => {
39
40
  .add(tablePlugin);
40
41
 
41
42
  editor = (doc: DocBuilder) =>
42
- createEditor<TablePluginState, PluginKey>({
43
+ createEditor<TablePluginState, PluginKey, typeof preset>({
43
44
  doc,
44
45
  preset,
45
46
  pluginKey,
@@ -3,21 +3,21 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
3
3
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
5
5
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
6
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import {
9
9
  getCellsInColumn,
10
10
  getCellsInRow,
11
11
  getCellsInTable,
12
12
  } from '@atlaskit/editor-tables/utils';
13
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
14
  import {
14
15
  createProsemirrorEditorFactory,
15
- LightEditorPlugin,
16
16
  Preset,
17
17
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
18
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
18
19
  import {
19
20
  doc,
20
- DocBuilder,
21
21
  p,
22
22
  table,
23
23
  tdCursor,
@@ -35,7 +35,8 @@ import {
35
35
  } from '../../plugins/table/commands';
36
36
  import { getDecorations } from '../../plugins/table/pm-plugins/decorations/plugin';
37
37
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
38
- import { TableDecorations, TablePluginState } from '../../plugins/table/types';
38
+ import type { TablePluginState } from '../../plugins/table/types';
39
+ import { TableDecorations } from '../../plugins/table/types';
39
40
 
40
41
  describe('table hover selection plugin', () => {
41
42
  const createEditor = createProsemirrorEditorFactory();
@@ -48,7 +49,7 @@ describe('table hover selection plugin', () => {
48
49
  .add(tablePlugin);
49
50
 
50
51
  const editor = (doc: DocBuilder) =>
51
- createEditor<TablePluginState, PluginKey>({
52
+ createEditor<TablePluginState, PluginKey, typeof preset>({
52
53
  doc,
53
54
  preset,
54
55
  pluginKey,
@@ -1,20 +1,20 @@
1
- import { TableLayout } from '@atlaskit/adf-schema';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
2
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
4
4
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
5
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
6
6
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
7
7
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
8
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findTable } from '@atlaskit/editor-tables/utils';
10
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
10
11
  import {
11
12
  createProsemirrorEditorFactory,
12
- LightEditorPlugin,
13
13
  Preset,
14
14
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
15
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
15
16
  import {
16
17
  doc,
17
- DocBuilder,
18
18
  table,
19
19
  tdCursor,
20
20
  tdEmpty,
@@ -25,7 +25,7 @@ import tablePlugin from '../../plugins/table-plugin';
25
25
  import { toggleTableLayout } from '../../plugins/table/commands';
26
26
  import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
27
27
  import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
28
- import {
28
+ import type {
29
29
  PermittedLayoutsDescriptor,
30
30
  TablePluginState,
31
31
  } from '../../plugins/table/types';
@@ -49,7 +49,7 @@ describe('table toolbar', () => {
49
49
  .add([tablePlugin, { tableOptions }]);
50
50
 
51
51
  const editor = (doc: DocBuilder) => {
52
- return createEditor<TablePluginState, PluginKey>({
52
+ return createEditor<TablePluginState, PluginKey, typeof preset>({
53
53
  doc,
54
54
  preset,
55
55
  pluginKey: tablePluginKey,
@@ -3,18 +3,19 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
3
3
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
5
5
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
6
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
8
- import { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
8
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
10
  import { getCellsInColumn } from '@atlaskit/editor-tables/utils';
11
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
10
12
  import {
11
13
  createProsemirrorEditorFactory,
12
- LightEditorPlugin,
13
14
  Preset,
14
15
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
16
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
15
17
  import {
16
18
  doc,
17
- DocBuilder,
18
19
  p,
19
20
  table,
20
21
  td,
@@ -31,30 +32,29 @@ import {
31
32
  import { getDecorations } from '../../../../plugins/table/pm-plugins/decorations/plugin';
32
33
  import { buildColumnResizingDecorations } from '../../../../plugins/table/pm-plugins/decorations/utils';
33
34
  import { pluginKey } from '../../../../plugins/table/pm-plugins/plugin-key';
34
- import {
35
- TableDecorations,
36
- TablePluginState,
37
- } from '../../../../plugins/table/types';
35
+ import type { TablePluginState } from '../../../../plugins/table/types';
36
+ import { TableDecorations } from '../../../../plugins/table/types';
38
37
 
39
38
  describe('tables: column resizing decorations', () => {
40
39
  const createEditor = createProsemirrorEditorFactory();
41
40
  const getEditorFeatureFlags = () => ({});
41
+ const preset = new Preset<LightEditorPlugin>()
42
+ .add([featureFlagsPlugin, {}])
43
+ .add([analyticsPlugin, {}])
44
+ .add(contentInsertionPlugin)
45
+ .add(widthPlugin)
46
+ .add(guidelinePlugin)
47
+ .add([
48
+ tablePlugin,
49
+ {
50
+ tableOptions: { allowColumnResizing: true },
51
+ getEditorFeatureFlags,
52
+ },
53
+ ]);
42
54
  const editor = (doc: DocBuilder) =>
43
- createEditor<TablePluginState, PluginKey>({
55
+ createEditor<TablePluginState, PluginKey, typeof preset>({
44
56
  doc,
45
- preset: new Preset<LightEditorPlugin>()
46
- .add([featureFlagsPlugin, {}])
47
- .add([analyticsPlugin, {}])
48
- .add(contentInsertionPlugin)
49
- .add(widthPlugin)
50
- .add(guidelinePlugin)
51
- .add([
52
- tablePlugin,
53
- {
54
- tableOptions: { allowColumnResizing: true },
55
- getEditorFeatureFlags,
56
- },
57
- ]),
57
+ preset,
58
58
  pluginKey,
59
59
  });
60
60
 
@@ -5,15 +5,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
5
5
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
6
6
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
7
7
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
8
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
9
10
  import {
10
11
  createProsemirrorEditorFactory,
11
- LightEditorPlugin,
12
12
  Preset,
13
13
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
14
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
14
15
  import {
15
16
  doc,
16
- DocBuilder,
17
17
  p,
18
18
  table,
19
19
  td,
@@ -24,7 +24,7 @@ import {
24
24
  import tablePlugin from '../../plugins/table-plugin';
25
25
  import { sortByColumn } from '../../plugins/table/commands';
26
26
  import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
27
- import {
27
+ import type {
28
28
  PermittedLayoutsDescriptor,
29
29
  TablePluginState,
30
30
  } from '../../plugins/table/types';
@@ -58,7 +58,7 @@ describe('table plugin', () => {
58
58
  .add([tablePlugin, { tableOptions }]);
59
59
 
60
60
  const editor = (doc: DocBuilder) => {
61
- return createEditor<TablePluginState, PluginKey>({
61
+ return createEditor<TablePluginState, PluginKey, typeof preset>({
62
62
  doc,
63
63
  preset,
64
64
  pluginKey: tablePluginKey,
@@ -4,17 +4,17 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
- import { Rect } from '@atlaskit/editor-tables/table-map';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
9
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
10
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
10
11
  import {
11
12
  createProsemirrorEditorFactory,
12
- LightEditorPlugin,
13
13
  Preset,
14
14
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
15
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
15
16
  import {
16
17
  doc,
17
- DocBuilder,
18
18
  p,
19
19
  table,
20
20
  td,
@@ -26,7 +26,7 @@ import {
26
26
  import tablePlugin from '../../../plugins/table-plugin';
27
27
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
28
28
  import { deleteColumns } from '../../../plugins/table/transforms';
29
- import { TablePluginState } from '../../../plugins/table/types';
29
+ import type { TablePluginState } from '../../../plugins/table/types';
30
30
 
31
31
  const colsToRect = (cols: Array<number>, noOfRows: number): Rect => ({
32
32
  left: Math.min(...cols),
@@ -56,7 +56,7 @@ describe('table plugin -> transforms -> delete columns', () => {
56
56
  .add(tablePlugin);
57
57
 
58
58
  const editor = (doc: DocBuilder) =>
59
- createEditor<TablePluginState, PluginKey>({
59
+ createEditor<TablePluginState, PluginKey, typeof preset>({
60
60
  doc,
61
61
  preset,
62
62
  pluginKey,
@@ -4,17 +4,17 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
- import { Rect } from '@atlaskit/editor-tables/table-map';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
9
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
10
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
10
11
  import {
11
12
  createProsemirrorEditorFactory,
12
- LightEditorPlugin,
13
13
  Preset,
14
14
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
15
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
15
16
  import {
16
17
  doc,
17
- DocBuilder,
18
18
  p,
19
19
  table,
20
20
  td,
@@ -27,7 +27,7 @@ import {
27
27
  import tablePlugin from '../../../plugins/table-plugin';
28
28
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
29
29
  import { deleteRows } from '../../../plugins/table/transforms';
30
- import { TablePluginState } from '../../../plugins/table/types';
30
+ import type { TablePluginState } from '../../../plugins/table/types';
31
31
 
32
32
  const rowsToRect = (rows: Array<number>, noOfColumns: number): Rect => ({
33
33
  left: 0,
@@ -56,7 +56,7 @@ describe('table plugin -> transforms -> delete rows', () => {
56
56
  .add(tablePlugin);
57
57
 
58
58
  const editor = (doc: DocBuilder) =>
59
- createEditor<TablePluginState, PluginKey>({
59
+ createEditor<TablePluginState, PluginKey, typeof preset>({
60
60
  doc,
61
61
  preset,
62
62
  pluginKey,
@@ -4,15 +4,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
4
4
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
5
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
6
6
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
7
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
8
9
  import {
9
10
  createProsemirrorEditorFactory,
10
- LightEditorPlugin,
11
11
  Preset,
12
12
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
13
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
13
14
  import {
14
15
  doc,
15
- DocBuilder,
16
16
  p,
17
17
  table,
18
18
  td,
@@ -23,7 +23,7 @@ import {
23
23
  import tablePlugin from '../../../plugins/table-plugin';
24
24
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
25
25
  import { mergeCells } from '../../../plugins/table/transforms';
26
- import { TablePluginState } from '../../../plugins/table/types';
26
+ import type { TablePluginState } from '../../../plugins/table/types';
27
27
 
28
28
  const TABLE_LOCAL_ID = 'test-table-local-id';
29
29
 
@@ -46,7 +46,7 @@ describe('table plugin -> transforms -> merge cells', () => {
46
46
  .add(tablePlugin);
47
47
 
48
48
  const editor = (doc: DocBuilder) =>
49
- createEditor<TablePluginState, PluginKey>({
49
+ createEditor<TablePluginState, PluginKey, typeof preset>({
50
50
  doc,
51
51
  preset,
52
52
  pluginKey,
@@ -8,15 +8,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
8
8
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
9
9
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
10
10
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
11
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
12
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
12
13
  import {
13
14
  createProsemirrorEditorFactory,
14
- LightEditorPlugin,
15
15
  Preset,
16
16
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
17
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
17
18
  import {
18
19
  doc,
19
- DocBuilder,
20
20
  p,
21
21
  table,
22
22
  tdCursor,
@@ -28,7 +28,7 @@ import tablePlugin from '../../../plugins/table-plugin';
28
28
  import { hoverTable } from '../../../plugins/table/commands';
29
29
  import { getDecorations } from '../../../plugins/table/pm-plugins/decorations/plugin';
30
30
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
31
- import { TablePluginState } from '../../../plugins/table/types';
31
+ import type { TablePluginState } from '../../../plugins/table/types';
32
32
  import TableFloatingControls from '../../../plugins/table/ui/TableFloatingControls';
33
33
 
34
34
  describe('TableFloatingControls', () => {
@@ -43,7 +43,7 @@ describe('TableFloatingControls', () => {
43
43
  .add(tablePlugin);
44
44
 
45
45
  const editor = (doc: DocBuilder) =>
46
- createEditor<TablePluginState, PluginKey>({
46
+ createEditor<TablePluginState, PluginKey, typeof preset>({
47
47
  doc,
48
48
  preset,
49
49
  pluginKey: pluginKey,
@@ -3,15 +3,15 @@ import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertio
3
3
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
5
5
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
6
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
7
8
  import {
8
9
  createProsemirrorEditorFactory,
9
- LightEditorPlugin,
10
10
  Preset,
11
11
  } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
12
+ import type { DocBuilder } from '@atlaskit/editor-test-helpers/doc-builder';
12
13
  import {
13
14
  doc,
14
- DocBuilder,
15
15
  p,
16
16
  table,
17
17
  td,
@@ -22,7 +22,7 @@ import {
22
22
 
23
23
  import tablePlugin from '../../plugins/table';
24
24
  import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
25
- import { TablePluginState } from '../../plugins/table/types';
25
+ import type { TablePluginState } from '../../plugins/table/types';
26
26
  import {
27
27
  getColumnClassNames,
28
28
  getColumnDeleteButtonParams,
@@ -46,7 +46,7 @@ describe('table plugin: utils', () => {
46
46
  .add(tablePlugin);
47
47
 
48
48
  const editor = (doc: DocBuilder) =>
49
- createEditor<TablePluginState, PluginKey>({
49
+ createEditor<TablePluginState, PluginKey, typeof preset>({
50
50
  doc,
51
51
  preset,
52
52
  pluginKey,
@@ -184,8 +184,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
184
184
  }
185
185
 
186
186
  componentDidUpdate() {
187
- const { view, getNode, isMediaFullscreen, allowColumnResizing } =
188
- this.props;
187
+ const {
188
+ view,
189
+ getNode,
190
+ isMediaFullscreen,
191
+ allowColumnResizing,
192
+ isResizing,
193
+ options,
194
+ } = this.props;
189
195
  const { isInDanger } = getPluginState(view.state);
190
196
  const table = findTable(view.state.selection);
191
197
 
@@ -227,7 +233,17 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
227
233
  tablesHaveDifferentNoOfColumns(currentTable, previousTable)
228
234
  ) {
229
235
  const { view } = this.props;
230
- recreateResizeColsByNode(this.table, currentTable);
236
+
237
+ const shouldRecreateResizeCols =
238
+ !options?.isTableResizingEnabled ||
239
+ !isResizing ||
240
+ (tablesHaveDifferentNoOfColumns(currentTable, previousTable) &&
241
+ isResizing);
242
+
243
+ if (shouldRecreateResizeCols) {
244
+ recreateResizeColsByNode(this.table, currentTable);
245
+ }
246
+
231
247
  updateControls()(view.state);
232
248
  }
233
249
 
@@ -345,6 +361,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
345
361
  isNested={isNested}
346
362
  pluginInjectionApi={pluginInjectionApi}
347
363
  isTableResizingEnabled={options?.isTableResizingEnabled}
364
+ isResizing={isResizing}
348
365
  >
349
366
  <div
350
367
  className={ClassName.TABLE_STICKY_SENTINEL_TOP}
@@ -10,7 +10,10 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
10
10
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
11
11
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
12
12
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
- import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
13
+ import {
14
+ akEditorDefaultLayoutWidth,
15
+ akEditorMobileBreakoutPoint,
16
+ } from '@atlaskit/editor-shared-styles';
14
17
 
15
18
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
16
19
  import type { PluginInjectionAPI } from '../types';
@@ -66,6 +69,7 @@ type ResizableTableContainerProps = {
66
69
  editorView: EditorView;
67
70
  getPos: () => number | undefined;
68
71
  tableRef: HTMLTableElement;
72
+ isResizing?: boolean;
69
73
  pluginInjectionApi?: PluginInjectionAPI;
70
74
  };
71
75
 
@@ -78,10 +82,12 @@ export const ResizableTableContainer = ({
78
82
  editorView,
79
83
  getPos,
80
84
  tableRef,
85
+ isResizing,
81
86
  pluginInjectionApi,
82
87
  }: PropsWithChildren<ResizableTableContainerProps>) => {
83
88
  const containerRef = useRef<HTMLDivElement | null>(null);
84
89
  const marginLeftRef = useRef<number | undefined>(0);
90
+ const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
85
91
 
86
92
  const updateWidth = useCallback(
87
93
  (width: number) => {
@@ -134,12 +140,19 @@ export const ResizableTableContainer = ({
134
140
  // 76 is currently an accepted padding value considering the spacing for resizer handle
135
141
  const responsiveContainerWidth = containerWidth - 76;
136
142
  const width = Math.min(tableWidth, responsiveContainerWidth);
137
- marginLeftRef.current = getMarginLeft(lineLength, width);
143
+
144
+ if (!isResizing) {
145
+ tableWidthRef.current = width;
146
+ marginLeftRef.current = getMarginLeft(lineLength, width);
147
+ }
138
148
  const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
139
149
 
140
150
  return (
141
151
  <div
142
- style={{ marginLeft: marginLeftRef.current, width }}
152
+ style={{
153
+ marginLeft: marginLeftRef.current,
154
+ width: tableWidthRef.current,
155
+ }}
143
156
  className={ClassName.TABLE_RESIZER_CONTAINER}
144
157
  ref={containerRef}
145
158
  >
@@ -173,6 +186,7 @@ type TableContainerProps = {
173
186
  getPos: () => number | undefined;
174
187
  tableRef: HTMLTableElement;
175
188
  isNested: boolean;
189
+ isResizing?: boolean;
176
190
  pluginInjectionApi?: PluginInjectionAPI;
177
191
  };
178
192
 
@@ -187,6 +201,7 @@ export const TableContainer = ({
187
201
  getPos,
188
202
  tableRef,
189
203
  isNested,
204
+ isResizing,
190
205
  pluginInjectionApi,
191
206
  }: PropsWithChildren<TableContainerProps>) => {
192
207
  if (isTableResizingEnabled && !isNested) {
@@ -199,6 +214,7 @@ export const TableContainer = ({
199
214
  editorView={editorView}
200
215
  getPos={getPos}
201
216
  tableRef={tableRef}
217
+ isResizing={isResizing}
202
218
  pluginInjectionApi={pluginInjectionApi}
203
219
  >
204
220
  {children}
@@ -12,13 +12,16 @@ import type {
12
12
  getPosHandlerNode,
13
13
  } from '@atlaskit/editor-common/types';
14
14
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
15
- import {
15
+ import type {
16
16
  DOMOutputSpec,
17
- DOMSerializer,
18
17
  Node as PmNode,
19
18
  } from '@atlaskit/editor-prosemirror/model';
20
- import { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state';
21
- import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
19
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
20
+ import type {
21
+ EditorState,
22
+ PluginKey,
23
+ } from '@atlaskit/editor-prosemirror/state';
24
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
22
25
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
23
26
  import { TableMap } from '@atlaskit/editor-tables/table-map';
24
27
 
@@ -28,11 +31,11 @@ import { pluginKey } from '../pm-plugins/plugin-key';
28
31
  import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing';
29
32
  import { generateColgroup } from '../pm-plugins/table-resizing/utils';
30
33
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
31
- import { PluginInjectionAPI } from '../types';
34
+ import type { PluginInjectionAPI } from '../types';
32
35
  import { isTableNested } from '../utils';
33
36
 
34
37
  import TableComponent from './TableComponent';
35
- import { Props, TableOptions } from './types';
38
+ import type { Props, TableOptions } from './types';
36
39
 
37
40
  type ForwardRef = (node: HTMLElement | null) => void;
38
41
 
@@ -160,7 +163,11 @@ export default class TableView extends ReactNodeView<Props> {
160
163
  this.getPos(),
161
164
  );
162
165
 
163
- if (tableInlineWidth) {
166
+ const isTableResizing = tableWidthPluginKey.getState(
167
+ this.view.state,
168
+ )?.resizing;
169
+
170
+ if (!isTableResizing && tableInlineWidth) {
164
171
  handleInlineTableWidth(this.table, tableInlineWidth);
165
172
  }
166
173
  }