@atlaskit/editor-plugin-table 2.8.5 → 2.9.0

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 (85) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +6 -6
  4. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +1 -1
  5. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +3 -1
  6. package/dist/cjs/plugins/table/pm-plugins/keymap.js +10 -13
  7. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  8. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +13 -2
  9. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +21 -8
  11. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -6
  12. package/dist/cjs/plugins/table/ui/common-styles.js +12 -4
  13. package/dist/cjs/plugins/table/ui/consts.js +3 -1
  14. package/dist/cjs/plugins/table/ui/ui-styles.js +16 -7
  15. package/dist/cjs/version.json +1 -1
  16. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +6 -6
  18. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +1 -1
  19. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -1
  20. package/dist/es2019/plugins/table/pm-plugins/keymap.js +11 -11
  21. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  22. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +9 -1
  23. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  24. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +18 -7
  25. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -3
  26. package/dist/es2019/plugins/table/ui/common-styles.js +27 -9
  27. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  28. package/dist/es2019/plugins/table/ui/ui-styles.js +51 -4
  29. package/dist/es2019/version.json +1 -1
  30. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  31. package/dist/esm/plugins/table/nodeviews/TableComponent.js +6 -6
  32. package/dist/esm/plugins/table/nodeviews/TableContainer.js +1 -1
  33. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -1
  34. package/dist/esm/plugins/table/pm-plugins/keymap.js +11 -11
  35. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  36. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +11 -1
  37. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  38. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +22 -9
  39. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -3
  40. package/dist/esm/plugins/table/ui/common-styles.js +12 -4
  41. package/dist/esm/plugins/table/ui/consts.js +1 -0
  42. package/dist/esm/plugins/table/ui/ui-styles.js +17 -8
  43. package/dist/esm/version.json +1 -1
  44. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +5 -4
  45. package/dist/types/plugins/table/pm-plugins/keymap.d.ts +2 -2
  46. package/dist/types/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  47. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
  48. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
  49. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
  50. package/dist/types/plugins/table/types.d.ts +8 -8
  51. package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +3 -2
  52. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  53. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -1
  54. package/dist/types/plugins/table/utils/decoration.d.ts +6 -4
  55. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +5 -4
  56. package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +2 -2
  57. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  58. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
  59. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
  60. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
  61. package/dist/types-ts4.5/plugins/table/types.d.ts +8 -8
  62. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +3 -2
  63. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  64. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -1
  65. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +6 -4
  66. package/package.json +2 -2
  67. package/report.api.md +1 -1
  68. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +157 -61
  69. package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +5 -1
  70. package/src/plugins/table/nodeviews/TableComponent.tsx +16 -15
  71. package/src/plugins/table/nodeviews/TableContainer.tsx +1 -1
  72. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  73. package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -1
  74. package/src/plugins/table/pm-plugins/keymap.ts +36 -27
  75. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +18 -9
  76. package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +17 -8
  77. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +9 -13
  78. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +34 -17
  79. package/src/plugins/table/types.ts +8 -8
  80. package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +11 -5
  81. package/src/plugins/table/ui/common-styles.ts +28 -9
  82. package/src/plugins/table/ui/consts.ts +1 -0
  83. package/src/plugins/table/ui/ui-styles.ts +59 -4
  84. package/src/plugins/table/utils/decoration.ts +8 -11
  85. package/tmp/api-report-tmp.d.ts +1 -1
@@ -1,13 +1,23 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
1
2
  import {
2
3
  ACTION,
3
4
  ACTION_SUBJECT,
4
5
  ACTION_SUBJECT_ID,
5
- EditorAnalyticsAPI,
6
6
  EVENT_TYPE,
7
7
  INPUT_METHOD,
8
8
  } from '@atlaskit/editor-common/analytics';
9
- import * as keymaps from '@atlaskit/editor-common/keymaps';
10
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
+ import {
10
+ addColumnAfter,
11
+ addColumnBefore,
12
+ addRowAfter,
13
+ addRowBefore,
14
+ backspace,
15
+ bindKeymapWithCommand,
16
+ nextCell,
17
+ previousCell,
18
+ toggleTable,
19
+ } from '@atlaskit/editor-common/keymaps';
20
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
21
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
12
22
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
13
23
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
@@ -23,7 +33,10 @@ import {
23
33
  deleteTableIfSelectedWithAnalytics,
24
34
  emptyMultipleCellsWithAnalytics,
25
35
  } from '../commands-with-analytics';
26
- import { addColumnAfter, addColumnBefore } from '../commands/insert';
36
+ import {
37
+ addColumnAfter as addColumnAfterCommand,
38
+ addColumnBefore as addColumnBeforeCommand,
39
+ } from '../commands/insert';
27
40
  import { withEditorAnalyticsAPI } from '../utils/analytics';
28
41
 
29
42
  const createTableWithAnalytics = (
@@ -43,23 +56,23 @@ export function keymapPlugin(
43
56
  ): SafePlugin {
44
57
  const list = {};
45
58
 
46
- keymaps.bindKeymapWithCommand(
47
- keymaps.nextCell.common!,
59
+ bindKeymapWithCommand(
60
+ nextCell.common!,
48
61
  goToNextCell(editorAnalyticsAPI)(1),
49
62
  list,
50
63
  );
51
- keymaps.bindKeymapWithCommand(
52
- keymaps.previousCell.common!,
64
+ bindKeymapWithCommand(
65
+ previousCell.common!,
53
66
  goToNextCell(editorAnalyticsAPI)(-1),
54
67
  list,
55
68
  );
56
- keymaps.bindKeymapWithCommand(
57
- keymaps.toggleTable.common!,
69
+ bindKeymapWithCommand(
70
+ toggleTable.common!,
58
71
  createTableWithAnalytics(editorAnalyticsAPI),
59
72
  list,
60
73
  );
61
- keymaps.bindKeymapWithCommand(
62
- keymaps.backspace.common!,
74
+ bindKeymapWithCommand(
75
+ backspace.common!,
63
76
  chainCommands(
64
77
  deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(
65
78
  INPUT_METHOD.KEYBOARD,
@@ -70,34 +83,30 @@ export function keymapPlugin(
70
83
  ),
71
84
  list,
72
85
  );
73
- keymaps.bindKeymapWithCommand(
74
- keymaps.backspace.common!,
75
- moveCursorBackward,
76
- list,
77
- );
86
+ bindKeymapWithCommand(backspace.common!, moveCursorBackward, list);
78
87
 
79
88
  // Add row/column shortcuts
80
- keymaps.bindKeymapWithCommand(
81
- keymaps.addRowBefore.common!,
89
+ bindKeymapWithCommand(
90
+ addRowBefore.common!,
82
91
  addRowAroundSelection(editorAnalyticsAPI)('TOP'),
83
92
  list,
84
93
  );
85
94
 
86
- keymaps.bindKeymapWithCommand(
87
- keymaps.addRowAfter.common!,
95
+ bindKeymapWithCommand(
96
+ addRowAfter.common!,
88
97
  addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'),
89
98
  list,
90
99
  );
91
100
 
92
- keymaps.bindKeymapWithCommand(
93
- keymaps.addColumnBefore.common!,
94
- triggerUnlessTableHeader(addColumnBefore(getEditorContainerWidth)),
101
+ bindKeymapWithCommand(
102
+ addColumnBefore.common!,
103
+ triggerUnlessTableHeader(addColumnBeforeCommand(getEditorContainerWidth)),
95
104
  list,
96
105
  );
97
106
 
98
- keymaps.bindKeymapWithCommand(
99
- keymaps.addColumnAfter.common!,
100
- addColumnAfter(getEditorContainerWidth),
107
+ bindKeymapWithCommand(
108
+ addColumnAfter.common!,
109
+ addColumnAfterCommand(getEditorContainerWidth),
101
110
  list,
102
111
  );
103
112
 
@@ -1,4 +1,4 @@
1
- import { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  ACTION_SUBJECT,
4
4
  EVENT_TYPE,
@@ -11,10 +11,11 @@ import type {
11
11
  GetEditorContainerWidth,
12
12
  GetEditorFeatureFlags,
13
13
  } from '@atlaskit/editor-common/types';
14
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
14
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
15
15
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
16
16
  import { TableMap } from '@atlaskit/editor-tables/table-map';
17
17
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
18
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
19
 
19
20
  import { updateColumnWidths } from '../../transforms';
20
21
  import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
@@ -65,13 +66,21 @@ export const handleMouseDown = (
65
66
  const containerWidth = getEditorContainerWidth();
66
67
  const parentWidth = getParentNodeWidth(start, state, containerWidth);
67
68
 
68
- let maxSize =
69
- parentWidth ||
70
- getLayoutSize(
71
- dom.getAttribute('data-layout') as TableLayout,
72
- containerWidth.width,
73
- {},
74
- );
69
+ let maxSize = getBooleanFF('platform.editor.custom-table-width')
70
+ ? parentWidth ||
71
+ // its safe to reference table width from node as this will not have changed
72
+ originalTable.attrs.width ||
73
+ getLayoutSize(
74
+ dom.getAttribute('data-layout') as TableLayout,
75
+ containerWidth.width,
76
+ {},
77
+ )
78
+ : parentWidth ||
79
+ getLayoutSize(
80
+ dom.getAttribute('data-layout') as TableLayout,
81
+ containerWidth.width,
82
+ {},
83
+ );
75
84
 
76
85
  if (originalTable.attrs.isNumberColumnEnabled) {
77
86
  maxSize -= akEditorTableNumberColumnWidth;
@@ -1,18 +1,26 @@
1
1
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
2
  import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
3
- import {
4
- DOMSerializer,
5
- Node as PmNode,
6
- } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
6
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
7
 
10
8
  type Col = Array<string | { [name: string]: string }>;
11
9
 
12
- export const generateColgroup = (table: PmNode): Col[] => {
10
+ /**
11
+ * This ensures the combined width of the columns (and tbody) of table is always smaller or equal
12
+ * than the table and table wrapper elements. This is necessary as there is no longer
13
+ * padding on the .pm-table-wrapper, so all elements need to be the same width to avoid
14
+ * overflow.
15
+ */
16
+ export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
17
+ colwidth - 1 / tableColumnCount;
18
+
19
+ export const generateColgroup = (table: PmNode) => {
13
20
  const cols: Col[] = [];
14
21
 
15
22
  if (getBooleanFF('platform.editor.custom-table-width')) {
23
+ const map = TableMap.get(table);
16
24
  table.content.firstChild!.content.forEach((cell) => {
17
25
  const colspan = cell.attrs.colspan || 1;
18
26
  if (Array.isArray(cell.attrs.colwidth)) {
@@ -22,9 +30,10 @@ export const generateColgroup = (table: PmNode): Col[] => {
22
30
  cols.push([
23
31
  'col',
24
32
  {
25
- style: `width: ${
26
- width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth
27
- }px;`,
33
+ style: `width: ${getColWidthFix(
34
+ width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth,
35
+ map.width,
36
+ )}px;`,
28
37
  },
29
38
  ]);
30
39
  });
@@ -1,4 +1,4 @@
1
- import { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  getParentNodeWidth,
4
4
  layoutToWidth,
@@ -10,13 +10,13 @@ import {
10
10
  mapBreakpointToLayoutMaxWidth,
11
11
  } from '@atlaskit/editor-common/ui';
12
12
  import { containsClassName } from '@atlaskit/editor-common/utils';
13
- import {
13
+ import type {
14
14
  NodeSpec,
15
15
  Node as PMNode,
16
16
  ResolvedPos,
17
17
  } from '@atlaskit/editor-prosemirror/model';
18
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
19
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
18
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
19
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
20
20
  import {
21
21
  akEditorFullWidthLayoutWidth,
22
22
  akEditorGutterPadding,
@@ -24,7 +24,7 @@ import {
24
24
  } from '@atlaskit/editor-shared-styles';
25
25
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
26
26
 
27
- import { TableOptions } from '../../../nodeviews/types';
27
+ import type { TableOptions } from '../../../nodeviews/types';
28
28
 
29
29
  // Translates named layouts in number values.
30
30
  export function getLayoutSize(
@@ -120,15 +120,11 @@ export const getTableMaxWidth = ({
120
120
  const containerWidth = getEditorContainerWidth();
121
121
  const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
122
122
 
123
- let maxWidth;
124
- if (getBooleanFF('platform.editor.custom-table-width')) {
125
- maxWidth =
126
- parentWidth ||
123
+ let maxWidth = getBooleanFF('platform.editor.custom-table-width')
124
+ ? parentWidth ||
127
125
  table.attrs.width ||
128
- getLayoutSize(layout, containerWidth.width, {});
129
- } else {
130
- maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
131
- }
126
+ getLayoutSize(layout, containerWidth.width, {})
127
+ : parentWidth || getLayoutSize(layout, containerWidth.width, {});
132
128
 
133
129
  if (table.attrs.isNumberColumnEnabled) {
134
130
  maxWidth -= akEditorTableNumberColumnWidth;
@@ -1,25 +1,27 @@
1
- import { TableLayout } from '@atlaskit/adf-schema';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  tableCellMinWidth,
4
4
  tableNewColumnMinWidth,
5
5
  } from '@atlaskit/editor-common/styles';
6
6
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
7
7
  import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
8
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
9
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
10
- import { Rect } from '@atlaskit/editor-tables/table-map';
8
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
9
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
10
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
12
 
12
13
  import { getSelectedTableInfo } from '../../../utils';
13
14
 
14
- import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
15
15
  import {
16
- ColumnState,
17
- getCellsRefsInColumn,
18
- getColumnStateFromDOM,
19
- } from './column-state';
16
+ getColWidthFix,
17
+ hasTableBeenResized,
18
+ insertColgroupFromNode,
19
+ } from './colgroup';
20
+ import type { ColumnState } from './column-state';
21
+ import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
20
22
  import { syncStickyRowToTable } from './dom';
21
23
  import { getTableMaxWidth } from './misc';
22
- import { ResizeState, ResizeStateWithAnalytics } from './types';
24
+ import type { ResizeState, ResizeStateWithAnalytics } from './types';
23
25
 
24
26
  export const getResizeState = ({
25
27
  minWidth,
@@ -83,13 +85,28 @@ export const updateColgroup = (
83
85
  tableRef: HTMLElement,
84
86
  ): void => {
85
87
  const cols = tableRef.querySelectorAll('col');
86
- state.cols
87
- .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
88
- .forEach((column, i) => {
89
- if (cols[i]) {
90
- cols[i].style.width = `${column.width}px`;
91
- }
92
- });
88
+
89
+ if (getBooleanFF('platform.editor.custom-table-width')) {
90
+ const columnsCount = cols.length;
91
+ state.cols
92
+ .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
93
+ .forEach((column, i) => {
94
+ if (cols[i]) {
95
+ cols[i].style.width = `${getColWidthFix(
96
+ column.width,
97
+ columnsCount,
98
+ )}px`;
99
+ }
100
+ });
101
+ } else {
102
+ state.cols
103
+ .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
104
+ .forEach((column, i) => {
105
+ if (cols[i]) {
106
+ cols[i].style.width = `${column.width}px`;
107
+ }
108
+ });
109
+ }
93
110
 
94
111
  // colgroup has updated, reflect new widths in sticky header
95
112
  syncStickyRowToTable(tableRef);
@@ -1,19 +1,19 @@
1
- import { IntlShape } from 'react-intl-next';
1
+ import type { IntlShape } from 'react-intl-next';
2
2
 
3
+ import type { TableLayout } from '@atlaskit/adf-schema';
3
4
  import {
4
5
  tableCellSelector,
5
6
  tableHeaderSelector,
6
- TableLayout,
7
7
  tablePrefixSelector,
8
8
  } from '@atlaskit/adf-schema';
9
- import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
10
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
+ import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
10
+ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
11
11
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
12
12
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
13
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
14
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
15
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
16
- import { Rect } from '@atlaskit/editor-tables/table-map';
13
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
14
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
15
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
16
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
17
17
 
18
18
  import type tablePlugin from './index';
19
19
 
@@ -1,8 +1,14 @@
1
- import React, { SyntheticEvent } from 'react';
1
+ import type { SyntheticEvent } from 'react';
2
+ import React from 'react';
2
3
 
3
- import { injectIntl, WrappedComponentProps } from 'react-intl-next';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { injectIntl } from 'react-intl-next';
4
6
 
5
- import * as keymaps from '@atlaskit/editor-common/keymaps';
7
+ import {
8
+ addColumnAfter,
9
+ addRowAfter,
10
+ ToolTipContent,
11
+ } from '@atlaskit/editor-common/keymaps';
6
12
  import { tableMarginTop } from '@atlaskit/editor-common/styles';
7
13
  import { closestElement } from '@atlaskit/editor-common/utils';
8
14
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
@@ -77,9 +83,9 @@ const InsertButton = ({
77
83
  const content = (
78
84
  <Tooltip
79
85
  content={
80
- <keymaps.ToolTipContent
86
+ <ToolTipContent
81
87
  description={formatMessage(tooltipMessageByType(type))}
82
- keymap={type === 'row' ? keymaps.addRowAfter : keymaps.addColumnAfter}
88
+ keymap={type === 'row' ? addRowAfter : addColumnAfter}
83
89
  />
84
90
  }
85
91
  position="top"
@@ -18,6 +18,7 @@ import {
18
18
  SelectionStyle,
19
19
  } from '@atlaskit/editor-shared-styles';
20
20
  import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
21
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
22
  import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
22
23
  import { fontSize } from '@atlaskit/theme/constants';
23
24
  import { ThemeProps } from '@atlaskit/theme/types';
@@ -155,6 +156,32 @@ const breakoutWidthStyling = () => {
155
156
  `;
156
157
  };
157
158
 
159
+ const tableWrapperStyles = () => {
160
+ if (getBooleanFF('platform.editor.custom-table-width')) {
161
+ return css`
162
+ .${ClassName.TABLE_NODE_WRAPPER} {
163
+ padding-bottom: 0px;
164
+ /* fixes gap cursor height */
165
+ overflow: auto;
166
+ overflow-y: hidden;
167
+ position: relative;
168
+ }
169
+ `;
170
+ } else {
171
+ return css`
172
+ .${ClassName.TABLE_NODE_WRAPPER} {
173
+ padding-right: ${insertColumnButtonOffset}px;
174
+ margin-right: -${insertColumnButtonOffset}px;
175
+ padding-bottom: 0px;
176
+ /* fixes gap cursor height */
177
+ overflow: auto;
178
+ overflow-y: hidden;
179
+ position: relative;
180
+ }
181
+ `;
182
+ }
183
+ };
184
+
158
185
  // TODO: https://product-fabric.atlassian.net/browse/DSP-4139
159
186
  export const tableStyles = (
160
187
  props: ThemeProps & { featureFlags?: FeatureFlags },
@@ -733,15 +760,7 @@ export const tableStyles = (
733
760
  .${ClassName.ROW_CONTROLS_WRAPPER} {
734
761
  left: -${tableToolbarSize}px;
735
762
  }
736
- .${ClassName.TABLE_NODE_WRAPPER} {
737
- padding-right: ${insertColumnButtonOffset}px;
738
- margin-right: -${insertColumnButtonOffset}px;
739
- padding-bottom: 0px;
740
- /* fixes gap cursor height */
741
- overflow: auto;
742
- overflow-y: hidden;
743
- position: relative;
744
- }
763
+ ${tableWrapperStyles()}
745
764
  }
746
765
 
747
766
  .ProseMirror.${ClassName.IS_RESIZING} {
@@ -130,6 +130,7 @@ export const contextualMenuDropdownWidth = 180;
130
130
  export const stickyRowZIndex = resizeHandlerZIndex + 2;
131
131
  export const stickyRowOffsetTop = 8;
132
132
  export const stickyHeaderBorderBottomWidth = 1;
133
+ export const tableOverflowShadowWidth = 8;
133
134
 
134
135
  export const TABLE_SNAP_GAP = 9;
135
136
  export const TABLE_HIGHLIGHT_GAP = 10;
@@ -10,9 +10,10 @@ import {
10
10
  akEditorTableNumberColumnWidth,
11
11
  akEditorUnitZIndex,
12
12
  } from '@atlaskit/editor-shared-styles';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
  import { B300, N0, N300, N40A, N60A, Y200, Y50 } from '@atlaskit/theme/colors';
14
15
  import { borderRadius } from '@atlaskit/theme/constants';
15
- import { ThemeProps } from '@atlaskit/theme/types';
16
+ import type { ThemeProps } from '@atlaskit/theme/types';
16
17
  import { token } from '@atlaskit/tokens';
17
18
 
18
19
  import { TableCssClassName as ClassName } from '../types';
@@ -36,6 +37,7 @@ import {
36
37
  tableDeleteButtonSize,
37
38
  tableHeaderCellBackgroundColor,
38
39
  tableInsertColumnButtonSize,
40
+ tableOverflowShadowWidth,
39
41
  tableToolbarDeleteColor,
40
42
  tableToolbarSelectedColor,
41
43
  tableToolbarSize,
@@ -244,7 +246,7 @@ export const OverflowShadow = (props: ThemeProps) => css`
244
246
  pointer-events: none;
245
247
  top: ${tableMarginTop}px;
246
248
  z-index: ${akEditorShadowZIndex};
247
- width: 8px;
249
+ width: ${tableOverflowShadowWidth}px;
248
250
  }
249
251
  .${ClassName.TABLE_LEFT_SHADOW} {
250
252
  background: linear-gradient(
@@ -273,9 +275,10 @@ export const OverflowShadow = (props: ThemeProps) => css`
273
275
  ${token('elevation.shadow.overflow.perimeter', 'transparent')} 0px,
274
276
  transparent 1px
275
277
  );
276
- left: calc(100% + 2px);
278
+ left: ${getBooleanFF('platform.editor.custom-table-width')
279
+ ? `calc(100% - ${tableOverflowShadowWidth}px)`
280
+ : 'calc(100% + 2px)'};
277
281
  }
278
-
279
282
  .${ClassName.WITH_CONTROLS} {
280
283
  .${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
281
284
  height: calc(100% - ${tableMarginTopWithControl}px);
@@ -308,6 +311,29 @@ const columnHeaderButtonSelected = (props: ThemeProps) => css`
308
311
  z-index: ${columnControlsSelectedZIndex};
309
312
  `;
310
313
 
314
+ const getFloatingDotOverrides = (props: ThemeProps) => {
315
+ return getBooleanFF('platform.editor.custom-table-width')
316
+ ? css`
317
+ tr
318
+ th:last-child
319
+ .${ClassName.COLUMN_CONTROLS_DECORATIONS}::before,
320
+ tr
321
+ td:last-child
322
+ .${ClassName.COLUMN_CONTROLS_DECORATIONS}::before {
323
+ content: '';
324
+ background-color: ${tableBorderColor(props)};
325
+ position: absolute;
326
+ height: ${lineMarkerSize}px;
327
+ width: ${lineMarkerSize}px;
328
+ border-radius: 50%;
329
+ pointer-events: none;
330
+ top: ${token('space.025', '2px')};
331
+ right: 0px;
332
+ }
333
+ `
334
+ : '';
335
+ };
336
+
311
337
  export const columnControlsDecoration = (props: ThemeProps) => css`
312
338
  .${ClassName.COLUMN_CONTROLS_DECORATIONS} {
313
339
  display: none;
@@ -317,6 +343,7 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
317
343
  left: -1px;
318
344
  top: -${columnControlsDecorationHeight + tableCellBorderWidth}px;
319
345
  height: ${columnControlsDecorationHeight}px;
346
+ // floating dot for adding column button
320
347
  &::before {
321
348
  content: ' ';
322
349
  background-color: ${tableBorderColor(props)};
@@ -350,6 +377,9 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
350
377
  }
351
378
  }
352
379
 
380
+ // floating dot for adding column button - overriding style on last column to avoid scroll
381
+ ${getFloatingDotOverrides(props)}
382
+
353
383
  div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
354
384
  content: ' ';
355
385
  background-color: ${tableBorderColor(props)};
@@ -439,6 +469,29 @@ export const hoveredWarningCell = css`
439
469
  }
440
470
  `;
441
471
 
472
+ // move the resize handle zone completely inside the table cell to avoid overflow
473
+ const getLastColumnResizerOverrides = () => {
474
+ return getBooleanFF('platform.editor.custom-table-width')
475
+ ? css`
476
+ tr
477
+ th:last-child
478
+ .${ClassName.RESIZE_HANDLE_DECORATION},
479
+ tr
480
+ td:last-child
481
+ .${ClassName.RESIZE_HANDLE_DECORATION} {
482
+ background-color: transparent;
483
+ position: absolute;
484
+ width: ${resizeHandlerAreaWidth}px;
485
+ height: 100%;
486
+ top: 0;
487
+ right: 0;
488
+ cursor: col-resize;
489
+ z-index: ${resizeHandlerZIndex};
490
+ }
491
+ `
492
+ : '';
493
+ };
494
+
442
495
  export const resizeHandle = (props: ThemeProps) => css`
443
496
  .${ClassName.TABLE_CONTAINER} {
444
497
  .${ClassName.RESIZE_HANDLE_DECORATION} {
@@ -452,6 +505,8 @@ export const resizeHandle = (props: ThemeProps) => css`
452
505
  z-index: ${resizeHandlerZIndex};
453
506
  }
454
507
 
508
+ ${getLastColumnResizerOverrides()}
509
+
455
510
  td.${ClassName.WITH_RESIZE_LINE}::before {
456
511
  content: ' ';
457
512
  position: absolute;
@@ -1,14 +1,15 @@
1
- import { CellAttributes } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes } from '@atlaskit/adf-schema';
2
2
  import { nonNullable } from '@atlaskit/editor-common/utils';
3
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
4
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
5
- import {
5
+ import type {
6
6
  ReadonlyTransaction,
7
7
  Selection,
8
8
  Transaction,
9
9
  } from '@atlaskit/editor-prosemirror/state';
10
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
11
- import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
11
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
12
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
12
13
  import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
13
14
  import {
14
15
  findTable,
@@ -16,12 +17,8 @@ import {
16
17
  getSelectionRect,
17
18
  } from '@atlaskit/editor-tables/utils';
18
19
 
19
- import {
20
- Cell,
21
- CellColumnPositioning,
22
- TableCssClassName as ClassName,
23
- TableDecorations,
24
- } from '../types';
20
+ import type { Cell, CellColumnPositioning } from '../types';
21
+ import { TableCssClassName as ClassName, TableDecorations } from '../types';
25
22
 
26
23
  const filterDecorationByKey = (
27
24
  key: TableDecorations,
@@ -12,7 +12,7 @@ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
12
12
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
13
13
  import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
14
14
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
15
- import { TableLayout } from '@atlaskit/adf-schema';
15
+ import type { TableLayout } from '@atlaskit/adf-schema';
16
16
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
17
17
 
18
18
  // @public (undocumented)