@atlaskit/editor-plugin-table 4.1.1 → 4.2.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 +6 -0
- package/dist/cjs/plugins/table/commands/delete.js +18 -0
- package/dist/cjs/plugins/table/commands-with-analytics.js +2 -7
- package/dist/cjs/plugins/table/event-handlers.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/table/transforms/column-width.js +110 -5
- package/dist/cjs/plugins/table/transforms/delete-columns.js +16 -6
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/es2019/plugins/table/commands/delete.js +10 -0
- package/dist/es2019/plugins/table/commands-with-analytics.js +3 -8
- package/dist/es2019/plugins/table/event-handlers.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/table/transforms/column-width.js +105 -5
- package/dist/es2019/plugins/table/transforms/delete-columns.js +16 -5
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +0 -1
- package/dist/esm/plugins/table/commands/delete.js +12 -0
- package/dist/esm/plugins/table/commands-with-analytics.js +3 -8
- package/dist/esm/plugins/table/event-handlers.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/table/transforms/column-width.js +111 -5
- package/dist/esm/plugins/table/transforms/delete-columns.js +16 -6
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/types/plugins/table/commands/delete.d.ts +3 -0
- package/dist/types/plugins/table/event-handlers.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/plugins/table/transforms/column-width.d.ts +25 -6
- package/dist/types/plugins/table/transforms/delete-columns.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
- package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +25 -6
- package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +4 -4
- package/package.json +4 -1
- package/src/__tests__/unit/commands.ts +1 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +406 -105
- package/src/__tests__/unit/undo-redo.ts +1 -1
- package/src/plugins/table/commands/delete.ts +20 -0
- package/src/plugins/table/commands-with-analytics.ts +3 -10
- package/src/plugins/table/event-handlers.ts +6 -1
- package/src/plugins/table/pm-plugins/main.ts +7 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -1
- package/src/plugins/table/transforms/column-width.ts +155 -15
- package/src/plugins/table/transforms/delete-columns.ts +23 -6
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +7 -6
- package/src/plugins/table/ui/common-styles.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#40780](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40780) [`981ad6038e9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/981ad6038e9) - Fixes a bug when deleting a table column will cause column resizing to become unresponsive and lag. Delete columns operation will now update the table column widths to avoid this, under a new feature flag.
|
|
8
|
+
|
|
3
9
|
## 4.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deleteColumnsCommand = void 0;
|
|
7
|
+
var _deleteColumns = require("../transforms/delete-columns");
|
|
8
|
+
var _getAllowAddColumnCustomStep = require("../utils/get-allow-add-column-custom-step");
|
|
9
|
+
var deleteColumnsCommand = exports.deleteColumnsCommand = function deleteColumnsCommand(rect) {
|
|
10
|
+
return function (state, dispatch, view) {
|
|
11
|
+
var tr = (0, _deleteColumns.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(state), view)(state.tr);
|
|
12
|
+
if (dispatch) {
|
|
13
|
+
dispatch(tr);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -12,6 +12,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
12
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
13
|
var _clear = require("./commands/clear");
|
|
14
14
|
var _collapse = require("./commands/collapse");
|
|
15
|
+
var _delete = require("./commands/delete");
|
|
15
16
|
var _insert = require("./commands/insert");
|
|
16
17
|
var _misc = require("./commands/misc");
|
|
17
18
|
var _sort = require("./commands/sort");
|
|
@@ -22,7 +23,6 @@ var _commands = require("./pm-plugins/table-resizing/commands");
|
|
|
22
23
|
var _transforms = require("./transforms");
|
|
23
24
|
var _utils2 = require("./utils");
|
|
24
25
|
var _analytics2 = require("./utils/analytics");
|
|
25
|
-
var _getAllowAddColumnCustomStep = require("./utils/get-allow-add-column-custom-step");
|
|
26
26
|
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; }
|
|
27
27
|
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) { (0, _defineProperty2.default)(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; }
|
|
28
28
|
var TABLE_BREAKOUT_NAME_MAPPING = {
|
|
@@ -258,12 +258,7 @@ var deleteColumnsWithAnalytics = exports.deleteColumnsWithAnalytics = function d
|
|
|
258
258
|
},
|
|
259
259
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
260
260
|
};
|
|
261
|
-
})(editorAnalyticsAPI)(
|
|
262
|
-
if (dispatch) {
|
|
263
|
-
dispatch((0, _transforms.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(state))(state.tr));
|
|
264
|
-
}
|
|
265
|
-
return true;
|
|
266
|
-
});
|
|
261
|
+
})(editorAnalyticsAPI)((0, _delete.deleteColumnsCommand)(rect));
|
|
267
262
|
};
|
|
268
263
|
};
|
|
269
264
|
var getTableDeletedAnalytics = function getTableDeletedAnalytics(selection, inputMethod) {
|
|
@@ -259,7 +259,7 @@ function handleTripleClick(view, pos) {
|
|
|
259
259
|
}
|
|
260
260
|
return false;
|
|
261
261
|
}
|
|
262
|
-
var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI) {
|
|
262
|
+
var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
|
|
263
263
|
var oldSelection = oldState.tr.selection;
|
|
264
264
|
var tr = newState.tr;
|
|
265
265
|
if (oldSelection instanceof _cellSelection.CellSelection) {
|
|
@@ -302,7 +302,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
|
|
|
302
302
|
isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
|
|
303
303
|
tr = (0, _transforms.deleteRows)(rect, isHeaderRowRequired)(tr);
|
|
304
304
|
} else if (tr.selection.isColSelection()) {
|
|
305
|
-
tr = (0, _transforms.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(oldState))(tr);
|
|
305
|
+
tr = (0, _transforms.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(oldState), editorView)(tr);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
}
|
|
@@ -100,7 +100,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
100
100
|
}
|
|
101
101
|
if (tr) {
|
|
102
102
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
103
|
-
var updatedTr = (0, _eventHandlers.handleCut)(tr, oldState, newState, editorAnalyticsAPI);
|
|
103
|
+
var updatedTr = (0, _eventHandlers.handleCut)(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined);
|
|
104
104
|
return (0, _transforms2.fixTables)(updatedTr) || updatedTr;
|
|
105
105
|
}
|
|
106
106
|
if (transactions.find(function (tr) {
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateColumnWidths = exports.rescaleColumns = void 0;
|
|
7
|
+
exports.updateColumnWidths = exports.rescaleColumnsOld = exports.rescaleColumnsNew = exports.rescaleColumns = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -19,6 +19,13 @@ var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
|
|
|
19
19
|
var _commonStyles = require("../ui/common-styles");
|
|
20
20
|
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; }
|
|
21
21
|
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) { (0, _defineProperty2.default)(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; }
|
|
22
|
+
/**
|
|
23
|
+
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
24
|
+
* @param resizeState
|
|
25
|
+
* @param table
|
|
26
|
+
* @param start
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
22
29
|
var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidths(resizeState, table, start) {
|
|
23
30
|
return function (tr) {
|
|
24
31
|
var map = _tableMap.TableMap.get(table);
|
|
@@ -121,10 +128,102 @@ var updateColumnWidths = exports.updateColumnWidths = function updateColumnWidth
|
|
|
121
128
|
* @param view
|
|
122
129
|
* @returns Updated transaction with rescaled columns for a given table
|
|
123
130
|
*/
|
|
124
|
-
var
|
|
131
|
+
var rescaleColumnsNew = exports.rescaleColumnsNew = function rescaleColumnsNew() {
|
|
132
|
+
return function (table, view) {
|
|
133
|
+
return function (tr) {
|
|
134
|
+
var _tableRef$parentEleme, _tableRef$parentEleme2;
|
|
135
|
+
if (!view) {
|
|
136
|
+
return tr;
|
|
137
|
+
}
|
|
138
|
+
var newTable = tr.doc.nodeAt(table.pos);
|
|
139
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
140
|
+
var maybeTable = domAtPos(table.start).node;
|
|
141
|
+
var tableRef = maybeTable.closest('table');
|
|
142
|
+
if (!tableRef || !newTable) {
|
|
143
|
+
return tr;
|
|
144
|
+
}
|
|
145
|
+
var isResized = (0, _utils.hasTableBeenResized)(table.node);
|
|
146
|
+
// get current table info
|
|
147
|
+
var previousTableInfo = {
|
|
148
|
+
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
149
|
+
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
150
|
+
/** the is the width the table can reach before overflowing */
|
|
151
|
+
possibleMaxWidth: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0 : ((tableRef === null || tableRef === void 0 || (_tableRef$parentEleme2 = tableRef.parentElement) === null || _tableRef$parentEleme2 === void 0 ? void 0 : _tableRef$parentEleme2.clientWidth) || 0) - _commonStyles.insertColumnButtonOffset - 1,
|
|
152
|
+
isResized: isResized
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// determine the new table, based on new width
|
|
156
|
+
var newTableInfo = {
|
|
157
|
+
noOfColumns: _tableMap.TableMap.get(newTable).width
|
|
158
|
+
};
|
|
159
|
+
if (!newTableInfo.noOfColumns || newTableInfo.noOfColumns <= 0) {
|
|
160
|
+
return tr;
|
|
161
|
+
}
|
|
162
|
+
var averageColumnWidth = previousTableInfo.width / newTableInfo.noOfColumns;
|
|
163
|
+
|
|
164
|
+
// If the table has not been resized (i.e. all columns will have the same width) and every column width is bigger than the minimum column width
|
|
165
|
+
// we skip updating the size of columns here.
|
|
166
|
+
if (!previousTableInfo.isResized && averageColumnWidth > _styles.tableCellMinWidth) {
|
|
167
|
+
return tr;
|
|
168
|
+
}
|
|
169
|
+
var wasTableInOverflow = previousTableInfo.width > previousTableInfo.possibleMaxWidth;
|
|
170
|
+
|
|
171
|
+
// If the table has not been resized, and each column width is smaller than the minimum column width
|
|
172
|
+
// Or if the table has been resized, but each column width is either 48px or null
|
|
173
|
+
// we update the table to have 48px for each column
|
|
174
|
+
if (!previousTableInfo.isResized && averageColumnWidth <= _styles.tableCellMinWidth || previousTableInfo.isResized && (0, _colgroup.isMinCellWidthTable)(table.node)) {
|
|
175
|
+
var widths = new Array(newTableInfo.noOfColumns).fill(_styles.tableCellMinWidth);
|
|
176
|
+
var cols = widths.map(function (_, index) {
|
|
177
|
+
return {
|
|
178
|
+
width: _styles.tableCellMinWidth,
|
|
179
|
+
minWidth: _styles.tableCellMinWidth,
|
|
180
|
+
index: index
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
var minWidthResizeState = {
|
|
184
|
+
cols: cols,
|
|
185
|
+
widths: widths,
|
|
186
|
+
maxSize: previousTableInfo.possibleMaxWidth,
|
|
187
|
+
tableWidth: previousTableInfo.width,
|
|
188
|
+
overflow: wasTableInOverflow
|
|
189
|
+
};
|
|
190
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
191
|
+
}
|
|
192
|
+
var resizeState = (0, _resizeState.getResizeState)({
|
|
193
|
+
minWidth: _styles.tableCellMinWidth,
|
|
194
|
+
table: table.node,
|
|
195
|
+
start: table.start,
|
|
196
|
+
tableRef: tableRef,
|
|
197
|
+
domAtPos: domAtPos,
|
|
198
|
+
maxSize: previousTableInfo.possibleMaxWidth
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Two scenarios that require scaling:
|
|
202
|
+
// 1. If the new table width will result in the table going into overflow
|
|
203
|
+
// we resize the cells to avoid it (e.g. adding a column)
|
|
204
|
+
// 2. If the new table width will be shorter than the parent width, scale columns to fit parent
|
|
205
|
+
if (!wasTableInOverflow && resizeState.overflow || resizeState.tableWidth < resizeState.maxSize) {
|
|
206
|
+
resizeState = (0, _scaleTable.scaleTableTo)(resizeState, previousTableInfo.possibleMaxWidth);
|
|
207
|
+
}
|
|
208
|
+
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* This function is called when user inserts/deletes a column in a table to;
|
|
215
|
+
* - rescale all columns (if the table did not overflow before the insertion)
|
|
216
|
+
* - and update column widths.
|
|
217
|
+
*
|
|
218
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
219
|
+
* @param table
|
|
220
|
+
* @param view
|
|
221
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
222
|
+
*/
|
|
223
|
+
var rescaleColumnsOld = exports.rescaleColumnsOld = function rescaleColumnsOld(getEditorContainerWidth) {
|
|
125
224
|
return function (table, view) {
|
|
126
225
|
return function (tr) {
|
|
127
|
-
var _tableRef$
|
|
226
|
+
var _tableRef$parentEleme3;
|
|
128
227
|
if (!view) {
|
|
129
228
|
return tr;
|
|
130
229
|
}
|
|
@@ -147,7 +246,7 @@ var rescaleColumns = exports.rescaleColumns = function rescaleColumns(getEditorC
|
|
|
147
246
|
getEditorContainerWidth: getEditorContainerWidth
|
|
148
247
|
});
|
|
149
248
|
var tableWidth = tableRef.clientWidth || _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
150
|
-
var tableMaxWidth = (tableRef === null || tableRef === void 0 || (_tableRef$
|
|
249
|
+
var tableMaxWidth = (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme3 = tableRef.parentElement) === null || _tableRef$parentEleme3 === void 0 ? void 0 : _tableRef$parentEleme3.clientWidth) || 0;
|
|
151
250
|
tableMaxWidth -= _commonStyles.insertColumnButtonOffset;
|
|
152
251
|
var newTableMap = _tableMap.TableMap.get(newTable);
|
|
153
252
|
var noOfColumns = newTableMap.width;
|
|
@@ -192,7 +291,7 @@ var rescaleColumns = exports.rescaleColumns = function rescaleColumns(getEditorC
|
|
|
192
291
|
domAtPos: domAtPos,
|
|
193
292
|
maxSize: maxSize
|
|
194
293
|
});
|
|
195
|
-
var previousTableWidth = resizeState.tableWidth -
|
|
294
|
+
var previousTableWidth = resizeState.tableWidth - _tableMap.tableNewColumnMinWidth;
|
|
196
295
|
var tableDidntPreviouslyOverflow = previousTableWidth <= Math.max(maxSize, tableMaxWidth);
|
|
197
296
|
|
|
198
297
|
// If the new table width will result in the table going into an overflow state
|
|
@@ -203,4 +302,10 @@ var rescaleColumns = exports.rescaleColumns = function rescaleColumns(getEditorC
|
|
|
203
302
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
204
303
|
};
|
|
205
304
|
};
|
|
305
|
+
};
|
|
306
|
+
var rescaleColumns = exports.rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
307
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
308
|
+
return rescaleColumnsNew();
|
|
309
|
+
}
|
|
310
|
+
return rescaleColumnsOld(getEditorContainerWidth);
|
|
206
311
|
};
|
|
@@ -12,7 +12,9 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
14
14
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
17
|
+
var _columnWidth = require("./column-width");
|
|
16
18
|
var _split = require("./split");
|
|
17
19
|
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; }
|
|
18
20
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -210,15 +212,23 @@ function fixRowSpans(table) {
|
|
|
210
212
|
}
|
|
211
213
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
212
214
|
}
|
|
213
|
-
var deleteColumns = exports.deleteColumns = function deleteColumns(rect) {
|
|
214
|
-
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
215
|
+
var deleteColumns = exports.deleteColumns = function deleteColumns(rect, allowCustomStep, view) {
|
|
215
216
|
return function (tr) {
|
|
216
|
-
tr
|
|
217
|
+
var updatedTr = tr;
|
|
218
|
+
updatedTr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
217
219
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
218
220
|
});
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
+
if (allowCustomStep) {
|
|
222
|
+
updatedTr = deleteColumnsCustomStep(rect)(updatedTr);
|
|
223
|
+
} else {
|
|
224
|
+
updatedTr = deleteColumnsLegacy(rect)(updatedTr);
|
|
225
|
+
}
|
|
226
|
+
var table = (0, _utils.findTable)(updatedTr.selection);
|
|
227
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
228
|
+
if (table) {
|
|
229
|
+
updatedTr = (0, _columnWidth.rescaleColumns)()(table, view)(updatedTr);
|
|
230
|
+
}
|
|
221
231
|
}
|
|
222
|
-
return
|
|
232
|
+
return updatedTr;
|
|
223
233
|
};
|
|
224
234
|
};
|
|
@@ -304,7 +304,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
304
304
|
_this.toggleOpen();
|
|
305
305
|
break;
|
|
306
306
|
case 'delete_column':
|
|
307
|
-
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch);
|
|
307
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
308
308
|
_this.toggleOpen();
|
|
309
309
|
break;
|
|
310
310
|
case 'delete_row':
|
|
@@ -125,7 +125,7 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
125
125
|
switch (_this.state.selectionType) {
|
|
126
126
|
case 'column':
|
|
127
127
|
{
|
|
128
|
-
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, rect)(state, dispatch);
|
|
128
|
+
(0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, rect)(state, dispatch, _this.props.editorView);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
case 'row':
|
|
@@ -56,7 +56,7 @@ var tableStickyHeaderColumnControlsDecorationsStyle = function tableStickyHeader
|
|
|
56
56
|
};
|
|
57
57
|
var tableWrapperStyles = function tableWrapperStyles() {
|
|
58
58
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width')) {
|
|
59
|
-
return (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n padding-bottom: 0px;\n /* fixes gap cursor height */\n overflow: auto;\n overflow-y: hidden;\n position: relative;\n\n > table[data-number-column='true'] {\n
|
|
59
|
+
return (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n padding-bottom: 0px;\n /* fixes gap cursor height */\n overflow: auto;\n overflow-y: hidden;\n position: relative;\n\n > table[data-number-column='true'] {\n width: calc(100% - 1px);\n }\n }\n "])), _types.TableCssClassName.TABLE_NODE_WRAPPER);
|
|
60
60
|
} else {
|
|
61
61
|
return (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n padding-right: ", "px;\n margin-right: -", "px;\n padding-bottom: 0px;\n /* fixes gap cursor height */\n overflow: auto;\n overflow-y: hidden;\n position: relative;\n }\n "])), _types.TableCssClassName.TABLE_NODE_WRAPPER, insertColumnButtonOffset, insertColumnButtonOffset);
|
|
62
62
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { deleteColumns } from '../transforms/delete-columns';
|
|
2
|
+
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
|
+
export const deleteColumnsCommand = rect => (state, dispatch, view) => {
|
|
4
|
+
const tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
5
|
+
if (dispatch) {
|
|
6
|
+
dispatch(tr);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
@@ -4,6 +4,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
4
4
|
import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { clearMultipleCells } from './commands/clear';
|
|
6
6
|
import { wrapTableInExpand } from './commands/collapse';
|
|
7
|
+
import { deleteColumnsCommand } from './commands/delete';
|
|
7
8
|
import { insertColumn, insertRow } from './commands/insert';
|
|
8
9
|
import { deleteTable, deleteTableIfSelected, setMultipleCellAttrs } from './commands/misc';
|
|
9
10
|
import { sortByColumn } from './commands/sort';
|
|
@@ -11,10 +12,9 @@ import { splitCell } from './commands/split-cell';
|
|
|
11
12
|
import { getNextLayout, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './commands/toggle';
|
|
12
13
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
13
14
|
import { distributeColumnsWidths } from './pm-plugins/table-resizing/commands';
|
|
14
|
-
import {
|
|
15
|
+
import { deleteRows, mergeCells } from './transforms';
|
|
15
16
|
import { checkIfNumberColumnEnabled, getSelectedCellInfo, getSelectedTableInfo } from './utils';
|
|
16
17
|
import { withEditorAnalyticsAPI } from './utils/analytics';
|
|
17
|
-
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
18
18
|
const TABLE_BREAKOUT_NAME_MAPPING = {
|
|
19
19
|
default: TABLE_BREAKOUT.NORMAL,
|
|
20
20
|
wide: TABLE_BREAKOUT.WIDE,
|
|
@@ -231,12 +231,7 @@ export const deleteColumnsWithAnalytics = editorAnalyticsAPI => (inputMethod, re
|
|
|
231
231
|
},
|
|
232
232
|
eventType: EVENT_TYPE.TRACK
|
|
233
233
|
};
|
|
234
|
-
})(editorAnalyticsAPI)((
|
|
235
|
-
if (dispatch) {
|
|
236
|
-
dispatch(deleteColumns(rect, getAllowAddColumnCustomStep(state))(state.tr));
|
|
237
|
-
}
|
|
238
|
-
return true;
|
|
239
|
-
});
|
|
234
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect));
|
|
240
235
|
const getTableDeletedAnalytics = (selection, inputMethod) => {
|
|
241
236
|
const {
|
|
242
237
|
totalRowCount,
|
|
@@ -263,7 +263,7 @@ export function handleTripleClick(view, pos) {
|
|
|
263
263
|
}
|
|
264
264
|
return false;
|
|
265
265
|
}
|
|
266
|
-
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
266
|
+
export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorView) => {
|
|
267
267
|
const oldSelection = oldState.tr.selection;
|
|
268
268
|
let {
|
|
269
269
|
tr
|
|
@@ -312,7 +312,7 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
312
312
|
} = getPluginState(newState);
|
|
313
313
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
314
314
|
} else if (tr.selection.isColSelection()) {
|
|
315
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState))(tr);
|
|
315
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
}
|
|
@@ -82,7 +82,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
82
82
|
}
|
|
83
83
|
if (tr) {
|
|
84
84
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
85
|
-
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI);
|
|
85
|
+
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined);
|
|
86
86
|
return fixTables(updatedTr) || updatedTr;
|
|
87
87
|
}
|
|
88
88
|
if (transactions.find(tr => tr.docChanged)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
|
-
import { tableCellMinWidth
|
|
2
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
|
+
import { TableMap, tableNewColumnMinWidth } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
7
7
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
@@ -9,6 +9,14 @@ import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
|
|
|
9
9
|
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
10
10
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
11
11
|
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
15
|
+
* @param resizeState
|
|
16
|
+
* @param table
|
|
17
|
+
* @param start
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
12
20
|
export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
13
21
|
const map = TableMap.get(table);
|
|
14
22
|
const updatedCellsAttrs = {};
|
|
@@ -112,8 +120,94 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
112
120
|
* @param view
|
|
113
121
|
* @returns Updated transaction with rescaled columns for a given table
|
|
114
122
|
*/
|
|
115
|
-
export const
|
|
116
|
-
var _tableRef$parentEleme;
|
|
123
|
+
export const rescaleColumnsNew = () => (table, view) => tr => {
|
|
124
|
+
var _tableRef$parentEleme, _tableRef$parentEleme2;
|
|
125
|
+
if (!view) {
|
|
126
|
+
return tr;
|
|
127
|
+
}
|
|
128
|
+
const newTable = tr.doc.nodeAt(table.pos);
|
|
129
|
+
const domAtPos = view.domAtPos.bind(view);
|
|
130
|
+
const maybeTable = domAtPos(table.start).node;
|
|
131
|
+
const tableRef = maybeTable.closest('table');
|
|
132
|
+
if (!tableRef || !newTable) {
|
|
133
|
+
return tr;
|
|
134
|
+
}
|
|
135
|
+
const isResized = hasTableBeenResized(table.node);
|
|
136
|
+
// get current table info
|
|
137
|
+
const previousTableInfo = {
|
|
138
|
+
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
139
|
+
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
140
|
+
/** the is the width the table can reach before overflowing */
|
|
141
|
+
possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0 : ((tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme2 = tableRef.parentElement) === null || _tableRef$parentEleme2 === void 0 ? void 0 : _tableRef$parentEleme2.clientWidth) || 0) - insertColumnButtonOffset - 1,
|
|
142
|
+
isResized
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// determine the new table, based on new width
|
|
146
|
+
const newTableInfo = {
|
|
147
|
+
noOfColumns: TableMap.get(newTable).width
|
|
148
|
+
};
|
|
149
|
+
if (!newTableInfo.noOfColumns || newTableInfo.noOfColumns <= 0) {
|
|
150
|
+
return tr;
|
|
151
|
+
}
|
|
152
|
+
const averageColumnWidth = previousTableInfo.width / newTableInfo.noOfColumns;
|
|
153
|
+
|
|
154
|
+
// If the table has not been resized (i.e. all columns will have the same width) and every column width is bigger than the minimum column width
|
|
155
|
+
// we skip updating the size of columns here.
|
|
156
|
+
if (!previousTableInfo.isResized && averageColumnWidth > tableCellMinWidth) {
|
|
157
|
+
return tr;
|
|
158
|
+
}
|
|
159
|
+
const wasTableInOverflow = previousTableInfo.width > previousTableInfo.possibleMaxWidth;
|
|
160
|
+
|
|
161
|
+
// If the table has not been resized, and each column width is smaller than the minimum column width
|
|
162
|
+
// Or if the table has been resized, but each column width is either 48px or null
|
|
163
|
+
// we update the table to have 48px for each column
|
|
164
|
+
if (!previousTableInfo.isResized && averageColumnWidth <= tableCellMinWidth || previousTableInfo.isResized && isMinCellWidthTable(table.node)) {
|
|
165
|
+
const widths = new Array(newTableInfo.noOfColumns).fill(tableCellMinWidth);
|
|
166
|
+
const cols = widths.map((_, index) => ({
|
|
167
|
+
width: tableCellMinWidth,
|
|
168
|
+
minWidth: tableCellMinWidth,
|
|
169
|
+
index
|
|
170
|
+
}));
|
|
171
|
+
const minWidthResizeState = {
|
|
172
|
+
cols,
|
|
173
|
+
widths,
|
|
174
|
+
maxSize: previousTableInfo.possibleMaxWidth,
|
|
175
|
+
tableWidth: previousTableInfo.width,
|
|
176
|
+
overflow: wasTableInOverflow
|
|
177
|
+
};
|
|
178
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
179
|
+
}
|
|
180
|
+
let resizeState = getResizeState({
|
|
181
|
+
minWidth: tableCellMinWidth,
|
|
182
|
+
table: table.node,
|
|
183
|
+
start: table.start,
|
|
184
|
+
tableRef,
|
|
185
|
+
domAtPos,
|
|
186
|
+
maxSize: previousTableInfo.possibleMaxWidth
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Two scenarios that require scaling:
|
|
190
|
+
// 1. If the new table width will result in the table going into overflow
|
|
191
|
+
// we resize the cells to avoid it (e.g. adding a column)
|
|
192
|
+
// 2. If the new table width will be shorter than the parent width, scale columns to fit parent
|
|
193
|
+
if (!wasTableInOverflow && resizeState.overflow || resizeState.tableWidth < resizeState.maxSize) {
|
|
194
|
+
resizeState = scaleTableTo(resizeState, previousTableInfo.possibleMaxWidth);
|
|
195
|
+
}
|
|
196
|
+
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* This function is called when user inserts/deletes a column in a table to;
|
|
201
|
+
* - rescale all columns (if the table did not overflow before the insertion)
|
|
202
|
+
* - and update column widths.
|
|
203
|
+
*
|
|
204
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
205
|
+
* @param table
|
|
206
|
+
* @param view
|
|
207
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
208
|
+
*/
|
|
209
|
+
export const rescaleColumnsOld = getEditorContainerWidth => (table, view) => tr => {
|
|
210
|
+
var _tableRef$parentEleme3;
|
|
117
211
|
if (!view) {
|
|
118
212
|
return tr;
|
|
119
213
|
}
|
|
@@ -138,7 +232,7 @@ export const rescaleColumns = getEditorContainerWidth => (table, view) => tr =>
|
|
|
138
232
|
getEditorContainerWidth
|
|
139
233
|
});
|
|
140
234
|
const tableWidth = tableRef.clientWidth || akEditorDefaultLayoutWidth;
|
|
141
|
-
let tableMaxWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$
|
|
235
|
+
let tableMaxWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme3 = tableRef.parentElement) === null || _tableRef$parentEleme3 === void 0 ? void 0 : _tableRef$parentEleme3.clientWidth) || 0;
|
|
142
236
|
tableMaxWidth -= insertColumnButtonOffset;
|
|
143
237
|
const newTableMap = TableMap.get(newTable);
|
|
144
238
|
const noOfColumns = newTableMap.width;
|
|
@@ -190,4 +284,10 @@ export const rescaleColumns = getEditorContainerWidth => (table, view) => tr =>
|
|
|
190
284
|
resizeState = scaleTableTo(resizeState, maxSize);
|
|
191
285
|
}
|
|
192
286
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
287
|
+
};
|
|
288
|
+
export const rescaleColumns = getEditorContainerWidth => {
|
|
289
|
+
if (getBooleanFF('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
290
|
+
return rescaleColumnsNew();
|
|
291
|
+
}
|
|
292
|
+
return rescaleColumnsOld(getEditorContainerWidth);
|
|
193
293
|
};
|
|
@@ -3,7 +3,9 @@ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics
|
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
8
|
+
import { rescaleColumns } from './column-width';
|
|
7
9
|
import { splitCellsInColumns } from './split';
|
|
8
10
|
const deleteColumnsCustomStep = rect => tr => {
|
|
9
11
|
const table = findTable(tr.selection);
|
|
@@ -191,12 +193,21 @@ function fixRowSpans(table) {
|
|
|
191
193
|
}
|
|
192
194
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
193
195
|
}
|
|
194
|
-
export const deleteColumns = (rect,
|
|
195
|
-
tr
|
|
196
|
+
export const deleteColumns = (rect, allowCustomStep, view) => tr => {
|
|
197
|
+
let updatedTr = tr;
|
|
198
|
+
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
196
199
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
197
200
|
});
|
|
198
|
-
if (
|
|
199
|
-
|
|
201
|
+
if (allowCustomStep) {
|
|
202
|
+
updatedTr = deleteColumnsCustomStep(rect)(updatedTr);
|
|
203
|
+
} else {
|
|
204
|
+
updatedTr = deleteColumnsLegacy(rect)(updatedTr);
|
|
205
|
+
}
|
|
206
|
+
const table = findTable(updatedTr.selection);
|
|
207
|
+
if (getBooleanFF('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
208
|
+
if (table) {
|
|
209
|
+
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
210
|
+
}
|
|
200
211
|
}
|
|
201
|
-
return
|
|
212
|
+
return updatedTr;
|
|
202
213
|
};
|
|
@@ -300,7 +300,7 @@ export class ContextualMenu extends Component {
|
|
|
300
300
|
this.toggleOpen();
|
|
301
301
|
break;
|
|
302
302
|
case 'delete_column':
|
|
303
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch);
|
|
303
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
304
304
|
this.toggleOpen();
|
|
305
305
|
break;
|
|
306
306
|
case 'delete_row':
|
|
@@ -108,7 +108,7 @@ class FloatingDeleteButton extends Component {
|
|
|
108
108
|
switch (this.state.selectionType) {
|
|
109
109
|
case 'column':
|
|
110
110
|
{
|
|
111
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch);
|
|
111
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch, this.props.editorView);
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
case 'row':
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { deleteColumns } from '../transforms/delete-columns';
|
|
2
|
+
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
3
|
+
export var deleteColumnsCommand = function deleteColumnsCommand(rect) {
|
|
4
|
+
return function (state, dispatch, view) {
|
|
5
|
+
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
6
|
+
if (dispatch) {
|
|
7
|
+
dispatch(tr);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
};
|