quill-table-up 3.1.2 → 3.2.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/README.md +7 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +168 -146
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +52 -52
- package/dist/index.umd.js.map +1 -1
- package/package.json +22 -24
- package/src/__tests__/e2e/custom-creator.test.ts +44 -44
- package/src/__tests__/e2e/editor-page.ts +77 -77
- package/src/__tests__/e2e/table-align.test.ts +104 -104
- package/src/__tests__/e2e/table-blots.test.ts +169 -169
- package/src/__tests__/e2e/table-caption.test.ts +134 -134
- package/src/__tests__/e2e/table-clipboard.test.ts +20 -20
- package/src/__tests__/e2e/table-hack.test.ts +151 -151
- package/src/__tests__/e2e/table-keyboard-handler.test.ts +12 -3
- package/src/__tests__/e2e/table-menu.test.ts +172 -172
- package/src/__tests__/e2e/table-resize.test.ts +654 -9
- package/src/__tests__/e2e/table-scrollbar.test.ts +144 -144
- package/src/__tests__/e2e/table-selection.test.ts +563 -563
- package/src/__tests__/e2e/types.d.ts +7 -7
- package/src/__tests__/e2e/utils.ts +52 -52
- package/src/__tests__/unit/table-blots.test.ts +720 -720
- package/src/__tests__/unit/table-caption.test.ts +234 -234
- package/src/__tests__/unit/table-cell-merge.test.ts +724 -724
- package/src/__tests__/unit/table-clipboard.test.ts +2176 -2176
- package/src/__tests__/unit/table-hack.test.ts +1014 -1014
- package/src/__tests__/unit/table-insert.test.ts +926 -926
- package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
- package/src/__tests__/unit/table-remove.test.ts +343 -343
- package/src/__tests__/unit/utils.test-d.ts +49 -49
- package/src/__tests__/unit/utils.test.ts +711 -711
- package/src/__tests__/unit/utils.ts +307 -307
- package/src/__tests__/unit/vitest.d.ts +14 -14
- package/src/formats/container-format.ts +107 -107
- package/src/formats/overrides/block-embed.ts +72 -72
- package/src/formats/overrides/block.ts +95 -95
- package/src/formats/overrides/index.ts +3 -3
- package/src/formats/overrides/scroll.ts +70 -70
- package/src/formats/table-body-format.ts +52 -52
- package/src/formats/table-caption-format.ts +116 -116
- package/src/formats/table-cell-format.ts +304 -304
- package/src/formats/table-cell-inner-format.ts +403 -398
- package/src/formats/table-colgroup-format.ts +136 -136
- package/src/formats/table-foot-format.ts +7 -7
- package/src/formats/table-head-format.ts +7 -7
- package/src/formats/table-main-format.ts +1 -1
- package/src/formats/table-row-format.ts +218 -210
- package/src/formats/utils.ts +6 -6
- package/src/index.ts +19 -19
- package/src/modules/index.ts +7 -7
- package/src/modules/table-align.ts +131 -131
- package/src/modules/table-clipboard/table-clipboard.ts +6 -8
- package/src/modules/table-dom-selector.ts +33 -33
- package/src/modules/table-menu/constants.ts +223 -223
- package/src/modules/table-menu/index.ts +4 -4
- package/src/modules/table-menu/table-menu-common.ts +330 -329
- package/src/modules/table-menu/table-menu-contextmenu.ts +111 -118
- package/src/modules/table-menu/table-menu-select.ts +96 -94
- package/src/modules/table-resize/index.ts +5 -5
- package/src/modules/table-resize/table-resize-box.ts +714 -363
- package/src/modules/table-resize/table-resize-common.ts +246 -382
- package/src/modules/table-resize/table-resize-drag.ts +241 -0
- package/src/modules/table-resize/table-resize-line.ts +244 -182
- package/src/modules/table-resize/table-resize-scale.ts +174 -173
- package/src/modules/table-resize/utils.ts +84 -3
- package/src/modules/table-scrollbar.ts +292 -292
- package/src/modules/table-selection.ts +613 -669
- package/src/style/button.less +45 -45
- package/src/style/color-picker.less +136 -136
- package/src/style/dialog.less +53 -53
- package/src/style/functions.less +9 -9
- package/src/style/index.less +120 -120
- package/src/style/input.less +64 -64
- package/src/style/select-box.less +52 -52
- package/src/style/table-creator.less +56 -56
- package/src/style/table-menu.less +125 -125
- package/src/style/table-resize-scale.less +31 -31
- package/src/style/table-resize.less +249 -202
- package/src/style/table-scrollbar.less +49 -49
- package/src/style/table-selection.less +23 -23
- package/src/style/tooltip.less +19 -19
- package/src/style/variables.less +1 -1
- package/src/svg/arrow-up-down.svg +11 -11
- package/src/svg/convert-cell.svg +7 -7
- package/src/table-up.ts +1360 -1360
- package/src/types.d.ts +4 -4
- package/src/utils/bem.ts +23 -23
- package/src/utils/blot-helper.ts +101 -105
- package/src/utils/color.ts +109 -109
- package/src/utils/components/button.ts +22 -22
- package/src/utils/components/color-picker.ts +236 -236
- package/src/utils/components/dialog.ts +83 -41
- package/src/utils/components/index.ts +6 -6
- package/src/utils/components/input.ts +74 -74
- package/src/utils/components/table/creator.ts +89 -89
- package/src/utils/components/table/index.ts +2 -2
- package/src/utils/components/table/select-box.ts +78 -78
- package/src/utils/components/tooltip.ts +179 -189
- package/src/utils/constants.ts +125 -124
- package/src/utils/drag-helper.ts +112 -0
- package/src/utils/index.ts +15 -14
- package/src/utils/is.ts +9 -9
- package/src/utils/position.ts +60 -60
- package/src/utils/resize-observer-helper.ts +47 -47
- package/src/utils/scroll.ts +145 -47
- package/src/utils/style-helper.ts +47 -47
- package/src/utils/transformer.ts +10 -10
- package/src/utils/transition-event-helper.ts +8 -8
- package/src/utils/types.ts +156 -157
- package/src/utils/utils.ts +12 -12
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { TableCellInnerFormat } from '../../formats';
|
|
2
|
+
import type { TableSelection } from '../../modules';
|
|
3
|
+
import type { TableUp } from '../../table-up';
|
|
1
4
|
import { expect, test } from '@playwright/test';
|
|
2
5
|
import { createTableBySelect, extendTest, pasteHTML } from './utils';
|
|
3
6
|
|
|
@@ -402,9 +405,15 @@ extendTest.describe('TableSelection keyboard handler', () => {
|
|
|
402
405
|
expect(cell1Bound).not.toBeNull();
|
|
403
406
|
|
|
404
407
|
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
405
|
-
|
|
406
|
-
page.
|
|
407
|
-
|
|
408
|
+
// set table selection
|
|
409
|
+
await page.evaluate(() => {
|
|
410
|
+
const tableUp = window.quills[0].getModule('table-up') as TableUp;
|
|
411
|
+
const tableSelection = tableUp.getModule<TableSelection>('table-selection')!;
|
|
412
|
+
const doms = document.querySelectorAll('#container1 td .ql-table-cell-inner');
|
|
413
|
+
const cells = Array.from(doms).map(dom => (window as any).Quill.find(dom)) as TableCellInnerFormat[];
|
|
414
|
+
tableSelection.setSelectedTds([cells[0], cells[1], cells[3]]);
|
|
415
|
+
tableSelection.updateWithSelectedTds();
|
|
416
|
+
});
|
|
408
417
|
|
|
409
418
|
const tableSelection = page.locator('#container1 .table-up-toolbox .table-up-selection__line');
|
|
410
419
|
await expect(tableSelection).toBeVisible();
|
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
import { expect, test } from '@playwright/test';
|
|
2
|
-
import { createTableBySelect, extendTest } from './utils';
|
|
3
|
-
|
|
4
|
-
test.beforeEach(async ({ page }) => {
|
|
5
|
-
await page.goto('http://127.0.0.1:5500/docs/test.html');
|
|
6
|
-
page.locator('.ql-container.ql-snow');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
extendTest('test menu color picker should work correctly', async ({ page }) => {
|
|
10
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
-
const container1Cell = page.locator('#editor1 .ql-table-cell').nth(0);
|
|
12
|
-
const cellBoundbox = (await container1Cell.boundingBox())!;
|
|
13
|
-
expect(cellBoundbox).not.toBeNull();
|
|
14
|
-
await container1Cell.click();
|
|
15
|
-
await page.mouse.down();
|
|
16
|
-
await page.mouse.move(cellBoundbox.x + cellBoundbox.width * 1.5, cellBoundbox.y + cellBoundbox.height * 1.5);
|
|
17
|
-
await page.mouse.up();
|
|
18
|
-
await container1Cell.click({ button: 'right' });
|
|
19
|
-
const selectionBoundbox = (await page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line').boundingBox())!;
|
|
20
|
-
expect(selectionBoundbox).not.toBeNull();
|
|
21
|
-
expect(selectionBoundbox.x).toBeCloseTo(cellBoundbox.x, 0);
|
|
22
|
-
expect(selectionBoundbox.y).toBeCloseTo(cellBoundbox.y, 0);
|
|
23
|
-
expect(selectionBoundbox.width).toBeCloseTo(cellBoundbox.width * 2, 0);
|
|
24
|
-
expect(selectionBoundbox.height).toBeCloseTo(cellBoundbox.height * 2, 0);
|
|
25
|
-
|
|
26
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
27
|
-
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
|
|
28
|
-
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
29
|
-
await expect(page.locator('#editor1 .ql-table-cell[style="background-color: rgb(255, 255, 255);"]')).toHaveCount(4);
|
|
30
|
-
await expect(page.locator('#editor1 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
31
|
-
await expect(page.locator('#editor1 .ql-table-cell').nth(1)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
32
|
-
await expect(page.locator('#editor1 .ql-table-cell').nth(3)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
33
|
-
await expect(page.locator('#editor1 .ql-table-cell').nth(4)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
34
|
-
|
|
35
|
-
await page.mouse.click(0, 0);
|
|
36
|
-
|
|
37
|
-
await createTableBySelect(page, 'container2', 3, 3);
|
|
38
|
-
await page.locator('#editor2 .ql-table-cell').nth(0).click();
|
|
39
|
-
await page.waitForTimeout(1000);
|
|
40
|
-
|
|
41
|
-
await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
|
|
42
|
-
await page.waitForTimeout(1000);
|
|
43
|
-
|
|
44
|
-
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
|
|
45
|
-
await expect(page.locator('#editor2 .table-up-menu')).toBeVisible();
|
|
46
|
-
await expect(page.locator('#editor2 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
extendTest('test menu color picker should not have two at the same time', async ({ page }) => {
|
|
50
|
-
await createTableBySelect(page, 'container2', 3, 3);
|
|
51
|
-
await page.locator('#editor2 .ql-table-cell').nth(0).click();
|
|
52
|
-
await page.waitForTimeout(1000);
|
|
53
|
-
|
|
54
|
-
await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
|
|
55
|
-
await page.waitForTimeout(1000);
|
|
56
|
-
|
|
57
|
-
await page.locator('.table-up-tooltip .custom.table-up-color-map__btn').click();
|
|
58
|
-
const colorpicker = page.locator('.table-up-tooltip .custom.table-up-color-map__btn .table-up-color-picker');
|
|
59
|
-
await expect(colorpicker).toBeVisible();
|
|
60
|
-
|
|
61
|
-
await page.locator('#editor2 .table-up-menu .color-selector').nth(1).click();
|
|
62
|
-
await page.waitForTimeout(1000);
|
|
63
|
-
await expect(colorpicker).not.toBeVisible();
|
|
64
|
-
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
extendTest('test TableMenuSelect should update when text change', async ({ page, editorPage }) => {
|
|
68
|
-
editorPage.index = 1;
|
|
69
|
-
await createTableBySelect(page, 'container2', 3, 3);
|
|
70
|
-
|
|
71
|
-
await page.evaluate(() => {
|
|
72
|
-
window.scrollTo(0, 600);
|
|
73
|
-
});
|
|
74
|
-
const lineBound = (await page.locator('#editor2 .ql-editor > p').first().boundingBox())!;
|
|
75
|
-
expect(lineBound).not.toBeNull();
|
|
76
|
-
|
|
77
|
-
await page.locator('#editor2 .ql-table .ql-table-cell').nth(0).click();
|
|
78
|
-
const menuWrapper = page.locator('#container2 .table-up-menu');
|
|
79
|
-
await expect(menuWrapper).toBeVisible();
|
|
80
|
-
const menuBound = (await menuWrapper.boundingBox())!;
|
|
81
|
-
expect(menuBound).not.toBeNull();
|
|
82
|
-
|
|
83
|
-
await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
|
|
84
|
-
await page.evaluate(() => {
|
|
85
|
-
window.scrollTo(0, 600);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
await expect(menuWrapper).toBeVisible();
|
|
89
|
-
const newMenuWrapper = (await menuWrapper.boundingBox())!;
|
|
90
|
-
expect(newMenuWrapper).not.toBeNull();
|
|
91
|
-
expect(newMenuWrapper.y - menuBound.y).toBeCloseTo(lineBound.height, 0);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
extendTest('TableMenu color picker should trigger by click', async ({ page }) => {
|
|
95
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
96
|
-
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
97
|
-
await cell.click();
|
|
98
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
99
|
-
await cell.click({ button: 'right' });
|
|
100
|
-
const colorItem = page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first();
|
|
101
|
-
await colorItem.hover();
|
|
102
|
-
await expect(page.locator('.table-up-tooltip .table-up-color-map')).not.toBeVisible();
|
|
103
|
-
await colorItem.click();
|
|
104
|
-
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
extendTest('TableMenu color picker display should blur editor', async ({ page }) => {
|
|
108
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
109
|
-
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
110
|
-
await cell.click();
|
|
111
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
112
|
-
await cell.click({ button: 'right' });
|
|
113
|
-
|
|
114
|
-
const qlEditor = await page.locator('#editor1 .ql-editor').elementHandle();
|
|
115
|
-
expect(qlEditor).not.toBeNull();
|
|
116
|
-
const isFocused = await page.evaluate((qlEditor) => {
|
|
117
|
-
const activeElement = document.activeElement;
|
|
118
|
-
return qlEditor.contains(activeElement);
|
|
119
|
-
}, qlEditor!);
|
|
120
|
-
expect(isFocused).toBe(true);
|
|
121
|
-
|
|
122
|
-
const colorItem = page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first();
|
|
123
|
-
await colorItem.click();
|
|
124
|
-
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
125
|
-
|
|
126
|
-
const isFocusedAfterMenuDisplay = await page.evaluate((qlEditor) => {
|
|
127
|
-
const activeElement = document.activeElement;
|
|
128
|
-
return qlEditor.contains(activeElement);
|
|
129
|
-
}, qlEditor!);
|
|
130
|
-
expect(isFocusedAfterMenuDisplay).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
extendTest('test TableSelection should not display when color pick display', async ({ page }) => {
|
|
134
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
135
|
-
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
136
|
-
await cell.click();
|
|
137
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
138
|
-
|
|
139
|
-
await cell.click({ button: 'right' });
|
|
140
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
141
|
-
await page.waitForTimeout(1000);
|
|
142
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).not.toBeVisible();
|
|
143
|
-
|
|
144
|
-
await page.locator('#editor1 .ql-editor td').nth(0).click();
|
|
145
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
146
|
-
|
|
147
|
-
await cell.click();
|
|
148
|
-
await cell.click({ button: 'right' });
|
|
149
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
150
|
-
await page.waitForTimeout(1000);
|
|
151
|
-
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__btn.custom').click();
|
|
152
|
-
await page.waitForTimeout(1000);
|
|
153
|
-
const bgPicker = page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__btn.custom .table-up-color-picker__background');
|
|
154
|
-
const bounding = (await bgPicker.boundingBox())!;
|
|
155
|
-
expect(bounding).not.toBeNull();
|
|
156
|
-
await page.mouse.click(bounding.x + bounding.width / 2, bounding.y + bounding.height / 2);
|
|
157
|
-
await page.waitForTimeout(1000);
|
|
158
|
-
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).not.toBeVisible();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
extendTest('table width switch should work', async ({ page }) => {
|
|
162
|
-
await createTableBySelect(page, 'container1', 4, 4);
|
|
163
|
-
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
164
|
-
await cell.click();
|
|
165
|
-
await cell.click({ button: 'right' });
|
|
166
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Switch table width' }).first().click();
|
|
167
|
-
expect(await page.locator('#editor1 .ql-editor .ql-table col[data-full="true"]').count()).toBe(4);
|
|
168
|
-
|
|
169
|
-
await cell.click({ button: 'right' });
|
|
170
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Switch table width' }).first().click();
|
|
171
|
-
expect(await page.locator('#editor1 .ql-editor .ql-table col:not([data-full])').count()).toBe(4);
|
|
172
|
-
});
|
|
1
|
+
import { expect, test } from '@playwright/test';
|
|
2
|
+
import { createTableBySelect, extendTest } from './utils';
|
|
3
|
+
|
|
4
|
+
test.beforeEach(async ({ page }) => {
|
|
5
|
+
await page.goto('http://127.0.0.1:5500/docs/test.html');
|
|
6
|
+
page.locator('.ql-container.ql-snow');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
extendTest('test menu color picker should work correctly', async ({ page }) => {
|
|
10
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
+
const container1Cell = page.locator('#editor1 .ql-table-cell').nth(0);
|
|
12
|
+
const cellBoundbox = (await container1Cell.boundingBox())!;
|
|
13
|
+
expect(cellBoundbox).not.toBeNull();
|
|
14
|
+
await container1Cell.click();
|
|
15
|
+
await page.mouse.down();
|
|
16
|
+
await page.mouse.move(cellBoundbox.x + cellBoundbox.width * 1.5, cellBoundbox.y + cellBoundbox.height * 1.5);
|
|
17
|
+
await page.mouse.up();
|
|
18
|
+
await container1Cell.click({ button: 'right' });
|
|
19
|
+
const selectionBoundbox = (await page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line').boundingBox())!;
|
|
20
|
+
expect(selectionBoundbox).not.toBeNull();
|
|
21
|
+
expect(selectionBoundbox.x).toBeCloseTo(cellBoundbox.x, 0);
|
|
22
|
+
expect(selectionBoundbox.y).toBeCloseTo(cellBoundbox.y, 0);
|
|
23
|
+
expect(selectionBoundbox.width).toBeCloseTo(cellBoundbox.width * 2, 0);
|
|
24
|
+
expect(selectionBoundbox.height).toBeCloseTo(cellBoundbox.height * 2, 0);
|
|
25
|
+
|
|
26
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
27
|
+
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
|
|
28
|
+
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
29
|
+
await expect(page.locator('#editor1 .ql-table-cell[style="background-color: rgb(255, 255, 255);"]')).toHaveCount(4);
|
|
30
|
+
await expect(page.locator('#editor1 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
31
|
+
await expect(page.locator('#editor1 .ql-table-cell').nth(1)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
32
|
+
await expect(page.locator('#editor1 .ql-table-cell').nth(3)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
33
|
+
await expect(page.locator('#editor1 .ql-table-cell').nth(4)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
34
|
+
|
|
35
|
+
await page.mouse.click(0, 0);
|
|
36
|
+
|
|
37
|
+
await createTableBySelect(page, 'container2', 3, 3);
|
|
38
|
+
await page.locator('#editor2 .ql-table-cell').nth(0).click();
|
|
39
|
+
await page.waitForTimeout(1000);
|
|
40
|
+
|
|
41
|
+
await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
|
|
42
|
+
await page.waitForTimeout(1000);
|
|
43
|
+
|
|
44
|
+
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
|
|
45
|
+
await expect(page.locator('#editor2 .table-up-menu')).toBeVisible();
|
|
46
|
+
await expect(page.locator('#editor2 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
extendTest('test menu color picker should not have two at the same time', async ({ page }) => {
|
|
50
|
+
await createTableBySelect(page, 'container2', 3, 3);
|
|
51
|
+
await page.locator('#editor2 .ql-table-cell').nth(0).click();
|
|
52
|
+
await page.waitForTimeout(1000);
|
|
53
|
+
|
|
54
|
+
await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
|
|
55
|
+
await page.waitForTimeout(1000);
|
|
56
|
+
|
|
57
|
+
await page.locator('.table-up-tooltip .custom.table-up-color-map__btn').click();
|
|
58
|
+
const colorpicker = page.locator('.table-up-tooltip .custom.table-up-color-map__btn .table-up-color-picker');
|
|
59
|
+
await expect(colorpicker).toBeVisible();
|
|
60
|
+
|
|
61
|
+
await page.locator('#editor2 .table-up-menu .color-selector').nth(1).click();
|
|
62
|
+
await page.waitForTimeout(1000);
|
|
63
|
+
await expect(colorpicker).not.toBeVisible();
|
|
64
|
+
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
extendTest('test TableMenuSelect should update when text change', async ({ page, editorPage }) => {
|
|
68
|
+
editorPage.index = 1;
|
|
69
|
+
await createTableBySelect(page, 'container2', 3, 3);
|
|
70
|
+
|
|
71
|
+
await page.evaluate(() => {
|
|
72
|
+
window.scrollTo(0, 600);
|
|
73
|
+
});
|
|
74
|
+
const lineBound = (await page.locator('#editor2 .ql-editor > p').first().boundingBox())!;
|
|
75
|
+
expect(lineBound).not.toBeNull();
|
|
76
|
+
|
|
77
|
+
await page.locator('#editor2 .ql-table .ql-table-cell').nth(0).click();
|
|
78
|
+
const menuWrapper = page.locator('#container2 .table-up-menu');
|
|
79
|
+
await expect(menuWrapper).toBeVisible();
|
|
80
|
+
const menuBound = (await menuWrapper.boundingBox())!;
|
|
81
|
+
expect(menuBound).not.toBeNull();
|
|
82
|
+
|
|
83
|
+
await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
|
|
84
|
+
await page.evaluate(() => {
|
|
85
|
+
window.scrollTo(0, 600);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await expect(menuWrapper).toBeVisible();
|
|
89
|
+
const newMenuWrapper = (await menuWrapper.boundingBox())!;
|
|
90
|
+
expect(newMenuWrapper).not.toBeNull();
|
|
91
|
+
expect(newMenuWrapper.y - menuBound.y).toBeCloseTo(lineBound.height, 0);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
extendTest('TableMenu color picker should trigger by click', async ({ page }) => {
|
|
95
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
96
|
+
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
97
|
+
await cell.click();
|
|
98
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
99
|
+
await cell.click({ button: 'right' });
|
|
100
|
+
const colorItem = page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first();
|
|
101
|
+
await colorItem.hover();
|
|
102
|
+
await expect(page.locator('.table-up-tooltip .table-up-color-map')).not.toBeVisible();
|
|
103
|
+
await colorItem.click();
|
|
104
|
+
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
extendTest('TableMenu color picker display should blur editor', async ({ page }) => {
|
|
108
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
109
|
+
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
110
|
+
await cell.click();
|
|
111
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
112
|
+
await cell.click({ button: 'right' });
|
|
113
|
+
|
|
114
|
+
const qlEditor = await page.locator('#editor1 .ql-editor').elementHandle();
|
|
115
|
+
expect(qlEditor).not.toBeNull();
|
|
116
|
+
const isFocused = await page.evaluate((qlEditor) => {
|
|
117
|
+
const activeElement = document.activeElement;
|
|
118
|
+
return qlEditor.contains(activeElement);
|
|
119
|
+
}, qlEditor!);
|
|
120
|
+
expect(isFocused).toBe(true);
|
|
121
|
+
|
|
122
|
+
const colorItem = page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first();
|
|
123
|
+
await colorItem.click();
|
|
124
|
+
await expect(page.locator('.table-up-tooltip .table-up-color-map')).toBeVisible();
|
|
125
|
+
|
|
126
|
+
const isFocusedAfterMenuDisplay = await page.evaluate((qlEditor) => {
|
|
127
|
+
const activeElement = document.activeElement;
|
|
128
|
+
return qlEditor.contains(activeElement);
|
|
129
|
+
}, qlEditor!);
|
|
130
|
+
expect(isFocusedAfterMenuDisplay).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
extendTest('test TableSelection should not display when color pick display', async ({ page }) => {
|
|
134
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
135
|
+
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
136
|
+
await cell.click();
|
|
137
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
138
|
+
|
|
139
|
+
await cell.click({ button: 'right' });
|
|
140
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
141
|
+
await page.waitForTimeout(1000);
|
|
142
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).not.toBeVisible();
|
|
143
|
+
|
|
144
|
+
await page.locator('#editor1 .ql-editor td').nth(0).click();
|
|
145
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).toBeVisible();
|
|
146
|
+
|
|
147
|
+
await cell.click();
|
|
148
|
+
await cell.click({ button: 'right' });
|
|
149
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
150
|
+
await page.waitForTimeout(1000);
|
|
151
|
+
await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__btn.custom').click();
|
|
152
|
+
await page.waitForTimeout(1000);
|
|
153
|
+
const bgPicker = page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__btn.custom .table-up-color-picker__background');
|
|
154
|
+
const bounding = (await bgPicker.boundingBox())!;
|
|
155
|
+
expect(bounding).not.toBeNull();
|
|
156
|
+
await page.mouse.click(bounding.x + bounding.width / 2, bounding.y + bounding.height / 2);
|
|
157
|
+
await page.waitForTimeout(1000);
|
|
158
|
+
await expect(page.locator('#container1 .table-up-toolbox .table-up-selection .table-up-selection__line')).not.toBeVisible();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
extendTest('table width switch should work', async ({ page }) => {
|
|
162
|
+
await createTableBySelect(page, 'container1', 4, 4);
|
|
163
|
+
const cell = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
164
|
+
await cell.click();
|
|
165
|
+
await cell.click({ button: 'right' });
|
|
166
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Switch table width' }).first().click();
|
|
167
|
+
expect(await page.locator('#editor1 .ql-editor .ql-table col[data-full="true"]').count()).toBe(4);
|
|
168
|
+
|
|
169
|
+
await cell.click({ button: 'right' });
|
|
170
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Switch table width' }).first().click();
|
|
171
|
+
expect(await page.locator('#editor1 .ql-editor .ql-table col:not([data-full])').count()).toBe(4);
|
|
172
|
+
});
|