quill-table-up 2.2.0 → 2.2.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quill-table-up",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.2.2",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "A table module for quill2.x",
7
7
  "author": "zzxming",
@@ -47,8 +47,10 @@
47
47
  "@floating-ui/dom": "^1.6.13"
48
48
  },
49
49
  "devDependencies": {
50
+ "@babel/preset-env": "^7.27.1",
50
51
  "@esbuild-kit/cjs-loader": "^2.4.4",
51
52
  "@playwright/test": "^1.52.0",
53
+ "@rollup/plugin-babel": "^6.0.4",
52
54
  "@rollup/plugin-node-resolve": "^16.0.1",
53
55
  "@rollup/plugin-terser": "^0.4.4",
54
56
  "@rollup/plugin-typescript": "^11.1.6",
@@ -71,6 +73,7 @@
71
73
  "rollup": "^4.40.1",
72
74
  "rollup-plugin-dts": "^6.2.1",
73
75
  "rollup-plugin-svg-import": "^3.0.0",
76
+ "tslib": "^2.8.1",
74
77
  "typescript": "~5.7.3",
75
78
  "vitest": "^3.1.2"
76
79
  }
@@ -6,6 +6,47 @@ test.beforeEach(async ({ page }) => {
6
6
  page.locator('.ql-container.ql-snow');
7
7
  });
8
8
 
9
+ extendTest('tableCaption switch visiable', async ({ page, editorPage }) => {
10
+ editorPage.index = 0;
11
+ await editorPage.setContents([
12
+ { insert: '\nTable Caption' },
13
+ { attributes: { 'table-up-caption': { tableId: '1', side: 'top' } }, insert: '\n' },
14
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
15
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
16
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
17
+ { insert: '1' },
18
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
19
+ { insert: '2' },
20
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
21
+ { insert: '3' },
22
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
23
+ { insert: '4' },
24
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
25
+ { insert: '5' },
26
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
27
+ { insert: '6' },
28
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
29
+ { insert: '7' },
30
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
31
+ { insert: '8' },
32
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
33
+ { insert: '9' },
34
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
35
+ { insert: '\n' },
36
+ ]);
37
+ await page.waitForTimeout(1000);
38
+
39
+ const captionSwitch = page.locator('#editor1 .ql-editor .ql-table caption.ql-table-caption .ql-table-caption--switch').nth(0);
40
+ await expect(captionSwitch).not.toBeVisible();
41
+
42
+ const boundingBox = (await page.locator('#editor1 .ql-editor .ql-table caption.ql-table-caption').boundingBox())!;
43
+ expect(boundingBox).not.toBeNull();
44
+ await page.mouse.move(boundingBox.x + boundingBox.width / 2, boundingBox.y + boundingBox.height / 2);
45
+ await expect(captionSwitch).toBeVisible();
46
+ await page.mouse.move(0, 0);
47
+ await expect(captionSwitch).not.toBeVisible();
48
+ });
49
+
9
50
  extendTest('text tableCaption insert', async ({ page, editorPage }) => {
10
51
  editorPage.index = 0;
11
52
  await editorPage.setContents([
@@ -107,3 +107,38 @@ extendTest('test TableScrollbar should not effect selection', async ({ page, edi
107
107
  return !document.onselectstart || (document.onselectstart && document.onselectstart(new Event('selectstart')) === true);
108
108
  })).toBe(true);
109
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
+ });
@@ -515,3 +515,64 @@ extendTest('should delete tablewhen selected all cells and press delete', async
515
515
 
516
516
  expect(await page.locator('#editor1 .ql-table').count()).toBe(0);
517
517
  });
518
+
519
+ extendTest('selection should be no offset when container have padding', async ({ page, editorPage }) => {
520
+ editorPage.index = 4;
521
+ await editorPage.setContents([
522
+ { insert: '\n' },
523
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 300 } } },
524
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 300 } } },
525
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 300 } } },
526
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
527
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
528
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
529
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
530
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
531
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
532
+ { insert: '\n' },
533
+ ]);
534
+
535
+ const toolbox = page.locator('#editor5 .table-up-toolbox').nth(0);
536
+ await expect(toolbox).toHaveCSS('left', '20px');
537
+ await expect(toolbox).toHaveCSS('top', '20px');
538
+
539
+ await page.locator('#editor5 .ql-editor td').nth(0).click();
540
+
541
+ const tableBounding = (await page.locator('#editor5 .ql-editor .ql-table-wrapper').boundingBox())!;
542
+ const selectionBounding = (await page.locator('#editor5 .table-up-selection').boundingBox())!;
543
+ expect(tableBounding).not.toBeNull();
544
+ expect(selectionBounding).not.toBeNull();
545
+ expect(tableBounding.x).toBe(selectionBounding.x);
546
+ expect(tableBounding.y).toBe(selectionBounding.y);
547
+ });
548
+
549
+ extendTest('toolbox bounds should same with quill.root', async ({ page, editorPage }) => {
550
+ editorPage.index = 4;
551
+ const toolbox = page.locator('#editor5 .table-up-toolbox').nth(0);
552
+ const quillRoot = page.locator('#editor5 .ql-editor').nth(0);
553
+ const toolboxBoundingBefore = (await toolbox.boundingBox())!;
554
+ const quillRootBoundingBefore = (await quillRoot.boundingBox())!;
555
+ expect(toolboxBoundingBefore).not.toBeNull();
556
+ expect(quillRootBoundingBefore).not.toBeNull();
557
+ expect(toolboxBoundingBefore).toEqual(quillRootBoundingBefore);
558
+
559
+ await editorPage.setContents([
560
+ { insert: '\n' },
561
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 300 } } },
562
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 300 } } },
563
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 300 } } },
564
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
565
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
566
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
567
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
568
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
569
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
570
+ { insert: '\n' },
571
+ ]);
572
+
573
+ const toolboxBoundingAfter = (await toolbox.boundingBox())!;
574
+ const quillRootBoundingAfter = (await quillRoot.boundingBox())!;
575
+ expect(toolboxBoundingAfter).not.toBeNull();
576
+ expect(quillRootBoundingAfter).not.toBeNull();
577
+ expect(toolboxBoundingAfter).toEqual(quillRootBoundingAfter);
578
+ });