@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
|
@@ -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 { deleteColumnsCommand } from './commands/delete';
|
|
10
11
|
import { insertColumn, insertRow } from './commands/insert';
|
|
11
12
|
import { deleteTable, deleteTableIfSelected, setMultipleCellAttrs } from './commands/misc';
|
|
12
13
|
import { sortByColumn } from './commands/sort';
|
|
@@ -14,10 +15,9 @@ import { splitCell } from './commands/split-cell';
|
|
|
14
15
|
import { getNextLayout, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './commands/toggle';
|
|
15
16
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
16
17
|
import { distributeColumnsWidths } from './pm-plugins/table-resizing/commands';
|
|
17
|
-
import {
|
|
18
|
+
import { deleteRows, mergeCells } from './transforms';
|
|
18
19
|
import { checkIfNumberColumnEnabled, getSelectedCellInfo, getSelectedTableInfo } from './utils';
|
|
19
20
|
import { withEditorAnalyticsAPI } from './utils/analytics';
|
|
20
|
-
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
21
21
|
var TABLE_BREAKOUT_NAME_MAPPING = {
|
|
22
22
|
default: TABLE_BREAKOUT.NORMAL,
|
|
23
23
|
wide: TABLE_BREAKOUT.WIDE,
|
|
@@ -251,12 +251,7 @@ export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(edit
|
|
|
251
251
|
},
|
|
252
252
|
eventType: EVENT_TYPE.TRACK
|
|
253
253
|
};
|
|
254
|
-
})(editorAnalyticsAPI)(
|
|
255
|
-
if (dispatch) {
|
|
256
|
-
dispatch(deleteColumns(rect, getAllowAddColumnCustomStep(state))(state.tr));
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
});
|
|
254
|
+
})(editorAnalyticsAPI)(deleteColumnsCommand(rect));
|
|
260
255
|
};
|
|
261
256
|
};
|
|
262
257
|
var getTableDeletedAnalytics = function getTableDeletedAnalytics(selection, inputMethod) {
|
|
@@ -250,7 +250,7 @@ export function handleTripleClick(view, pos) {
|
|
|
250
250
|
}
|
|
251
251
|
return false;
|
|
252
252
|
}
|
|
253
|
-
export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI) {
|
|
253
|
+
export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
|
|
254
254
|
var oldSelection = oldState.tr.selection;
|
|
255
255
|
var tr = newState.tr;
|
|
256
256
|
if (oldSelection instanceof CellSelection) {
|
|
@@ -293,7 +293,7 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
293
293
|
isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
|
|
294
294
|
tr = deleteRows(rect, isHeaderRowRequired)(tr);
|
|
295
295
|
} else if (tr.selection.isColSelection()) {
|
|
296
|
-
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState))(tr);
|
|
296
|
+
tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|
|
@@ -93,7 +93,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
93
93
|
}
|
|
94
94
|
if (tr) {
|
|
95
95
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
96
|
-
var updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI);
|
|
96
|
+
var updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined);
|
|
97
97
|
return fixTables(updatedTr) || updatedTr;
|
|
98
98
|
}
|
|
99
99
|
if (transactions.find(function (tr) {
|
|
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
5
|
-
import { tableCellMinWidth
|
|
5
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
|
+
import { TableMap, tableNewColumnMinWidth } from '@atlaskit/editor-tables/table-map';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
10
10
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
@@ -12,6 +12,14 @@ import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
|
|
|
12
12
|
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
13
13
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
14
14
|
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
18
|
+
* @param resizeState
|
|
19
|
+
* @param table
|
|
20
|
+
* @param start
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
15
23
|
export var updateColumnWidths = function updateColumnWidths(resizeState, table, start) {
|
|
16
24
|
return function (tr) {
|
|
17
25
|
var map = TableMap.get(table);
|
|
@@ -114,10 +122,102 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
114
122
|
* @param view
|
|
115
123
|
* @returns Updated transaction with rescaled columns for a given table
|
|
116
124
|
*/
|
|
117
|
-
export var
|
|
125
|
+
export var rescaleColumnsNew = function rescaleColumnsNew() {
|
|
118
126
|
return function (table, view) {
|
|
119
127
|
return function (tr) {
|
|
120
|
-
var _tableRef$parentEleme;
|
|
128
|
+
var _tableRef$parentEleme, _tableRef$parentEleme2;
|
|
129
|
+
if (!view) {
|
|
130
|
+
return tr;
|
|
131
|
+
}
|
|
132
|
+
var newTable = tr.doc.nodeAt(table.pos);
|
|
133
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
134
|
+
var maybeTable = domAtPos(table.start).node;
|
|
135
|
+
var tableRef = maybeTable.closest('table');
|
|
136
|
+
if (!tableRef || !newTable) {
|
|
137
|
+
return tr;
|
|
138
|
+
}
|
|
139
|
+
var isResized = hasTableBeenResized(table.node);
|
|
140
|
+
// get current table info
|
|
141
|
+
var previousTableInfo = {
|
|
142
|
+
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
143
|
+
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
144
|
+
/** the is the width the table can reach before overflowing */
|
|
145
|
+
possibleMaxWidth: 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) - insertColumnButtonOffset - 1,
|
|
146
|
+
isResized: isResized
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// determine the new table, based on new width
|
|
150
|
+
var newTableInfo = {
|
|
151
|
+
noOfColumns: TableMap.get(newTable).width
|
|
152
|
+
};
|
|
153
|
+
if (!newTableInfo.noOfColumns || newTableInfo.noOfColumns <= 0) {
|
|
154
|
+
return tr;
|
|
155
|
+
}
|
|
156
|
+
var averageColumnWidth = previousTableInfo.width / newTableInfo.noOfColumns;
|
|
157
|
+
|
|
158
|
+
// 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
|
|
159
|
+
// we skip updating the size of columns here.
|
|
160
|
+
if (!previousTableInfo.isResized && averageColumnWidth > tableCellMinWidth) {
|
|
161
|
+
return tr;
|
|
162
|
+
}
|
|
163
|
+
var wasTableInOverflow = previousTableInfo.width > previousTableInfo.possibleMaxWidth;
|
|
164
|
+
|
|
165
|
+
// If the table has not been resized, and each column width is smaller than the minimum column width
|
|
166
|
+
// Or if the table has been resized, but each column width is either 48px or null
|
|
167
|
+
// we update the table to have 48px for each column
|
|
168
|
+
if (!previousTableInfo.isResized && averageColumnWidth <= tableCellMinWidth || previousTableInfo.isResized && isMinCellWidthTable(table.node)) {
|
|
169
|
+
var widths = new Array(newTableInfo.noOfColumns).fill(tableCellMinWidth);
|
|
170
|
+
var cols = widths.map(function (_, index) {
|
|
171
|
+
return {
|
|
172
|
+
width: tableCellMinWidth,
|
|
173
|
+
minWidth: tableCellMinWidth,
|
|
174
|
+
index: index
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
var minWidthResizeState = {
|
|
178
|
+
cols: cols,
|
|
179
|
+
widths: widths,
|
|
180
|
+
maxSize: previousTableInfo.possibleMaxWidth,
|
|
181
|
+
tableWidth: previousTableInfo.width,
|
|
182
|
+
overflow: wasTableInOverflow
|
|
183
|
+
};
|
|
184
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
185
|
+
}
|
|
186
|
+
var resizeState = getResizeState({
|
|
187
|
+
minWidth: tableCellMinWidth,
|
|
188
|
+
table: table.node,
|
|
189
|
+
start: table.start,
|
|
190
|
+
tableRef: tableRef,
|
|
191
|
+
domAtPos: domAtPos,
|
|
192
|
+
maxSize: previousTableInfo.possibleMaxWidth
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Two scenarios that require scaling:
|
|
196
|
+
// 1. If the new table width will result in the table going into overflow
|
|
197
|
+
// we resize the cells to avoid it (e.g. adding a column)
|
|
198
|
+
// 2. If the new table width will be shorter than the parent width, scale columns to fit parent
|
|
199
|
+
if (!wasTableInOverflow && resizeState.overflow || resizeState.tableWidth < resizeState.maxSize) {
|
|
200
|
+
resizeState = scaleTableTo(resizeState, previousTableInfo.possibleMaxWidth);
|
|
201
|
+
}
|
|
202
|
+
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* This function is called when user inserts/deletes a column in a table to;
|
|
209
|
+
* - rescale all columns (if the table did not overflow before the insertion)
|
|
210
|
+
* - and update column widths.
|
|
211
|
+
*
|
|
212
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
213
|
+
* @param table
|
|
214
|
+
* @param view
|
|
215
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
216
|
+
*/
|
|
217
|
+
export var rescaleColumnsOld = function rescaleColumnsOld(getEditorContainerWidth) {
|
|
218
|
+
return function (table, view) {
|
|
219
|
+
return function (tr) {
|
|
220
|
+
var _tableRef$parentEleme3;
|
|
121
221
|
if (!view) {
|
|
122
222
|
return tr;
|
|
123
223
|
}
|
|
@@ -140,7 +240,7 @@ export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
140
240
|
getEditorContainerWidth: getEditorContainerWidth
|
|
141
241
|
});
|
|
142
242
|
var tableWidth = tableRef.clientWidth || akEditorDefaultLayoutWidth;
|
|
143
|
-
var tableMaxWidth = (tableRef === null || tableRef === void 0 || (_tableRef$
|
|
243
|
+
var tableMaxWidth = (tableRef === null || tableRef === void 0 || (_tableRef$parentEleme3 = tableRef.parentElement) === null || _tableRef$parentEleme3 === void 0 ? void 0 : _tableRef$parentEleme3.clientWidth) || 0;
|
|
144
244
|
tableMaxWidth -= insertColumnButtonOffset;
|
|
145
245
|
var newTableMap = TableMap.get(newTable);
|
|
146
246
|
var noOfColumns = newTableMap.width;
|
|
@@ -196,4 +296,10 @@ export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
|
196
296
|
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
197
297
|
};
|
|
198
298
|
};
|
|
299
|
+
};
|
|
300
|
+
export var rescaleColumns = function rescaleColumns(getEditorContainerWidth) {
|
|
301
|
+
if (getBooleanFF('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
302
|
+
return rescaleColumnsNew();
|
|
303
|
+
}
|
|
304
|
+
return rescaleColumnsOld(getEditorContainerWidth);
|
|
199
305
|
};
|
|
@@ -7,7 +7,9 @@ import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics
|
|
|
7
7
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
12
|
+
import { rescaleColumns } from './column-width';
|
|
11
13
|
import { splitCellsInColumns } from './split';
|
|
12
14
|
var deleteColumnsCustomStep = function deleteColumnsCustomStep(rect) {
|
|
13
15
|
return function (tr) {
|
|
@@ -203,15 +205,23 @@ function fixRowSpans(table) {
|
|
|
203
205
|
}
|
|
204
206
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
205
207
|
}
|
|
206
|
-
export var deleteColumns = function deleteColumns(rect) {
|
|
207
|
-
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
208
|
+
export var deleteColumns = function deleteColumns(rect, allowCustomStep, view) {
|
|
208
209
|
return function (tr) {
|
|
209
|
-
tr
|
|
210
|
+
var updatedTr = tr;
|
|
211
|
+
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
210
212
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
211
213
|
});
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
+
if (allowCustomStep) {
|
|
215
|
+
updatedTr = deleteColumnsCustomStep(rect)(updatedTr);
|
|
216
|
+
} else {
|
|
217
|
+
updatedTr = deleteColumnsLegacy(rect)(updatedTr);
|
|
218
|
+
}
|
|
219
|
+
var table = findTable(updatedTr.selection);
|
|
220
|
+
if (getBooleanFF('platform.editor.table-update-colwidths-after-column-is-deleted')) {
|
|
221
|
+
if (table) {
|
|
222
|
+
updatedTr = rescaleColumns()(table, view)(updatedTr);
|
|
223
|
+
}
|
|
214
224
|
}
|
|
215
|
-
return
|
|
225
|
+
return updatedTr;
|
|
216
226
|
};
|
|
217
227
|
};
|
|
@@ -298,7 +298,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
298
298
|
_this.toggleOpen();
|
|
299
299
|
break;
|
|
300
300
|
case 'delete_column':
|
|
301
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch);
|
|
301
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
302
302
|
_this.toggleOpen();
|
|
303
303
|
break;
|
|
304
304
|
case 'delete_row':
|
|
@@ -114,7 +114,7 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
114
114
|
switch (_this.state.selectionType) {
|
|
115
115
|
case 'column':
|
|
116
116
|
{
|
|
117
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch);
|
|
117
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch, _this.props.editorView);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
case 'row':
|
|
@@ -49,7 +49,7 @@ var tableStickyHeaderColumnControlsDecorationsStyle = function tableStickyHeader
|
|
|
49
49
|
};
|
|
50
50
|
var tableWrapperStyles = function tableWrapperStyles() {
|
|
51
51
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
52
|
-
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\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
|
|
52
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\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 "])), ClassName.TABLE_NODE_WRAPPER);
|
|
53
53
|
} else {
|
|
54
54
|
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\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 "])), ClassName.TABLE_NODE_WRAPPER, insertColumnButtonOffset, insertColumnButtonOffset);
|
|
55
55
|
}
|
|
@@ -11,5 +11,5 @@ export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => bo
|
|
|
11
11
|
export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
|
|
12
12
|
export declare const handleMouseMove: (view: EditorView, event: Event, elementContentRects?: ElementContentRects) => boolean;
|
|
13
13
|
export declare function handleTripleClick(view: EditorView, pos: number): boolean;
|
|
14
|
-
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI) => Transaction;
|
|
14
|
+
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView) => Transaction;
|
|
15
15
|
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
@@ -16,5 +16,5 @@ interface getTableMaxWidthProps {
|
|
|
16
16
|
layout: TableLayout;
|
|
17
17
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
18
18
|
}
|
|
19
|
-
export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) =>
|
|
19
|
+
export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => number;
|
|
20
20
|
export {};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import type { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
7
|
+
/**
|
|
8
|
+
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
9
|
+
* @param resizeState
|
|
10
|
+
* @param table
|
|
11
|
+
* @param start
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
7
14
|
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number) => (tr: Transaction) => Transaction;
|
|
8
15
|
/**
|
|
9
16
|
* This function is called when user inserts/deletes a column in a table to;
|
|
@@ -15,4 +22,16 @@ export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNod
|
|
|
15
22
|
* @param view
|
|
16
23
|
* @returns Updated transaction with rescaled columns for a given table
|
|
17
24
|
*/
|
|
18
|
-
export declare const
|
|
25
|
+
export declare const rescaleColumnsNew: () => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
26
|
+
/**
|
|
27
|
+
* This function is called when user inserts/deletes a column in a table to;
|
|
28
|
+
* - rescale all columns (if the table did not overflow before the insertion)
|
|
29
|
+
* - and update column widths.
|
|
30
|
+
*
|
|
31
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
32
|
+
* @param table
|
|
33
|
+
* @param view
|
|
34
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
35
|
+
*/
|
|
36
|
+
export declare const rescaleColumnsOld: (getEditorContainerWidth: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
37
|
+
export declare const rescaleColumns: (getEditorContainerWidth?: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
3
|
-
export declare const deleteColumns: (rect: Rect,
|
|
4
|
+
export declare const deleteColumns: (rect: Rect, allowCustomStep: boolean, view?: EditorView) => (tr: Transaction) => Transaction;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
|
-
import { CellSelectionType } from './types';
|
|
3
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
|
+
import type { CellSelectionType } from './types';
|
|
7
7
|
export interface Props {
|
|
8
8
|
editorView: EditorView;
|
|
9
9
|
selection: Selection;
|
|
@@ -11,5 +11,5 @@ export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => bo
|
|
|
11
11
|
export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
|
|
12
12
|
export declare const handleMouseMove: (view: EditorView, event: Event, elementContentRects?: ElementContentRects) => boolean;
|
|
13
13
|
export declare function handleTripleClick(view: EditorView, pos: number): boolean;
|
|
14
|
-
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI) => Transaction;
|
|
14
|
+
export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView) => Transaction;
|
|
15
15
|
export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
|
|
@@ -16,5 +16,5 @@ interface getTableMaxWidthProps {
|
|
|
16
16
|
layout: TableLayout;
|
|
17
17
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
18
18
|
}
|
|
19
|
-
export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) =>
|
|
19
|
+
export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => number;
|
|
20
20
|
export {};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import type { ResizeState } from '../pm-plugins/table-resizing/utils';
|
|
7
|
+
/**
|
|
8
|
+
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
9
|
+
* @param resizeState
|
|
10
|
+
* @param table
|
|
11
|
+
* @param start
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
7
14
|
export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNode, start: number) => (tr: Transaction) => Transaction;
|
|
8
15
|
/**
|
|
9
16
|
* This function is called when user inserts/deletes a column in a table to;
|
|
@@ -15,4 +22,16 @@ export declare const updateColumnWidths: (resizeState: ResizeState, table: PMNod
|
|
|
15
22
|
* @param view
|
|
16
23
|
* @returns Updated transaction with rescaled columns for a given table
|
|
17
24
|
*/
|
|
18
|
-
export declare const
|
|
25
|
+
export declare const rescaleColumnsNew: () => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
26
|
+
/**
|
|
27
|
+
* This function is called when user inserts/deletes a column in a table to;
|
|
28
|
+
* - rescale all columns (if the table did not overflow before the insertion)
|
|
29
|
+
* - and update column widths.
|
|
30
|
+
*
|
|
31
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
32
|
+
* @param table
|
|
33
|
+
* @param view
|
|
34
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
35
|
+
*/
|
|
36
|
+
export declare const rescaleColumnsOld: (getEditorContainerWidth: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
37
|
+
export declare const rescaleColumns: (getEditorContainerWidth?: GetEditorContainerWidth) => (table: ContentNodeWithPos, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
3
|
-
export declare const deleteColumns: (rect: Rect,
|
|
4
|
+
export declare const deleteColumns: (rect: Rect, allowCustomStep: boolean, view?: EditorView) => (tr: Transaction) => Transaction;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
|
-
import { CellSelectionType } from './types';
|
|
3
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
6
|
+
import type { CellSelectionType } from './types';
|
|
7
7
|
export interface Props {
|
|
8
8
|
editorView: EditorView;
|
|
9
9
|
selection: Selection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -126,6 +126,9 @@
|
|
|
126
126
|
},
|
|
127
127
|
"platform.editor.table.update-table-resizer-styles": {
|
|
128
128
|
"type": "boolean"
|
|
129
|
+
},
|
|
130
|
+
"platform.editor.table-update-colwidths-after-column-is-deleted": {
|
|
131
|
+
"type": "boolean"
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
}
|
|
@@ -327,6 +327,7 @@ describe('table plugin: actions', () => {
|
|
|
327
327
|
const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
328
328
|
attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
|
|
329
329
|
};
|
|
330
|
+
|
|
330
331
|
describe('when the entire table is selected', () => {
|
|
331
332
|
it('should remove the table', () => {
|
|
332
333
|
const { editorView, refs } = editor(
|