json-joy
Version:
Collection of libraries for building collaborative editing apps.
115 lines (114 loc) • 4.42 kB
TypeScript
import { Point } from '../rga/Point';
import { type OverlayRef, OverlayRefSliceEnd, OverlayRefSliceStart } from './refs';
import type { SliceType } from '../slice/types';
import type { Slice } from '../slice/Slice';
import type { HeadlessNode } from 'sonic-forest/lib/types';
import type { Printable } from 'tree-dump/lib/types';
import type { HeadlessNode2 } from 'sonic-forest/lib/types2';
/**
* 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, HeadlessNode2 {
/**
* Hash of text contents until the next {@link OverlayPoint}. This field is
* modified by the {@link Overlay} tree.
*/
hash: number;
/** -------------------------------------------------- {@link HeadlessNode} */
p: OverlayPoint<T> | undefined;
l: OverlayPoint<T> | undefined;
r: OverlayPoint<T> | undefined;
/** ------------------------------------------------- {@link HeadlessNode2} */
p2: OverlayPoint<T> | undefined;
l2: OverlayPoint<T> | undefined;
r2: OverlayPoint<T> | undefined;
/**
* 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;
/**
* 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: Slice<T>): void;
upsertStartRef(slice: Slice<T>): OverlayRefSliceStart<T>;
upsertEndRef(slice: Slice<T>): OverlayRefSliceEnd<T>;
/**
* 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;
/**
* Hash value of the following text contents, up until the next marker.
*/
textHash: number;
/**
* @deprecated Use `this.marker().type()` instead.
*/
type(): SliceType;
/**
* @deprecated Use `this.marker().data()` instead.
*/
data(): unknown;
/**
* Collapsed slices - markers (block splits), which represent a single point
* in the text, even if the start and end of the slice are different.
*
* @todo This normally should never be a list, but a single item. Enforce?
*/
readonly markers: Slice<T>[];
/**
* @deprecated Make this a method.
*/
get marker(): Slice<T>;
isMarker(): boolean;
/**
* 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.
*
* @todo Make this method private.
*/
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;
/** ----------------------------------------------------- {@link Printable} */
toStringName(): string;
toStringHeader(tab?: string, lite?: boolean): string;
toString(tab?: string, lite?: boolean): string;
}