json-joy
Version:
Collection of libraries for building collaborative editing apps.
97 lines (96 loc) • 3.63 kB
TypeScript
import { Point } from '../rga/Point';
import { type OverlayRef } from './refs';
import type { MarkerSlice } from '../slice/MarkerSlice';
import type { HeadlessNode } from 'sonic-forest/lib/types';
import type { Printable } from 'tree-dump/lib/types';
import type { Slice } from '../slice/types';
/**
* A {@link Point} which is indexed in the {@link Overlay} tree. Represents
* sparse locations in the string of the places where annotation slices start,
* end, or are broken down by other intersecting slices.
*/
export declare class OverlayPoint<T = string> extends Point<T> implements Printable, HeadlessNode {
/**
* Hash of text contents until the next {@link OverlayPoint}. This field is
* modified by the {@link Overlay} tree.
*/
hash: number;
/**
* Sorted list of layers, contains the interval from this point to the next
* one. A *layer* is a part of a slice from the current point to the next one.
* This interval can contain many layers, as the slices can be overlapped.
*/
readonly layers: Slice<T>[];
/**
* Inserts a slice to the list of layers which contains the area from this
* point until the next one. The operation is idempotent, so inserting the
* same slice twice will not change the state of the point. The layers are
* sorted by the slice ID.
*
* @param slice Slice to add to the layer list.
*/
addLayer(slice: Slice<T>): void;
/**
* Removes a slice from the list of layers, which start from this overlay
* point.
*
* @param slice Slice to remove from the layer list.
*/
removeLayer(slice: Slice<T>): void;
/**
* Collapsed slices - markers (block splits), which represent a single point
* in the text, even if the start and end of the slice are different.
*/
readonly markers: Slice<T>[];
/**
* Inserts a slice to the list of markers which represent a single point in
* the text, even if the start and end of the slice are different. The
* operation is idempotent, so inserting the same slice twice will not change
* the state of the point. The markers are sorted by the slice ID.
*
* @param slice Slice to add to the marker list.
*/
addMarker(slice: Slice<T>): void;
/**
* Removes a slice from the list of markers, which represent a single point in
* the text, even if the start and end of the slice are different.
*
* @param slice Slice to remove from the marker list.
*/
removeMarker(slice: Slice<T>): void;
/**
* Sorted list of all references to rich-text constructs.
*/
readonly refs: OverlayRef<T>[];
/**
* Insert a reference to a marker.
*
* @param slice A marker (split slice).
*/
addMarkerRef(slice: MarkerSlice<T>): void;
/**
* Insert a layer that starts at this point.
*
* @param slice A slice that starts at this point.
*/
addLayerStartRef(slice: Slice<T>): void;
/**
* Insert a layer that ends at this point.
*
* @param slice A slice that ends at this point.
*/
addLayerEndRef(slice: Slice<T>): void;
/**
* Removes a reference to a marker or a slice, and remove the corresponding
* layer or marker.
*
* @param slice A slice to remove the reference to.
*/
removeRef(slice: Slice<T>): void;
toStringName(): string;
toStringHeader(tab?: string, lite?: boolean): string;
toString(tab?: string, lite?: boolean): string;
p: OverlayPoint<T> | undefined;
l: OverlayPoint<T> | undefined;
r: OverlayPoint<T> | undefined;
}