Skip to content

Commit 0803e37

Browse files
authored
feat: scroll wrapper when selection (#263)
* feat: auto scroll handler * chore: move TableScrollbar * feat: table selection auto scroll when selecting * feat: support y axis * refactor: move scroll util function * test: fix case
1 parent e55ed40 commit 0803e37

File tree

3 files changed

+315
-296
lines changed

3 files changed

+315
-296
lines changed

src/__tests__/e2e/table-keyboard-handler.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import type { TableCellInnerFormat } from '../../formats';
2+
import type { TableSelection } from '../../modules';
3+
import type { TableUp } from '../../table-up';
14
import { expect, test } from '@playwright/test';
25
import { createTableBySelect, extendTest, pasteHTML } from './utils';
36

@@ -402,9 +405,15 @@ extendTest.describe('TableSelection keyboard handler', () => {
402405
expect(cell1Bound).not.toBeNull();
403406

404407
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+
// set table selection
409+
await page.evaluate(() => {
410+
const tableUp = window.quills[0].getModule('table-up') as TableUp;
411+
const tableSelection = tableUp.getModule<TableSelection>('table-selection')!;
412+
const doms = document.querySelectorAll('#container1 td .ql-table-cell-inner');
413+
const cells = Array.from(doms).map(dom => (window as any).Quill.find(dom)) as TableCellInnerFormat[];
414+
tableSelection.setSelectedTds([cells[0], cells[1], cells[3]]);
415+
tableSelection.updateWithSelectedTds();
416+
});
408417

409418
const tableSelection = page.locator('#container1 .table-up-toolbox .table-up-selection__line');
410419
await expect(tableSelection).toBeVisible();

0 commit comments

Comments
 (0)