quill-table-up 3.0.2 → 3.1.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 +5 -7
- package/dist/index.d.ts +71 -18
- package/dist/index.js +26 -25
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +33 -32
- package/dist/index.umd.js.map +1 -1
- package/package.json +16 -12
- package/src/__tests__/e2e/editor-page.ts +3 -2
- package/src/__tests__/e2e/table-keyboard-handler.test.ts +610 -372
- package/src/__tests__/e2e/table-menu.test.ts +0 -24
- package/src/__tests__/e2e/utils.ts +37 -1
- package/src/__tests__/unit/table-blots.test.ts +341 -2
- package/src/__tests__/unit/table-cell-merge.test.ts +22 -1
- package/src/__tests__/unit/table-clipboard.test.ts +187 -21
- package/src/__tests__/unit/table-redo-undo.test.ts +54 -2
- package/src/__tests__/unit/utils.ts +14 -9
- package/src/formats/table-cell-format.ts +11 -3
- package/src/formats/table-row-format.ts +1 -1
- package/src/modules/table-clipboard/index.ts +2 -0
- package/src/modules/table-clipboard/paste-cell-into-cell.ts +329 -0
- package/src/modules/{table-clipboard.ts → table-clipboard/table-clipboard.ts} +375 -360
- package/src/modules/table-menu/constants.ts +38 -17
- package/src/modules/table-resize/table-resize-box.ts +4 -1
- package/src/modules/table-selection.ts +52 -11
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/table-up.ts +61 -7
- package/src/utils/components/table/select-box.ts +1 -6
- package/src/utils/is.ts +1 -0
|
@@ -1,372 +1,610 @@
|
|
|
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.describe('table cell keyboard handler enter', () => {
|
|
10
|
-
extendTest('cursor at the start of BlockEmbed', async ({ page, editorPage }) => {
|
|
11
|
-
editorPage.index = 0;
|
|
12
|
-
await editorPage.setContents([
|
|
13
|
-
{ insert: '\n' },
|
|
14
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
15
|
-
{ insert: { video: 'https://quilljs.com/' } },
|
|
16
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
17
|
-
{ insert: '\n' },
|
|
18
|
-
]);
|
|
19
|
-
await page.waitForTimeout(1000);
|
|
20
|
-
|
|
21
|
-
await editorPage.setSelection(2, 0);
|
|
22
|
-
await page.keyboard.press('Enter');
|
|
23
|
-
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner iframe').nth(0)).toBeVisible();
|
|
24
|
-
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0)).toBeVisible();
|
|
25
|
-
const delta = await editorPage.getContents();
|
|
26
|
-
const contents = [
|
|
27
|
-
{ insert: '\n' },
|
|
28
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
29
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
30
|
-
{ insert: { video: 'https://quilljs.com/' } },
|
|
31
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
32
|
-
{ insert: '\n' },
|
|
33
|
-
];
|
|
34
|
-
for (const [i, op] of delta.ops.entries()) {
|
|
35
|
-
expect(op).toStrictEqual(contents[i]);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
extendTest('cursor at the end of BlockEmbed', async ({ page, editorPage }) => {
|
|
40
|
-
editorPage.index = 0;
|
|
41
|
-
await editorPage.setContents([
|
|
42
|
-
{ insert: '\n' },
|
|
43
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
44
|
-
{ insert: { video: 'https://quilljs.com/' } },
|
|
45
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
46
|
-
{ insert: '\n' },
|
|
47
|
-
]);
|
|
48
|
-
await page.waitForTimeout(1000);
|
|
49
|
-
|
|
50
|
-
await editorPage.setSelection(3, 0);
|
|
51
|
-
await page.keyboard.press('Enter');
|
|
52
|
-
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0)).toBeVisible();
|
|
53
|
-
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner iframe').nth(0)).toBeVisible();
|
|
54
|
-
const delta = await editorPage.getContents();
|
|
55
|
-
const contents = [
|
|
56
|
-
{ insert: '\n' },
|
|
57
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
58
|
-
{ insert: { video: 'https://quilljs.com/' } },
|
|
59
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n\n' },
|
|
60
|
-
{ insert: '\n' },
|
|
61
|
-
];
|
|
62
|
-
for (const [i, op] of delta.ops.entries()) {
|
|
63
|
-
expect(op).toStrictEqual(contents[i]);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
extendTest('selection multiple line', async ({ page, editorPage }) => {
|
|
68
|
-
editorPage.index = 0;
|
|
69
|
-
await editorPage.setContents([
|
|
70
|
-
{ insert: '\n' },
|
|
71
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
72
|
-
{ insert: { video: 'https://quilljs.com/' } },
|
|
73
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
74
|
-
{ insert: '123' },
|
|
75
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
76
|
-
{ insert: '123' },
|
|
77
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
78
|
-
]);
|
|
79
|
-
await page.waitForTimeout(1000);
|
|
80
|
-
|
|
81
|
-
await editorPage.setSelection(4, 7);
|
|
82
|
-
await page.keyboard.press('Enter');
|
|
83
|
-
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p')).toHaveCount(2);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
extendTest.describe('table cell keyboard handler ArrowUp and ArrowDown', () => {
|
|
88
|
-
extendTest('test TableSelection should update when selection change', async ({ page, editorPage }) => {
|
|
89
|
-
editorPage.index = 0;
|
|
90
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
91
|
-
|
|
92
|
-
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
93
|
-
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
94
|
-
await expect(selectionLine).toBeVisible();
|
|
95
|
-
|
|
96
|
-
await page.keyboard.press('ArrowRight');
|
|
97
|
-
await expect(selectionLine).toBeVisible();
|
|
98
|
-
const newSelectionWrapper = (await selectionLine.boundingBox())!;
|
|
99
|
-
expect(newSelectionWrapper).not.toBeNull();
|
|
100
|
-
const cell1Bound = (await page.locator('#editor1 .ql-editor td').nth(1).boundingBox())!;
|
|
101
|
-
expect(cell1Bound).not.toBeNull();
|
|
102
|
-
expect(cell1Bound).toEqual(newSelectionWrapper);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
extendTest('test TableSelection and TableMenuSelect should hide when selection out table', async ({ page }) => {
|
|
106
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
107
|
-
const firstCell1 = page.locator('#editor1').getByRole('cell').nth(0);
|
|
108
|
-
await firstCell1.click();
|
|
109
|
-
expect(page.locator('#container1 .table-up-selection')).toBeVisible();
|
|
110
|
-
|
|
111
|
-
await page.keyboard.down('ArrowUp');
|
|
112
|
-
expect(page.locator('#container1 .table-up-selection')).not.toBeVisible();
|
|
113
|
-
|
|
114
|
-
await firstCell1.click();
|
|
115
|
-
await firstCell1.click({ button: 'right' });
|
|
116
|
-
await expect(page.locator('#container1 .table-up-selection')).toBeVisible();
|
|
117
|
-
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
118
|
-
|
|
119
|
-
await page.keyboard.down('ArrowUp');
|
|
120
|
-
await expect(page.locator('#container1 .table-up-selection')).not.toBeVisible();
|
|
121
|
-
await expect(page.locator('.table-up-menu.is-contextmenu')).not.toBeVisible();
|
|
122
|
-
|
|
123
|
-
await createTableBySelect(page, 'container2', 3, 3);
|
|
124
|
-
const firstCell2 = page.locator('#editor2').getByRole('cell').nth(0);
|
|
125
|
-
await firstCell2.click();
|
|
126
|
-
await expect(page.locator('#container2 .table-up-selection')).toBeVisible();
|
|
127
|
-
|
|
128
|
-
await page.keyboard.down('ArrowUp');
|
|
129
|
-
await expect(page.locator('#container2 .table-up-selection')).not.toBeVisible();
|
|
130
|
-
|
|
131
|
-
await firstCell2.click();
|
|
132
|
-
await expect(page.locator('#container2 .table-up-selection')).toBeVisible();
|
|
133
|
-
await expect(page.locator('#container2 .table-up-menu')).toBeVisible();
|
|
134
|
-
|
|
135
|
-
await page.keyboard.down('ArrowUp');
|
|
136
|
-
await expect(page.locator('#container2 .table-up-selection')).not.toBeVisible();
|
|
137
|
-
await expect(page.locator('#container2 .table-up-menu')).not.toBeVisible();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
extendTest('test table keyboard ArrowUp and ArrowDown should work', async ({ page, editorPage }) => {
|
|
141
|
-
editorPage.index = 0;
|
|
142
|
-
editorPage.setContents([
|
|
143
|
-
{ insert: '123456\n' },
|
|
144
|
-
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'mnpytyt1cno', full: false, width: 291 } } },
|
|
145
|
-
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: '6ihx044tflt', full: false, width: 291 } } },
|
|
146
|
-
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'raiomwr9yuc', full: false, width: 291 } } },
|
|
147
|
-
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'qiuz7k09q6r', full: false, width: 291 } } },
|
|
148
|
-
{ insert: '123' },
|
|
149
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
150
|
-
{ insert: '123456' },
|
|
151
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
152
|
-
{ insert: '123' },
|
|
153
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
154
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'raiomwr9yuc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
155
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'qiuz7k09q6r', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
156
|
-
{ insert: '123' },
|
|
157
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
158
|
-
{ insert: '123456' },
|
|
159
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
160
|
-
{ insert: '123' },
|
|
161
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
162
|
-
{ insert: '12345' },
|
|
163
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'mnpytyt1cno', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
164
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: '6ihx044tflt', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
165
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'raiomwr9yuc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
166
|
-
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'qiuz7k09q6r', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
167
|
-
{ insert: '123456\n' },
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
await editorPage.setSelection(50, 0);
|
|
171
|
-
await page.keyboard.press('ArrowUp');
|
|
172
|
-
expect((await editorPage.getSelection())!.index).toBe(39);
|
|
173
|
-
|
|
174
|
-
await editorPage.setSelection(48, 0);
|
|
175
|
-
await page.keyboard.press('ArrowUp');
|
|
176
|
-
expect((await editorPage.getSelection())!.index).toBe(25);
|
|
177
|
-
|
|
178
|
-
await editorPage.setSelection(14, 0);
|
|
179
|
-
await page.keyboard.press('ArrowUp');
|
|
180
|
-
expect((await editorPage.getSelection())!.index).toBe(6);
|
|
181
|
-
|
|
182
|
-
await editorPage.setSelection(25, 0);
|
|
183
|
-
await page.keyboard.press('ArrowDown');
|
|
184
|
-
expect((await editorPage.getSelection())!.index).toBe(46);
|
|
185
|
-
|
|
186
|
-
await editorPage.setSelection(26, 0);
|
|
187
|
-
await page.keyboard.press('ArrowDown');
|
|
188
|
-
expect((await editorPage.getSelection())!.index).toBe(28);
|
|
189
|
-
|
|
190
|
-
await editorPage.setSelection(48, 0);
|
|
191
|
-
await page.keyboard.press('ArrowDown');
|
|
192
|
-
expect((await editorPage.getSelection())!.index).toBe(52);
|
|
193
|
-
|
|
194
|
-
await editorPage.setSelection(50, 0);
|
|
195
|
-
await page.keyboard.press('ArrowDown');
|
|
196
|
-
expect((await editorPage.getSelection())!.index).toBe(52);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
extendTest('test TableSelection should update when selection change and menu display', async ({ page, editorPage }) => {
|
|
200
|
-
editorPage.index = 0;
|
|
201
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
202
|
-
|
|
203
|
-
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
204
|
-
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
205
|
-
await expect(selectionLine).toBeVisible();
|
|
206
|
-
|
|
207
|
-
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click({ button: 'right' });
|
|
208
|
-
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
209
|
-
|
|
210
|
-
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
211
|
-
await page.waitForTimeout(1000);
|
|
212
|
-
await expect(selectionLine).not.toBeVisible();
|
|
213
|
-
|
|
214
|
-
await page.keyboard.press('ArrowDown');
|
|
215
|
-
await expect(selectionLine).not.toBeVisible();
|
|
216
|
-
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
extendTest.describe('TableSelection keyboard handler', () => {
|
|
221
|
-
extendTest('backspace should not remove cell content when focus element not in editor', async ({ page, editorPage }) => {
|
|
222
|
-
editorPage.index = 0;
|
|
223
|
-
await editorPage.setContents([
|
|
224
|
-
{ insert: '\n' },
|
|
225
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
226
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
227
|
-
{ attributes: { link: 'www.any.link' }, insert: 'some text' },
|
|
228
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
229
|
-
{ insert: '2' },
|
|
230
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
231
|
-
{ insert: '4' },
|
|
232
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
233
|
-
{ insert: '5' },
|
|
234
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
235
|
-
{ insert: '\n' },
|
|
236
|
-
]);
|
|
237
|
-
await page.waitForTimeout(1000);
|
|
238
|
-
|
|
239
|
-
await page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0).click();
|
|
240
|
-
await page.locator('#editor1 .ql-tooltip .ql-action').click();
|
|
241
|
-
await page.keyboard.press('ArrowRight');
|
|
242
|
-
await page.keyboard.press('Backspace');
|
|
243
|
-
|
|
244
|
-
expect(await page.locator('#editor1 .ql-tooltip input').nth(0).inputValue()).toBe('www.any.lin');
|
|
245
|
-
expect(await page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0).textContent()).toBe('some text');
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
extendTest('should handle delete table cell text when selected tds', async ({ page, editorPage }) => {
|
|
249
|
-
editorPage.index = 0;
|
|
250
|
-
await editorPage.setContents([
|
|
251
|
-
{ insert: '\n' },
|
|
252
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
253
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
254
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 121 } } },
|
|
255
|
-
{ insert: '1' },
|
|
256
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
257
|
-
{ insert: '2' },
|
|
258
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
259
|
-
{ insert: '3' },
|
|
260
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
261
|
-
{ insert: '4' },
|
|
262
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
263
|
-
{ insert: '5' },
|
|
264
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
265
|
-
{ insert: '6' },
|
|
266
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
267
|
-
{ insert: '7' },
|
|
268
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
269
|
-
{ insert: '8' },
|
|
270
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
271
|
-
{ insert: '9' },
|
|
272
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
273
|
-
{ insert: '\n' },
|
|
274
|
-
]);
|
|
275
|
-
|
|
276
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(0)).toHaveText('1');
|
|
277
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(1)).toHaveText('2');
|
|
278
|
-
|
|
279
|
-
const cell1 = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
280
|
-
const cell1Bounding = (await cell1.boundingBox())!;
|
|
281
|
-
expect(cell1Bounding).not.toBeNull();
|
|
282
|
-
await cell1.click();
|
|
283
|
-
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
284
|
-
await expect(selectionLine).toBeVisible();
|
|
285
|
-
|
|
286
|
-
await page.mouse.down();
|
|
287
|
-
await page.mouse.move(cell1Bounding.x + cell1Bounding.width * 1.5, cell1Bounding.y + cell1Bounding.height / 2);
|
|
288
|
-
await page.mouse.up();
|
|
289
|
-
await editorPage.blur();
|
|
290
|
-
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
291
|
-
key: 'Backspace',
|
|
292
|
-
code: 'Backspace',
|
|
293
|
-
keyCode: 13,
|
|
294
|
-
which: 13,
|
|
295
|
-
bubbles: true,
|
|
296
|
-
cancelable: true,
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(0)).toHaveText('');
|
|
300
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(1)).toHaveText('');
|
|
301
|
-
|
|
302
|
-
const cell8 = page.locator('#editor1 .ql-editor .ql-table td').nth(8);
|
|
303
|
-
const cell8Bounding = (await cell8.boundingBox())!;
|
|
304
|
-
expect(cell8Bounding).not.toBeNull();
|
|
305
|
-
await cell8.click();
|
|
306
|
-
await page.mouse.down();
|
|
307
|
-
await page.mouse.move(cell8Bounding.x - cell8Bounding.width * 0.5, cell8Bounding.y + cell8Bounding.height / 2);
|
|
308
|
-
await page.mouse.up();
|
|
309
|
-
await editorPage.blur();
|
|
310
|
-
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
311
|
-
key: 'Backspace',
|
|
312
|
-
code: 'Backspace',
|
|
313
|
-
keyCode: 13,
|
|
314
|
-
which: 13,
|
|
315
|
-
bubbles: true,
|
|
316
|
-
cancelable: true,
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(8)).toHaveText('');
|
|
320
|
-
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(7)).toHaveText('');
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
extendTest('should delete table when selected all cells and press delete', async ({ page, editorPage }) => {
|
|
324
|
-
editorPage.index = 0;
|
|
325
|
-
await editorPage.setContents([
|
|
326
|
-
{ insert: '\n' },
|
|
327
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
328
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
329
|
-
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 121 } } },
|
|
330
|
-
{ insert: '1' },
|
|
331
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
332
|
-
{ insert: '2' },
|
|
333
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
334
|
-
{ insert: '3' },
|
|
335
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
336
|
-
{ insert: '4' },
|
|
337
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
338
|
-
{ insert: '5' },
|
|
339
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
340
|
-
{ insert: '6' },
|
|
341
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
342
|
-
{ insert: '7' },
|
|
343
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
344
|
-
{ insert: '8' },
|
|
345
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
346
|
-
{ insert: '9' },
|
|
347
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
348
|
-
{ insert: '\n' },
|
|
349
|
-
]);
|
|
350
|
-
const cell1 = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
351
|
-
const cell1Bounding = (await cell1.boundingBox())!;
|
|
352
|
-
expect(cell1Bounding).not.toBeNull();
|
|
353
|
-
await cell1.click();
|
|
354
|
-
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
355
|
-
await expect(selectionLine).toBeVisible();
|
|
356
|
-
|
|
357
|
-
await page.mouse.down();
|
|
358
|
-
await page.mouse.move(cell1Bounding.x + cell1Bounding.width * 2.5, cell1Bounding.y + cell1Bounding.height * 2.5);
|
|
359
|
-
await page.mouse.up();
|
|
360
|
-
await editorPage.blur();
|
|
361
|
-
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
362
|
-
key: 'Backspace',
|
|
363
|
-
code: 'Backspace',
|
|
364
|
-
keyCode: 13,
|
|
365
|
-
which: 13,
|
|
366
|
-
bubbles: true,
|
|
367
|
-
cancelable: true,
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
expect(await page.locator('#editor1 .ql-table').count()).toBe(0);
|
|
371
|
-
});
|
|
372
|
-
|
|
1
|
+
import { expect, test } from '@playwright/test';
|
|
2
|
+
import { createTableBySelect, extendTest, pasteHTML } 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.describe('table cell keyboard handler enter', () => {
|
|
10
|
+
extendTest('cursor at the start of BlockEmbed', async ({ page, editorPage }) => {
|
|
11
|
+
editorPage.index = 0;
|
|
12
|
+
await editorPage.setContents([
|
|
13
|
+
{ insert: '\n' },
|
|
14
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
15
|
+
{ insert: { video: 'https://quilljs.com/' } },
|
|
16
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
17
|
+
{ insert: '\n' },
|
|
18
|
+
]);
|
|
19
|
+
await page.waitForTimeout(1000);
|
|
20
|
+
|
|
21
|
+
await editorPage.setSelection(2, 0);
|
|
22
|
+
await page.keyboard.press('Enter');
|
|
23
|
+
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner iframe').nth(0)).toBeVisible();
|
|
24
|
+
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0)).toBeVisible();
|
|
25
|
+
const delta = await editorPage.getContents();
|
|
26
|
+
const contents = [
|
|
27
|
+
{ insert: '\n' },
|
|
28
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
29
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
30
|
+
{ insert: { video: 'https://quilljs.com/' } },
|
|
31
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
32
|
+
{ insert: '\n' },
|
|
33
|
+
];
|
|
34
|
+
for (const [i, op] of delta.ops.entries()) {
|
|
35
|
+
expect(op).toStrictEqual(contents[i]);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
extendTest('cursor at the end of BlockEmbed', async ({ page, editorPage }) => {
|
|
40
|
+
editorPage.index = 0;
|
|
41
|
+
await editorPage.setContents([
|
|
42
|
+
{ insert: '\n' },
|
|
43
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
44
|
+
{ insert: { video: 'https://quilljs.com/' } },
|
|
45
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
46
|
+
{ insert: '\n' },
|
|
47
|
+
]);
|
|
48
|
+
await page.waitForTimeout(1000);
|
|
49
|
+
|
|
50
|
+
await editorPage.setSelection(3, 0);
|
|
51
|
+
await page.keyboard.press('Enter');
|
|
52
|
+
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0)).toBeVisible();
|
|
53
|
+
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner iframe').nth(0)).toBeVisible();
|
|
54
|
+
const delta = await editorPage.getContents();
|
|
55
|
+
const contents = [
|
|
56
|
+
{ insert: '\n' },
|
|
57
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
58
|
+
{ insert: { video: 'https://quilljs.com/' } },
|
|
59
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n\n' },
|
|
60
|
+
{ insert: '\n' },
|
|
61
|
+
];
|
|
62
|
+
for (const [i, op] of delta.ops.entries()) {
|
|
63
|
+
expect(op).toStrictEqual(contents[i]);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
extendTest('selection multiple line', async ({ page, editorPage }) => {
|
|
68
|
+
editorPage.index = 0;
|
|
69
|
+
await editorPage.setContents([
|
|
70
|
+
{ insert: '\n' },
|
|
71
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 100 } } },
|
|
72
|
+
{ insert: { video: 'https://quilljs.com/' } },
|
|
73
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
74
|
+
{ insert: '123' },
|
|
75
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
76
|
+
{ insert: '123' },
|
|
77
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
78
|
+
]);
|
|
79
|
+
await page.waitForTimeout(1000);
|
|
80
|
+
|
|
81
|
+
await editorPage.setSelection(4, 7);
|
|
82
|
+
await page.keyboard.press('Enter');
|
|
83
|
+
await expect(page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p')).toHaveCount(2);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
extendTest.describe('table cell keyboard handler ArrowUp and ArrowDown', () => {
|
|
88
|
+
extendTest('test TableSelection should update when selection change', async ({ page, editorPage }) => {
|
|
89
|
+
editorPage.index = 0;
|
|
90
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
91
|
+
|
|
92
|
+
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
93
|
+
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
94
|
+
await expect(selectionLine).toBeVisible();
|
|
95
|
+
|
|
96
|
+
await page.keyboard.press('ArrowRight');
|
|
97
|
+
await expect(selectionLine).toBeVisible();
|
|
98
|
+
const newSelectionWrapper = (await selectionLine.boundingBox())!;
|
|
99
|
+
expect(newSelectionWrapper).not.toBeNull();
|
|
100
|
+
const cell1Bound = (await page.locator('#editor1 .ql-editor td').nth(1).boundingBox())!;
|
|
101
|
+
expect(cell1Bound).not.toBeNull();
|
|
102
|
+
expect(cell1Bound).toEqual(newSelectionWrapper);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
extendTest('test TableSelection and TableMenuSelect should hide when selection out table', async ({ page }) => {
|
|
106
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
107
|
+
const firstCell1 = page.locator('#editor1').getByRole('cell').nth(0);
|
|
108
|
+
await firstCell1.click();
|
|
109
|
+
expect(page.locator('#container1 .table-up-selection')).toBeVisible();
|
|
110
|
+
|
|
111
|
+
await page.keyboard.down('ArrowUp');
|
|
112
|
+
expect(page.locator('#container1 .table-up-selection')).not.toBeVisible();
|
|
113
|
+
|
|
114
|
+
await firstCell1.click();
|
|
115
|
+
await firstCell1.click({ button: 'right' });
|
|
116
|
+
await expect(page.locator('#container1 .table-up-selection')).toBeVisible();
|
|
117
|
+
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
118
|
+
|
|
119
|
+
await page.keyboard.down('ArrowUp');
|
|
120
|
+
await expect(page.locator('#container1 .table-up-selection')).not.toBeVisible();
|
|
121
|
+
await expect(page.locator('.table-up-menu.is-contextmenu')).not.toBeVisible();
|
|
122
|
+
|
|
123
|
+
await createTableBySelect(page, 'container2', 3, 3);
|
|
124
|
+
const firstCell2 = page.locator('#editor2').getByRole('cell').nth(0);
|
|
125
|
+
await firstCell2.click();
|
|
126
|
+
await expect(page.locator('#container2 .table-up-selection')).toBeVisible();
|
|
127
|
+
|
|
128
|
+
await page.keyboard.down('ArrowUp');
|
|
129
|
+
await expect(page.locator('#container2 .table-up-selection')).not.toBeVisible();
|
|
130
|
+
|
|
131
|
+
await firstCell2.click();
|
|
132
|
+
await expect(page.locator('#container2 .table-up-selection')).toBeVisible();
|
|
133
|
+
await expect(page.locator('#container2 .table-up-menu')).toBeVisible();
|
|
134
|
+
|
|
135
|
+
await page.keyboard.down('ArrowUp');
|
|
136
|
+
await expect(page.locator('#container2 .table-up-selection')).not.toBeVisible();
|
|
137
|
+
await expect(page.locator('#container2 .table-up-menu')).not.toBeVisible();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
extendTest('test table keyboard ArrowUp and ArrowDown should work', async ({ page, editorPage }) => {
|
|
141
|
+
editorPage.index = 0;
|
|
142
|
+
editorPage.setContents([
|
|
143
|
+
{ insert: '123456\n' },
|
|
144
|
+
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'mnpytyt1cno', full: false, width: 291 } } },
|
|
145
|
+
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: '6ihx044tflt', full: false, width: 291 } } },
|
|
146
|
+
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'raiomwr9yuc', full: false, width: 291 } } },
|
|
147
|
+
{ insert: { 'table-up-col': { tableId: 'njo6syk0zqb', colId: 'qiuz7k09q6r', full: false, width: 291 } } },
|
|
148
|
+
{ insert: '123' },
|
|
149
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
150
|
+
{ insert: '123456' },
|
|
151
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
152
|
+
{ insert: '123' },
|
|
153
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'mnpytyt1cno', rowspan: 2, colspan: 2 } }, insert: '\n' },
|
|
154
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'raiomwr9yuc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
155
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'rvwpsb2pky', colId: 'qiuz7k09q6r', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
156
|
+
{ insert: '123' },
|
|
157
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
158
|
+
{ insert: '123456' },
|
|
159
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
160
|
+
{ insert: '123' },
|
|
161
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'vhg5x933cs', colId: 'raiomwr9yuc', rowspan: 1, colspan: 2 } }, insert: '\n' },
|
|
162
|
+
{ insert: '12345' },
|
|
163
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'mnpytyt1cno', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
164
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: '6ihx044tflt', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
165
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'raiomwr9yuc', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
166
|
+
{ attributes: { 'table-up-cell-inner': { tableId: 'njo6syk0zqb', rowId: 'nsb7mrygbk9', colId: 'qiuz7k09q6r', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
167
|
+
{ insert: '123456\n' },
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
await editorPage.setSelection(50, 0);
|
|
171
|
+
await page.keyboard.press('ArrowUp');
|
|
172
|
+
expect((await editorPage.getSelection())!.index).toBe(39);
|
|
173
|
+
|
|
174
|
+
await editorPage.setSelection(48, 0);
|
|
175
|
+
await page.keyboard.press('ArrowUp');
|
|
176
|
+
expect((await editorPage.getSelection())!.index).toBe(25);
|
|
177
|
+
|
|
178
|
+
await editorPage.setSelection(14, 0);
|
|
179
|
+
await page.keyboard.press('ArrowUp');
|
|
180
|
+
expect((await editorPage.getSelection())!.index).toBe(6);
|
|
181
|
+
|
|
182
|
+
await editorPage.setSelection(25, 0);
|
|
183
|
+
await page.keyboard.press('ArrowDown');
|
|
184
|
+
expect((await editorPage.getSelection())!.index).toBe(46);
|
|
185
|
+
|
|
186
|
+
await editorPage.setSelection(26, 0);
|
|
187
|
+
await page.keyboard.press('ArrowDown');
|
|
188
|
+
expect((await editorPage.getSelection())!.index).toBe(28);
|
|
189
|
+
|
|
190
|
+
await editorPage.setSelection(48, 0);
|
|
191
|
+
await page.keyboard.press('ArrowDown');
|
|
192
|
+
expect((await editorPage.getSelection())!.index).toBe(52);
|
|
193
|
+
|
|
194
|
+
await editorPage.setSelection(50, 0);
|
|
195
|
+
await page.keyboard.press('ArrowDown');
|
|
196
|
+
expect((await editorPage.getSelection())!.index).toBe(52);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
extendTest('test TableSelection should update when selection change and menu display', async ({ page, editorPage }) => {
|
|
200
|
+
editorPage.index = 0;
|
|
201
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
202
|
+
|
|
203
|
+
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
204
|
+
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
205
|
+
await expect(selectionLine).toBeVisible();
|
|
206
|
+
|
|
207
|
+
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click({ button: 'right' });
|
|
208
|
+
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
209
|
+
|
|
210
|
+
await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
|
|
211
|
+
await page.waitForTimeout(1000);
|
|
212
|
+
await expect(selectionLine).not.toBeVisible();
|
|
213
|
+
|
|
214
|
+
await page.keyboard.press('ArrowDown');
|
|
215
|
+
await expect(selectionLine).not.toBeVisible();
|
|
216
|
+
await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
extendTest.describe('TableSelection keyboard handler', () => {
|
|
221
|
+
extendTest('backspace should not remove cell content when focus element not in editor', async ({ page, editorPage }) => {
|
|
222
|
+
editorPage.index = 0;
|
|
223
|
+
await editorPage.setContents([
|
|
224
|
+
{ insert: '\n' },
|
|
225
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
226
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
227
|
+
{ attributes: { link: 'www.any.link' }, insert: 'some text' },
|
|
228
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
229
|
+
{ insert: '2' },
|
|
230
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
231
|
+
{ insert: '4' },
|
|
232
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
233
|
+
{ insert: '5' },
|
|
234
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td' } }, insert: '\n' },
|
|
235
|
+
{ insert: '\n' },
|
|
236
|
+
]);
|
|
237
|
+
await page.waitForTimeout(1000);
|
|
238
|
+
|
|
239
|
+
await page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0).click();
|
|
240
|
+
await page.locator('#editor1 .ql-tooltip .ql-action').click();
|
|
241
|
+
await page.keyboard.press('ArrowRight');
|
|
242
|
+
await page.keyboard.press('Backspace');
|
|
243
|
+
|
|
244
|
+
expect(await page.locator('#editor1 .ql-tooltip input').nth(0).inputValue()).toBe('www.any.lin');
|
|
245
|
+
expect(await page.locator('#editor1 .ql-table-wrapper .ql-table-cell-inner p').nth(0).textContent()).toBe('some text');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
extendTest('should handle delete table cell text when selected tds', async ({ page, editorPage }) => {
|
|
249
|
+
editorPage.index = 0;
|
|
250
|
+
await editorPage.setContents([
|
|
251
|
+
{ insert: '\n' },
|
|
252
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
253
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
254
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 121 } } },
|
|
255
|
+
{ insert: '1' },
|
|
256
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
257
|
+
{ insert: '2' },
|
|
258
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
259
|
+
{ insert: '3' },
|
|
260
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
261
|
+
{ insert: '4' },
|
|
262
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
263
|
+
{ insert: '5' },
|
|
264
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
265
|
+
{ insert: '6' },
|
|
266
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
267
|
+
{ insert: '7' },
|
|
268
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
269
|
+
{ insert: '8' },
|
|
270
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
271
|
+
{ insert: '9' },
|
|
272
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
273
|
+
{ insert: '\n' },
|
|
274
|
+
]);
|
|
275
|
+
|
|
276
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(0)).toHaveText('1');
|
|
277
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(1)).toHaveText('2');
|
|
278
|
+
|
|
279
|
+
const cell1 = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
280
|
+
const cell1Bounding = (await cell1.boundingBox())!;
|
|
281
|
+
expect(cell1Bounding).not.toBeNull();
|
|
282
|
+
await cell1.click();
|
|
283
|
+
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
284
|
+
await expect(selectionLine).toBeVisible();
|
|
285
|
+
|
|
286
|
+
await page.mouse.down();
|
|
287
|
+
await page.mouse.move(cell1Bounding.x + cell1Bounding.width * 1.5, cell1Bounding.y + cell1Bounding.height / 2);
|
|
288
|
+
await page.mouse.up();
|
|
289
|
+
await editorPage.blur();
|
|
290
|
+
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
291
|
+
key: 'Backspace',
|
|
292
|
+
code: 'Backspace',
|
|
293
|
+
keyCode: 13,
|
|
294
|
+
which: 13,
|
|
295
|
+
bubbles: true,
|
|
296
|
+
cancelable: true,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(0)).toHaveText('');
|
|
300
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(1)).toHaveText('');
|
|
301
|
+
|
|
302
|
+
const cell8 = page.locator('#editor1 .ql-editor .ql-table td').nth(8);
|
|
303
|
+
const cell8Bounding = (await cell8.boundingBox())!;
|
|
304
|
+
expect(cell8Bounding).not.toBeNull();
|
|
305
|
+
await cell8.click();
|
|
306
|
+
await page.mouse.down();
|
|
307
|
+
await page.mouse.move(cell8Bounding.x - cell8Bounding.width * 0.5, cell8Bounding.y + cell8Bounding.height / 2);
|
|
308
|
+
await page.mouse.up();
|
|
309
|
+
await editorPage.blur();
|
|
310
|
+
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
311
|
+
key: 'Backspace',
|
|
312
|
+
code: 'Backspace',
|
|
313
|
+
keyCode: 13,
|
|
314
|
+
which: 13,
|
|
315
|
+
bubbles: true,
|
|
316
|
+
cancelable: true,
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(8)).toHaveText('');
|
|
320
|
+
await expect(page.locator('#editor1 .ql-table .ql-table-cell').nth(7)).toHaveText('');
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
extendTest('should delete table when selected all cells and press delete', async ({ page, editorPage }) => {
|
|
324
|
+
editorPage.index = 0;
|
|
325
|
+
await editorPage.setContents([
|
|
326
|
+
{ insert: '\n' },
|
|
327
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 121 } } },
|
|
328
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 121 } } },
|
|
329
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 121 } } },
|
|
330
|
+
{ insert: '1' },
|
|
331
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
332
|
+
{ insert: '2' },
|
|
333
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
334
|
+
{ insert: '3' },
|
|
335
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
336
|
+
{ insert: '4' },
|
|
337
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
338
|
+
{ insert: '5' },
|
|
339
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
340
|
+
{ insert: '6' },
|
|
341
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
342
|
+
{ insert: '7' },
|
|
343
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
344
|
+
{ insert: '8' },
|
|
345
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
346
|
+
{ insert: '9' },
|
|
347
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
348
|
+
{ insert: '\n' },
|
|
349
|
+
]);
|
|
350
|
+
const cell1 = page.locator('#editor1 .ql-editor .ql-table td').nth(0);
|
|
351
|
+
const cell1Bounding = (await cell1.boundingBox())!;
|
|
352
|
+
expect(cell1Bounding).not.toBeNull();
|
|
353
|
+
await cell1.click();
|
|
354
|
+
const selectionLine = page.locator('#container1 .table-up-selection .table-up-selection__line');
|
|
355
|
+
await expect(selectionLine).toBeVisible();
|
|
356
|
+
|
|
357
|
+
await page.mouse.down();
|
|
358
|
+
await page.mouse.move(cell1Bounding.x + cell1Bounding.width * 2.5, cell1Bounding.y + cell1Bounding.height * 2.5);
|
|
359
|
+
await page.mouse.up();
|
|
360
|
+
await editorPage.blur();
|
|
361
|
+
await page.dispatchEvent('#editor1 .ql-editor', 'keydown', {
|
|
362
|
+
key: 'Backspace',
|
|
363
|
+
code: 'Backspace',
|
|
364
|
+
keyCode: 13,
|
|
365
|
+
which: 13,
|
|
366
|
+
bubbles: true,
|
|
367
|
+
cancelable: true,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
expect(await page.locator('#editor1 .ql-table').count()).toBe(0);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
extendTest('copy cells', async ({ page, editorPage }) => {
|
|
374
|
+
editorPage.page = page;
|
|
375
|
+
editorPage.index = 0;
|
|
376
|
+
await editorPage.setContents([
|
|
377
|
+
{ insert: '\n' },
|
|
378
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
|
|
379
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
|
|
380
|
+
{ insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
|
|
381
|
+
{ insert: '1' },
|
|
382
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
383
|
+
{ insert: '2' },
|
|
384
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
385
|
+
{ insert: '3' },
|
|
386
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
387
|
+
{ insert: '4' },
|
|
388
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 2, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
389
|
+
{ insert: '5' },
|
|
390
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 2, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
391
|
+
{ insert: '6' },
|
|
392
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
393
|
+
{ insert: '7' },
|
|
394
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
395
|
+
{ insert: '8' },
|
|
396
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
397
|
+
{ insert: '9' },
|
|
398
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody' } }, insert: '\n' },
|
|
399
|
+
{ insert: '\n' },
|
|
400
|
+
]);
|
|
401
|
+
const cell1Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
402
|
+
expect(cell1Bound).not.toBeNull();
|
|
403
|
+
|
|
404
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
405
|
+
page.mouse.move(cell1Bound.x + cell1Bound.width * 0.5, cell1Bound.y + cell1Bound.height * 0.5);
|
|
406
|
+
page.mouse.down();
|
|
407
|
+
page.mouse.move(cell1Bound.x + cell1Bound.width * 1.5, cell1Bound.y + cell1Bound.height * 1.5);
|
|
408
|
+
|
|
409
|
+
const tableSelection = page.locator('#container1 .table-up-toolbox .table-up-selection__line');
|
|
410
|
+
await expect(tableSelection).toBeVisible();
|
|
411
|
+
|
|
412
|
+
await editorPage.blur();
|
|
413
|
+
await page.keyboard.press('Control+c');
|
|
414
|
+
const copiedText = await page.evaluate(() => navigator.clipboard.readText());
|
|
415
|
+
expect(copiedText.replaceAll('\r', '')).toEqual(`1\n2\n4\n5\n`);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
extendTest('paste cells with struct(colspan)', async ({ page, browserName, editorPage }) => {
|
|
419
|
+
editorPage.page = page;
|
|
420
|
+
editorPage.index = 0;
|
|
421
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
422
|
+
|
|
423
|
+
const newCell1Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
424
|
+
expect(newCell1Bound).not.toBeNull();
|
|
425
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
426
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
427
|
+
page.mouse.down();
|
|
428
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 1.5, newCell1Bound.y + newCell1Bound.height * 1.5);
|
|
429
|
+
|
|
430
|
+
await editorPage.blur();
|
|
431
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="1" contenteditable="false"><table class="ql-table" data-table-id="1" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 200px;"><colgroup data-table-id="1" contenteditable="false"><col width="100px" data-table-id="1" data-col-id="1"><col width="100px" data-table-id="1" data-col-id="2"></colgroup><tbody data-table-id="1"><tr class="ql-table-row" data-table-id="1" data-row-id="1" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="1" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="1" data-col-id="1" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>1</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="1" data-col-id="2" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="1" data-col-id="2" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>2</p></div></td></tr><tr class="ql-table-row" data-table-id="1" data-row-id="2" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="2" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="2"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="2" data-col-id="1" data-rowspan="1" data-colspan="2" data-tag="td" data-wrap-tag="tbody"><p>4</p><p>5</p></div></td></tr></tbody></table></div>', { browserName });
|
|
432
|
+
|
|
433
|
+
const cells = page.locator('#container1 .ql-table-wrapper td');
|
|
434
|
+
await expect(cells.nth(0)).toHaveText('1');
|
|
435
|
+
await expect(cells.nth(1)).toHaveText('2');
|
|
436
|
+
await expect(cells.nth(3)).toHaveText('45');
|
|
437
|
+
await expect(cells.nth(3)).toHaveAttribute('colspan', '2');
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
extendTest('paste cells with struct(rowspan)', async ({ page, browserName, editorPage }) => {
|
|
441
|
+
editorPage.page = page;
|
|
442
|
+
editorPage.index = 0;
|
|
443
|
+
await createTableBySelect(page, 'container1', 5, 5);
|
|
444
|
+
|
|
445
|
+
const newCell1Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
446
|
+
expect(newCell1Bound).not.toBeNull();
|
|
447
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
448
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
449
|
+
page.mouse.down();
|
|
450
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 2.5, newCell1Bound.y + newCell1Bound.height * 1.5);
|
|
451
|
+
|
|
452
|
+
await editorPage.blur();
|
|
453
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="1" contenteditable="false"><table class="ql-table" data-table-id="1" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 240px;"><colgroup data-table-id="1" contenteditable="false"><col width="80px" data-table-id="1" data-col-id="1"><col width="80px" data-table-id="1" data-col-id="2"><col width="80px" data-table-id="1" data-col-id="3"></colgroup><tbody data-table-id="1"><tr class="ql-table-row" data-table-id="1" data-row-id="1" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="1" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="1" data-col-id="1" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>1</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="1" data-col-id="2" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="1" data-col-id="2" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>2</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="1" data-col-id="3" data-wrap-tag="tbody" rowspan="2" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="1" data-col-id="3" data-rowspan="2" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>3</p><p>8</p></div></td></tr><tr class="ql-table-row" data-table-id="1" data-row-id="2" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="2" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="2" data-col-id="1" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>6</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="2" data-col-id="2" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="2" data-col-id="2" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>7</p></div></td></tr></tbody></table></div>', { browserName });
|
|
454
|
+
|
|
455
|
+
const cells = page.locator('#container1 .ql-table-wrapper td');
|
|
456
|
+
await expect(cells.nth(0)).toHaveText('1');
|
|
457
|
+
await expect(cells.nth(1)).toHaveText('2');
|
|
458
|
+
await expect(cells.nth(2)).toHaveText('38');
|
|
459
|
+
await expect(cells.nth(2)).toHaveAttribute('rowspan', '2');
|
|
460
|
+
await expect(cells.nth(5)).toHaveText('6');
|
|
461
|
+
await expect(cells.nth(6)).toHaveText('7');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
extendTest('paste cells with struct(colspan and rowspan)', async ({ page, browserName, editorPage }) => {
|
|
465
|
+
editorPage.page = page;
|
|
466
|
+
editorPage.index = 0;
|
|
467
|
+
await createTableBySelect(page, 'container1', 5, 5);
|
|
468
|
+
|
|
469
|
+
const newCell1Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
470
|
+
expect(newCell1Bound).not.toBeNull();
|
|
471
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
472
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
473
|
+
page.mouse.down();
|
|
474
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 2.5, newCell1Bound.y + newCell1Bound.height * 1.5);
|
|
475
|
+
|
|
476
|
+
await editorPage.blur();
|
|
477
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="1" contenteditable="false"><table class="ql-table" data-table-id="1" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 363px;"><colgroup data-table-id="1" contenteditable="false"><col width="121px" data-table-id="1" data-col-id="1"><col width="121px" data-table-id="1" data-col-id="2"><col width="121px" data-table-id="1" data-col-id="3"></colgroup><tbody data-table-id="1"><tr class="ql-table-row" data-table-id="1" data-row-id="2" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="2" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="2"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="2" data-col-id="1" data-rowspan="1" data-colspan="2" data-tag="td" data-wrap-tag="tbody"><p>4</p><p>5</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="2" data-col-id="3" data-wrap-tag="tbody" rowspan="2" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="2" data-col-id="3" data-rowspan="2" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>6</p><p>9</p></div></td></tr><tr class="ql-table-row" data-table-id="1" data-row-id="3" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="1" data-row-id="3" data-col-id="1" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="3" data-col-id="1" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>7</p></div></td><td class="ql-table-cell" data-table-id="1" data-row-id="3" data-col-id="2" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="1" data-row-id="3" data-col-id="2" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>8</p></div></td></tr></tbody></table></div>', { browserName });
|
|
478
|
+
|
|
479
|
+
const cells = page.locator('#container1 .ql-table-wrapper td');
|
|
480
|
+
await expect(cells.nth(0)).toHaveText('45');
|
|
481
|
+
await expect(cells.nth(0)).toHaveAttribute('colspan', '2');
|
|
482
|
+
await expect(cells.nth(1)).toHaveText('69');
|
|
483
|
+
await expect(cells.nth(1)).toHaveAttribute('rowspan', '2');
|
|
484
|
+
await expect(cells.nth(4)).toHaveText('7');
|
|
485
|
+
await expect(cells.nth(5)).toHaveText('8');
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
extendTest('paste cells with `emptyRow` in `autoMerge` true', async ({ page, browserName, editorPage }) => {
|
|
489
|
+
editorPage.page = page;
|
|
490
|
+
editorPage.index = 0;
|
|
491
|
+
await createTableBySelect(page, 'container1', 5, 5);
|
|
492
|
+
|
|
493
|
+
const newCell1Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
494
|
+
expect(newCell1Bound).not.toBeNull();
|
|
495
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
496
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
497
|
+
page.mouse.down();
|
|
498
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 4.5, newCell1Bound.y + newCell1Bound.height * 2.5);
|
|
499
|
+
await editorPage.blur();
|
|
500
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="j89168rvqrd" contenteditable="false"><table class="ql-table" data-table-id="j89168rvqrd" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 730px;"><colgroup data-table-id="j89168rvqrd" contenteditable="false"><col width="146px" data-table-id="j89168rvqrd" data-col-id="i3bpg2i2oy"><col width="146px" data-table-id="j89168rvqrd" data-col-id="lpwv9bfkdxe"><col width="146px" data-table-id="j89168rvqrd" data-col-id="9oopcw7mbfq"><col width="146px" data-table-id="j89168rvqrd" data-col-id="ejdvsjml25"><col width="146px" data-table-id="j89168rvqrd" data-col-id="nialr8ceyks"></colgroup><tbody data-table-id="j89168rvqrd"><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="3" colspan="5" data-empty-row="["v4r34a160is","n73z32w0t9l"]"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-rowspan="3" data-colspan="5" data-tag="td" data-wrap-tag="tbody" data-empty-row="["v4r34a160is","n73z32w0t9l"]"><p></p></div></td></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="v4r34a160is" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="n73z32w0t9l" data-wrap-tag="tbody"></tr></tbody></table></div>', { browserName });
|
|
501
|
+
const cell1 = page.locator('#container1 .ql-table-wrapper td').nth(0);
|
|
502
|
+
await expect(cell1).not.toHaveAttribute('data-empty-row');
|
|
503
|
+
expect(await page.locator('#container1 .ql-table-wrapper tr').count()).toEqual(3);
|
|
504
|
+
|
|
505
|
+
await editorPage.setContents([]);
|
|
506
|
+
await createTableBySelect(page, 'container1', 5, 5);
|
|
507
|
+
const newCell2Bound = (await page.locator('#container1 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
508
|
+
expect(newCell2Bound).not.toBeNull();
|
|
509
|
+
await page.locator('#container1 .ql-table-wrapper td').nth(0).click();
|
|
510
|
+
page.mouse.move(newCell2Bound.x + newCell2Bound.width * 0.5, newCell2Bound.y + newCell2Bound.height * 0.5);
|
|
511
|
+
page.mouse.down();
|
|
512
|
+
page.mouse.move(newCell2Bound.x + newCell2Bound.width * 4.5, newCell2Bound.y + newCell2Bound.height * 3.5);
|
|
513
|
+
await editorPage.blur();
|
|
514
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="j89168rvqrd" contenteditable="false"><table class="ql-table" data-table-id="j89168rvqrd" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 730px;"><colgroup data-table-id="j89168rvqrd" contenteditable="false"><col width="146px" data-table-id="j89168rvqrd" data-col-id="i3bpg2i2oy"><col width="146px" data-table-id="j89168rvqrd" data-col-id="lpwv9bfkdxe"><col width="146px" data-table-id="j89168rvqrd" data-col-id="9oopcw7mbfq"><col width="146px" data-table-id="j89168rvqrd" data-col-id="ejdvsjml25"><col width="146px" data-table-id="j89168rvqrd" data-col-id="nialr8ceyks"></colgroup><tbody data-table-id="j89168rvqrd"><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="3" colspan="5" data-empty-row="["v4r34a160is","n73z32w0t9l"]" style="height: 49px;"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-rowspan="3" data-colspan="5" data-tag="td" data-wrap-tag="tbody" data-empty-row="["v4r34a160is","n73z32w0t9l"]" data-style="height: 49px;"><p></p></div></td></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="v4r34a160is" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="n73z32w0t9l" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="i3bpg2i2oy" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="lpwv9bfkdxe" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="lpwv9bfkdxe" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="9oopcw7mbfq" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="9oopcw7mbfq" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="ejdvsjml25" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="ejdvsjml25" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="nialr8ceyks" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="nialr8ceyks" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td></tr></tbody></table></div>', { browserName });
|
|
515
|
+
const cell2 = page.locator('#container1 .ql-table-wrapper td').nth(0);
|
|
516
|
+
await expect(cell2).not.toHaveAttribute('data-empty-row');
|
|
517
|
+
expect(await page.locator('#container1 .ql-table-wrapper tr').count()).toEqual(3);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
extendTest('paste cells with `emptyRow` in `autoMerge` false', async ({ page, browserName, editorPage }) => {
|
|
521
|
+
editorPage.page = page;
|
|
522
|
+
editorPage.index = 4;
|
|
523
|
+
await createTableBySelect(page, 'container5', 5, 5);
|
|
524
|
+
|
|
525
|
+
const newCell1Bound = (await page.locator('#container5 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
526
|
+
expect(newCell1Bound).not.toBeNull();
|
|
527
|
+
await page.locator('#container5 .ql-table-wrapper td').nth(0).click();
|
|
528
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
529
|
+
page.mouse.down();
|
|
530
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 4.5, newCell1Bound.y + newCell1Bound.height * 2.5);
|
|
531
|
+
await editorPage.blur();
|
|
532
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="j89168rvqrd" contenteditable="false"><table class="ql-table" data-table-id="j89168rvqrd" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 730px;"><colgroup data-table-id="j89168rvqrd" contenteditable="false"><col width="146px" data-table-id="j89168rvqrd" data-col-id="i3bpg2i2oy"><col width="146px" data-table-id="j89168rvqrd" data-col-id="lpwv9bfkdxe"><col width="146px" data-table-id="j89168rvqrd" data-col-id="9oopcw7mbfq"><col width="146px" data-table-id="j89168rvqrd" data-col-id="ejdvsjml25"><col width="146px" data-table-id="j89168rvqrd" data-col-id="nialr8ceyks"></colgroup><tbody data-table-id="j89168rvqrd"><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="3" colspan="5" data-empty-row="["v4r34a160is","n73z32w0t9l"]"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-rowspan="3" data-colspan="5" data-tag="td" data-wrap-tag="tbody" data-empty-row="["v4r34a160is","n73z32w0t9l"]"><p></p></div></td></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="v4r34a160is" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="n73z32w0t9l" data-wrap-tag="tbody"></tr></tbody></table></div>', { browserName });
|
|
533
|
+
const cell1 = page.locator('#container5 .ql-table-wrapper td').nth(0);
|
|
534
|
+
const emptyRow1 = await cell1.getAttribute('data-empty-row');
|
|
535
|
+
expect(emptyRow1).not.toBeNull();
|
|
536
|
+
try {
|
|
537
|
+
const data = JSON.parse(emptyRow1!);
|
|
538
|
+
expect(data.length).toEqual(2);
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
// data error
|
|
542
|
+
expect(false).toEqual(true);
|
|
543
|
+
}
|
|
544
|
+
expect(await page.locator('#container5 .ql-table-wrapper tr').count()).toEqual(5);
|
|
545
|
+
|
|
546
|
+
await editorPage.setContents([]);
|
|
547
|
+
await createTableBySelect(page, 'container5', 5, 5);
|
|
548
|
+
const newCell2Bound = (await page.locator('#container5 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
549
|
+
expect(newCell2Bound).not.toBeNull();
|
|
550
|
+
await page.locator('#container5 .ql-table-wrapper td').nth(0).click();
|
|
551
|
+
page.mouse.move(newCell2Bound.x + newCell2Bound.width * 0.5, newCell2Bound.y + newCell2Bound.height * 0.5);
|
|
552
|
+
page.mouse.down();
|
|
553
|
+
page.mouse.move(newCell2Bound.x + newCell2Bound.width * 4.5, newCell2Bound.y + newCell2Bound.height * 3.5);
|
|
554
|
+
await editorPage.blur();
|
|
555
|
+
await pasteHTML(page, '<div class="ql-table-wrapper" data-table-id="j89168rvqrd" contenteditable="false"><table class="ql-table" data-table-id="j89168rvqrd" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 730px;"><colgroup data-table-id="j89168rvqrd" contenteditable="false"><col width="146px" data-table-id="j89168rvqrd" data-col-id="i3bpg2i2oy"><col width="146px" data-table-id="j89168rvqrd" data-col-id="lpwv9bfkdxe"><col width="146px" data-table-id="j89168rvqrd" data-col-id="9oopcw7mbfq"><col width="146px" data-table-id="j89168rvqrd" data-col-id="ejdvsjml25"><col width="146px" data-table-id="j89168rvqrd" data-col-id="nialr8ceyks"></colgroup><tbody data-table-id="j89168rvqrd"><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="3" colspan="5" data-empty-row="["v4r34a160is","n73z32w0t9l"]" style="height: 49px;"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="m8wb3vitcit" data-col-id="i3bpg2i2oy" data-rowspan="3" data-colspan="5" data-tag="td" data-wrap-tag="tbody" data-empty-row="["v4r34a160is","n73z32w0t9l"]" data-style="height: 49px;"><p></p></div></td></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="v4r34a160is" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="n73z32w0t9l" data-wrap-tag="tbody"></tr><tr class="ql-table-row" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="i3bpg2i2oy" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="i3bpg2i2oy" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="lpwv9bfkdxe" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="lpwv9bfkdxe" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="9oopcw7mbfq" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="9oopcw7mbfq" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="ejdvsjml25" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="ejdvsjml25" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td><td class="ql-table-cell" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="nialr8ceyks" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="j89168rvqrd" data-row-id="rfiuu54tyn" data-col-id="nialr8ceyks" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p></p></div></td></tr></tbody></table></div>', { browserName });
|
|
556
|
+
const cell2 = page.locator('#container5 .ql-table-wrapper td').nth(0);
|
|
557
|
+
const emptyRow2 = await cell2.getAttribute('data-empty-row');
|
|
558
|
+
expect(emptyRow2).not.toBeNull();
|
|
559
|
+
try {
|
|
560
|
+
const data = JSON.parse(emptyRow2!);
|
|
561
|
+
expect(data.length).toEqual(2);
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
// data error
|
|
565
|
+
expect(false).toEqual(true);
|
|
566
|
+
}
|
|
567
|
+
expect(await page.locator('#container5 .ql-table-wrapper tr').count()).toEqual(5);
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
extendTest('paste cells with other Block', async ({ page, browserName, editorPage }) => {
|
|
571
|
+
editorPage.page = page;
|
|
572
|
+
editorPage.index = 4;
|
|
573
|
+
await createTableBySelect(page, 'container5', 5, 5);
|
|
574
|
+
|
|
575
|
+
const newCell1Bound = (await page.locator('#container5 .ql-table-wrapper td').nth(0).boundingBox())!;
|
|
576
|
+
expect(newCell1Bound).not.toBeNull();
|
|
577
|
+
await page.locator('#container5 .ql-table-wrapper td').nth(0).click();
|
|
578
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 0.5, newCell1Bound.y + newCell1Bound.height * 0.5);
|
|
579
|
+
page.mouse.down();
|
|
580
|
+
page.mouse.move(newCell1Bound.x + newCell1Bound.width * 2.5, newCell1Bound.y + newCell1Bound.height * 1.5);
|
|
581
|
+
await editorPage.blur();
|
|
582
|
+
await pasteHTML(page, `<div class="ql-table-wrapper" data-table-id="bein21b5pui" contenteditable="false"><table class="ql-table" data-table-id="bein21b5pui" cellpadding="0" cellspacing="0" style="margin-right: auto; width: 444px;"><colgroup data-table-id="bein21b5pui" contenteditable="false"><col width="142px" data-table-id="bein21b5pui" data-col-id="481dzooan6g"><col width="159px" data-table-id="bein21b5pui" data-col-id="hz2gh55d0ib"><col width="143px" data-table-id="bein21b5pui" data-col-id="feqmvzorecq"></colgroup><tbody data-table-id="bein21b5pui"><tr class="ql-table-row" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="481dzooan6g" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="481dzooan6g" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>1</p></div></td><td class="ql-table-cell" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="hz2gh55d0ib" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="hz2gh55d0ib" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>2<strong>123</strong>4</p><pre data-language="plain">www
|
|
583
|
+
</pre></div></td><td class="ql-table-cell" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="feqmvzorecq" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="bein21b5pui" data-row-id="ge4p39olq3t" data-col-id="feqmvzorecq" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><h1>3</h1></div></td></tr><tr class="ql-table-row" data-table-id="bein21b5pui" data-row-id="nvid3wj1n3" data-wrap-tag="tbody"><td class="ql-table-cell" data-table-id="bein21b5pui" data-row-id="nvid3wj1n3" data-col-id="481dzooan6g" data-wrap-tag="tbody" rowspan="1" colspan="2"><div class="ql-table-cell-inner" data-table-id="bein21b5pui" data-row-id="nvid3wj1n3" data-col-id="481dzooan6g" data-rowspan="1" data-colspan="2" data-tag="td" data-wrap-tag="tbody"><ol><li>4</li><li>5</li></ol><p></p></div></td><td class="ql-table-cell" data-table-id="bein21b5pui" data-row-id="nvid3wj1n3" data-col-id="feqmvzorecq" data-wrap-tag="tbody" rowspan="1" colspan="1"><div class="ql-table-cell-inner" data-table-id="bein21b5pui" data-row-id="nvid3wj1n3" data-col-id="feqmvzorecq" data-rowspan="1" data-colspan="1" data-tag="td" data-wrap-tag="tbody"><p>6</p></div></td></tr></tbody></table></div>`, { browserName });
|
|
584
|
+
|
|
585
|
+
const cells = page.locator('#container5 .ql-table-wrapper td');
|
|
586
|
+
await expect(cells.nth(0)).toHaveText('1');
|
|
587
|
+
await expect(cells.nth(1)).toHaveText('21234www');
|
|
588
|
+
const strongEl = cells.nth(1).locator('strong');
|
|
589
|
+
expect(await strongEl.count()).toEqual(1);
|
|
590
|
+
await expect(strongEl).toHaveText('123');
|
|
591
|
+
const codeBlock = cells.nth(1).locator('.ql-code-block-container');
|
|
592
|
+
const codeBlockLine = cells.nth(1).locator('.ql-code-block-container .ql-code-block');
|
|
593
|
+
expect(await codeBlock.count()).toEqual(1);
|
|
594
|
+
expect(await codeBlockLine.count()).toEqual(1);
|
|
595
|
+
await expect(cells.nth(2)).toHaveText('3');
|
|
596
|
+
const header1 = cells.nth(2).locator('h1');
|
|
597
|
+
expect(await header1.count()).toEqual(1);
|
|
598
|
+
await expect(cells.nth(5)).toHaveText('45');
|
|
599
|
+
await expect(cells.nth(5)).toHaveAttribute('colspan', '2');
|
|
600
|
+
const orderedList = cells.nth(5).locator('ol');
|
|
601
|
+
const orderedListItem = orderedList.locator('li');
|
|
602
|
+
expect(await orderedList.count()).toEqual(1);
|
|
603
|
+
const listItemCount = await orderedListItem.count();
|
|
604
|
+
expect(listItemCount).toEqual(2);
|
|
605
|
+
for (let i = 0; i < listItemCount; i++) {
|
|
606
|
+
await expect(orderedListItem.nth(i)).toHaveAttribute('data-list', 'ordered');
|
|
607
|
+
}
|
|
608
|
+
await expect(cells.nth(6)).toHaveText('6');
|
|
609
|
+
});
|
|
610
|
+
});
|