@atlaskit/editor-plugin-table 7.23.0 → 7.24.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 +24 -0
- package/dist/cjs/pm-plugins/main.js +1 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +34 -19
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +3 -0
- package/dist/cjs/toolbar.js +15 -12
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +14 -8
- package/dist/es2019/pm-plugins/main.js +1 -5
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +41 -25
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +1 -0
- package/dist/es2019/toolbar.js +15 -12
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +14 -8
- package/dist/esm/pm-plugins/main.js +1 -5
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +35 -21
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +3 -0
- package/dist/esm/toolbar.js +15 -12
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +14 -8
- package/package.json +5 -5
- package/src/pm-plugins/main.ts +1 -4
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +59 -31
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +1 -0
- package/src/toolbar.tsx +19 -14
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124519](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124519)
|
|
8
|
+
[`fbd519a29db88`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fbd519a29db88) -
|
|
9
|
+
Don't add merge cell and split cell options to floating toolbar if allowMergedCell is disabled or
|
|
10
|
+
undefined
|
|
11
|
+
- [#124475](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124475)
|
|
12
|
+
[`f1beea7ed5546`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f1beea7ed5546) -
|
|
13
|
+
[ux] [ED-24078] This change is adding aria-labels to the Table Cell Options menu so that the
|
|
14
|
+
screenreader will announce the keyboard shortcuts to keyboard-only users. The change is feature
|
|
15
|
+
flagged behind 'platform_editor_announce_cell_options_hotkeys'.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#124231](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124231)
|
|
20
|
+
[`48ae65e0f36e8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48ae65e0f36e8) -
|
|
21
|
+
Removed FF platform.editor.transform-slice-for-nested-expand
|
|
22
|
+
- [#124519](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124519)
|
|
23
|
+
[`0d1225bff51ff`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0d1225bff51ff) -
|
|
24
|
+
Use scaled amounts for new column resizing, and update logic to cater for more scenarios
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 7.23.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
@@ -202,11 +202,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
202
202
|
if (!pluginConfig.allowBackgroundColor) {
|
|
203
203
|
slice = (0, _misc.transformSliceRemoveCellBackgroundColor)(slice, schema);
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
// If a partial paste of nested expand, paste only nested-expand's content */
|
|
207
|
-
if ((0, _platformFeatureFlags.fg)('platform.editor.transform-slice-for-nested-expand')) {
|
|
208
|
-
slice = (0, _transforms.transformSliceToRemoveOpenNestedExpand)(slice, schema);
|
|
209
|
-
}
|
|
205
|
+
slice = (0, _transforms.transformSliceToRemoveOpenNestedExpand)(slice, schema);
|
|
210
206
|
return slice;
|
|
211
207
|
},
|
|
212
208
|
handleClick: function handleClick(_ref2, _pos, event) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.scaleResizeState = exports.resizeColumnAndTable = exports.resizeColumn = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
11
|
var _types = require("../../../types");
|
|
11
12
|
var _alignment = require("../../../utils/alignment");
|
|
@@ -38,17 +39,18 @@ var resizeColumnAndTable = exports.resizeColumnAndTable = function resizeColumnA
|
|
|
38
39
|
isTableAlignmentEnabled = _ref.isTableAlignmentEnabled;
|
|
39
40
|
var editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
40
41
|
var isTableLeftAligned = tableNode.attrs.layout === _alignment.ALIGN_START;
|
|
42
|
+
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
43
|
+
var isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
41
44
|
var resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
42
45
|
var willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
43
|
-
var willResizedTableStayInOverflow =
|
|
46
|
+
var willResizedTableStayInOverflow = isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
44
47
|
|
|
45
48
|
// STEP 1: Update col width
|
|
46
49
|
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
47
50
|
var _tableRef$closest;
|
|
48
51
|
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
49
52
|
resizeAmount = amount < 0 ? amount : resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth) / 2;
|
|
50
|
-
}
|
|
51
|
-
if (!willResizedTableStayInOverflow && !willTableHitEditorEdge) {
|
|
53
|
+
} else {
|
|
52
54
|
var diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
53
55
|
var rest = amount - diff;
|
|
54
56
|
var final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
@@ -59,25 +61,23 @@ var resizeColumnAndTable = exports.resizeColumnAndTable = function resizeColumnA
|
|
|
59
61
|
// STEP 2: Update table container width
|
|
60
62
|
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
61
63
|
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
62
|
-
newState.maxSize = Math.round(
|
|
64
|
+
newState.maxSize = Math.round(isOverflow ? willResizedTableStayInOverflow ?
|
|
63
65
|
// CASE 1A: table will stay in overflow
|
|
64
66
|
// do not grow the table because resize is happening in the overflow region
|
|
65
67
|
// and the overall table container needs to be retained
|
|
66
|
-
resizeState.maxSize :
|
|
68
|
+
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth : resizeState.maxSize :
|
|
67
69
|
// CASE 1B: table will no longer be in overflow, so adjust container width
|
|
68
70
|
// ensure the table is resized without any 'big jumps' by working out
|
|
69
71
|
// the difference between the new table width and the max size and adding the resize
|
|
70
|
-
resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
72
|
+
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + (resizeState.tableWidth - resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + delta) : resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
71
73
|
// CASE 2: table will hit editor edge
|
|
72
74
|
editorContainerWidth :
|
|
73
75
|
// CASE 3: table is being resized from a non-overflow state
|
|
74
|
-
resizeState.maxSize + delta);
|
|
76
|
+
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + delta : resizeState.maxSize + delta);
|
|
75
77
|
|
|
76
78
|
// do not apply scaling logic because resize state is already scaled
|
|
77
79
|
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, false, false);
|
|
78
|
-
|
|
79
|
-
updateTablePreview(tableRef, newState.maxSize, (0, _alignment.shouldChangeAlignmentToCenterResized)(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
80
|
-
}
|
|
80
|
+
updateTablePreview(tableRef, newState.maxSize, (0, _alignment.shouldChangeAlignmentToCenterResized)(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
81
81
|
return newState;
|
|
82
82
|
};
|
|
83
83
|
var updateTablePreview = function updateTablePreview(tableRef, newTableWidth, shouldChangeAlignment) {
|
|
@@ -105,37 +105,52 @@ var scaleResizeState = exports.scaleResizeState = function scaleResizeState(_ref
|
|
|
105
105
|
tableRef = _ref2.tableRef,
|
|
106
106
|
tableNode = _ref2.tableNode,
|
|
107
107
|
editorWidth = _ref2.editorWidth;
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
109
|
+
var isTableScaled = isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
110
|
+
|
|
111
|
+
// Tables with number column can cause the table to be in two different states:
|
|
112
|
+
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
113
|
+
// avoid scaling and take the document width
|
|
114
|
+
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
115
|
+
// is scaled using preserve table width logic, for this apply a scaled width
|
|
116
|
+
// return early if table isn't scaled
|
|
117
|
+
if (!isTableScaled || isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth) {
|
|
110
118
|
return resizeState;
|
|
111
119
|
}
|
|
112
120
|
var scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef);
|
|
121
|
+
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
113
122
|
var cols = resizeState.cols.map(function (col) {
|
|
114
123
|
return _objectSpread(_objectSpread({}, col), {}, {
|
|
115
|
-
|
|
124
|
+
minWidth: _styles.tableCellMinWidth,
|
|
125
|
+
width: Math.max(Math.round(col.width * scalePercent), _styles.tableCellMinWidth)
|
|
116
126
|
});
|
|
117
127
|
});
|
|
118
|
-
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
119
128
|
var calculatedTableWidth = cols.reduce(function (prev, curr) {
|
|
120
129
|
return prev + curr.width;
|
|
121
130
|
}, 0);
|
|
122
131
|
|
|
123
132
|
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
124
|
-
// distribute the difference to the
|
|
133
|
+
// distribute the difference to the first column
|
|
125
134
|
if (calculatedTableWidth > scaledTableWidth) {
|
|
126
135
|
var diff = calculatedTableWidth - scaledTableWidth;
|
|
136
|
+
var hasDiffBeenDistributed = false;
|
|
127
137
|
cols = cols.map(function (col) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
139
|
+
hasDiffBeenDistributed = true;
|
|
140
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
141
|
+
width: col.width - diff
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return col;
|
|
131
145
|
});
|
|
132
146
|
}
|
|
147
|
+
var maxSize = isNumberColumnEnabled ? Math.round((resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth) * scalePercent) : Math.round(resizeState.maxSize * scalePercent);
|
|
133
148
|
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
134
149
|
widths: cols.map(function (col) {
|
|
135
150
|
return col.width;
|
|
136
151
|
}),
|
|
137
152
|
tableWidth: scaledTableWidth,
|
|
138
|
-
maxSize:
|
|
153
|
+
maxSize: maxSize,
|
|
139
154
|
cols: cols
|
|
140
155
|
});
|
|
141
156
|
};
|
|
@@ -241,6 +241,9 @@ function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
|
241
241
|
return col;
|
|
242
242
|
});
|
|
243
243
|
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
244
|
+
tableWidth: updatedCols.reduce(function (acc, col) {
|
|
245
|
+
return acc + col.width;
|
|
246
|
+
}, 0),
|
|
244
247
|
cols: updatedCols
|
|
245
248
|
});
|
|
246
249
|
}
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -217,19 +217,22 @@ var getToolbarCellOptionsConfig = exports.getToolbarCellOptionsConfig = function
|
|
|
217
217
|
onMouseLeave: (0, _commands.clearHoverSelection)(),
|
|
218
218
|
selected: false,
|
|
219
219
|
disabled: false
|
|
220
|
-
}, {
|
|
221
|
-
id: 'editor.table.mergeCells',
|
|
222
|
-
title: formatMessage(_messages.tableMessages.mergeCells),
|
|
223
|
-
onClick: (0, _commandsWithAnalytics.mergeCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB),
|
|
224
|
-
selected: false,
|
|
225
|
-
disabled: !(0, _transforms.canMergeCells)(editorState.tr)
|
|
226
|
-
}, {
|
|
227
|
-
id: 'editor.table.splitCell',
|
|
228
|
-
title: formatMessage(_messages.tableMessages.splitCell),
|
|
229
|
-
onClick: (0, _commandsWithAnalytics.splitCellWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB),
|
|
230
|
-
selected: false,
|
|
231
|
-
disabled: !(0, _utils3.splitCell)(editorState)
|
|
232
220
|
}];
|
|
221
|
+
if (pluginState.pluginConfig.allowMergeCells) {
|
|
222
|
+
options.push({
|
|
223
|
+
id: 'editor.table.mergeCells',
|
|
224
|
+
title: formatMessage(_messages.tableMessages.mergeCells),
|
|
225
|
+
onClick: (0, _commandsWithAnalytics.mergeCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB),
|
|
226
|
+
selected: false,
|
|
227
|
+
disabled: !(0, _transforms.canMergeCells)(editorState.tr)
|
|
228
|
+
}, {
|
|
229
|
+
id: 'editor.table.splitCell',
|
|
230
|
+
title: formatMessage(_messages.tableMessages.splitCell),
|
|
231
|
+
onClick: (0, _commandsWithAnalytics.splitCellWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.FLOATING_TB),
|
|
232
|
+
selected: false,
|
|
233
|
+
disabled: !(0, _utils3.splitCell)(editorState)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
233
236
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
234
237
|
var _newResizeStateWithAn;
|
|
235
238
|
var newResizeStateWithAnalytics = editorView ? (0, _resizeState.getNewResizeStateFromSelectedColumns)(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : undefined;
|
|
@@ -215,8 +215,9 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
215
215
|
editorView = _this$props3.editorView;
|
|
216
216
|
var _getPluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
217
217
|
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
218
|
+
var content = formatMessage(isDragAndDropEnabled ? _messages.tableMessages.addColumnRight : _messages.tableMessages.insertColumn);
|
|
218
219
|
return {
|
|
219
|
-
content:
|
|
220
|
+
content: content,
|
|
220
221
|
value: {
|
|
221
222
|
name: 'insert_column'
|
|
222
223
|
},
|
|
@@ -228,7 +229,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
228
229
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
229
230
|
(0, _react2.jsx)("span", {
|
|
230
231
|
css: _styles2.elementBeforeIconStyles
|
|
231
|
-
}, (0, _react2.jsx)(_icons.AddColRightIcon, null)) : undefined
|
|
232
|
+
}, (0, _react2.jsx)(_icons.AddColRightIcon, null)) : undefined,
|
|
233
|
+
'aria-label': (0, _platformFeatureFlags.fg)('platform_editor_announce_cell_options_hotkeys') ? (0, _keymaps.tooltip)(_keymaps.addColumnAfter, String(content)) : undefined
|
|
232
234
|
};
|
|
233
235
|
});
|
|
234
236
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createInsertRowItem", function () {
|
|
@@ -237,8 +239,9 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
237
239
|
editorView = _this$props4.editorView;
|
|
238
240
|
var _getPluginState4 = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
239
241
|
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
|
|
242
|
+
var content = formatMessage(isDragAndDropEnabled ? _messages.tableMessages.addRowBelow : _messages.tableMessages.insertRow);
|
|
240
243
|
return {
|
|
241
|
-
content:
|
|
244
|
+
content: content,
|
|
242
245
|
value: {
|
|
243
246
|
name: 'insert_row'
|
|
244
247
|
},
|
|
@@ -250,7 +253,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
250
253
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
251
254
|
(0, _react2.jsx)("span", {
|
|
252
255
|
css: _styles2.elementBeforeIconStyles
|
|
253
|
-
}, (0, _react2.jsx)(_icons.AddRowBelowIcon, null)) : undefined
|
|
256
|
+
}, (0, _react2.jsx)(_icons.AddRowBelowIcon, null)) : undefined,
|
|
257
|
+
'aria-label': (0, _platformFeatureFlags.fg)('platform_editor_announce_cell_options_hotkeys') ? (0, _keymaps.tooltip)(_keymaps.addRowAfter, String(content)) : undefined
|
|
254
258
|
};
|
|
255
259
|
});
|
|
256
260
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createClearCellsItem", function () {
|
|
@@ -266,10 +270,11 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
266
270
|
left = selectionRect.left;
|
|
267
271
|
var noOfColumns = right - left;
|
|
268
272
|
var noOfRows = bottom - top;
|
|
273
|
+
var content = formatMessage(_messages.tableMessages.clearCells, {
|
|
274
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
275
|
+
});
|
|
269
276
|
return {
|
|
270
|
-
content:
|
|
271
|
-
0: Math.max(noOfColumns, noOfRows)
|
|
272
|
-
}),
|
|
277
|
+
content: content,
|
|
273
278
|
value: {
|
|
274
279
|
name: 'clear'
|
|
275
280
|
},
|
|
@@ -285,7 +290,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
285
290
|
label: formatMessage(_messages.tableMessages.clearCells, {
|
|
286
291
|
0: Math.max(noOfColumns, noOfRows)
|
|
287
292
|
})
|
|
288
|
-
})) : undefined
|
|
293
|
+
})) : undefined,
|
|
294
|
+
'aria-label': (0, _platformFeatureFlags.fg)('platform_editor_announce_cell_options_hotkeys') ? (0, _keymaps.tooltip)(_keymaps.backspace, String(content)) : undefined
|
|
289
295
|
};
|
|
290
296
|
});
|
|
291
297
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createDeleteColumnItem", function () {
|
|
@@ -194,11 +194,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
194
194
|
if (!pluginConfig.allowBackgroundColor) {
|
|
195
195
|
slice = transformSliceRemoveCellBackgroundColor(slice, schema);
|
|
196
196
|
}
|
|
197
|
-
|
|
198
|
-
// If a partial paste of nested expand, paste only nested-expand's content */
|
|
199
|
-
if (fg('platform.editor.transform-slice-for-nested-expand')) {
|
|
200
|
-
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
201
|
-
}
|
|
197
|
+
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
202
198
|
return slice;
|
|
203
199
|
},
|
|
204
200
|
handleClick: ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
|
-
|
|
3
|
-
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
2
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
+
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
5
5
|
import { ALIGN_CENTER, ALIGN_START, shouldChangeAlignmentToCenterResized } from '../../../utils/alignment';
|
|
6
6
|
import { getTableScalingPercent } from './misc';
|
|
@@ -29,46 +29,45 @@ export const resizeColumnAndTable = ({
|
|
|
29
29
|
}) => {
|
|
30
30
|
const editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
31
31
|
const isTableLeftAligned = tableNode.attrs.layout === ALIGN_START;
|
|
32
|
+
const isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
33
|
+
const isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
32
34
|
let resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
33
35
|
const willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
34
|
-
const willResizedTableStayInOverflow =
|
|
36
|
+
const willResizedTableStayInOverflow = isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
35
37
|
|
|
36
38
|
// STEP 1: Update col width
|
|
37
39
|
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
38
40
|
var _tableRef$closest;
|
|
39
41
|
const tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
40
42
|
resizeAmount = amount < 0 ? amount : resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth) / 2;
|
|
41
|
-
}
|
|
42
|
-
if (!willResizedTableStayInOverflow && !willTableHitEditorEdge) {
|
|
43
|
+
} else {
|
|
43
44
|
const diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
44
45
|
const rest = amount - diff;
|
|
45
46
|
const final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
46
47
|
resizeAmount = final;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
const newState = updateAffectedColumn(resizeState, colIndex, resizeAmount);
|
|
49
50
|
|
|
50
51
|
// STEP 2: Update table container width
|
|
51
52
|
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
52
53
|
const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
53
|
-
newState.maxSize = Math.round(
|
|
54
|
+
newState.maxSize = Math.round(isOverflow ? willResizedTableStayInOverflow ?
|
|
54
55
|
// CASE 1A: table will stay in overflow
|
|
55
56
|
// do not grow the table because resize is happening in the overflow region
|
|
56
57
|
// and the overall table container needs to be retained
|
|
57
|
-
resizeState.maxSize :
|
|
58
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth : resizeState.maxSize :
|
|
58
59
|
// CASE 1B: table will no longer be in overflow, so adjust container width
|
|
59
60
|
// ensure the table is resized without any 'big jumps' by working out
|
|
60
61
|
// the difference between the new table width and the max size and adding the resize
|
|
61
|
-
resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
62
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + (resizeState.tableWidth - resizeState.maxSize + akEditorTableNumberColumnWidth + delta) : resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
62
63
|
// CASE 2: table will hit editor edge
|
|
63
64
|
editorContainerWidth :
|
|
64
65
|
// CASE 3: table is being resized from a non-overflow state
|
|
65
|
-
resizeState.maxSize + delta);
|
|
66
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + delta : resizeState.maxSize + delta);
|
|
66
67
|
|
|
67
68
|
// do not apply scaling logic because resize state is already scaled
|
|
68
69
|
updateColgroup(newState, tableRef, tableNode, false, false);
|
|
69
|
-
|
|
70
|
-
updateTablePreview(tableRef, newState.maxSize, shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
71
|
-
}
|
|
70
|
+
updateTablePreview(tableRef, newState.maxSize, shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
72
71
|
return newState;
|
|
73
72
|
};
|
|
74
73
|
const updateTablePreview = (tableRef, newTableWidth, shouldChangeAlignment) => {
|
|
@@ -95,34 +94,51 @@ export const scaleResizeState = ({
|
|
|
95
94
|
tableNode,
|
|
96
95
|
editorWidth
|
|
97
96
|
}) => {
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
98
|
+
const isTableScaled = isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
99
|
+
|
|
100
|
+
// Tables with number column can cause the table to be in two different states:
|
|
101
|
+
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
102
|
+
// avoid scaling and take the document width
|
|
103
|
+
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
104
|
+
// is scaled using preserve table width logic, for this apply a scaled width
|
|
105
|
+
// return early if table isn't scaled
|
|
106
|
+
if (!isTableScaled || isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth) {
|
|
100
107
|
return resizeState;
|
|
101
108
|
}
|
|
102
109
|
const scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
103
|
-
let cols = resizeState.cols.map(col => ({
|
|
104
|
-
...col,
|
|
105
|
-
width: Math.round(Math.max(col.width * scalePercent, col.minWidth))
|
|
106
|
-
}));
|
|
107
110
|
const scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
111
|
+
let cols = resizeState.cols.map(col => {
|
|
112
|
+
return {
|
|
113
|
+
...col,
|
|
114
|
+
minWidth: tableCellMinWidth,
|
|
115
|
+
width: Math.max(Math.round(col.width * scalePercent), tableCellMinWidth)
|
|
116
|
+
};
|
|
117
|
+
});
|
|
108
118
|
const calculatedTableWidth = cols.reduce((prev, curr) => prev + curr.width, 0);
|
|
109
119
|
|
|
110
120
|
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
111
|
-
// distribute the difference to the
|
|
121
|
+
// distribute the difference to the first column
|
|
112
122
|
if (calculatedTableWidth > scaledTableWidth) {
|
|
113
123
|
const diff = calculatedTableWidth - scaledTableWidth;
|
|
124
|
+
let hasDiffBeenDistributed = false;
|
|
114
125
|
cols = cols.map(col => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
127
|
+
hasDiffBeenDistributed = true;
|
|
128
|
+
return {
|
|
129
|
+
...col,
|
|
130
|
+
width: col.width - diff
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return col;
|
|
119
134
|
});
|
|
120
135
|
}
|
|
136
|
+
const maxSize = isNumberColumnEnabled ? Math.round((resizeState.maxSize + akEditorTableNumberColumnWidth) * scalePercent) : Math.round(resizeState.maxSize * scalePercent);
|
|
121
137
|
return {
|
|
122
138
|
...resizeState,
|
|
123
139
|
widths: cols.map(col => col.width),
|
|
124
140
|
tableWidth: scaledTableWidth,
|
|
125
|
-
maxSize
|
|
141
|
+
maxSize,
|
|
126
142
|
cols
|
|
127
143
|
};
|
|
128
144
|
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -199,19 +199,22 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
199
199
|
onMouseLeave: clearHoverSelection(),
|
|
200
200
|
selected: false,
|
|
201
201
|
disabled: false
|
|
202
|
-
}, {
|
|
203
|
-
id: 'editor.table.mergeCells',
|
|
204
|
-
title: formatMessage(messages.mergeCells),
|
|
205
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
206
|
-
selected: false,
|
|
207
|
-
disabled: !canMergeCells(editorState.tr)
|
|
208
|
-
}, {
|
|
209
|
-
id: 'editor.table.splitCell',
|
|
210
|
-
title: formatMessage(messages.splitCell),
|
|
211
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
212
|
-
selected: false,
|
|
213
|
-
disabled: !splitCell(editorState)
|
|
214
202
|
}];
|
|
203
|
+
if (pluginState.pluginConfig.allowMergeCells) {
|
|
204
|
+
options.push({
|
|
205
|
+
id: 'editor.table.mergeCells',
|
|
206
|
+
title: formatMessage(messages.mergeCells),
|
|
207
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
208
|
+
selected: false,
|
|
209
|
+
disabled: !canMergeCells(editorState.tr)
|
|
210
|
+
}, {
|
|
211
|
+
id: 'editor.table.splitCell',
|
|
212
|
+
title: formatMessage(messages.splitCell),
|
|
213
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
214
|
+
selected: false,
|
|
215
|
+
disabled: !splitCell(editorState)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
215
218
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
216
219
|
var _newResizeStateWithAn;
|
|
217
220
|
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : undefined;
|
|
@@ -208,8 +208,9 @@ export class ContextualMenu extends Component {
|
|
|
208
208
|
const {
|
|
209
209
|
isDragAndDropEnabled
|
|
210
210
|
} = getPluginState(editorView.state);
|
|
211
|
+
const content = formatMessage(isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn);
|
|
211
212
|
return {
|
|
212
|
-
content
|
|
213
|
+
content,
|
|
213
214
|
value: {
|
|
214
215
|
name: 'insert_column'
|
|
215
216
|
},
|
|
@@ -221,7 +222,8 @@ export class ContextualMenu extends Component {
|
|
|
221
222
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
222
223
|
jsx("span", {
|
|
223
224
|
css: elementBeforeIconStyles
|
|
224
|
-
}, jsx(AddColRightIcon, null)) : undefined
|
|
225
|
+
}, jsx(AddColRightIcon, null)) : undefined,
|
|
226
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(addColumnAfter, String(content)) : undefined
|
|
225
227
|
};
|
|
226
228
|
});
|
|
227
229
|
_defineProperty(this, "createInsertRowItem", () => {
|
|
@@ -234,8 +236,9 @@ export class ContextualMenu extends Component {
|
|
|
234
236
|
const {
|
|
235
237
|
isDragAndDropEnabled
|
|
236
238
|
} = getPluginState(editorView.state);
|
|
239
|
+
const content = formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow);
|
|
237
240
|
return {
|
|
238
|
-
content
|
|
241
|
+
content,
|
|
239
242
|
value: {
|
|
240
243
|
name: 'insert_row'
|
|
241
244
|
},
|
|
@@ -247,7 +250,8 @@ export class ContextualMenu extends Component {
|
|
|
247
250
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
248
251
|
jsx("span", {
|
|
249
252
|
css: elementBeforeIconStyles
|
|
250
|
-
}, jsx(AddRowBelowIcon, null)) : undefined
|
|
253
|
+
}, jsx(AddRowBelowIcon, null)) : undefined,
|
|
254
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(addRowAfter, String(content)) : undefined
|
|
251
255
|
};
|
|
252
256
|
});
|
|
253
257
|
_defineProperty(this, "createClearCellsItem", () => {
|
|
@@ -269,10 +273,11 @@ export class ContextualMenu extends Component {
|
|
|
269
273
|
} = selectionRect;
|
|
270
274
|
const noOfColumns = right - left;
|
|
271
275
|
const noOfRows = bottom - top;
|
|
276
|
+
const content = formatMessage(messages.clearCells, {
|
|
277
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
278
|
+
});
|
|
272
279
|
return {
|
|
273
|
-
content
|
|
274
|
-
0: Math.max(noOfColumns, noOfRows)
|
|
275
|
-
}),
|
|
280
|
+
content,
|
|
276
281
|
value: {
|
|
277
282
|
name: 'clear'
|
|
278
283
|
},
|
|
@@ -288,7 +293,8 @@ export class ContextualMenu extends Component {
|
|
|
288
293
|
label: formatMessage(messages.clearCells, {
|
|
289
294
|
0: Math.max(noOfColumns, noOfRows)
|
|
290
295
|
})
|
|
291
|
-
})) : undefined
|
|
296
|
+
})) : undefined,
|
|
297
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(backspace, String(content)) : undefined
|
|
292
298
|
};
|
|
293
299
|
});
|
|
294
300
|
_defineProperty(this, "createDeleteColumnItem", () => {
|
|
@@ -195,11 +195,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
195
195
|
if (!pluginConfig.allowBackgroundColor) {
|
|
196
196
|
slice = transformSliceRemoveCellBackgroundColor(slice, schema);
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
// If a partial paste of nested expand, paste only nested-expand's content */
|
|
200
|
-
if (fg('platform.editor.transform-slice-for-nested-expand')) {
|
|
201
|
-
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
202
|
-
}
|
|
198
|
+
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
203
199
|
return slice;
|
|
204
200
|
},
|
|
205
201
|
handleClick: function handleClick(_ref2, _pos, event) {
|
|
@@ -2,8 +2,8 @@ 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
|
// Resize a given column by an amount from the current state
|
|
5
|
-
|
|
6
|
-
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
8
8
|
import { ALIGN_CENTER, ALIGN_START, shouldChangeAlignmentToCenterResized } from '../../../utils/alignment';
|
|
9
9
|
import { getTableScalingPercent } from './misc';
|
|
@@ -33,17 +33,18 @@ export var resizeColumnAndTable = function resizeColumnAndTable(_ref) {
|
|
|
33
33
|
isTableAlignmentEnabled = _ref.isTableAlignmentEnabled;
|
|
34
34
|
var editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
35
35
|
var isTableLeftAligned = tableNode.attrs.layout === ALIGN_START;
|
|
36
|
+
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
37
|
+
var isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
36
38
|
var resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
37
39
|
var willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
38
|
-
var willResizedTableStayInOverflow =
|
|
40
|
+
var willResizedTableStayInOverflow = isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
39
41
|
|
|
40
42
|
// STEP 1: Update col width
|
|
41
43
|
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
42
44
|
var _tableRef$closest;
|
|
43
45
|
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
44
46
|
resizeAmount = amount < 0 ? amount : resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth) / 2;
|
|
45
|
-
}
|
|
46
|
-
if (!willResizedTableStayInOverflow && !willTableHitEditorEdge) {
|
|
47
|
+
} else {
|
|
47
48
|
var diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
48
49
|
var rest = amount - diff;
|
|
49
50
|
var final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
@@ -54,25 +55,23 @@ export var resizeColumnAndTable = function resizeColumnAndTable(_ref) {
|
|
|
54
55
|
// STEP 2: Update table container width
|
|
55
56
|
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
56
57
|
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
57
|
-
newState.maxSize = Math.round(
|
|
58
|
+
newState.maxSize = Math.round(isOverflow ? willResizedTableStayInOverflow ?
|
|
58
59
|
// CASE 1A: table will stay in overflow
|
|
59
60
|
// do not grow the table because resize is happening in the overflow region
|
|
60
61
|
// and the overall table container needs to be retained
|
|
61
|
-
resizeState.maxSize :
|
|
62
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth : resizeState.maxSize :
|
|
62
63
|
// CASE 1B: table will no longer be in overflow, so adjust container width
|
|
63
64
|
// ensure the table is resized without any 'big jumps' by working out
|
|
64
65
|
// the difference between the new table width and the max size and adding the resize
|
|
65
|
-
resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
66
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + (resizeState.tableWidth - resizeState.maxSize + akEditorTableNumberColumnWidth + delta) : resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
66
67
|
// CASE 2: table will hit editor edge
|
|
67
68
|
editorContainerWidth :
|
|
68
69
|
// CASE 3: table is being resized from a non-overflow state
|
|
69
|
-
resizeState.maxSize + delta);
|
|
70
|
+
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + delta : resizeState.maxSize + delta);
|
|
70
71
|
|
|
71
72
|
// do not apply scaling logic because resize state is already scaled
|
|
72
73
|
updateColgroup(newState, tableRef, tableNode, false, false);
|
|
73
|
-
|
|
74
|
-
updateTablePreview(tableRef, newState.maxSize, shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
75
|
-
}
|
|
74
|
+
updateTablePreview(tableRef, newState.maxSize, shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
76
75
|
return newState;
|
|
77
76
|
};
|
|
78
77
|
var updateTablePreview = function updateTablePreview(tableRef, newTableWidth, shouldChangeAlignment) {
|
|
@@ -100,37 +99,52 @@ export var scaleResizeState = function scaleResizeState(_ref2) {
|
|
|
100
99
|
tableRef = _ref2.tableRef,
|
|
101
100
|
tableNode = _ref2.tableNode,
|
|
102
101
|
editorWidth = _ref2.editorWidth;
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
103
|
+
var isTableScaled = isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
104
|
+
|
|
105
|
+
// Tables with number column can cause the table to be in two different states:
|
|
106
|
+
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
107
|
+
// avoid scaling and take the document width
|
|
108
|
+
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
109
|
+
// is scaled using preserve table width logic, for this apply a scaled width
|
|
110
|
+
// return early if table isn't scaled
|
|
111
|
+
if (!isTableScaled || isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth) {
|
|
105
112
|
return resizeState;
|
|
106
113
|
}
|
|
107
114
|
var scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
115
|
+
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
108
116
|
var cols = resizeState.cols.map(function (col) {
|
|
109
117
|
return _objectSpread(_objectSpread({}, col), {}, {
|
|
110
|
-
|
|
118
|
+
minWidth: tableCellMinWidth,
|
|
119
|
+
width: Math.max(Math.round(col.width * scalePercent), tableCellMinWidth)
|
|
111
120
|
});
|
|
112
121
|
});
|
|
113
|
-
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
114
122
|
var calculatedTableWidth = cols.reduce(function (prev, curr) {
|
|
115
123
|
return prev + curr.width;
|
|
116
124
|
}, 0);
|
|
117
125
|
|
|
118
126
|
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
119
|
-
// distribute the difference to the
|
|
127
|
+
// distribute the difference to the first column
|
|
120
128
|
if (calculatedTableWidth > scaledTableWidth) {
|
|
121
129
|
var diff = calculatedTableWidth - scaledTableWidth;
|
|
130
|
+
var hasDiffBeenDistributed = false;
|
|
122
131
|
cols = cols.map(function (col) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
133
|
+
hasDiffBeenDistributed = true;
|
|
134
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
135
|
+
width: col.width - diff
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return col;
|
|
126
139
|
});
|
|
127
140
|
}
|
|
141
|
+
var maxSize = isNumberColumnEnabled ? Math.round((resizeState.maxSize + akEditorTableNumberColumnWidth) * scalePercent) : Math.round(resizeState.maxSize * scalePercent);
|
|
128
142
|
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
129
143
|
widths: cols.map(function (col) {
|
|
130
144
|
return col.width;
|
|
131
145
|
}),
|
|
132
146
|
tableWidth: scaledTableWidth,
|
|
133
|
-
maxSize:
|
|
147
|
+
maxSize: maxSize,
|
|
134
148
|
cols: cols
|
|
135
149
|
});
|
|
136
150
|
};
|
|
@@ -231,6 +231,9 @@ export function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
|
|
|
231
231
|
return col;
|
|
232
232
|
});
|
|
233
233
|
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
234
|
+
tableWidth: updatedCols.reduce(function (acc, col) {
|
|
235
|
+
return acc + col.width;
|
|
236
|
+
}, 0),
|
|
234
237
|
cols: updatedCols
|
|
235
238
|
});
|
|
236
239
|
}
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -209,19 +209,22 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
209
209
|
onMouseLeave: clearHoverSelection(),
|
|
210
210
|
selected: false,
|
|
211
211
|
disabled: false
|
|
212
|
-
}, {
|
|
213
|
-
id: 'editor.table.mergeCells',
|
|
214
|
-
title: formatMessage(messages.mergeCells),
|
|
215
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
216
|
-
selected: false,
|
|
217
|
-
disabled: !canMergeCells(editorState.tr)
|
|
218
|
-
}, {
|
|
219
|
-
id: 'editor.table.splitCell',
|
|
220
|
-
title: formatMessage(messages.splitCell),
|
|
221
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
222
|
-
selected: false,
|
|
223
|
-
disabled: !splitCell(editorState)
|
|
224
212
|
}];
|
|
213
|
+
if (pluginState.pluginConfig.allowMergeCells) {
|
|
214
|
+
options.push({
|
|
215
|
+
id: 'editor.table.mergeCells',
|
|
216
|
+
title: formatMessage(messages.mergeCells),
|
|
217
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
218
|
+
selected: false,
|
|
219
|
+
disabled: !canMergeCells(editorState.tr)
|
|
220
|
+
}, {
|
|
221
|
+
id: 'editor.table.splitCell',
|
|
222
|
+
title: formatMessage(messages.splitCell),
|
|
223
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
224
|
+
selected: false,
|
|
225
|
+
disabled: !splitCell(editorState)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
225
228
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
226
229
|
var _newResizeStateWithAn;
|
|
227
230
|
var newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled) : undefined;
|
|
@@ -208,8 +208,9 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
208
208
|
editorView = _this$props3.editorView;
|
|
209
209
|
var _getPluginState3 = getPluginState(editorView.state),
|
|
210
210
|
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
211
|
+
var content = formatMessage(isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn);
|
|
211
212
|
return {
|
|
212
|
-
content:
|
|
213
|
+
content: content,
|
|
213
214
|
value: {
|
|
214
215
|
name: 'insert_column'
|
|
215
216
|
},
|
|
@@ -221,7 +222,8 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
221
222
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
222
223
|
jsx("span", {
|
|
223
224
|
css: elementBeforeIconStyles
|
|
224
|
-
}, jsx(AddColRightIcon, null)) : undefined
|
|
225
|
+
}, jsx(AddColRightIcon, null)) : undefined,
|
|
226
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(addColumnAfter, String(content)) : undefined
|
|
225
227
|
};
|
|
226
228
|
});
|
|
227
229
|
_defineProperty(_assertThisInitialized(_this), "createInsertRowItem", function () {
|
|
@@ -230,8 +232,9 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
230
232
|
editorView = _this$props4.editorView;
|
|
231
233
|
var _getPluginState4 = getPluginState(editorView.state),
|
|
232
234
|
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
|
|
235
|
+
var content = formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow);
|
|
233
236
|
return {
|
|
234
|
-
content:
|
|
237
|
+
content: content,
|
|
235
238
|
value: {
|
|
236
239
|
name: 'insert_row'
|
|
237
240
|
},
|
|
@@ -243,7 +246,8 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
243
246
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
244
247
|
jsx("span", {
|
|
245
248
|
css: elementBeforeIconStyles
|
|
246
|
-
}, jsx(AddRowBelowIcon, null)) : undefined
|
|
249
|
+
}, jsx(AddRowBelowIcon, null)) : undefined,
|
|
250
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(addRowAfter, String(content)) : undefined
|
|
247
251
|
};
|
|
248
252
|
});
|
|
249
253
|
_defineProperty(_assertThisInitialized(_this), "createClearCellsItem", function () {
|
|
@@ -259,10 +263,11 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
259
263
|
left = selectionRect.left;
|
|
260
264
|
var noOfColumns = right - left;
|
|
261
265
|
var noOfRows = bottom - top;
|
|
266
|
+
var content = formatMessage(messages.clearCells, {
|
|
267
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
268
|
+
});
|
|
262
269
|
return {
|
|
263
|
-
content:
|
|
264
|
-
0: Math.max(noOfColumns, noOfRows)
|
|
265
|
-
}),
|
|
270
|
+
content: content,
|
|
266
271
|
value: {
|
|
267
272
|
name: 'clear'
|
|
268
273
|
},
|
|
@@ -278,7 +283,8 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
278
283
|
label: formatMessage(messages.clearCells, {
|
|
279
284
|
0: Math.max(noOfColumns, noOfRows)
|
|
280
285
|
})
|
|
281
|
-
})) : undefined
|
|
286
|
+
})) : undefined,
|
|
287
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys') ? tooltip(backspace, String(content)) : undefined
|
|
282
288
|
};
|
|
283
289
|
});
|
|
284
290
|
_defineProperty(_assertThisInitialized(_this), "createDeleteColumnItem", function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.24.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/adf-schema": "^40.3.0",
|
|
32
32
|
"@atlaskit/button": "^19.1.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.6.0",
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^87.0.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.6.0",
|
|
@@ -105,9 +105,6 @@
|
|
|
105
105
|
"platform_editor_lazy-node-views": {
|
|
106
106
|
"type": "boolean"
|
|
107
107
|
},
|
|
108
|
-
"platform.editor.transform-slice-for-nested-expand": {
|
|
109
|
-
"type": "boolean"
|
|
110
|
-
},
|
|
111
108
|
"platform.editor.table.use-shared-state-hook": {
|
|
112
109
|
"type": "boolean"
|
|
113
110
|
},
|
|
@@ -125,6 +122,9 @@
|
|
|
125
122
|
},
|
|
126
123
|
"platform_editor_a11y_table_context_menu": {
|
|
127
124
|
"type": "boolean"
|
|
125
|
+
},
|
|
126
|
+
"platform_editor_announce_cell_options_hotkeys": {
|
|
127
|
+
"type": "boolean"
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -294,10 +294,7 @@ export const createPlugin = (
|
|
|
294
294
|
slice = transformSliceRemoveCellBackgroundColor(slice, schema);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
if (fg('platform.editor.transform-slice-for-nested-expand')) {
|
|
299
|
-
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
300
|
-
}
|
|
297
|
+
slice = transformSliceToRemoveOpenNestedExpand(slice, schema);
|
|
301
298
|
|
|
302
299
|
return slice;
|
|
303
300
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Resize a given column by an amount from the current state
|
|
2
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
3
|
import { type EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import {
|
|
5
6
|
akEditorFullWidthLayoutWidth,
|
|
6
7
|
akEditorGutterPaddingDynamic,
|
|
8
|
+
akEditorTableNumberColumnWidth,
|
|
7
9
|
} from '@atlaskit/editor-shared-styles';
|
|
8
10
|
|
|
9
11
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
@@ -86,12 +88,13 @@ export const resizeColumnAndTable = ({
|
|
|
86
88
|
}: ResizeColumnAndTable): ResizeState => {
|
|
87
89
|
const editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
88
90
|
const isTableLeftAligned = tableNode.attrs.layout === ALIGN_START;
|
|
91
|
+
const isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
92
|
+
const isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
89
93
|
let resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
90
|
-
|
|
91
94
|
const willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
92
95
|
|
|
93
96
|
const willResizedTableStayInOverflow =
|
|
94
|
-
|
|
97
|
+
isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
95
98
|
|
|
96
99
|
// STEP 1: Update col width
|
|
97
100
|
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
@@ -100,54 +103,58 @@ export const resizeColumnAndTable = ({
|
|
|
100
103
|
amount < 0
|
|
101
104
|
? amount
|
|
102
105
|
: resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth!) / 2;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!willResizedTableStayInOverflow && !willTableHitEditorEdge) {
|
|
106
|
+
} else {
|
|
106
107
|
const diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
107
108
|
const rest = amount - diff;
|
|
108
109
|
const final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
109
110
|
resizeAmount = final;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
const newState = updateAffectedColumn(resizeState, colIndex, resizeAmount);
|
|
113
114
|
|
|
114
115
|
// STEP 2: Update table container width
|
|
115
116
|
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
116
117
|
const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
117
118
|
|
|
118
119
|
newState.maxSize = Math.round(
|
|
119
|
-
|
|
120
|
+
isOverflow
|
|
120
121
|
? willResizedTableStayInOverflow
|
|
121
122
|
? // CASE 1A: table will stay in overflow
|
|
122
123
|
// do not grow the table because resize is happening in the overflow region
|
|
123
124
|
// and the overall table container needs to be retained
|
|
124
|
-
|
|
125
|
+
isNumberColumnEnabled
|
|
126
|
+
? resizeState.maxSize + akEditorTableNumberColumnWidth
|
|
127
|
+
: resizeState.maxSize
|
|
125
128
|
: // CASE 1B: table will no longer be in overflow, so adjust container width
|
|
126
129
|
// ensure the table is resized without any 'big jumps' by working out
|
|
127
130
|
// the difference between the new table width and the max size and adding the resize
|
|
128
|
-
|
|
131
|
+
isNumberColumnEnabled
|
|
132
|
+
? resizeState.maxSize +
|
|
133
|
+
akEditorTableNumberColumnWidth +
|
|
134
|
+
(resizeState.tableWidth - resizeState.maxSize + akEditorTableNumberColumnWidth + delta)
|
|
135
|
+
: resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta)
|
|
129
136
|
: willTableHitEditorEdge
|
|
130
137
|
? // CASE 2: table will hit editor edge
|
|
131
138
|
editorContainerWidth
|
|
132
139
|
: // CASE 3: table is being resized from a non-overflow state
|
|
133
|
-
|
|
140
|
+
isNumberColumnEnabled
|
|
141
|
+
? resizeState.maxSize + akEditorTableNumberColumnWidth + delta
|
|
142
|
+
: resizeState.maxSize + delta,
|
|
134
143
|
);
|
|
135
144
|
|
|
136
145
|
// do not apply scaling logic because resize state is already scaled
|
|
137
146
|
updateColgroup(newState, tableRef, tableNode, false, false);
|
|
138
147
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
updateTablePreview(
|
|
149
|
+
tableRef,
|
|
150
|
+
newState.maxSize,
|
|
151
|
+
shouldChangeAlignmentToCenterResized(
|
|
152
|
+
isTableAlignmentEnabled,
|
|
153
|
+
tableNode,
|
|
154
|
+
lineLength,
|
|
142
155
|
newState.maxSize,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
tableNode,
|
|
146
|
-
lineLength,
|
|
147
|
-
newState.maxSize,
|
|
148
|
-
),
|
|
149
|
-
);
|
|
150
|
-
}
|
|
156
|
+
),
|
|
157
|
+
);
|
|
151
158
|
|
|
152
159
|
return newState;
|
|
153
160
|
};
|
|
@@ -184,34 +191,55 @@ export const scaleResizeState = ({
|
|
|
184
191
|
tableNode,
|
|
185
192
|
editorWidth,
|
|
186
193
|
}: TableReferences & { resizeState: ResizeState; editorWidth: number }): ResizeState => {
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
const isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
195
|
+
const isTableScaled =
|
|
196
|
+
isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
197
|
+
|
|
198
|
+
// Tables with number column can cause the table to be in two different states:
|
|
199
|
+
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
200
|
+
// avoid scaling and take the document width
|
|
201
|
+
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
202
|
+
// is scaled using preserve table width logic, for this apply a scaled width
|
|
203
|
+
// return early if table isn't scaled
|
|
204
|
+
if (!isTableScaled || (isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth)) {
|
|
189
205
|
return resizeState;
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
const scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
193
|
-
let cols = resizeState.cols.map((col) => ({
|
|
194
|
-
...col,
|
|
195
|
-
width: Math.round(Math.max(col.width * scalePercent, col.minWidth)),
|
|
196
|
-
}));
|
|
197
|
-
|
|
198
209
|
const scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
210
|
+
let cols = resizeState.cols.map((col) => {
|
|
211
|
+
return {
|
|
212
|
+
...col,
|
|
213
|
+
minWidth: tableCellMinWidth,
|
|
214
|
+
width: Math.max(Math.round(col.width * scalePercent), tableCellMinWidth),
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
|
|
199
218
|
const calculatedTableWidth = cols.reduce((prev, curr) => prev + curr.width, 0);
|
|
200
219
|
|
|
201
220
|
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
202
|
-
// distribute the difference to the
|
|
221
|
+
// distribute the difference to the first column
|
|
203
222
|
if (calculatedTableWidth > scaledTableWidth) {
|
|
204
223
|
const diff = calculatedTableWidth - scaledTableWidth;
|
|
224
|
+
let hasDiffBeenDistributed = false;
|
|
205
225
|
cols = cols.map((col) => {
|
|
206
|
-
|
|
226
|
+
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
227
|
+
hasDiffBeenDistributed = true;
|
|
228
|
+
return { ...col, width: col.width - diff };
|
|
229
|
+
}
|
|
230
|
+
return col;
|
|
207
231
|
});
|
|
208
232
|
}
|
|
209
233
|
|
|
234
|
+
const maxSize = isNumberColumnEnabled
|
|
235
|
+
? Math.round((resizeState.maxSize + akEditorTableNumberColumnWidth) * scalePercent)
|
|
236
|
+
: Math.round(resizeState.maxSize * scalePercent);
|
|
237
|
+
|
|
210
238
|
return {
|
|
211
239
|
...resizeState,
|
|
212
240
|
widths: cols.map((col) => col.width),
|
|
213
241
|
tableWidth: scaledTableWidth,
|
|
214
|
-
maxSize
|
|
242
|
+
maxSize,
|
|
215
243
|
cols,
|
|
216
244
|
};
|
|
217
245
|
};
|
package/src/toolbar.tsx
CHANGED
|
@@ -292,22 +292,27 @@ export const getToolbarCellOptionsConfig = (
|
|
|
292
292
|
selected: false,
|
|
293
293
|
disabled: false,
|
|
294
294
|
},
|
|
295
|
-
{
|
|
296
|
-
id: 'editor.table.mergeCells',
|
|
297
|
-
title: formatMessage(messages.mergeCells),
|
|
298
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
299
|
-
selected: false,
|
|
300
|
-
disabled: !canMergeCells(editorState.tr),
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
id: 'editor.table.splitCell',
|
|
304
|
-
title: formatMessage(messages.splitCell),
|
|
305
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
306
|
-
selected: false,
|
|
307
|
-
disabled: !splitCell(editorState),
|
|
308
|
-
},
|
|
309
295
|
];
|
|
310
296
|
|
|
297
|
+
if (pluginState.pluginConfig.allowMergeCells) {
|
|
298
|
+
options.push(
|
|
299
|
+
{
|
|
300
|
+
id: 'editor.table.mergeCells',
|
|
301
|
+
title: formatMessage(messages.mergeCells),
|
|
302
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
303
|
+
selected: false,
|
|
304
|
+
disabled: !canMergeCells(editorState.tr),
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: 'editor.table.splitCell',
|
|
308
|
+
title: formatMessage(messages.splitCell),
|
|
309
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
310
|
+
selected: false,
|
|
311
|
+
disabled: !splitCell(editorState),
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
311
316
|
if (pluginState?.pluginConfig?.allowDistributeColumns) {
|
|
312
317
|
const newResizeStateWithAnalytics = editorView
|
|
313
318
|
? getNewResizeStateFromSelectedColumns(
|
|
@@ -370,11 +370,12 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
370
370
|
editorView,
|
|
371
371
|
} = this.props;
|
|
372
372
|
const { isDragAndDropEnabled } = getPluginState(editorView.state);
|
|
373
|
+
const content = formatMessage(
|
|
374
|
+
isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn,
|
|
375
|
+
);
|
|
373
376
|
|
|
374
377
|
return {
|
|
375
|
-
content
|
|
376
|
-
isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn,
|
|
377
|
-
),
|
|
378
|
+
content,
|
|
378
379
|
value: { name: 'insert_column' },
|
|
379
380
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
380
381
|
elemAfter: <div css={shortcutStyle}>{tooltip(addColumnAfter)}</div>,
|
|
@@ -384,6 +385,9 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
384
385
|
<AddColRightIcon />
|
|
385
386
|
</span>
|
|
386
387
|
) : undefined,
|
|
388
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys')
|
|
389
|
+
? tooltip(addColumnAfter, String(content))
|
|
390
|
+
: undefined,
|
|
387
391
|
} as MenuItem;
|
|
388
392
|
};
|
|
389
393
|
|
|
@@ -393,9 +397,10 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
393
397
|
editorView,
|
|
394
398
|
} = this.props;
|
|
395
399
|
const { isDragAndDropEnabled } = getPluginState(editorView.state);
|
|
400
|
+
const content = formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow);
|
|
396
401
|
|
|
397
402
|
return {
|
|
398
|
-
content
|
|
403
|
+
content,
|
|
399
404
|
value: { name: 'insert_row' },
|
|
400
405
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
401
406
|
elemAfter: <div css={shortcutStyle}>{tooltip(addRowAfter)}</div>,
|
|
@@ -405,6 +410,9 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
405
410
|
<AddRowBelowIcon />
|
|
406
411
|
</span>
|
|
407
412
|
) : undefined,
|
|
413
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys')
|
|
414
|
+
? tooltip(addRowAfter, String(content))
|
|
415
|
+
: undefined,
|
|
408
416
|
} as MenuItem;
|
|
409
417
|
};
|
|
410
418
|
|
|
@@ -419,10 +427,12 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
419
427
|
const noOfColumns = right - left;
|
|
420
428
|
const noOfRows = bottom - top;
|
|
421
429
|
|
|
430
|
+
const content = formatMessage(messages.clearCells, {
|
|
431
|
+
0: Math.max(noOfColumns, noOfRows),
|
|
432
|
+
});
|
|
433
|
+
|
|
422
434
|
return {
|
|
423
|
-
content
|
|
424
|
-
0: Math.max(noOfColumns, noOfRows),
|
|
425
|
-
}),
|
|
435
|
+
content,
|
|
426
436
|
value: { name: 'clear' },
|
|
427
437
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
428
438
|
elemAfter: <div css={shortcutStyle}>{tooltip(backspace)}</div>,
|
|
@@ -436,6 +446,9 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
436
446
|
/>
|
|
437
447
|
</span>
|
|
438
448
|
) : undefined,
|
|
449
|
+
'aria-label': fg('platform_editor_announce_cell_options_hotkeys')
|
|
450
|
+
? tooltip(backspace, String(content))
|
|
451
|
+
: undefined,
|
|
439
452
|
} as MenuItem;
|
|
440
453
|
};
|
|
441
454
|
|