json-joy
Version:
Collection of libraries for building collaborative editing apps.
68 lines (67 loc) • 2.93 kB
TypeScript
import { Point } from '../rga/Point';
import { Range } from '../rga/Range';
import { SliceStacking } from './constants';
import type { VecNode } from '../../../json-crdt/nodes';
import type { ITimestampStruct } from '../../../json-crdt-patch/clock';
import type { ArrChunk } from '../../../json-crdt/nodes';
import type { MutableSlice, SliceType, SliceUpdateParams, SliceTypeSteps, SliceTypeStep } from './types';
import type { Stateful } from '../types';
import type { Printable } from 'tree-dump/lib/types';
import type { AbstractRga } from '../../../json-crdt/nodes/rga';
import type { Model } from '../../../json-crdt/model';
import type { Peritext } from '../Peritext';
import type { Slices } from './Slices';
/**
* A persisted slice is a slice that is stored in a {@link Model}. It is used for
* rich-text formatting and annotations.
*
* @todo Maybe rename to "saved", "stored", "mutable".
*/
export declare class PersistedSlice<T = string> extends Range<T> implements MutableSlice<T>, Stateful, Printable {
/** The `Model` where the slice is stored. */
protected readonly model: Model;
/** The Peritext context. */
protected readonly txt: Peritext<T>;
/** The `arr` chunk of `arr` where the slice is stored. */
protected readonly chunk: ArrChunk;
/** The `vec` node which stores the serialized contents of this slice. */
readonly tuple: VecNode;
start: Point<T>;
end: Point<T>;
static deserialize<T>(model: Model, txt: Peritext<T>, chunk: ArrChunk, tuple: VecNode): PersistedSlice<T>;
/** @todo Use API node here. */
protected readonly rga: AbstractRga<T>;
constructor(
/** The `Model` where the slice is stored. */
model: Model,
/** The Peritext context. */
txt: Peritext<T>,
/** The `arr` chunk of `arr` where the slice is stored. */
chunk: ArrChunk,
/** The `vec` node which stores the serialized contents of this slice. */
tuple: VecNode, stacking: SliceStacking, type: SliceType, start: Point<T>, end: Point<T>);
isSplit(): boolean;
protected tupleApi(): import("../../../json-crdt/model").VecApi<VecNode<any>>;
set(start: Point<T>, end?: Point<T>): void;
/**
* Expand range left and right to contain all invisible space: (1) tombstones,
* (2) anchors of non-deleted adjacent chunks.
*/
expand(): void;
readonly id: ITimestampStruct;
stacking: SliceStacking;
type: SliceType;
tag(): SliceTypeStep;
typeSteps(): SliceTypeSteps;
update(params: SliceUpdateParams<T>): void;
data(): unknown | undefined;
dataNode(): import("../../../json-crdt/model").NodeApi<import("../../../json-crdt/nodes").JsonNode<unknown>> | undefined;
getStore(): Slices<T> | undefined;
del(): void;
isDel(): boolean;
hash: number;
refresh(): number;
toStringName(): string;
protected toStringHeaderName(): string;
toStringHeader(tab?: string): string;
}