@atlaskit/editor-plugin-table 5.7.1 → 5.7.3
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 +16 -0
- 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/toolbar.js +87 -14
- 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 +49 -18
- 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/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/toolbar.js +77 -9
- 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 +42 -12
- 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/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/toolbar.js +86 -13
- 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 +45 -14
- 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/toolbar.d.ts +3 -1
- package/dist/types/types.d.ts +1 -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/toolbar.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +1 -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 +8 -8
- 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/toolbar.tsx +135 -9
- package/src/types.ts +1 -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 +53 -19
- package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -10
- 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
|
@@ -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
|
-
var _colWidths$map$join, _rowHeights
|
|
38
|
-
const
|
|
41
|
+
var _colWidths$map$join, _rowHeights$;
|
|
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,14 +112,32 @@ export const ColumnControls = ({
|
|
|
104
112
|
const colIndexes = useMemo(() => {
|
|
105
113
|
return [colIndex];
|
|
106
114
|
}, [colIndex]);
|
|
107
|
-
const
|
|
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]);
|
|
108
133
|
const generateHandleByType = type => {
|
|
109
|
-
var _colWidths;
|
|
134
|
+
var _rowHeights$reduce, _colWidths;
|
|
110
135
|
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
111
136
|
return null;
|
|
112
137
|
}
|
|
113
138
|
const isHover = type === 'hover';
|
|
114
139
|
const isColumnsSelected = selectedColIndexes.length > 0;
|
|
140
|
+
const previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce((sum, cur) => sum + cur, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
115
141
|
const showCondition = isHover ? isColumnsSelected && !selectedColIndexes.includes(colIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedColIndexes.length < (colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
116
142
|
if (!showCondition) {
|
|
117
143
|
return null;
|
|
@@ -119,15 +145,15 @@ export const ColumnControls = ({
|
|
|
119
145
|
const gridColumnPosition = `${colIndex + 1} / span 1`;
|
|
120
146
|
const selectedColumnPosition = `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`;
|
|
121
147
|
const hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
122
|
-
const
|
|
123
|
-
const
|
|
148
|
+
const currentSelectionAppearance = isColumnsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
149
|
+
const isSelecting = isColumnsSelected && !isHover;
|
|
124
150
|
|
|
125
151
|
// this indexes are used to calculate the drag and drop source
|
|
126
152
|
const indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
127
153
|
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
128
154
|
key: type,
|
|
129
155
|
style: {
|
|
130
|
-
gridColumn:
|
|
156
|
+
gridColumn: isSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
131
157
|
display: 'flex',
|
|
132
158
|
justifyContent: 'center',
|
|
133
159
|
alignItems: 'center',
|
|
@@ -145,7 +171,7 @@ export const ColumnControls = ({
|
|
|
145
171
|
forceDefaultHandle: isHover ? false : isColumnsSelected,
|
|
146
172
|
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : tableCellMinWidth,
|
|
147
173
|
previewHeight: previewHeight,
|
|
148
|
-
appearance:
|
|
174
|
+
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
149
175
|
onClick: handleClick,
|
|
150
176
|
onMouseOver: handleMouseOver,
|
|
151
177
|
onMouseOut: handleMouseOut,
|
|
@@ -164,22 +190,26 @@ 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,
|
|
179
209
|
endIndex
|
|
180
210
|
}, index) => /*#__PURE__*/React.createElement("div", {
|
|
181
211
|
style: {
|
|
182
|
-
gridColumn: `${
|
|
212
|
+
gridColumn: `${startIndex + 1} / span 1`
|
|
183
213
|
},
|
|
184
214
|
"data-start-index": startIndex,
|
|
185
215
|
"data-end-index": endIndex,
|
|
@@ -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';
|
|
@@ -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);
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -10,8 +10,12 @@ import { closestElement, getChildrenInfo as _getChildrenInfo, getNodeName, isRef
|
|
|
10
10
|
import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
12
12
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
13
|
+
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
13
14
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType, splitCell } from '@atlaskit/editor-tables/utils';
|
|
15
|
+
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
14
16
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
17
|
+
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
18
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
19
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
|
|
16
20
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
17
21
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
@@ -49,16 +53,30 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
|
|
|
49
53
|
disabled: !state.canCollapseTable,
|
|
50
54
|
hidden: !config.allowCollapse
|
|
51
55
|
}];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
if (state.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling')) {
|
|
57
|
+
return {
|
|
58
|
+
id: 'editor.table.tableOptions',
|
|
59
|
+
type: 'dropdown',
|
|
60
|
+
testId: 'table_options',
|
|
61
|
+
icon: TableOptionsIcon,
|
|
62
|
+
title: formatMessage(messages.tableOptions),
|
|
63
|
+
hidden: options.every(function (option) {
|
|
64
|
+
return option.hidden;
|
|
65
|
+
}),
|
|
66
|
+
options: options
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
return {
|
|
70
|
+
id: 'editor.table.tableOptions',
|
|
71
|
+
type: 'dropdown',
|
|
72
|
+
testId: 'table_options',
|
|
73
|
+
title: formatMessage(messages.tableOptions),
|
|
74
|
+
hidden: options.every(function (option) {
|
|
75
|
+
return option.hidden;
|
|
76
|
+
}),
|
|
77
|
+
options: options
|
|
78
|
+
};
|
|
79
|
+
}
|
|
62
80
|
};
|
|
63
81
|
|
|
64
82
|
// Added these options for mobile. Mobile bridge translates this menu and
|
|
@@ -257,6 +275,16 @@ export var getClosestSelectionRect = function getClosestSelectionRect(state) {
|
|
|
257
275
|
var selection = state.selection;
|
|
258
276
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
259
277
|
};
|
|
278
|
+
export var getClosestSelectionOrTableRect = function getClosestSelectionOrTableRect(state) {
|
|
279
|
+
var selection = state.selection;
|
|
280
|
+
var tableObject = findTable(state.selection);
|
|
281
|
+
if (!tableObject) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
var map = TableMap.get(tableObject.node);
|
|
285
|
+
var tableRect = new Rect(0, 0, map.width, map.height);
|
|
286
|
+
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
287
|
+
};
|
|
260
288
|
export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
|
|
261
289
|
return function (config) {
|
|
262
290
|
return function (state, intl) {
|
|
@@ -272,6 +300,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
272
300
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
273
301
|
var cellItems;
|
|
274
302
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI);
|
|
303
|
+
var columnSettingsItems;
|
|
304
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI) : [];
|
|
275
305
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
276
306
|
|
|
277
307
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -324,7 +354,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
324
354
|
},
|
|
325
355
|
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
326
356
|
// Place the context menu slightly above the others
|
|
327
|
-
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), colorPicker, [{
|
|
357
|
+
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), colorPicker, [{
|
|
328
358
|
type: 'extensions-placeholder',
|
|
329
359
|
separator: 'end'
|
|
330
360
|
}, {
|
|
@@ -379,9 +409,52 @@ var getCellItems = function getCellItems(pluginConfig, state, view, _ref3, getEd
|
|
|
379
409
|
}
|
|
380
410
|
return [];
|
|
381
411
|
};
|
|
382
|
-
var
|
|
383
|
-
|
|
412
|
+
export var getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
413
|
+
return function (state, dispatch, editorView) {
|
|
414
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
415
|
+
if (!editorView || !selectionOrTableRect) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
419
|
+
if (newResizeStateWithAnalytics) {
|
|
420
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
return false;
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
// this create the button group for distribute column and also fixed column width
|
|
428
|
+
// fixed column button should be in this function call in the future
|
|
429
|
+
var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
430
|
+
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
384
431
|
var formatMessage = _ref4.formatMessage;
|
|
432
|
+
var pluginState = getPluginState(editorState);
|
|
433
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
434
|
+
if (!selectionOrTableRect || !editorView) {
|
|
435
|
+
return [];
|
|
436
|
+
}
|
|
437
|
+
var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
438
|
+
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
439
|
+
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
440
|
+
return [{
|
|
441
|
+
id: 'editor.table.distributeColumns',
|
|
442
|
+
type: 'button',
|
|
443
|
+
title: formatMessage(messages.distributeColumns),
|
|
444
|
+
icon: DistributeColumnIcon,
|
|
445
|
+
onClick: function onClick(state, dispatch, view) {
|
|
446
|
+
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI)(state, dispatch, view);
|
|
447
|
+
},
|
|
448
|
+
disabled: !wouldChange
|
|
449
|
+
}, {
|
|
450
|
+
type: 'separator'
|
|
451
|
+
}];
|
|
452
|
+
}
|
|
453
|
+
return [];
|
|
454
|
+
};
|
|
455
|
+
var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
|
|
456
|
+
var _node$attrs;
|
|
457
|
+
var formatMessage = _ref5.formatMessage;
|
|
385
458
|
var _getPluginState2 = getPluginState(state),
|
|
386
459
|
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
387
460
|
pluginConfig = _getPluginState2.pluginConfig;
|
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"),
|