quill-table-up 3.1.2 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- 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 +20 -4
- 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 +8 -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 +713 -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 +915 -926
- package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
- package/src/__tests__/unit/table-remove.test.ts +313 -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 +1363 -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
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quill-table-up",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.1
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "3.2.1",
|
|
5
|
+
"packageManager": "pnpm@10.20.0",
|
|
6
6
|
"description": "A table module for quill2.x",
|
|
7
7
|
"author": "zzxming",
|
|
8
8
|
"license": "MIT",
|
|
@@ -30,15 +30,12 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"lint": "eslint
|
|
34
|
-
"lint:fix": "eslint . --fix",
|
|
33
|
+
"lint": "eslint",
|
|
35
34
|
"build": "tsx ./scripts/build.ts",
|
|
36
35
|
"dev": "tsx ./scripts/build.ts watch",
|
|
37
36
|
"server": "tsx ./scripts/start-server.ts",
|
|
38
37
|
"test:unit": "vitest",
|
|
39
|
-
"test:
|
|
40
|
-
"test:e2e": "playwright test",
|
|
41
|
-
"test:e2e-ui": "playwright test --ui"
|
|
38
|
+
"test:e2e": "playwright test"
|
|
42
39
|
},
|
|
43
40
|
"peerDependencies": {
|
|
44
41
|
"quill": "^2.0.3"
|
|
@@ -47,38 +44,39 @@
|
|
|
47
44
|
"@floating-ui/dom": "^1.7.4"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@babel/preset-env": "^7.28.
|
|
51
|
-
"@oxc-project/runtime": "^0.
|
|
52
|
-
"@playwright/test": "^1.
|
|
47
|
+
"@babel/preset-env": "^7.28.5",
|
|
48
|
+
"@oxc-project/runtime": "^0.96.0",
|
|
49
|
+
"@playwright/test": "^1.56.1",
|
|
53
50
|
"@prettier/plugin-xml": "^3.4.2",
|
|
54
|
-
"@rollup/plugin-babel": "^6.0
|
|
55
|
-
"@rollup/plugin-typescript": "^12.
|
|
56
|
-
"@types/gulp": "^4.0.
|
|
51
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
52
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
53
|
+
"@types/gulp": "^4.0.18",
|
|
57
54
|
"@types/gulp-clean-css": "^4.3.4",
|
|
58
55
|
"@types/gulp-less": "^0.0.36",
|
|
59
56
|
"@types/gulp-postcss": "^8.0.6",
|
|
60
|
-
"@types/node": "^24.
|
|
57
|
+
"@types/node": "^24.9.2",
|
|
61
58
|
"@types/postcss-pxtorem": "^6.1.0",
|
|
62
|
-
"@
|
|
63
|
-
"@typescript-eslint/
|
|
64
|
-
"@
|
|
65
|
-
"@vitest/
|
|
66
|
-
"@
|
|
59
|
+
"@types/ws": "^8.18.1",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
61
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
62
|
+
"@vitest/coverage-v8": "^4.0.6",
|
|
63
|
+
"@vitest/ui": "^4.0.6",
|
|
64
|
+
"@zzxming/eslint-config": "0.6.0",
|
|
67
65
|
"autoprefixer": "^10.4.21",
|
|
68
|
-
"eslint": "^9.
|
|
66
|
+
"eslint": "^9.39.0",
|
|
69
67
|
"gulp": "^5.0.1",
|
|
70
68
|
"gulp-clean-css": "^4.3.0",
|
|
71
69
|
"gulp-less": "^5.0.0",
|
|
72
70
|
"gulp-postcss": "^10.0.0",
|
|
73
|
-
"jsdom": "^27.
|
|
71
|
+
"jsdom": "^27.1.0",
|
|
74
72
|
"parchment": "^3.0.0",
|
|
75
73
|
"postcss-pxtorem": "^6.1.0",
|
|
76
74
|
"resize-observer-polyfill": "^1.5.1",
|
|
77
|
-
"tsdown": "^0.15.
|
|
75
|
+
"tsdown": "^0.15.12",
|
|
78
76
|
"tslib": "^2.8.1",
|
|
79
77
|
"tsx": "^4.20.6",
|
|
80
|
-
"typescript": "~5.9.
|
|
81
|
-
"vitest": "^
|
|
78
|
+
"typescript": "~5.9.3",
|
|
79
|
+
"vitest": "^4.0.6",
|
|
82
80
|
"ws": "^8.18.3"
|
|
83
81
|
}
|
|
84
82
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { expect, test } from '@playwright/test';
|
|
2
|
-
import { createTableBySelect } from './utils';
|
|
3
|
-
|
|
4
|
-
test.beforeEach(async ({ page }) => {
|
|
5
|
-
await page.goto('http://127.0.0.1:5500/docs/test.html');
|
|
6
|
-
page.locator('#editor1.ql-container.ql-snow');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('custom selecor should work', async ({ page }) => {
|
|
10
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
-
|
|
12
|
-
const isVisible = await page.locator('#editor1.ql-container .ql-table-wrapper').isVisible();
|
|
13
|
-
expect(isVisible).toBe(true);
|
|
14
|
-
const colCount = await page.locator('#editor1.ql-container .ql-table-wrapper col').count();
|
|
15
|
-
expect(colCount).toBe(3);
|
|
16
|
-
const rowCount = await page.locator('#editor1.ql-container .ql-table-wrapper tr').count();
|
|
17
|
-
expect(rowCount).toBe(3);
|
|
18
|
-
const cellCount = await page.locator('#editor1.ql-container .ql-table-wrapper td').count();
|
|
19
|
-
expect(cellCount).toBe(9);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('custom button should work', async ({ page }) => {
|
|
23
|
-
await page.locator('#container1 .ql-toolbar .ql-table-up > .ql-picker-label').first().click();
|
|
24
|
-
await page.locator('#container1 .ql-toolbar .ql-table-up .ql-custom-select').getByText('Custom').click();
|
|
25
|
-
|
|
26
|
-
await page.locator('.table-up-dialog .table-up-button.confirm').click();
|
|
27
|
-
const rowInput = page.locator('.table-up-dialog .table-up-input__input').first();
|
|
28
|
-
expect(rowInput).toHaveClass(/error/);
|
|
29
|
-
const errorText = await page.locator('.table-up-dialog .table-up-input__input').first().locator('.table-up-input__error-tip').textContent();
|
|
30
|
-
expect(errorText).toBe('Please enter a positive integer');
|
|
31
|
-
|
|
32
|
-
await page.locator('.table-up-input__item').nth(0).locator('input').fill('3');
|
|
33
|
-
await page.locator('.table-up-input__item').nth(1).locator('input').fill('3');
|
|
34
|
-
await page.getByRole('button', { name: 'Confirm' }).click();
|
|
35
|
-
|
|
36
|
-
const isVisible = await page.locator('#editor1.ql-container .ql-table-wrapper').isVisible();
|
|
37
|
-
expect(isVisible).toBe(true);
|
|
38
|
-
const colCount = await page.locator('#editor1.ql-container .ql-table-wrapper col').count();
|
|
39
|
-
expect(colCount).toBe(3);
|
|
40
|
-
const rowCount = await page.locator('#editor1.ql-container .ql-table-wrapper tr').count();
|
|
41
|
-
expect(rowCount).toBe(3);
|
|
42
|
-
const cellCount = await page.locator('#editor1.ql-container .ql-table-wrapper td').count();
|
|
43
|
-
expect(cellCount).toBe(9);
|
|
44
|
-
});
|
|
1
|
+
import { expect, test } from '@playwright/test';
|
|
2
|
+
import { createTableBySelect } from './utils';
|
|
3
|
+
|
|
4
|
+
test.beforeEach(async ({ page }) => {
|
|
5
|
+
await page.goto('http://127.0.0.1:5500/docs/test.html');
|
|
6
|
+
page.locator('#editor1.ql-container.ql-snow');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('custom selecor should work', async ({ page }) => {
|
|
10
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
+
|
|
12
|
+
const isVisible = await page.locator('#editor1.ql-container .ql-table-wrapper').isVisible();
|
|
13
|
+
expect(isVisible).toBe(true);
|
|
14
|
+
const colCount = await page.locator('#editor1.ql-container .ql-table-wrapper col').count();
|
|
15
|
+
expect(colCount).toBe(3);
|
|
16
|
+
const rowCount = await page.locator('#editor1.ql-container .ql-table-wrapper tr').count();
|
|
17
|
+
expect(rowCount).toBe(3);
|
|
18
|
+
const cellCount = await page.locator('#editor1.ql-container .ql-table-wrapper td').count();
|
|
19
|
+
expect(cellCount).toBe(9);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('custom button should work', async ({ page }) => {
|
|
23
|
+
await page.locator('#container1 .ql-toolbar .ql-table-up > .ql-picker-label').first().click();
|
|
24
|
+
await page.locator('#container1 .ql-toolbar .ql-table-up .ql-custom-select').getByText('Custom').click();
|
|
25
|
+
|
|
26
|
+
await page.locator('.table-up-dialog .table-up-button.confirm').click();
|
|
27
|
+
const rowInput = page.locator('.table-up-dialog .table-up-input__input').first();
|
|
28
|
+
expect(rowInput).toHaveClass(/error/);
|
|
29
|
+
const errorText = await page.locator('.table-up-dialog .table-up-input__input').first().locator('.table-up-input__error-tip').textContent();
|
|
30
|
+
expect(errorText).toBe('Please enter a positive integer');
|
|
31
|
+
|
|
32
|
+
await page.locator('.table-up-input__item').nth(0).locator('input').fill('3');
|
|
33
|
+
await page.locator('.table-up-input__item').nth(1).locator('input').fill('3');
|
|
34
|
+
await page.getByRole('button', { name: 'Confirm' }).click();
|
|
35
|
+
|
|
36
|
+
const isVisible = await page.locator('#editor1.ql-container .ql-table-wrapper').isVisible();
|
|
37
|
+
expect(isVisible).toBe(true);
|
|
38
|
+
const colCount = await page.locator('#editor1.ql-container .ql-table-wrapper col').count();
|
|
39
|
+
expect(colCount).toBe(3);
|
|
40
|
+
const rowCount = await page.locator('#editor1.ql-container .ql-table-wrapper tr').count();
|
|
41
|
+
expect(rowCount).toBe(3);
|
|
42
|
+
const cellCount = await page.locator('#editor1.ql-container .ql-table-wrapper td').count();
|
|
43
|
+
expect(cellCount).toBe(9);
|
|
44
|
+
});
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import type { Page } from '@playwright/test';
|
|
2
|
-
import type { Delta, Op } from 'quill';
|
|
3
|
-
|
|
4
|
-
// Specify the index of the editor before use.
|
|
5
|
-
export class EditorPage {
|
|
6
|
-
public index: number = 0;
|
|
7
|
-
constructor(public page: Page) {}
|
|
8
|
-
|
|
9
|
-
get root() {
|
|
10
|
-
return this.page.locator('.ql-editor');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async html(content: string) {
|
|
14
|
-
await this.page.evaluate(({ index, content: html }) => {
|
|
15
|
-
const contents = window.quills[index].clipboard.convert({ html, text: '\n' });
|
|
16
|
-
return window.quills[index].setContents(contents);
|
|
17
|
-
}, { index: this.index, content });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getSelection() {
|
|
21
|
-
return this.page.evaluate(({ index }) => {
|
|
22
|
-
return window.quills[index].getSelection();
|
|
23
|
-
}, { index: this.index });
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async setSelection(index: null): Promise<void>;
|
|
27
|
-
async setSelection(index: number, length: number): Promise<void>;
|
|
28
|
-
async setSelection(range: { index: number; length: number }): Promise<void>;
|
|
29
|
-
async setSelection(
|
|
30
|
-
range: { index: number; length: number } | number | null,
|
|
31
|
-
length?: number,
|
|
32
|
-
) {
|
|
33
|
-
await this.page.evaluate(
|
|
34
|
-
({ index, range }) => window.quills[index].setSelection(range),
|
|
35
|
-
{ index: this.index, range: typeof range === 'number' ? { index: range, length: length || 0 } : range },
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async updateContents(delta: Op[], source: 'api' | 'user' = 'api') {
|
|
40
|
-
await this.page.evaluate(
|
|
41
|
-
({ index, delta, source }) => {
|
|
42
|
-
window.quills[index].updateContents(delta, source);
|
|
43
|
-
},
|
|
44
|
-
{ index: this.index, delta, source },
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async setContents(delta: Op[]) {
|
|
49
|
-
await this.page.evaluate(({ index, delta }) => {
|
|
50
|
-
window.quills[index].setContents(delta);
|
|
51
|
-
}, { index: this.index, delta });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getContents(): Promise<Delta> {
|
|
55
|
-
return this.page.evaluate(({ index }) => {
|
|
56
|
-
return window.quills[index].getContents();
|
|
57
|
-
}, { index: this.index });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
focus(): Promise<void> {
|
|
61
|
-
return this.page.evaluate(({ index }) => {
|
|
62
|
-
return window.quills[index].focus();
|
|
63
|
-
}, { index: this.index });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
blur(): Promise<void> {
|
|
67
|
-
return this.page.evaluate(({ index }) => {
|
|
68
|
-
return window.quills[index].blur();
|
|
69
|
-
}, { index: this.index });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
enable(enabled: boolean) {
|
|
73
|
-
return this.page.evaluate(({ index, enabled }) => {
|
|
74
|
-
return window.quills[index].enable(enabled);
|
|
75
|
-
}, { index: this.index, enabled });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
import type { Delta, Op } from 'quill';
|
|
3
|
+
|
|
4
|
+
// Specify the index of the editor before use.
|
|
5
|
+
export class EditorPage {
|
|
6
|
+
public index: number = 0;
|
|
7
|
+
constructor(public page: Page) {}
|
|
8
|
+
|
|
9
|
+
get root() {
|
|
10
|
+
return this.page.locator('.ql-editor');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async html(content: string) {
|
|
14
|
+
await this.page.evaluate(({ index, content: html }) => {
|
|
15
|
+
const contents = window.quills[index].clipboard.convert({ html, text: '\n' });
|
|
16
|
+
return window.quills[index].setContents(contents);
|
|
17
|
+
}, { index: this.index, content });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getSelection() {
|
|
21
|
+
return this.page.evaluate(({ index }) => {
|
|
22
|
+
return window.quills[index].getSelection();
|
|
23
|
+
}, { index: this.index });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async setSelection(index: null): Promise<void>;
|
|
27
|
+
async setSelection(index: number, length: number): Promise<void>;
|
|
28
|
+
async setSelection(range: { index: number; length: number }): Promise<void>;
|
|
29
|
+
async setSelection(
|
|
30
|
+
range: { index: number; length: number } | number | null,
|
|
31
|
+
length?: number,
|
|
32
|
+
) {
|
|
33
|
+
await this.page.evaluate(
|
|
34
|
+
({ index, range }) => window.quills[index].setSelection(range),
|
|
35
|
+
{ index: this.index, range: typeof range === 'number' ? { index: range, length: length || 0 } : range },
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async updateContents(delta: Op[], source: 'api' | 'user' = 'api') {
|
|
40
|
+
await this.page.evaluate(
|
|
41
|
+
({ index, delta, source }) => {
|
|
42
|
+
window.quills[index].updateContents(delta, source);
|
|
43
|
+
},
|
|
44
|
+
{ index: this.index, delta, source },
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async setContents(delta: Op[]) {
|
|
49
|
+
await this.page.evaluate(({ index, delta }) => {
|
|
50
|
+
window.quills[index].setContents(delta);
|
|
51
|
+
}, { index: this.index, delta });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getContents(): Promise<Delta> {
|
|
55
|
+
return this.page.evaluate(({ index }) => {
|
|
56
|
+
return window.quills[index].getContents();
|
|
57
|
+
}, { index: this.index });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
focus(): Promise<void> {
|
|
61
|
+
return this.page.evaluate(({ index }) => {
|
|
62
|
+
return window.quills[index].focus();
|
|
63
|
+
}, { index: this.index });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
blur(): Promise<void> {
|
|
67
|
+
return this.page.evaluate(({ index }) => {
|
|
68
|
+
return window.quills[index].blur();
|
|
69
|
+
}, { index: this.index });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
enable(enabled: boolean) {
|
|
73
|
+
return this.page.evaluate(({ index, enabled }) => {
|
|
74
|
+
return window.quills[index].enable(enabled);
|
|
75
|
+
}, { index: this.index, enabled });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,104 +1,104 @@
|
|
|
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 TableAlign should functional', async ({ page }) => {
|
|
10
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
-
const centerCell = page.locator('#editor1').getByRole('cell').nth(4);
|
|
12
|
-
await centerCell.click();
|
|
13
|
-
const cellBounding = (await centerCell.boundingBox())!;
|
|
14
|
-
expect(cellBounding).not.toBeNull();
|
|
15
|
-
await page.mouse.move(cellBounding.x, cellBounding.y);
|
|
16
|
-
const colBoundingBox = (await page.locator('#editor1 .table-up-resize-line__col').boundingBox())!;
|
|
17
|
-
expect(colBoundingBox).not.toBeNull();
|
|
18
|
-
await page.mouse.move(colBoundingBox.x + colBoundingBox.width / 2, colBoundingBox.y + colBoundingBox.height / 2);
|
|
19
|
-
await page.mouse.down();
|
|
20
|
-
await page.mouse.move(colBoundingBox.x + colBoundingBox.width / 2 - 200, colBoundingBox.y + colBoundingBox.height / 2);
|
|
21
|
-
await page.mouse.up();
|
|
22
|
-
|
|
23
|
-
expect(await page.locator('#editor1 .table-up-align').isVisible()).toBeTruthy();
|
|
24
|
-
|
|
25
|
-
const table = page.locator('#editor1 .ql-editor .ql-table');
|
|
26
|
-
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="center"]').click();
|
|
27
|
-
await expect(table).toHaveCSS('margin-left', `100px`);
|
|
28
|
-
await expect(table).toHaveCSS('margin-right', `100px`);
|
|
29
|
-
|
|
30
|
-
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="right"]').click();
|
|
31
|
-
await expect(table).toHaveCSS('margin-left', `200px`);
|
|
32
|
-
await expect(table).toHaveCSS('margin-right', '0px');
|
|
33
|
-
|
|
34
|
-
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="left"]').click();
|
|
35
|
-
await expect(table).toHaveCSS('margin-left', '0px');
|
|
36
|
-
await expect(table).toHaveCSS('margin-right', '200px');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
extendTest('test TableAlign should update after resize', async ({ page }) => {
|
|
40
|
-
await createTableBySelect(page, 'container1', 3, 3);
|
|
41
|
-
const centerCell = page.locator('#editor1').getByRole('cell').nth(4);
|
|
42
|
-
await centerCell.click();
|
|
43
|
-
const cellBounding = (await centerCell.boundingBox())!;
|
|
44
|
-
expect(cellBounding).not.toBeNull();
|
|
45
|
-
const alignToolbar = page.locator('#editor1 .table-up-align');
|
|
46
|
-
expect(await alignToolbar.isVisible()).toBeTruthy();
|
|
47
|
-
const alignToolbarBoundingBox = (await alignToolbar.boundingBox())!;
|
|
48
|
-
expect(alignToolbarBoundingBox).not.toBeNull();
|
|
49
|
-
|
|
50
|
-
await page.mouse.move(cellBounding.x + cellBounding.width / 2, cellBounding.y + cellBounding.height / 2);
|
|
51
|
-
const rowBoundingBox = (await page.locator('#editor1 .table-up-resize-line__row').boundingBox())!;
|
|
52
|
-
expect(rowBoundingBox).not.toBeNull();
|
|
53
|
-
|
|
54
|
-
await page.mouse.move(rowBoundingBox.x + rowBoundingBox.width / 2, rowBoundingBox.y + rowBoundingBox.height / 2);
|
|
55
|
-
await page.mouse.down();
|
|
56
|
-
await page.mouse.move(rowBoundingBox.x + rowBoundingBox.width / 2, rowBoundingBox.y + rowBoundingBox.height / 2 + 200);
|
|
57
|
-
await page.mouse.up();
|
|
58
|
-
|
|
59
|
-
expect(await alignToolbar.isVisible()).toBeTruthy();
|
|
60
|
-
const newAlignToolbarBoundingBox = (await alignToolbar.boundingBox())!;
|
|
61
|
-
expect(newAlignToolbarBoundingBox).not.toBeNull();
|
|
62
|
-
// resize used Math.round, numDigits is 1 but not 0.1
|
|
63
|
-
expect(newAlignToolbarBoundingBox.y - alignToolbarBoundingBox.y).toBeCloseTo(200, -1);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
extendTest('test TableAlign should update when text change', async ({ page, editorPage }) => {
|
|
67
|
-
editorPage.index = 0;
|
|
68
|
-
await editorPage.setContents([
|
|
69
|
-
{ insert: '\n' },
|
|
70
|
-
{ insert: '\n' },
|
|
71
|
-
{ insert: '\n' },
|
|
72
|
-
{ insert: '\n' },
|
|
73
|
-
{ insert: '\n' },
|
|
74
|
-
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 50 } } },
|
|
75
|
-
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 50 } } },
|
|
76
|
-
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 50 } } },
|
|
77
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
78
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
79
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
80
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
81
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
82
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
83
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
84
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
85
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
86
|
-
{ insert: '\n' },
|
|
87
|
-
]);
|
|
88
|
-
|
|
89
|
-
const lineBound = (await page.locator('#editor1 .ql-editor > p').first().boundingBox())!;
|
|
90
|
-
expect(lineBound).not.toBeNull();
|
|
91
|
-
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
92
|
-
const alignToolbar = page.locator('#container1 .table-up-align');
|
|
93
|
-
await expect(alignToolbar).toBeVisible();
|
|
94
|
-
const toolbarBound = (await alignToolbar.boundingBox())!;
|
|
95
|
-
expect(toolbarBound).not.toBeNull();
|
|
96
|
-
|
|
97
|
-
await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
|
|
98
|
-
|
|
99
|
-
await expect(alignToolbar).toBeVisible();
|
|
100
|
-
const newToolbarBound = (await alignToolbar.boundingBox())!;
|
|
101
|
-
expect(toolbarBound).not.toBeNull();
|
|
102
|
-
|
|
103
|
-
expect(newToolbarBound.y - toolbarBound.y).toBeCloseTo(lineBound.height, 5);
|
|
104
|
-
});
|
|
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 TableAlign should functional', async ({ page }) => {
|
|
10
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
11
|
+
const centerCell = page.locator('#editor1').getByRole('cell').nth(4);
|
|
12
|
+
await centerCell.click();
|
|
13
|
+
const cellBounding = (await centerCell.boundingBox())!;
|
|
14
|
+
expect(cellBounding).not.toBeNull();
|
|
15
|
+
await page.mouse.move(cellBounding.x, cellBounding.y);
|
|
16
|
+
const colBoundingBox = (await page.locator('#editor1 .table-up-resize-line__col').boundingBox())!;
|
|
17
|
+
expect(colBoundingBox).not.toBeNull();
|
|
18
|
+
await page.mouse.move(colBoundingBox.x + colBoundingBox.width / 2, colBoundingBox.y + colBoundingBox.height / 2);
|
|
19
|
+
await page.mouse.down();
|
|
20
|
+
await page.mouse.move(colBoundingBox.x + colBoundingBox.width / 2 - 200, colBoundingBox.y + colBoundingBox.height / 2);
|
|
21
|
+
await page.mouse.up();
|
|
22
|
+
|
|
23
|
+
expect(await page.locator('#editor1 .table-up-align').isVisible()).toBeTruthy();
|
|
24
|
+
|
|
25
|
+
const table = page.locator('#editor1 .ql-editor .ql-table');
|
|
26
|
+
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="center"]').click();
|
|
27
|
+
await expect(table).toHaveCSS('margin-left', `100px`);
|
|
28
|
+
await expect(table).toHaveCSS('margin-right', `100px`);
|
|
29
|
+
|
|
30
|
+
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="right"]').click();
|
|
31
|
+
await expect(table).toHaveCSS('margin-left', `200px`);
|
|
32
|
+
await expect(table).toHaveCSS('margin-right', '0px');
|
|
33
|
+
|
|
34
|
+
await page.locator('#editor1 .table-up-align .table-up-align__item[data-align="left"]').click();
|
|
35
|
+
await expect(table).toHaveCSS('margin-left', '0px');
|
|
36
|
+
await expect(table).toHaveCSS('margin-right', '200px');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
extendTest('test TableAlign should update after resize', async ({ page }) => {
|
|
40
|
+
await createTableBySelect(page, 'container1', 3, 3);
|
|
41
|
+
const centerCell = page.locator('#editor1').getByRole('cell').nth(4);
|
|
42
|
+
await centerCell.click();
|
|
43
|
+
const cellBounding = (await centerCell.boundingBox())!;
|
|
44
|
+
expect(cellBounding).not.toBeNull();
|
|
45
|
+
const alignToolbar = page.locator('#editor1 .table-up-align');
|
|
46
|
+
expect(await alignToolbar.isVisible()).toBeTruthy();
|
|
47
|
+
const alignToolbarBoundingBox = (await alignToolbar.boundingBox())!;
|
|
48
|
+
expect(alignToolbarBoundingBox).not.toBeNull();
|
|
49
|
+
|
|
50
|
+
await page.mouse.move(cellBounding.x + cellBounding.width / 2, cellBounding.y + cellBounding.height / 2);
|
|
51
|
+
const rowBoundingBox = (await page.locator('#editor1 .table-up-resize-line__row').boundingBox())!;
|
|
52
|
+
expect(rowBoundingBox).not.toBeNull();
|
|
53
|
+
|
|
54
|
+
await page.mouse.move(rowBoundingBox.x + rowBoundingBox.width / 2, rowBoundingBox.y + rowBoundingBox.height / 2);
|
|
55
|
+
await page.mouse.down();
|
|
56
|
+
await page.mouse.move(rowBoundingBox.x + rowBoundingBox.width / 2, rowBoundingBox.y + rowBoundingBox.height / 2 + 200);
|
|
57
|
+
await page.mouse.up();
|
|
58
|
+
|
|
59
|
+
expect(await alignToolbar.isVisible()).toBeTruthy();
|
|
60
|
+
const newAlignToolbarBoundingBox = (await alignToolbar.boundingBox())!;
|
|
61
|
+
expect(newAlignToolbarBoundingBox).not.toBeNull();
|
|
62
|
+
// resize used Math.round, numDigits is 1 but not 0.1
|
|
63
|
+
expect(newAlignToolbarBoundingBox.y - alignToolbarBoundingBox.y).toBeCloseTo(200, -1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
extendTest('test TableAlign should update when text change', async ({ page, editorPage }) => {
|
|
67
|
+
editorPage.index = 0;
|
|
68
|
+
await editorPage.setContents([
|
|
69
|
+
{ insert: '\n' },
|
|
70
|
+
{ insert: '\n' },
|
|
71
|
+
{ insert: '\n' },
|
|
72
|
+
{ insert: '\n' },
|
|
73
|
+
{ insert: '\n' },
|
|
74
|
+
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 50 } } },
|
|
75
|
+
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 50 } } },
|
|
76
|
+
{ insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 50 } } },
|
|
77
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
78
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
79
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
80
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
81
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
82
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
83
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
84
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
85
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
|
|
86
|
+
{ insert: '\n' },
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
const lineBound = (await page.locator('#editor1 .ql-editor > p').first().boundingBox())!;
|
|
90
|
+
expect(lineBound).not.toBeNull();
|
|
91
|
+
await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
|
|
92
|
+
const alignToolbar = page.locator('#container1 .table-up-align');
|
|
93
|
+
await expect(alignToolbar).toBeVisible();
|
|
94
|
+
const toolbarBound = (await alignToolbar.boundingBox())!;
|
|
95
|
+
expect(toolbarBound).not.toBeNull();
|
|
96
|
+
|
|
97
|
+
await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
|
|
98
|
+
|
|
99
|
+
await expect(alignToolbar).toBeVisible();
|
|
100
|
+
const newToolbarBound = (await alignToolbar.boundingBox())!;
|
|
101
|
+
expect(toolbarBound).not.toBeNull();
|
|
102
|
+
|
|
103
|
+
expect(newToolbarBound.y - toolbarBound.y).toBeCloseTo(lineBound.height, 5);
|
|
104
|
+
});
|