Skip to content

Commit

Permalink
feat: resize-box header shift multiple select
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming committed Nov 26, 2024
1 parent 8e72126 commit a654a38
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/modules/table-resize/table-resize-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { addScrollEvent, clearScrollEvent } from '../../utils';
import { TableResizeCommon } from './table-resize-common';
import { isTableAlignRight } from './utils';

interface Point {
x: number;
y: number;
};
export class TableResizeBox extends TableResizeCommon {
options: TableResizeBoxOptions;
root!: HTMLElement;
Expand All @@ -19,6 +23,7 @@ export class TableResizeBox extends TableResizeCommon {
colHeadWrapper: HTMLElement | null = null;
corner: HTMLElement | null = null;
scrollHandler: [HTMLElement, (e: Event) => void][] = [];
lastHeaderSelect: [Point, Point] | null = null;

constructor(public tableModule: TableUp, public table: HTMLElement, quill: Quill, options: Partial<TableResizeBoxOptions>) {
super(quill);
Expand Down Expand Up @@ -47,11 +52,27 @@ export class TableResizeBox extends TableResizeCommon {
const tableRect = this.table.getBoundingClientRect();
if (this.tableModule.tableSelection) {
const tableSelection = this.tableModule.tableSelection;
tableSelection.selectedTds = tableSelection.computeSelectedTds(
if (!e.shiftKey) {
this.lastHeaderSelect = null;
}
const currentBoundary: [Point, Point] = [
{ x: isX ? tableRect.left : clientX, y: isX ? clientY : tableRect.top },
{ x: isX ? tableRect.right : clientX, y: isX ? clientY : tableRect.bottom },
);
];
if (this.lastHeaderSelect) {
currentBoundary[0] = {
x: Math.min(currentBoundary[0].x, this.lastHeaderSelect[0].x),
y: Math.min(currentBoundary[0].y, this.lastHeaderSelect[0].y),
};
currentBoundary[1] = {
x: Math.max(currentBoundary[1].x, this.lastHeaderSelect[1].x),
y: Math.max(currentBoundary[1].y, this.lastHeaderSelect[1].y),
};
}

tableSelection.selectedTds = tableSelection.computeSelectedTds(...currentBoundary);
tableSelection.showSelection();
this.lastHeaderSelect = currentBoundary;
}
};

Expand Down

0 comments on commit a654a38

Please sign in to comment.