Skip to content

Commit

Permalink
feat(json-crdt-extensions): 馃幐 implement overlay "ref" concept
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Apr 26, 2024
1 parent 120ba2f commit 7c31a6f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/json-crdt-extensions/peritext/overlay/refs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type {SplitSlice} from '../slice/SplitSlice';
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 =
| SplitSlice // Ref to a *marker* slice
| OverlayRefSliceStart // Ref to the start of an annotation slice
| OverlayRefSliceEnd; // Ref to the end of an annotation slice

export class OverlayRefSliceStart {
constructor(public readonly slice: Slice) {}
}

export class OverlayRefSliceEnd {
constructor(public readonly slice: Slice) {}
}

0 comments on commit 7c31a6f

Please sign in to comment.