Render the char-wise visual selection [anchor..head] as a themed overlay * measured over the range — NOT a native DOM selection, which CodeMirror * would mirror into a multi-cell editor selection (and which falls back to * the washed-out OS color).
(cell: HTMLElement)
| 1071 | * would mirror into a multi-cell editor selection (and which falls back to |
| 1072 | * the washed-out OS color). */ |
| 1073 | private renderCellSelection(cell: HTMLElement): void { |
| 1074 | this.clearCellCursor(cell) |
| 1075 | const text = cell.dataset.raw ?? '' |
| 1076 | const node = cell.firstChild |
| 1077 | if (!node || node.nodeType !== Node.TEXT_NODE || text.length === 0) return |
| 1078 | const from = Math.max(0, Math.min(this.visualAnchor, this.cursorOffset)) |
| 1079 | const to = Math.min(text.length, Math.max(this.visualAnchor, this.cursorOffset) + 1) |
| 1080 | const range = document.createRange() |
| 1081 | range.setStart(node, from) |
| 1082 | range.setEnd(node, to) |
| 1083 | if (typeof range.getBoundingClientRect !== 'function') return |
| 1084 | const rect = range.getBoundingClientRect() |
| 1085 | const cellRect = cell.getBoundingClientRect() |
| 1086 | const overlay = document.createElement('span') |
| 1087 | overlay.className = 'cm-table-cell-sel' |
| 1088 | overlay.style.left = `${rect.left - cellRect.left}px` |
| 1089 | overlay.style.top = `${rect.top - cellRect.top}px` |
| 1090 | overlay.style.width = `${Math.max(rect.width, 2)}px` |
| 1091 | overlay.style.height = `${rect.height || 18}px` |
| 1092 | cell.appendChild(overlay) |
| 1093 | } |
| 1094 | |
| 1095 | private exitVisual(): void { |
| 1096 | this.visualMode = false |
no test coverage detected