json-joy
Version:
Collection of libraries for building collaborative editing apps.
99 lines (98 loc) • 6.43 kB
TypeScript
import { type Printable } from 'tree-dump';
import { InputController } from './InputController';
import { CursorController } from './CursorController';
import { RichTextController } from './RichTextController';
import { KeyController } from './KeyController';
import { CompositionController } from './CompositionController';
import { AnnalsController } from './annals/AnnalsController';
import { type ITimestampStruct } from '../../../json-crdt-patch';
import type { Point } from '../../../json-crdt-extensions/peritext/rga/Point';
import type { PeritextEventDefaults } from '../../events/defaults/PeritextEventDefaults';
import type { PeritextEventTarget } from '../../events/PeritextEventTarget';
import type { Rect, UiLifeCycles } from '../types';
import type { Log } from '../../../json-crdt/log/Log';
import type { Peritext } from '../../../json-crdt-extensions';
import type { Range } from '../../../json-crdt-extensions/peritext/rga/Range';
import type { PeritextUiApi } from '../../events/defaults/ui/types';
export interface DomControllerOpts {
source: HTMLElement;
events: PeritextEventDefaults;
log: Log;
}
export declare class DomController implements UiLifeCycles, Printable, PeritextUiApi {
readonly opts: DomControllerOpts;
readonly txt: Peritext;
readonly et: PeritextEventTarget;
readonly keys: KeyController;
readonly comp: CompositionController;
readonly input: InputController;
readonly cursor: CursorController;
readonly richText: RichTextController;
readonly annals: AnnalsController;
/**
* Index of block HTML <div> elements keyed by the ID (timestamp) of the split
* boundary that starts that block element.
*/
readonly blocks: {
min: import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
root: import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
max: import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
readonly comparator: import("sonic-forest/lib/types").Comparator<ITimestampStruct>;
set(k: ITimestampStruct, v: HTMLSpanElement): import("sonic-forest/lib/types").SonicNodePublicReference<import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement>>;
find(k: ITimestampStruct): import("sonic-forest/lib/types").SonicNodePublicReference<import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement>> | undefined;
get(k: ITimestampStruct): HTMLSpanElement | undefined;
del(k: ITimestampStruct): boolean;
clear(): void;
has(k: ITimestampStruct): boolean;
_size: number;
size(): number;
isEmpty(): boolean;
getOrNextLower(k: ITimestampStruct): import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
forEach(fn: (node: import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement>) => void): void;
first(): import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
last(): import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
readonly next: <N extends import("sonic-forest/lib/types").HeadlessNode>(curr: N) => N | undefined;
iterator0(): () => import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement> | undefined;
iterator(): Iterator<import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement>, any, any>;
entries(): IterableIterator<import("sonic-forest/lib/types").ITreeNode<ITimestampStruct, HTMLSpanElement>>;
toString(tab: string): string;
};
/**
* Index of inline HTML <span> elements keyed by the slice start {@link Point}.
*/
readonly inlines: {
min: import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
root: import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
max: import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
readonly comparator: import("sonic-forest/lib/types").Comparator<Point<string>>;
set(k: Point<string>, v: HTMLSpanElement): import("sonic-forest/lib/types").SonicNodePublicReference<import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement>>;
find(k: Point<string>): import("sonic-forest/lib/types").SonicNodePublicReference<import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement>> | undefined;
get(k: Point<string>): HTMLSpanElement | undefined;
del(k: Point<string>): boolean;
clear(): void;
has(k: Point<string>): boolean;
_size: number;
size(): number;
isEmpty(): boolean;
getOrNextLower(k: Point<string>): import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
forEach(fn: (node: import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement>) => void): void;
first(): import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
last(): import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
readonly next: <N extends import("sonic-forest/lib/types").HeadlessNode>(curr: N) => N | undefined;
iterator0(): () => import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement> | undefined;
iterator(): Iterator<import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement>, any, any>;
entries(): IterableIterator<import("sonic-forest/lib/types").ITreeNode<Point<string>, HTMLSpanElement>>;
toString(tab: string): string;
};
constructor(opts: DomControllerOpts);
/** -------------------------------------------------- {@link UiLifeCycles} */
start(): () => void;
/** ------------------------------------------------- {@link PeritextUiApi} */
focus(): void;
protected getSpans(blockInnerId?: Point): NodeListOf<Element>;
protected findSpanContaining(char: Range): HTMLSpanElement | undefined;
getCharRect(char: number | ITimestampStruct): Rect | undefined;
caretRect(): Rect | undefined;
/** ----------------------------------------------------- {@link Printable} */
toString(tab?: string): string;
}