latex-ub/services/web/frontend/js/features/review-panel-new/utils/is-selection-within-op.ts
2025-05-05 12:24:05 +00:00

10 lines
337 B
TypeScript

import { AnyOperation } from '../../../../../types/change'
import { SelectionRange } from '@codemirror/state'
import { visibleTextLength } from '@/utils/operations'
export const isSelectionWithinOp = (
op: AnyOperation,
range: SelectionRange
): boolean => {
return range.to >= op.p && range.from <= op.p + visibleTextLength(op)
}