@atlaskit/editor-plugin-table 0.2.2 → 0.2.4
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 +26 -0
- package/dist/cjs/plugins/table/commands/hover.js +2 -1
- package/dist/cjs/plugins/table/event-handlers.js +9 -13
- package/dist/cjs/plugins/table/index.js +3 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +15 -5
- package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +42 -8
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/cjs/plugins/table/toolbar.js +42 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +7 -1
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +34 -6
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +4 -4
- package/dist/cjs/plugins/table/ui/ui-styles.js +5 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/hover.js +2 -1
- package/dist/es2019/plugins/table/event-handlers.js +10 -13
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +12 -1
- package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +31 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/es2019/plugins/table/toolbar.js +43 -12
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +6 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/styles.js +47 -8
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +9 -9
- package/dist/es2019/plugins/table/ui/consts.js +5 -5
- package/dist/es2019/plugins/table/ui/ui-styles.js +5 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/hover.js +2 -1
- package/dist/esm/plugins/table/event-handlers.js +10 -14
- package/dist/esm/plugins/table/index.js +3 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +17 -6
- package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +43 -8
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/esm/plugins/table/toolbar.js +43 -12
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +8 -2
- package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +28 -5
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/table/ui/consts.js +5 -5
- package/dist/esm/plugins/table/ui/ui-styles.js +5 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +8 -0
- package/dist/types/plugins/table/toolbar.d.ts +3 -2
- package/dist/types/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -1
- package/dist/types/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -2
- package/dist/types/plugins/table/ui/common-styles.d.ts +3 -3
- package/dist/types/plugins/table/ui/consts.d.ts +2 -2
- package/dist/types/plugins/table/ui/ui-styles.d.ts +14 -14
- package/package.json +4 -4
- package/src/__tests__/integration/__snapshots__/floating-toolbar.ts.snap +321 -0
- package/src/__tests__/integration/delete-last-column-in-full-width.ts +6 -5
- package/src/__tests__/integration/floating-toolbar.ts +169 -0
- package/src/__tests__/unit/get-toolbar-config.ts +1 -0
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +146 -4
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +82 -31
- package/src/__tests__/unit/toolbar.ts +165 -4
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +2 -2
- package/src/plugins/table/commands/hover.ts +1 -0
- package/src/plugins/table/event-handlers.ts +6 -17
- package/src/plugins/table/index.tsx +1 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +10 -2
- package/src/plugins/table/nodeviews/tableCell.tsx +1 -1
- package/src/plugins/table/pm-plugins/default-table-selection.ts +0 -1
- package/src/plugins/table/pm-plugins/main.ts +26 -28
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +44 -9
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +1 -1
- package/src/plugins/table/toolbar.tsx +60 -13
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +12 -2
- package/src/plugins/table/ui/FloatingContextualButton/styles.ts +51 -7
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +3 -0
- package/src/plugins/table/ui/common-styles.ts +24 -9
- package/src/plugins/table/ui/consts.ts +7 -5
- package/src/plugins/table/ui/ui-styles.ts +20 -5
|
@@ -125,34 +125,32 @@ export const createPlugin = (
|
|
|
125
125
|
})
|
|
126
126
|
: undefined;
|
|
127
127
|
|
|
128
|
-
const tableCellNodeview =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
: {};
|
|
128
|
+
const tableCellNodeview = {
|
|
129
|
+
tableCell: (
|
|
130
|
+
node: ProseMirrorNode,
|
|
131
|
+
view: EditorView,
|
|
132
|
+
getPos: getPosHandler,
|
|
133
|
+
) =>
|
|
134
|
+
new TableCellNodeView(
|
|
135
|
+
node,
|
|
136
|
+
view,
|
|
137
|
+
getPos,
|
|
138
|
+
getEditorFeatureFlags,
|
|
139
|
+
observer,
|
|
140
|
+
),
|
|
141
|
+
tableHeader: (
|
|
142
|
+
node: ProseMirrorNode,
|
|
143
|
+
view: EditorView,
|
|
144
|
+
getPos: getPosHandler,
|
|
145
|
+
) =>
|
|
146
|
+
new TableCellNodeView(
|
|
147
|
+
node,
|
|
148
|
+
view,
|
|
149
|
+
getPos,
|
|
150
|
+
getEditorFeatureFlags,
|
|
151
|
+
observer,
|
|
152
|
+
),
|
|
153
|
+
};
|
|
156
154
|
|
|
157
155
|
// Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
158
156
|
const invalidTableIds: string[] = [];
|
|
@@ -33,19 +33,51 @@ import throttle from 'lodash/throttle';
|
|
|
33
33
|
const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
34
34
|
|
|
35
35
|
// timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
36
|
-
// if too short it would trigger too many dom
|
|
36
|
+
// if too short it would trigger too many dom updates.
|
|
37
37
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
38
38
|
|
|
39
|
+
const anyChildCellMergedAcrossRow = (node: PmNode) =>
|
|
40
|
+
mapChildren(node, (child) => child.attrs.rowspan || 0).some(
|
|
41
|
+
(rowspan) => rowspan > 1,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Compare two table row nodes and return true if the two table rows have a
|
|
46
|
+
* different number of table cells or if table cell row spans are different
|
|
47
|
+
*/
|
|
48
|
+
const rowHasDifferentMergedCells = (prevNode: PmNode, incomingNode: PmNode) => {
|
|
49
|
+
const incomingNodeChildrenRowSpan = mapChildren(
|
|
50
|
+
prevNode,
|
|
51
|
+
(child) => child.attrs.rowspan || 0,
|
|
52
|
+
);
|
|
53
|
+
const currentNodeChildrenRowSpan = mapChildren(
|
|
54
|
+
incomingNode,
|
|
55
|
+
(child) => child.attrs.rowspan || 0,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
incomingNodeChildrenRowSpan.length !== currentNodeChildrenRowSpan.length ||
|
|
60
|
+
currentNodeChildrenRowSpan.some(
|
|
61
|
+
(child, index) => child !== incomingNodeChildrenRowSpan[index],
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if a given node is a header row with this definition:
|
|
68
|
+
* - all children are tableHeader cells
|
|
69
|
+
* - no table cells have been have merged with other table row cells
|
|
70
|
+
*
|
|
71
|
+
* @param node ProseMirror node
|
|
72
|
+
* @return boolean if it meets definition
|
|
73
|
+
*/
|
|
39
74
|
export const supportedHeaderRow = (node: PmNode) => {
|
|
40
75
|
const allHeaders = mapChildren(
|
|
41
76
|
node,
|
|
42
77
|
(child) => child.type.name === 'tableHeader',
|
|
43
78
|
).every(Boolean);
|
|
44
79
|
|
|
45
|
-
const someMerged =
|
|
46
|
-
node,
|
|
47
|
-
(child) => child.attrs.rowspan || 0,
|
|
48
|
-
).some((rowspan) => rowspan > 1);
|
|
80
|
+
const someMerged = anyChildCellMergedAcrossRow(node);
|
|
49
81
|
|
|
50
82
|
return allHeaders && !someMerged;
|
|
51
83
|
};
|
|
@@ -297,8 +329,8 @@ export class TableRowNodeView implements NodeView {
|
|
|
297
329
|
{ root: this.editorScrollableElement as Element },
|
|
298
330
|
);
|
|
299
331
|
}
|
|
300
|
-
/* paint/update loop */
|
|
301
332
|
|
|
333
|
+
/* paint/update loop */
|
|
302
334
|
previousDomTop: number | undefined;
|
|
303
335
|
previousPadding: number | undefined;
|
|
304
336
|
|
|
@@ -367,7 +399,6 @@ export class TableRowNodeView implements NodeView {
|
|
|
367
399
|
};
|
|
368
400
|
|
|
369
401
|
/* nodeview lifecycle */
|
|
370
|
-
|
|
371
402
|
update(node: PmNode, ..._args: any[]) {
|
|
372
403
|
// do nothing if nodes were identical
|
|
373
404
|
if (node === this.node) {
|
|
@@ -376,11 +407,15 @@ export class TableRowNodeView implements NodeView {
|
|
|
376
407
|
|
|
377
408
|
// see if we're changing into a header row or
|
|
378
409
|
// changing away from one
|
|
379
|
-
const
|
|
380
|
-
if (this.isHeaderRow !==
|
|
410
|
+
const newNodeIsHeaderRow = supportedHeaderRow(node);
|
|
411
|
+
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
381
412
|
return false; // re-create nodeview
|
|
382
413
|
}
|
|
383
414
|
|
|
415
|
+
if (rowHasDifferentMergedCells(this.node, node)) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
|
|
384
419
|
// node is different but no need to re-create nodeview
|
|
385
420
|
this.node = node;
|
|
386
421
|
|
|
@@ -33,7 +33,7 @@ export const shrinkColumn = (
|
|
|
33
33
|
selectedColumns?: number[],
|
|
34
34
|
): ResizeState => {
|
|
35
35
|
// can't shrink if columns don't exist
|
|
36
|
-
if (!state.cols[colIndex]
|
|
36
|
+
if (!state.cols[colIndex]) {
|
|
37
37
|
return state;
|
|
38
38
|
}
|
|
39
39
|
// try to shrink dragging column by giving from the column to the right first
|
|
@@ -7,6 +7,7 @@ import commonMessages from '@atlaskit/editor-common/messages';
|
|
|
7
7
|
import type {
|
|
8
8
|
Command,
|
|
9
9
|
CommandDispatch,
|
|
10
|
+
DropdownOptionT,
|
|
10
11
|
FloatingToolbarDropdown,
|
|
11
12
|
FloatingToolbarHandler,
|
|
12
13
|
FloatingToolbarItem,
|
|
@@ -15,7 +16,12 @@ import type {
|
|
|
15
16
|
|
|
16
17
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
17
18
|
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
clearHoverSelection,
|
|
21
|
+
hoverTable,
|
|
22
|
+
hoverColumns,
|
|
23
|
+
hoverRows,
|
|
24
|
+
} from './commands';
|
|
19
25
|
import {
|
|
20
26
|
deleteTableWithAnalytics,
|
|
21
27
|
toggleHeaderColumnWithAnalytics,
|
|
@@ -43,7 +49,11 @@ import {
|
|
|
43
49
|
PluginConfig,
|
|
44
50
|
TableCssClassName,
|
|
45
51
|
} from './types';
|
|
46
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
getMergedCellsPositions,
|
|
54
|
+
getSelectedColumnIndexes,
|
|
55
|
+
getSelectedRowIndexes,
|
|
56
|
+
} from './utils';
|
|
47
57
|
import { isReferencedSource } from './utils/referentiality';
|
|
48
58
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
49
59
|
import {
|
|
@@ -76,6 +86,7 @@ import {
|
|
|
76
86
|
cellBackgroundColorPalette,
|
|
77
87
|
DEFAULT_BORDER_COLOR,
|
|
78
88
|
} from '@atlaskit/editor-common/ui-color';
|
|
89
|
+
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
79
90
|
|
|
80
91
|
export const messages = defineMessages({
|
|
81
92
|
tableOptions: {
|
|
@@ -157,6 +168,7 @@ export const getToolbarMenuConfig = (
|
|
|
157
168
|
// with native widgets. It's enabled via a plugin config.
|
|
158
169
|
export const getToolbarCellOptionsConfig = (
|
|
159
170
|
editorState: EditorState,
|
|
171
|
+
editorView: EditorView | undefined | null,
|
|
160
172
|
initialSelectionRect: Rect,
|
|
161
173
|
{ formatMessage }: ToolbarMenuContext,
|
|
162
174
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
@@ -167,7 +179,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
167
179
|
const numberOfRows = bottom - top;
|
|
168
180
|
const pluginState = getPluginState(editorState);
|
|
169
181
|
|
|
170
|
-
const options = [
|
|
182
|
+
const options: DropdownOptionT<Command>[] = [
|
|
171
183
|
{
|
|
172
184
|
id: 'editor.table.insertColumn',
|
|
173
185
|
title: formatMessage(tableMessages.insertColumn),
|
|
@@ -227,6 +239,18 @@ export const getToolbarCellOptionsConfig = (
|
|
|
227
239
|
}
|
|
228
240
|
return true;
|
|
229
241
|
},
|
|
242
|
+
onMouseOver: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
243
|
+
const selectionRect = getClosestSelectionRect(state);
|
|
244
|
+
if (selectionRect) {
|
|
245
|
+
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(
|
|
246
|
+
state,
|
|
247
|
+
dispatch,
|
|
248
|
+
);
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
},
|
|
253
|
+
onMouseLeave: clearHoverSelection(),
|
|
230
254
|
selected: false,
|
|
231
255
|
disabled: false,
|
|
232
256
|
},
|
|
@@ -246,6 +270,18 @@ export const getToolbarCellOptionsConfig = (
|
|
|
246
270
|
}
|
|
247
271
|
return true;
|
|
248
272
|
},
|
|
273
|
+
onMouseOver: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
274
|
+
const selectionRect = getClosestSelectionRect(state);
|
|
275
|
+
if (selectionRect) {
|
|
276
|
+
hoverRows(getSelectedRowIndexes(selectionRect), true)(
|
|
277
|
+
state,
|
|
278
|
+
dispatch,
|
|
279
|
+
);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
},
|
|
284
|
+
onMouseLeave: clearHoverSelection(),
|
|
249
285
|
selected: false,
|
|
250
286
|
disabled: false,
|
|
251
287
|
},
|
|
@@ -270,16 +306,17 @@ export const getToolbarCellOptionsConfig = (
|
|
|
270
306
|
];
|
|
271
307
|
|
|
272
308
|
if (pluginState?.pluginConfig?.allowDistributeColumns) {
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
309
|
+
const newResizeStateWithAnalytics = editorView
|
|
310
|
+
? getNewResizeStateFromSelectedColumns(
|
|
311
|
+
initialSelectionRect,
|
|
312
|
+
editorState,
|
|
313
|
+
editorView.domAtPos.bind(editorView),
|
|
314
|
+
getEditorContainerWidth,
|
|
315
|
+
)
|
|
316
|
+
: undefined;
|
|
317
|
+
const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
|
|
282
318
|
|
|
319
|
+
const distributeColumnWidths: Command = (state, dispatch) => {
|
|
283
320
|
if (newResizeStateWithAnalytics) {
|
|
284
321
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(
|
|
285
322
|
INPUT_METHOD.FLOATING_TB,
|
|
@@ -295,13 +332,16 @@ export const getToolbarCellOptionsConfig = (
|
|
|
295
332
|
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
296
333
|
onClick: distributeColumnWidths,
|
|
297
334
|
selected: false,
|
|
298
|
-
disabled:
|
|
335
|
+
disabled: !wouldChange,
|
|
299
336
|
});
|
|
300
337
|
}
|
|
301
338
|
|
|
302
339
|
if (pluginState?.pluginConfig?.allowColumnSorting) {
|
|
303
340
|
const hasMergedCellsInTable =
|
|
304
341
|
getMergedCellsPositions(editorState.tr).length > 0;
|
|
342
|
+
const warning = hasMergedCellsInTable
|
|
343
|
+
? formatMessage(ContextualMenuMessages.canNotSortTable)
|
|
344
|
+
: undefined;
|
|
305
345
|
|
|
306
346
|
options.push({
|
|
307
347
|
id: 'editor.table.sortColumnAsc',
|
|
@@ -316,6 +356,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
316
356
|
},
|
|
317
357
|
selected: false,
|
|
318
358
|
disabled: hasMergedCellsInTable,
|
|
359
|
+
tooltip: warning,
|
|
319
360
|
});
|
|
320
361
|
|
|
321
362
|
options.push({
|
|
@@ -331,6 +372,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
331
372
|
},
|
|
332
373
|
selected: false,
|
|
333
374
|
disabled: hasMergedCellsInTable,
|
|
375
|
+
tooltip: warning,
|
|
334
376
|
});
|
|
335
377
|
}
|
|
336
378
|
|
|
@@ -375,6 +417,7 @@ export const getToolbarConfig =
|
|
|
375
417
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
376
418
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
377
419
|
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
420
|
+
getEditorView: () => EditorView | null,
|
|
378
421
|
) =>
|
|
379
422
|
(config: PluginConfig): FloatingToolbarHandler =>
|
|
380
423
|
(state, intl) => {
|
|
@@ -396,6 +439,7 @@ export const getToolbarConfig =
|
|
|
396
439
|
const cellItems = getCellItems(
|
|
397
440
|
config,
|
|
398
441
|
state,
|
|
442
|
+
getEditorView(),
|
|
399
443
|
intl,
|
|
400
444
|
getEditorContainerWidth,
|
|
401
445
|
editorAnalyticsAPI,
|
|
@@ -453,6 +497,7 @@ export const getToolbarConfig =
|
|
|
453
497
|
getDomRef,
|
|
454
498
|
nodeType,
|
|
455
499
|
offset: [0, 3],
|
|
500
|
+
zIndex: akEditorFloatingPanelZIndex + 1, // Place the context menu slightly above the others
|
|
456
501
|
items: [
|
|
457
502
|
menu,
|
|
458
503
|
separator(menu.hidden),
|
|
@@ -504,6 +549,7 @@ const separator = (hidden?: boolean): FloatingToolbarItem<Command> => {
|
|
|
504
549
|
const getCellItems = (
|
|
505
550
|
pluginConfig: PluginConfig,
|
|
506
551
|
state: EditorState,
|
|
552
|
+
view: EditorView | null,
|
|
507
553
|
{ formatMessage }: ToolbarMenuContext,
|
|
508
554
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
509
555
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
@@ -517,6 +563,7 @@ const getCellItems = (
|
|
|
517
563
|
if (initialSelectionRect) {
|
|
518
564
|
const cellOptions = getToolbarCellOptionsConfig(
|
|
519
565
|
state,
|
|
566
|
+
view,
|
|
520
567
|
initialSelectionRect,
|
|
521
568
|
{ formatMessage },
|
|
522
569
|
getEditorContainerWidth,
|
|
@@ -32,9 +32,13 @@ import {
|
|
|
32
32
|
ACTION_SUBJECT,
|
|
33
33
|
EVENT_TYPE,
|
|
34
34
|
} from '@atlaskit/editor-common/analytics';
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
tableFloatingCellButtonStyles,
|
|
37
|
+
tableFloatingCellButtonSelectedStyles,
|
|
38
|
+
} from './styles';
|
|
36
39
|
import { Node as PMNode } from 'prosemirror-model';
|
|
37
40
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
41
|
+
import { ThemeProps } from '@atlaskit/theme/types';
|
|
38
42
|
|
|
39
43
|
export interface Props {
|
|
40
44
|
editorView: EditorView;
|
|
@@ -103,7 +107,13 @@ export class FloatingContextualButtonInner extends React.Component<
|
|
|
103
107
|
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
104
108
|
|
|
105
109
|
const button = (
|
|
106
|
-
<div
|
|
110
|
+
<div
|
|
111
|
+
css={(theme: ThemeProps) => [
|
|
112
|
+
tableFloatingCellButtonStyles({ theme }),
|
|
113
|
+
isContextualMenuOpen &&
|
|
114
|
+
tableFloatingCellButtonSelectedStyles({ theme }),
|
|
115
|
+
]}
|
|
116
|
+
>
|
|
107
117
|
<ToolbarButton
|
|
108
118
|
className={ClassName.CONTEXTUAL_MENU_BUTTON}
|
|
109
119
|
selected={isContextualMenuOpen}
|
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import { N0, N20 } from '@atlaskit/theme/colors';
|
|
2
|
+
import { B75, DN0, DN60, N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
|
|
3
3
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
4
4
|
import { contextualMenuTriggerSize } from '../consts';
|
|
5
5
|
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { themed } from '@atlaskit/theme/components';
|
|
7
|
+
import { ThemeProps } from '@atlaskit/theme/types';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
export const tableFloatingCellButtonStyles = css`
|
|
9
|
+
export const tableFloatingCellButtonStyles = (props: ThemeProps) => css`
|
|
9
10
|
> div {
|
|
10
|
-
|
|
11
|
+
// Sits behind button to provide surface-color background
|
|
12
|
+
background: ${token('elevation.surface', N20)};
|
|
11
13
|
border-radius: ${borderRadius()}px;
|
|
12
|
-
border: 2px solid ${token('color.border.inverse', N0)};
|
|
13
14
|
display: flex;
|
|
14
|
-
height: ${contextualMenuTriggerSize
|
|
15
|
+
height: ${contextualMenuTriggerSize + 2}px;
|
|
15
16
|
flex-direction: column;
|
|
16
17
|
}
|
|
17
18
|
&& button {
|
|
19
|
+
background: ${themed({
|
|
20
|
+
light: token('color.background.neutral', 'none'),
|
|
21
|
+
dark: token('color.background.neutral', 'none'),
|
|
22
|
+
})(props)};
|
|
18
23
|
flex-direction: column;
|
|
24
|
+
margin: 2px;
|
|
25
|
+
outline: 2px solid ${token('color.border', N0)};
|
|
26
|
+
border-radius: 1px;
|
|
19
27
|
padding: 0;
|
|
20
|
-
height: 100
|
|
28
|
+
height: calc(100% - 4px);
|
|
21
29
|
display: flex;
|
|
22
30
|
}
|
|
31
|
+
&& button:hover {
|
|
32
|
+
background: ${themed({
|
|
33
|
+
light: token('color.background.neutral.hovered', N30A),
|
|
34
|
+
dark: token('color.background.neutral.hovered', DN60),
|
|
35
|
+
})(props)};
|
|
36
|
+
}
|
|
37
|
+
&& button:active {
|
|
38
|
+
background: ${themed({
|
|
39
|
+
light: token(
|
|
40
|
+
'color.background.neutral.pressed',
|
|
41
|
+
'rgba(179, 212, 255, 0.6)',
|
|
42
|
+
),
|
|
43
|
+
dark: token('color.background.neutral.pressed', B75),
|
|
44
|
+
})(props)};
|
|
45
|
+
}
|
|
23
46
|
&& button > span {
|
|
24
47
|
margin: 0px -4px;
|
|
25
48
|
}
|
|
@@ -27,3 +50,24 @@ export const tableFloatingCellButtonStyles = css`
|
|
|
27
50
|
pointer-events: none;
|
|
28
51
|
}
|
|
29
52
|
`;
|
|
53
|
+
|
|
54
|
+
export const tableFloatingCellButtonSelectedStyles = (props: ThemeProps) => css`
|
|
55
|
+
&& button {
|
|
56
|
+
background: ${themed({
|
|
57
|
+
light: token('color.background.selected', N700),
|
|
58
|
+
dark: token('color.background.selected', DN0),
|
|
59
|
+
})(props)};
|
|
60
|
+
}
|
|
61
|
+
&& button:hover {
|
|
62
|
+
background: ${themed({
|
|
63
|
+
light: token('color.background.selected.hovered', N700),
|
|
64
|
+
dark: token('color.background.selected.hovered', DN0),
|
|
65
|
+
})(props)};
|
|
66
|
+
}
|
|
67
|
+
&& button:active {
|
|
68
|
+
background: ${themed({
|
|
69
|
+
light: token('color.background.selected.pressed', N700),
|
|
70
|
+
dark: token('color.background.selected.pressed', DN0),
|
|
71
|
+
})(props)};
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
@@ -159,6 +159,9 @@ export class ContextualMenu extends Component<
|
|
|
159
159
|
>
|
|
160
160
|
<DropdownMenu
|
|
161
161
|
mountTo={mountPoint}
|
|
162
|
+
//This needs be removed when the a11y is completely handled
|
|
163
|
+
//Disabling key navigation now as it works only partially
|
|
164
|
+
disableArrowKeyNavigation={true}
|
|
162
165
|
items={items}
|
|
163
166
|
isOpen={isOpen}
|
|
164
167
|
onOpenChange={this.handleOpenChange}
|
|
@@ -427,7 +427,10 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
427
427
|
}
|
|
428
428
|
.active .${ClassName.CONTROLS_CORNER_BUTTON} {
|
|
429
429
|
border-color: ${tableBorderSelectedColor};
|
|
430
|
-
background: ${
|
|
430
|
+
background: ${token(
|
|
431
|
+
'color.background.selected',
|
|
432
|
+
tableToolbarSelectedColor,
|
|
433
|
+
)};
|
|
431
434
|
}
|
|
432
435
|
|
|
433
436
|
.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
@@ -441,14 +444,17 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
441
444
|
|
|
442
445
|
:not(.${ClassName.IS_RESIZING}) .${ClassName.CONTROLS_CORNER_BUTTON}:hover {
|
|
443
446
|
border-color: ${tableBorderSelectedColor};
|
|
444
|
-
background: ${
|
|
447
|
+
background: ${token(
|
|
448
|
+
'color.background.selected',
|
|
449
|
+
tableToolbarSelectedColor,
|
|
450
|
+
)};
|
|
445
451
|
cursor: pointer;
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
:not(.${ClassName.IS_RESIZING})
|
|
449
455
|
.${ClassName.CONTROLS_CORNER_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
|
|
450
456
|
border-color: ${tableBorderDeleteColor};
|
|
451
|
-
background: ${tableToolbarDeleteColor};
|
|
457
|
+
background: ${token('color.background.danger', tableToolbarDeleteColor)};
|
|
452
458
|
}
|
|
453
459
|
|
|
454
460
|
/* Row controls */
|
|
@@ -555,10 +561,13 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
555
561
|
.${ClassName.NUMBERED_COLUMN_BUTTON}.active {
|
|
556
562
|
border-bottom: 1px solid ${tableBorderSelectedColor};
|
|
557
563
|
border-color: ${tableBorderSelectedColor};
|
|
558
|
-
background-color: ${
|
|
564
|
+
background-color: ${token(
|
|
565
|
+
'color.background.selected',
|
|
566
|
+
tableToolbarSelectedColor,
|
|
567
|
+
)};
|
|
559
568
|
position: relative;
|
|
560
569
|
z-index: ${akEditorUnitZIndex};
|
|
561
|
-
color: ${token('color.text.
|
|
570
|
+
color: ${token('color.text.selected', N0)};
|
|
562
571
|
}
|
|
563
572
|
}
|
|
564
573
|
}
|
|
@@ -569,16 +578,22 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
569
578
|
.${ClassName.NUMBERED_COLUMN_BUTTON}:hover {
|
|
570
579
|
border-bottom: 1px solid ${tableBorderSelectedColor};
|
|
571
580
|
border-color: ${tableBorderSelectedColor};
|
|
572
|
-
background-color: ${
|
|
581
|
+
background-color: ${token(
|
|
582
|
+
'color.background.selected',
|
|
583
|
+
tableToolbarSelectedColor,
|
|
584
|
+
)};
|
|
573
585
|
position: relative;
|
|
574
586
|
z-index: ${akEditorUnitZIndex};
|
|
575
|
-
color: ${token('color.text.
|
|
587
|
+
color: ${token('color.text.selected', N0)};
|
|
576
588
|
}
|
|
577
589
|
.${ClassName.NUMBERED_COLUMN_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
|
|
578
|
-
background-color: ${
|
|
590
|
+
background-color: ${token(
|
|
591
|
+
'color.background.danger',
|
|
592
|
+
tableToolbarDeleteColor,
|
|
593
|
+
)};
|
|
579
594
|
border: 1px solid ${tableBorderDeleteColor};
|
|
580
595
|
border-left: 0;
|
|
581
|
-
color: ${token('color.text.
|
|
596
|
+
color: ${token('color.text.danger', R500)};
|
|
582
597
|
position: relative;
|
|
583
598
|
z-index: ${akEditorUnitZIndex};
|
|
584
599
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
B200,
|
|
3
3
|
B300,
|
|
4
|
-
N0,
|
|
5
4
|
N20,
|
|
6
5
|
R400,
|
|
7
6
|
R75,
|
|
8
7
|
DN400,
|
|
9
8
|
N200,
|
|
10
9
|
DN30,
|
|
10
|
+
N0,
|
|
11
11
|
} from '@atlaskit/theme/colors';
|
|
12
12
|
import {
|
|
13
13
|
tableCellBorderWidth,
|
|
@@ -34,11 +34,13 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
34
34
|
|
|
35
35
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4135
|
|
36
36
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
37
|
-
export const tableCellBackgroundColor = themed({
|
|
38
|
-
|
|
37
|
+
export const tableCellBackgroundColor = themed({
|
|
38
|
+
light: token('elevation.surface', N0),
|
|
39
|
+
dark: token('elevation.surface', DN30),
|
|
40
|
+
});
|
|
39
41
|
export const tableToolbarColor = themed({
|
|
40
|
-
light: akEditorTableToolbar,
|
|
41
|
-
dark: akEditorTableToolbarDark,
|
|
42
|
+
light: token('color.background.neutral.subtle', akEditorTableToolbar),
|
|
43
|
+
dark: token('color.background.neutral.subtle', akEditorTableToolbarDark),
|
|
42
44
|
});
|
|
43
45
|
export const tableTextColor = themed({
|
|
44
46
|
light: token('color.text.subtlest', N200),
|
|
@@ -120,7 +120,10 @@ export const HeaderButton = (props: ThemeProps, cssString?: string) => css`
|
|
|
120
120
|
|
|
121
121
|
.active .${ClassName.CONTROLS_BUTTON} {
|
|
122
122
|
color: ${token('color.icon.inverse', N0)};
|
|
123
|
-
background-color: ${
|
|
123
|
+
background-color: ${token(
|
|
124
|
+
'color.background.selected',
|
|
125
|
+
tableToolbarSelectedColor,
|
|
126
|
+
)};
|
|
124
127
|
border-color: ${tableBorderSelectedColor};
|
|
125
128
|
}
|
|
126
129
|
`;
|
|
@@ -128,7 +131,10 @@ export const HeaderButton = (props: ThemeProps, cssString?: string) => css`
|
|
|
128
131
|
export const HeaderButtonHover = () => css`
|
|
129
132
|
.${ClassName.CONTROLS_BUTTON}:hover {
|
|
130
133
|
color: ${token('color.icon.inverse', N0)};
|
|
131
|
-
background-color: ${
|
|
134
|
+
background-color: ${token(
|
|
135
|
+
'color.background.selected',
|
|
136
|
+
tableToolbarSelectedColor,
|
|
137
|
+
)};
|
|
132
138
|
border-color: ${tableBorderSelectedColor};
|
|
133
139
|
cursor: pointer;
|
|
134
140
|
}
|
|
@@ -136,7 +142,10 @@ export const HeaderButtonHover = () => css`
|
|
|
136
142
|
|
|
137
143
|
export const HeaderButtonDanger = () => css`
|
|
138
144
|
.${ClassName.HOVERED_CELL_IN_DANGER} .${ClassName.CONTROLS_BUTTON} {
|
|
139
|
-
background-color: ${
|
|
145
|
+
background-color: ${token(
|
|
146
|
+
'color.background.danger',
|
|
147
|
+
tableToolbarDeleteColor,
|
|
148
|
+
)};
|
|
140
149
|
border-color: ${tableBorderDeleteColor};
|
|
141
150
|
position: relative;
|
|
142
151
|
z-index: ${akEditorUnitZIndex};
|
|
@@ -291,7 +300,10 @@ const columnHeaderButton = (props: ThemeProps, cssString?: string) => css`
|
|
|
291
300
|
|
|
292
301
|
const columnHeaderButtonSelected = css`
|
|
293
302
|
color: ${token('color.text.inverse', N0)};
|
|
294
|
-
background-color: ${
|
|
303
|
+
background-color: ${token(
|
|
304
|
+
'color.background.selected',
|
|
305
|
+
tableToolbarSelectedColor,
|
|
306
|
+
)};
|
|
295
307
|
border-color: ${tableBorderSelectedColor};
|
|
296
308
|
z-index: ${columnControlsSelectedZIndex};
|
|
297
309
|
`;
|
|
@@ -370,7 +382,10 @@ export const columnControlsDecoration = (props: ThemeProps) => css`
|
|
|
370
382
|
|
|
371
383
|
&.${ClassName.HOVERED_CELL_IN_DANGER}
|
|
372
384
|
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::after {
|
|
373
|
-
background-color: ${
|
|
385
|
+
background-color: ${token(
|
|
386
|
+
'color.background.danger',
|
|
387
|
+
tableToolbarDeleteColor,
|
|
388
|
+
)};
|
|
374
389
|
border: 1px solid ${tableBorderDeleteColor};
|
|
375
390
|
border-bottom: none;
|
|
376
391
|
z-index: ${akEditorUnitZIndex * 100};
|