@atlaskit/editor-plugin-table 7.13.0 → 7.13.1
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 +10 -0
- package/dist/cjs/commands/insert.js +6 -4
- package/dist/cjs/commands-with-analytics.js +4 -2
- package/dist/cjs/plugin.js +4 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +11 -7
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +10 -4
- package/dist/cjs/utils/drag-menu.js +3 -2
- package/dist/es2019/commands/insert.js +6 -6
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +7 -3
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
- package/dist/es2019/ui/FloatingInsertButton/index.js +10 -4
- package/dist/es2019/utils/drag-menu.js +3 -3
- package/dist/esm/commands/insert.js +6 -4
- package/dist/esm/commands-with-analytics.js +4 -2
- package/dist/esm/plugin.js +4 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +11 -7
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
- package/dist/esm/ui/FloatingInsertButton/index.js +10 -4
- package/dist/esm/utils/drag-menu.js +3 -2
- package/dist/types/commands/insert.d.ts +3 -3
- package/dist/types/commands-with-analytics.d.ts +2 -2
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +3 -3
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +1 -1
- package/src/commands/insert.ts +16 -6
- package/src/commands-with-analytics.ts +13 -3
- package/src/plugin.tsx +8 -0
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +21 -8
- package/src/ui/FloatingContextualMenu/index.tsx +2 -0
- package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -0
- package/src/ui/FloatingDragMenu/index.tsx +11 -1
- package/src/ui/FloatingInsertButton/index.tsx +38 -11
- package/src/utils/drag-menu.ts +17 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#94829](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94829)
|
|
8
|
+
[`815fda434fe7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/815fda434fe7) -
|
|
9
|
+
[ED-22849] Align add column and row behaviour behind
|
|
10
|
+
platform_editor_table_duplicate_cell_colouring flag so that adding a column will copy cell
|
|
11
|
+
background from the left and adding a row will copy background colour from row above
|
|
12
|
+
|
|
3
13
|
## 7.13.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -30,6 +30,7 @@ function addColumnAtCustomStep(column) {
|
|
|
30
30
|
}
|
|
31
31
|
function addColumnAt() {
|
|
32
32
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
33
|
+
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
33
34
|
return function (column) {
|
|
34
35
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
36
|
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -38,7 +39,7 @@ function addColumnAt() {
|
|
|
38
39
|
if (allowAddColumnCustomStep) {
|
|
39
40
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
40
41
|
} else {
|
|
41
|
-
updatedTr = (0, _utils2.addColumnAt)(column)(updatedTr);
|
|
42
|
+
updatedTr = (0, _utils2.addColumnAt)(column, isCellBackgroundDuplicated)(updatedTr);
|
|
42
43
|
}
|
|
43
44
|
var table = (0, _utils2.findTable)(updatedTr.selection);
|
|
44
45
|
if (table) {
|
|
@@ -92,9 +93,10 @@ var addColumnAfter = exports.addColumnAfter = function addColumnAfter(isTableSca
|
|
|
92
93
|
};
|
|
93
94
|
var insertColumn = exports.insertColumn = function insertColumn() {
|
|
94
95
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
96
|
+
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
95
97
|
return function (column) {
|
|
96
98
|
return function (state, dispatch, view) {
|
|
97
|
-
var tr = addColumnAt(isTableScalingEnabled)(column, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(state), view)(state.tr);
|
|
99
|
+
var tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated)(column, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(state), view)(state.tr);
|
|
98
100
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
99
101
|
if (!table) {
|
|
100
102
|
return false;
|
|
@@ -108,7 +110,7 @@ var insertColumn = exports.insertColumn = function insertColumn() {
|
|
|
108
110
|
};
|
|
109
111
|
};
|
|
110
112
|
};
|
|
111
|
-
var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
113
|
+
var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRow, isCellBackgroundDuplicated) {
|
|
112
114
|
return function (state, dispatch) {
|
|
113
115
|
// Don't clone the header row
|
|
114
116
|
var headerRowEnabled = (0, _utils3.checkIfHeaderRowEnabled)(state.selection);
|
|
@@ -119,7 +121,7 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
|
|
|
119
121
|
if (row === 0 && headerRowEnabled) {
|
|
120
122
|
return false;
|
|
121
123
|
}
|
|
122
|
-
var tr = clonePreviousRow ? (0, _utils3.copyPreviousRow)(state.schema)(row)(state.tr) : (0, _utils2.addRowAt)(row)(state.tr);
|
|
124
|
+
var tr = clonePreviousRow ? (0, _utils3.copyPreviousRow)(state.schema)(row)(state.tr) : (0, _utils2.addRowAt)(row, undefined, isCellBackgroundDuplicated)(state.tr);
|
|
123
125
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
124
126
|
if (!table) {
|
|
125
127
|
return false;
|
|
@@ -172,6 +172,7 @@ var addRowAroundSelection = exports.addRowAroundSelection = function addRowAroun
|
|
|
172
172
|
};
|
|
173
173
|
};
|
|
174
174
|
var insertRowWithAnalytics = exports.insertRowWithAnalytics = function insertRowWithAnalytics(editorAnalyticsAPI) {
|
|
175
|
+
var isCellbackgroundDuplicated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
175
176
|
return function (inputMethod, options) {
|
|
176
177
|
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
177
178
|
var _getSelectedTableInfo = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
@@ -189,7 +190,7 @@ var insertRowWithAnalytics = exports.insertRowWithAnalytics = function insertRow
|
|
|
189
190
|
},
|
|
190
191
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
191
192
|
};
|
|
192
|
-
})(editorAnalyticsAPI)((0, _insert.insertRow)(options.index, options.moveCursorToInsertedRow));
|
|
193
|
+
})(editorAnalyticsAPI)((0, _insert.insertRow)(options.index, options.moveCursorToInsertedRow, isCellbackgroundDuplicated));
|
|
193
194
|
};
|
|
194
195
|
};
|
|
195
196
|
var changeColumnWidthByStepWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = function changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI) {
|
|
@@ -226,6 +227,7 @@ var changeColumnWidthByStepWithAnalytics = exports.changeColumnWidthByStepWithAn
|
|
|
226
227
|
};
|
|
227
228
|
var insertColumnWithAnalytics = exports.insertColumnWithAnalytics = function insertColumnWithAnalytics(editorAnalyticsAPI) {
|
|
228
229
|
var isTableScalingEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
230
|
+
var isCellbackgroundDuplicated = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
229
231
|
return function (inputMethod, position) {
|
|
230
232
|
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
231
233
|
var _getSelectedTableInfo3 = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
@@ -243,7 +245,7 @@ var insertColumnWithAnalytics = exports.insertColumnWithAnalytics = function ins
|
|
|
243
245
|
},
|
|
244
246
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
245
247
|
};
|
|
246
|
-
})(editorAnalyticsAPI)((0, _insert.insertColumn)(isTableScalingEnabled)(position));
|
|
248
|
+
})(editorAnalyticsAPI)((0, _insert.insertColumn)(isTableScalingEnabled, isCellbackgroundDuplicated)(position));
|
|
247
249
|
};
|
|
248
250
|
};
|
|
249
251
|
var deleteRowsWithAnalytics = exports.deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnalyticsAPI) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -368,7 +368,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
368
368
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
369
369
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
370
370
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
371
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
371
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
372
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
372
373
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/_react.default.createElement(_FloatingContextualMenu.default, {
|
|
373
374
|
editorView: editorView,
|
|
374
375
|
mountPoint: popupsMountPoint,
|
|
@@ -393,7 +394,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
393
394
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
394
395
|
stickyHeaders: stickyHeader,
|
|
395
396
|
pluginConfig: pluginConfig,
|
|
396
|
-
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled
|
|
397
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
398
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
397
399
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
398
400
|
editorView: editorView,
|
|
399
401
|
selection: editorView.state.selection,
|
|
@@ -370,7 +370,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
370
370
|
editorView = _this$props10.editorView,
|
|
371
371
|
selectionRect = _this$props10.selectionRect,
|
|
372
372
|
editorAnalyticsAPI = _this$props10.editorAnalyticsAPI,
|
|
373
|
-
getEditorContainerWidth = _this$props10.getEditorContainerWidth
|
|
373
|
+
getEditorContainerWidth = _this$props10.getEditorContainerWidth,
|
|
374
|
+
getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
|
|
374
375
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
375
376
|
var state = editorView.state,
|
|
376
377
|
dispatch = editorView.dispatch;
|
|
@@ -378,6 +379,9 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
378
379
|
targetCellPosition = _getPluginState11.targetCellPosition,
|
|
379
380
|
_getPluginState11$isT = _getPluginState11.isTableScalingEnabled,
|
|
380
381
|
isTableScalingEnabled = _getPluginState11$isT === void 0 ? false : _getPluginState11$isT;
|
|
382
|
+
var _ref2 = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
383
|
+
_ref2$tableDuplicateC = _ref2.tableDuplicateCellColouring,
|
|
384
|
+
tableDuplicateCellColouring = _ref2$tableDuplicateC === void 0 ? false : _ref2$tableDuplicateC;
|
|
381
385
|
switch (item.value.name) {
|
|
382
386
|
case 'sort_column_desc':
|
|
383
387
|
(0, _commandsWithAnalytics.sortColumnWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect.left, _customSteps.TableSortOrder.DESC)(state, dispatch);
|
|
@@ -407,11 +411,11 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
407
411
|
_this.toggleOpen();
|
|
408
412
|
break;
|
|
409
413
|
case 'insert_column':
|
|
410
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
414
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(_analytics.INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
411
415
|
_this.toggleOpen();
|
|
412
416
|
break;
|
|
413
417
|
case 'insert_row':
|
|
414
|
-
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.CONTEXT_MENU, {
|
|
418
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI, tableDuplicateCellColouring)(_analytics.INPUT_METHOD.CONTEXT_MENU, {
|
|
415
419
|
index: selectionRect.bottom,
|
|
416
420
|
moveCursorToInsertedRow: true
|
|
417
421
|
})(state, dispatch);
|
|
@@ -451,8 +455,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
451
455
|
isSubmenuOpen: false
|
|
452
456
|
});
|
|
453
457
|
});
|
|
454
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleItemMouseEnter", function (
|
|
455
|
-
var item =
|
|
458
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleItemMouseEnter", function (_ref3) {
|
|
459
|
+
var item = _ref3.item;
|
|
456
460
|
var _this$props12 = _this.props,
|
|
457
461
|
_this$props12$editorV = _this$props12.editorView,
|
|
458
462
|
state = _this$props12$editorV.state,
|
|
@@ -475,8 +479,8 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
475
479
|
(0, _commands.hoverMergedCells)()(state, dispatch);
|
|
476
480
|
}
|
|
477
481
|
});
|
|
478
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleItemMouseLeave", function (
|
|
479
|
-
var item =
|
|
482
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleItemMouseLeave", function (_ref4) {
|
|
483
|
+
var item = _ref4.item;
|
|
480
484
|
var _this$props$editorVie2 = _this.props.editorView,
|
|
481
485
|
state = _this$props$editorVie2.state,
|
|
482
486
|
dispatch = _this$props$editorVie2.dispatch;
|
|
@@ -24,7 +24,8 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
24
24
|
isOpen = _ref.isOpen,
|
|
25
25
|
pluginConfig = _ref.pluginConfig,
|
|
26
26
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
27
|
-
getEditorContainerWidth = _ref.getEditorContainerWidth
|
|
27
|
+
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
28
|
+
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
28
29
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
29
30
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
30
31
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
@@ -72,7 +73,8 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
72
73
|
selectionRect: selectionRect,
|
|
73
74
|
boundariesElement: boundariesElement,
|
|
74
75
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
75
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
76
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
77
|
+
getEditorFeatureFlags: getEditorFeatureFlags
|
|
76
78
|
})));
|
|
77
79
|
};
|
|
78
80
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -191,7 +191,8 @@ var DragMenu = exports.DragMenu = /*#__PURE__*/_react.default.memo(function (_re
|
|
|
191
191
|
mountPoint = _ref.mountPoint,
|
|
192
192
|
scrollableElement = _ref.scrollableElement,
|
|
193
193
|
boundariesElement = _ref.boundariesElement,
|
|
194
|
-
isTableScalingEnabled = _ref.isTableScalingEnabled
|
|
194
|
+
isTableScalingEnabled = _ref.isTableScalingEnabled,
|
|
195
|
+
tableDuplicateCellColouring = _ref.tableDuplicateCellColouring;
|
|
195
196
|
var state = editorView.state,
|
|
196
197
|
dispatch = editorView.dispatch;
|
|
197
198
|
var selection = state.selection;
|
|
@@ -215,7 +216,7 @@ var DragMenu = exports.DragMenu = /*#__PURE__*/_react.default.memo(function (_re
|
|
|
215
216
|
hasMergedCellsInTable = (0, _utils3.getMergedCellsPositions)(state.tr).length > 0;
|
|
216
217
|
}
|
|
217
218
|
var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
218
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
|
|
219
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring);
|
|
219
220
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
|
|
220
221
|
menuItems = _convertToDropdownIte.menuItems,
|
|
221
222
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -25,7 +25,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
25
25
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
26
26
|
stickyHeaders = _ref.stickyHeaders,
|
|
27
27
|
pluginConfig = _ref.pluginConfig,
|
|
28
|
-
isTableScalingEnabled = _ref.isTableScalingEnabled
|
|
28
|
+
isTableScalingEnabled = _ref.isTableScalingEnabled,
|
|
29
|
+
getEditorFeatureFlags = _ref.getEditorFeatureFlags;
|
|
29
30
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
@@ -35,6 +36,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
35
36
|
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
39
|
+
var _ref2 = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
40
|
+
_ref2$tableDuplicateC = _ref2.tableDuplicateCellColouring,
|
|
41
|
+
tableDuplicateCellColouring = _ref2$tableDuplicateC === void 0 ? false : _ref2$tableDuplicateC;
|
|
38
42
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
39
43
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
40
44
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -68,7 +72,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
68
72
|
mountPoint: mountPoint,
|
|
69
73
|
boundariesElement: boundariesElement,
|
|
70
74
|
scrollableElement: scrollableElement,
|
|
71
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
75
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
76
|
+
tableDuplicateCellColouring: tableDuplicateCellColouring
|
|
72
77
|
}));
|
|
73
78
|
};
|
|
74
79
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -179,12 +179,14 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
179
179
|
var _this$props3 = this.props,
|
|
180
180
|
editorView = _this$props3.editorView,
|
|
181
181
|
insertRowButtonIndex = _this$props3.insertRowButtonIndex,
|
|
182
|
-
editorAnalyticsAPI = _this$props3.editorAnalyticsAPI
|
|
182
|
+
editorAnalyticsAPI = _this$props3.editorAnalyticsAPI,
|
|
183
|
+
getEditorFeatureFlags = _this$props3.getEditorFeatureFlags;
|
|
183
184
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
184
185
|
event.preventDefault();
|
|
185
186
|
var state = editorView.state,
|
|
186
187
|
dispatch = editorView.dispatch;
|
|
187
|
-
|
|
188
|
+
var featureFlags = !!getEditorFeatureFlags && getEditorFeatureFlags();
|
|
189
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI, featureFlags && featureFlags.tableDuplicateCellColouring)(_analytics.INPUT_METHOD.BUTTON, {
|
|
188
190
|
index: insertRowButtonIndex,
|
|
189
191
|
moveCursorToInsertedRow: true
|
|
190
192
|
})(state, dispatch);
|
|
@@ -196,15 +198,19 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
|
|
|
196
198
|
var _this$props4 = this.props,
|
|
197
199
|
editorView = _this$props4.editorView,
|
|
198
200
|
insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
|
|
199
|
-
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI
|
|
201
|
+
editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
|
|
202
|
+
getEditorFeatureFlags = _this$props4.getEditorFeatureFlags;
|
|
200
203
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
201
204
|
event.preventDefault();
|
|
202
205
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
203
206
|
_getPluginState$isTab = _getPluginState.isTableScalingEnabled,
|
|
204
207
|
isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
|
|
208
|
+
var _ref = getEditorFeatureFlags ? getEditorFeatureFlags() : {},
|
|
209
|
+
_ref$tableDuplicateCe = _ref.tableDuplicateCellColouring,
|
|
210
|
+
tableDuplicateCellColouring = _ref$tableDuplicateCe === void 0 ? false : _ref$tableDuplicateCe;
|
|
205
211
|
var state = editorView.state,
|
|
206
212
|
dispatch = editorView.dispatch;
|
|
207
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
213
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
216
|
}]);
|
|
@@ -78,6 +78,7 @@ var defaultSelectionRect = {
|
|
|
78
78
|
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) {
|
|
79
79
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
80
80
|
var isTableScalingEnabled = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : false;
|
|
81
|
+
var tableDuplicateCellColouring = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : false;
|
|
81
82
|
var addOptions = direction === 'row' ? [{
|
|
82
83
|
label: 'above',
|
|
83
84
|
offset: 0,
|
|
@@ -157,12 +158,12 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
157
158
|
icon: icon,
|
|
158
159
|
onClick: function onClick(state, dispatch) {
|
|
159
160
|
if (direction === 'row') {
|
|
160
|
-
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
161
|
+
(0, _commandsWithAnalytics.insertRowWithAnalytics)(editorAnalyticsAPI, tableDuplicateCellColouring)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
161
162
|
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
162
163
|
moveCursorToInsertedRow: true
|
|
163
164
|
})(state, dispatch);
|
|
164
165
|
} else {
|
|
165
|
-
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
166
|
+
(0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
166
167
|
}
|
|
167
168
|
return true;
|
|
168
169
|
},
|
|
@@ -19,14 +19,14 @@ function addColumnAtCustomStep(column) {
|
|
|
19
19
|
return tr;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export function addColumnAt(isTableScalingEnabled = false) {
|
|
22
|
+
export function addColumnAt(isTableScalingEnabled = false, isCellBackgroundDuplicated) {
|
|
23
23
|
return (column, allowAddColumnCustomStep = false, view) => {
|
|
24
24
|
return tr => {
|
|
25
25
|
let updatedTr = tr;
|
|
26
26
|
if (allowAddColumnCustomStep) {
|
|
27
27
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
28
28
|
} else {
|
|
29
|
-
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
29
|
+
updatedTr = addColumnAtPMUtils(column, isCellBackgroundDuplicated)(updatedTr);
|
|
30
30
|
}
|
|
31
31
|
const table = findTable(updatedTr.selection);
|
|
32
32
|
if (table) {
|
|
@@ -73,8 +73,8 @@ export const addColumnAfter = isTableScalingEnabled => (state, dispatch, view) =
|
|
|
73
73
|
}
|
|
74
74
|
return true;
|
|
75
75
|
};
|
|
76
|
-
export const insertColumn = (isTableScalingEnabled = false) => column => (state, dispatch, view) => {
|
|
77
|
-
let tr = addColumnAt(isTableScalingEnabled)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
76
|
+
export const insertColumn = (isTableScalingEnabled = false, isCellBackgroundDuplicated) => column => (state, dispatch, view) => {
|
|
77
|
+
let tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
78
78
|
const table = findTable(tr.selection);
|
|
79
79
|
if (!table) {
|
|
80
80
|
return false;
|
|
@@ -86,7 +86,7 @@ export const insertColumn = (isTableScalingEnabled = false) => column => (state,
|
|
|
86
86
|
}
|
|
87
87
|
return true;
|
|
88
88
|
};
|
|
89
|
-
export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
89
|
+
export const insertRow = (row, moveCursorToTheNewRow, isCellBackgroundDuplicated) => (state, dispatch) => {
|
|
90
90
|
// Don't clone the header row
|
|
91
91
|
const headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
92
92
|
const clonePreviousRow = headerRowEnabled && row > 1 || !headerRowEnabled && row > 0;
|
|
@@ -96,7 +96,7 @@ export const insertRow = (row, moveCursorToTheNewRow) => (state, dispatch) => {
|
|
|
96
96
|
if (row === 0 && headerRowEnabled) {
|
|
97
97
|
return false;
|
|
98
98
|
}
|
|
99
|
-
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row)(state.tr);
|
|
99
|
+
const tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row, undefined, isCellBackgroundDuplicated)(state.tr);
|
|
100
100
|
const table = findTable(tr.selection);
|
|
101
101
|
if (!table) {
|
|
102
102
|
return false;
|
|
@@ -152,7 +152,7 @@ export const addRowAroundSelection = editorAnalyticsAPI => side => (state, dispa
|
|
|
152
152
|
moveCursorToInsertedRow: false
|
|
153
153
|
})(state, dispatch);
|
|
154
154
|
};
|
|
155
|
-
export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, options) => withEditorAnalyticsAPI(state => {
|
|
155
|
+
export const insertRowWithAnalytics = (editorAnalyticsAPI, isCellbackgroundDuplicated = false) => (inputMethod, options) => withEditorAnalyticsAPI(state => {
|
|
156
156
|
const {
|
|
157
157
|
totalRowCount,
|
|
158
158
|
totalColumnCount
|
|
@@ -169,7 +169,7 @@ export const insertRowWithAnalytics = editorAnalyticsAPI => (inputMethod, option
|
|
|
169
169
|
},
|
|
170
170
|
eventType: EVENT_TYPE.TRACK
|
|
171
171
|
};
|
|
172
|
-
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow));
|
|
172
|
+
})(editorAnalyticsAPI)(insertRow(options.index, options.moveCursorToInsertedRow, isCellbackgroundDuplicated));
|
|
173
173
|
export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepSize, getEditorContainerWidth, isTableScalingEnabled, inputMethod, ariaNotify, getIntl) => withEditorAnalyticsAPI(state => {
|
|
174
174
|
const {
|
|
175
175
|
table,
|
|
@@ -202,7 +202,7 @@ export const changeColumnWidthByStepWithAnalytics = editorAnalyticsAPI => (stepS
|
|
|
202
202
|
ariaNotify: ariaNotify,
|
|
203
203
|
getIntl: getIntl
|
|
204
204
|
}));
|
|
205
|
-
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
205
|
+
export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnabled = false, isCellbackgroundDuplicated = false) => (inputMethod, position) => withEditorAnalyticsAPI(state => {
|
|
206
206
|
const {
|
|
207
207
|
totalRowCount,
|
|
208
208
|
totalColumnCount
|
|
@@ -219,7 +219,7 @@ export const insertColumnWithAnalytics = (editorAnalyticsAPI, isTableScalingEnab
|
|
|
219
219
|
},
|
|
220
220
|
eventType: EVENT_TYPE.TRACK
|
|
221
221
|
};
|
|
222
|
-
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled)(position));
|
|
222
|
+
})(editorAnalyticsAPI)(insertColumn(isTableScalingEnabled, isCellbackgroundDuplicated)(position));
|
|
223
223
|
export const deleteRowsWithAnalytics = editorAnalyticsAPI => (inputMethod, rect, isHeaderRowRequired) => withEditorAnalyticsAPI(({
|
|
224
224
|
selection
|
|
225
225
|
}) => {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -364,7 +364,8 @@ const tablesPlugin = ({
|
|
|
364
364
|
hasStickyHeaders: stickyHeader && stickyHeader.sticky,
|
|
365
365
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
366
366
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
367
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
367
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
368
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
368
369
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
369
370
|
editorView: editorView,
|
|
370
371
|
mountPoint: popupsMountPoint,
|
|
@@ -389,7 +390,8 @@ const tablesPlugin = ({
|
|
|
389
390
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
390
391
|
stickyHeaders: stickyHeader,
|
|
391
392
|
pluginConfig: pluginConfig,
|
|
392
|
-
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled
|
|
393
|
+
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
394
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
393
395
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
394
396
|
editorView: editorView,
|
|
395
397
|
selection: editorView.state.selection,
|
|
@@ -399,7 +399,8 @@ export class ContextualMenu extends Component {
|
|
|
399
399
|
editorView,
|
|
400
400
|
selectionRect,
|
|
401
401
|
editorAnalyticsAPI,
|
|
402
|
-
getEditorContainerWidth
|
|
402
|
+
getEditorContainerWidth,
|
|
403
|
+
getEditorFeatureFlags
|
|
403
404
|
} = this.props;
|
|
404
405
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
405
406
|
const {
|
|
@@ -410,6 +411,9 @@ export class ContextualMenu extends Component {
|
|
|
410
411
|
targetCellPosition,
|
|
411
412
|
isTableScalingEnabled = false
|
|
412
413
|
} = getPluginState(state);
|
|
414
|
+
const {
|
|
415
|
+
tableDuplicateCellColouring = false
|
|
416
|
+
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
413
417
|
switch (item.value.name) {
|
|
414
418
|
case 'sort_column_desc':
|
|
415
419
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -439,11 +443,11 @@ export class ContextualMenu extends Component {
|
|
|
439
443
|
this.toggleOpen();
|
|
440
444
|
break;
|
|
441
445
|
case 'insert_column':
|
|
442
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
446
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
443
447
|
this.toggleOpen();
|
|
444
448
|
break;
|
|
445
449
|
case 'insert_row':
|
|
446
|
-
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, {
|
|
450
|
+
insertRowWithAnalytics(editorAnalyticsAPI, tableDuplicateCellColouring)(INPUT_METHOD.CONTEXT_MENU, {
|
|
447
451
|
index: selectionRect.bottom,
|
|
448
452
|
moveCursorToInsertedRow: true
|
|
449
453
|
})(state, dispatch);
|
|
@@ -16,7 +16,8 @@ const FloatingContextualMenu = ({
|
|
|
16
16
|
isOpen,
|
|
17
17
|
pluginConfig,
|
|
18
18
|
editorAnalyticsAPI,
|
|
19
|
-
getEditorContainerWidth
|
|
19
|
+
getEditorContainerWidth,
|
|
20
|
+
getEditorFeatureFlags
|
|
20
21
|
}) => {
|
|
21
22
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
22
23
|
const {
|
|
@@ -68,7 +69,8 @@ const FloatingContextualMenu = ({
|
|
|
68
69
|
selectionRect: selectionRect,
|
|
69
70
|
boundariesElement: boundariesElement,
|
|
70
71
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
71
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
72
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
73
|
+
getEditorFeatureFlags: getEditorFeatureFlags
|
|
72
74
|
})));
|
|
73
75
|
};
|
|
74
76
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -176,7 +176,8 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
176
176
|
mountPoint,
|
|
177
177
|
scrollableElement,
|
|
178
178
|
boundariesElement,
|
|
179
|
-
isTableScalingEnabled
|
|
179
|
+
isTableScalingEnabled,
|
|
180
|
+
tableDuplicateCellColouring
|
|
180
181
|
}) => {
|
|
181
182
|
var _pluginConfig$allowBa;
|
|
182
183
|
const {
|
|
@@ -204,7 +205,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
204
205
|
hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
205
206
|
}
|
|
206
207
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
207
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
|
|
208
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring);
|
|
208
209
|
const {
|
|
209
210
|
menuItems,
|
|
210
211
|
menuCallback
|
|
@@ -18,7 +18,8 @@ const FloatingDragMenu = ({
|
|
|
18
18
|
editorAnalyticsAPI,
|
|
19
19
|
stickyHeaders,
|
|
20
20
|
pluginConfig,
|
|
21
|
-
isTableScalingEnabled
|
|
21
|
+
isTableScalingEnabled,
|
|
22
|
+
getEditorFeatureFlags
|
|
22
23
|
}) => {
|
|
23
24
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
24
25
|
return null;
|
|
@@ -29,6 +30,9 @@ const FloatingDragMenu = ({
|
|
|
29
30
|
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
33
|
+
const {
|
|
34
|
+
tableDuplicateCellColouring = false
|
|
35
|
+
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
32
36
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
33
37
|
alignX: direction === 'row' ? 'right' : undefined,
|
|
34
38
|
alignY: direction === 'row' ? 'start' : undefined,
|
|
@@ -62,7 +66,8 @@ const FloatingDragMenu = ({
|
|
|
62
66
|
mountPoint: mountPoint,
|
|
63
67
|
boundariesElement: boundariesElement,
|
|
64
68
|
scrollableElement: scrollableElement,
|
|
65
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
69
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
70
|
+
tableDuplicateCellColouring: tableDuplicateCellColouring
|
|
66
71
|
}));
|
|
67
72
|
};
|
|
68
73
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -156,7 +156,8 @@ export class FloatingInsertButton extends React.Component {
|
|
|
156
156
|
const {
|
|
157
157
|
editorView,
|
|
158
158
|
insertRowButtonIndex,
|
|
159
|
-
editorAnalyticsAPI
|
|
159
|
+
editorAnalyticsAPI,
|
|
160
|
+
getEditorFeatureFlags
|
|
160
161
|
} = this.props;
|
|
161
162
|
if (typeof insertRowButtonIndex !== 'undefined') {
|
|
162
163
|
event.preventDefault();
|
|
@@ -164,7 +165,8 @@ export class FloatingInsertButton extends React.Component {
|
|
|
164
165
|
state,
|
|
165
166
|
dispatch
|
|
166
167
|
} = editorView;
|
|
167
|
-
|
|
168
|
+
const featureFlags = !!getEditorFeatureFlags && getEditorFeatureFlags();
|
|
169
|
+
insertRowWithAnalytics(editorAnalyticsAPI, featureFlags && featureFlags.tableDuplicateCellColouring)(INPUT_METHOD.BUTTON, {
|
|
168
170
|
index: insertRowButtonIndex,
|
|
169
171
|
moveCursorToInsertedRow: true
|
|
170
172
|
})(state, dispatch);
|
|
@@ -174,18 +176,22 @@ export class FloatingInsertButton extends React.Component {
|
|
|
174
176
|
const {
|
|
175
177
|
editorView,
|
|
176
178
|
insertColumnButtonIndex,
|
|
177
|
-
editorAnalyticsAPI
|
|
179
|
+
editorAnalyticsAPI,
|
|
180
|
+
getEditorFeatureFlags
|
|
178
181
|
} = this.props;
|
|
179
182
|
if (typeof insertColumnButtonIndex !== 'undefined') {
|
|
180
183
|
event.preventDefault();
|
|
181
184
|
const {
|
|
182
185
|
isTableScalingEnabled = false
|
|
183
186
|
} = getPluginState(editorView.state);
|
|
187
|
+
const {
|
|
188
|
+
tableDuplicateCellColouring = false
|
|
189
|
+
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
184
190
|
const {
|
|
185
191
|
state,
|
|
186
192
|
dispatch
|
|
187
193
|
} = editorView;
|
|
188
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
194
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
}
|
|
@@ -65,7 +65,7 @@ const defaultSelectionRect = {
|
|
|
65
65
|
right: 0,
|
|
66
66
|
bottom: 0
|
|
67
67
|
};
|
|
68
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false) => {
|
|
68
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, tableDuplicateCellColouring = false) => {
|
|
69
69
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
70
70
|
const addOptions = direction === 'row' ? [{
|
|
71
71
|
label: 'above',
|
|
@@ -140,12 +140,12 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
|
|
|
140
140
|
icon,
|
|
141
141
|
onClick: (state, dispatch) => {
|
|
142
142
|
if (direction === 'row') {
|
|
143
|
-
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
143
|
+
insertRowWithAnalytics(editorAnalyticsAPI, tableDuplicateCellColouring)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
144
144
|
index: (index !== null && index !== void 0 ? index : 0) + offset,
|
|
145
145
|
moveCursorToInsertedRow: true
|
|
146
146
|
})(state, dispatch);
|
|
147
147
|
} else {
|
|
148
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
148
|
+
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
|
|
149
149
|
}
|
|
150
150
|
return true;
|
|
151
151
|
},
|
|
@@ -21,6 +21,7 @@ function addColumnAtCustomStep(column) {
|
|
|
21
21
|
}
|
|
22
22
|
export function addColumnAt() {
|
|
23
23
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
24
|
+
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
24
25
|
return function (column) {
|
|
25
26
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
26
27
|
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -29,7 +30,7 @@ export function addColumnAt() {
|
|
|
29
30
|
if (allowAddColumnCustomStep) {
|
|
30
31
|
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
31
32
|
} else {
|
|
32
|
-
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
33
|
+
updatedTr = addColumnAtPMUtils(column, isCellBackgroundDuplicated)(updatedTr);
|
|
33
34
|
}
|
|
34
35
|
var table = findTable(updatedTr.selection);
|
|
35
36
|
if (table) {
|
|
@@ -83,9 +84,10 @@ export var addColumnAfter = function addColumnAfter(isTableScalingEnabled) {
|
|
|
83
84
|
};
|
|
84
85
|
export var insertColumn = function insertColumn() {
|
|
85
86
|
var isTableScalingEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
87
|
+
var isCellBackgroundDuplicated = arguments.length > 1 ? arguments[1] : undefined;
|
|
86
88
|
return function (column) {
|
|
87
89
|
return function (state, dispatch, view) {
|
|
88
|
-
var tr = addColumnAt(isTableScalingEnabled)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
90
|
+
var tr = addColumnAt(isTableScalingEnabled, isCellBackgroundDuplicated)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
89
91
|
var table = findTable(tr.selection);
|
|
90
92
|
if (!table) {
|
|
91
93
|
return false;
|
|
@@ -99,7 +101,7 @@ export var insertColumn = function insertColumn() {
|
|
|
99
101
|
};
|
|
100
102
|
};
|
|
101
103
|
};
|
|
102
|
-
export var insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
104
|
+
export var insertRow = function insertRow(row, moveCursorToTheNewRow, isCellBackgroundDuplicated) {
|
|
103
105
|
return function (state, dispatch) {
|
|
104
106
|
// Don't clone the header row
|
|
105
107
|
var headerRowEnabled = checkIfHeaderRowEnabled(state.selection);
|
|
@@ -110,7 +112,7 @@ export var insertRow = function insertRow(row, moveCursorToTheNewRow) {
|
|
|
110
112
|
if (row === 0 && headerRowEnabled) {
|
|
111
113
|
return false;
|
|
112
114
|
}
|
|
113
|
-
var tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row)(state.tr);
|
|
115
|
+
var tr = clonePreviousRow ? copyPreviousRow(state.schema)(row)(state.tr) : addRowAt(row, undefined, isCellBackgroundDuplicated)(state.tr);
|
|
114
116
|
var table = findTable(tr.selection);
|
|
115
117
|
if (!table) {
|
|
116
118
|
return false;
|