( value: string, selectionStart: number | null | undefined, selectionEnd: number | null | undefined, )
| 251 | } |
| 252 | |
| 253 | export function getInputSelectionText( |
| 254 | value: string, |
| 255 | selectionStart: number | null | undefined, |
| 256 | selectionEnd: number | null | undefined, |
| 257 | ): string | null { |
| 258 | const selection = normalizeInputSelection(value, selectionStart, selectionEnd); |
| 259 | if (!selection) return null; |
| 260 | const [start, end] = |
| 261 | selection.start <= selection.end |
| 262 | ? [selection.start, selection.end] |
| 263 | : [selection.end, selection.start]; |
| 264 | if (start >= end) return null; |
| 265 | return value.slice(start, end); |
| 266 | } |
| 267 | |
| 268 | function asUnicodeScalarString(codepoint: number): string { |
| 269 | if (!Number.isFinite(codepoint)) return "\ufffd"; |
no test coverage detected