@atlaskit/editor-plugin-table 1.5.2 → 1.5.4

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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/index.js +5 -12
  3. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -16
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -9
  5. package/dist/cjs/version.json +1 -1
  6. package/dist/es2019/plugins/table/index.js +5 -16
  7. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -16
  8. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +3 -15
  9. package/dist/es2019/version.json +1 -1
  10. package/dist/esm/plugins/table/index.js +5 -12
  11. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -16
  12. package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -9
  13. package/dist/esm/version.json +1 -1
  14. package/dist/types/plugins/table/index.d.ts +6 -1
  15. package/dist/types/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +0 -1
  16. package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
  17. package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +0 -1
  18. package/package.json +3 -3
  19. package/report.api.md +6 -1
  20. package/src/__tests__/unit/analytics.ts +2 -1
  21. package/src/__tests__/unit/collab.ts +2 -2
  22. package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
  23. package/src/__tests__/unit/commands/insert.ts +2 -2
  24. package/src/__tests__/unit/commands/misc.ts +2 -0
  25. package/src/__tests__/unit/commands/sort.ts +5 -0
  26. package/src/__tests__/unit/copy-paste.ts +2 -0
  27. package/src/__tests__/unit/event-handlers/index.ts +3 -0
  28. package/src/__tests__/unit/event-handlers.ts +1 -0
  29. package/src/__tests__/unit/fix-tables.ts +2 -0
  30. package/src/__tests__/unit/handlers.ts +2 -0
  31. package/src/__tests__/unit/hover-selection.ts +2 -0
  32. package/src/__tests__/unit/nodeviews/cell.ts +2 -0
  33. package/src/__tests__/unit/nodeviews/table.ts +2 -0
  34. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
  35. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +2 -0
  36. package/src/__tests__/unit/pm-plugins/main.ts +2 -0
  37. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
  38. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
  39. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +1 -1
  40. package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +2 -0
  41. package/src/__tests__/unit/sort-column.ts +2 -0
  42. package/src/__tests__/unit/toolbar.ts +2 -0
  43. package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
  44. package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
  45. package/src/__tests__/unit/transforms/merging.ts +2 -0
  46. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  47. package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
  48. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
  49. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
  50. package/src/__tests__/unit/ui/RowControls.tsx +2 -0
  51. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
  52. package/src/__tests__/unit/undo-redo.ts +2 -2
  53. package/src/__tests__/unit/utils/collapse.ts +2 -0
  54. package/src/__tests__/unit/utils/nodes.ts +2 -0
  55. package/src/__tests__/unit/utils/row-controls.ts +2 -0
  56. package/src/__tests__/unit/utils.ts +2 -0
  57. package/src/plugins/table/index.tsx +10 -15
  58. package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +3 -23
  59. package/src/plugins/table/nodeviews/TableComponent.tsx +4 -10
  60. package/tmp/api-report-tmp.d.ts +6 -1
@@ -34,6 +34,7 @@ import undoRedoPlugin from '@atlaskit/editor-core/src/plugins/undo-redo';
34
34
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
35
35
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
36
36
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
37
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
37
38
 
38
39
  jest.mock('@atlaskit/editor-common/utils', () => ({
39
40
  ...jest.requireActual<Object>('@atlaskit/editor-common/utils'),
@@ -68,6 +69,7 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
68
69
  .add([featureFlagsPlugin, {}])
69
70
  .add([analyticsPlugin, {}])
70
71
  .add(contentInsertionPlugin)
72
+ .add(widthPlugin)
71
73
  .add([tablePlugin, { tableOptions: { advanced: true, ...props } }])
72
74
  .add(undoRedoPlugin),
73
75
  pluginKey,
@@ -24,6 +24,7 @@ import { hoverRows } from '../../../plugins/table/commands';
24
24
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
25
25
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
27
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
27
28
 
28
29
  describe('table -> nodeviews -> table.tsx', () => {
29
30
  const createEditor = createProsemirrorEditorFactory();
@@ -41,6 +42,7 @@ describe('table -> nodeviews -> table.tsx', () => {
41
42
  .add([featureFlagsPlugin, {}])
42
43
  .add([analyticsPlugin, {}])
43
44
  .add(contentInsertionPlugin)
45
+ .add(widthPlugin)
44
46
  .add([
45
47
  tablePlugin,
46
48
  {
@@ -35,6 +35,7 @@ import {
35
35
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
36
36
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
37
37
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
38
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
38
39
 
39
40
  describe('tables: column resizing decorations', () => {
40
41
  const createEditor = createProsemirrorEditorFactory();
@@ -46,6 +47,7 @@ describe('tables: column resizing decorations', () => {
46
47
  .add([featureFlagsPlugin, {}])
47
48
  .add([analyticsPlugin, {}])
48
49
  .add(contentInsertionPlugin)
50
+ .add(widthPlugin)
49
51
  .add([
50
52
  tablePlugin,
51
53
  {
@@ -27,6 +27,7 @@ import tablePlugin from '../../../../plugins/table';
27
27
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
28
28
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
29
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
30
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
30
31
 
31
32
  describe('decorations plugin', () => {
32
33
  const createEditor = createProsemirrorEditorFactory();
@@ -38,6 +39,7 @@ describe('decorations plugin', () => {
38
39
  .add([featureFlagsPlugin, {}])
39
40
  .add([analyticsPlugin, {}])
40
41
  .add(contentInsertionPlugin)
42
+ .add(widthPlugin)
41
43
  .add(tablePlugin),
42
44
  pluginKey,
43
45
  });
@@ -31,6 +31,7 @@ import {
31
31
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
32
32
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
33
33
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
34
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
34
35
 
35
36
  describe('tables: main plugin', () => {
36
37
  const createEditor = createProsemirrorEditorFactory();
@@ -41,6 +42,7 @@ describe('tables: main plugin', () => {
41
42
  .add([featureFlagsPlugin, {}])
42
43
  .add([analyticsPlugin, {}])
43
44
  .add(contentInsertionPlugin)
45
+ .add(widthPlugin)
44
46
  .add(tablePlugin)
45
47
  .add(textFormattingPlugin),
46
48
  pluginKey,
@@ -16,6 +16,7 @@ import tablePlugin from '../../../plugins/table-plugin';
16
16
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
17
17
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
18
18
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
19
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
19
20
 
20
21
  describe('table/safari-delete-composition-text-issue-workaround', () => {
21
22
  let editor: any;
@@ -28,6 +29,7 @@ describe('table/safari-delete-composition-text-issue-workaround', () => {
28
29
  .add([featureFlagsPlugin, {}])
29
30
  .add([analyticsPlugin, {}])
30
31
  .add(contentInsertionPlugin)
32
+ .add(widthPlugin)
31
33
  .add([tablePlugin, { tableOptions: { allowColumnResizing: true } }]),
32
34
  pluginKey,
33
35
  });
@@ -46,6 +46,7 @@ import {
46
46
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
47
47
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
48
48
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
49
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
49
50
 
50
51
  describe('TableRowNodeView', () => {
51
52
  let tableRowNodeView: TableRowNodeView;
@@ -60,6 +61,7 @@ describe('TableRowNodeView', () => {
60
61
  .add([featureFlagsPlugin, {}])
61
62
  .add([analyticsPlugin, {}])
62
63
  .add(contentInsertionPlugin)
64
+ .add(widthPlugin)
63
65
  .add(tablePlugin),
64
66
  pluginKey,
65
67
  attachTo: document.body,
@@ -91,6 +93,7 @@ describe('TableRowNodeView', () => {
91
93
  .add([featureFlagsPlugin, {}])
92
94
  .add([analyticsPlugin, {}])
93
95
  .add(contentInsertionPlugin)
96
+ .add(widthPlugin)
94
97
  .add(tablePlugin),
95
98
  pluginKey,
96
99
  });
@@ -51,6 +51,7 @@ describe('table-resizing/event-handlers', () => {
51
51
  .add([analyticsPlugin, {}])
52
52
  .add(contentInsertionPlugin)
53
53
  .add(decorationsPlugin)
54
+ .add(widthPlugin)
54
55
  .add([
55
56
  tablePlugin,
56
57
  {
@@ -58,7 +59,6 @@ describe('table-resizing/event-handlers', () => {
58
59
  editorAnalyticsAPI: editorAnalyticsAPIFake,
59
60
  },
60
61
  ])
61
- .add(widthPlugin)
62
62
  .add(panelPlugin),
63
63
  pluginKey,
64
64
  });
@@ -32,6 +32,7 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
32
32
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
33
33
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
34
34
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
35
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
35
36
 
36
37
  const TABLE_LOCAL_ID = 'test-table-local-id';
37
38
  describe('table selection keymap', () => {
@@ -51,6 +52,7 @@ describe('table selection keymap', () => {
51
52
  .add(contentInsertionPlugin)
52
53
  .add(decorationsPlugin)
53
54
  .add(selectionPlugin)
55
+ .add(widthPlugin)
54
56
  .add([tablePlugin, { tableOptions: {}, editorSelectionAPI }])
55
57
  .add(panelPlugin)
56
58
  .add([codeBlockPlugin, { appearance: 'full-page' }]);
@@ -29,6 +29,7 @@ import { PluginKey } from 'prosemirror-state';
29
29
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
30
30
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
31
31
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
32
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
32
33
 
33
34
  const TABLE_LOCAL_ID = 'test-table-local-id';
34
35
 
@@ -54,6 +55,7 @@ describe('table plugin', () => {
54
55
  .add([featureFlagsPlugin, {}])
55
56
  .add([analyticsPlugin, {}])
56
57
  .add(contentInsertionPlugin)
58
+ .add(widthPlugin)
57
59
  .add([tablePlugin, { tableOptions }])
58
60
  .add(textFormattingPlugin)
59
61
  .add(blockTypePlugin);
@@ -34,6 +34,7 @@ import { getNewResizeStateFromSelectedColumns } from '../../plugins/table/pm-plu
34
34
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
35
35
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
36
36
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
37
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
37
38
 
38
39
  jest.mock('@atlaskit/editor-tables/utils');
39
40
  jest.mock('../../plugins/table/transforms');
@@ -158,6 +159,7 @@ describe('getToolbarCellOptionsConfig', () => {
158
159
  .add([featureFlagsPlugin, {}])
159
160
  .add([analyticsPlugin, {}])
160
161
  .add(contentInsertionPlugin)
162
+ .add(widthPlugin)
161
163
  .add([
162
164
  tablePlugin,
163
165
  {
@@ -24,6 +24,7 @@ import tablePlugin from '../../../plugins/table-plugin';
24
24
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
25
25
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
27
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
27
28
 
28
29
  const colsToRect = (cols: Array<number>, noOfRows: number): Rect => ({
29
30
  left: Math.min(...cols),
@@ -48,6 +49,7 @@ describe('table plugin -> transforms -> delete columns', () => {
48
49
  .add([featureFlagsPlugin, {}])
49
50
  .add([analyticsPlugin, {}])
50
51
  .add(contentInsertionPlugin)
52
+ .add(widthPlugin)
51
53
  .add(tablePlugin);
52
54
 
53
55
  const editor = (doc: DocBuilder) =>
@@ -25,6 +25,7 @@ import tablePlugin from '../../../plugins/table-plugin';
25
25
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
26
26
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
27
27
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
28
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
28
29
 
29
30
  const rowsToRect = (rows: Array<number>, noOfColumns: number): Rect => ({
30
31
  left: 0,
@@ -48,6 +49,7 @@ describe('table plugin -> transforms -> delete rows', () => {
48
49
  .add([featureFlagsPlugin, {}])
49
50
  .add([analyticsPlugin, {}])
50
51
  .add(contentInsertionPlugin)
52
+ .add(widthPlugin)
51
53
  .add(tablePlugin);
52
54
 
53
55
  const editor = (doc: DocBuilder) =>
@@ -21,6 +21,7 @@ import { PluginKey } from 'prosemirror-state';
21
21
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
22
22
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
23
23
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
24
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
24
25
 
25
26
  const TABLE_LOCAL_ID = 'test-table-local-id';
26
27
 
@@ -38,6 +39,7 @@ describe('table plugin -> transforms -> merge cells', () => {
38
39
  .add([featureFlagsPlugin, {}])
39
40
  .add([analyticsPlugin, {}])
40
41
  .add(contentInsertionPlugin)
42
+ .add(widthPlugin)
41
43
  .add(tablePlugin);
42
44
 
43
45
  const editor = (doc: DocBuilder) =>
@@ -20,6 +20,7 @@ import tablePlugin from '../../../plugins/table-plugin';
20
20
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
21
21
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
22
22
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
23
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
23
24
 
24
25
  import { ContextualMenu } from '../../../plugins/table/ui/FloatingContextualMenu/ContextualMenu';
25
26
 
@@ -36,6 +37,7 @@ describe('ContextualMenu', () => {
36
37
  .add([featureFlagsPlugin, {}])
37
38
  .add([analyticsPlugin, {}])
38
39
  .add(contentInsertionPlugin)
40
+ .add(widthPlugin)
39
41
  .add([tablePlugin, { tableOptions: { advanced: true } }]),
40
42
  }));
41
43
  });
@@ -22,6 +22,7 @@ import tablePlugin from '../../../plugins/table-plugin';
22
22
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
23
23
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
24
24
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
25
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
25
26
 
26
27
  describe('CornerControls', () => {
27
28
  const createEditor = createProsemirrorEditorFactory();
@@ -33,6 +34,7 @@ describe('CornerControls', () => {
33
34
  .add([featureFlagsPlugin, {}])
34
35
  .add([analyticsPlugin, {}])
35
36
  .add(contentInsertionPlugin)
37
+ .add(widthPlugin)
36
38
  .add(tablePlugin),
37
39
  pluginKey,
38
40
  });
@@ -26,6 +26,7 @@ import tablePlugin from '../../../plugins/table-plugin';
26
26
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
27
27
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
28
28
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
29
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
29
30
 
30
31
  const createEditor = createProsemirrorEditorFactory();
31
32
  let createAnalyticsEvent = jest.fn(() => ({ fire() {} } as UIAnalyticsEvent));
@@ -36,6 +37,7 @@ const editor = (doc: DocBuilder) =>
36
37
  .add([featureFlagsPlugin, {}])
37
38
  .add([analyticsPlugin, {}])
38
39
  .add(contentInsertionPlugin)
40
+ .add(widthPlugin)
39
41
  .add(tablePlugin),
40
42
  });
41
43
 
@@ -23,6 +23,7 @@ import tablePlugin from '../../../plugins/table-plugin';
23
23
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
24
24
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
25
25
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
26
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
26
27
 
27
28
  describe('FloatingContextualMenu', () => {
28
29
  const createEditor = createProsemirrorEditorFactory();
@@ -35,6 +36,7 @@ describe('FloatingContextualMenu', () => {
35
36
  .add([featureFlagsPlugin, {}])
36
37
  .add([analyticsPlugin, {}])
37
38
  .add(contentInsertionPlugin)
39
+ .add(widthPlugin)
38
40
  .add(tablePlugin),
39
41
  }));
40
42
  });
@@ -28,6 +28,7 @@ import tablePlugin from '../../../plugins/table-plugin';
28
28
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
29
29
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
30
30
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
31
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
31
32
 
32
33
  describe('RowControls', () => {
33
34
  const createEditor = createProsemirrorEditorFactory();
@@ -59,6 +60,7 @@ describe('RowControls', () => {
59
60
  .add([featureFlagsPlugin, {}])
60
61
  .add([analyticsPlugin, {}])
61
62
  .add(contentInsertionPlugin)
63
+ .add(widthPlugin)
62
64
  .add(tablePlugin),
63
65
  pluginKey,
64
66
  });
@@ -27,6 +27,7 @@ import { PluginKey } from 'prosemirror-state';
27
27
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
28
28
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
29
29
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
30
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
30
31
 
31
32
  describe('TableFloatingControls', () => {
32
33
  const createEditor = createProsemirrorEditorFactory();
@@ -35,6 +36,7 @@ describe('TableFloatingControls', () => {
35
36
  .add([featureFlagsPlugin, {}])
36
37
  .add([analyticsPlugin, {}])
37
38
  .add(contentInsertionPlugin)
39
+ .add(widthPlugin)
38
40
  .add(tablePlugin);
39
41
 
40
42
  const editor = (doc: DocBuilder) =>
@@ -65,8 +65,8 @@ describe('undo/redo with tables', () => {
65
65
  .add([featureFlagsPlugin, {}])
66
66
  .add([analyticsPlugin, {}])
67
67
  .add(contentInsertionPlugin)
68
- .add([tablePlugin, { tableOptions }])
69
- .add(widthPlugin),
68
+ .add(widthPlugin)
69
+ .add([tablePlugin, { tableOptions }]),
70
70
  pluginKey: tablePluginKey,
71
71
  });
72
72
  };
@@ -13,6 +13,7 @@ import {
13
13
 
14
14
  import tablePlugin from '../../../plugins/table';
15
15
  import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
16
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
16
17
 
17
18
  import {
18
19
  isTableCollapsible,
@@ -31,6 +32,7 @@ describe('collapse', () => {
31
32
  .add([featureFlagsPlugin, {}])
32
33
  .add([analyticsPlugin, {}])
33
34
  .add(contentInsertionPlugin)
35
+ .add(widthPlugin)
34
36
  .add(tablePlugin);
35
37
 
36
38
  const finalPreset = expandInPlugins
@@ -21,6 +21,7 @@ import tablePlugin from '../../../plugins/table-plugin';
21
21
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
22
22
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
23
23
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
24
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
24
25
 
25
26
  describe('table merging logic', () => {
26
27
  const createEditor = createProsemirrorEditorFactory();
@@ -32,6 +33,7 @@ describe('table merging logic', () => {
32
33
  .add([featureFlagsPlugin, {}])
33
34
  .add([analyticsPlugin, {}])
34
35
  .add(contentInsertionPlugin)
36
+ .add(widthPlugin)
35
37
  .add(tablePlugin),
36
38
  pluginKey,
37
39
  });
@@ -22,6 +22,7 @@ import tablePlugin from '../../../plugins/table-plugin';
22
22
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
23
23
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
24
24
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
25
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
25
26
 
26
27
  const TABLE_LOCAL_ID = 'test-table-local-id';
27
28
 
@@ -42,6 +43,7 @@ describe('table plugin: utils/row-controls.js', () => {
42
43
  .add([featureFlagsPlugin, {}])
43
44
  .add([analyticsPlugin, {}])
44
45
  .add(contentInsertionPlugin)
46
+ .add(widthPlugin)
45
47
  .add(tablePlugin),
46
48
  pluginKey,
47
49
  });
@@ -31,6 +31,7 @@ import { PluginKey } from 'prosemirror-state';
31
31
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
32
32
  import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
33
33
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
34
+ import { widthPlugin } from '@atlaskit/editor-plugin-width';
34
35
 
35
36
  describe('table plugin: utils', () => {
36
37
  const createEditor = createProsemirrorEditorFactory();
@@ -38,6 +39,7 @@ describe('table plugin: utils', () => {
38
39
  .add([featureFlagsPlugin, {}])
39
40
  .add([analyticsPlugin, {}])
40
41
  .add(contentInsertionPlugin)
42
+ .add(widthPlugin)
41
43
  .add(tablePlugin);
42
44
 
43
45
  const editor = (doc: DocBuilder) =>
@@ -70,6 +70,7 @@ import { EditorState, Transaction } from 'prosemirror-state';
70
70
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
71
71
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
72
72
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
73
+ import type { widthPlugin } from '@atlaskit/editor-plugin-width';
73
74
 
74
75
  interface TablePluginOptions {
75
76
  tableOptions: PluginConfig;
@@ -94,25 +95,19 @@ const tablesPlugin: NextEditorPlugin<
94
95
  actions: {
95
96
  insertTable: InsertTableAction;
96
97
  };
97
- dependencies: [typeof analyticsPlugin, typeof contentInsertionPlugin];
98
+ dependencies: [
99
+ typeof analyticsPlugin,
100
+ typeof contentInsertionPlugin,
101
+ typeof widthPlugin,
102
+ ];
98
103
  }
99
104
  > = (options?: TablePluginOptions, api?) => {
100
105
  const editorViewRef: Record<'current', EditorView | null> = { current: null };
101
106
  const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
102
- if (!editorViewRef.current) {
103
- return {
104
- width: document?.body?.offsetWidth || 500,
105
- };
106
- }
107
-
108
- const {
109
- current: { state },
110
- } = editorViewRef;
111
-
112
- // TODO: ED-15663
113
- // Please, do not copy or use this kind of code below
114
- // @ts-ignore
115
- return (state as any)['widthPlugin$'];
107
+ const defaultState = {
108
+ width: document?.body?.offsetWidth ?? 500,
109
+ };
110
+ return api?.dependencies.width.sharedState.currentState() ?? defaultState;
116
111
  };
117
112
 
118
113
  return {
@@ -39,21 +39,19 @@ export class OverflowShadowsObserver {
39
39
  const intersectonOnbserverCallback = (
40
40
  entry: IntersectionObserverEntry,
41
41
  ) => {
42
- if (!entry.rootBounds?.height && !entry.rootBounds?.width) {
43
- return;
44
- }
45
42
  if (
46
43
  entry.target !== this.leftShadowSentinel &&
47
44
  entry.target !== this.rightShadowSentinel
48
45
  ) {
49
46
  return;
50
47
  }
48
+
51
49
  this.updateStickyShadowsHeightIfChanged();
52
- this.checkIntersectionEvent(
53
- entry,
50
+ this.updateShadowState(
54
51
  this.leftShadowSentinel === entry.target
55
52
  ? ShadowEvent.SHOW_BEFORE_SHADOW
56
53
  : ShadowEvent.SHOW_AFTER_SHADOW,
54
+ entry.intersectionRatio !== 1,
57
55
  );
58
56
  };
59
57
 
@@ -71,24 +69,6 @@ export class OverflowShadowsObserver {
71
69
  }
72
70
  };
73
71
 
74
- private checkIntersectionEvent = (
75
- entry: IntersectionObserverEntry,
76
- shadowKey: ShadowEvent,
77
- ) => {
78
- if (
79
- // If it's in full view, don't show shadow.
80
- entry.isIntersecting &&
81
- entry.intersectionRatio === 1
82
- ) {
83
- this.updateShadowState(shadowKey, false);
84
- } else if (
85
- // If it's in partial view, show a shadow
86
- entry.intersectionRatio < 1
87
- ) {
88
- this.updateShadowState(shadowKey, true);
89
- }
90
- };
91
-
92
72
  private updateStickyShadowsHeightIfChanged() {
93
73
  if (!this.isSticky) {
94
74
  return;
@@ -280,11 +280,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
280
280
  if (this.state[shadowKey] === value) {
281
281
  return;
282
282
  }
283
- // need this check to satisfy types for the setState argument
284
- if (shadowKey === ShadowEvent.SHOW_BEFORE_SHADOW) {
285
- return this.setState({ [shadowKey]: value });
286
- }
287
- this.setState({ [shadowKey]: value });
283
+ this.setState({ [shadowKey]: value } as Pick<TableState, typeof shadowKey>);
288
284
  };
289
285
 
290
286
  private createShadowSentinels = (table: HTMLTableElement | null) => {
@@ -537,11 +533,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
537
533
  this.updateShadows();
538
534
  }
539
535
 
540
- if (this.wrapper.scrollLeft === 0) {
541
- this.setState({ [ShadowEvent.SHOW_BEFORE_SHADOW]: false });
542
- } else {
543
- this.setState({ [ShadowEvent.SHOW_BEFORE_SHADOW]: true });
544
- }
536
+ this.setState({
537
+ [ShadowEvent.SHOW_BEFORE_SHADOW]: this.wrapper.scrollLeft !== 0,
538
+ });
545
539
  };
546
540
 
547
541
  private handleTableResizing = () => {
@@ -13,6 +13,7 @@ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
13
13
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
14
14
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
15
15
  import { TableLayout } from '@atlaskit/adf-schema';
16
+ import type { widthPlugin } from '@atlaskit/editor-plugin-width';
16
17
 
17
18
  // @public (undocumented)
18
19
  type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
@@ -94,7 +95,11 @@ export const tablesPlugin: NextEditorPlugin<'table', {
94
95
  actions: {
95
96
  insertTable: InsertTableAction;
96
97
  };
97
- dependencies: [typeof analyticsPlugin, typeof contentInsertionPlugin];
98
+ dependencies: [
99
+ typeof analyticsPlugin,
100
+ typeof contentInsertionPlugin,
101
+ typeof widthPlugin
102
+ ];
98
103
  }>;
99
104
 
100
105
  // (No @packageDocumentation comment for this package)