diff --git a/src/components/editor.ts b/src/components/editor.ts index b707083..3e1c216 100644 --- a/src/components/editor.ts +++ b/src/components/editor.ts @@ -66,6 +66,7 @@ export class Editor { }); this.hide(); + this.root.renderSelection() } } }; diff --git a/src/components/sheet.ts b/src/components/sheet.ts index baeb8e5..47e9d1e 100644 --- a/src/components/sheet.ts +++ b/src/components/sheet.ts @@ -52,7 +52,7 @@ export class Sheet { this.root.data[row][column].render(this.root); } - getSelectionRange() { + private getSelectionRange() { const { selectedCell, selectedRange } = this.root.selection if (!selectedCell && !selectedRange) return; @@ -85,7 +85,7 @@ export class Sheet { } } - renderSelectionRange(x: number, y: number, width: number, height: number) { + private renderSelectionRange(x: number, y: number, width: number, height: number) { this.ctx.save() this.ctx.strokeStyle = '#47d1ff' @@ -97,6 +97,13 @@ export class Sheet { } + renderSelection() { + const box = this.getSelectionRange() + if (!box) return; + const {height, width, x, y} = box + this.renderSelectionRange(x, y, width, height) + } + renderSheet() { const firstRowIdx = this.root.viewport.firstRow; const lastColIdx = this.root.viewport.lastCol + 3; @@ -112,10 +119,7 @@ export class Sheet { this.renderCell({ column: col, row }); } } + this.renderSelection() - const box = this.getSelectionRange() - if (!box) return; - const {height, width, x, y} = box - this.renderSelectionRange(x, y, width, height) } } diff --git a/src/main.ts b/src/main.ts index bdc1983..4239f77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -315,6 +315,10 @@ export default class Spreadsheet { this.sheet.renderSheet(); } + renderSelection() { + this.sheet.renderSelection(); + } + renderColumnsBar() { this.columnsBar.renderBar(); } diff --git a/src/modules/clipboard.ts b/src/modules/clipboard.ts index f767592..3821222 100644 --- a/src/modules/clipboard.ts +++ b/src/modules/clipboard.ts @@ -77,7 +77,7 @@ export class Clipboard { } catch (err) { console.error("Cannot read clipboard. ", err); } - + root.renderSheet() return; }