@atlaskit/editor-plugin-table 5.7.2 → 5.7.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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/commands/insert.js +1 -1
- package/dist/cjs/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/main.js +5 -16
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +0 -4
- package/dist/cjs/transforms/column-width.js +3 -105
- package/dist/cjs/transforms/delete-columns.js +2 -5
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +5 -2
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +39 -8
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +17 -8
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/cjs/utils/decoration.js +48 -34
- package/dist/cjs/utils/dom.js +1 -19
- package/dist/cjs/utils/index.js +0 -6
- package/dist/es2019/commands/insert.js +1 -1
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/plugin.js +2 -1
- package/dist/es2019/pm-plugins/main.js +1 -12
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/es2019/transforms/column-width.js +4 -102
- package/dist/es2019/transforms/delete-columns.js +2 -5
- package/dist/es2019/types.js +0 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +6 -3
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +34 -4
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/es2019/ui/common-styles.js +6 -1
- package/dist/es2019/utils/decoration.js +47 -33
- package/dist/es2019/utils/dom.js +0 -18
- package/dist/es2019/utils/index.js +1 -1
- package/dist/esm/commands/insert.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +5 -2
- package/dist/esm/plugin.js +2 -1
- package/dist/esm/pm-plugins/main.js +1 -12
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/esm/transforms/column-width.js +4 -106
- package/dist/esm/transforms/delete-columns.js +2 -5
- package/dist/esm/types.js +0 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +35 -4
- package/dist/esm/ui/TableFloatingColumnControls/index.js +18 -9
- package/dist/esm/ui/common-styles.js +2 -2
- package/dist/esm/utils/decoration.js +48 -34
- package/dist/esm/utils/dom.js +0 -18
- package/dist/esm/utils/index.js +1 -1
- package/dist/types/transforms/column-width.d.ts +1 -14
- package/dist/types/types.d.ts +0 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types/utils/dom.d.ts +0 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -14
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/dom.d.ts +0 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +6 -9
- package/src/__tests__/unit/commands/insert.ts +7 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +147 -368
- package/src/commands/insert.ts +1 -3
- package/src/nodeviews/TableComponent.tsx +7 -2
- package/src/plugin.tsx +1 -0
- package/src/pm-plugins/main.ts +0 -18
- package/src/pm-plugins/table-resizing/event-handlers.ts +1 -8
- package/src/transforms/column-width.ts +4 -137
- package/src/transforms/delete-columns.ts +3 -9
- package/src/types.ts +0 -2
- package/src/ui/FloatingDragMenu/index.tsx +14 -2
- package/src/ui/FloatingInsertButton/InsertButton.tsx +6 -2
- package/src/ui/FloatingInsertButton/index.tsx +4 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +48 -3
- package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
- package/src/ui/common-styles.ts +6 -0
- package/src/utils/decoration.ts +41 -28
- package/src/utils/dom.ts +0 -23
- package/src/utils/index.ts +0 -1
|
@@ -11,12 +11,12 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
|
11
11
|
import Tooltip from '@atlaskit/tooltip';
|
|
12
12
|
import { TableCssClassName as ClassName } from '../../types';
|
|
13
13
|
import { tableToolbarSize } from '../consts';
|
|
14
|
-
const getInsertLineHeight = (tableRef, hasStickyHeaders) => {
|
|
14
|
+
const getInsertLineHeight = (tableRef, hasStickyHeaders, isDragAndDropEnabled) => {
|
|
15
15
|
// The line gets height 100% from the table,
|
|
16
16
|
// but since we have an overflow on the left,
|
|
17
17
|
// we should add an offset to make up for it.
|
|
18
18
|
const LINE_OFFSET = 3;
|
|
19
|
-
const ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop * 4 - LINE_OFFSET : tableToolbarSize + LINE_OFFSET;
|
|
19
|
+
const ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop * (isDragAndDropEnabled ? 3 : 4) - LINE_OFFSET : tableToolbarSize + LINE_OFFSET;
|
|
20
20
|
return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
|
|
21
21
|
};
|
|
22
22
|
const getToolbarSize = tableRef => {
|
|
@@ -89,7 +89,7 @@ export const InsertButtonForDragAndDrop = ({
|
|
|
89
89
|
width: getInsertLineWidth(tableRef, true),
|
|
90
90
|
left: "var(--ds-space-150, 12px)"
|
|
91
91
|
} : {
|
|
92
|
-
height: getInsertLineHeight(tableRef, hasStickyHeaders) - 8,
|
|
92
|
+
height: getInsertLineHeight(tableRef, hasStickyHeaders, true) - 8,
|
|
93
93
|
top: '-3px'
|
|
94
94
|
}
|
|
95
95
|
})));
|
|
@@ -6,7 +6,7 @@ import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE, INPUT_METHOD } f
|
|
|
6
6
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { akEditorTableInsertButtonOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
11
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
12
12
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -106,7 +106,7 @@ export class FloatingInsertButton extends React.Component {
|
|
|
106
106
|
// By setting the Popup z-index higher than the sticky header z-index ( common-styles.ts tr.sticky)
|
|
107
107
|
// Only when inserting a column, otherwise set to undefined
|
|
108
108
|
// Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
|
|
109
|
-
const zIndex = type === 'column' ?
|
|
109
|
+
const zIndex = type === 'column' ? akEditorTableInsertButtonOnStickyHeaderZIndex : undefined;
|
|
110
110
|
return /*#__PURE__*/React.createElement(Popup, _extends({
|
|
111
111
|
target: targetCellRef,
|
|
112
112
|
mountTo: tableContainerWrapper || mountPoint,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
2
|
|
|
3
|
-
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
5
7
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
8
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
9
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../commands';
|
|
@@ -32,10 +34,16 @@ export const ColumnControls = ({
|
|
|
32
34
|
colWidths,
|
|
33
35
|
hasHeaderColumn,
|
|
34
36
|
isTableHovered,
|
|
35
|
-
canDrag
|
|
37
|
+
canDrag,
|
|
38
|
+
tableContainerWidth,
|
|
39
|
+
isNumberColumnEnabled
|
|
36
40
|
}) => {
|
|
37
41
|
var _colWidths$map$join, _rowHeights$;
|
|
38
|
-
const
|
|
42
|
+
const columnControlsRef = useRef(null);
|
|
43
|
+
const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width =>
|
|
44
|
+
// when there is sticky header, a `margin-right: -1px` applied to `tr.sticky th` so it causes colWidths to be 1px wider
|
|
45
|
+
// we need to reduce the width by 1px to avoid misalignment of column controls.
|
|
46
|
+
width ? stickyTop ? `${width - 2}px` : `${width - 1}px` : '0px').join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
39
47
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
40
48
|
const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
41
49
|
const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
@@ -104,6 +112,24 @@ export const ColumnControls = ({
|
|
|
104
112
|
const colIndexes = useMemo(() => {
|
|
105
113
|
return [colIndex];
|
|
106
114
|
}, [colIndex]);
|
|
115
|
+
const tableWrapper = closestElement(tableRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
116
|
+
const handleScroll = useCallback(event => {
|
|
117
|
+
if (stickyTop) {
|
|
118
|
+
if (columnControlsRef && columnControlsRef.current) {
|
|
119
|
+
var _tableWrapper$scrollL;
|
|
120
|
+
columnControlsRef.current.scrollLeft = (_tableWrapper$scrollL = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.scrollLeft) !== null && _tableWrapper$scrollL !== void 0 ? _tableWrapper$scrollL : 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, [stickyTop, tableWrapper]);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
handleScroll();
|
|
126
|
+
}, [handleScroll]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.addEventListener('scroll', handleScroll);
|
|
129
|
+
return () => {
|
|
130
|
+
tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.removeEventListener('scroll', handleScroll);
|
|
131
|
+
};
|
|
132
|
+
}, [tableWrapper, handleScroll]);
|
|
107
133
|
const generateHandleByType = type => {
|
|
108
134
|
var _rowHeights$reduce, _colWidths;
|
|
109
135
|
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
@@ -164,15 +190,19 @@ export const ColumnControls = ({
|
|
|
164
190
|
const sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
165
191
|
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
166
192
|
};
|
|
193
|
+
const containerWidth = isNumberColumnEnabled && tableContainerWidth ? tableContainerWidth - akEditorTableNumberColumnWidth : tableContainerWidth;
|
|
167
194
|
return /*#__PURE__*/React.createElement("div", {
|
|
168
195
|
className: ClassName.DRAG_COLUMN_CONTROLS,
|
|
169
196
|
onMouseMove: handleMouseMove
|
|
170
197
|
}, /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
ref: columnControlsRef,
|
|
171
199
|
className: ClassName.DRAG_COLUMN_CONTROLS_INNER,
|
|
172
200
|
"data-testid": "table-floating-column-controls",
|
|
173
201
|
style: {
|
|
174
202
|
gridTemplateColumns: widths,
|
|
175
|
-
marginTop
|
|
203
|
+
marginTop,
|
|
204
|
+
width: stickyTop ? containerWidth : undefined,
|
|
205
|
+
overflowX: stickyTop ? 'hidden' : 'visible'
|
|
176
206
|
}
|
|
177
207
|
}, !isResizing && columnParams.map(({
|
|
178
208
|
startIndex,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
3
3
|
import { TableCssClassName as ClassName } from '../../types';
|
|
4
4
|
import { containsHeaderColumn, getColumnsWidths, getRowHeights } from '../../utils';
|
|
@@ -16,16 +16,20 @@ export const TableFloatingColumnControls = ({
|
|
|
16
16
|
selection,
|
|
17
17
|
isInDanger,
|
|
18
18
|
isTableHovered,
|
|
19
|
-
canDrag
|
|
19
|
+
canDrag,
|
|
20
|
+
tableContainerWidth,
|
|
21
|
+
isNumberColumnEnabled
|
|
20
22
|
}) => {
|
|
21
23
|
const [tableRect, setTableRect] = useState({
|
|
22
24
|
width: 0,
|
|
23
25
|
height: 0
|
|
24
26
|
});
|
|
25
27
|
const [hasDropTargets, setHasDropTargets] = useState(false);
|
|
28
|
+
const containerRef = useRef(null);
|
|
26
29
|
const node = getNode();
|
|
27
30
|
const currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
28
31
|
const hasHeaderColumn = containsHeaderColumn(node);
|
|
32
|
+
const stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
29
33
|
useEffect(() => {
|
|
30
34
|
var _window;
|
|
31
35
|
if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
@@ -76,14 +80,17 @@ export const TableFloatingColumnControls = ({
|
|
|
76
80
|
return null;
|
|
77
81
|
}
|
|
78
82
|
const colWidths = getColumnsWidths(editorView);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
if (stickyTop) {
|
|
84
|
+
var _rowHeights$, _containerRef$current;
|
|
85
|
+
const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
86
|
+
containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('top', `${stickyTop - headerRowHeight + 33}px` // 33px is padding and margin applied on tr.sticky
|
|
87
|
+
);
|
|
88
|
+
} else {
|
|
89
|
+
var _containerRef$current2;
|
|
90
|
+
containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.removeProperty('top');
|
|
85
91
|
}
|
|
86
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
ref: containerRef,
|
|
87
94
|
className: ClassName.DRAG_COLUMN_CONTROLS_WRAPPER,
|
|
88
95
|
"data-testid": "table-floating-column-controls-wrapper"
|
|
89
96
|
}, /*#__PURE__*/React.createElement(ColumnControls, {
|
|
@@ -99,7 +106,9 @@ export const TableFloatingColumnControls = ({
|
|
|
99
106
|
rowHeights: rowHeights,
|
|
100
107
|
colWidths: colWidths,
|
|
101
108
|
hasHeaderColumn: hasHeaderColumn,
|
|
102
|
-
canDrag: canDrag
|
|
109
|
+
canDrag: canDrag,
|
|
110
|
+
tableContainerWidth: tableContainerWidth,
|
|
111
|
+
isNumberColumnEnabled: isNumberColumnEnabled
|
|
103
112
|
}), hasDropTargets && /*#__PURE__*/React.createElement(ColumnDropTargets, {
|
|
104
113
|
tableRef: tableRef,
|
|
105
114
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { tableMarginTop, tableSharedStyle } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, MAX_BROWSER_SCROLLBAR_HEIGHT, relativeFontSizeToBase16, SelectionStyle } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { akEditorFloatingDialogZIndex, akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, MAX_BROWSER_SCROLLBAR_HEIGHT, relativeFontSizeToBase16, SelectionStyle } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
@@ -940,6 +940,11 @@ export const tableStyles = props => css`
|
|
|
940
940
|
top: ${tableMarginTop}px;
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
+
.${ClassName.TABLE_STICKY} .${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
|
|
944
|
+
position: fixed;
|
|
945
|
+
z-index: ${akEditorFloatingDialogZIndex};
|
|
946
|
+
}
|
|
947
|
+
|
|
943
948
|
${tableWrapperStyles()}
|
|
944
949
|
}
|
|
945
950
|
|
|
@@ -8,6 +8,7 @@ import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
10
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
13
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
13
14
|
const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
|
|
@@ -43,40 +44,53 @@ export const createControlsHoverDecoration = (cells, type, tr, isDragAndDropEnab
|
|
|
43
44
|
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
44
45
|
// to match the "clicked" selection
|
|
45
46
|
|
|
46
|
-
if (danger) {
|
|
47
|
-
|
|
48
|
-
// merged cells.
|
|
49
|
-
const {
|
|
50
|
-
recLeft,
|
|
51
|
-
recTop,
|
|
52
|
-
recRight,
|
|
53
|
-
recBottom
|
|
54
|
-
} = cells.reduce((acc, cell) => {
|
|
47
|
+
if (getBooleanFF('platform.editor.table.in-danger-hover-merged-cells-fix')) {
|
|
48
|
+
if (danger && type !== 'table') {
|
|
55
49
|
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
50
|
+
selection
|
|
51
|
+
} = tr;
|
|
52
|
+
const table = findTable(selection);
|
|
53
|
+
const rect = getSelectionRect(selection);
|
|
54
|
+
if (table && rect) {
|
|
55
|
+
updatedCells = map.cellsInRect(rect).map(x => x + table.start);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
if (danger) {
|
|
60
|
+
// Find the bounding rectangle of all the given cells, also considering
|
|
61
|
+
// merged cells.
|
|
62
|
+
const {
|
|
63
|
+
recLeft,
|
|
64
|
+
recTop,
|
|
65
|
+
recRight,
|
|
66
|
+
recBottom
|
|
67
|
+
} = cells.reduce((acc, cell) => {
|
|
68
|
+
const {
|
|
69
|
+
left,
|
|
70
|
+
right,
|
|
71
|
+
bottom,
|
|
72
|
+
top
|
|
73
|
+
} = map.findCell(cell.pos - table.start);
|
|
74
|
+
// Finding the bounding rect requires finding the min left and top positions,
|
|
75
|
+
// and the max right and bottom positions of the cells
|
|
76
|
+
return {
|
|
77
|
+
recLeft: Math.min(acc.recLeft, left),
|
|
78
|
+
recTop: Math.min(acc.recTop, top),
|
|
79
|
+
recRight: Math.max(acc.recRight, right),
|
|
80
|
+
recBottom: Math.max(acc.recBottom, bottom)
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
// +-Infinity as initialisation vars which will always be overwritten
|
|
84
|
+
// by smaller/larger values respectively
|
|
85
|
+
{
|
|
86
|
+
recLeft: Infinity,
|
|
87
|
+
recTop: Infinity,
|
|
88
|
+
recRight: -Infinity,
|
|
89
|
+
recBottom: -Infinity
|
|
90
|
+
});
|
|
91
|
+
const rect = new Rect(recLeft, recTop, recRight, recBottom);
|
|
92
|
+
updatedCells = map.cellsInRect(rect).map(x => x + table.start);
|
|
93
|
+
}
|
|
80
94
|
}
|
|
81
95
|
return updatedCells.map(pos => {
|
|
82
96
|
const cell = tr.doc.nodeAt(pos);
|
package/dist/es2019/utils/dom.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { closestElement, containsClassName } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { TableCssClassName as ClassName } from '../types';
|
|
3
|
-
import { tableToolbarSize } from '../ui/consts';
|
|
4
3
|
const SELECTOR_TABLE_LEAFS = `.${ClassName.TABLE_CELL}, .${ClassName.TABLE_HEADER_CELL}`;
|
|
5
4
|
export const isCell = node => {
|
|
6
5
|
return Boolean(node && (['TH', 'TD'].indexOf(node.tagName) > -1 || !!closestElement(node, `.${ClassName.TABLE_HEADER_CELL}`) || !!closestElement(node, `.${ClassName.TABLE_CELL}`)));
|
|
@@ -116,23 +115,6 @@ export const getMousePositionVerticalRelativeByElement = mouseEvent => {
|
|
|
116
115
|
}
|
|
117
116
|
return null;
|
|
118
117
|
};
|
|
119
|
-
|
|
120
|
-
// This function is deprecated
|
|
121
|
-
export const updateResizeHandles = tableRef => {
|
|
122
|
-
if (!tableRef) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// see ED-7600
|
|
127
|
-
const nodes = Array.from(tableRef.querySelectorAll(`.${ClassName.RESIZE_HANDLE}`));
|
|
128
|
-
if (!nodes || !nodes.length) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const height = tableRef.offsetHeight + tableToolbarSize;
|
|
132
|
-
nodes.forEach(node => {
|
|
133
|
-
node.style.height = `${height}px`;
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
118
|
export const hasResizeHandler = ({
|
|
137
119
|
columnEndIndexTarget,
|
|
138
120
|
target
|
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement,
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
|
|
6
6
|
export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
8
|
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
@@ -34,7 +34,7 @@ export function addColumnAt(getEditorContainerWidth) {
|
|
|
34
34
|
var table = findTable(updatedTr.selection);
|
|
35
35
|
if (table) {
|
|
36
36
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
37
|
-
updatedTr = rescaleColumns(
|
|
37
|
+
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
38
38
|
}
|
|
39
39
|
if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
40
40
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -14,7 +14,7 @@ import classnames from 'classnames';
|
|
|
14
14
|
import memoizeOne from 'memoize-one';
|
|
15
15
|
import rafSchedule from 'raf-schd';
|
|
16
16
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
17
|
-
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
17
|
+
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
18
18
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
19
19
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
20
20
|
import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
@@ -554,6 +554,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
554
554
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
555
555
|
stickyHeader: this.state.stickyHeader
|
|
556
556
|
});
|
|
557
|
+
var tableContainerWidth = getTableContainerWidth(node);
|
|
557
558
|
var colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
|
|
558
559
|
editorView: view,
|
|
559
560
|
tableRef: tableRef,
|
|
@@ -572,7 +573,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
572
573
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
573
574
|
stickyHeader: this.state.stickyHeader,
|
|
574
575
|
canDrag: canDrag,
|
|
575
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
576
|
+
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
577
|
+
tableContainerWidth: tableContainerWidth,
|
|
578
|
+
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled
|
|
576
579
|
}) : null;
|
|
577
580
|
var shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
578
581
|
var shadowStyle = memoizeOne(function (visible) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -352,7 +352,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
352
352
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
353
353
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
354
354
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
355
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
355
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
356
|
+
stickyHeaders: stickyHeader
|
|
356
357
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
357
358
|
editorView: editorView,
|
|
358
359
|
selection: editorView.state.selection,
|
|
@@ -7,8 +7,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes } from '@atlaskit/editor-common/transforms';
|
|
8
8
|
import { browser, closestElement } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
10
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
13
11
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
14
12
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
@@ -18,7 +16,7 @@ import TableRow from '../nodeviews/TableRow';
|
|
|
18
16
|
import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
|
|
19
17
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
20
18
|
import { TableCssClassName as ClassName } from '../types';
|
|
21
|
-
import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable
|
|
19
|
+
import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable } from '../utils';
|
|
22
20
|
import { isHeaderRowRequired } from '../utils/paste';
|
|
23
21
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
24
22
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
@@ -107,24 +105,15 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
107
105
|
var selection = state.selection;
|
|
108
106
|
var pluginState = getPluginState(state);
|
|
109
107
|
var tableRef;
|
|
110
|
-
var tableNode;
|
|
111
108
|
if (pluginState.editorHasFocus) {
|
|
112
109
|
var parent = findParentDomRefOfType(state.schema.nodes.table, domAtPos)(selection);
|
|
113
110
|
if (parent) {
|
|
114
111
|
tableRef = parent.querySelector('table') || undefined;
|
|
115
112
|
}
|
|
116
|
-
tableNode = findTable(state.selection);
|
|
117
113
|
}
|
|
118
114
|
if (pluginState.tableRef !== tableRef) {
|
|
119
115
|
setTableRef(tableRef)(state, dispatch);
|
|
120
116
|
}
|
|
121
|
-
|
|
122
|
-
// Removes updateResizeHandles
|
|
123
|
-
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
124
|
-
if (pluginState.tableNode !== tableNode) {
|
|
125
|
-
updateResizeHandles(tableRef);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
117
|
if (pluginState.editorHasFocus && pluginState.tableRef) {
|
|
129
118
|
var _ref = state.selection,
|
|
130
119
|
$cursor = _ref.$cursor;
|
|
@@ -7,7 +7,7 @@ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
9
9
|
import { updateColumnWidths } from '../../transforms';
|
|
10
|
-
import { getSelectedColumnIndexes
|
|
10
|
+
import { getSelectedColumnIndexes } from '../../utils';
|
|
11
11
|
import { META_KEYS } from '../table-analytics';
|
|
12
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
13
13
|
import { getPluginState } from './plugin-factory';
|
|
@@ -145,10 +145,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
145
145
|
var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
|
|
146
146
|
resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
|
|
147
147
|
updateControls()(state);
|
|
148
|
-
// Remove updateResizeHandles
|
|
149
|
-
if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
|
|
150
|
-
updateResizeHandles(dom);
|
|
151
|
-
}
|
|
152
148
|
}
|
|
153
149
|
window.addEventListener('mouseup', finish);
|
|
154
150
|
window.addEventListener('mousemove', move);
|
|
@@ -3,13 +3,11 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
|
-
import {
|
|
7
|
-
import { TableMap, tableNewColumnMinWidth } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
10
9
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
11
|
-
import {
|
|
12
|
-
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
10
|
+
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
13
11
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
14
12
|
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
15
13
|
|
|
@@ -89,7 +87,7 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
89
87
|
* @param view
|
|
90
88
|
* @returns Updated transaction with rescaled columns for a given table
|
|
91
89
|
*/
|
|
92
|
-
export var
|
|
90
|
+
export var rescaleColumns = function rescaleColumns() {
|
|
93
91
|
return function (table, view) {
|
|
94
92
|
return function (tr) {
|
|
95
93
|
var _tableRef$parentEleme, _tableRef$parentEleme2;
|
|
@@ -109,7 +107,7 @@ export var rescaleColumnsNew = function rescaleColumnsNew() {
|
|
|
109
107
|
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
110
108
|
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
111
109
|
/** the is the width the table can reach before overflowing */
|
|
112
|
-
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0 : ((tableRef === null || tableRef === void 0 || (_tableRef$parentEleme2 = tableRef.parentElement) === null || _tableRef$parentEleme2 === void 0 ? void 0 : _tableRef$parentEleme2.clientWidth) || 0) - insertColumnButtonOffset
|
|
110
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0 : ((tableRef === null || tableRef === void 0 || (_tableRef$parentEleme2 = tableRef.parentElement) === null || _tableRef$parentEleme2 === void 0 ? void 0 : _tableRef$parentEleme2.clientWidth) || 0) - insertColumnButtonOffset,
|
|
113
111
|
isResized: isResized
|
|
114
112
|
};
|
|
115
113
|
|
|
@@ -169,104 +167,4 @@ export var rescaleColumnsNew = function rescaleColumnsNew() {
|
|
|
169
167
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
170
168
|
};
|
|
171
169
|
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* This function is called when user inserts/deletes a column in a table to;
|
|
176
|
-
* - rescale all columns (if the table did not overflow before the insertion)
|
|
177
|
-
* - and update column widths.
|
|
178
|
-
*
|
|
179
|
-
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
180
|
-
* @param table
|
|
181
|
-
* @param view
|
|
182
|
-
* @returns Updated transaction with rescaled columns for a given table
|
|
183
|
-
*/
|
|
184
|
-
export var rescaleColumnsOld = function rescaleColumnsOld(getEditorContainerWidth) {
|
|
185
|
-
return function (table, view) {
|
|
186
|
-
return function (tr) {
|
|
187
|
-
var _tableRef$parentEleme3;
|
|
188
|
-
if (!view) {
|
|
189
|
-
return tr;
|
|
190
|
-
}
|
|
191
|
-
var pos = table.pos;
|
|
192
|
-
var newTable = tr.doc.nodeAt(pos);
|
|
193
|
-
var state = view.state;
|
|
194
|
-
var domAtPos = view.domAtPos.bind(view);
|
|
195
|
-
var maybeTable = domAtPos(table.start).node;
|
|
196
|
-
var tableRef = maybeTable.closest('table');
|
|
197
|
-
if (!tableRef || !newTable) {
|
|
198
|
-
return tr;
|
|
199
|
-
}
|
|
200
|
-
var layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
|
|
201
|
-
// The is the width the table can reach before overflowing
|
|
202
|
-
var maxSize = getTableMaxWidth({
|
|
203
|
-
table: table.node,
|
|
204
|
-
tableStart: table.start,
|
|
205
|
-
state: state,
|
|
206
|
-
layout: layout,
|
|
207
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
208
|
-
});
|
|
209
|
-
var tableWidth = tableRef.clientWidth || akEditorDefaultLayoutWidth;
|
|
210
|
-
var tableMaxWidth = (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme3 = tableRef.parentElement) === null || _tableRef$parentEleme3 === void 0 ? void 0 : _tableRef$parentEleme3.clientWidth) || 0;
|
|
211
|
-
tableMaxWidth -= insertColumnButtonOffset;
|
|
212
|
-
var newTableMap = TableMap.get(newTable);
|
|
213
|
-
var noOfColumns = newTableMap.width;
|
|
214
|
-
if (!noOfColumns || noOfColumns <= 0) {
|
|
215
|
-
return tr;
|
|
216
|
-
}
|
|
217
|
-
var columnWidthUnresized = tableWidth / noOfColumns;
|
|
218
|
-
|
|
219
|
-
// If the table has not been resized, and the column width is bigger than the minimum column width
|
|
220
|
-
// we skip updating the size of columns here.
|
|
221
|
-
if (!hasTableBeenResized(table.node) && columnWidthUnresized > tableCellMinWidth) {
|
|
222
|
-
return tr;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// If the table has not been resized, and the column width is smaller than the minimum column width
|
|
226
|
-
// Or if the table has been resized, but each column width is either 48px or null
|
|
227
|
-
// we update the table to have 48px for each column
|
|
228
|
-
if (!hasTableBeenResized(table.node) && columnWidthUnresized <= tableCellMinWidth || hasTableBeenResized(table.node) && isMinCellWidthTable(table.node)) {
|
|
229
|
-
var widths = new Array(noOfColumns).fill(tableCellMinWidth);
|
|
230
|
-
var cols = widths.map(function (_, index) {
|
|
231
|
-
return {
|
|
232
|
-
width: tableCellMinWidth,
|
|
233
|
-
minWidth: tableCellMinWidth,
|
|
234
|
-
index: index
|
|
235
|
-
};
|
|
236
|
-
});
|
|
237
|
-
var overflow = tableWidth > maxSize;
|
|
238
|
-
var minWidthResizeState = {
|
|
239
|
-
cols: cols,
|
|
240
|
-
widths: widths,
|
|
241
|
-
maxSize: maxSize,
|
|
242
|
-
tableWidth: tableWidth,
|
|
243
|
-
overflow: overflow
|
|
244
|
-
};
|
|
245
|
-
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
246
|
-
}
|
|
247
|
-
var resizeState = getResizeState({
|
|
248
|
-
minWidth: tableCellMinWidth,
|
|
249
|
-
table: table.node,
|
|
250
|
-
start: table.start,
|
|
251
|
-
tableRef: tableRef,
|
|
252
|
-
domAtPos: domAtPos,
|
|
253
|
-
maxSize: maxSize
|
|
254
|
-
});
|
|
255
|
-
var previousTableWidth = resizeState.tableWidth - tableNewColumnMinWidth;
|
|
256
|
-
var tableDidntPreviouslyOverflow = previousTableWidth <= Math.max(maxSize, tableMaxWidth);
|
|
257
|
-
|
|
258
|
-
// If the new table width will result in the table going into an overflow state
|
|
259
|
-
// we resize the cells to avoid the overflow occuring
|
|
260
|
-
if (tableDidntPreviouslyOverflow && resizeState.overflow) {
|
|
261
|
-
resizeState = scaleTableTo(resizeState, maxSize);
|
|
262
|
-
}
|
|
263
|
-
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
268
|
-
if (getBooleanFF('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
269
|
-
return rescaleColumnsNew();
|
|
270
|
-
}
|
|
271
|
-
return rescaleColumnsOld(getEditorContainerWidth);
|
|
272
170
|
};
|
|
@@ -7,7 +7,6 @@ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics
|
|
|
7
7
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
12
11
|
import { rescaleColumns } from './column-width';
|
|
13
12
|
import { splitCellsInColumns } from './split';
|
|
@@ -217,10 +216,8 @@ export var deleteColumns = function deleteColumns(rect, allowCustomStep, view) {
|
|
|
217
216
|
updatedTr = deleteColumnsLegacy(rect)(updatedTr);
|
|
218
217
|
}
|
|
219
218
|
var table = findTable(updatedTr.selection);
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
223
|
-
}
|
|
219
|
+
if (table) {
|
|
220
|
+
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
224
221
|
}
|
|
225
222
|
return updatedTr;
|
|
226
223
|
};
|
package/dist/esm/types.js
CHANGED
|
@@ -116,8 +116,6 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
116
116
|
RESIZING_PLUGIN: "".concat(tablePrefixSelector, "-resizing-plugin"),
|
|
117
117
|
RESIZE_CURSOR: "".concat(tablePrefixSelector, "-resize-cursor"),
|
|
118
118
|
IS_RESIZING: "".concat(tablePrefixSelector, "-is-resizing"),
|
|
119
|
-
// Resize handle is going to be removed together with updateResizeHandles - table's utility function
|
|
120
|
-
RESIZE_HANDLE: "".concat(tablePrefixSelector, "-resize-handle"),
|
|
121
119
|
RESIZE_HANDLE_DECORATION: "".concat(tablePrefixSelector, "-resize-decoration"),
|
|
122
120
|
CONTEXTUAL_SUBMENU: "".concat(tablePrefixSelector, "-contextual-submenu"),
|
|
123
121
|
CONTEXTUAL_MENU_BUTTON_WRAP: "".concat(tablePrefixSelector, "-contextual-menu-button-wrap"),
|