fix multiselect

This commit is contained in:
Ekaterina Balakina
2022-12-15 15:53:09 +01:00
parent fbe406c511
commit e94ebe9f4c
8 changed files with 312 additions and 149 deletions

View File

@@ -1,6 +1,6 @@
export interface Cell {
row: number | null
col: number | null
row: number
col: number
}
export class CellRange {
@@ -12,14 +12,22 @@ export class CellRange {
this._end = end ?? this._start
}
get start() {
isEmpty() {
return this._start == null || this._end == null
}
isSingleCell() {
return !this.isEmpty() && this._start?.col === this._end?.col && this._start?.row === this._end?.row
}
get start(): Cell {
return {
row: Math.min(this._start?.row ?? NaN, this._end?.row ?? NaN),
col: Math.min(this._start?.col ?? NaN, this._end?.col ?? NaN),
}
}
get end() {
get end(): Cell {
return {
row: Math.max(this._start?.row ?? NaN, this._end?.row ?? NaN),
col: Math.max(this._start?.col ?? NaN, this._end?.col ?? NaN),
@@ -27,19 +35,11 @@ export class CellRange {
}
startRange(value: Cell) {
if (value == null) {
return
}
this._start = value
this._end = value
}
endRange(value: Cell) {
if (value == null) {
return
}
this._end = value
}
@@ -47,8 +47,4 @@ export class CellRange {
this._start = null
this._end = null
}
isEmpty() {
return this._start == null || this._end == null
}
}