@atlaskit/editor-plugin-table 7.5.4 → 7.5.6
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 +13 -0
- package/dist/cjs/commands/column-resize.js +3 -3
- package/dist/cjs/commands/delete.js +2 -2
- package/dist/cjs/commands/insert.js +15 -15
- package/dist/cjs/commands-with-analytics.js +7 -7
- package/dist/cjs/event-handlers.js +27 -11
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +120 -83
- package/dist/cjs/nodeviews/TableContainer.js +23 -21
- package/dist/cjs/nodeviews/TableResizer.js +13 -13
- package/dist/cjs/nodeviews/table.js +9 -9
- package/dist/cjs/plugin.js +60 -59
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/cjs/pm-plugins/keymap.js +6 -8
- package/dist/cjs/pm-plugins/main.js +7 -24
- package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/cjs/pm-plugins/table-width.js +6 -2
- package/dist/cjs/toolbar.js +21 -21
- package/dist/cjs/transforms/column-width.js +4 -4
- package/dist/cjs/transforms/delete-columns.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
- package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/create.js +2 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/cjs/utils/drag-menu.js +4 -4
- package/dist/es2019/commands/column-resize.js +3 -3
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +12 -12
- package/dist/es2019/commands-with-analytics.js +6 -6
- package/dist/es2019/event-handlers.js +27 -11
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +88 -63
- package/dist/es2019/nodeviews/TableContainer.js +20 -22
- package/dist/es2019/nodeviews/TableResizer.js +13 -13
- package/dist/es2019/nodeviews/table.js +9 -9
- package/dist/es2019/plugin.js +19 -20
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
- package/dist/es2019/pm-plugins/keymap.js +5 -8
- package/dist/es2019/pm-plugins/main.js +6 -23
- package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/es2019/pm-plugins/table-width.js +6 -2
- package/dist/es2019/toolbar.js +15 -15
- package/dist/es2019/transforms/column-width.js +5 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
- package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/create.js +2 -5
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +3 -3
- package/dist/esm/commands/delete.js +2 -2
- package/dist/esm/commands/insert.js +15 -15
- package/dist/esm/commands-with-analytics.js +7 -7
- package/dist/esm/event-handlers.js +27 -11
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +119 -82
- package/dist/esm/nodeviews/TableContainer.js +24 -22
- package/dist/esm/nodeviews/TableResizer.js +13 -13
- package/dist/esm/nodeviews/table.js +9 -9
- package/dist/esm/plugin.js +60 -59
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
- package/dist/esm/pm-plugins/keymap.js +6 -8
- package/dist/esm/pm-plugins/main.js +7 -24
- package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
- package/dist/esm/pm-plugins/table-width.js +6 -2
- package/dist/esm/toolbar.js +21 -21
- package/dist/esm/transforms/column-width.js +5 -5
- package/dist/esm/transforms/delete-columns.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
- package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/create.js +2 -5
- package/dist/esm/utils/dom.js +13 -15
- package/dist/esm/utils/drag-menu.js +4 -4
- package/dist/types/commands/column-resize.d.ts +1 -1
- package/dist/types/commands/delete.d.ts +1 -1
- package/dist/types/commands/insert.d.ts +7 -7
- package/dist/types/commands-with-analytics.d.ts +3 -3
- package/dist/types/event-handlers.d.ts +4 -5
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.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 +2 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types/pm-plugins/table-width.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -2
- package/dist/types/transforms/column-width.d.ts +1 -1
- package/dist/types/transforms/delete-columns.d.ts +1 -1
- package/dist/types/types.d.ts +1 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/create.d.ts +1 -2
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/commands/delete.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +7 -7
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/event-handlers.d.ts +4 -5
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
- 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/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.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 +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -2
- package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/create.d.ts +1 -2
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -4
- package/src/commands/column-resize.ts +4 -3
- package/src/commands/delete.ts +2 -2
- package/src/commands/insert.ts +15 -27
- package/src/commands-with-analytics.ts +6 -9
- package/src/event-handlers.ts +107 -105
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +107 -78
- package/src/nodeviews/TableContainer.tsx +26 -32
- package/src/nodeviews/TableResizer.tsx +15 -18
- package/src/nodeviews/table.tsx +6 -5
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +17 -32
- package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
- package/src/pm-plugins/keymap.ts +6 -13
- package/src/pm-plugins/main.ts +6 -25
- package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
- package/src/pm-plugins/table-width.ts +4 -6
- package/src/toolbar.tsx +16 -19
- package/src/transforms/column-width.ts +7 -6
- package/src/transforms/delete-columns.ts +2 -2
- package/src/types.ts +1 -4
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
- package/src/ui/FloatingContextualMenu/index.tsx +0 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
- package/src/ui/FloatingDragMenu/index.tsx +4 -8
- package/src/ui/FloatingInsertButton/index.tsx +11 -22
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/create.ts +2 -5
- package/src/utils/dom.ts +12 -19
- package/src/utils/drag-menu.ts +7 -12
|
@@ -70,7 +70,7 @@ var defaultSelectionRect = {
|
|
|
70
70
|
};
|
|
71
71
|
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
72
72
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
73
|
-
var
|
|
73
|
+
var isTableScalingEnabled = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
74
74
|
var addOptions = direction === 'row' ? [{
|
|
75
75
|
label: 'above',
|
|
76
76
|
offset: 0,
|
|
@@ -155,7 +155,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
155
155
|
moveCursorToInsertedRow: true
|
|
156
156
|
})(state, dispatch);
|
|
157
157
|
} else {
|
|
158
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(
|
|
158
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
159
159
|
}
|
|
160
160
|
return true;
|
|
161
161
|
},
|
|
@@ -168,7 +168,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
168
168
|
onClick: function onClick(state, dispatch) {
|
|
169
169
|
var selectionRect = (0, _toolbar.getClosestSelectionRect)(state);
|
|
170
170
|
if (selectionRect) {
|
|
171
|
-
var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth,
|
|
171
|
+
var newResizeState = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
172
172
|
if (newResizeState) {
|
|
173
173
|
(0, _commandsWithAnalytics.distributeColumnsWidthsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
|
|
174
174
|
return true;
|
|
@@ -194,7 +194,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
194
194
|
if (direction === 'row') {
|
|
195
195
|
(0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
196
196
|
} else {
|
|
197
|
-
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI,
|
|
197
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
|
|
198
198
|
}
|
|
199
199
|
return true;
|
|
200
200
|
},
|
|
@@ -121,7 +121,7 @@ export const activateNextResizeArea = direction => (state, dispatch, view) => {
|
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
123
123
|
};
|
|
124
|
-
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth,
|
|
124
|
+
export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth, isTableScalingEnabled = false) => (state, dispatch, view) => {
|
|
125
125
|
let customTr = state.tr;
|
|
126
126
|
const fakeDispatch = tr => {
|
|
127
127
|
customTr = tr;
|
|
@@ -171,14 +171,14 @@ export const changeColumnWidthByStep = (stepSize, getEditorContainerWidth, table
|
|
|
171
171
|
tableRef: dom,
|
|
172
172
|
start: tableStartPosition,
|
|
173
173
|
domAtPos,
|
|
174
|
-
|
|
174
|
+
isTableScalingEnabled
|
|
175
175
|
});
|
|
176
176
|
updateControls()(state);
|
|
177
177
|
const selectionRect = getSelectionRect(state.selection);
|
|
178
178
|
const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
179
179
|
// only selected (or selected - 1) columns should be distributed
|
|
180
180
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
181
|
-
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined,
|
|
181
|
+
const newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
|
|
182
182
|
customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
|
|
183
183
|
if (dispatch) {
|
|
184
184
|
dispatch(customTr);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteColumns } from '../transforms/delete-columns';
|
|
2
2
|
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
|
-
export const deleteColumnsCommand = (rect,
|
|
4
|
-
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view,
|
|
3
|
+
export const deleteColumnsCommand = (rect, isTableScalingEnabled = false) => (state, dispatch, view) => {
|
|
4
|
+
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, isTableScalingEnabled)(state.tr);
|
|
5
5
|
if (dispatch) {
|
|
6
6
|
dispatch(tr);
|
|
7
7
|
return true;
|
|
@@ -20,7 +20,7 @@ function addColumnAtCustomStep(column) {
|
|
|
20
20
|
return tr;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export function addColumnAt(
|
|
23
|
+
export function addColumnAt(isTableScalingEnabled = false) {
|
|
24
24
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
25
25
|
return tr => {
|
|
26
26
|
let updatedTr = tr;
|
|
@@ -32,7 +32,7 @@ export function addColumnAt(getEditorContainerWidth, tablePreserveWidth = false)
|
|
|
32
32
|
const table = findTable(updatedTr.selection);
|
|
33
33
|
if (table) {
|
|
34
34
|
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
35
|
-
updatedTr = rescaleColumns(
|
|
35
|
+
updatedTr = rescaleColumns(isTableScalingEnabled)(table, view)(updatedTr);
|
|
36
36
|
}
|
|
37
37
|
if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
|
|
38
38
|
updatedTr = updateRowOrColumnMovedTransform({
|
|
@@ -49,33 +49,33 @@ export function addColumnAt(getEditorContainerWidth, tablePreserveWidth = false)
|
|
|
49
49
|
|
|
50
50
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
51
51
|
// Command to add a column before the column with the selection.
|
|
52
|
-
export const addColumnBefore = (
|
|
52
|
+
export const addColumnBefore = (isTableScalingEnabled = false) => (state, dispatch, view) => {
|
|
53
53
|
const table = findTable(state.selection);
|
|
54
54
|
if (!table) {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
if (dispatch) {
|
|
58
58
|
let rect = selectedRect(state);
|
|
59
|
-
dispatch(addColumnAt(
|
|
59
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
60
60
|
}
|
|
61
61
|
return true;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
65
65
|
// Command to add a column after the column with the selection.
|
|
66
|
-
export const addColumnAfter =
|
|
66
|
+
export const addColumnAfter = isTableScalingEnabled => (state, dispatch, view) => {
|
|
67
67
|
const table = findTable(state.selection);
|
|
68
68
|
if (!table) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
if (dispatch) {
|
|
72
72
|
let rect = selectedRect(state);
|
|
73
|
-
dispatch(addColumnAt(
|
|
73
|
+
dispatch(addColumnAt(isTableScalingEnabled)(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
74
74
|
}
|
|
75
75
|
return true;
|
|
76
76
|
};
|
|
77
|
-
export const insertColumn = (
|
|
78
|
-
let tr = addColumnAt(
|
|
77
|
+
export const insertColumn = (isTableScalingEnabled = false) => column => (state, dispatch, view) => {
|
|
78
|
+
let tr = addColumnAt(isTableScalingEnabled)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
79
79
|
const table = findTable(tr.selection);
|
|
80
80
|
if (!table) {
|
|
81
81
|
return false;
|
|
@@ -122,18 +122,18 @@ export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
|
122
122
|
}
|
|
123
123
|
return true;
|
|
124
124
|
};
|
|
125
|
-
export const createTable = (
|
|
126
|
-
const table = createTableWithWidth(
|
|
125
|
+
export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled) => (state, dispatch) => {
|
|
126
|
+
const table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
127
127
|
if (dispatch) {
|
|
128
128
|
dispatch(safeInsert(table)(state.tr).scrollIntoView());
|
|
129
129
|
}
|
|
130
130
|
return true;
|
|
131
131
|
};
|
|
132
|
-
export const insertTableWithSize = (isFullWidthModeEnabled,
|
|
132
|
+
export const insertTableWithSize = (isFullWidthModeEnabled, isTableScalingEnabled, editorAnalyticsAPI) => (rowsCount, colsCount, inputMethod) => {
|
|
133
133
|
return ({
|
|
134
134
|
tr
|
|
135
135
|
}) => {
|
|
136
|
-
const tableNode = createTableWithWidth(
|
|
136
|
+
const tableNode = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, {
|
|
137
137
|
rowsCount: rowsCount,
|
|
138
138
|
colsCount: colsCount
|
|
139
139
|
})(tr.doc.type.schema);
|
|
@@ -168,7 +168,7 @@ export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, option
|
|
|
168
168
|
eventType: EVENT_TYPE.TRACK
|
|
169
169
|
};
|
|
170
170
|
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
171
|
-
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth,
|
|
171
|
+
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
172
172
|
const {
|
|
173
173
|
table,
|
|
174
174
|
totalRowCount,
|
|
@@ -193,8 +193,8 @@ export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepS
|
|
|
193
193
|
totalColumnCount
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth,
|
|
197
|
-
export const insertColumnWithAnalytics = (
|
|
196
|
+
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth, isTableScalingEnabled));
|
|
197
|
+
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
198
198
|
const {
|
|
199
199
|
totalRowCount,
|
|
200
200
|
totalColumnCount
|
|
@@ -211,7 +211,7 @@ export const insertColumnWithAnalytics = (getEditorContainerWidth, editorAnalyti
|
|
|
211
211
|
},
|
|
212
212
|
eventType: EVENT_TYPE.TRACK
|
|
213
213
|
};
|
|
214
|
-
})(editorAnalyticsAPI)(insertColumn(
|
|
214
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled)(position));
|
|
215
215
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
216
216
|
selection
|
|
217
217
|
}) => {
|
|
@@ -238,7 +238,7 @@ export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect,
|
|
|
238
238
|
}
|
|
239
239
|
return true;
|
|
240
240
|
});
|
|
241
|
-
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI,
|
|
241
|
+
export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false) => (inputMethod, rect) => withEditorAnalyticsAPI(({
|
|
242
242
|
selection
|
|
243
243
|
}) => {
|
|
244
244
|
const {
|
|
@@ -258,7 +258,7 @@ export const deleteColumnsWithAnalytics = (editorAnalyticsAPI, tablePreserveWidt
|
|
|
258
258
|
},
|
|
259
259
|
eventType: EVENT_TYPE.TRACK
|
|
260
260
|
};
|
|
261
|
-
})(editorAnalyticsAPI)(deleteColumnsCommand(rect,
|
|
261
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect, isTableScalingEnabled));
|
|
262
262
|
export const deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = editorAnalyticsAPI => (state, dispatch) => {
|
|
263
263
|
const {
|
|
264
264
|
selection
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import rafSchedule from 'raf-schd';
|
|
1
2
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
3
4
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -261,7 +262,10 @@ export const handleMouseLeave = (view, event) => {
|
|
|
261
262
|
}
|
|
262
263
|
return false;
|
|
263
264
|
};
|
|
264
|
-
|
|
265
|
+
|
|
266
|
+
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
267
|
+
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
268
|
+
const handleMouseMoveDebounce = rafSchedule((view, event, offsetX) => {
|
|
265
269
|
if (!(event.target instanceof HTMLElement)) {
|
|
266
270
|
return false;
|
|
267
271
|
}
|
|
@@ -272,11 +276,10 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
272
276
|
dispatch
|
|
273
277
|
} = view;
|
|
274
278
|
const {
|
|
275
|
-
insertColumnButtonIndex
|
|
276
|
-
isDragAndDropEnabled
|
|
279
|
+
insertColumnButtonIndex
|
|
277
280
|
} = getPluginState(state);
|
|
278
281
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
279
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
282
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, undefined) === 'right' ? endIndex : startIndex;
|
|
280
283
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
281
284
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
282
285
|
}
|
|
@@ -296,7 +299,7 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
299
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
302
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
300
303
|
if (positionColumn !== null) {
|
|
301
304
|
const {
|
|
302
305
|
state,
|
|
@@ -324,6 +327,19 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
return false;
|
|
330
|
+
});
|
|
331
|
+
export const handleMouseMove = (view, event) => {
|
|
332
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
|
|
337
|
+
// within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
|
|
338
|
+
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
339
|
+
// in the deferred callback handler.
|
|
340
|
+
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
341
|
+
handleMouseMoveDebounce(view, event, browser.gecko ? event.offsetX : NaN);
|
|
342
|
+
return false;
|
|
327
343
|
};
|
|
328
344
|
export function handleTripleClick(view, pos) {
|
|
329
345
|
const {
|
|
@@ -345,7 +361,7 @@ export function handleTripleClick(view, pos) {
|
|
|
345
361
|
}
|
|
346
362
|
return false;
|
|
347
363
|
}
|
|
348
|
-
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView,
|
|
364
|
+
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView, isTableScalingEnabled = false) => {
|
|
349
365
|
const oldSelection = oldState.tr.selection;
|
|
350
366
|
let {
|
|
351
367
|
tr
|
|
@@ -394,7 +410,7 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorV
|
|
|
394
410
|
} = getPluginState(newState);
|
|
395
411
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
396
412
|
} else if (tr.selection.isColSelection()) {
|
|
397
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView,
|
|
413
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, isTableScalingEnabled)(tr);
|
|
398
414
|
}
|
|
399
415
|
}
|
|
400
416
|
}
|
|
@@ -406,11 +422,11 @@ export const isTableInFocus = view => {
|
|
|
406
422
|
var _getPluginState, _getResizePluginState;
|
|
407
423
|
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
408
424
|
};
|
|
409
|
-
export const whenTableInFocus =
|
|
425
|
+
export const whenTableInFocus = eventHandler => (view, mouseEvent) => {
|
|
410
426
|
if (!isTableInFocus(view)) {
|
|
411
427
|
return false;
|
|
412
428
|
}
|
|
413
|
-
return eventHandler(view, mouseEvent
|
|
429
|
+
return eventHandler(view, mouseEvent);
|
|
414
430
|
};
|
|
415
431
|
const trackCellLocation = (view, mouseEvent) => {
|
|
416
432
|
var _tableElement$dataset;
|
|
@@ -440,9 +456,9 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
440
456
|
}
|
|
441
457
|
hoverCell(htmlRowIndex, colIndex)(view.state, view.dispatch);
|
|
442
458
|
};
|
|
443
|
-
export const withCellTracking =
|
|
459
|
+
export const withCellTracking = eventHandler => (view, mouseEvent) => {
|
|
444
460
|
if (getPluginState(view.state).isDragAndDropEnabled && !getDragDropPluginState(view.state).isDragging) {
|
|
445
461
|
trackCellLocation(view, mouseEvent);
|
|
446
462
|
}
|
|
447
|
-
return eventHandler(view, mouseEvent
|
|
463
|
+
return eventHandler(view, mouseEvent);
|
|
448
464
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import rafSchedule from 'raf-schd';
|
|
2
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
4
5
|
import { tableInsertColumnButtonSize } from '../ui/consts';
|
|
@@ -36,8 +37,13 @@ export class OverflowShadowsObserver {
|
|
|
36
37
|
});
|
|
37
38
|
_defineProperty(this, "observeShadowSentinels", isSticky => {
|
|
38
39
|
var _this$table, _this$table2;
|
|
40
|
+
if (this.isSticky === isSticky) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
39
43
|
this.isSticky = !!isSticky;
|
|
40
44
|
|
|
45
|
+
// reset height
|
|
46
|
+
this.stickyRowHeight = 0;
|
|
41
47
|
// update sticky shadows
|
|
42
48
|
this.updateStickyShadowsHeightIfChanged();
|
|
43
49
|
this.leftShadowSentinel = (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(`.${ClassName.TABLE_SHADOW_SENTINEL_LEFT}`);
|
|
@@ -54,8 +60,8 @@ export class OverflowShadowsObserver {
|
|
|
54
60
|
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
55
61
|
* reading it from sticky cell
|
|
56
62
|
*/
|
|
57
|
-
_defineProperty(this, "updateStickyShadows", stickyRowHeight => {
|
|
58
|
-
var _this$wrapper
|
|
63
|
+
_defineProperty(this, "updateStickyShadows", rafSchedule(stickyRowHeight => {
|
|
64
|
+
var _this$wrapper;
|
|
59
65
|
if (!this.isSticky) {
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
@@ -63,14 +69,21 @@ export class OverflowShadowsObserver {
|
|
|
63
69
|
if (!stickyCell || !((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement)) {
|
|
64
70
|
return;
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
|
|
73
|
+
// Reflow Warning! - stickyCell.clientHeight
|
|
74
|
+
const newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
|
|
75
|
+
if (newStickyRowHeight !== this.stickyRowHeight) {
|
|
76
|
+
var _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
|
|
77
|
+
this.stickyRowHeight = newStickyRowHeight;
|
|
78
|
+
const heightStyleOrCompute = `${newStickyRowHeight}px`;
|
|
79
|
+
// Use getElementsByClassName here for a live node list to capture
|
|
80
|
+
// sticky shadows
|
|
81
|
+
const liveRightShadows = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : (_this$wrapper2$parent = _this$wrapper2.parentElement) === null || _this$wrapper2$parent === void 0 ? void 0 : _this$wrapper2$parent.getElementsByClassName(`${ClassName.TABLE_RIGHT_SHADOW}`);
|
|
82
|
+
const liveLeftShadows = (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 ? void 0 : (_this$wrapper3$parent = _this$wrapper3.parentElement) === null || _this$wrapper3$parent === void 0 ? void 0 : _this$wrapper3$parent.getElementsByClassName(`${ClassName.TABLE_LEFT_SHADOW}`);
|
|
83
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
|
|
84
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
74
87
|
this.updateShadowState = updateShadowState;
|
|
75
88
|
this.table = _table;
|
|
76
89
|
this.wrapper = wrapper;
|
|
@@ -84,11 +97,7 @@ export class OverflowShadowsObserver {
|
|
|
84
97
|
if (!stickyCell) {
|
|
85
98
|
return;
|
|
86
99
|
}
|
|
87
|
-
|
|
88
|
-
if (newStickyRowHeight === this.stickyRowHeight) {
|
|
89
|
-
this.stickyRowHeight = newStickyRowHeight;
|
|
90
|
-
this.updateStickyShadows(this.stickyRowHeight);
|
|
91
|
-
}
|
|
100
|
+
this.updateStickyShadows();
|
|
92
101
|
}
|
|
93
102
|
getStickyCell() {
|
|
94
103
|
var _this$wrapper4;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import uuid from 'uuid';
|
|
2
1
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
3
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
4
2
|
import TableNodeView from './TableNodeViewBase';
|
|
5
3
|
const DEFAULT_COL_SPAN = 1;
|
|
6
4
|
const DEFAULT_ROW_SPAN = 1;
|
|
7
5
|
export default class TableCell extends TableNodeView {
|
|
8
|
-
constructor(node, view, getPos, eventDispatcher
|
|
6
|
+
constructor(node, view, getPos, eventDispatcher) {
|
|
9
7
|
super(node, view, getPos, eventDispatcher);
|
|
10
|
-
this.observer = observer;
|
|
11
|
-
const {
|
|
12
|
-
pluginConfig,
|
|
13
|
-
isDragAndDropEnabled
|
|
14
|
-
} = getPluginState(view.state);
|
|
15
|
-
this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
16
|
-
this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
17
|
-
if (observer) {
|
|
18
|
-
this.contentDOM.id = uuid();
|
|
19
|
-
observer.observe(this.contentDOM);
|
|
20
|
-
}
|
|
21
8
|
}
|
|
22
|
-
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
|
|
27
9
|
update(node) {
|
|
28
10
|
const didUpdate = this.updateNodeView(node);
|
|
29
11
|
if (didUpdate) {
|
|
@@ -31,11 +13,6 @@ export default class TableCell extends TableNodeView {
|
|
|
31
13
|
}
|
|
32
14
|
return didUpdate;
|
|
33
15
|
}
|
|
34
|
-
destroy() {
|
|
35
|
-
if (this.observer) {
|
|
36
|
-
this.observer.unobserve(this.contentDOM);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
16
|
updateNodeView(node) {
|
|
40
17
|
if (this.node.type !== node.type) {
|
|
41
18
|
return false;
|