@atlaskit/editor-plugin-table 0.1.2 → 0.2.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 +21 -0
- package/dist/cjs/plugins/table/commands/misc.js +4 -2
- package/dist/cjs/plugins/table/create-plugin-config.js +0 -1
- package/dist/cjs/plugins/table/event-handlers.js +5 -6
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -5
- package/dist/cjs/plugins/table/reducer.js +3 -2
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +8 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +4 -4
- package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
- package/dist/cjs/plugins/table/utils/decoration.js +16 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +4 -2
- package/dist/es2019/plugins/table/create-plugin-config.js +0 -1
- package/dist/es2019/plugins/table/event-handlers.js +6 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -8
- package/dist/es2019/plugins/table/reducer.js +3 -2
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +16 -17
- package/dist/es2019/plugins/table/ui/ui-styles.js +67 -24
- package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
- package/dist/es2019/plugins/table/utils/decoration.js +16 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/misc.js +4 -2
- package/dist/esm/plugins/table/create-plugin-config.js +0 -1
- package/dist/esm/plugins/table/event-handlers.js +6 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -8
- package/dist/esm/plugins/table/reducer.js +3 -2
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/common-styles.js +8 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +5 -5
- package/dist/esm/plugins/table/utils/column-controls.js +1 -1
- package/dist/esm/plugins/table/utils/decoration.js +16 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +3 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +1 -1
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +5 -4
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +8 -0
- package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +5228 -0
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +3 -0
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +3 -0
- package/src/__tests__/visual-regression/cell-options-menu.ts +110 -99
- package/src/__tests__/visual-regression/index.ts +56 -44
- package/src/__tests__/visual-regression/sticky-header.ts +55 -0
- package/src/plugins/table/commands/misc.ts +10 -2
- package/src/plugins/table/create-plugin-config.ts +0 -1
- package/src/plugins/table/event-handlers.ts +9 -7
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +4 -2
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +5 -11
- package/src/plugins/table/reducer.ts +3 -1
- package/src/plugins/table/types.ts +7 -2
- package/src/plugins/table/ui/common-styles.ts +16 -20
- package/src/plugins/table/ui/ui-styles.ts +66 -25
- package/src/plugins/table/utils/column-controls.ts +1 -1
- package/src/plugins/table/utils/decoration.ts +17 -4
|
@@ -1,99 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
import {
|
|
2
|
+
PuppeteerPage,
|
|
3
|
+
waitForNoTooltip,
|
|
4
|
+
} from '@atlaskit/visual-regression/helper';
|
|
5
|
+
import { insertTable } from '@atlaskit/editor-test-helpers/page-objects/table';
|
|
6
|
+
import {
|
|
7
|
+
snapshot,
|
|
8
|
+
initFullPageEditorWithAdf,
|
|
9
|
+
} from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
|
|
10
|
+
|
|
11
|
+
const firstCellSelector = 'table tbody th p';
|
|
12
|
+
const cellOptionsSelector = '[aria-label="Cell options"]';
|
|
13
|
+
const deleteColumnCellOptionSelector = '[aria-label="Delete column"]';
|
|
14
|
+
const deleteRowCellOptionSelector = '[aria-label="Delete row"]';
|
|
15
|
+
|
|
16
|
+
const emptyDocAdf = {
|
|
17
|
+
version: 1,
|
|
18
|
+
type: 'doc',
|
|
19
|
+
content: [],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('Table cell options menu', () => {
|
|
23
|
+
let page: PuppeteerPage;
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
page = global.page;
|
|
27
|
+
await initFullPageEditorWithAdf(
|
|
28
|
+
page,
|
|
29
|
+
emptyDocAdf,
|
|
30
|
+
undefined,
|
|
31
|
+
undefined,
|
|
32
|
+
{},
|
|
33
|
+
undefined,
|
|
34
|
+
undefined,
|
|
35
|
+
true,
|
|
36
|
+
false,
|
|
37
|
+
undefined,
|
|
38
|
+
{
|
|
39
|
+
group: 'editor',
|
|
40
|
+
packageName: 'editor-plugin-table',
|
|
41
|
+
exampleName: 'testing',
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
await insertTable(page);
|
|
45
|
+
page.waitForSelector(firstCellSelector);
|
|
46
|
+
|
|
47
|
+
// move the focus to the first table cell
|
|
48
|
+
await page.type(firstCellSelector, 'focus table cell');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('delete column menu item', () => {
|
|
52
|
+
it('visual hints should be added to the table column on hover', async () => {
|
|
53
|
+
// open the table cell options menu
|
|
54
|
+
await page.waitForSelector(cellOptionsSelector);
|
|
55
|
+
await page.click(cellOptionsSelector);
|
|
56
|
+
|
|
57
|
+
// hover over the table cell options Delete column entry
|
|
58
|
+
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
59
|
+
await page.hover(deleteColumnCellOptionSelector);
|
|
60
|
+
|
|
61
|
+
await waitForNoTooltip(page);
|
|
62
|
+
|
|
63
|
+
await snapshot(page);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should remove the table column on click', async () => {
|
|
67
|
+
// open the table cell options menu
|
|
68
|
+
await page.waitForSelector(cellOptionsSelector);
|
|
69
|
+
await page.click(cellOptionsSelector);
|
|
70
|
+
|
|
71
|
+
// click the table cell options Delete column entry
|
|
72
|
+
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
73
|
+
await page.click(deleteColumnCellOptionSelector);
|
|
74
|
+
|
|
75
|
+
await waitForNoTooltip(page);
|
|
76
|
+
|
|
77
|
+
await snapshot(page);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('delete row menu item', () => {
|
|
82
|
+
it('visual hints should be added to the table row on hover', async () => {
|
|
83
|
+
// open the table cell options menu
|
|
84
|
+
await page.waitForSelector(cellOptionsSelector);
|
|
85
|
+
await page.click(cellOptionsSelector);
|
|
86
|
+
|
|
87
|
+
// hover over the table cell options Delete row entry
|
|
88
|
+
await page.waitForSelector(deleteRowCellOptionSelector);
|
|
89
|
+
await page.hover(deleteRowCellOptionSelector);
|
|
90
|
+
|
|
91
|
+
await waitForNoTooltip(page);
|
|
92
|
+
|
|
93
|
+
await snapshot(page);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should remove the table row on click', async () => {
|
|
97
|
+
// open the table cell options menu
|
|
98
|
+
await page.waitForSelector(cellOptionsSelector);
|
|
99
|
+
await page.click(cellOptionsSelector);
|
|
100
|
+
|
|
101
|
+
// click the table cell options Delete row entry
|
|
102
|
+
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
103
|
+
await page.click(deleteRowCellOptionSelector);
|
|
104
|
+
|
|
105
|
+
await waitForNoTooltip(page);
|
|
106
|
+
|
|
107
|
+
await snapshot(page);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
1
|
+
import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
|
|
2
|
+
import { Device } from '@atlaskit/editor-test-helpers/vr-utils/device-viewport';
|
|
3
|
+
import {
|
|
4
|
+
snapshot,
|
|
5
|
+
initFullPageEditorWithAdf,
|
|
6
|
+
} from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
|
|
7
|
+
import tableWith100ListItemsADF from './__fixtures__/table-with-100-numbered-list-items.json';
|
|
8
|
+
import {
|
|
9
|
+
scrollToBottom,
|
|
10
|
+
scrollToElement,
|
|
11
|
+
} from '@atlaskit/editor-test-helpers/page-objects/editor';
|
|
12
|
+
|
|
13
|
+
async function initEditor(page: PuppeteerPage, adf: Object) {
|
|
14
|
+
await initFullPageEditorWithAdf(
|
|
15
|
+
page,
|
|
16
|
+
adf,
|
|
17
|
+
Device.LaptopMDPI,
|
|
18
|
+
undefined,
|
|
19
|
+
{},
|
|
20
|
+
undefined,
|
|
21
|
+
undefined,
|
|
22
|
+
true,
|
|
23
|
+
false,
|
|
24
|
+
undefined,
|
|
25
|
+
{
|
|
26
|
+
group: 'editor',
|
|
27
|
+
packageName: 'editor-plugin-table',
|
|
28
|
+
exampleName: 'testing',
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('Snapshot Test: Table', () => {
|
|
34
|
+
let page: PuppeteerPage;
|
|
35
|
+
|
|
36
|
+
beforeAll(async () => {
|
|
37
|
+
page = global.page;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('numbered list', () => {
|
|
41
|
+
it('should not overflow table cell, when there are more than 100 ordered list items', async () => {
|
|
42
|
+
await initEditor(page, tableWith100ListItemsADF);
|
|
43
|
+
|
|
44
|
+
// initial elements
|
|
45
|
+
await snapshot(page);
|
|
46
|
+
|
|
47
|
+
// 100th elements
|
|
48
|
+
await scrollToElement(page, 'ol > li:nth-of-type(120)');
|
|
49
|
+
await snapshot(page);
|
|
50
|
+
|
|
51
|
+
// 1000th elements
|
|
52
|
+
await scrollToBottom(page);
|
|
53
|
+
await snapshot(page);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
|
|
2
|
+
import {
|
|
3
|
+
snapshot,
|
|
4
|
+
initEditorWithAdf,
|
|
5
|
+
Appearance,
|
|
6
|
+
} from '@atlaskit/editor-test-helpers/vr-utils/base-utils';
|
|
7
|
+
import stickyHeaderWithHorizontalScroll from './__fixtures__/sticky-header-with-horizontal-scroll.json';
|
|
8
|
+
import { scrollToElement } from '@atlaskit/editor-test-helpers/page-objects/editor';
|
|
9
|
+
import { clickFirstCell } from '@atlaskit/editor-test-helpers/page-objects/table';
|
|
10
|
+
|
|
11
|
+
const initEditor = async (page: PuppeteerPage, adf: any) => {
|
|
12
|
+
await initEditorWithAdf(
|
|
13
|
+
page,
|
|
14
|
+
{
|
|
15
|
+
appearance: Appearance.fullPage,
|
|
16
|
+
adf,
|
|
17
|
+
viewport: { width: 1280, height: 868 },
|
|
18
|
+
editorProps: {
|
|
19
|
+
allowTables: {
|
|
20
|
+
stickyHeaders: true,
|
|
21
|
+
allowColumnResizing: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
group: 'editor',
|
|
27
|
+
packageName: 'editor-plugin-table',
|
|
28
|
+
exampleName: 'testing',
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe('Snapshot Test: Table', () => {
|
|
34
|
+
let page: PuppeteerPage;
|
|
35
|
+
|
|
36
|
+
beforeEach(async () => {
|
|
37
|
+
page = global.page;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('sticky header', () => {
|
|
41
|
+
it('should align with table cell when active', async () => {
|
|
42
|
+
await initEditor(page, stickyHeaderWithHorizontalScroll);
|
|
43
|
+
|
|
44
|
+
await clickFirstCell(page, true);
|
|
45
|
+
|
|
46
|
+
// scroll to bottom center to see scroll shadows
|
|
47
|
+
await scrollToElement(page, 'ol > li');
|
|
48
|
+
await snapshot(page);
|
|
49
|
+
|
|
50
|
+
// scroll to bottom right
|
|
51
|
+
await scrollToElement(page, 'ul > li');
|
|
52
|
+
await snapshot(page);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -90,6 +90,7 @@ export const setTableRef = (ref?: HTMLTableElement) =>
|
|
|
90
90
|
isHeaderRowEnabled: checkIfHeaderRowEnabled(state.selection),
|
|
91
91
|
isHeaderColumnEnabled: checkIfHeaderColumnEnabled(state.selection),
|
|
92
92
|
decorationSet,
|
|
93
|
+
resizeHandleRowIndex: undefined,
|
|
93
94
|
resizeHandleColumnIndex: undefined,
|
|
94
95
|
},
|
|
95
96
|
};
|
|
@@ -434,7 +435,10 @@ export const hideInsertColumnOrRowButton = () =>
|
|
|
434
435
|
(tr) => tr.setMeta('addToHistory', false),
|
|
435
436
|
);
|
|
436
437
|
|
|
437
|
-
export const addResizeHandleDecorations = (
|
|
438
|
+
export const addResizeHandleDecorations = (
|
|
439
|
+
rowIndex: number,
|
|
440
|
+
columnIndex: number,
|
|
441
|
+
) =>
|
|
438
442
|
createCommand(
|
|
439
443
|
(state) => {
|
|
440
444
|
const tableNode = findTable(state.selection);
|
|
@@ -449,10 +453,14 @@ export const addResizeHandleDecorations = (columnIndex: number) =>
|
|
|
449
453
|
return {
|
|
450
454
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
451
455
|
data: {
|
|
452
|
-
decorationSet: buildColumnResizingDecorations(
|
|
456
|
+
decorationSet: buildColumnResizingDecorations(
|
|
457
|
+
rowIndex,
|
|
458
|
+
columnIndex,
|
|
459
|
+
)({
|
|
453
460
|
tr: state.tr,
|
|
454
461
|
decorationSet: getDecorations(state),
|
|
455
462
|
}),
|
|
463
|
+
resizeHandleRowIndex: rowIndex,
|
|
456
464
|
resizeHandleColumnIndex: columnIndex,
|
|
457
465
|
},
|
|
458
466
|
};
|
|
@@ -9,7 +9,6 @@ export const pluginConfig = (config: PluginConfig = {}) => {
|
|
|
9
9
|
allowHeaderRow: true,
|
|
10
10
|
allowMergeCells: true,
|
|
11
11
|
allowNumberColumn: true,
|
|
12
|
-
stickToolbarToBottom: true,
|
|
13
12
|
permittedLayouts: 'all' as PermittedLayoutsDescriptor,
|
|
14
13
|
allowControls: true,
|
|
15
14
|
...config,
|
|
@@ -55,7 +55,6 @@ import {
|
|
|
55
55
|
getMousePositionHorizontalRelativeByElement,
|
|
56
56
|
getMousePositionVerticalRelativeByElement,
|
|
57
57
|
getSelectedCellInfo,
|
|
58
|
-
hasResizeHandler,
|
|
59
58
|
isCell,
|
|
60
59
|
isColumnControlsDecorations,
|
|
61
60
|
isCornerButton,
|
|
@@ -358,7 +357,8 @@ export const handleMouseMove =
|
|
|
358
357
|
|
|
359
358
|
if (positionColumn !== null) {
|
|
360
359
|
const { state, dispatch } = view;
|
|
361
|
-
const { resizeHandleColumnIndex } =
|
|
360
|
+
const { resizeHandleColumnIndex, resizeHandleRowIndex } =
|
|
361
|
+
getPluginState(state);
|
|
362
362
|
const tableCell = closestElement(
|
|
363
363
|
element,
|
|
364
364
|
'td, th',
|
|
@@ -372,14 +372,16 @@ export const handleMouseMove =
|
|
|
372
372
|
const columnEndIndexTarget =
|
|
373
373
|
positionColumn === 'left' ? rect.left : rect.right;
|
|
374
374
|
|
|
375
|
+
const rowIndexTarget = rect.top;
|
|
376
|
+
|
|
375
377
|
if (
|
|
376
378
|
columnEndIndexTarget !== resizeHandleColumnIndex ||
|
|
377
|
-
|
|
379
|
+
rowIndexTarget !== resizeHandleRowIndex
|
|
378
380
|
) {
|
|
379
|
-
return addResizeHandleDecorations(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
);
|
|
381
|
+
return addResizeHandleDecorations(
|
|
382
|
+
rowIndexTarget,
|
|
383
|
+
columnEndIndexTarget,
|
|
384
|
+
)(state, dispatch);
|
|
383
385
|
}
|
|
384
386
|
}
|
|
385
387
|
}
|
|
@@ -32,12 +32,14 @@ const updateLastCellElement =
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
export const buildColumnResizingDecorations =
|
|
35
|
-
(columnEndIndex: number): DecorationTransformer =>
|
|
35
|
+
(rowEndIndex: number, columnEndIndex: number): DecorationTransformer =>
|
|
36
36
|
({ tr, decorationSet }): DecorationSet => {
|
|
37
37
|
const [columnResizesDecorations, lastCellElementsDecorations] =
|
|
38
38
|
columnEndIndex < 0
|
|
39
39
|
? emptyDecorations
|
|
40
|
-
: createResizeHandleDecoration(tr, {
|
|
40
|
+
: createResizeHandleDecoration(tr, rowEndIndex, {
|
|
41
|
+
right: columnEndIndex,
|
|
42
|
+
});
|
|
41
43
|
|
|
42
44
|
return composeDecorations([
|
|
43
45
|
updateColumnResizeHandle(columnResizesDecorations),
|
|
@@ -4,10 +4,8 @@ import { EditorView } from 'prosemirror-view';
|
|
|
4
4
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
5
|
import {
|
|
6
6
|
tableCellBorderWidth,
|
|
7
|
-
tableCellPadding,
|
|
8
7
|
tableMarginTop,
|
|
9
8
|
} from '@atlaskit/editor-common/styles';
|
|
10
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
11
9
|
|
|
12
10
|
import {
|
|
13
11
|
closestElement,
|
|
@@ -114,15 +112,11 @@ export const updateStickyMargins = (table: HTMLElement) => {
|
|
|
114
112
|
|
|
115
113
|
const paddingTop =
|
|
116
114
|
parsePx(window.getComputedStyle(row).paddingTop || '') || 0;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
table.style.marginTop = `${
|
|
122
|
-
browser.gecko
|
|
123
|
-
? firstRowHeight + tableCellPadding - tableCellBorderWidth
|
|
124
|
-
: tableMarginTop + firstRowHeight
|
|
125
|
-
}px`;
|
|
115
|
+
|
|
116
|
+
const firstRowHeight =
|
|
117
|
+
row.getBoundingClientRect().height - paddingTop - tableCellBorderWidth;
|
|
118
|
+
|
|
119
|
+
table.style.marginTop = `${tableMarginTop + firstRowHeight}px`;
|
|
126
120
|
};
|
|
127
121
|
|
|
128
122
|
export const applyColWidthsToStickyRow = (
|
|
@@ -80,12 +80,14 @@ export default (
|
|
|
80
80
|
...pluginState,
|
|
81
81
|
...action.data,
|
|
82
82
|
resizeHandleColumnIndex: undefined,
|
|
83
|
+
resizeHandleRowIndex: undefined,
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
86
87
|
if (
|
|
87
88
|
action.data.resizeHandleColumnIndex ===
|
|
88
|
-
|
|
89
|
+
pluginState.resizeHandleColumnIndex &&
|
|
90
|
+
action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex
|
|
89
91
|
) {
|
|
90
92
|
return pluginState;
|
|
91
93
|
}
|
|
@@ -46,7 +46,6 @@ export interface PluginConfig {
|
|
|
46
46
|
allowAddColumnWithCustomStep?: boolean;
|
|
47
47
|
allowCollapse?: boolean;
|
|
48
48
|
isHeaderRowRequired?: boolean;
|
|
49
|
-
stickToolbarToBottom?: boolean;
|
|
50
49
|
permittedLayouts?: PermittedLayoutsDescriptor;
|
|
51
50
|
allowControls?: boolean;
|
|
52
51
|
stickyHeaders?: boolean;
|
|
@@ -116,6 +115,7 @@ export interface TablePluginState {
|
|
|
116
115
|
isFullWidthModeEnabled?: boolean;
|
|
117
116
|
layout?: TableLayout;
|
|
118
117
|
ordering?: TableColumnOrdering;
|
|
118
|
+
resizeHandleRowIndex?: number;
|
|
119
119
|
resizeHandleColumnIndex?: number;
|
|
120
120
|
tableCellOptimization?: boolean;
|
|
121
121
|
// for table wrap/collapse
|
|
@@ -172,7 +172,11 @@ export type TablePluginAction =
|
|
|
172
172
|
}
|
|
173
173
|
| {
|
|
174
174
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS';
|
|
175
|
-
data: {
|
|
175
|
+
data: {
|
|
176
|
+
decorationSet: DecorationSet;
|
|
177
|
+
resizeHandleRowIndex: number;
|
|
178
|
+
resizeHandleColumnIndex: number;
|
|
179
|
+
};
|
|
176
180
|
}
|
|
177
181
|
| { type: 'CLEAR_HOVER_SELECTION'; data: { decorationSet: DecorationSet } }
|
|
178
182
|
| { type: 'SHOW_RESIZE_HANDLE_LINE'; data: { decorationSet: DecorationSet } }
|
|
@@ -302,6 +306,7 @@ export const TableCssClassName = {
|
|
|
302
306
|
LAST_ITEM_IN_CELL: `${tablePrefixSelector}-last-item-in-cell`,
|
|
303
307
|
|
|
304
308
|
WITH_RESIZE_LINE: `${tablePrefixSelector}-column-resize-line`,
|
|
309
|
+
WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`,
|
|
305
310
|
};
|
|
306
311
|
|
|
307
312
|
export interface ToolbarMenuConfig {
|
|
@@ -67,6 +67,13 @@ import { token } from '@atlaskit/tokens';
|
|
|
67
67
|
|
|
68
68
|
const cornerControlHeight = tableToolbarSize + 1;
|
|
69
69
|
|
|
70
|
+
/*
|
|
71
|
+
compensating for half of the insert column button
|
|
72
|
+
that is aligned to the right edge initially on hover of the top right column control when table overflown,
|
|
73
|
+
its center should be aligned with the edge
|
|
74
|
+
*/
|
|
75
|
+
const insertColumnButtonOffset = tableInsertColumnButtonSize / 2;
|
|
76
|
+
|
|
70
77
|
const rangeSelectionStyles = `
|
|
71
78
|
.${ClassName.NODEVIEW_WRAPPER}.${akEditorSelectedNodeClassName} table tbody tr {
|
|
72
79
|
th,td {
|
|
@@ -280,7 +287,7 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
280
287
|
/* add a little bit so the scroll lines up with the table */
|
|
281
288
|
.${ClassName.TABLE_STICKY} tr.sticky::after {
|
|
282
289
|
content: ' ';
|
|
283
|
-
width:
|
|
290
|
+
width: ${insertColumnButtonOffset + 1}px;
|
|
284
291
|
}
|
|
285
292
|
|
|
286
293
|
/* To fix jumpiness caused in Chrome Browsers for sticky headers */
|
|
@@ -394,18 +401,6 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
394
401
|
`,
|
|
395
402
|
)};
|
|
396
403
|
}
|
|
397
|
-
|
|
398
|
-
.${ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER} {
|
|
399
|
-
position: relative;
|
|
400
|
-
|
|
401
|
-
${InsertMarker(
|
|
402
|
-
props,
|
|
403
|
-
`
|
|
404
|
-
right: -1px;
|
|
405
|
-
top: -12px;
|
|
406
|
-
`,
|
|
407
|
-
)};
|
|
408
|
-
}
|
|
409
404
|
}
|
|
410
405
|
|
|
411
406
|
.${ClassName.CORNER_CONTROLS}.sticky {
|
|
@@ -592,6 +587,12 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
592
587
|
/* Table */
|
|
593
588
|
.${ClassName.TABLE_NODE_WRAPPER} > table {
|
|
594
589
|
table-layout: fixed;
|
|
590
|
+
white-space: normal;
|
|
591
|
+
border-top: none;
|
|
592
|
+
|
|
593
|
+
> tbody > tr {
|
|
594
|
+
white-space: pre-wrap;
|
|
595
|
+
}
|
|
595
596
|
|
|
596
597
|
.${ClassName.COLUMN_CONTROLS_DECORATIONS} + * {
|
|
597
598
|
margin-top: 0;
|
|
@@ -676,13 +677,8 @@ export const tableStyles = (props: ThemeProps) => css`
|
|
|
676
677
|
left: -${tableToolbarSize}px;
|
|
677
678
|
}
|
|
678
679
|
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
that is aligned to the right edge initially on hover of the top right column control when table overflown,
|
|
682
|
-
its center should be aligned with the edge
|
|
683
|
-
*/
|
|
684
|
-
padding-right: ${tableInsertColumnButtonSize / 2}px;
|
|
685
|
-
margin-right: -${tableInsertColumnButtonSize / 2}px;
|
|
680
|
+
padding-right: ${insertColumnButtonOffset}px;
|
|
681
|
+
margin-right: -${insertColumnButtonOffset}px;
|
|
686
682
|
padding-bottom: ${tableScrollbarOffset}px;
|
|
687
683
|
margin-bottom: -${tableScrollbarOffset}px;
|
|
688
684
|
/* fixes gap cursor height */
|