@atlaskit/editor-plugin-table 7.5.2 → 7.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/commands-with-analytics.js +65 -38
- package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -2
- package/dist/cjs/nodeviews/TableCell.js +1 -1
- package/dist/cjs/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/nodeviews/TableContainer.js +3 -3
- package/dist/cjs/nodeviews/TableResizer.js +10 -10
- package/dist/cjs/nodeviews/TableRow.js +1 -1
- package/dist/cjs/nodeviews/table.js +1 -1
- package/dist/cjs/pm-plugins/keymap.js +2 -2
- package/dist/cjs/pm-plugins/table-analytics.js +2 -2
- package/dist/cjs/pm-plugins/table-local-id.js +11 -11
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +16 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/toolbar.js +2 -2
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -5
- package/dist/cjs/ui/DragHandle/index.js +2 -2
- package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/ui/FloatingDeleteButton/index.js +3 -3
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +2 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -3
- package/dist/cjs/ui/LayoutButton/index.js +3 -3
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/RowDropTarget/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/index.js +3 -3
- package/dist/cjs/utils/decoration.js +0 -4
- package/dist/cjs/utils/guidelines.js +5 -2
- package/dist/cjs/utils/merged-cells.js +0 -1
- package/dist/cjs/utils/snapping.js +14 -1
- package/dist/es2019/commands-with-analytics.js +27 -0
- package/dist/es2019/nodeviews/TableContainer.js +2 -2
- package/dist/es2019/nodeviews/TableResizer.js +10 -10
- package/dist/es2019/pm-plugins/keymap.js +4 -4
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +17 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/es2019/reducer.js +0 -2
- package/dist/es2019/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/es2019/utils/decoration.js +0 -4
- package/dist/es2019/utils/guidelines.js +3 -2
- package/dist/es2019/utils/merged-cells.js +0 -1
- package/dist/es2019/utils/snapping.js +12 -1
- package/dist/esm/commands-with-analytics.js +64 -37
- package/dist/esm/nodeviews/TableCell.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/TableContainer.js +2 -2
- package/dist/esm/nodeviews/TableResizer.js +10 -10
- package/dist/esm/nodeviews/TableRow.js +1 -1
- package/dist/esm/nodeviews/table.js +1 -1
- package/dist/esm/pm-plugins/keymap.js +4 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +17 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/ui/LayoutButton/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/index.js +1 -1
- package/dist/esm/utils/decoration.js +0 -4
- package/dist/esm/utils/guidelines.js +5 -2
- package/dist/esm/utils/merged-cells.js +0 -1
- package/dist/esm/utils/snapping.js +14 -1
- package/dist/types/commands-with-analytics.d.ts +1 -0
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types/utils/guidelines.d.ts +1 -0
- package/dist/types/utils/snapping.d.ts +2 -0
- package/dist/types-ts4.5/commands-with-analytics.d.ts +1 -0
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/utils/guidelines.d.ts +1 -0
- package/dist/types-ts4.5/utils/snapping.d.ts +2 -0
- package/package.json +1 -1
- package/src/commands-with-analytics.ts +39 -0
- package/src/nodeviews/TableContainer.tsx +10 -1
- package/src/nodeviews/TableResizer.tsx +39 -19
- package/src/pm-plugins/keymap.ts +13 -3
- package/src/pm-plugins/table-resizing/event-handlers.ts +20 -1
- package/src/ui/ColumnResizeWidget/index.tsx +2 -4
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
- package/src/utils/drag-menu.ts +1 -1
- package/src/utils/guidelines.ts +12 -1
- package/src/utils/snapping.ts +36 -0
|
@@ -4,8 +4,8 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { createTable, goToNextCell, moveCursorBackward } from '../commands';
|
|
7
|
-
import { addRowAroundSelection, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
|
-
import { activateNextResizeArea,
|
|
7
|
+
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
|
+
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
|
|
10
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
11
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
@@ -56,8 +56,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
|
|
|
56
56
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
57
57
|
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
58
58
|
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
59
|
-
bindKeymapWithCommand(decreaseMediaSize.common,
|
|
60
|
-
bindKeymapWithCommand(increaseMediaSize.common,
|
|
59
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
|
|
60
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
|
|
61
61
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
|
|
62
62
|
}
|
|
63
63
|
return keymap(list);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -154,6 +154,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
154
154
|
// only selected (or selected - 1) columns should be distributed
|
|
155
155
|
const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
156
156
|
const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
|
|
157
|
+
const resizedDelta = clientX - startX;
|
|
157
158
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
158
159
|
if (colIndex === map.width - 1) {
|
|
159
160
|
const mouseUpTime = event.timeStamp;
|
|
@@ -165,11 +166,25 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
165
166
|
type: 'table-border',
|
|
166
167
|
position: 'right',
|
|
167
168
|
duration: mouseUpTime - mouseDownTime,
|
|
168
|
-
delta: Math.abs(
|
|
169
|
+
delta: Math.abs(resizedDelta)
|
|
169
170
|
},
|
|
170
171
|
eventType: EVENT_TYPE.UI
|
|
171
172
|
})(tr);
|
|
172
173
|
}
|
|
174
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
175
|
+
action: TABLE_ACTION.COLUMN_RESIZED,
|
|
176
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
177
|
+
eventType: EVENT_TYPE.TRACK,
|
|
178
|
+
attributes: {
|
|
179
|
+
colIndex: colIndex,
|
|
180
|
+
resizedDelta,
|
|
181
|
+
isLastColumn: colIndex === map.width - 1,
|
|
182
|
+
tableWidth: table.attrs.width,
|
|
183
|
+
inputMethod: INPUT_METHOD.MOUSE,
|
|
184
|
+
totalRowCount: map.height,
|
|
185
|
+
totalColumnCount: map.width
|
|
186
|
+
}
|
|
187
|
+
})(tr);
|
|
173
188
|
}
|
|
174
189
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
175
190
|
if (isKeyboardResize || !isTableHovered) {
|
|
@@ -39,7 +39,6 @@ export const getResizeState = ({
|
|
|
39
39
|
// Getting the resize state from DOM
|
|
40
40
|
const colgroupChildren = insertColgroupFromNode(tableRef, table, tablePreserveWidth, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
|
|
41
41
|
);
|
|
42
|
-
|
|
43
42
|
const cols = Array.from(colgroupChildren).map((_, index) => {
|
|
44
43
|
// If the table hasn't been resized and we have a table width attribute, we can use it
|
|
45
44
|
// to calculate the widths of the columns
|
package/dist/es2019/reducer.js
CHANGED
|
@@ -48,7 +48,6 @@ export default ((pluginState, action) => {
|
|
|
48
48
|
...action.data,
|
|
49
49
|
insertColumnButtonIndex: undefined // We need to assure that column is not shown
|
|
50
50
|
};
|
|
51
|
-
|
|
52
51
|
case 'SHOW_INSERT_COLUMN_BUTTON':
|
|
53
52
|
if (action.data.insertColumnButtonIndex === pluginState.insertColumnButtonIndex) {
|
|
54
53
|
return pluginState;
|
|
@@ -58,7 +57,6 @@ export default ((pluginState, action) => {
|
|
|
58
57
|
...action.data,
|
|
59
58
|
insertRowButtonIndex: undefined // We need to assure that row is not shown
|
|
60
59
|
};
|
|
61
|
-
|
|
62
60
|
case 'HIDE_INSERT_COLUMN_OR_ROW_BUTTON':
|
|
63
61
|
if (pluginState.insertRowButtonIndex !== undefined || pluginState.insertColumnButtonIndex !== undefined) {
|
|
64
62
|
return {
|
|
@@ -406,11 +406,9 @@ export const createColumnLineResize = (selection, cellColumnPositioning) => {
|
|
|
406
406
|
if (isLastColumn) {
|
|
407
407
|
return true; // If is the last column no filter applied
|
|
408
408
|
}
|
|
409
|
-
|
|
410
409
|
const nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
|
|
411
410
|
return cellPosition !== nextPosition; // Removed it if next position is merged
|
|
412
411
|
});
|
|
413
|
-
|
|
414
412
|
const cells = cellPositions.map(pos => ({
|
|
415
413
|
pos: pos + table.start,
|
|
416
414
|
node: table.node.nodeAt(pos)
|
|
@@ -447,11 +445,9 @@ export const createColumnInsertLine = (columnIndex, selection, hasMergedCells) =
|
|
|
447
445
|
if (isLastColumn) {
|
|
448
446
|
return true; // If is the last column no filter applied
|
|
449
447
|
}
|
|
450
|
-
|
|
451
448
|
const nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
|
|
452
449
|
return cellPosition !== nextPosition; // Removed it if next position is merged
|
|
453
450
|
});
|
|
454
|
-
|
|
455
451
|
const cells = cellPositions.map(pos => ({
|
|
456
452
|
pos: pos + table.start,
|
|
457
453
|
node: table.node.nodeAt(pos)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
2
|
-
import { calculateDefaultSnappings } from './snapping';
|
|
2
|
+
import { calculateDefaultSnappings, calculateDefaultTablePreserveSnappings } from './snapping';
|
|
3
3
|
|
|
4
4
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
5
5
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
6
|
-
export const defaultGuidelines = createFixedGuidelinesFromLengths([0, ...calculateDefaultSnappings(-1)]);
|
|
6
|
+
export const defaultGuidelines = createFixedGuidelinesFromLengths([0, ...calculateDefaultSnappings(-1)]);
|
|
7
|
+
export const defaultGuidelinesForPreserveTable = editorContainerWidth => createFixedGuidelinesFromLengths([0, ...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth)]);
|
|
@@ -100,7 +100,6 @@ export const hasMergedCellsInBetween = (indexes, type) => selection => {
|
|
|
100
100
|
return !cells.includes(nodePos) // cell exists in Rect but not show in the map.cellsInRect list => merged cell
|
|
101
101
|
? true : mergedCells.has(nodePos); // cell includes in mergedCells => merged cell
|
|
102
102
|
});
|
|
103
|
-
|
|
104
103
|
return [...new Set(mergedCell)];
|
|
105
104
|
};
|
|
106
105
|
const mergedCellsInRectArr = indexes.map(index => getMergedCellsInRect(index, type));
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { isVerticalPosition } from '@atlaskit/editor-common/guideline';
|
|
2
|
-
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
2
|
+
import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
const numberOfLanesInDefaultLayoutWidth = 12;
|
|
4
4
|
const calculateSubSnappingWidths = (totalLanes, totalWidth) => new Array(Math.round(totalLanes / 2) - 1).fill(totalWidth / totalLanes).map((v, i) => v * (i + 1) * 2);
|
|
5
5
|
export const calculateDefaultSnappings = (lengthOffset = 0) => [...calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset), akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, akEditorFullWidthLayoutWidth + lengthOffset];
|
|
6
|
+
|
|
7
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
8
|
+
export const calculateDefaultTablePreserveSnappings = (lengthOffset = 0, editorContainerWith = akEditorFullWidthLayoutWidth) => {
|
|
9
|
+
const dynamicFullWidthLine = editorContainerWith - akEditorGutterPadding * 2 >= akEditorFullWidthLayoutWidth ? akEditorFullWidthLayoutWidth : editorContainerWith - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
10
|
+
return [...calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset), akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset];
|
|
11
|
+
};
|
|
6
12
|
export const defaultSnappingWidths = calculateDefaultSnappings();
|
|
7
13
|
|
|
14
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
15
|
+
export const defaultTablePreserveSnappingWidths = editorContainerWidth => {
|
|
16
|
+
return editorContainerWidth - akEditorGutterPadding * 2 > akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
17
|
+
};
|
|
18
|
+
|
|
8
19
|
/**
|
|
9
20
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
10
21
|
*/
|
|
@@ -7,6 +7,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
7
7
|
import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { clearMultipleCells } from './commands/clear';
|
|
9
9
|
import { wrapTableInExpand } from './commands/collapse';
|
|
10
|
+
import { changeColumnWidthByStep } from './commands/column-resize';
|
|
10
11
|
import { deleteColumnsCommand } from './commands/delete';
|
|
11
12
|
import { insertColumn, insertRow } from './commands/insert';
|
|
12
13
|
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs } from './commands/misc';
|
|
@@ -182,13 +183,39 @@ export var insertRowWithAnalytics = function insertRowWithAnalytics(editorAnalyt
|
|
|
182
183
|
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
183
184
|
};
|
|
184
185
|
};
|
|
185
|
-
export var
|
|
186
|
-
|
|
187
|
-
return function (inputMethod, position) {
|
|
186
|
+
export var changeColumnWidthByStepWithAnalytics = function changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI) {
|
|
187
|
+
return function (stepSize, getEditorContainerWidth, tablePreserveWidth, inputMethod) {
|
|
188
188
|
return withEditorAnalyticsAPI(function (state) {
|
|
189
189
|
var _getSelectedTableInfo2 = getSelectedTableInfo(state.selection),
|
|
190
|
+
table = _getSelectedTableInfo2.table,
|
|
190
191
|
totalRowCount = _getSelectedTableInfo2.totalRowCount,
|
|
191
192
|
totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
|
|
193
|
+
var _getPluginState = getPluginState(state),
|
|
194
|
+
colIndex = _getPluginState.hoveredCell.colIndex;
|
|
195
|
+
return {
|
|
196
|
+
action: TABLE_ACTION.COLUMN_RESIZED,
|
|
197
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
198
|
+
eventType: EVENT_TYPE.TRACK,
|
|
199
|
+
attributes: {
|
|
200
|
+
colIndex: colIndex,
|
|
201
|
+
resizedDelta: stepSize,
|
|
202
|
+
isLastColumn: colIndex === totalColumnCount - 1,
|
|
203
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
204
|
+
inputMethod: inputMethod,
|
|
205
|
+
totalRowCount: totalRowCount,
|
|
206
|
+
totalColumnCount: totalColumnCount
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
})(editorAnalyticsAPI)(changeColumnWidthByStep(stepSize, getEditorContainerWidth, tablePreserveWidth));
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export var insertColumnWithAnalytics = function insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
213
|
+
var tablePreserveWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
214
|
+
return function (inputMethod, position) {
|
|
215
|
+
return withEditorAnalyticsAPI(function (state) {
|
|
216
|
+
var _getSelectedTableInfo3 = getSelectedTableInfo(state.selection),
|
|
217
|
+
totalRowCount = _getSelectedTableInfo3.totalRowCount,
|
|
218
|
+
totalColumnCount = _getSelectedTableInfo3.totalColumnCount;
|
|
192
219
|
return {
|
|
193
220
|
action: TABLE_ACTION.ADDED_COLUMN,
|
|
194
221
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -208,9 +235,9 @@ export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnal
|
|
|
208
235
|
return function (inputMethod, rect, isHeaderRowRequired) {
|
|
209
236
|
return withEditorAnalyticsAPI(function (_ref5) {
|
|
210
237
|
var selection = _ref5.selection;
|
|
211
|
-
var
|
|
212
|
-
totalRowCount =
|
|
213
|
-
totalColumnCount =
|
|
238
|
+
var _getSelectedTableInfo4 = getSelectedTableInfo(selection),
|
|
239
|
+
totalRowCount = _getSelectedTableInfo4.totalRowCount,
|
|
240
|
+
totalColumnCount = _getSelectedTableInfo4.totalColumnCount;
|
|
214
241
|
return {
|
|
215
242
|
action: TABLE_ACTION.DELETED_ROW,
|
|
216
243
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -237,9 +264,9 @@ export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(edit
|
|
|
237
264
|
return function (inputMethod, rect) {
|
|
238
265
|
return withEditorAnalyticsAPI(function (_ref6) {
|
|
239
266
|
var selection = _ref6.selection;
|
|
240
|
-
var
|
|
241
|
-
totalRowCount =
|
|
242
|
-
totalColumnCount =
|
|
267
|
+
var _getSelectedTableInfo5 = getSelectedTableInfo(selection),
|
|
268
|
+
totalRowCount = _getSelectedTableInfo5.totalRowCount,
|
|
269
|
+
totalColumnCount = _getSelectedTableInfo5.totalColumnCount;
|
|
243
270
|
return {
|
|
244
271
|
action: TABLE_ACTION.DELETED_COLUMN,
|
|
245
272
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -269,8 +296,8 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
|
|
|
269
296
|
}
|
|
270
297
|
var selectionType = getTableSelectionType(selection);
|
|
271
298
|
if (selectionType === 'row') {
|
|
272
|
-
var
|
|
273
|
-
pluginConfig =
|
|
299
|
+
var _getPluginState2 = getPluginState(state),
|
|
300
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
274
301
|
var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
|
|
275
302
|
return deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
|
|
276
303
|
} else if (selectionType === 'column') {
|
|
@@ -281,9 +308,9 @@ export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function delete
|
|
|
281
308
|
};
|
|
282
309
|
};
|
|
283
310
|
var getTableDeletedAnalytics = function getTableDeletedAnalytics(selection, inputMethod) {
|
|
284
|
-
var
|
|
285
|
-
totalRowCount =
|
|
286
|
-
totalColumnCount =
|
|
311
|
+
var _getSelectedTableInfo6 = getSelectedTableInfo(selection),
|
|
312
|
+
totalRowCount = _getSelectedTableInfo6.totalRowCount,
|
|
313
|
+
totalColumnCount = _getSelectedTableInfo6.totalColumnCount;
|
|
287
314
|
return {
|
|
288
315
|
action: TABLE_ACTION.DELETED,
|
|
289
316
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -311,11 +338,11 @@ export var deleteTableIfSelectedWithAnalytics = function deleteTableIfSelectedWi
|
|
|
311
338
|
};
|
|
312
339
|
export var toggleHeaderRowWithAnalytics = function toggleHeaderRowWithAnalytics(editorAnalyticsAPI) {
|
|
313
340
|
return withEditorAnalyticsAPI(function (state) {
|
|
314
|
-
var
|
|
315
|
-
totalRowCount =
|
|
316
|
-
totalColumnCount =
|
|
317
|
-
var
|
|
318
|
-
isHeaderRowEnabled =
|
|
341
|
+
var _getSelectedTableInfo7 = getSelectedTableInfo(state.selection),
|
|
342
|
+
totalRowCount = _getSelectedTableInfo7.totalRowCount,
|
|
343
|
+
totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
|
|
344
|
+
var _getPluginState3 = getPluginState(state),
|
|
345
|
+
isHeaderRowEnabled = _getPluginState3.isHeaderRowEnabled;
|
|
319
346
|
return {
|
|
320
347
|
action: TABLE_ACTION.TOGGLED_HEADER_ROW,
|
|
321
348
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -331,11 +358,11 @@ export var toggleHeaderRowWithAnalytics = function toggleHeaderRowWithAnalytics(
|
|
|
331
358
|
};
|
|
332
359
|
export var toggleHeaderColumnWithAnalytics = function toggleHeaderColumnWithAnalytics(editorAnalyticsAPI) {
|
|
333
360
|
return withEditorAnalyticsAPI(function (state) {
|
|
334
|
-
var
|
|
335
|
-
totalRowCount =
|
|
336
|
-
totalColumnCount =
|
|
337
|
-
var
|
|
338
|
-
isHeaderColumnEnabled =
|
|
361
|
+
var _getSelectedTableInfo8 = getSelectedTableInfo(state.selection),
|
|
362
|
+
totalRowCount = _getSelectedTableInfo8.totalRowCount,
|
|
363
|
+
totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
|
|
364
|
+
var _getPluginState4 = getPluginState(state),
|
|
365
|
+
isHeaderColumnEnabled = _getPluginState4.isHeaderColumnEnabled;
|
|
339
366
|
return {
|
|
340
367
|
action: TABLE_ACTION.TOGGLED_HEADER_COLUMN,
|
|
341
368
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -351,9 +378,9 @@ export var toggleHeaderColumnWithAnalytics = function toggleHeaderColumnWithAnal
|
|
|
351
378
|
};
|
|
352
379
|
export var toggleNumberColumnWithAnalytics = function toggleNumberColumnWithAnalytics(editorAnalyticsAPI) {
|
|
353
380
|
return withEditorAnalyticsAPI(function (state) {
|
|
354
|
-
var
|
|
355
|
-
totalRowCount =
|
|
356
|
-
totalColumnCount =
|
|
381
|
+
var _getSelectedTableInfo9 = getSelectedTableInfo(state.selection),
|
|
382
|
+
totalRowCount = _getSelectedTableInfo9.totalRowCount,
|
|
383
|
+
totalColumnCount = _getSelectedTableInfo9.totalColumnCount;
|
|
357
384
|
return {
|
|
358
385
|
action: TABLE_ACTION.TOGGLED_NUMBER_COLUMN,
|
|
359
386
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -369,10 +396,10 @@ export var toggleNumberColumnWithAnalytics = function toggleNumberColumnWithAnal
|
|
|
369
396
|
};
|
|
370
397
|
export var toggleTableLayoutWithAnalytics = function toggleTableLayoutWithAnalytics(editorAnalyticsAPI) {
|
|
371
398
|
return withEditorAnalyticsAPI(function (state) {
|
|
372
|
-
var
|
|
373
|
-
table =
|
|
374
|
-
totalRowCount =
|
|
375
|
-
totalColumnCount =
|
|
399
|
+
var _getSelectedTableInfo10 = getSelectedTableInfo(state.selection),
|
|
400
|
+
table = _getSelectedTableInfo10.table,
|
|
401
|
+
totalRowCount = _getSelectedTableInfo10.totalRowCount,
|
|
402
|
+
totalColumnCount = _getSelectedTableInfo10.totalColumnCount;
|
|
376
403
|
if (table) {
|
|
377
404
|
var _ref9 = table.node.attrs,
|
|
378
405
|
layout = _ref9.layout;
|
|
@@ -395,9 +422,9 @@ export var toggleTableLayoutWithAnalytics = function toggleTableLayoutWithAnalyt
|
|
|
395
422
|
export var sortColumnWithAnalytics = function sortColumnWithAnalytics(editorAnalyticsAPI) {
|
|
396
423
|
return function (inputMethod, columnIndex, sortOrder) {
|
|
397
424
|
return withEditorAnalyticsAPI(function (state) {
|
|
398
|
-
var
|
|
399
|
-
totalRowCount =
|
|
400
|
-
totalColumnCount =
|
|
425
|
+
var _getSelectedTableInfo11 = getSelectedTableInfo(state.selection),
|
|
426
|
+
totalRowCount = _getSelectedTableInfo11.totalRowCount,
|
|
427
|
+
totalColumnCount = _getSelectedTableInfo11.totalColumnCount;
|
|
401
428
|
return {
|
|
402
429
|
action: TABLE_ACTION.SORTED_COLUMN,
|
|
403
430
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -439,9 +466,9 @@ export var distributeColumnsWidthsWithAnalytics = function distributeColumnsWidt
|
|
|
439
466
|
};
|
|
440
467
|
export var wrapTableInExpandWithAnalytics = function wrapTableInExpandWithAnalytics(editorAnalyticsAPI) {
|
|
441
468
|
return withEditorAnalyticsAPI(function (state) {
|
|
442
|
-
var
|
|
443
|
-
totalRowCount =
|
|
444
|
-
totalColumnCount =
|
|
469
|
+
var _getSelectedTableInfo12 = getSelectedTableInfo(state.selection),
|
|
470
|
+
totalRowCount = _getSelectedTableInfo12.totalRowCount,
|
|
471
|
+
totalColumnCount = _getSelectedTableInfo12.totalColumnCount;
|
|
445
472
|
return {
|
|
446
473
|
action: TABLE_ACTION.COLLAPSED,
|
|
447
474
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
function _isNativeReflectConstruct() {
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
import uuid from 'uuid';
|
|
10
10
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
11
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
function _isNativeReflectConstruct() {
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import classnames from 'classnames';
|
|
15
15
|
import memoizeOne from 'memoize-one';
|
|
@@ -5,7 +5,7 @@ import React, { forwardRef, useCallback, useRef } from 'react';
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
7
7
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
8
|
-
import { akEditorDefaultLayoutWidth, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
11
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -108,7 +108,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
108
108
|
}, [pluginInjectionApi]);
|
|
109
109
|
var tableWidth = getTableContainerWidth(node);
|
|
110
110
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
111
|
-
var responsiveContainerWidth = containerWidth -
|
|
111
|
+
var responsiveContainerWidth = tablePreserveWidth ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
|
|
112
112
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
113
113
|
if (!isResizing) {
|
|
114
114
|
tableWidthRef.current = width;
|
|
@@ -20,8 +20,8 @@ import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTa
|
|
|
20
20
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
21
21
|
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
22
22
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
23
|
-
import { defaultGuidelines } from '../utils/guidelines';
|
|
24
|
-
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
23
|
+
import { defaultGuidelines, defaultGuidelinesForPreserveTable } from '../utils/guidelines';
|
|
24
|
+
import { defaultSnappingWidths, defaultTablePreserveSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
25
25
|
var DEBOUNCE_TIME_FOR_SCREEN_READER_ANNOUNCER = 1000;
|
|
26
26
|
var RESIZE_STEP_VALUE = 10;
|
|
27
27
|
var handles = {
|
|
@@ -135,15 +135,15 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
135
135
|
keys = _ref2.keys;
|
|
136
136
|
if (gap !== currentGap.current) {
|
|
137
137
|
currentGap.current = gap;
|
|
138
|
-
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
138
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
139
139
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
140
140
|
}
|
|
141
|
-
}, [
|
|
141
|
+
}, [tablePreserveWidth, containerWidth, displayGuideline]);
|
|
142
142
|
var guidelineSnaps = useMemo(function () {
|
|
143
143
|
return snappingEnabled ? {
|
|
144
|
-
x: defaultSnappingWidths
|
|
144
|
+
x: tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
|
|
145
145
|
} : undefined;
|
|
146
|
-
}, [snappingEnabled]);
|
|
146
|
+
}, [snappingEnabled, tablePreserveWidth, containerWidth]);
|
|
147
147
|
useEffect(function () {
|
|
148
148
|
return function () {
|
|
149
149
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -173,12 +173,12 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
173
173
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
174
174
|
});
|
|
175
175
|
dispatch(tr);
|
|
176
|
-
var visibleGuidelines = getVisibleGuidelines(defaultGuidelines, containerWidth);
|
|
176
|
+
var visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
|
|
177
177
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
178
178
|
if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
|
|
179
179
|
onResizeStart();
|
|
180
180
|
}
|
|
181
|
-
}, [displayGapCursor,
|
|
181
|
+
}, [startMeasure, editorView, displayGapCursor, tablePreserveWidth, containerWidth, displayGuideline, onResizeStart]);
|
|
182
182
|
var handleResize = useCallback(function (originalState, delta) {
|
|
183
183
|
countFrames();
|
|
184
184
|
var newWidth = originalState.width + delta.width;
|
|
@@ -197,10 +197,10 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
197
197
|
start: pos + 1,
|
|
198
198
|
parentWidth: newWidth
|
|
199
199
|
}, editorView.domAtPos.bind(editorView), tablePreserveWidth);
|
|
200
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
200
|
+
updateActiveGuidelines(findClosestSnap(newWidth, tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
|
|
201
201
|
updateWidth(newWidth);
|
|
202
202
|
return newWidth;
|
|
203
|
-
}, [
|
|
203
|
+
}, [countFrames, tablePreserveWidth, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
|
|
204
204
|
var scheduleResize = useMemo(function () {
|
|
205
205
|
return rafSchd(handleResize);
|
|
206
206
|
}, [handleResize]);
|
|
@@ -6,7 +6,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _isNativeReflectConstruct() {
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
10
|
import debounce from 'lodash/debounce';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
12
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
@@ -9,7 +9,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
10
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
function _isNativeReflectConstruct() {
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
15
15
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -4,8 +4,8 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { createTable, goToNextCell, moveCursorBackward } from '../commands';
|
|
7
|
-
import { addRowAroundSelection, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
|
-
import { activateNextResizeArea,
|
|
7
|
+
import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
|
|
8
|
+
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
|
|
10
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
11
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
@@ -58,8 +58,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
|
|
|
58
58
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
|
|
59
59
|
bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
|
|
60
60
|
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
|
|
61
|
-
bindKeymapWithCommand(decreaseMediaSize.common,
|
|
62
|
-
bindKeymapWithCommand(increaseMediaSize.common,
|
|
61
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
|
|
62
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
|
|
63
63
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
|
|
64
64
|
}
|
|
65
65
|
return keymap(list);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -141,6 +141,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
141
141
|
// only selected (or selected - 1) columns should be distributed
|
|
142
142
|
var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
|
|
143
143
|
var newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
|
|
144
|
+
var resizedDelta = clientX - startX;
|
|
144
145
|
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
145
146
|
if (colIndex === map.width - 1) {
|
|
146
147
|
var mouseUpTime = event.timeStamp;
|
|
@@ -152,11 +153,25 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
152
153
|
type: 'table-border',
|
|
153
154
|
position: 'right',
|
|
154
155
|
duration: mouseUpTime - mouseDownTime,
|
|
155
|
-
delta: Math.abs(
|
|
156
|
+
delta: Math.abs(resizedDelta)
|
|
156
157
|
},
|
|
157
158
|
eventType: EVENT_TYPE.UI
|
|
158
159
|
})(tr);
|
|
159
160
|
}
|
|
161
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
162
|
+
action: TABLE_ACTION.COLUMN_RESIZED,
|
|
163
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
164
|
+
eventType: EVENT_TYPE.TRACK,
|
|
165
|
+
attributes: {
|
|
166
|
+
colIndex: colIndex,
|
|
167
|
+
resizedDelta: resizedDelta,
|
|
168
|
+
isLastColumn: colIndex === map.width - 1,
|
|
169
|
+
tableWidth: table.attrs.width,
|
|
170
|
+
inputMethod: INPUT_METHOD.MOUSE,
|
|
171
|
+
totalRowCount: map.height,
|
|
172
|
+
totalColumnCount: map.width
|
|
173
|
+
}
|
|
174
|
+
})(tr);
|
|
160
175
|
}
|
|
161
176
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
162
177
|
if (isKeyboardResize || !isTableHovered) {
|
|
@@ -48,7 +48,6 @@ export var getResizeState = function getResizeState(_ref) {
|
|
|
48
48
|
// Getting the resize state from DOM
|
|
49
49
|
var colgroupChildren = insertColgroupFromNode(tableRef, table, tablePreserveWidth, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
|
|
50
50
|
);
|
|
51
|
-
|
|
52
51
|
var cols = Array.from(colgroupChildren).map(function (_, index) {
|
|
53
52
|
// If the table hasn't been resized and we have a table width attribute, we can use it
|
|
54
53
|
// to calculate the widths of the columns
|
package/dist/esm/reducer.js
CHANGED
|
@@ -35,7 +35,6 @@ export default (function (pluginState, action) {
|
|
|
35
35
|
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
36
36
|
insertColumnButtonIndex: undefined // We need to assure that column is not shown
|
|
37
37
|
});
|
|
38
|
-
|
|
39
38
|
case 'SHOW_INSERT_COLUMN_BUTTON':
|
|
40
39
|
if (action.data.insertColumnButtonIndex === pluginState.insertColumnButtonIndex) {
|
|
41
40
|
return pluginState;
|
|
@@ -43,7 +42,6 @@ export default (function (pluginState, action) {
|
|
|
43
42
|
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
44
43
|
insertRowButtonIndex: undefined // We need to assure that row is not shown
|
|
45
44
|
});
|
|
46
|
-
|
|
47
45
|
case 'HIDE_INSERT_COLUMN_OR_ROW_BUTTON':
|
|
48
46
|
if (pluginState.insertRowButtonIndex !== undefined || pluginState.insertColumnButtonIndex !== undefined) {
|
|
49
47
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
function _isNativeReflectConstruct() {
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
14
14
|
/** @jsx jsx */
|
|
15
15
|
import { Component } from 'react';
|
|
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
function _isNativeReflectConstruct() {
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import React, { Component } from 'react';
|
|
14
14
|
import { createPortal } from 'react-dom';
|
|
15
15
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -7,7 +7,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
function _isNativeReflectConstruct() {
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import { injectIntl } from 'react-intl-next';
|
|
13
13
|
import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|