@atlaskit/editor-plugin-table 2.10.0 → 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 (37) hide show
  1. package/CHANGELOG.md +14 -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/TableResizer.js +5 -1
  5. package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
  6. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +9 -3
  7. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +10 -3
  8. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +6 -1
  9. package/dist/es2019/plugins/table/nodeviews/table.js +3 -1
  10. package/dist/esm/plugins/table/nodeviews/TableComponent.js +9 -3
  11. package/dist/esm/plugins/table/nodeviews/TableContainer.js +10 -3
  12. package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -1
  13. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  14. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +4 -2
  15. package/dist/types/plugins/table/nodeviews/table.d.ts +4 -4
  16. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +4 -2
  17. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +4 -4
  18. package/package.json +3 -3
  19. package/src/__tests__/unit/commands/go-to-next-cell.ts +5 -5
  20. package/src/__tests__/unit/commands/insert.ts +5 -5
  21. package/src/__tests__/unit/commands/misc.ts +6 -8
  22. package/src/__tests__/unit/copy-paste.ts +10 -13
  23. package/src/__tests__/unit/event-handlers/index.ts +6 -6
  24. package/src/__tests__/unit/handlers.ts +6 -5
  25. package/src/__tests__/unit/hover-selection.ts +7 -6
  26. package/src/__tests__/unit/layout.ts +6 -6
  27. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +23 -23
  28. package/src/__tests__/unit/sort-column.ts +5 -5
  29. package/src/__tests__/unit/transforms/delete-columns.ts +6 -6
  30. package/src/__tests__/unit/transforms/delete-rows.ts +6 -6
  31. package/src/__tests__/unit/transforms/merging.ts +5 -5
  32. package/src/__tests__/unit/ui/TableFloatingControls.tsx +5 -5
  33. package/src/__tests__/unit/utils.ts +5 -5
  34. package/src/plugins/table/nodeviews/TableComponent.tsx +20 -3
  35. package/src/plugins/table/nodeviews/TableContainer.tsx +19 -3
  36. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -0
  37. package/src/plugins/table/nodeviews/table.tsx +14 -7
@@ -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}