@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,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
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
4
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
5
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
6
5
|
import { contextualMenuDropdownWidth } from '../consts';
|
|
7
6
|
export const cellColourPreviewStyles = selectedColor => css`
|
|
@@ -14,7 +13,7 @@ export const cellColourPreviewStyles = selectedColor => css`
|
|
|
14
13
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
15
14
|
export const tablePopupStyles = css`
|
|
16
15
|
.${ClassName.CONTEXTUAL_SUBMENU} {
|
|
17
|
-
border-radius: ${
|
|
16
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
18
17
|
background: ${"var(--ds-surface-overlay, white)"};
|
|
19
18
|
box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
|
|
20
19
|
display: block;
|
|
@@ -35,7 +34,7 @@ export const tablePopupStyles = css`
|
|
|
35
34
|
content: '';
|
|
36
35
|
display: block;
|
|
37
36
|
border: 1px solid ${tableBackgroundBorderColor};
|
|
38
|
-
border-radius: ${
|
|
37
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
39
38
|
width: 20px;
|
|
40
39
|
height: 20px;
|
|
41
40
|
}
|
|
@@ -47,4 +46,24 @@ export const tablePopupStyles = css`
|
|
|
47
46
|
color: ${`var(--ds-icon, ${N90})`};
|
|
48
47
|
}
|
|
49
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
|
+
}
|
|
50
69
|
`;
|
|
@@ -94,7 +94,7 @@ export default class NumberColumn extends Component {
|
|
|
94
94
|
className: ClassName.NUMBERED_COLUMN,
|
|
95
95
|
style: {
|
|
96
96
|
marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined,
|
|
97
|
-
borderLeft: isDragAndDropEnabled && tableActive ? `1px solid ${tableBorderColor
|
|
97
|
+
borderLeft: isDragAndDropEnabled && tableActive ? `1px solid ${tableBorderColor}` : undefined
|
|
98
98
|
},
|
|
99
99
|
contentEditable: false
|
|
100
100
|
}, rowHeights.map((rowHeight, index) => isDragAndDropEnabled ? /*#__PURE__*/React.createElement("div", {
|