UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

57 lines (56 loc) 2.2 kB
import { MarkerOverlayPoint } from '../overlay/MarkerOverlayPoint'; import { type UndefIterator } from '../../../util/iterator'; import { Inline } from './Inline'; import { Range } from '../rga/Range'; import type { Point } from '../rga/Point'; import type { OverlayPoint } from '../overlay/OverlayPoint'; import type { Printable } from 'tree-dump'; import type { Peritext } from '../Peritext'; import type { Stateful } from '../types'; import type { OverlayTuple } from '../overlay/types'; import type { PeritextMlElement } from './types'; import type { SliceTypeSteps } from '../slice'; export interface IBlock { readonly path: SliceTypeSteps; readonly parent: IBlock | null; } export declare class Block<T = string, Attr = unknown> extends Range<T> implements IBlock, Printable, Stateful { readonly txt: Peritext<T>; readonly path: SliceTypeSteps; readonly marker: MarkerOverlayPoint<T> | undefined; start: Point<T>; end: Point<T>; parent: Block<T> | null; children: Block<T>[]; constructor(txt: Peritext<T>, path: SliceTypeSteps, marker: MarkerOverlayPoint<T> | undefined, start: Point<T>, end: Point<T>); /** * @returns Stable unique identifier within a list of blocks. Used for React * or other rendering library keys. */ key(): number | string; tag(): number | string; attr(): Attr | undefined; isLeaf(): boolean; /** * Iterate through all overlay points of this block, until the next marker * (regardless if that marker is a child or not). */ points0(withMarker?: boolean): UndefIterator<OverlayPoint<T>>; points(withMarker?: boolean): IterableIterator<OverlayPoint<T>>; protected tuples0(): UndefIterator<OverlayTuple<T>>; /** * @todo Consider moving inline-related methods to {@link LeafBlock}. */ texts0(): UndefIterator<Inline<T>>; /** * @todo Consider moving inline-related methods to {@link LeafBlock}. */ texts(): IterableIterator<Inline<T>>; text(): string; toJson(): PeritextMlElement; hash: number; refresh(): number; toStringName(): string; protected toStringHeader(): string; toString(tab?: string): string; }