| 238 | export type InputSelection = Readonly<{ start: number; end: number }>; |
| 239 | |
| 240 | export function normalizeInputSelection( |
| 241 | value: string, |
| 242 | selectionStart: number | null | undefined, |
| 243 | selectionEnd: number | null | undefined, |
| 244 | ): InputSelection | null { |
| 245 | if (selectionStart === null || selectionStart === undefined) return null; |
| 246 | if (selectionEnd === null || selectionEnd === undefined) return null; |
| 247 | const start = normalizeInputCursor(value, selectionStart); |
| 248 | const end = normalizeInputCursor(value, selectionEnd); |
| 249 | if (start === end) return null; |
| 250 | return Object.freeze({ start, end }); |
| 251 | } |
| 252 | |
| 253 | export function getInputSelectionText( |
| 254 | value: string, |