@atlaskit/editor-plugin-table 7.9.0 → 7.10.1
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 +12 -0
- package/dist/cjs/commands/column-resize.js +25 -7
- package/dist/cjs/nodeviews/TableComponent.js +11 -3
- package/dist/cjs/nodeviews/TableRow.js +1 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +4 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +9 -7
- package/dist/cjs/transforms/column-width.js +3 -1
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +19 -6
- package/dist/cjs/utils/index.js +12 -0
- package/dist/cjs/utils/nodes.js +6 -1
- package/dist/cjs/utils/table.js +34 -1
- package/dist/es2019/commands/column-resize.js +25 -7
- package/dist/es2019/nodeviews/TableComponent.js +12 -4
- package/dist/es2019/nodeviews/TableRow.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +4 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +9 -7
- package/dist/es2019/transforms/column-width.js +3 -1
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +19 -6
- package/dist/es2019/utils/index.js +2 -2
- package/dist/es2019/utils/nodes.js +5 -0
- package/dist/es2019/utils/table.js +36 -1
- package/dist/esm/commands/column-resize.js +25 -7
- package/dist/esm/nodeviews/TableComponent.js +12 -4
- package/dist/esm/nodeviews/TableRow.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +4 -4
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +5 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +9 -7
- package/dist/esm/transforms/column-width.js +3 -1
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +19 -6
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/nodes.js +5 -0
- package/dist/esm/utils/table.js +33 -0
- package/dist/types/commands/column-resize.d.ts +5 -4
- package/dist/types/nodeviews/TableComponent.d.ts +6 -54
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +16 -20
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +32 -40
- package/dist/types/ui/TableFloatingControls/index.d.ts +16 -20
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/nodes.d.ts +1 -0
- package/dist/types/utils/table.d.ts +3 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +5 -4
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -54
- package/dist/types-ts4.5/plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +16 -20
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +32 -40
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +16 -20
- package/dist/types-ts4.5/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/nodes.d.ts +1 -0
- package/dist/types-ts4.5/utils/table.d.ts +3 -0
- package/package.json +4 -1
- package/src/commands/column-resize.ts +42 -11
- package/src/nodeviews/TableComponent.tsx +21 -6
- package/src/nodeviews/TableRow.ts +2 -2
- package/src/plugin.tsx +1 -1
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +5 -5
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +7 -5
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +16 -10
- package/src/transforms/column-width.ts +10 -2
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +28 -11
- package/src/utils/index.ts +2 -1
- package/src/utils/nodes.ts +10 -0
- package/src/utils/table.ts +36 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
2
2
|
import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { getSelectedTableInfo } from '../../../utils';
|
|
5
6
|
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
6
7
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
@@ -72,8 +73,8 @@ export const getResizeState = ({
|
|
|
72
73
|
|
|
73
74
|
// updates Colgroup DOM node with new widths
|
|
74
75
|
export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
|
|
75
|
-
const cols = tableRef.querySelectorAll('col');
|
|
76
|
-
const columnsCount = cols.length;
|
|
76
|
+
const cols = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelectorAll('col');
|
|
77
|
+
const columnsCount = cols === null || cols === void 0 ? void 0 : cols.length;
|
|
77
78
|
/**
|
|
78
79
|
updateColgroup will update whole table scale when click the column resize handle, this behavior will affect when table overflowed, when now resize handle been dragged and extend to make table overflowed, table will show overflow. This need to be confirmed because it conflict with how isTableScalingEnabled work.
|
|
79
80
|
We don't want to scale the table when resizing columns, only when viewpoint shrinks the table.
|
|
@@ -83,19 +84,19 @@ export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled
|
|
|
83
84
|
const scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
84
85
|
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
85
86
|
.forEach((column, i) => {
|
|
86
|
-
const fixedColWidth = getColWidthFix(column.width, columnsCount);
|
|
87
|
+
const fixedColWidth = getColWidthFix(column.width, columnsCount !== null && columnsCount !== void 0 ? columnsCount : 0);
|
|
87
88
|
const scaledWidth = fixedColWidth * scalePercent;
|
|
88
89
|
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
89
90
|
// we aren't handling the remaining pixels here when the 48px min width is reached
|
|
90
|
-
if (cols[i]) {
|
|
91
|
+
if (cols !== null && cols !== void 0 && cols[i]) {
|
|
91
92
|
cols[i].style.width = `${finalWidth}px`;
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
} else {
|
|
95
96
|
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
96
97
|
.forEach((column, i) => {
|
|
97
|
-
if (cols[i]) {
|
|
98
|
-
cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
|
|
98
|
+
if (cols !== null && cols !== void 0 && cols[i]) {
|
|
99
|
+
cols[i].style.width = `${getColWidthFix(column.width, columnsCount !== null && columnsCount !== void 0 ? columnsCount : 0)}px`;
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
@@ -290,7 +291,8 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
|
|
|
290
291
|
return;
|
|
291
292
|
}
|
|
292
293
|
const maybeTable = domAtPos(table.start).node;
|
|
293
|
-
const
|
|
294
|
+
const maybeTableElement = maybeTable instanceof HTMLElement ? maybeTable : null;
|
|
295
|
+
const tableRef = getBooleanFF('platform.editor.explicit-html-element-check') ? maybeTableElement === null || maybeTableElement === void 0 ? void 0 : maybeTableElement.closest('table') : maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.closest('table');
|
|
294
296
|
if (!tableRef) {
|
|
295
297
|
return;
|
|
296
298
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
5
6
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
6
7
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -94,7 +95,8 @@ export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) =
|
|
|
94
95
|
const newTable = tr.doc.nodeAt(table.pos);
|
|
95
96
|
const domAtPos = view.domAtPos.bind(view);
|
|
96
97
|
const maybeTable = domAtPos(table.start).node;
|
|
97
|
-
const
|
|
98
|
+
const maybeTableElement = getBooleanFF('platform.editor.explicit-html-element-check') ? maybeTable instanceof HTMLElement ? maybeTable : null : maybeTable;
|
|
99
|
+
const tableRef = maybeTableElement === null || maybeTableElement === void 0 ? void 0 : maybeTableElement.closest('table');
|
|
98
100
|
if (!tableRef || !newTable) {
|
|
99
101
|
return tr;
|
|
100
102
|
}
|
|
@@ -4,6 +4,7 @@ import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'reac
|
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
9
|
import { clearHoverSelection } from '../../../commands';
|
|
9
10
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
@@ -90,14 +91,26 @@ const DragControlsComponent = ({
|
|
|
90
91
|
}
|
|
91
92
|
}, [editorView, tableActive]);
|
|
92
93
|
const handleMouseMove = useCallback(e => {
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
if (getBooleanFF('platform.editor.explicit-html-element-check')) {
|
|
95
|
+
const target = e.nativeEvent.target instanceof Element ? e.nativeEvent.target : null;
|
|
96
|
+
const isParentDragControls = target === null || target === void 0 ? void 0 : target.closest(`.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
97
|
+
const rowIndex = target === null || target === void 0 ? void 0 : target.getAttribute('data-start-index');
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// avoid updating if event target is not related
|
|
100
|
+
if (!isParentDragControls || !rowIndex) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
updateCellHoverLocation(Number(rowIndex));
|
|
104
|
+
} else {
|
|
105
|
+
const isParentDragControls = e.nativeEvent.target.closest(`.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
106
|
+
const rowIndex = e.nativeEvent.target.getAttribute('data-start-index');
|
|
107
|
+
|
|
108
|
+
// avoid updating if event target is not related
|
|
109
|
+
if (!isParentDragControls || !rowIndex) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
updateCellHoverLocation(Number(rowIndex));
|
|
99
113
|
}
|
|
100
|
-
updateCellHoverLocation(Number(rowIndex));
|
|
101
114
|
}, [updateCellHoverLocation]);
|
|
102
115
|
const rowIndexes = useMemo(() => {
|
|
103
116
|
return [rowIndex];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
|
-
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
3
|
+
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
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';
|
|
9
|
-
export { getMergedCellsPositions } from './table';
|
|
9
|
+
export { getMergedCellsPositions, getAssistiveMessage } from './table';
|
|
10
10
|
export { updatePluginStateDecorations } from './update-plugin-state-decorations';
|
|
11
11
|
export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells } from './merged-cells';
|
|
12
12
|
export { createTableWithWidth } from './create';
|
|
@@ -57,6 +57,11 @@ export const tablesHaveDifferentNoOfColumns = (currentTable, previousTable) => {
|
|
|
57
57
|
const currentMap = TableMap.get(currentTable);
|
|
58
58
|
return prevMap.width !== currentMap.width;
|
|
59
59
|
};
|
|
60
|
+
export const tablesHaveDifferentNoOfRows = (currentTable, previousTable) => {
|
|
61
|
+
const prevMap = TableMap.get(previousTable);
|
|
62
|
+
const currentMap = TableMap.get(currentTable);
|
|
63
|
+
return prevMap.height !== currentMap.height;
|
|
64
|
+
};
|
|
60
65
|
function filterNearSelection(selection, findNode, predicate, defaultValue) {
|
|
61
66
|
const found = findNode(selection);
|
|
62
67
|
if (!found) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
1
2
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
3
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
4
|
export const getMergedCellsPositions = tr => {
|
|
@@ -22,4 +23,38 @@ export const colsToRect = (cols, noOfRows) => ({
|
|
|
22
23
|
right: Math.max(...cols) + 1,
|
|
23
24
|
top: 0,
|
|
24
25
|
bottom: noOfRows
|
|
25
|
-
});
|
|
26
|
+
});
|
|
27
|
+
export const getAssistiveMessage = (prevTableNode, currentTableNode, intl) => {
|
|
28
|
+
const {
|
|
29
|
+
formatMessage
|
|
30
|
+
} = intl;
|
|
31
|
+
const prevTableMap = TableMap.get(prevTableNode);
|
|
32
|
+
const currentTableMap = TableMap.get(currentTableNode);
|
|
33
|
+
if (currentTableMap.width !== prevTableMap.width) {
|
|
34
|
+
const diff = Math.abs(currentTableMap.width - prevTableMap.width);
|
|
35
|
+
if (currentTableMap.width > prevTableMap.width) {
|
|
36
|
+
return formatMessage(messages.columnsAreInserted, {
|
|
37
|
+
count: diff
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (currentTableMap.width < prevTableMap.width) {
|
|
41
|
+
return formatMessage(messages.columnsAreRemoved, {
|
|
42
|
+
count: diff
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (currentTableMap.height !== prevTableMap.height) {
|
|
47
|
+
const diff = Math.abs(currentTableMap.height - prevTableMap.height);
|
|
48
|
+
if (currentTableMap.height > prevTableMap.height) {
|
|
49
|
+
return formatMessage(messages.rowsAreInserted, {
|
|
50
|
+
count: diff
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (currentTableMap.height < prevTableMap.height) {
|
|
54
|
+
return formatMessage(messages.rowsAreRemoved, {
|
|
55
|
+
count: diff
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return '';
|
|
60
|
+
};
|
|
@@ -72,7 +72,9 @@ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResiz
|
|
|
72
72
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
73
73
|
var cell = findCellClosestToPos(selection.$from);
|
|
74
74
|
if (ariaNotify && getIntl) {
|
|
75
|
-
ariaNotify(getIntl().formatMessage(messages.startedColumnResize)
|
|
75
|
+
ariaNotify(getIntl().formatMessage(messages.startedColumnResize), {
|
|
76
|
+
priority: 'important'
|
|
77
|
+
});
|
|
76
78
|
}
|
|
77
79
|
if (selectionRect && cell && view) {
|
|
78
80
|
return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
|
|
@@ -116,12 +118,16 @@ export var activateNextResizeArea = function activateNextResizeArea(_ref2) {
|
|
|
116
118
|
if (direction === 1) {
|
|
117
119
|
ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
|
|
118
120
|
direction: 'right'
|
|
119
|
-
})
|
|
121
|
+
}), {
|
|
122
|
+
priority: 'important'
|
|
123
|
+
});
|
|
120
124
|
}
|
|
121
125
|
if (direction === -1) {
|
|
122
126
|
ariaNotify(getIntl().formatMessage(messages.focusedOtherResize, {
|
|
123
127
|
direction: 'left'
|
|
124
|
-
})
|
|
128
|
+
}), {
|
|
129
|
+
priority: 'important'
|
|
130
|
+
});
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
if ($nextCell) {
|
|
@@ -170,7 +176,13 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
170
176
|
var map = TableMap.get(originalTable);
|
|
171
177
|
var domAtPos = view.domAtPos.bind(view);
|
|
172
178
|
var colIndex = map.colCount($cell.pos - tableStartPosition) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
173
|
-
var dom =
|
|
179
|
+
var dom = null;
|
|
180
|
+
if (getBooleanFF('platform.editor.explicit-html-element-check')) {
|
|
181
|
+
var domAtPosition = domAtPos(tableStartPosition);
|
|
182
|
+
dom = domAtPosition.node instanceof HTMLTableElement ? domAtPosition.node : null;
|
|
183
|
+
} else {
|
|
184
|
+
dom = domAtPos(tableStartPosition).node;
|
|
185
|
+
}
|
|
174
186
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
175
187
|
dom = dom.closest('table');
|
|
176
188
|
}
|
|
@@ -217,10 +229,14 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(_ref4) {
|
|
|
217
229
|
}));
|
|
218
230
|
if (newResizeState.cols.length === colIndex + 1) {
|
|
219
231
|
if (newResizeState.overflow === true) {
|
|
220
|
-
ariaNotify(getIntl().formatMessage(messages.columnResizeLast)
|
|
232
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeLast), {
|
|
233
|
+
priority: 'important'
|
|
234
|
+
});
|
|
221
235
|
}
|
|
222
236
|
if (newResizeState.overflow === false) {
|
|
223
|
-
ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow)
|
|
237
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow), {
|
|
238
|
+
priority: 'important'
|
|
239
|
+
});
|
|
224
240
|
}
|
|
225
241
|
}
|
|
226
242
|
}
|
|
@@ -256,7 +272,9 @@ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(_ref
|
|
|
256
272
|
return customTr.setMeta('scrollIntoView', false);
|
|
257
273
|
})(state, fakeDispatch);
|
|
258
274
|
if (ariaNotify && getIntl) {
|
|
259
|
-
ariaNotify(getIntl().formatMessage(messages.columnResizeStop)
|
|
275
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeStop), {
|
|
276
|
+
priority: 'important'
|
|
277
|
+
});
|
|
260
278
|
}
|
|
261
279
|
if (dispatch) {
|
|
262
280
|
dispatch(customTr);
|
|
@@ -17,6 +17,7 @@ import React from 'react';
|
|
|
17
17
|
import classnames from 'classnames';
|
|
18
18
|
import memoizeOne from 'memoize-one';
|
|
19
19
|
import rafSchedule from 'raf-schd';
|
|
20
|
+
import { injectIntl } from 'react-intl-next';
|
|
20
21
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
21
22
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
22
23
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
@@ -37,7 +38,7 @@ import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
|
37
38
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
38
39
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
39
40
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
40
|
-
import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
|
|
41
|
+
import { containsHeaderRow, getAssistiveMessage, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../utils';
|
|
41
42
|
import { ExternalDropTargets } from './ExternalDropTargets';
|
|
42
43
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
43
44
|
import { TableContainer } from './TableContainer';
|
|
@@ -515,6 +516,15 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
515
516
|
this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
|
|
516
517
|
}
|
|
517
518
|
var currentTable = getNode();
|
|
519
|
+
var previousTable = this.node;
|
|
520
|
+
var isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
|
|
521
|
+
var isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
|
|
522
|
+
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
523
|
+
var _this$props$pluginInj;
|
|
524
|
+
(_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify(getAssistiveMessage(previousTable, currentTable, this.props.intl), {
|
|
525
|
+
priority: 'important'
|
|
526
|
+
});
|
|
527
|
+
}
|
|
518
528
|
if (currentTable.attrs.__autoSize) {
|
|
519
529
|
// Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
|
|
520
530
|
this.handleAutoSizeDebounced();
|
|
@@ -524,8 +534,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
524
534
|
else if (allowColumnResizing && this.table && !isMediaFullscreen) {
|
|
525
535
|
// If col widths (e.g. via collab) or number of columns (e.g. delete a column) have changed,
|
|
526
536
|
// re-draw colgroup.
|
|
527
|
-
var previousTable = this.node;
|
|
528
|
-
var isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
|
|
529
537
|
if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || isNoOfColumnsChanged) {
|
|
530
538
|
var _view = this.props.view;
|
|
531
539
|
var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
@@ -786,4 +794,4 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
786
794
|
return TableComponent;
|
|
787
795
|
}(React.Component);
|
|
788
796
|
_defineProperty(TableComponent, "displayName", 'TableComponent');
|
|
789
|
-
export default TableComponent;
|
|
797
|
+
export default injectIntl(TableComponent);
|
|
@@ -396,7 +396,7 @@ var TableRow = /*#__PURE__*/function (_ref) {
|
|
|
396
396
|
this.focused = isCurrentTableSelected;
|
|
397
397
|
var wrapper = tree.wrapper;
|
|
398
398
|
var tableContainer = wrapper.parentElement;
|
|
399
|
-
var tableContentWrapper = tableContainer.parentElement;
|
|
399
|
+
var tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
400
400
|
var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
401
401
|
if (isCurrentTableSelected) {
|
|
402
402
|
this.colControlsOffset = tableControlsSpacing;
|
|
@@ -56,13 +56,13 @@ export var generateColgroup = function generateColgroup(table, tableRef) {
|
|
|
56
56
|
export var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
|
57
57
|
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
58
58
|
var shouldRemove = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
59
|
-
var colgroup = tableRef.querySelector('colgroup');
|
|
59
|
+
var colgroup = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelector('colgroup');
|
|
60
60
|
if (colgroup && shouldRemove) {
|
|
61
|
-
tableRef.removeChild(colgroup);
|
|
61
|
+
tableRef === null || tableRef === void 0 || tableRef.removeChild(colgroup);
|
|
62
62
|
}
|
|
63
|
-
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef : undefined);
|
|
63
|
+
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef !== null && tableRef !== void 0 ? tableRef : undefined : undefined);
|
|
64
64
|
if (shouldRemove) {
|
|
65
|
-
tableRef.insertBefore(colgroup, tableRef.firstChild);
|
|
65
|
+
tableRef === null || tableRef === void 0 || tableRef.insertBefore(colgroup, tableRef === null || tableRef === void 0 ? void 0 : tableRef.firstChild);
|
|
66
66
|
}
|
|
67
67
|
return colgroup.children;
|
|
68
68
|
};
|
|
@@ -93,7 +93,7 @@ export var getTableContainerElementWidth = function getTableContainerElementWidt
|
|
|
93
93
|
export var getTableScalingPercent = function getTableScalingPercent(table, tableRef) {
|
|
94
94
|
var _tableRef$parentEleme;
|
|
95
95
|
var tableWidth = getTableContainerElementWidth(table);
|
|
96
|
-
var renderWidth = ((_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || tableWidth;
|
|
96
|
+
var renderWidth = (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || tableWidth;
|
|
97
97
|
// minus 1 here to avoid any 1px scroll in Firefox
|
|
98
98
|
var scalePercent = (renderWidth - 1) / tableWidth;
|
|
99
99
|
scalePercent = Math.max(scalePercent, 1 - MAX_SCALING_PERCENT);
|
|
@@ -17,7 +17,7 @@ export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, t
|
|
|
17
17
|
var _tableRef$closest;
|
|
18
18
|
// when table initially not overflow, but enter overflow, we need to calculate the resize amount by two part, before and after overflow, before overflow should be double, after should not be double.
|
|
19
19
|
var tableWidth = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientWidth;
|
|
20
|
-
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
20
|
+
var tableContainerWidth = tableRef === null || tableRef === void 0 || (_tableRef$closest = tableRef.closest('.resizer-item')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
21
21
|
var isOverflowed = !!(tableWidth && tableContainerWidth && tableWidth > tableContainerWidth);
|
|
22
22
|
resizeAmount = amount * 2;
|
|
23
23
|
if (isOverflowed) {
|
|
@@ -48,11 +48,13 @@ export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, t
|
|
|
48
48
|
};
|
|
49
49
|
var updateTable = function updateTable(resizeAmount, tableRef, tableNode) {
|
|
50
50
|
var currentWidth = getTableContainerElementWidth(tableNode);
|
|
51
|
-
var resizingContainer = tableRef.closest(".".concat(ClassName.TABLE_RESIZER_CONTAINER));
|
|
51
|
+
var resizingContainer = tableRef === null || tableRef === void 0 ? void 0 : tableRef.closest(".".concat(ClassName.TABLE_RESIZER_CONTAINER));
|
|
52
52
|
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
53
53
|
if (resizingContainer && resizingItem) {
|
|
54
54
|
var newWidth = "".concat(currentWidth + resizeAmount, "px");
|
|
55
|
-
tableRef
|
|
55
|
+
if (tableRef) {
|
|
56
|
+
tableRef.style.width = newWidth;
|
|
57
|
+
}
|
|
56
58
|
resizingContainer.style.width = newWidth;
|
|
57
59
|
resizingItem.style.width = newWidth;
|
|
58
60
|
}
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
5
5
|
import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getSelectedTableInfo } from '../../../utils';
|
|
8
9
|
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
9
10
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
@@ -85,8 +86,8 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
85
86
|
|
|
86
87
|
// updates Colgroup DOM node with new widths
|
|
87
88
|
export var updateColgroup = function updateColgroup(state, tableRef, tableNode, isTableScalingEnabled) {
|
|
88
|
-
var cols = tableRef.querySelectorAll('col');
|
|
89
|
-
var columnsCount = cols.length;
|
|
89
|
+
var cols = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelectorAll('col');
|
|
90
|
+
var columnsCount = cols === null || cols === void 0 ? void 0 : cols.length;
|
|
90
91
|
/**
|
|
91
92
|
updateColgroup will update whole table scale when click the column resize handle, this behavior will affect when table overflowed, when now resize handle been dragged and extend to make table overflowed, table will show overflow. This need to be confirmed because it conflict with how isTableScalingEnabled work.
|
|
92
93
|
We don't want to scale the table when resizing columns, only when viewpoint shrinks the table.
|
|
@@ -98,11 +99,11 @@ export var updateColgroup = function updateColgroup(state, tableRef, tableNode,
|
|
|
98
99
|
return column && !!column.width;
|
|
99
100
|
}) // if width is 0, we dont want to apply that.
|
|
100
101
|
.forEach(function (column, i) {
|
|
101
|
-
var fixedColWidth = getColWidthFix(column.width, columnsCount);
|
|
102
|
+
var fixedColWidth = getColWidthFix(column.width, columnsCount !== null && columnsCount !== void 0 ? columnsCount : 0);
|
|
102
103
|
var scaledWidth = fixedColWidth * scalePercent;
|
|
103
104
|
var finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
104
105
|
// we aren't handling the remaining pixels here when the 48px min width is reached
|
|
105
|
-
if (cols[i]) {
|
|
106
|
+
if (cols !== null && cols !== void 0 && cols[i]) {
|
|
106
107
|
cols[i].style.width = "".concat(finalWidth, "px");
|
|
107
108
|
}
|
|
108
109
|
});
|
|
@@ -111,8 +112,8 @@ export var updateColgroup = function updateColgroup(state, tableRef, tableNode,
|
|
|
111
112
|
return column && !!column.width;
|
|
112
113
|
}) // if width is 0, we dont want to apply that.
|
|
113
114
|
.forEach(function (column, i) {
|
|
114
|
-
if (cols[i]) {
|
|
115
|
-
cols[i].style.width = "".concat(getColWidthFix(column.width, columnsCount), "px");
|
|
115
|
+
if (cols !== null && cols !== void 0 && cols[i]) {
|
|
116
|
+
cols[i].style.width = "".concat(getColWidthFix(column.width, columnsCount !== null && columnsCount !== void 0 ? columnsCount : 0), "px");
|
|
116
117
|
}
|
|
117
118
|
});
|
|
118
119
|
}
|
|
@@ -312,7 +313,8 @@ export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFrom
|
|
|
312
313
|
return;
|
|
313
314
|
}
|
|
314
315
|
var maybeTable = domAtPos(table.start).node;
|
|
315
|
-
var
|
|
316
|
+
var maybeTableElement = maybeTable instanceof HTMLElement ? maybeTable : null;
|
|
317
|
+
var tableRef = getBooleanFF('platform.editor.explicit-html-element-check') ? maybeTableElement === null || maybeTableElement === void 0 ? void 0 : maybeTableElement.closest('table') : maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.closest('table');
|
|
316
318
|
if (!tableRef) {
|
|
317
319
|
return;
|
|
318
320
|
}
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
8
9
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
9
10
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -99,7 +100,8 @@ export var rescaleColumns = function rescaleColumns() {
|
|
|
99
100
|
var newTable = tr.doc.nodeAt(table.pos);
|
|
100
101
|
var domAtPos = view.domAtPos.bind(view);
|
|
101
102
|
var maybeTable = domAtPos(table.start).node;
|
|
102
|
-
var
|
|
103
|
+
var maybeTableElement = getBooleanFF('platform.editor.explicit-html-element-check') ? maybeTable instanceof HTMLElement ? maybeTable : null : maybeTable;
|
|
104
|
+
var tableRef = maybeTableElement === null || maybeTableElement === void 0 ? void 0 : maybeTableElement.closest('table');
|
|
103
105
|
if (!tableRef || !newTable) {
|
|
104
106
|
return tr;
|
|
105
107
|
}
|
|
@@ -5,6 +5,7 @@ import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'reac
|
|
|
5
5
|
import { injectIntl } from 'react-intl-next';
|
|
6
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
7
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
9
10
|
import { clearHoverSelection } from '../../../commands';
|
|
10
11
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
@@ -90,14 +91,26 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
90
91
|
}
|
|
91
92
|
}, [editorView, tableActive]);
|
|
92
93
|
var handleMouseMove = useCallback(function (e) {
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
if (getBooleanFF('platform.editor.explicit-html-element-check')) {
|
|
95
|
+
var target = e.nativeEvent.target instanceof Element ? e.nativeEvent.target : null;
|
|
96
|
+
var isParentDragControls = target === null || target === void 0 ? void 0 : target.closest(".".concat(ClassName.DRAG_ROW_CONTROLS));
|
|
97
|
+
var _rowIndex = target === null || target === void 0 ? void 0 : target.getAttribute('data-start-index');
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// avoid updating if event target is not related
|
|
100
|
+
if (!isParentDragControls || !_rowIndex) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
updateCellHoverLocation(Number(_rowIndex));
|
|
104
|
+
} else {
|
|
105
|
+
var _isParentDragControls = e.nativeEvent.target.closest(".".concat(ClassName.DRAG_ROW_CONTROLS));
|
|
106
|
+
var _rowIndex2 = e.nativeEvent.target.getAttribute('data-start-index');
|
|
107
|
+
|
|
108
|
+
// avoid updating if event target is not related
|
|
109
|
+
if (!_isParentDragControls || !_rowIndex2) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
updateCellHoverLocation(Number(_rowIndex2));
|
|
99
113
|
}
|
|
100
|
-
updateCellHoverLocation(Number(rowIndex));
|
|
101
114
|
}, [updateCellHoverLocation]);
|
|
102
115
|
var rowIndexes = useMemo(function () {
|
|
103
116
|
return [rowIndex];
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated } from './selection';
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
|
-
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
3
|
+
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
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';
|
|
9
|
-
export { getMergedCellsPositions } from './table';
|
|
9
|
+
export { getMergedCellsPositions, getAssistiveMessage } from './table';
|
|
10
10
|
export { updatePluginStateDecorations } from './update-plugin-state-decorations';
|
|
11
11
|
export { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInBetween, hasMergedCellsInSelection, findDuplicatePosition, checkEdgeHasMergedCells } from './merged-cells';
|
|
12
12
|
export { createTableWithWidth } from './create';
|
package/dist/esm/utils/nodes.js
CHANGED
|
@@ -68,6 +68,11 @@ export var tablesHaveDifferentNoOfColumns = function tablesHaveDifferentNoOfColu
|
|
|
68
68
|
var currentMap = TableMap.get(currentTable);
|
|
69
69
|
return prevMap.width !== currentMap.width;
|
|
70
70
|
};
|
|
71
|
+
export var tablesHaveDifferentNoOfRows = function tablesHaveDifferentNoOfRows(currentTable, previousTable) {
|
|
72
|
+
var prevMap = TableMap.get(previousTable);
|
|
73
|
+
var currentMap = TableMap.get(currentTable);
|
|
74
|
+
return prevMap.height !== currentMap.height;
|
|
75
|
+
};
|
|
71
76
|
function filterNearSelection(selection, findNode, predicate, defaultValue) {
|
|
72
77
|
var found = findNode(selection);
|
|
73
78
|
if (!found) {
|
package/dist/esm/utils/table.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
2
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
3
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
5
|
export var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
@@ -25,4 +26,36 @@ export var colsToRect = function colsToRect(cols, noOfRows) {
|
|
|
25
26
|
top: 0,
|
|
26
27
|
bottom: noOfRows
|
|
27
28
|
};
|
|
29
|
+
};
|
|
30
|
+
export var getAssistiveMessage = function getAssistiveMessage(prevTableNode, currentTableNode, intl) {
|
|
31
|
+
var formatMessage = intl.formatMessage;
|
|
32
|
+
var prevTableMap = TableMap.get(prevTableNode);
|
|
33
|
+
var currentTableMap = TableMap.get(currentTableNode);
|
|
34
|
+
if (currentTableMap.width !== prevTableMap.width) {
|
|
35
|
+
var diff = Math.abs(currentTableMap.width - prevTableMap.width);
|
|
36
|
+
if (currentTableMap.width > prevTableMap.width) {
|
|
37
|
+
return formatMessage(messages.columnsAreInserted, {
|
|
38
|
+
count: diff
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (currentTableMap.width < prevTableMap.width) {
|
|
42
|
+
return formatMessage(messages.columnsAreRemoved, {
|
|
43
|
+
count: diff
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (currentTableMap.height !== prevTableMap.height) {
|
|
48
|
+
var _diff = Math.abs(currentTableMap.height - prevTableMap.height);
|
|
49
|
+
if (currentTableMap.height > prevTableMap.height) {
|
|
50
|
+
return formatMessage(messages.rowsAreInserted, {
|
|
51
|
+
count: _diff
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (currentTableMap.height < prevTableMap.height) {
|
|
55
|
+
return formatMessage(messages.rowsAreRemoved, {
|
|
56
|
+
count: _diff
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return '';
|
|
28
61
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
2
|
import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
3
4
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import type { Direction } from '@atlaskit/editor-tables/types';
|
|
5
6
|
export declare const initiateKeyboardColumnResizing: ({ ariaNotify, getIntl, }: {
|
|
6
|
-
ariaNotify?: ((message: string) => void) | undefined;
|
|
7
|
+
ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
|
|
7
8
|
getIntl?: (() => IntlShape) | undefined;
|
|
8
9
|
}) => Command;
|
|
9
10
|
export declare const activateNextResizeArea: ({ direction, ariaNotify, getIntl, }: {
|
|
10
11
|
direction: Direction;
|
|
11
|
-
ariaNotify?: ((message: string) => void) | undefined;
|
|
12
|
+
ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
|
|
12
13
|
getIntl?: (() => IntlShape) | undefined;
|
|
13
14
|
}) => Command;
|
|
14
15
|
export declare const changeColumnWidthByStep: ({ stepSize, getEditorContainerWidth, isTableScalingEnabled, ariaNotify, getIntl, }: {
|
|
15
16
|
stepSize: number;
|
|
16
17
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
17
18
|
isTableScalingEnabled: boolean;
|
|
18
|
-
ariaNotify?: ((message: string) => void) | undefined;
|
|
19
|
+
ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
|
|
19
20
|
getIntl?: (() => IntlShape) | undefined;
|
|
20
21
|
originalTr?: Transaction | undefined;
|
|
21
22
|
}) => Command;
|
|
22
23
|
export declare const stopKeyboardColumnResizing: ({ ariaNotify, getIntl, originalTr, }: {
|
|
23
|
-
ariaNotify?: ((message: string) => void) | undefined;
|
|
24
|
+
ariaNotify?: ((message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void) | undefined;
|
|
24
25
|
getIntl?: (() => IntlShape) | undefined;
|
|
25
26
|
originalTr?: Transaction | undefined;
|
|
26
27
|
}) => Command;
|