@atlaskit/editor-plugin-table 2.8.6 → 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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +13 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +21 -8
- package/dist/cjs/plugins/table/ui/common-styles.js +12 -4
- package/dist/cjs/plugins/table/ui/consts.js +3 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +16 -7
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +9 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +18 -7
- package/dist/es2019/plugins/table/ui/common-styles.js +27 -9
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +51 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +11 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +22 -9
- package/dist/esm/plugins/table/ui/common-styles.js +12 -4
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +17 -8
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +5 -4
- package/dist/types/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
- package/dist/types/plugins/table/types.d.ts +8 -8
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +6 -4
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +5 -4
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/types.d.ts +8 -8
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +6 -4
- package/package.json +2 -2
- package/report.api.md +1 -1
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +157 -61
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +5 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +16 -15
- package/src/plugins/table/nodeviews/TableContainer.tsx +1 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -1
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +18 -9
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +17 -8
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +9 -13
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +34 -17
- package/src/plugins/table/types.ts +8 -8
- package/src/plugins/table/ui/common-styles.ts +28 -9
- package/src/plugins/table/ui/consts.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +59 -4
- package/src/plugins/table/utils/decoration.ts +8 -11
- package/tmp/api-report-tmp.d.ts +1 -1
|
@@ -36,7 +36,9 @@ const getResizerHandleHeight = tableRef => {
|
|
|
36
36
|
const getResizerMinWidth = node => {
|
|
37
37
|
const currentColumnCount = getColgroupChildrenLength(node);
|
|
38
38
|
const minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
|
|
39
|
-
|
|
39
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
40
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
41
|
+
return minColumnWidth + 1;
|
|
40
42
|
};
|
|
41
43
|
export const TableResizer = ({
|
|
42
44
|
children,
|
|
@@ -4,6 +4,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
4
4
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { updateColumnWidths } from '../../transforms';
|
|
8
9
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
9
10
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -31,7 +32,9 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
31
32
|
}
|
|
32
33
|
const containerWidth = getEditorContainerWidth();
|
|
33
34
|
const parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
34
|
-
let maxSize =
|
|
35
|
+
let maxSize = getBooleanFF('platform.editor.custom-table-width') ? parentWidth ||
|
|
36
|
+
// its safe to reference table width from node as this will not have changed
|
|
37
|
+
originalTable.attrs.width || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {}) : parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
35
38
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
36
39
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
37
40
|
}
|
|
@@ -3,9 +3,17 @@ import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
|
3
3
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
/**
|
|
7
|
+
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
8
|
+
* than the table and table wrapper elements. This is necessary as there is no longer
|
|
9
|
+
* padding on the .pm-table-wrapper, so all elements need to be the same width to avoid
|
|
10
|
+
* overflow.
|
|
11
|
+
*/
|
|
12
|
+
export const getColWidthFix = (colwidth, tableColumnCount) => colwidth - 1 / tableColumnCount;
|
|
6
13
|
export const generateColgroup = table => {
|
|
7
14
|
const cols = [];
|
|
8
15
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
16
|
+
const map = TableMap.get(table);
|
|
9
17
|
table.content.firstChild.content.forEach(cell => {
|
|
10
18
|
const colspan = cell.attrs.colspan || 1;
|
|
11
19
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
@@ -13,7 +21,7 @@ export const generateColgroup = table => {
|
|
|
13
21
|
// Than the we actually span. We'll patch the document at a later point.
|
|
14
22
|
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
15
23
|
cols.push(['col', {
|
|
16
|
-
style: `width: ${width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth}px;`
|
|
24
|
+
style: `width: ${getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width)}px;`
|
|
17
25
|
}]);
|
|
18
26
|
});
|
|
19
27
|
} else {
|
|
@@ -66,12 +66,7 @@ export const getTableMaxWidth = ({
|
|
|
66
66
|
}) => {
|
|
67
67
|
const containerWidth = getEditorContainerWidth();
|
|
68
68
|
const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
69
|
-
let maxWidth;
|
|
70
|
-
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
71
|
-
maxWidth = parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {});
|
|
72
|
-
} else {
|
|
73
|
-
maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
74
|
-
}
|
|
69
|
+
let maxWidth = getBooleanFF('platform.editor.custom-table-width') ? parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {}) : parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
75
70
|
if (table.attrs.isNumberColumnEnabled) {
|
|
76
71
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
77
72
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { getSelectedTableInfo } from '../../../utils';
|
|
4
|
-
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
5
|
+
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
5
6
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
6
7
|
import { syncStickyRowToTable } from './dom';
|
|
7
8
|
import { getTableMaxWidth } from './misc';
|
|
@@ -52,12 +53,22 @@ export const getResizeState = ({
|
|
|
52
53
|
// updates Colgroup DOM node with new widths
|
|
53
54
|
export const updateColgroup = (state, tableRef) => {
|
|
54
55
|
const cols = tableRef.querySelectorAll('col');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
57
|
+
const columnsCount = cols.length;
|
|
58
|
+
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
59
|
+
.forEach((column, i) => {
|
|
60
|
+
if (cols[i]) {
|
|
61
|
+
cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
66
|
+
.forEach((column, i) => {
|
|
67
|
+
if (cols[i]) {
|
|
68
|
+
cols[i].style.width = `${column.width}px`;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
61
72
|
|
|
62
73
|
// colgroup has updated, reflect new widths in sticky header
|
|
63
74
|
syncStickyRowToTable(tableRef);
|
|
@@ -2,6 +2,7 @@ import { css } from '@emotion/react';
|
|
|
2
2
|
import { tableMarginTop, tableSharedStyle } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, relativeFontSizeToBase16, SelectionStyle } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
6
7
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
7
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -88,6 +89,31 @@ const breakoutWidthStyling = () => {
|
|
|
88
89
|
}
|
|
89
90
|
`;
|
|
90
91
|
};
|
|
92
|
+
const tableWrapperStyles = () => {
|
|
93
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
94
|
+
return css`
|
|
95
|
+
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
96
|
+
padding-bottom: 0px;
|
|
97
|
+
/* fixes gap cursor height */
|
|
98
|
+
overflow: auto;
|
|
99
|
+
overflow-y: hidden;
|
|
100
|
+
position: relative;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
} else {
|
|
104
|
+
return css`
|
|
105
|
+
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
106
|
+
padding-right: ${insertColumnButtonOffset}px;
|
|
107
|
+
margin-right: -${insertColumnButtonOffset}px;
|
|
108
|
+
padding-bottom: 0px;
|
|
109
|
+
/* fixes gap cursor height */
|
|
110
|
+
overflow: auto;
|
|
111
|
+
overflow-y: hidden;
|
|
112
|
+
position: relative;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
91
117
|
|
|
92
118
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
93
119
|
export const tableStyles = props => {
|
|
@@ -658,15 +684,7 @@ export const tableStyles = props => {
|
|
|
658
684
|
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
659
685
|
left: -${tableToolbarSize}px;
|
|
660
686
|
}
|
|
661
|
-
|
|
662
|
-
padding-right: ${insertColumnButtonOffset}px;
|
|
663
|
-
margin-right: -${insertColumnButtonOffset}px;
|
|
664
|
-
padding-bottom: 0px;
|
|
665
|
-
/* fixes gap cursor height */
|
|
666
|
-
overflow: auto;
|
|
667
|
-
overflow-y: hidden;
|
|
668
|
-
position: relative;
|
|
669
|
-
}
|
|
687
|
+
${tableWrapperStyles()}
|
|
670
688
|
}
|
|
671
689
|
|
|
672
690
|
.ProseMirror.${ClassName.IS_RESIZING} {
|
|
@@ -97,6 +97,7 @@ export const contextualMenuDropdownWidth = 180;
|
|
|
97
97
|
export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
98
98
|
export const stickyRowOffsetTop = 8;
|
|
99
99
|
export const stickyHeaderBorderBottomWidth = 1;
|
|
100
|
+
export const tableOverflowShadowWidth = 8;
|
|
100
101
|
export const TABLE_SNAP_GAP = 9;
|
|
101
102
|
export const TABLE_HIGHLIGHT_GAP = 10;
|
|
102
103
|
export const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorShadowZIndex, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { B300, N0, N300, N40A, N60A, Y200, Y50 } from '@atlaskit/theme/colors';
|
|
5
6
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
6
7
|
import { TableCssClassName as ClassName } from '../types';
|
|
7
|
-
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
8
|
+
import { columnControlsDecorationHeight, columnControlsSelectedZIndex, columnControlsZIndex, lineMarkerSize, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, tableBorderColor, tableBorderDeleteColor, tableBorderSelectedColor, tableCellDeleteColor, tableCellHoverDeleteIconBackground, tableCellHoverDeleteIconColor, tableCellSelectedDeleteIconBackground, tableCellSelectedDeleteIconColor, tableDeleteButtonSize, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
8
9
|
const InsertLine = (props, cssString) => css`
|
|
9
10
|
.${ClassName.CONTROLS_INSERT_LINE} {
|
|
10
11
|
background: ${tableBorderSelectedColor(props)};
|
|
@@ -186,7 +187,7 @@ export const OverflowShadow = props => css`
|
|
|
186
187
|
pointer-events: none;
|
|
187
188
|
top: ${tableMarginTop}px;
|
|
188
189
|
z-index: ${akEditorShadowZIndex};
|
|
189
|
-
width:
|
|
190
|
+
width: ${tableOverflowShadowWidth}px;
|
|
190
191
|
}
|
|
191
192
|
.${ClassName.TABLE_LEFT_SHADOW} {
|
|
192
193
|
background: linear-gradient(
|
|
@@ -215,9 +216,8 @@ export const OverflowShadow = props => css`
|
|
|
215
216
|
${"var(--ds-shadow-overflow-perimeter, transparent)"} 0px,
|
|
216
217
|
transparent 1px
|
|
217
218
|
);
|
|
218
|
-
left: calc(100% + 2px);
|
|
219
|
+
left: ${getBooleanFF('platform.editor.custom-table-width') ? `calc(100% - ${tableOverflowShadowWidth}px)` : 'calc(100% + 2px)'};
|
|
219
220
|
}
|
|
220
|
-
|
|
221
221
|
.${ClassName.WITH_CONTROLS} {
|
|
222
222
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
223
223
|
height: calc(100% - ${tableMarginTopWithControl}px);
|
|
@@ -247,6 +247,26 @@ const columnHeaderButtonSelected = props => css`
|
|
|
247
247
|
border-color: ${tableBorderSelectedColor(props)};
|
|
248
248
|
z-index: ${columnControlsSelectedZIndex};
|
|
249
249
|
`;
|
|
250
|
+
const getFloatingDotOverrides = props => {
|
|
251
|
+
return getBooleanFF('platform.editor.custom-table-width') ? css`
|
|
252
|
+
tr
|
|
253
|
+
th:last-child
|
|
254
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before,
|
|
255
|
+
tr
|
|
256
|
+
td:last-child
|
|
257
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before {
|
|
258
|
+
content: '';
|
|
259
|
+
background-color: ${tableBorderColor(props)};
|
|
260
|
+
position: absolute;
|
|
261
|
+
height: ${lineMarkerSize}px;
|
|
262
|
+
width: ${lineMarkerSize}px;
|
|
263
|
+
border-radius: 50%;
|
|
264
|
+
pointer-events: none;
|
|
265
|
+
top: ${"var(--ds-space-025, 2px)"};
|
|
266
|
+
right: 0px;
|
|
267
|
+
}
|
|
268
|
+
` : '';
|
|
269
|
+
};
|
|
250
270
|
export const columnControlsDecoration = props => css`
|
|
251
271
|
.${ClassName.COLUMN_CONTROLS_DECORATIONS} {
|
|
252
272
|
display: none;
|
|
@@ -256,6 +276,7 @@ export const columnControlsDecoration = props => css`
|
|
|
256
276
|
left: -1px;
|
|
257
277
|
top: -${columnControlsDecorationHeight + tableCellBorderWidth}px;
|
|
258
278
|
height: ${columnControlsDecorationHeight}px;
|
|
279
|
+
// floating dot for adding column button
|
|
259
280
|
&::before {
|
|
260
281
|
content: ' ';
|
|
261
282
|
background-color: ${tableBorderColor(props)};
|
|
@@ -284,6 +305,9 @@ export const columnControlsDecoration = props => css`
|
|
|
284
305
|
}
|
|
285
306
|
}
|
|
286
307
|
|
|
308
|
+
// floating dot for adding column button - overriding style on last column to avoid scroll
|
|
309
|
+
${getFloatingDotOverrides(props)}
|
|
310
|
+
|
|
287
311
|
div.${ClassName.WITH_CONTROLS}>.${ClassName.ROW_CONTROLS_WRAPPER}::after {
|
|
288
312
|
content: ' ';
|
|
289
313
|
background-color: ${tableBorderColor(props)};
|
|
@@ -366,6 +390,27 @@ export const hoveredWarningCell = css`
|
|
|
366
390
|
}
|
|
367
391
|
}
|
|
368
392
|
`;
|
|
393
|
+
|
|
394
|
+
// move the resize handle zone completely inside the table cell to avoid overflow
|
|
395
|
+
const getLastColumnResizerOverrides = () => {
|
|
396
|
+
return getBooleanFF('platform.editor.custom-table-width') ? css`
|
|
397
|
+
tr
|
|
398
|
+
th:last-child
|
|
399
|
+
.${ClassName.RESIZE_HANDLE_DECORATION},
|
|
400
|
+
tr
|
|
401
|
+
td:last-child
|
|
402
|
+
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
403
|
+
background-color: transparent;
|
|
404
|
+
position: absolute;
|
|
405
|
+
width: ${resizeHandlerAreaWidth}px;
|
|
406
|
+
height: 100%;
|
|
407
|
+
top: 0;
|
|
408
|
+
right: 0;
|
|
409
|
+
cursor: col-resize;
|
|
410
|
+
z-index: ${resizeHandlerZIndex};
|
|
411
|
+
}
|
|
412
|
+
` : '';
|
|
413
|
+
};
|
|
369
414
|
export const resizeHandle = props => css`
|
|
370
415
|
.${ClassName.TABLE_CONTAINER} {
|
|
371
416
|
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
@@ -379,6 +424,8 @@ export const resizeHandle = props => css`
|
|
|
379
424
|
z-index: ${resizeHandlerZIndex};
|
|
380
425
|
}
|
|
381
426
|
|
|
427
|
+
${getLastColumnResizerOverrides()}
|
|
428
|
+
|
|
382
429
|
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
383
430
|
content: ' ';
|
|
384
431
|
position: absolute;
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
5
6
|
import { tableInsertColumnButtonSize } from '../ui/consts';
|
|
6
7
|
import { updateShadowListForStickyStyles } from './update-overflow-shadows';
|
|
@@ -34,7 +35,7 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
34
35
|
}, {
|
|
35
36
|
threshold: [0, 1],
|
|
36
37
|
root: _this.wrapper,
|
|
37
|
-
rootMargin: "0px ".concat(tableInsertColumnButtonSize / 2, "px 0px 0px")
|
|
38
|
+
rootMargin: getBooleanFF('platform.editor.custom-table-width') ? '0px' : "0px ".concat(tableInsertColumnButtonSize / 2, "px 0px 0px")
|
|
38
39
|
});
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
@@ -18,6 +18,7 @@ import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
|
18
18
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
19
19
|
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
20
20
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
21
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
21
22
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
22
23
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
23
24
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
@@ -25,6 +26,7 @@ import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scal
|
|
|
25
26
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
26
27
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
27
28
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
29
|
+
import { tableOverflowShadowWidth } from '../ui/consts';
|
|
28
30
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
29
31
|
import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
|
|
30
32
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
@@ -134,8 +136,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
134
136
|
if (shouldScaleTable) {
|
|
135
137
|
_this.scaleTable({
|
|
136
138
|
parentWidth: parentWidth,
|
|
137
|
-
layoutChanged: layoutChanged
|
|
138
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
139
|
+
layoutChanged: layoutChanged
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -143,9 +144,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
143
144
|
if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
144
145
|
if (!hasTableBeenResized(prevNode)) {
|
|
145
146
|
_this.scaleTable({
|
|
146
|
-
parentWidth:
|
|
147
|
-
layoutChanged: layoutChanged
|
|
148
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
147
|
+
parentWidth: node.attrs.width,
|
|
148
|
+
layoutChanged: layoutChanged
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -496,7 +496,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
496
496
|
}), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
|
|
497
497
|
style: {
|
|
498
498
|
position: 'absolute',
|
|
499
|
-
right: '-2px'
|
|
499
|
+
right: getBooleanFF('platform.editor.custom-table-width') ? "".concat(tableOverflowShadowWidth, "px") : '-2px'
|
|
500
500
|
}
|
|
501
501
|
}, /*#__PURE__*/React.createElement("div", {
|
|
502
502
|
className: "".concat(ClassName.TABLE_RIGHT_SHADOW, " ").concat(ClassName.TABLE_STICKY_SHADOW),
|
|
@@ -122,7 +122,7 @@ export var TableContainer = function TableContainer(_ref3) {
|
|
|
122
122
|
return /*#__PURE__*/React.createElement(InnerContainer, {
|
|
123
123
|
node: node,
|
|
124
124
|
className: classNames(className, {
|
|
125
|
-
'less-padding': editorWidth < akEditorMobileBreakoutPoint
|
|
125
|
+
'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested
|
|
126
126
|
}),
|
|
127
127
|
style: {
|
|
128
128
|
width: tableWidth,
|
|
@@ -40,7 +40,9 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
40
40
|
var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
41
41
|
var currentColumnCount = getColgroupChildrenLength(node);
|
|
42
42
|
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
|
|
43
|
-
|
|
43
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
44
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
45
|
+
return minColumnWidth + 1;
|
|
44
46
|
};
|
|
45
47
|
export var TableResizer = function TableResizer(_ref) {
|
|
46
48
|
var _findTable, _editorView$state;
|
|
@@ -4,6 +4,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
4
4
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { updateColumnWidths } from '../../transforms';
|
|
8
9
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
9
10
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -29,7 +30,9 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
29
30
|
}
|
|
30
31
|
var containerWidth = getEditorContainerWidth();
|
|
31
32
|
var parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
32
|
-
var maxSize =
|
|
33
|
+
var maxSize = getBooleanFF('platform.editor.custom-table-width') ? parentWidth ||
|
|
34
|
+
// its safe to reference table width from node as this will not have changed
|
|
35
|
+
originalTable.attrs.width || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {}) : parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
33
36
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
34
37
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
35
38
|
}
|
|
@@ -4,9 +4,19 @@ import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
/**
|
|
8
|
+
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
9
|
+
* than the table and table wrapper elements. This is necessary as there is no longer
|
|
10
|
+
* padding on the .pm-table-wrapper, so all elements need to be the same width to avoid
|
|
11
|
+
* overflow.
|
|
12
|
+
*/
|
|
13
|
+
export var getColWidthFix = function getColWidthFix(colwidth, tableColumnCount) {
|
|
14
|
+
return colwidth - 1 / tableColumnCount;
|
|
15
|
+
};
|
|
7
16
|
export var generateColgroup = function generateColgroup(table) {
|
|
8
17
|
var cols = [];
|
|
9
18
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
19
|
+
var map = TableMap.get(table);
|
|
10
20
|
table.content.firstChild.content.forEach(function (cell) {
|
|
11
21
|
var colspan = cell.attrs.colspan || 1;
|
|
12
22
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
@@ -14,7 +24,7 @@ export var generateColgroup = function generateColgroup(table) {
|
|
|
14
24
|
// Than the we actually span. We'll patch the document at a later point.
|
|
15
25
|
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
16
26
|
cols.push(['col', {
|
|
17
|
-
style: "width: ".concat(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, "px;")
|
|
27
|
+
style: "width: ".concat(getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width), "px;")
|
|
18
28
|
}]);
|
|
19
29
|
});
|
|
20
30
|
} else {
|
|
@@ -64,12 +64,7 @@ export var getTableMaxWidth = function getTableMaxWidth(_ref2) {
|
|
|
64
64
|
getEditorContainerWidth = _ref2.getEditorContainerWidth;
|
|
65
65
|
var containerWidth = getEditorContainerWidth();
|
|
66
66
|
var parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
67
|
-
var maxWidth;
|
|
68
|
-
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
69
|
-
maxWidth = parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {});
|
|
70
|
-
} else {
|
|
71
|
-
maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
72
|
-
}
|
|
67
|
+
var maxWidth = getBooleanFF('platform.editor.custom-table-width') ? parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {}) : parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
73
68
|
if (table.attrs.isNumberColumnEnabled) {
|
|
74
69
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
75
70
|
}
|
|
@@ -3,8 +3,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { getSelectedTableInfo } from '../../../utils';
|
|
7
|
-
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
8
|
+
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
8
9
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
9
10
|
import { syncStickyRowToTable } from './dom';
|
|
10
11
|
import { getTableMaxWidth } from './misc';
|
|
@@ -64,14 +65,26 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
64
65
|
// updates Colgroup DOM node with new widths
|
|
65
66
|
export var updateColgroup = function updateColgroup(state, tableRef) {
|
|
66
67
|
var cols = tableRef.querySelectorAll('col');
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
69
|
+
var columnsCount = cols.length;
|
|
70
|
+
state.cols.filter(function (column) {
|
|
71
|
+
return column && !!column.width;
|
|
72
|
+
}) // if width is 0, we dont want to apply that.
|
|
73
|
+
.forEach(function (column, i) {
|
|
74
|
+
if (cols[i]) {
|
|
75
|
+
cols[i].style.width = "".concat(getColWidthFix(column.width, columnsCount), "px");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
state.cols.filter(function (column) {
|
|
80
|
+
return column && !!column.width;
|
|
81
|
+
}) // if width is 0, we dont want to apply that.
|
|
82
|
+
.forEach(function (column, i) {
|
|
83
|
+
if (cols[i]) {
|
|
84
|
+
cols[i].style.width = "".concat(column.width, "px");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
75
88
|
|
|
76
89
|
// colgroup has updated, reflect new widths in sticky header
|
|
77
90
|
syncStickyRowToTable(tableRef);
|