All files / json-crdt-extensions/peritext/overlay refs.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                            57x 13446x     57x 13444x    
import type {MarkerSlice} from '../slice/MarkerSlice';
import type {Slice} from '../slice/types';
 
/**
 * On overlay "ref" is a reference from the {@link Overlay} to a {@link Slice}.
 * In case of a *marker* slice, the reference is to the slice itself. In case of
 * a regular annotation slice, two references are needed: one to the start slice
 * and one to the end slice.
 */
export type OverlayRef<T = string> =
  | MarkerSlice<T> // Ref to a *marker*
  | OverlayRefSliceStart<T> // Ref to the start of an annotation slice
  | OverlayRefSliceEnd<T>; // Ref to the end of an annotation slice
 
export class OverlayRefSliceStart<T = string> {
  constructor(public readonly slice: Slice<T>) {}
}
 
export class OverlayRefSliceEnd<T = string> {
  constructor(public readonly slice: Slice<T>) {}
}