quill-table-up 3.1.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +7 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +168 -146
  4. package/dist/index.js +47 -47
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +52 -52
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +22 -24
  9. package/src/__tests__/e2e/custom-creator.test.ts +44 -44
  10. package/src/__tests__/e2e/editor-page.ts +77 -77
  11. package/src/__tests__/e2e/table-align.test.ts +104 -104
  12. package/src/__tests__/e2e/table-blots.test.ts +169 -169
  13. package/src/__tests__/e2e/table-caption.test.ts +134 -134
  14. package/src/__tests__/e2e/table-clipboard.test.ts +20 -20
  15. package/src/__tests__/e2e/table-hack.test.ts +151 -151
  16. package/src/__tests__/e2e/table-keyboard-handler.test.ts +12 -3
  17. package/src/__tests__/e2e/table-menu.test.ts +172 -172
  18. package/src/__tests__/e2e/table-resize.test.ts +654 -9
  19. package/src/__tests__/e2e/table-scrollbar.test.ts +144 -144
  20. package/src/__tests__/e2e/table-selection.test.ts +563 -563
  21. package/src/__tests__/e2e/types.d.ts +7 -7
  22. package/src/__tests__/e2e/utils.ts +52 -52
  23. package/src/__tests__/unit/table-blots.test.ts +720 -720
  24. package/src/__tests__/unit/table-caption.test.ts +234 -234
  25. package/src/__tests__/unit/table-cell-merge.test.ts +724 -724
  26. package/src/__tests__/unit/table-clipboard.test.ts +2176 -2176
  27. package/src/__tests__/unit/table-hack.test.ts +1014 -1014
  28. package/src/__tests__/unit/table-insert.test.ts +926 -926
  29. package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
  30. package/src/__tests__/unit/table-remove.test.ts +343 -343
  31. package/src/__tests__/unit/utils.test-d.ts +49 -49
  32. package/src/__tests__/unit/utils.test.ts +711 -711
  33. package/src/__tests__/unit/utils.ts +307 -307
  34. package/src/__tests__/unit/vitest.d.ts +14 -14
  35. package/src/formats/container-format.ts +107 -107
  36. package/src/formats/overrides/block-embed.ts +72 -72
  37. package/src/formats/overrides/block.ts +95 -95
  38. package/src/formats/overrides/index.ts +3 -3
  39. package/src/formats/overrides/scroll.ts +70 -70
  40. package/src/formats/table-body-format.ts +52 -52
  41. package/src/formats/table-caption-format.ts +116 -116
  42. package/src/formats/table-cell-format.ts +304 -304
  43. package/src/formats/table-cell-inner-format.ts +403 -398
  44. package/src/formats/table-colgroup-format.ts +136 -136
  45. package/src/formats/table-foot-format.ts +7 -7
  46. package/src/formats/table-head-format.ts +7 -7
  47. package/src/formats/table-main-format.ts +1 -1
  48. package/src/formats/table-row-format.ts +218 -210
  49. package/src/formats/utils.ts +6 -6
  50. package/src/index.ts +19 -19
  51. package/src/modules/index.ts +7 -7
  52. package/src/modules/table-align.ts +131 -131
  53. package/src/modules/table-clipboard/table-clipboard.ts +6 -8
  54. package/src/modules/table-dom-selector.ts +33 -33
  55. package/src/modules/table-menu/constants.ts +223 -223
  56. package/src/modules/table-menu/index.ts +4 -4
  57. package/src/modules/table-menu/table-menu-common.ts +330 -329
  58. package/src/modules/table-menu/table-menu-contextmenu.ts +111 -118
  59. package/src/modules/table-menu/table-menu-select.ts +96 -94
  60. package/src/modules/table-resize/index.ts +5 -5
  61. package/src/modules/table-resize/table-resize-box.ts +714 -363
  62. package/src/modules/table-resize/table-resize-common.ts +246 -382
  63. package/src/modules/table-resize/table-resize-drag.ts +241 -0
  64. package/src/modules/table-resize/table-resize-line.ts +244 -182
  65. package/src/modules/table-resize/table-resize-scale.ts +174 -173
  66. package/src/modules/table-resize/utils.ts +84 -3
  67. package/src/modules/table-scrollbar.ts +292 -292
  68. package/src/modules/table-selection.ts +613 -669
  69. package/src/style/button.less +45 -45
  70. package/src/style/color-picker.less +136 -136
  71. package/src/style/dialog.less +53 -53
  72. package/src/style/functions.less +9 -9
  73. package/src/style/index.less +120 -120
  74. package/src/style/input.less +64 -64
  75. package/src/style/select-box.less +52 -52
  76. package/src/style/table-creator.less +56 -56
  77. package/src/style/table-menu.less +125 -125
  78. package/src/style/table-resize-scale.less +31 -31
  79. package/src/style/table-resize.less +249 -202
  80. package/src/style/table-scrollbar.less +49 -49
  81. package/src/style/table-selection.less +23 -23
  82. package/src/style/tooltip.less +19 -19
  83. package/src/style/variables.less +1 -1
  84. package/src/svg/arrow-up-down.svg +11 -11
  85. package/src/svg/convert-cell.svg +7 -7
  86. package/src/table-up.ts +1360 -1360
  87. package/src/types.d.ts +4 -4
  88. package/src/utils/bem.ts +23 -23
  89. package/src/utils/blot-helper.ts +101 -105
  90. package/src/utils/color.ts +109 -109
  91. package/src/utils/components/button.ts +22 -22
  92. package/src/utils/components/color-picker.ts +236 -236
  93. package/src/utils/components/dialog.ts +83 -41
  94. package/src/utils/components/index.ts +6 -6
  95. package/src/utils/components/input.ts +74 -74
  96. package/src/utils/components/table/creator.ts +89 -89
  97. package/src/utils/components/table/index.ts +2 -2
  98. package/src/utils/components/table/select-box.ts +78 -78
  99. package/src/utils/components/tooltip.ts +179 -189
  100. package/src/utils/constants.ts +125 -124
  101. package/src/utils/drag-helper.ts +112 -0
  102. package/src/utils/index.ts +15 -14
  103. package/src/utils/is.ts +9 -9
  104. package/src/utils/position.ts +60 -60
  105. package/src/utils/resize-observer-helper.ts +47 -47
  106. package/src/utils/scroll.ts +145 -47
  107. package/src/utils/style-helper.ts +47 -47
  108. package/src/utils/transformer.ts +10 -10
  109. package/src/utils/transition-event-helper.ts +8 -8
  110. package/src/utils/types.ts +156 -157
  111. package/src/utils/utils.ts +12 -12
@@ -1,144 +1,144 @@
1
- import type { Locator } from '@playwright/test';
2
- import { expect, test } from '@playwright/test';
3
- import { createTableBySelect, extendTest } from './utils';
4
-
5
- test.beforeEach(async ({ page }) => {
6
- await page.goto('http://127.0.0.1:5500/docs/test.html');
7
- page.locator('.ql-container.ql-snow');
8
- });
9
- function getTransformValue(elemet: Locator, index: number) {
10
- return elemet.evaluate((element, { index }) => {
11
- const matrix = window.getComputedStyle(element).transform;
12
- const matrixValues = matrix.match(/^matrix\(([^)]+)\)$/)?.[1].split(', ').map(Number);
13
- return matrixValues ? matrixValues[index] : 0;
14
- }, { index });
15
- }
16
-
17
- test('test TableScrollbar', async ({ page }) => {
18
- await createTableBySelect(page, 'container2', 3, 3);
19
- const centerCell = page.locator('#editor2').getByRole('cell').nth(4);
20
- await centerCell.click();
21
- const cellBounding = (await centerCell.boundingBox())!;
22
- expect(cellBounding).not.toBeNull();
23
-
24
- await page.waitForTimeout(200);
25
- expect(await page.locator('#editor2 .table-up-scrollbar.is-vertical').isVisible()).toBeFalsy();
26
- expect(await page.locator('#editor2 .table-up-scrollbar.is-horizontal').isVisible()).toBeFalsy();
27
-
28
- const colBoundingBox = (await page.locator('#editor2 .table-up-resize-box__col-separator').nth(1).boundingBox())!;
29
- expect(colBoundingBox).not.toBeNull();
30
- await page.mouse.move(colBoundingBox.x + colBoundingBox.width - 4, colBoundingBox.y + 4);
31
- await page.mouse.down();
32
- await page.mouse.move(colBoundingBox.x + colBoundingBox.width - 4 + 100, colBoundingBox.y + 4);
33
- await page.mouse.up();
34
-
35
- await page.mouse.move(cellBounding.x, cellBounding.y);
36
- await page.waitForTimeout(200);
37
- expect(await page.locator('#editor2 .table-up-scrollbar.is-vertical').isVisible()).toBeFalsy();
38
- expect(await page.locator('#editor2 .table-up-scrollbar.is-horizontal').isVisible()).toBeTruthy();
39
- });
40
-
41
- extendTest('test TableScrollbar should update when text change', async ({ page, editorPage }) => {
42
- editorPage.index = 0;
43
- await editorPage.setContents([
44
- { insert: '\n' },
45
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 500 } } },
46
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 500 } } },
47
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 500 } } },
48
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
49
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
50
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
51
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
52
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
53
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
54
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
55
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
56
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
57
- { insert: '\n' },
58
- ]);
59
-
60
- const lineBound = (await page.locator('#editor1 .ql-editor > p').first().boundingBox())!;
61
- expect(lineBound).not.toBeNull();
62
- await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
63
- const scrollbarHorizontal = page.locator('#container1 .table-up-scrollbar.is-horizontal');
64
- await expect(scrollbarHorizontal).toBeVisible();
65
- const scrollbarTop = await getTransformValue(scrollbarHorizontal, 5);
66
-
67
- await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
68
-
69
- await expect(scrollbarHorizontal).toBeVisible();
70
- const newScrollbarTop = await getTransformValue(scrollbarHorizontal, 5);
71
- expect(newScrollbarTop - scrollbarTop).toBeCloseTo(lineBound.height, 0);
72
- });
73
-
74
- extendTest('test TableScrollbar should not effect selection', async ({ page, editorPage }) => {
75
- editorPage.index = 0;
76
- await editorPage.setContents([
77
- { insert: '\n' },
78
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 500 } } },
79
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 500 } } },
80
- { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 500 } } },
81
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
82
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
83
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
84
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
85
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
86
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
87
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
88
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
89
- { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
90
- { insert: '\n' },
91
- ]);
92
-
93
- await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
94
- const scrollbarHorizontal = page.locator('#container1 .table-up-scrollbar.is-horizontal .table-up-scrollbar__thumb');
95
- await expect(scrollbarHorizontal).toBeVisible();
96
- const bound = (await scrollbarHorizontal.boundingBox())!;
97
- expect(bound).not.toBeNull();
98
-
99
- await page.mouse.move(bound.x + bound.width / 2, bound.y + bound.height / 2);
100
- await page.mouse.down();
101
- expect(await page.evaluate(() => {
102
- return document.onselectstart && document.onselectstart(new Event('selectstart')) === false;
103
- })).toBe(true);
104
-
105
- await page.mouse.up();
106
- expect(await page.evaluate(() => {
107
- return !document.onselectstart || (document.onselectstart && document.onselectstart(new Event('selectstart')) === true);
108
- })).toBe(true);
109
- });
110
-
111
- extendTest('scrollbar should be no offset when container have padding', async ({ page, editorPage, browserName }) => {
112
- editorPage.index = 4;
113
- await editorPage.setContents([
114
- { insert: '\n' },
115
- { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 500 } } },
116
- { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 500 } } },
117
- { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 500 } } },
118
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
119
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
120
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
121
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
122
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
123
- { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
124
- { insert: '\n' },
125
- ]);
126
-
127
- const toolbox = page.locator('#editor5 .table-up-toolbox').nth(0);
128
- await expect(toolbox).toHaveCSS('left', '20px');
129
- await expect(toolbox).toHaveCSS('top', '20px');
130
-
131
- await page.locator('#editor5 .ql-editor td').nth(0).click();
132
- await page.waitForTimeout(1000);
133
- const selectionBounding = (await page.locator('#editor5 .table-up-selection').boundingBox())!;
134
- const scrollHorizontalScroll = (await page.locator('#editor5 .table-up-scrollbar.is-horizontal').boundingBox())!;
135
- expect(scrollHorizontalScroll).not.toBeNull();
136
- expect(selectionBounding).not.toBeNull();
137
- if (browserName === 'firefox') {
138
- // extra 1px for broder
139
- expect(scrollHorizontalScroll.x).toBe(selectionBounding.x + 3);
140
- }
141
- else {
142
- expect(scrollHorizontalScroll.x).toBe(selectionBounding.x + 2);
143
- }
144
- });
1
+ import type { Locator } from '@playwright/test';
2
+ import { expect, test } from '@playwright/test';
3
+ import { createTableBySelect, extendTest } from './utils';
4
+
5
+ test.beforeEach(async ({ page }) => {
6
+ await page.goto('http://127.0.0.1:5500/docs/test.html');
7
+ page.locator('.ql-container.ql-snow');
8
+ });
9
+ function getTransformValue(elemet: Locator, index: number) {
10
+ return elemet.evaluate((element, { index }) => {
11
+ const matrix = window.getComputedStyle(element).transform;
12
+ const matrixValues = matrix.match(/^matrix\(([^)]+)\)$/)?.[1].split(', ').map(Number);
13
+ return matrixValues ? matrixValues[index] : 0;
14
+ }, { index });
15
+ }
16
+
17
+ test('test TableScrollbar', async ({ page }) => {
18
+ await createTableBySelect(page, 'container2', 3, 3);
19
+ const centerCell = page.locator('#editor2').getByRole('cell').nth(4);
20
+ await centerCell.click();
21
+ const cellBounding = (await centerCell.boundingBox())!;
22
+ expect(cellBounding).not.toBeNull();
23
+
24
+ await page.waitForTimeout(200);
25
+ expect(await page.locator('#editor2 .table-up-scrollbar.is-vertical').isVisible()).toBeFalsy();
26
+ expect(await page.locator('#editor2 .table-up-scrollbar.is-horizontal').isVisible()).toBeFalsy();
27
+
28
+ const colBoundingBox = (await page.locator('#editor2 .table-up-resize-box__col-separator').nth(1).boundingBox())!;
29
+ expect(colBoundingBox).not.toBeNull();
30
+ await page.mouse.move(colBoundingBox.x + colBoundingBox.width - 4, colBoundingBox.y + 4);
31
+ await page.mouse.down();
32
+ await page.mouse.move(colBoundingBox.x + colBoundingBox.width - 4 + 100, colBoundingBox.y + 4);
33
+ await page.mouse.up();
34
+
35
+ await page.mouse.move(cellBounding.x, cellBounding.y);
36
+ await page.waitForTimeout(200);
37
+ expect(await page.locator('#editor2 .table-up-scrollbar.is-vertical').isVisible()).toBeFalsy();
38
+ expect(await page.locator('#editor2 .table-up-scrollbar.is-horizontal').isVisible()).toBeTruthy();
39
+ });
40
+
41
+ extendTest('test TableScrollbar should update when text change', async ({ page, editorPage }) => {
42
+ editorPage.index = 0;
43
+ await editorPage.setContents([
44
+ { insert: '\n' },
45
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 500 } } },
46
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 500 } } },
47
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 500 } } },
48
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
49
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
50
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
51
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
52
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
53
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
54
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
55
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
56
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
57
+ { insert: '\n' },
58
+ ]);
59
+
60
+ const lineBound = (await page.locator('#editor1 .ql-editor > p').first().boundingBox())!;
61
+ expect(lineBound).not.toBeNull();
62
+ await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
63
+ const scrollbarHorizontal = page.locator('#container1 .table-up-scrollbar.is-horizontal');
64
+ await expect(scrollbarHorizontal).toBeVisible();
65
+ const scrollbarTop = await getTransformValue(scrollbarHorizontal, 5);
66
+
67
+ await editorPage.updateContents([{ insert: '12345\n12345' }], 'user');
68
+
69
+ await expect(scrollbarHorizontal).toBeVisible();
70
+ const newScrollbarTop = await getTransformValue(scrollbarHorizontal, 5);
71
+ expect(newScrollbarTop - scrollbarTop).toBeCloseTo(lineBound.height, 0);
72
+ });
73
+
74
+ extendTest('test TableScrollbar should not effect selection', async ({ page, editorPage }) => {
75
+ editorPage.index = 0;
76
+ await editorPage.setContents([
77
+ { insert: '\n' },
78
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: '7jwlegz1wcx', full: false, width: 500 } } },
79
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'jzkt5xg4uoe', full: false, width: 500 } } },
80
+ { insert: { 'table-up-col': { tableId: '2y50yzsqukx', colId: 'ya1np2wbu5f', full: false, width: 500 } } },
81
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
82
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
83
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'q5927gxiii', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
84
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
85
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
86
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: '269nnst8unz', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
87
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: '7jwlegz1wcx', rowspan: 1, colspan: 1 } }, insert: '\n' },
88
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'jzkt5xg4uoe', rowspan: 1, colspan: 1 } }, insert: '\n' },
89
+ { attributes: { 'table-up-cell-inner': { tableId: '2y50yzsqukx', rowId: 'xpwngzum4e', colId: 'ya1np2wbu5f', rowspan: 1, colspan: 1 } }, insert: '\n' },
90
+ { insert: '\n' },
91
+ ]);
92
+
93
+ await page.locator('#editor1 .ql-table .ql-table-cell').nth(0).click();
94
+ const scrollbarHorizontal = page.locator('#container1 .table-up-scrollbar.is-horizontal .table-up-scrollbar__thumb');
95
+ await expect(scrollbarHorizontal).toBeVisible();
96
+ const bound = (await scrollbarHorizontal.boundingBox())!;
97
+ expect(bound).not.toBeNull();
98
+
99
+ await page.mouse.move(bound.x + bound.width / 2, bound.y + bound.height / 2);
100
+ await page.mouse.down();
101
+ expect(await page.evaluate(() => {
102
+ return document.onselectstart && document.onselectstart(new Event('selectstart')) === false;
103
+ })).toBe(true);
104
+
105
+ await page.mouse.up();
106
+ expect(await page.evaluate(() => {
107
+ return !document.onselectstart || (document.onselectstart && document.onselectstart(new Event('selectstart')) === true);
108
+ })).toBe(true);
109
+ });
110
+
111
+ extendTest('scrollbar should be no offset when container have padding', async ({ page, editorPage, browserName }) => {
112
+ editorPage.index = 4;
113
+ await editorPage.setContents([
114
+ { insert: '\n' },
115
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 500 } } },
116
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 500 } } },
117
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 500 } } },
118
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
119
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
120
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
121
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
122
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
123
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
124
+ { insert: '\n' },
125
+ ]);
126
+
127
+ const toolbox = page.locator('#editor5 .table-up-toolbox').nth(0);
128
+ await expect(toolbox).toHaveCSS('left', '20px');
129
+ await expect(toolbox).toHaveCSS('top', '20px');
130
+
131
+ await page.locator('#editor5 .ql-editor td').nth(0).click();
132
+ await page.waitForTimeout(1000);
133
+ const selectionBounding = (await page.locator('#editor5 .table-up-selection').boundingBox())!;
134
+ const scrollHorizontalScroll = (await page.locator('#editor5 .table-up-scrollbar.is-horizontal').boundingBox())!;
135
+ expect(scrollHorizontalScroll).not.toBeNull();
136
+ expect(selectionBounding).not.toBeNull();
137
+ if (browserName === 'firefox') {
138
+ // extra 1px for broder
139
+ expect(scrollHorizontalScroll.x).toBe(selectionBounding.x + 3);
140
+ }
141
+ else {
142
+ expect(scrollHorizontalScroll.x).toBe(selectionBounding.x + 2);
143
+ }
144
+ });