@atlaskit/editor-plugin-table 5.6.6 → 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 +13 -0
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/ui/FloatingContextualButton/index.js +1 -7
- package/dist/cjs/ui/FloatingContextualButton/styles.js +5 -25
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +238 -99
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +1 -2
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/cjs/ui/common-styles.js +7 -7
- package/dist/cjs/ui/consts.js +16 -63
- 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/cjs/ui/ui-styles.js +47 -48
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/FloatingContextualButton/index.js +1 -5
- package/dist/es2019/ui/FloatingContextualButton/styles.js +10 -31
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +248 -71
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +22 -3
- package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/es2019/ui/common-styles.js +59 -59
- package/dist/es2019/ui/consts.js +18 -64
- 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/es2019/ui/ui-styles.js +98 -99
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/FloatingContextualButton/index.js +1 -7
- package/dist/esm/ui/FloatingContextualButton/styles.js +5 -26
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +238 -98
- package/dist/esm/ui/FloatingContextualMenu/styles.js +1 -2
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/esm/ui/common-styles.js +7 -7
- package/dist/esm/ui/consts.js +18 -64
- 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/esm/ui/ui-styles.js +47 -48
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualButton/styles.d.ts +2 -3
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +12 -2
- package/dist/types/ui/common-styles.d.ts +1 -2
- package/dist/types/ui/consts.d.ts +15 -15
- 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/ui/ui-styles.d.ts +17 -18
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualButton/styles.d.ts +2 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +12 -2
- package/dist/types-ts4.5/ui/common-styles.d.ts +1 -2
- package/dist/types-ts4.5/ui/consts.d.ts +15 -15
- 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/dist/types-ts4.5/ui/ui-styles.d.ts +17 -18
- package/package.json +12 -5
- package/src/types.ts +1 -0
- package/src/ui/FloatingContextualButton/index.tsx +3 -5
- package/src/ui/FloatingContextualButton/styles.ts +13 -35
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +316 -68
- package/src/ui/FloatingContextualMenu/styles.ts +22 -3
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -1
- package/src/ui/common-styles.ts +57 -69
- package/src/ui/consts.ts +52 -73
- package/src/ui/icons/MergeCellsIcon.tsx +32 -0
- package/src/ui/icons/SplitCellIcon.tsx +40 -0
- package/src/ui/icons/index.ts +2 -0
- package/src/ui/ui-styles.ts +94 -106
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject, _templateObject2;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import {
|
|
5
|
-
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
6
|
-
import { themed } from '@atlaskit/theme/components';
|
|
7
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
4
|
+
import { N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
|
|
8
5
|
import { contextualMenuTriggerSize } from '../consts';
|
|
9
|
-
export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles(
|
|
10
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", "
|
|
11
|
-
light: "var(--ds-background-neutral, none)",
|
|
12
|
-
dark: "var(--ds-background-neutral, none)"
|
|
13
|
-
})(props), "var(--ds-space-025, 2px)", "var(--ds-surface, ".concat(N0, ")"), themed({
|
|
14
|
-
light: "var(--ds-background-neutral-hovered, ".concat(N30A, ")"),
|
|
15
|
-
dark: "var(--ds-background-neutral-hovered, ".concat(DN60, ")")
|
|
16
|
-
})(props), themed({
|
|
17
|
-
light: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))",
|
|
18
|
-
dark: "var(--ds-background-neutral-pressed, ".concat(B75, ")")
|
|
19
|
-
})(props), "var(--ds-space-negative-050, -4px)");
|
|
6
|
+
export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles() {
|
|
7
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", ";\n display: flex;\n height: ", "px;\n flex-direction: column;\n }\n && button {\n background: ", ";\n flex-direction: column;\n margin: ", ";\n outline: 2px solid ", ";\n border-radius: 1px;\n padding: 0;\n height: calc(100% - 4px);\n display: flex;\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n && button > span {\n margin: 0px ", ";\n }\n && span {\n pointer-events: none;\n }\n"])), "var(--ds-surface, ".concat(N20, ")"), "var(--ds-border-radius, 3px)", contextualMenuTriggerSize + 2, "var(--ds-background-neutral, none)", "var(--ds-space-025, 2px)", "var(--ds-surface, ".concat(N0, ")"), "var(--ds-background-neutral-hovered, ".concat(N30A, ")"), "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))", "var(--ds-space-negative-050, -4px)");
|
|
20
8
|
};
|
|
21
|
-
export var tableFloatingCellButtonSelectedStyles = function tableFloatingCellButtonSelectedStyles(
|
|
22
|
-
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n"])),
|
|
23
|
-
light: "var(--ds-background-selected, ".concat(N700, ")"),
|
|
24
|
-
dark: "var(--ds-background-selected, ".concat(DN0, ")")
|
|
25
|
-
})(props), themed({
|
|
26
|
-
light: "var(--ds-background-selected-hovered, ".concat(N700, ")"),
|
|
27
|
-
dark: "var(--ds-background-selected-hovered, ".concat(DN0, ")")
|
|
28
|
-
})(props), themed({
|
|
29
|
-
light: "var(--ds-background-selected-pressed, ".concat(N700, ")"),
|
|
30
|
-
dark: "var(--ds-background-selected-pressed, ".concat(DN0, ")")
|
|
31
|
-
})(props));
|
|
9
|
+
export var tableFloatingCellButtonSelectedStyles = function tableFloatingCellButtonSelectedStyles() {
|
|
10
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n"])), "var(--ds-background-selected, ".concat(N700, ")"), "var(--ds-background-selected-hovered, ".concat(N700, ")"), "var(--ds-background-selected-pressed, ".concat(N700, ")"));
|
|
32
11
|
};
|
|
@@ -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
|
}]);
|
|
@@ -3,7 +3,6 @@ var _templateObject, _templateObject2;
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
5
5
|
import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
6
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
7
6
|
import { TableCssClassName as ClassName } from '../../types';
|
|
8
7
|
import { contextualMenuDropdownWidth } from '../consts';
|
|
9
8
|
export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
|
|
@@ -12,4 +11,4 @@ export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedCo
|
|
|
12
11
|
|
|
13
12
|
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
14
13
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
15
|
-
export var tablePopupStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", "
|
|
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, ")"));
|
|
@@ -103,7 +103,7 @@ var NumberColumn = /*#__PURE__*/function (_Component) {
|
|
|
103
103
|
className: ClassName.NUMBERED_COLUMN,
|
|
104
104
|
style: {
|
|
105
105
|
marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined,
|
|
106
|
-
borderLeft: isDragAndDropEnabled && tableActive ? "1px solid ".concat(tableBorderColor
|
|
106
|
+
borderLeft: isDragAndDropEnabled && tableActive ? "1px solid ".concat(tableBorderColor) : undefined
|
|
107
107
|
},
|
|
108
108
|
contentEditable: false
|
|
109
109
|
}, rowHeights.map(function (rowHeight, index) {
|