@atlaskit/editor-plugin-table 5.6.7 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +238 -99
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +1 -1
- package/dist/cjs/ui/icons/MergeCellsIcon.js +34 -0
- package/dist/cjs/ui/icons/SplitCellIcon.js +41 -0
- package/dist/cjs/ui/icons/index.js +14 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +248 -71
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +20 -0
- package/dist/es2019/ui/icons/MergeCellsIcon.js +25 -0
- package/dist/es2019/ui/icons/SplitCellIcon.js +32 -0
- package/dist/es2019/ui/icons/index.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +238 -98
- package/dist/esm/ui/FloatingContextualMenu/styles.js +1 -1
- package/dist/esm/ui/icons/MergeCellsIcon.js +27 -0
- package/dist/esm/ui/icons/SplitCellIcon.js +34 -0
- package/dist/esm/ui/icons/index.js +2 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +12 -2
- package/dist/types/ui/icons/MergeCellsIcon.d.ts +2 -0
- package/dist/types/ui/icons/SplitCellIcon.d.ts +2 -0
- package/dist/types/ui/icons/index.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +12 -2
- package/dist/types-ts4.5/ui/icons/MergeCellsIcon.d.ts +2 -0
- package/dist/types-ts4.5/ui/icons/SplitCellIcon.d.ts +2 -0
- package/dist/types-ts4.5/ui/icons/index.d.ts +2 -0
- package/package.json +11 -4
- package/src/types.ts +1 -0
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +316 -68
- package/src/ui/FloatingContextualMenu/styles.ts +20 -0
- package/src/ui/icons/MergeCellsIcon.tsx +32 -0
- package/src/ui/icons/SplitCellIcon.tsx +40 -0
- package/src/ui/icons/index.ts +2 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -9,6 +10,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
9
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
12
14
|
/** @jsx jsx */
|
|
13
15
|
import { Component } from 'react';
|
|
14
16
|
import { jsx } from '@emotion/react';
|
|
@@ -24,6 +26,10 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
24
26
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
25
27
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
26
28
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
29
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
30
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
|
|
31
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
32
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
27
33
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, toggleContextualMenu } from '../../commands';
|
|
28
34
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../commands-with-analytics';
|
|
29
35
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
@@ -32,6 +38,7 @@ import { canMergeCells } from '../../transforms';
|
|
|
32
38
|
import { TableCssClassName as ClassName } from '../../types';
|
|
33
39
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
|
|
34
40
|
import { contextualMenuDropdownWidth } from '../consts';
|
|
41
|
+
import { AddColRightIcon, AddRowBelowIcon, MergeCellsIcon, SplitCellIcon } from '../icons';
|
|
35
42
|
import { cellColourPreviewStyles } from './styles';
|
|
36
43
|
export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
37
44
|
_inherits(ContextualMenu, _Component);
|
|
@@ -57,36 +64,35 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
57
64
|
ref.style.left = "-".concat(rect.width, "px");
|
|
58
65
|
}
|
|
59
66
|
});
|
|
60
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "createBackgroundColorItem", function () {
|
|
61
68
|
var _this$props = _this.props,
|
|
62
|
-
allowMergeCells = _this$props.allowMergeCells,
|
|
63
|
-
allowColumnSorting = _this$props.allowColumnSorting,
|
|
64
69
|
allowBackgroundColor = _this$props.allowBackgroundColor,
|
|
65
70
|
state = _this$props.editorView.state,
|
|
66
71
|
isOpen = _this$props.isOpen,
|
|
67
|
-
selectionRect = _this$props.selectionRect,
|
|
68
72
|
formatMessage = _this$props.intl.formatMessage,
|
|
69
73
|
editorView = _this$props.editorView;
|
|
70
|
-
var items = [];
|
|
71
74
|
var isSubmenuOpen = _this.state.isSubmenuOpen;
|
|
72
|
-
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
73
75
|
var _getPluginState = getPluginState(editorView.state),
|
|
74
76
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
75
|
-
|
|
77
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
76
78
|
if (allowBackgroundColor) {
|
|
77
79
|
var _node$attrs;
|
|
78
80
|
var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
79
81
|
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
80
|
-
|
|
81
|
-
content: formatMessage(messages.cellBackground),
|
|
82
|
+
return {
|
|
83
|
+
content: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
82
84
|
value: {
|
|
83
85
|
name: 'background'
|
|
84
86
|
},
|
|
87
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(EditorBackgroundColorIcon, {
|
|
88
|
+
label: formatMessage(messages.backgroundColor),
|
|
89
|
+
size: "medium"
|
|
90
|
+
}) : undefined,
|
|
85
91
|
elemAfter: jsx("div", {
|
|
86
92
|
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
87
93
|
}, jsx("div", {
|
|
88
94
|
css: cellColourPreviewStyles(background),
|
|
89
|
-
className: ClassName.CONTEXTUAL_MENU_ICON
|
|
95
|
+
className: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
90
96
|
}), isSubmenuOpen && jsx("div", {
|
|
91
97
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
92
98
|
ref: _this.handleSubMenuRef
|
|
@@ -100,122 +106,253 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
100
106
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
101
107
|
}
|
|
102
108
|
})))
|
|
103
|
-
}
|
|
109
|
+
};
|
|
104
110
|
}
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
});
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "createMergeSplitCellItems", function () {
|
|
113
|
+
var _this$props2 = _this.props,
|
|
114
|
+
allowMergeCells = _this$props2.allowMergeCells,
|
|
115
|
+
state = _this$props2.editorView.state,
|
|
116
|
+
formatMessage = _this$props2.intl.formatMessage,
|
|
117
|
+
editorView = _this$props2.editorView;
|
|
118
|
+
var _getPluginState2 = getPluginState(editorView.state),
|
|
119
|
+
isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
|
|
120
|
+
if (allowMergeCells) {
|
|
121
|
+
return [{
|
|
122
|
+
content: formatMessage(messages.mergeCells),
|
|
123
|
+
value: {
|
|
124
|
+
name: 'merge'
|
|
125
|
+
},
|
|
126
|
+
isDisabled: !canMergeCells(state.tr),
|
|
127
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(MergeCellsIcon, null) : undefined
|
|
128
|
+
}, {
|
|
129
|
+
content: formatMessage(messages.splitCell),
|
|
130
|
+
value: {
|
|
131
|
+
name: 'split'
|
|
132
|
+
},
|
|
133
|
+
isDisabled: !splitCell(state),
|
|
134
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(SplitCellIcon, null) : undefined
|
|
135
|
+
}];
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
});
|
|
139
|
+
_defineProperty(_assertThisInitialized(_this), "createInsertColumnItem", function () {
|
|
140
|
+
var _this$props3 = _this.props,
|
|
141
|
+
formatMessage = _this$props3.intl.formatMessage,
|
|
142
|
+
editorView = _this$props3.editorView;
|
|
143
|
+
var _getPluginState3 = getPluginState(editorView.state),
|
|
144
|
+
isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
|
|
145
|
+
return {
|
|
146
|
+
content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addColumn : messages.insertColumn),
|
|
107
147
|
value: {
|
|
108
148
|
name: 'insert_column'
|
|
109
149
|
},
|
|
110
150
|
elemAfter: jsx("div", {
|
|
111
151
|
css: shortcutStyle
|
|
112
|
-
}, tooltip(addColumnAfter))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
}, tooltip(addColumnAfter)),
|
|
153
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(AddColRightIcon, null) : undefined
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
_defineProperty(_assertThisInitialized(_this), "createInsertRowItem", function () {
|
|
157
|
+
var _this$props4 = _this.props,
|
|
158
|
+
formatMessage = _this$props4.intl.formatMessage,
|
|
159
|
+
editorView = _this$props4.editorView;
|
|
160
|
+
var _getPluginState4 = getPluginState(editorView.state),
|
|
161
|
+
isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
|
|
162
|
+
return {
|
|
163
|
+
content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addRow : messages.insertRow),
|
|
116
164
|
value: {
|
|
117
165
|
name: 'insert_row'
|
|
118
166
|
},
|
|
119
167
|
elemAfter: jsx("div", {
|
|
120
168
|
css: shortcutStyle
|
|
121
|
-
}, tooltip(addRowAfter))
|
|
122
|
-
|
|
169
|
+
}, tooltip(addRowAfter)),
|
|
170
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(AddRowBelowIcon, null) : undefined
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "createClearCellsItem", function () {
|
|
174
|
+
var _this$props5 = _this.props,
|
|
175
|
+
selectionRect = _this$props5.selectionRect,
|
|
176
|
+
formatMessage = _this$props5.intl.formatMessage,
|
|
177
|
+
editorView = _this$props5.editorView;
|
|
178
|
+
var _getPluginState5 = getPluginState(editorView.state),
|
|
179
|
+
isDragAndDropEnabled = _getPluginState5.isDragAndDropEnabled;
|
|
123
180
|
var top = selectionRect.top,
|
|
124
181
|
bottom = selectionRect.bottom,
|
|
125
182
|
right = selectionRect.right,
|
|
126
183
|
left = selectionRect.left;
|
|
127
184
|
var noOfColumns = right - left;
|
|
128
185
|
var noOfRows = bottom - top;
|
|
129
|
-
|
|
186
|
+
return {
|
|
187
|
+
content: formatMessage(messages.clearCells, {
|
|
188
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
189
|
+
}),
|
|
190
|
+
value: {
|
|
191
|
+
name: 'clear'
|
|
192
|
+
},
|
|
193
|
+
elemAfter: jsx("div", {
|
|
194
|
+
css: shortcutStyle
|
|
195
|
+
}, tooltip(backspace)),
|
|
196
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(CrossCircleIcon, {
|
|
197
|
+
label: formatMessage(messages.clearCells, {
|
|
198
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
199
|
+
})
|
|
200
|
+
}) : undefined
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
_defineProperty(_assertThisInitialized(_this), "createDeleteColumnItem", function () {
|
|
204
|
+
var _this$props6 = _this.props,
|
|
205
|
+
selectionRect = _this$props6.selectionRect,
|
|
206
|
+
formatMessage = _this$props6.intl.formatMessage,
|
|
207
|
+
editorView = _this$props6.editorView;
|
|
208
|
+
var _getPluginState6 = getPluginState(editorView.state),
|
|
209
|
+
isDragAndDropEnabled = _getPluginState6.isDragAndDropEnabled;
|
|
210
|
+
var right = selectionRect.right,
|
|
211
|
+
left = selectionRect.left;
|
|
212
|
+
var noOfColumns = right - left;
|
|
213
|
+
return {
|
|
130
214
|
content: formatMessage(messages.removeColumns, {
|
|
131
215
|
0: noOfColumns
|
|
132
216
|
}),
|
|
133
217
|
value: {
|
|
134
218
|
name: 'delete_column'
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
219
|
+
},
|
|
220
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(RemoveIcon, {
|
|
221
|
+
label: formatMessage(messages.removeColumns, {
|
|
222
|
+
0: noOfColumns
|
|
223
|
+
})
|
|
224
|
+
}) : undefined
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
_defineProperty(_assertThisInitialized(_this), "createDeleteRowItem", function () {
|
|
228
|
+
var _this$props7 = _this.props,
|
|
229
|
+
selectionRect = _this$props7.selectionRect,
|
|
230
|
+
formatMessage = _this$props7.intl.formatMessage,
|
|
231
|
+
editorView = _this$props7.editorView;
|
|
232
|
+
var _getPluginState7 = getPluginState(editorView.state),
|
|
233
|
+
isDragAndDropEnabled = _getPluginState7.isDragAndDropEnabled;
|
|
234
|
+
var bottom = selectionRect.bottom,
|
|
235
|
+
top = selectionRect.top;
|
|
236
|
+
var noOfRows = bottom - top;
|
|
237
|
+
return {
|
|
138
238
|
content: formatMessage(messages.removeRows, {
|
|
139
239
|
0: noOfRows
|
|
140
240
|
}),
|
|
141
241
|
value: {
|
|
142
242
|
name: 'delete_row'
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (allowDistributeColumns) {
|
|
243
|
+
},
|
|
244
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(RemoveIcon, {
|
|
245
|
+
label: formatMessage(messages.removeRows, {
|
|
246
|
+
0: noOfRows
|
|
247
|
+
})
|
|
248
|
+
}) : undefined
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
_defineProperty(_assertThisInitialized(_this), "createDistributeColumnsItem", function () {
|
|
252
|
+
var _this$props8 = _this.props,
|
|
253
|
+
selectionRect = _this$props8.selectionRect,
|
|
254
|
+
formatMessage = _this$props8.intl.formatMessage,
|
|
255
|
+
editorView = _this$props8.editorView,
|
|
256
|
+
getEditorContainerWidth = _this$props8.getEditorContainerWidth;
|
|
257
|
+
var _getPluginState8 = getPluginState(editorView.state),
|
|
258
|
+
isDragAndDropEnabled = _getPluginState8.isDragAndDropEnabled,
|
|
259
|
+
allowDistributeColumns = _getPluginState8.pluginConfig.allowDistributeColumns;
|
|
260
|
+
if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
162
261
|
var _newResizeState$chang;
|
|
163
|
-
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView),
|
|
262
|
+
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
164
263
|
var wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
165
|
-
|
|
264
|
+
return {
|
|
166
265
|
content: formatMessage(messages.distributeColumns),
|
|
167
266
|
value: {
|
|
168
267
|
name: 'distribute_columns'
|
|
169
268
|
},
|
|
170
269
|
isDisabled: !wouldChange
|
|
171
|
-
}
|
|
270
|
+
};
|
|
172
271
|
}
|
|
173
|
-
|
|
174
|
-
|
|
272
|
+
return null;
|
|
273
|
+
});
|
|
274
|
+
_defineProperty(_assertThisInitialized(_this), "createSortColumnItems", function () {
|
|
275
|
+
var _this$props9 = _this.props,
|
|
276
|
+
formatMessage = _this$props9.intl.formatMessage,
|
|
277
|
+
editorView = _this$props9.editorView,
|
|
278
|
+
allowColumnSorting = _this$props9.allowColumnSorting;
|
|
279
|
+
var _getPluginState9 = getPluginState(editorView.state),
|
|
280
|
+
isDragAndDropEnabled = _getPluginState9.isDragAndDropEnabled;
|
|
281
|
+
if (allowColumnSorting && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
282
|
+
var hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
|
|
175
283
|
var warning = hasMergedCellsInTable ? {
|
|
176
284
|
tooltipDescription: formatMessage(messages.canNotSortTable),
|
|
177
285
|
isDisabled: true
|
|
178
286
|
} : {};
|
|
179
|
-
|
|
287
|
+
return [_objectSpread({
|
|
180
288
|
content: formatMessage(messages.sortColumnASC),
|
|
181
289
|
value: {
|
|
182
290
|
name: 'sort_column_asc'
|
|
183
291
|
}
|
|
184
|
-
}, warning)
|
|
185
|
-
items.push(_objectSpread({
|
|
292
|
+
}, warning), _objectSpread({
|
|
186
293
|
content: formatMessage(messages.sortColumnDESC),
|
|
187
294
|
value: {
|
|
188
295
|
name: 'sort_column_desc'
|
|
189
296
|
}
|
|
190
|
-
}, warning)
|
|
297
|
+
}, warning)];
|
|
191
298
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
299
|
+
return null;
|
|
300
|
+
});
|
|
301
|
+
_defineProperty(_assertThisInitialized(_this), "createOriginalContextMenuItems", function () {
|
|
302
|
+
var items = [];
|
|
303
|
+
var backgroundColorItem = _this.createBackgroundColorItem();
|
|
304
|
+
backgroundColorItem && items.push(backgroundColorItem);
|
|
305
|
+
items.push(_this.createInsertColumnItem());
|
|
306
|
+
items.push(_this.createInsertRowItem());
|
|
307
|
+
items.push(_this.createDeleteColumnItem());
|
|
308
|
+
items.push(_this.createDeleteRowItem());
|
|
309
|
+
items.push.apply(items, _toConsumableArray(_this.createMergeSplitCellItems()));
|
|
310
|
+
var distributeColumnsItem = _this.createDistributeColumnsItem();
|
|
311
|
+
distributeColumnsItem && items.push(distributeColumnsItem);
|
|
312
|
+
var sortColumnItems = _this.createSortColumnItems();
|
|
313
|
+
sortColumnItems && items.push.apply(items, _toConsumableArray(sortColumnItems));
|
|
314
|
+
items.push(_this.createClearCellsItem());
|
|
315
|
+
return [{
|
|
204
316
|
items: items
|
|
205
|
-
}]
|
|
317
|
+
}];
|
|
318
|
+
});
|
|
319
|
+
_defineProperty(_assertThisInitialized(_this), "createNewContextMenuItems", function () {
|
|
320
|
+
var _items$0$items;
|
|
321
|
+
var backgroundColorItem = _this.createBackgroundColorItem();
|
|
322
|
+
var mergeSplitCellItems = _this.createMergeSplitCellItems();
|
|
323
|
+
var insertColumnItem = _this.createInsertColumnItem();
|
|
324
|
+
var insertRowItem = _this.createInsertRowItem();
|
|
325
|
+
var clearCellsItem = _this.createClearCellsItem();
|
|
326
|
+
var deleteColumnItem = _this.createDeleteColumnItem();
|
|
327
|
+
var deleteRowItem = _this.createDeleteRowItem();
|
|
328
|
+
|
|
329
|
+
// Group items so when table.menu.group-items FF is enabled, a divider shows under split cell, above add column
|
|
330
|
+
var items = [{
|
|
331
|
+
items: []
|
|
332
|
+
}, {
|
|
333
|
+
items: []
|
|
334
|
+
}];
|
|
335
|
+
backgroundColorItem && items[0].items.push(backgroundColorItem);
|
|
336
|
+
(_items$0$items = items[0].items).push.apply(_items$0$items, _toConsumableArray(mergeSplitCellItems));
|
|
337
|
+
items[1].items.push(insertColumnItem);
|
|
338
|
+
items[1].items.push(insertRowItem);
|
|
339
|
+
items[1].items.push(clearCellsItem);
|
|
340
|
+
items[1].items.push(deleteColumnItem);
|
|
341
|
+
items[1].items.push(deleteRowItem);
|
|
342
|
+
return items;
|
|
206
343
|
});
|
|
207
344
|
_defineProperty(_assertThisInitialized(_this), "onMenuItemActivated", function (_ref) {
|
|
208
345
|
var item = _ref.item;
|
|
209
|
-
var _this$
|
|
210
|
-
editorView = _this$
|
|
211
|
-
selectionRect = _this$
|
|
212
|
-
editorAnalyticsAPI = _this$
|
|
213
|
-
getEditorContainerWidth = _this$
|
|
346
|
+
var _this$props10 = _this.props,
|
|
347
|
+
editorView = _this$props10.editorView,
|
|
348
|
+
selectionRect = _this$props10.selectionRect,
|
|
349
|
+
editorAnalyticsAPI = _this$props10.editorAnalyticsAPI,
|
|
350
|
+
getEditorContainerWidth = _this$props10.getEditorContainerWidth;
|
|
214
351
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
215
352
|
var state = editorView.state,
|
|
216
353
|
dispatch = editorView.dispatch;
|
|
217
|
-
var
|
|
218
|
-
targetCellPosition =
|
|
354
|
+
var _getPluginState10 = getPluginState(state),
|
|
355
|
+
targetCellPosition = _getPluginState10.targetCellPosition;
|
|
219
356
|
switch (item.value.name) {
|
|
220
357
|
case 'sort_column_desc':
|
|
221
358
|
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
@@ -260,19 +397,19 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
260
397
|
_this.toggleOpen();
|
|
261
398
|
break;
|
|
262
399
|
case 'delete_row':
|
|
263
|
-
var
|
|
264
|
-
isHeaderRowRequired =
|
|
400
|
+
var _getPluginState11 = getPluginState(state),
|
|
401
|
+
isHeaderRowRequired = _getPluginState11.pluginConfig.isHeaderRowRequired;
|
|
265
402
|
deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect, !!isHeaderRowRequired)(state, dispatch);
|
|
266
403
|
_this.toggleOpen();
|
|
267
404
|
break;
|
|
268
405
|
}
|
|
269
406
|
});
|
|
270
407
|
_defineProperty(_assertThisInitialized(_this), "toggleOpen", function () {
|
|
271
|
-
var _this$
|
|
272
|
-
isOpen = _this$
|
|
273
|
-
_this$
|
|
274
|
-
state = _this$
|
|
275
|
-
dispatch = _this$
|
|
408
|
+
var _this$props11 = _this.props,
|
|
409
|
+
isOpen = _this$props11.isOpen,
|
|
410
|
+
_this$props11$editorV = _this$props11.editorView,
|
|
411
|
+
state = _this$props11$editorV.state,
|
|
412
|
+
dispatch = _this$props11$editorV.dispatch;
|
|
276
413
|
toggleContextualMenu()(state, dispatch);
|
|
277
414
|
if (!isOpen) {
|
|
278
415
|
_this.setState({
|
|
@@ -291,11 +428,11 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
291
428
|
});
|
|
292
429
|
_defineProperty(_assertThisInitialized(_this), "handleItemMouseEnter", function (_ref2) {
|
|
293
430
|
var item = _ref2.item;
|
|
294
|
-
var _this$
|
|
295
|
-
_this$
|
|
296
|
-
state = _this$
|
|
297
|
-
dispatch = _this$
|
|
298
|
-
selectionRect = _this$
|
|
431
|
+
var _this$props12 = _this.props,
|
|
432
|
+
_this$props12$editorV = _this$props12.editorView,
|
|
433
|
+
state = _this$props12$editorV.state,
|
|
434
|
+
dispatch = _this$props12$editorV.dispatch,
|
|
435
|
+
selectionRect = _this$props12.selectionRect;
|
|
299
436
|
if (item.value.name === 'background') {
|
|
300
437
|
if (!_this.state.isSubmenuOpen) {
|
|
301
438
|
_this.setState({
|
|
@@ -333,12 +470,12 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
333
470
|
}
|
|
334
471
|
});
|
|
335
472
|
_defineProperty(_assertThisInitialized(_this), "setColor", function (color) {
|
|
336
|
-
var _this$
|
|
337
|
-
editorView = _this$
|
|
338
|
-
editorAnalyticsAPI = _this$
|
|
473
|
+
var _this$props13 = _this.props,
|
|
474
|
+
editorView = _this$props13.editorView,
|
|
475
|
+
editorAnalyticsAPI = _this$props13.editorAnalyticsAPI;
|
|
339
476
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
340
|
-
var
|
|
341
|
-
targetCellPosition =
|
|
477
|
+
var _getPluginState12 = getPluginState(editorView.state),
|
|
478
|
+
targetCellPosition = _getPluginState12.targetCellPosition;
|
|
342
479
|
var state = editorView.state,
|
|
343
480
|
dispatch = editorView.dispatch;
|
|
344
481
|
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
@@ -349,15 +486,15 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
349
486
|
_createClass(ContextualMenu, [{
|
|
350
487
|
key: "render",
|
|
351
488
|
value: function render() {
|
|
352
|
-
var _this$
|
|
353
|
-
isOpen = _this$
|
|
354
|
-
mountPoint = _this$
|
|
355
|
-
offset = _this$
|
|
356
|
-
boundariesElement = _this$
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
489
|
+
var _this$props14 = this.props,
|
|
490
|
+
isOpen = _this$props14.isOpen,
|
|
491
|
+
mountPoint = _this$props14.mountPoint,
|
|
492
|
+
offset = _this$props14.offset,
|
|
493
|
+
boundariesElement = _this$props14.boundariesElement,
|
|
494
|
+
editorView = _this$props14.editorView;
|
|
495
|
+
var _getPluginState13 = getPluginState(editorView.state),
|
|
496
|
+
isDragAndDropEnabled = _getPluginState13.isDragAndDropEnabled;
|
|
497
|
+
var items = isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
361
498
|
return jsx("div", {
|
|
362
499
|
"data-testid": "table-cell-contextual-menu",
|
|
363
500
|
onMouseLeave: this.closeSubmenu
|
|
@@ -379,7 +516,10 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
379
516
|
fitHeight: 188,
|
|
380
517
|
fitWidth: contextualMenuDropdownWidth,
|
|
381
518
|
boundariesElement: boundariesElement,
|
|
382
|
-
offset: offset
|
|
519
|
+
offset: offset,
|
|
520
|
+
section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
|
|
521
|
+
hasSeparator: true
|
|
522
|
+
} : undefined
|
|
383
523
|
}));
|
|
384
524
|
}
|
|
385
525
|
}]);
|
|
@@ -11,4 +11,4 @@ export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedCo
|
|
|
11
11
|
|
|
12
12
|
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
13
13
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
14
|
-
export var tablePopupStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 20px;\n color: ", ";\n }\n }\n"])), ClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
|
|
14
|
+
export var tablePopupStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 20px;\n color: ", ";\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), ClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"), ClassName.CONTEXTUAL_MENU_ICON_SMALL, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var MergeCellsIcon = function MergeCellsIcon() {
|
|
3
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4
|
+
width: "24",
|
|
5
|
+
height: "24",
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fillRule: "evenodd",
|
|
11
|
+
clipRule: "evenodd",
|
|
12
|
+
d: "M10 19C10.5523 19 11 18.5523 11 18C11 17.4477 10.5523 17 10 17H6V7L10 7C10.5523 7 11 6.55228 11 6C11 5.44771 10.5523 5 10 5H6C4.89543 5 4 5.89543 4 7V17C4 18.1046 4.89543 19 6 19H10ZM14 5C13.4477 5 13 5.44772 13 6C13 6.55228 13.4477 7 14 7H18V17L14 17C13.4477 17 13 17.4477 13 18C13 18.5523 13.4477 19 14 19H18C19.1046 19 20 18.1046 20 17V7C20 5.89543 19.1046 5 18 5H14Z",
|
|
13
|
+
fill: "currentColor"
|
|
14
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
15
|
+
d: "M15.75 10L13.75 12L15.75 14",
|
|
16
|
+
stroke: "currentColor",
|
|
17
|
+
strokeWidth: "1.5",
|
|
18
|
+
strokeLinecap: "round",
|
|
19
|
+
strokeLinejoin: "round"
|
|
20
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
21
|
+
d: "M8.25 14L10.25 12L8.25 10",
|
|
22
|
+
stroke: "currentColor",
|
|
23
|
+
strokeWidth: "1.5",
|
|
24
|
+
strokeLinecap: "round",
|
|
25
|
+
strokeLinejoin: "round"
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var SplitCellIcon = function SplitCellIcon() {
|
|
3
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
4
|
+
width: "24",
|
|
5
|
+
height: "24",
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M19 18L14 18L14 6L19 6",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: "2",
|
|
13
|
+
strokeLinecap: "round",
|
|
14
|
+
strokeLinejoin: "round"
|
|
15
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
16
|
+
d: "M5 6L10 6L9.99999 18L5 18",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeWidth: "2",
|
|
19
|
+
strokeLinecap: "round",
|
|
20
|
+
strokeLinejoin: "round"
|
|
21
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
22
|
+
d: "M7 10L5 12L7 14",
|
|
23
|
+
stroke: "currentColor",
|
|
24
|
+
strokeWidth: "1.5",
|
|
25
|
+
strokeLinecap: "round",
|
|
26
|
+
strokeLinejoin: "round"
|
|
27
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
28
|
+
d: "M17 14L19 12L17 10",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: "1.5",
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round"
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
@@ -2,6 +2,8 @@ export { DragHandleIcon } from './DragHandleIcon';
|
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
3
|
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
4
4
|
export { MinimisedHandleIcon } from './MinimisedHandle';
|
|
5
|
+
export { MergeCellsIcon } from './MergeCellsIcon';
|
|
6
|
+
export { SplitCellIcon } from './SplitCellIcon';
|
|
5
7
|
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
6
8
|
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
7
9
|
export { AddColLeftIcon } from './AddColLeftIcon';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -329,6 +329,7 @@ export declare const TableCssClassName: {
|
|
|
329
329
|
CONTEXTUAL_MENU_BUTTON: string;
|
|
330
330
|
CONTEXTUAL_MENU_BUTTON_FIXED: string;
|
|
331
331
|
CONTEXTUAL_MENU_ICON: string;
|
|
332
|
+
CONTEXTUAL_MENU_ICON_SMALL: string;
|
|
332
333
|
SELECTED_CELL: string;
|
|
333
334
|
NODEVIEW_WRAPPER: string;
|
|
334
335
|
TABLE_SELECTED: string;
|
|
@@ -28,9 +28,19 @@ export declare class ContextualMenu extends Component<Props & WrappedComponentPr
|
|
|
28
28
|
static defaultProps: {
|
|
29
29
|
boundariesElement: HTMLElement | undefined;
|
|
30
30
|
};
|
|
31
|
-
render(): jsx.JSX.Element
|
|
31
|
+
render(): jsx.JSX.Element;
|
|
32
32
|
private handleSubMenuRef;
|
|
33
|
-
private
|
|
33
|
+
private createBackgroundColorItem;
|
|
34
|
+
private createMergeSplitCellItems;
|
|
35
|
+
private createInsertColumnItem;
|
|
36
|
+
private createInsertRowItem;
|
|
37
|
+
private createClearCellsItem;
|
|
38
|
+
private createDeleteColumnItem;
|
|
39
|
+
private createDeleteRowItem;
|
|
40
|
+
private createDistributeColumnsItem;
|
|
41
|
+
private createSortColumnItems;
|
|
42
|
+
private createOriginalContextMenuItems;
|
|
43
|
+
private createNewContextMenuItems;
|
|
34
44
|
private onMenuItemActivated;
|
|
35
45
|
private toggleOpen;
|
|
36
46
|
private handleOpenChange;
|
|
@@ -2,6 +2,8 @@ export { DragHandleIcon } from './DragHandleIcon';
|
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
3
|
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
4
4
|
export { MinimisedHandleIcon } from './MinimisedHandle';
|
|
5
|
+
export { MergeCellsIcon } from './MergeCellsIcon';
|
|
6
|
+
export { SplitCellIcon } from './SplitCellIcon';
|
|
5
7
|
export { AddRowAboveIcon } from './AddRowAboveIcon';
|
|
6
8
|
export { AddRowBelowIcon } from './AddRowBelowIcon';
|
|
7
9
|
export { AddColLeftIcon } from './AddColLeftIcon';
|
|
@@ -329,6 +329,7 @@ export declare const TableCssClassName: {
|
|
|
329
329
|
CONTEXTUAL_MENU_BUTTON: string;
|
|
330
330
|
CONTEXTUAL_MENU_BUTTON_FIXED: string;
|
|
331
331
|
CONTEXTUAL_MENU_ICON: string;
|
|
332
|
+
CONTEXTUAL_MENU_ICON_SMALL: string;
|
|
332
333
|
SELECTED_CELL: string;
|
|
333
334
|
NODEVIEW_WRAPPER: string;
|
|
334
335
|
TABLE_SELECTED: string;
|