@atlaskit/editor-plugin-table 5.6.7 → 5.7.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 +13 -0
- package/dist/cjs/nodeviews/TableResizer.js +1 -1
- 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/consts.js +6 -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/nodeviews/TableResizer.js +2 -2
- 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/consts.js +5 -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/nodeviews/TableResizer.js +2 -2
- 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/consts.js +5 -0
- 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/consts.d.ts +1 -0
- 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/consts.d.ts +1 -0
- 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/nodeviews/TableResizer.tsx +3 -1
- 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/consts.ts +5 -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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SplitCellIcon = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var SplitCellIcon = exports.SplitCellIcon = function SplitCellIcon() {
|
|
10
|
+
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
11
|
+
width: "24",
|
|
12
|
+
height: "24",
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
fill: "none",
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
16
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
17
|
+
d: "M19 18L14 18L14 6L19 6",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
strokeWidth: "2",
|
|
20
|
+
strokeLinecap: "round",
|
|
21
|
+
strokeLinejoin: "round"
|
|
22
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
23
|
+
d: "M5 6L10 6L9.99999 18L5 18",
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
strokeWidth: "2",
|
|
26
|
+
strokeLinecap: "round",
|
|
27
|
+
strokeLinejoin: "round"
|
|
28
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
29
|
+
d: "M7 10L5 12L7 14",
|
|
30
|
+
stroke: "currentColor",
|
|
31
|
+
strokeWidth: "1.5",
|
|
32
|
+
strokeLinecap: "round",
|
|
33
|
+
strokeLinejoin: "round"
|
|
34
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
35
|
+
d: "M17 14L19 12L17 10",
|
|
36
|
+
stroke: "currentColor",
|
|
37
|
+
strokeWidth: "1.5",
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
strokeLinejoin: "round"
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
@@ -45,16 +45,30 @@ Object.defineProperty(exports, "DragInMotionIcon", {
|
|
|
45
45
|
return _DragInMotionIcon.DragInMotionIcon;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "MergeCellsIcon", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _MergeCellsIcon.MergeCellsIcon;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
48
54
|
Object.defineProperty(exports, "MinimisedHandleIcon", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function get() {
|
|
51
57
|
return _MinimisedHandle.MinimisedHandleIcon;
|
|
52
58
|
}
|
|
53
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "SplitCellIcon", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _SplitCellIcon.SplitCellIcon;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
54
66
|
var _DragHandleIcon = require("./DragHandleIcon");
|
|
55
67
|
var _DragInMotionIcon = require("./DragInMotionIcon");
|
|
56
68
|
var _DragHandleDisabledIcon = require("./DragHandleDisabledIcon");
|
|
57
69
|
var _MinimisedHandle = require("./MinimisedHandle");
|
|
70
|
+
var _MergeCellsIcon = require("./MergeCellsIcon");
|
|
71
|
+
var _SplitCellIcon = require("./SplitCellIcon");
|
|
58
72
|
var _AddRowAboveIcon = require("./AddRowAboveIcon");
|
|
59
73
|
var _AddRowBelowIcon = require("./AddRowBelowIcon");
|
|
60
74
|
var _AddColLeftIcon = require("./AddColLeftIcon");
|
|
@@ -14,7 +14,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
|
14
14
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
15
15
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
16
16
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
17
|
-
import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
17
|
+
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
18
18
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
19
19
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
20
20
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
@@ -65,7 +65,7 @@ const getResizerMinWidth = node => {
|
|
|
65
65
|
*/
|
|
66
66
|
const getVisibleGuidelines = (guidelines, containerWidth) => {
|
|
67
67
|
return guidelines.filter(guideline => {
|
|
68
|
-
return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < containerWidth;
|
|
68
|
+
return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < containerWidth + TABLE_GUIDELINE_VISIBLE_ADJUSTMENT;
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
export const TableResizer = ({
|
package/dist/es2019/types.js
CHANGED
|
@@ -122,6 +122,7 @@ export const TableCssClassName = {
|
|
|
122
122
|
CONTEXTUAL_MENU_BUTTON: `${tablePrefixSelector}-contextual-menu-button`,
|
|
123
123
|
CONTEXTUAL_MENU_BUTTON_FIXED: `${tablePrefixSelector}-contextual-menu-button-fixed`,
|
|
124
124
|
CONTEXTUAL_MENU_ICON: `${tablePrefixSelector}-contextual-submenu-icon`,
|
|
125
|
+
CONTEXTUAL_MENU_ICON_SMALL: `${tablePrefixSelector}-contextual-submenu-icon-small`,
|
|
125
126
|
// come from prosemirror-table
|
|
126
127
|
SELECTED_CELL: 'selectedCell',
|
|
127
128
|
// defined in ReactNodeView based on PM node name
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
3
|
/** @jsx jsx */
|
|
3
4
|
import { Component } from 'react';
|
|
4
5
|
import { jsx } from '@emotion/react';
|
|
@@ -14,6 +15,10 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
14
15
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
15
16
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
16
17
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
18
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
19
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/glyph/editor/background-color';
|
|
20
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
21
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
22
|
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, toggleContextualMenu } from '../../commands';
|
|
18
23
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics } from '../../commands-with-analytics';
|
|
19
24
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
@@ -22,6 +27,7 @@ import { canMergeCells } from '../../transforms';
|
|
|
22
27
|
import { TableCssClassName as ClassName } from '../../types';
|
|
23
28
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
|
|
24
29
|
import { contextualMenuDropdownWidth } from '../consts';
|
|
30
|
+
import { AddColRightIcon, AddRowBelowIcon, MergeCellsIcon, SplitCellIcon } from '../icons';
|
|
25
31
|
import { cellColourPreviewStyles } from './styles';
|
|
26
32
|
export class ContextualMenu extends Component {
|
|
27
33
|
constructor(...args) {
|
|
@@ -40,46 +46,43 @@ export class ContextualMenu extends Component {
|
|
|
40
46
|
ref.style.left = `-${rect.width}px`;
|
|
41
47
|
}
|
|
42
48
|
});
|
|
43
|
-
_defineProperty(this, "
|
|
49
|
+
_defineProperty(this, "createBackgroundColorItem", () => {
|
|
44
50
|
const {
|
|
45
|
-
allowMergeCells,
|
|
46
|
-
allowColumnSorting,
|
|
47
51
|
allowBackgroundColor,
|
|
48
52
|
editorView: {
|
|
49
53
|
state
|
|
50
54
|
},
|
|
51
55
|
isOpen,
|
|
52
|
-
selectionRect,
|
|
53
56
|
intl: {
|
|
54
57
|
formatMessage
|
|
55
58
|
},
|
|
56
59
|
editorView
|
|
57
60
|
} = this.props;
|
|
58
|
-
const items = [];
|
|
59
61
|
const {
|
|
60
62
|
isSubmenuOpen
|
|
61
63
|
} = this.state;
|
|
62
|
-
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
63
64
|
const {
|
|
64
65
|
targetCellPosition,
|
|
65
|
-
|
|
66
|
-
allowDistributeColumns
|
|
67
|
-
}
|
|
66
|
+
isDragAndDropEnabled
|
|
68
67
|
} = getPluginState(editorView.state);
|
|
69
68
|
if (allowBackgroundColor) {
|
|
70
69
|
var _node$attrs;
|
|
71
70
|
const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
72
71
|
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
73
|
-
|
|
74
|
-
content: formatMessage(messages.cellBackground),
|
|
72
|
+
return {
|
|
73
|
+
content: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
75
74
|
value: {
|
|
76
75
|
name: 'background'
|
|
77
76
|
},
|
|
77
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(EditorBackgroundColorIcon, {
|
|
78
|
+
label: formatMessage(messages.backgroundColor),
|
|
79
|
+
size: "medium"
|
|
80
|
+
}) : undefined,
|
|
78
81
|
elemAfter: jsx("div", {
|
|
79
82
|
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
80
83
|
}, jsx("div", {
|
|
81
84
|
css: cellColourPreviewStyles(background),
|
|
82
|
-
className: ClassName.CONTEXTUAL_MENU_ICON
|
|
85
|
+
className: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? ClassName.CONTEXTUAL_MENU_ICON_SMALL : ClassName.CONTEXTUAL_MENU_ICON
|
|
83
86
|
}), isSubmenuOpen && jsx("div", {
|
|
84
87
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
85
88
|
ref: this.handleSubMenuRef
|
|
@@ -93,26 +96,95 @@ export class ContextualMenu extends Component {
|
|
|
93
96
|
hexToPaletteColor: hexToEditorBackgroundPaletteColor
|
|
94
97
|
}
|
|
95
98
|
})))
|
|
96
|
-
}
|
|
99
|
+
};
|
|
97
100
|
}
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
});
|
|
102
|
+
_defineProperty(this, "createMergeSplitCellItems", () => {
|
|
103
|
+
const {
|
|
104
|
+
allowMergeCells,
|
|
105
|
+
editorView: {
|
|
106
|
+
state
|
|
107
|
+
},
|
|
108
|
+
intl: {
|
|
109
|
+
formatMessage
|
|
110
|
+
},
|
|
111
|
+
editorView
|
|
112
|
+
} = this.props;
|
|
113
|
+
const {
|
|
114
|
+
isDragAndDropEnabled
|
|
115
|
+
} = getPluginState(editorView.state);
|
|
116
|
+
if (allowMergeCells) {
|
|
117
|
+
return [{
|
|
118
|
+
content: formatMessage(messages.mergeCells),
|
|
119
|
+
value: {
|
|
120
|
+
name: 'merge'
|
|
121
|
+
},
|
|
122
|
+
isDisabled: !canMergeCells(state.tr),
|
|
123
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(MergeCellsIcon, null) : undefined
|
|
124
|
+
}, {
|
|
125
|
+
content: formatMessage(messages.splitCell),
|
|
126
|
+
value: {
|
|
127
|
+
name: 'split'
|
|
128
|
+
},
|
|
129
|
+
isDisabled: !splitCell(state),
|
|
130
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(SplitCellIcon, null) : undefined
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
return [];
|
|
134
|
+
});
|
|
135
|
+
_defineProperty(this, "createInsertColumnItem", () => {
|
|
136
|
+
const {
|
|
137
|
+
intl: {
|
|
138
|
+
formatMessage
|
|
139
|
+
},
|
|
140
|
+
editorView
|
|
141
|
+
} = this.props;
|
|
142
|
+
const {
|
|
143
|
+
isDragAndDropEnabled
|
|
144
|
+
} = getPluginState(editorView.state);
|
|
145
|
+
return {
|
|
146
|
+
content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addColumn : messages.insertColumn),
|
|
100
147
|
value: {
|
|
101
148
|
name: 'insert_column'
|
|
102
149
|
},
|
|
103
150
|
elemAfter: jsx("div", {
|
|
104
151
|
css: shortcutStyle
|
|
105
|
-
}, tooltip(addColumnAfter))
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
152
|
+
}, tooltip(addColumnAfter)),
|
|
153
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(AddColRightIcon, null) : undefined
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
_defineProperty(this, "createInsertRowItem", () => {
|
|
157
|
+
const {
|
|
158
|
+
intl: {
|
|
159
|
+
formatMessage
|
|
160
|
+
},
|
|
161
|
+
editorView
|
|
162
|
+
} = this.props;
|
|
163
|
+
const {
|
|
164
|
+
isDragAndDropEnabled
|
|
165
|
+
} = getPluginState(editorView.state);
|
|
166
|
+
return {
|
|
167
|
+
content: formatMessage(isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? messages.addRow : messages.insertRow),
|
|
109
168
|
value: {
|
|
110
169
|
name: 'insert_row'
|
|
111
170
|
},
|
|
112
171
|
elemAfter: jsx("div", {
|
|
113
172
|
css: shortcutStyle
|
|
114
|
-
}, tooltip(addRowAfter))
|
|
115
|
-
|
|
173
|
+
}, tooltip(addRowAfter)),
|
|
174
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(AddRowBelowIcon, null) : undefined
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
_defineProperty(this, "createClearCellsItem", () => {
|
|
178
|
+
const {
|
|
179
|
+
selectionRect,
|
|
180
|
+
intl: {
|
|
181
|
+
formatMessage
|
|
182
|
+
},
|
|
183
|
+
editorView
|
|
184
|
+
} = this.props;
|
|
185
|
+
const {
|
|
186
|
+
isDragAndDropEnabled
|
|
187
|
+
} = getPluginState(editorView.state);
|
|
116
188
|
const {
|
|
117
189
|
top,
|
|
118
190
|
bottom,
|
|
@@ -121,85 +193,186 @@ export class ContextualMenu extends Component {
|
|
|
121
193
|
} = selectionRect;
|
|
122
194
|
const noOfColumns = right - left;
|
|
123
195
|
const noOfRows = bottom - top;
|
|
124
|
-
|
|
196
|
+
return {
|
|
197
|
+
content: formatMessage(messages.clearCells, {
|
|
198
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
199
|
+
}),
|
|
200
|
+
value: {
|
|
201
|
+
name: 'clear'
|
|
202
|
+
},
|
|
203
|
+
elemAfter: jsx("div", {
|
|
204
|
+
css: shortcutStyle
|
|
205
|
+
}, tooltip(backspace)),
|
|
206
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(CrossCircleIcon, {
|
|
207
|
+
label: formatMessage(messages.clearCells, {
|
|
208
|
+
0: Math.max(noOfColumns, noOfRows)
|
|
209
|
+
})
|
|
210
|
+
}) : undefined
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
_defineProperty(this, "createDeleteColumnItem", () => {
|
|
214
|
+
const {
|
|
215
|
+
selectionRect,
|
|
216
|
+
intl: {
|
|
217
|
+
formatMessage
|
|
218
|
+
},
|
|
219
|
+
editorView
|
|
220
|
+
} = this.props;
|
|
221
|
+
const {
|
|
222
|
+
isDragAndDropEnabled
|
|
223
|
+
} = getPluginState(editorView.state);
|
|
224
|
+
const {
|
|
225
|
+
right,
|
|
226
|
+
left
|
|
227
|
+
} = selectionRect;
|
|
228
|
+
const noOfColumns = right - left;
|
|
229
|
+
return {
|
|
125
230
|
content: formatMessage(messages.removeColumns, {
|
|
126
231
|
0: noOfColumns
|
|
127
232
|
}),
|
|
128
233
|
value: {
|
|
129
234
|
name: 'delete_column'
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
235
|
+
},
|
|
236
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(RemoveIcon, {
|
|
237
|
+
label: formatMessage(messages.removeColumns, {
|
|
238
|
+
0: noOfColumns
|
|
239
|
+
})
|
|
240
|
+
}) : undefined
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
_defineProperty(this, "createDeleteRowItem", () => {
|
|
244
|
+
const {
|
|
245
|
+
selectionRect,
|
|
246
|
+
intl: {
|
|
247
|
+
formatMessage
|
|
248
|
+
},
|
|
249
|
+
editorView
|
|
250
|
+
} = this.props;
|
|
251
|
+
const {
|
|
252
|
+
isDragAndDropEnabled
|
|
253
|
+
} = getPluginState(editorView.state);
|
|
254
|
+
const {
|
|
255
|
+
bottom,
|
|
256
|
+
top
|
|
257
|
+
} = selectionRect;
|
|
258
|
+
const noOfRows = bottom - top;
|
|
259
|
+
return {
|
|
133
260
|
content: formatMessage(messages.removeRows, {
|
|
134
261
|
0: noOfRows
|
|
135
262
|
}),
|
|
136
263
|
value: {
|
|
137
264
|
name: 'delete_row'
|
|
265
|
+
},
|
|
266
|
+
elemBefore: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? jsx(RemoveIcon, {
|
|
267
|
+
label: formatMessage(messages.removeRows, {
|
|
268
|
+
0: noOfRows
|
|
269
|
+
})
|
|
270
|
+
}) : undefined
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
_defineProperty(this, "createDistributeColumnsItem", () => {
|
|
274
|
+
const {
|
|
275
|
+
selectionRect,
|
|
276
|
+
intl: {
|
|
277
|
+
formatMessage
|
|
278
|
+
},
|
|
279
|
+
editorView,
|
|
280
|
+
getEditorContainerWidth
|
|
281
|
+
} = this.props;
|
|
282
|
+
const {
|
|
283
|
+
isDragAndDropEnabled,
|
|
284
|
+
pluginConfig: {
|
|
285
|
+
allowDistributeColumns
|
|
138
286
|
}
|
|
139
|
-
});
|
|
140
|
-
if (
|
|
141
|
-
items.push({
|
|
142
|
-
content: formatMessage(messages.mergeCells),
|
|
143
|
-
value: {
|
|
144
|
-
name: 'merge'
|
|
145
|
-
},
|
|
146
|
-
isDisabled: !canMergeCells(state.tr)
|
|
147
|
-
});
|
|
148
|
-
items.push({
|
|
149
|
-
content: formatMessage(messages.splitCell),
|
|
150
|
-
value: {
|
|
151
|
-
name: 'split'
|
|
152
|
-
},
|
|
153
|
-
isDisabled: !splitCell(state)
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (allowDistributeColumns) {
|
|
287
|
+
} = getPluginState(editorView.state);
|
|
288
|
+
if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
157
289
|
var _newResizeState$chang;
|
|
158
|
-
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView),
|
|
290
|
+
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
|
|
159
291
|
const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
|
|
160
|
-
|
|
292
|
+
return {
|
|
161
293
|
content: formatMessage(messages.distributeColumns),
|
|
162
294
|
value: {
|
|
163
295
|
name: 'distribute_columns'
|
|
164
296
|
},
|
|
165
297
|
isDisabled: !wouldChange
|
|
166
|
-
}
|
|
298
|
+
};
|
|
167
299
|
}
|
|
168
|
-
|
|
169
|
-
|
|
300
|
+
return null;
|
|
301
|
+
});
|
|
302
|
+
_defineProperty(this, "createSortColumnItems", () => {
|
|
303
|
+
const {
|
|
304
|
+
intl: {
|
|
305
|
+
formatMessage
|
|
306
|
+
},
|
|
307
|
+
editorView,
|
|
308
|
+
allowColumnSorting
|
|
309
|
+
} = this.props;
|
|
310
|
+
const {
|
|
311
|
+
isDragAndDropEnabled
|
|
312
|
+
} = getPluginState(editorView.state);
|
|
313
|
+
if (allowColumnSorting && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
|
|
314
|
+
const hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
|
|
170
315
|
const warning = hasMergedCellsInTable ? {
|
|
171
316
|
tooltipDescription: formatMessage(messages.canNotSortTable),
|
|
172
317
|
isDisabled: true
|
|
173
318
|
} : {};
|
|
174
|
-
|
|
319
|
+
return [{
|
|
175
320
|
content: formatMessage(messages.sortColumnASC),
|
|
176
321
|
value: {
|
|
177
322
|
name: 'sort_column_asc'
|
|
178
323
|
},
|
|
179
324
|
...warning
|
|
180
|
-
}
|
|
181
|
-
items.push({
|
|
325
|
+
}, {
|
|
182
326
|
content: formatMessage(messages.sortColumnDESC),
|
|
183
327
|
value: {
|
|
184
328
|
name: 'sort_column_desc'
|
|
185
329
|
},
|
|
186
330
|
...warning
|
|
187
|
-
}
|
|
331
|
+
}];
|
|
188
332
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
333
|
+
return null;
|
|
334
|
+
});
|
|
335
|
+
_defineProperty(this, "createOriginalContextMenuItems", () => {
|
|
336
|
+
let items = [];
|
|
337
|
+
const backgroundColorItem = this.createBackgroundColorItem();
|
|
338
|
+
backgroundColorItem && items.push(backgroundColorItem);
|
|
339
|
+
items.push(this.createInsertColumnItem());
|
|
340
|
+
items.push(this.createInsertRowItem());
|
|
341
|
+
items.push(this.createDeleteColumnItem());
|
|
342
|
+
items.push(this.createDeleteRowItem());
|
|
343
|
+
items.push(...this.createMergeSplitCellItems());
|
|
344
|
+
const distributeColumnsItem = this.createDistributeColumnsItem();
|
|
345
|
+
distributeColumnsItem && items.push(distributeColumnsItem);
|
|
346
|
+
const sortColumnItems = this.createSortColumnItems();
|
|
347
|
+
sortColumnItems && items.push(...sortColumnItems);
|
|
348
|
+
items.push(this.createClearCellsItem());
|
|
349
|
+
return [{
|
|
201
350
|
items
|
|
202
|
-
}]
|
|
351
|
+
}];
|
|
352
|
+
});
|
|
353
|
+
_defineProperty(this, "createNewContextMenuItems", () => {
|
|
354
|
+
const backgroundColorItem = this.createBackgroundColorItem();
|
|
355
|
+
const mergeSplitCellItems = this.createMergeSplitCellItems();
|
|
356
|
+
const insertColumnItem = this.createInsertColumnItem();
|
|
357
|
+
const insertRowItem = this.createInsertRowItem();
|
|
358
|
+
const clearCellsItem = this.createClearCellsItem();
|
|
359
|
+
const deleteColumnItem = this.createDeleteColumnItem();
|
|
360
|
+
const deleteRowItem = this.createDeleteRowItem();
|
|
361
|
+
|
|
362
|
+
// Group items so when table.menu.group-items FF is enabled, a divider shows under split cell, above add column
|
|
363
|
+
let items = [{
|
|
364
|
+
items: []
|
|
365
|
+
}, {
|
|
366
|
+
items: []
|
|
367
|
+
}];
|
|
368
|
+
backgroundColorItem && items[0].items.push(backgroundColorItem);
|
|
369
|
+
items[0].items.push(...mergeSplitCellItems);
|
|
370
|
+
items[1].items.push(insertColumnItem);
|
|
371
|
+
items[1].items.push(insertRowItem);
|
|
372
|
+
items[1].items.push(clearCellsItem);
|
|
373
|
+
items[1].items.push(deleteColumnItem);
|
|
374
|
+
items[1].items.push(deleteRowItem);
|
|
375
|
+
return items;
|
|
203
376
|
});
|
|
204
377
|
_defineProperty(this, "onMenuItemActivated", ({
|
|
205
378
|
item
|
|
@@ -369,12 +542,13 @@ export class ContextualMenu extends Component {
|
|
|
369
542
|
isOpen,
|
|
370
543
|
mountPoint,
|
|
371
544
|
offset,
|
|
372
|
-
boundariesElement
|
|
545
|
+
boundariesElement,
|
|
546
|
+
editorView
|
|
373
547
|
} = this.props;
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
548
|
+
const {
|
|
549
|
+
isDragAndDropEnabled
|
|
550
|
+
} = getPluginState(editorView.state);
|
|
551
|
+
const items = isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
378
552
|
return jsx("div", {
|
|
379
553
|
"data-testid": "table-cell-contextual-menu",
|
|
380
554
|
onMouseLeave: this.closeSubmenu
|
|
@@ -396,7 +570,10 @@ export class ContextualMenu extends Component {
|
|
|
396
570
|
fitHeight: 188,
|
|
397
571
|
fitWidth: contextualMenuDropdownWidth,
|
|
398
572
|
boundariesElement: boundariesElement,
|
|
399
|
-
offset: offset
|
|
573
|
+
offset: offset,
|
|
574
|
+
section: isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') && getBooleanFF('platform.editor.menu.group-items') ? {
|
|
575
|
+
hasSeparator: true
|
|
576
|
+
} : undefined
|
|
400
577
|
}));
|
|
401
578
|
}
|
|
402
579
|
}
|
|
@@ -46,4 +46,24 @@ export const tablePopupStyles = css`
|
|
|
46
46
|
color: ${`var(--ds-icon, ${N90})`};
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
.${ClassName.CONTEXTUAL_MENU_ICON_SMALL} {
|
|
51
|
+
display: flex;
|
|
52
|
+
|
|
53
|
+
&::before {
|
|
54
|
+
content: '';
|
|
55
|
+
display: block;
|
|
56
|
+
border: 1px solid ${tableBackgroundBorderColor};
|
|
57
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
58
|
+
width: 14px;
|
|
59
|
+
height: 14px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&::after {
|
|
63
|
+
content: '›';
|
|
64
|
+
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
65
|
+
line-height: 14px;
|
|
66
|
+
color: ${`var(--ds-icon, ${N90})`};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
49
69
|
`;
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -60,6 +60,11 @@ export const TABLE_SNAP_GAP = 9;
|
|
|
60
60
|
export const TABLE_HIGHLIGHT_GAP = 10;
|
|
61
61
|
export const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
62
62
|
export const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
63
|
+
// This adjustment value represents a pixel amount by which the container width needs to be adjusted when determining
|
|
64
|
+
// which guidelines are visible and most importantly CAN BE snapped too within the view. This value can be affected by
|
|
65
|
+
// table margins and padding. For example a guideline at 1800px and the view at 1860px wide, means the guidelines is visible
|
|
66
|
+
// BUT it cannot be snapped to during resize due to padding being applied to the resizer wrapper. This accommodates that difference.
|
|
67
|
+
export const TABLE_GUIDELINE_VISIBLE_ADJUSTMENT = -68;
|
|
63
68
|
export const dragMenuDropdownWidth = 240;
|
|
64
69
|
export const dragTableInsertColumnButtonSize = 16;
|
|
65
70
|
export const dropTargetExtendedWidth = 150;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const MergeCellsIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
3
|
+
width: "24",
|
|
4
|
+
height: "24",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
fill: "none",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
9
|
+
fillRule: "evenodd",
|
|
10
|
+
clipRule: "evenodd",
|
|
11
|
+
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",
|
|
12
|
+
fill: "currentColor"
|
|
13
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
14
|
+
d: "M15.75 10L13.75 12L15.75 14",
|
|
15
|
+
stroke: "currentColor",
|
|
16
|
+
strokeWidth: "1.5",
|
|
17
|
+
strokeLinecap: "round",
|
|
18
|
+
strokeLinejoin: "round"
|
|
19
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
d: "M8.25 14L10.25 12L8.25 10",
|
|
21
|
+
stroke: "currentColor",
|
|
22
|
+
strokeWidth: "1.5",
|
|
23
|
+
strokeLinecap: "round",
|
|
24
|
+
strokeLinejoin: "round"
|
|
25
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const SplitCellIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
3
|
+
width: "24",
|
|
4
|
+
height: "24",
|
|
5
|
+
viewBox: "0 0 24 24",
|
|
6
|
+
fill: "none",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
9
|
+
d: "M19 18L14 18L14 6L19 6",
|
|
10
|
+
stroke: "currentColor",
|
|
11
|
+
strokeWidth: "2",
|
|
12
|
+
strokeLinecap: "round",
|
|
13
|
+
strokeLinejoin: "round"
|
|
14
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
15
|
+
d: "M5 6L10 6L9.99999 18L5 18",
|
|
16
|
+
stroke: "currentColor",
|
|
17
|
+
strokeWidth: "2",
|
|
18
|
+
strokeLinecap: "round",
|
|
19
|
+
strokeLinejoin: "round"
|
|
20
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
21
|
+
d: "M7 10L5 12L7 14",
|
|
22
|
+
stroke: "currentColor",
|
|
23
|
+
strokeWidth: "1.5",
|
|
24
|
+
strokeLinecap: "round",
|
|
25
|
+
strokeLinejoin: "round"
|
|
26
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
d: "M17 14L19 12L17 10",
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
strokeWidth: "1.5",
|
|
30
|
+
strokeLinecap: "round",
|
|
31
|
+
strokeLinejoin: "round"
|
|
32
|
+
}));
|
|
@@ -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';
|
|
@@ -18,7 +18,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
|
18
18
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
19
19
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
20
20
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
21
|
-
import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
21
|
+
import { TABLE_GUIDELINE_VISIBLE_ADJUSTMENT, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '../ui/consts';
|
|
22
22
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
23
23
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
24
24
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
@@ -69,7 +69,7 @@ var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
|
69
69
|
*/
|
|
70
70
|
var getVisibleGuidelines = function getVisibleGuidelines(guidelines, containerWidth) {
|
|
71
71
|
return guidelines.filter(function (guideline) {
|
|
72
|
-
return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < containerWidth;
|
|
72
|
+
return guideline.position && guideline.position.x !== undefined && typeof guideline.position.x === 'number' && Math.abs(guideline.position.x * 2) < containerWidth + TABLE_GUIDELINE_VISIBLE_ADJUSTMENT;
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
75
|
export var TableResizer = function TableResizer(_ref) {
|