@atlaskit/editor-plugin-table 7.2.2 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/commands/column-resize.js +115 -45
- package/dist/cjs/commands/go-to-next-cell.js +7 -11
- package/dist/cjs/commands/misc.js +3 -2
- package/dist/cjs/commands/selection.js +3 -3
- package/dist/cjs/event-handlers.js +38 -25
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -19
- package/dist/cjs/pm-plugins/keymap.js +1 -0
- package/dist/cjs/pm-plugins/main.js +43 -9
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
- package/dist/cjs/reducer.js +5 -2
- package/dist/cjs/utils/drag-menu.js +37 -23
- package/dist/cjs/utils/merged-cells.js +66 -1
- package/dist/es2019/commands/column-resize.js +100 -35
- package/dist/es2019/commands/go-to-next-cell.js +7 -9
- package/dist/es2019/commands/misc.js +3 -2
- package/dist/es2019/commands/selection.js +5 -5
- package/dist/es2019/event-handlers.js +17 -3
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/es2019/pm-plugins/main.js +41 -5
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
- package/dist/es2019/reducer.js +5 -2
- package/dist/es2019/utils/drag-menu.js +38 -14
- package/dist/es2019/utils/merged-cells.js +73 -0
- package/dist/esm/commands/column-resize.js +105 -35
- package/dist/esm/commands/go-to-next-cell.js +7 -11
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/commands/selection.js +5 -5
- package/dist/esm/event-handlers.js +38 -25
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/esm/pm-plugins/main.js +38 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
- package/dist/esm/reducer.js +5 -2
- package/dist/esm/utils/drag-menu.js +36 -22
- package/dist/esm/utils/merged-cells.js +65 -0
- package/dist/types/commands/column-resize.d.ts +2 -0
- package/dist/types/commands/misc.d.ts +1 -1
- package/dist/types/types.d.ts +16 -0
- package/dist/types/utils/drag-menu.d.ts +4 -1
- package/dist/types/utils/merged-cells.d.ts +2 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
- package/dist/types-ts4.5/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +16 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +4 -1
- package/dist/types-ts4.5/utils/merged-cells.d.ts +2 -0
- package/package.json +10 -17
- package/src/commands/column-resize.ts +155 -40
- package/src/commands/go-to-next-cell.ts +6 -15
- package/src/commands/misc.ts +2 -0
- package/src/commands/selection.ts +5 -5
- package/src/event-handlers.ts +21 -4
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -32
- package/src/pm-plugins/keymap.ts +3 -0
- package/src/pm-plugins/main.ts +47 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
- package/src/pm-plugins/table-resizing/plugin.ts +18 -1
- package/src/reducer.ts +5 -2
- package/src/types.ts +16 -0
- package/src/utils/drag-menu.ts +94 -20
- package/src/utils/merged-cells.ts +78 -0
- package/tsconfig.dev.json +0 -69
- package/tsconfig.json +2 -877
- package/examples/99-testing.tsx +0 -140
- package/examples/config.jsonc +0 -14
- package/src/__tests__/unit/analytics.ts +0 -888
- package/src/__tests__/unit/collab.ts +0 -93
- package/src/__tests__/unit/commands/go-to-next-cell.ts +0 -173
- package/src/__tests__/unit/commands/insert.ts +0 -137
- package/src/__tests__/unit/commands/misc.ts +0 -185
- package/src/__tests__/unit/commands/sort.ts +0 -128
- package/src/__tests__/unit/commands.ts +0 -745
- package/src/__tests__/unit/copy-button.ts +0 -22
- package/src/__tests__/unit/copy-paste.ts +0 -677
- package/src/__tests__/unit/event-handlers/index.ts +0 -125
- package/src/__tests__/unit/event-handlers.ts +0 -296
- package/src/__tests__/unit/fix-tables.ts +0 -164
- package/src/__tests__/unit/get-toolbar-config.ts +0 -127
- package/src/__tests__/unit/handlers.ts +0 -98
- package/src/__tests__/unit/hover-selection.ts +0 -230
- package/src/__tests__/unit/index-with-fake-timers.ts +0 -111
- package/src/__tests__/unit/index.ts +0 -912
- package/src/__tests__/unit/layout.ts +0 -146
- package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +0 -162
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +0 -280
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +0 -525
- package/src/__tests__/unit/nodeviews/cell.ts +0 -132
- package/src/__tests__/unit/nodeviews/table.ts +0 -129
- package/src/__tests__/unit/pm-plugins/analytics.ts +0 -327
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +0 -94
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +0 -176
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +0 -211
- package/src/__tests__/unit/pm-plugins/main.ts +0 -214
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -101
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +0 -562
- package/src/__tests__/unit/pm-plugins/table-local-id.ts +0 -507
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +0 -269
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +0 -192
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +0 -33
- package/src/__tests__/unit/pm-plugins/table-width.ts +0 -292
- package/src/__tests__/unit/sort-column.ts +0 -399
- package/src/__tests__/unit/toolbar.ts +0 -512
- package/src/__tests__/unit/transforms/delete-columns.ts +0 -597
- package/src/__tests__/unit/transforms/delete-rows.ts +0 -620
- package/src/__tests__/unit/transforms/merging.ts +0 -392
- package/src/__tests__/unit/ui/ContextualMenu.tsx +0 -71
- package/src/__tests__/unit/ui/CornerControls.tsx +0 -99
- package/src/__tests__/unit/ui/DeleteButton.tsx +0 -38
- package/src/__tests__/unit/ui/FixedButton.tsx +0 -217
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +0 -123
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +0 -68
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +0 -178
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +0 -511
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +0 -322
- package/src/__tests__/unit/ui/NumberColumn.tsx +0 -146
- package/src/__tests__/unit/ui/RowControls.tsx +0 -294
- package/src/__tests__/unit/ui/RowDragControls.tsx +0 -129
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +0 -189
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +0 -118
- package/src/__tests__/unit/undo-redo.ts +0 -220
- package/src/__tests__/unit/utils/analytics.ts +0 -98
- package/src/__tests__/unit/utils/collapse.ts +0 -57
- package/src/__tests__/unit/utils/column-controls.ts +0 -205
- package/src/__tests__/unit/utils/dom.ts +0 -180
- package/src/__tests__/unit/utils/merged-cells.ts +0 -156
- package/src/__tests__/unit/utils/nodes.ts +0 -79
- package/src/__tests__/unit/utils/row-controls.ts +0 -195
- package/src/__tests__/unit/utils/table.ts +0 -96
- package/src/__tests__/unit/utils.ts +0 -670
- package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +0 -5228
- package/src/__tests__/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -20272
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +0 -3
- package/src/__tests__/visual-regression/cell-options-menu.ts +0 -101
- package/src/__tests__/visual-regression/copy-button.ts +0 -181
- package/src/__tests__/visual-regression/index.ts +0 -62
- package/src/__tests__/visual-regression/sticky-header.ts +0 -61
|
@@ -18,9 +18,35 @@ import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizi
|
|
|
18
18
|
import { getClosestSelectionRect } from '../toolbar';
|
|
19
19
|
import { deleteRows } from '../transforms';
|
|
20
20
|
import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
|
|
21
|
+
import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
|
|
21
22
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
22
|
-
const
|
|
23
|
-
const
|
|
23
|
+
export const getTargetIndex = (selectedIndexes, direction) => Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
|
|
24
|
+
export const canMove = (sourceType, direction, totalItemsOfSourceTypeCount, selection, selectionRect) => {
|
|
25
|
+
if (!selectionRect) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const isRow = sourceType === 'table-row';
|
|
29
|
+
const selectedIndexes = isRow ? getSelectedRowIndexes(selectionRect) : getSelectedColumnIndexes(selectionRect);
|
|
30
|
+
const targetIndex = getTargetIndex(selectedIndexes, direction);
|
|
31
|
+
const isValidTargetIndex = targetIndex >= 0 && targetIndex < totalItemsOfSourceTypeCount;
|
|
32
|
+
if (!isValidTargetIndex) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We can't move column when target has merges with other columns
|
|
37
|
+
// We can't move row when target has merges with other rows
|
|
38
|
+
const hasMergedCellsInTarget = isRow ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection) : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
|
|
39
|
+
if (hasMergedCellsInTarget) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Currently we can't move in any direction if there are merged cells in the source
|
|
44
|
+
const hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
|
|
45
|
+
if (hasMergedCellsInSource) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
24
50
|
const isDistributeColumnsEnabled = state => {
|
|
25
51
|
const rect = getClosestSelectionRect(state);
|
|
26
52
|
if (rect) {
|
|
@@ -30,6 +56,7 @@ const isDistributeColumnsEnabled = state => {
|
|
|
30
56
|
return false;
|
|
31
57
|
};
|
|
32
58
|
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI) => {
|
|
59
|
+
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
33
60
|
const addOptions = direction === 'row' ? [{
|
|
34
61
|
label: 'above',
|
|
35
62
|
offset: 0,
|
|
@@ -51,38 +78,35 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
51
78
|
icon: AddColRightIcon,
|
|
52
79
|
keymap: addColumnAfter
|
|
53
80
|
}];
|
|
81
|
+
const {
|
|
82
|
+
selection
|
|
83
|
+
} = editorView.state;
|
|
54
84
|
const moveOptions = direction === 'row' ? [{
|
|
55
85
|
label: 'up',
|
|
56
86
|
icon: ArrowUpIcon,
|
|
57
87
|
keymap: moveRowUp,
|
|
58
|
-
canMove:
|
|
88
|
+
canMove: canDrag && canMove('table-row', -1, (_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0, selection, selectionRect),
|
|
59
89
|
getOriginIndexes: getSelectedRowIndexes,
|
|
60
90
|
getTargetIndex: selectionRect => selectionRect.top - 1
|
|
61
91
|
}, {
|
|
62
92
|
label: 'down',
|
|
63
93
|
icon: ArrowDownIcon,
|
|
64
94
|
keymap: moveRowDown,
|
|
65
|
-
canMove:
|
|
66
|
-
var _selectionRect$bottom, _tableMap$height;
|
|
67
|
-
return canDrag && canIncrease(((_selectionRect$bottom = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom) !== null && _selectionRect$bottom !== void 0 ? _selectionRect$bottom : 0) - 1, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
68
|
-
},
|
|
95
|
+
canMove: canDrag && canMove('table-row', 1, (_tableMap$height2 = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height2 !== void 0 ? _tableMap$height2 : 0, selection, selectionRect),
|
|
69
96
|
getOriginIndexes: getSelectedRowIndexes,
|
|
70
97
|
getTargetIndex: selectionRect => selectionRect.bottom
|
|
71
98
|
}] : [{
|
|
72
99
|
label: 'left',
|
|
73
100
|
icon: ArrowLeftIcon,
|
|
74
101
|
keymap: moveColumnLeft,
|
|
75
|
-
canMove:
|
|
102
|
+
canMove: canDrag && canMove('table-column', -1, (_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0, selection, selectionRect),
|
|
76
103
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
77
104
|
getTargetIndex: selectionRect => selectionRect.left - 1
|
|
78
105
|
}, {
|
|
79
106
|
label: 'right',
|
|
80
107
|
icon: ArrowRightIcon,
|
|
81
108
|
keymap: moveColumnRight,
|
|
82
|
-
canMove:
|
|
83
|
-
var _selectionRect$right, _tableMap$width;
|
|
84
|
-
return canDrag && canIncrease(((_selectionRect$right = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right) !== null && _selectionRect$right !== void 0 ? _selectionRect$right : 0) - 1, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
85
|
-
},
|
|
109
|
+
canMove: canDrag && canMove('table-column', 1, (_tableMap$width2 = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width2 !== void 0 ? _tableMap$width2 : 0, selection, selectionRect),
|
|
86
110
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
87
111
|
getTargetIndex: selectionRect => selectionRect.right
|
|
88
112
|
}];
|
|
@@ -166,10 +190,10 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
166
190
|
}) => ({
|
|
167
191
|
id: `move_${direction}_${label}`,
|
|
168
192
|
title: `Move ${direction} ${label}`,
|
|
169
|
-
disabled: !canMove
|
|
193
|
+
disabled: !canMove,
|
|
170
194
|
icon,
|
|
171
195
|
onClick: (state, dispatch) => {
|
|
172
|
-
if (canMove
|
|
196
|
+
if (canMove) {
|
|
173
197
|
requestAnimationFrame(() => {
|
|
174
198
|
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`, getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
|
|
175
199
|
});
|
|
@@ -107,4 +107,77 @@ export const hasMergedCellsInBetween = (indexes, type) => selection => {
|
|
|
107
107
|
|
|
108
108
|
// Currently only support 2 indexes, but we can extend this to support more indexes in the future.
|
|
109
109
|
return mergedCellsInRectArr[0].some(cell => mergedCellsInRectArr[1].includes(cell));
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Checks if any cell in the column with colIndex is merged with a cell in a column to the left or to the right of it.
|
|
113
|
+
// colIndex is a logical index of the column. It starts at 0 and goes up to tableMap.width - 1.
|
|
114
|
+
export const hasMergedCellsWithColumnNextToColumnIndex = (colIndex, selection) => {
|
|
115
|
+
const table = findTable(selection);
|
|
116
|
+
if (!table) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const tableMap = TableMap.get(table.node);
|
|
120
|
+
const {
|
|
121
|
+
width
|
|
122
|
+
} = tableMap;
|
|
123
|
+
if (width <= 1) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (colIndex < 0 || colIndex > width - 1) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const {
|
|
130
|
+
map
|
|
131
|
+
} = tableMap;
|
|
132
|
+
// j is an index in the tableMap.map array. tableMap.map is a flat array.
|
|
133
|
+
// Each item of this array contains a number.
|
|
134
|
+
// The number represents the position of the corresponding cell in the tableMap. It exists for each cell.
|
|
135
|
+
// If there are merged cells, their positions will be represented by the same number.
|
|
136
|
+
const isFirstColumn = colIndex === 0;
|
|
137
|
+
const isLastColumn = colIndex === width - 1;
|
|
138
|
+
for (let j = colIndex; j < map.length; j += width) {
|
|
139
|
+
if (!isFirstColumn && map[j] === map[j - 1] ||
|
|
140
|
+
// compare with a cell in the column on the left
|
|
141
|
+
!isLastColumn && map[j] === map[j + 1] // compare with a cell in the column on the right
|
|
142
|
+
) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Checks if any cell in the row with rowIndex is merged with a cell in a row above or below it.
|
|
150
|
+
export const hasMergedCellsWithRowNextToRowIndex = (rowIndex, selection) => {
|
|
151
|
+
const table = findTable(selection);
|
|
152
|
+
if (!table) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const tableMap = TableMap.get(table.node);
|
|
156
|
+
const {
|
|
157
|
+
height
|
|
158
|
+
} = tableMap;
|
|
159
|
+
if (height <= 1) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (rowIndex < 0 || rowIndex > height - 1) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
const {
|
|
166
|
+
map,
|
|
167
|
+
width
|
|
168
|
+
} = tableMap; // map is a flat array representing position of each cell in the table.
|
|
169
|
+
const indexOfFirstCellInTheRow = rowIndex * width;
|
|
170
|
+
const indexOfLastCellInTheRow = indexOfFirstCellInTheRow + width - 1;
|
|
171
|
+
const isFirstRow = rowIndex === 0;
|
|
172
|
+
const isLastRow = rowIndex === height - 1;
|
|
173
|
+
// j is an index of a cell in a row
|
|
174
|
+
for (let j = indexOfFirstCellInTheRow; j <= indexOfLastCellInTheRow; j++) {
|
|
175
|
+
if (!isFirstRow && map[j] === map[j - width] ||
|
|
176
|
+
// compare with a cell in the row above
|
|
177
|
+
!isLastRow && map[j] === map[j + width] // compare with a cell in the row below
|
|
178
|
+
) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
110
183
|
};
|
|
@@ -2,25 +2,61 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { TableMap } from '@atlaskit/editor-tables';
|
|
3
3
|
import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/utils';
|
|
4
4
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
6
|
+
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
7
|
+
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
5
8
|
import { getPluginState as getTableResizingPluginState, createCommand as tableResizingPluginCreateCommand } from '../pm-plugins/table-resizing/plugin-factory';
|
|
9
|
+
import { pluginKey as tableResizingPK } from '../pm-plugins/table-resizing/plugin-key';
|
|
6
10
|
import { currentColWidth, getResizeState, getTableMaxWidth, resizeColumn, updateControls } from '../pm-plugins/table-resizing/utils';
|
|
7
11
|
import { updateColumnWidths } from '../transforms';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
12
|
+
import { TableDecorations } from '../types';
|
|
13
|
+
import { createColumnLineResize, getSelectedColumnIndexes, updateDecorations } from '../utils';
|
|
14
|
+
var getTablePluginCommand = function getTablePluginCommand(actionPayload, originalTr) {
|
|
15
|
+
return createCommand(function () {
|
|
16
|
+
return actionPayload;
|
|
17
|
+
}, function (tr) {
|
|
18
|
+
return (originalTr || tr).setMeta('addToHistory', false);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
10
21
|
var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosition(rowIndex, columnIndex, nextResizeHandlePos) {
|
|
11
22
|
return function (state, dispatch) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
var customTr = state.tr;
|
|
24
|
+
var _getPluginState = getPluginState(state),
|
|
25
|
+
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
|
|
26
|
+
getIntl = _getPluginState.getIntl;
|
|
27
|
+
var fakeDispatch = function fakeDispatch(tr) {
|
|
28
|
+
customTr = tr;
|
|
29
|
+
};
|
|
30
|
+
if (!allowColumnResizing) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var decorationsWithWidget = buildColumnResizingDecorations(rowIndex, columnIndex, true, getIntl)({
|
|
34
|
+
tr: customTr,
|
|
35
|
+
decorationSet: getDecorations(state)
|
|
36
|
+
});
|
|
37
|
+
var decorationsWithWidgetAndHandle = updateDecorations(customTr.doc, decorationsWithWidget, createColumnLineResize(state.selection, {
|
|
16
38
|
right: columnIndex
|
|
17
|
-
})
|
|
18
|
-
|
|
39
|
+
}), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
|
|
40
|
+
getTablePluginCommand({
|
|
41
|
+
type: 'START_KEYBOARD_COLUMN_RESIZE',
|
|
42
|
+
data: {
|
|
43
|
+
resizeHandleRowIndex: rowIndex,
|
|
44
|
+
resizeHandleColumnIndex: columnIndex,
|
|
45
|
+
resizeHandleIncludeTooltip: true,
|
|
46
|
+
isKeyboardResize: true,
|
|
47
|
+
decorationSet: decorationsWithWidgetAndHandle
|
|
48
|
+
}
|
|
49
|
+
}, customTr)(state, fakeDispatch);
|
|
50
|
+
customTr.setMeta(tableResizingPK, {
|
|
19
51
|
type: 'SET_RESIZE_HANDLE_POSITION',
|
|
20
52
|
data: {
|
|
21
53
|
resizeHandlePos: nextResizeHandlePos
|
|
22
54
|
}
|
|
23
|
-
})
|
|
55
|
+
});
|
|
56
|
+
if (dispatch) {
|
|
57
|
+
dispatch(customTr);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
24
60
|
return false;
|
|
25
61
|
};
|
|
26
62
|
};
|
|
@@ -32,32 +68,19 @@ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResiz
|
|
|
32
68
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
33
69
|
var cell = findCellClosestToPos(selection.$from);
|
|
34
70
|
if (selectionRect && cell && view) {
|
|
35
|
-
|
|
36
|
-
var width = currentColWidth(view, cell.pos, cellAttrs);
|
|
37
|
-
updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
|
|
38
|
-
tableResizingPluginCreateCommand({
|
|
39
|
-
type: 'SET_DRAGGING',
|
|
40
|
-
data: {
|
|
41
|
-
dragging: {
|
|
42
|
-
startX: 0,
|
|
43
|
-
startWidth: width
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})(state, dispatch);
|
|
47
|
-
return true;
|
|
71
|
+
return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
|
|
48
72
|
}
|
|
49
73
|
return false;
|
|
50
74
|
};
|
|
51
75
|
export var activateNextResizeArea = function activateNextResizeArea(direction) {
|
|
52
|
-
return function (state, dispatch) {
|
|
76
|
+
return function (state, dispatch, view) {
|
|
53
77
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
54
78
|
return false;
|
|
55
79
|
}
|
|
56
80
|
var _ref = getTableResizingPluginState(state) || {},
|
|
57
|
-
resizeHandlePos = _ref.resizeHandlePos
|
|
58
|
-
dragging = _ref.dragging;
|
|
81
|
+
resizeHandlePos = _ref.resizeHandlePos;
|
|
59
82
|
// If No resizing has initiated, skip to regular handler
|
|
60
|
-
if (!resizeHandlePos
|
|
83
|
+
if (!resizeHandlePos) {
|
|
61
84
|
return false;
|
|
62
85
|
}
|
|
63
86
|
var selection = state.selection;
|
|
@@ -82,31 +105,35 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
|
|
|
82
105
|
// we are somewhere in between the side columns of the table
|
|
83
106
|
var offset = $nextCell.pos - $nextCell.start(-1);
|
|
84
107
|
var rectForNextCell = tableMap.findCell(offset);
|
|
85
|
-
updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch);
|
|
108
|
+
return updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch, view);
|
|
86
109
|
} else {
|
|
87
110
|
// current position is in the one of the side columns of the table(left or right)
|
|
88
111
|
if (currentCellRect.left === 0) {
|
|
89
112
|
var lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
|
|
90
113
|
var $lastCell = state.doc.resolve(lastCellInCurrentRow);
|
|
91
|
-
updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch);
|
|
114
|
+
return updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch, view);
|
|
92
115
|
} else if (tableMap.width === currentCellRect.right) {
|
|
93
116
|
var firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
|
|
94
117
|
var _$nextCell = state.doc.resolve(firsCellInCurrentRow);
|
|
95
|
-
updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
|
|
118
|
+
return updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
|
-
return
|
|
121
|
+
return false;
|
|
99
122
|
};
|
|
100
123
|
};
|
|
101
124
|
export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
|
|
102
125
|
return function (state, dispatch, view) {
|
|
126
|
+
var customTr = state.tr;
|
|
127
|
+
var fakeDispatch = function fakeDispatch(tr) {
|
|
128
|
+
customTr = tr;
|
|
129
|
+
};
|
|
103
130
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
104
131
|
return false;
|
|
105
132
|
}
|
|
106
133
|
var _getTableResizingPlug = getTableResizingPluginState(state),
|
|
107
|
-
resizeHandlePos = _getTableResizingPlug.resizeHandlePos
|
|
108
|
-
|
|
109
|
-
if (!view || !resizeHandlePos || !
|
|
134
|
+
resizeHandlePos = _getTableResizingPlug.resizeHandlePos;
|
|
135
|
+
var cell = findCellClosestToPos(state.selection.$from);
|
|
136
|
+
if (!view || !resizeHandlePos || !cell) {
|
|
110
137
|
return false;
|
|
111
138
|
}
|
|
112
139
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
@@ -119,6 +146,17 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
|
|
|
119
146
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
120
147
|
dom = dom.closest('table');
|
|
121
148
|
}
|
|
149
|
+
var cellAttrs = cell === null || cell === void 0 ? void 0 : cell.node.attrs;
|
|
150
|
+
var width = currentColWidth(view, cell === null || cell === void 0 ? void 0 : cell.pos, cellAttrs);
|
|
151
|
+
tableResizingPluginCreateCommand({
|
|
152
|
+
type: 'SET_DRAGGING',
|
|
153
|
+
data: {
|
|
154
|
+
dragging: {
|
|
155
|
+
startX: 0,
|
|
156
|
+
startWidth: width
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
})(state, fakeDispatch);
|
|
122
160
|
var maxSize = getTableMaxWidth({
|
|
123
161
|
table: originalTable,
|
|
124
162
|
tableStart: tableStartPosition,
|
|
@@ -140,10 +178,42 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
|
|
|
140
178
|
// only selected (or selected - 1) columns should be distributed
|
|
141
179
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
142
180
|
var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
|
|
143
|
-
|
|
181
|
+
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
144
182
|
if (dispatch) {
|
|
145
|
-
dispatch(
|
|
183
|
+
dispatch(customTr);
|
|
146
184
|
}
|
|
147
185
|
return true;
|
|
148
186
|
};
|
|
187
|
+
};
|
|
188
|
+
export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(originalTr) {
|
|
189
|
+
return function (state, dispatch) {
|
|
190
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
var customTr = originalTr || state.tr;
|
|
194
|
+
var fakeDispatch = function fakeDispatch(tr) {
|
|
195
|
+
customTr = tr;
|
|
196
|
+
};
|
|
197
|
+
var decorationWithoutWidget = clearColumnResizingDecorations()({
|
|
198
|
+
tr: customTr,
|
|
199
|
+
decorationSet: getDecorations(state)
|
|
200
|
+
});
|
|
201
|
+
var decorationWithoutWidgetAndHandle = updateDecorations(customTr.doc, decorationWithoutWidget, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
|
|
202
|
+
getTablePluginCommand({
|
|
203
|
+
type: 'STOP_KEYBOARD_COLUMN_RESIZE',
|
|
204
|
+
data: {
|
|
205
|
+
decorationSet: decorationWithoutWidgetAndHandle
|
|
206
|
+
}
|
|
207
|
+
}, customTr)(state, fakeDispatch);
|
|
208
|
+
tableResizingPluginCreateCommand({
|
|
209
|
+
type: 'STOP_RESIZING'
|
|
210
|
+
}, function () {
|
|
211
|
+
return customTr.setMeta('scrollIntoView', false);
|
|
212
|
+
})(state, fakeDispatch);
|
|
213
|
+
if (dispatch) {
|
|
214
|
+
dispatch(customTr);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
};
|
|
149
219
|
};
|
|
@@ -6,27 +6,23 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
6
6
|
import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
9
|
-
import { getPluginState
|
|
10
|
-
import {
|
|
9
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
|
+
import { stopKeyboardColumnResizing } from './column-resize';
|
|
11
11
|
var TAB_FORWARD_DIRECTION = 1;
|
|
12
12
|
var TAB_BACKWARD_DIRECTION = -1;
|
|
13
13
|
export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
|
|
14
14
|
return function (direction) {
|
|
15
|
-
return function (state, dispatch) {
|
|
15
|
+
return function (state, dispatch, view) {
|
|
16
16
|
var table = findTable(state.selection);
|
|
17
17
|
if (!table) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
21
|
-
var
|
|
22
|
-
var isColumnResizing =
|
|
21
|
+
var _getPluginState;
|
|
22
|
+
var isColumnResizing = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
|
|
23
23
|
if (isColumnResizing) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, function (originalTr) {
|
|
27
|
-
return (state.tr || originalTr).setMeta('scrollIntoView', false);
|
|
28
|
-
})(state, dispatch);
|
|
29
|
-
hideResizeHandleLine()(state, dispatch);
|
|
24
|
+
stopKeyboardColumnResizing()(state, dispatch, view);
|
|
25
|
+
return true;
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
28
|
var map = TableMap.get(table.node);
|
|
@@ -447,7 +447,7 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
|
|
|
447
447
|
return tr.setMeta('addToHistory', false);
|
|
448
448
|
});
|
|
449
449
|
};
|
|
450
|
-
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
450
|
+
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, isKeyboardResize) {
|
|
451
451
|
return createCommand(function (state) {
|
|
452
452
|
var tableNode = findTable(state.selection);
|
|
453
453
|
var _getPluginState2 = getPluginState(state),
|
|
@@ -465,7 +465,8 @@ export var addResizeHandleDecorations = function addResizeHandleDecorations(rowI
|
|
|
465
465
|
}),
|
|
466
466
|
resizeHandleRowIndex: rowIndex,
|
|
467
467
|
resizeHandleColumnIndex: columnIndex,
|
|
468
|
-
resizeHandleIncludeTooltip: includeTooltip
|
|
468
|
+
resizeHandleIncludeTooltip: includeTooltip,
|
|
469
|
+
isKeyboardResize: isKeyboardResize || false
|
|
469
470
|
}
|
|
470
471
|
};
|
|
471
472
|
}, function (tr) {
|
|
@@ -5,7 +5,7 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
5
5
|
import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
8
|
-
import { getPluginState
|
|
8
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
9
9
|
import { getClosestSelectionRect } from '../toolbar';
|
|
10
10
|
export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
11
11
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
@@ -196,8 +196,8 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
|
196
196
|
var $from = selection.$from;
|
|
197
197
|
var isColumnResizing = false;
|
|
198
198
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
199
|
-
var columResizePluginState =
|
|
200
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.
|
|
199
|
+
var columResizePluginState = getPluginState(state) || {};
|
|
200
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
201
201
|
}
|
|
202
202
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
203
203
|
// + 3 for: row, cell & paragraph nodes
|
|
@@ -230,8 +230,8 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
|
230
230
|
var $to = selection.$to;
|
|
231
231
|
var isColumnResizing = false;
|
|
232
232
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
233
|
-
var columResizePluginState =
|
|
234
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.
|
|
233
|
+
var columResizePluginState = getPluginState(state) || {};
|
|
234
|
+
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
235
235
|
}
|
|
236
236
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
237
237
|
// + 3 for: row, cell & paragraph nodes
|
|
@@ -5,6 +5,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
9
10
|
import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
|
|
10
11
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
@@ -163,15 +164,25 @@ export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
|
|
|
163
164
|
if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
|
|
164
165
|
var _state2 = view.state,
|
|
165
166
|
_dispatch3 = view.dispatch;
|
|
166
|
-
|
|
167
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
168
|
+
var _getPluginState2 = getPluginState(_state2),
|
|
169
|
+
isKeyboardResize = _getPluginState2.isKeyboardResize;
|
|
170
|
+
if (isKeyboardResize) {
|
|
171
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
return hideResizeHandleLine()(_state2, _dispatch3);
|
|
175
|
+
} else {
|
|
176
|
+
return hideResizeHandleLine()(_state2, _dispatch3);
|
|
177
|
+
}
|
|
167
178
|
}
|
|
168
179
|
return false;
|
|
169
180
|
};
|
|
170
181
|
export var handleMouseEnter = function handleMouseEnter(view, mouseEvent) {
|
|
171
182
|
var state = view.state,
|
|
172
183
|
dispatch = view.dispatch;
|
|
173
|
-
var
|
|
174
|
-
isTableHovered =
|
|
184
|
+
var _getPluginState3 = getPluginState(state),
|
|
185
|
+
isTableHovered = _getPluginState3.isTableHovered;
|
|
175
186
|
if (!isTableHovered) {
|
|
176
187
|
return setTableHovered(true)(state, dispatch);
|
|
177
188
|
}
|
|
@@ -183,11 +194,11 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
|
|
|
183
194
|
}
|
|
184
195
|
var state = view.state,
|
|
185
196
|
dispatch = view.dispatch;
|
|
186
|
-
var
|
|
187
|
-
insertColumnButtonIndex =
|
|
188
|
-
insertRowButtonIndex =
|
|
189
|
-
isDragAndDropEnabled =
|
|
190
|
-
isTableHovered =
|
|
197
|
+
var _getPluginState4 = getPluginState(state),
|
|
198
|
+
insertColumnButtonIndex = _getPluginState4.insertColumnButtonIndex,
|
|
199
|
+
insertRowButtonIndex = _getPluginState4.insertRowButtonIndex,
|
|
200
|
+
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled,
|
|
201
|
+
isTableHovered = _getPluginState4.isTableHovered;
|
|
191
202
|
if (isTableHovered) {
|
|
192
203
|
if (isDragAndDropEnabled) {
|
|
193
204
|
var _getDragDropPluginSta = getDragDropPluginState(state),
|
|
@@ -220,9 +231,9 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
220
231
|
if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
|
|
221
232
|
var state = view.state,
|
|
222
233
|
dispatch = view.dispatch;
|
|
223
|
-
var
|
|
224
|
-
insertColumnButtonIndex =
|
|
225
|
-
isDragAndDropEnabled =
|
|
234
|
+
var _getPluginState5 = getPluginState(state),
|
|
235
|
+
insertColumnButtonIndex = _getPluginState5.insertColumnButtonIndex,
|
|
236
|
+
isDragAndDropEnabled = _getPluginState5.isDragAndDropEnabled;
|
|
226
237
|
var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
|
|
227
238
|
_getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
|
|
228
239
|
startIndex = _getColumnOrRowIndex10[0],
|
|
@@ -235,8 +246,8 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
235
246
|
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
236
247
|
var _state3 = view.state,
|
|
237
248
|
_dispatch4 = view.dispatch;
|
|
238
|
-
var
|
|
239
|
-
insertRowButtonIndex =
|
|
249
|
+
var _getPluginState6 = getPluginState(_state3),
|
|
250
|
+
insertRowButtonIndex = _getPluginState6.insertRowButtonIndex;
|
|
240
251
|
var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
|
|
241
252
|
_getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
|
|
242
253
|
_startIndex3 = _getColumnOrRowIndex12[0],
|
|
@@ -251,19 +262,21 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
251
262
|
if (_positionColumn !== null) {
|
|
252
263
|
var _state4 = view.state,
|
|
253
264
|
_dispatch5 = view.dispatch;
|
|
254
|
-
var
|
|
255
|
-
resizeHandleColumnIndex =
|
|
256
|
-
resizeHandleRowIndex =
|
|
265
|
+
var _getPluginState7 = getPluginState(_state4),
|
|
266
|
+
resizeHandleColumnIndex = _getPluginState7.resizeHandleColumnIndex,
|
|
267
|
+
resizeHandleRowIndex = _getPluginState7.resizeHandleRowIndex;
|
|
268
|
+
var isKeyboardResize = getBooleanFF('platform.editor.a11y-column-resizing_emcvz') ? getPluginState(_state4).isKeyboardResize : false;
|
|
257
269
|
var tableCell = closestElement(element, 'td, th');
|
|
258
270
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
259
271
|
var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
|
|
260
272
|
if (rect) {
|
|
261
273
|
var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
|
|
262
274
|
var rowIndexTarget = rect.top;
|
|
263
|
-
if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
|
|
275
|
+
if ((columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
|
|
264
276
|
target: element,
|
|
265
277
|
columnEndIndexTarget: columnEndIndexTarget
|
|
266
|
-
}))
|
|
278
|
+
})) && !isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
|
|
279
|
+
) {
|
|
267
280
|
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
|
|
268
281
|
}
|
|
269
282
|
}
|
|
@@ -328,8 +341,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
328
341
|
if (isTableSelected) {
|
|
329
342
|
tr = removeTable(tr);
|
|
330
343
|
} else if (tr.selection.isRowSelection()) {
|
|
331
|
-
var
|
|
332
|
-
isHeaderRowRequired =
|
|
344
|
+
var _getPluginState8 = getPluginState(newState),
|
|
345
|
+
isHeaderRowRequired = _getPluginState8.pluginConfig.isHeaderRowRequired;
|
|
333
346
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
334
347
|
} else if (tr.selection.isColSelection()) {
|
|
335
348
|
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
|
|
@@ -341,8 +354,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
341
354
|
return tr;
|
|
342
355
|
};
|
|
343
356
|
export var isTableInFocus = function isTableInFocus(view) {
|
|
344
|
-
var
|
|
345
|
-
return !!((
|
|
357
|
+
var _getPluginState9, _getResizePluginState;
|
|
358
|
+
return !!((_getPluginState9 = getPluginState(view.state)) !== null && _getPluginState9 !== void 0 && _getPluginState9.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
346
359
|
};
|
|
347
360
|
export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
|
|
348
361
|
return function (view, mouseEvent) {
|
|
@@ -356,9 +369,9 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
|
|
|
356
369
|
var _tableElement$dataset;
|
|
357
370
|
var target = mouseEvent.target;
|
|
358
371
|
var maybeTableCell = isElementInTableCell(target);
|
|
359
|
-
var
|
|
360
|
-
tableNode =
|
|
361
|
-
tableRef =
|
|
372
|
+
var _getPluginState10 = getPluginState(view.state),
|
|
373
|
+
tableNode = _getPluginState10.tableNode,
|
|
374
|
+
tableRef = _getPluginState10.tableRef;
|
|
362
375
|
var tableElement = closestElement(target, 'table');
|
|
363
376
|
|
|
364
377
|
// hover will only trigger if target localId is the same with selected localId
|