import { Subject } from "rxjs"; import Delta from "quill-delta-es"; import type { ElementChangedEvent } from "./events"; export interface DeltaChangedEvent { oldDelta: Delta; newDelta?: Delta; apply: Delta; } export interface AttributesObject { [key: string]: any; } export interface JSONNode { t: string; id?: string; children?: JSONChild[]; title?: JSONChild; body?: JSONChild; [index: string]: any; } export type JSONChild = JSONNode; export interface DataBaseNode { doc?: BlockyDocument; t: string; parent: DataBaseElement | null; nextSibling: DataBaseNode | null; prevSibling: DataBaseNode | null; firstChild: DataBaseNode | null; lastChild: DataBaseNode | null; childrenLength: number; clone(): DataBaseNode; toJSON(): JSONNode; } export interface DataNode extends DataBaseNode { clone(): DataNode; } export declare class BlockyTextModel { #private; changed$: Subject; constructor(delta?: Delta); get delta(): Delta; /** * Return the char at the index of the delta. * If the position is not a char(an embed), return null */ charAt(index: number): string | Record | undefined; /** * Used internally. * If you want to modify the state of the document and * notify the editor to update, apply a changeset. */ __applyDelta(v: Delta): void; toString(): string; get length(): number; clone(): BlockyTextModel; } interface InternAttributes { [key: string]: any; } export declare class DataBaseElement implements DataBaseNode { #private; t: string; nextSibling: DataNode | null; prevSibling: DataNode | null; doc?: BlockyDocument; parent: DataBaseElement | null; __backMap: WeakMap; changed: Subject; childrenLength: number; constructor(t: string, attributes?: AttributesObject); get firstChild(): DataBaseNode | null; get lastChild(): DataBaseNode | null; pathOf(node: DataBaseNode): number | string; childAt(index: number | string): DataBaseNode | null; /** * Used internally. * If you want to modify the state of the document and * notify the editor to update, apply a changeset. */ __setAttribute(name: string, value: any): void; getAttribute(name: string): T | undefined; getAttributes(): InternAttributes; getTextModel(name: string): BlockyTextModel | undefined; indexOf(node: DataBaseNode): number; clone(): DataBaseElement; toJSON(): JSONNode; } /** * DataBaseElement with children */ export declare class DataElement extends DataBaseElement implements DataNode { #private; get firstChild(): DataBaseNode | null; get lastChild(): DataBaseNode | null; constructor(t: string, attributes?: AttributesObject, children?: DataBaseNode[]); appendChild(node: DataBaseNode): void; childAt(index: number | string): DataBaseNode | null; queryChildByName(nodeName: string): DataBaseNode | void; protected __symInsertAfter(node: DataBaseNode, after?: DataBaseNode): void; /** * Used internally. * If you want to modify the state of the document and * notify the editor to update, apply a changeset. */ __insertChildAt(index: number, node: DataBaseNode): void; /** * Used internally. * If you want to modify the state of the document and * notify the editor to update, apply a changeset. */ __deleteChildrenAt(index: number, count: number): void; clone(): DataElement; toJSON(): JSONNode; } /** * This is a data layer of a block. * ID is used to locate a block in the document tree. * * A BlockElement can contain a * at the end of the block to store the children. */ export declare class BlockDataElement extends DataElement { readonly id: string; constructor(blockName: string, id: string, attributes?: AttributesObject, children?: DataBaseNode[]); /** * Used internally. * If you want to modify the state of the document and * notify the editor to update, apply a changeset. */ __setAttribute(name: string, value: string): void; /** * Return the level of block, * not the level of [Node]. */ blockLevel(): number; clone(): BlockDataElement; cloneWithId(id: string): BlockDataElement; toJSON(): JSONNode; } export interface DocumentInitProps { title?: string | BlockDataElement; body?: DataBaseElement; bodyChildren: DataBaseNode[]; } /** * The data model in Blocky Editor is represented as an XML Document: * * * <!-- Optional --> * <body> * <Text /> * <Text /> * <Image src="" /> * </Text> * </body> * </document> */ export declare class BlockyDocument extends DataElement { readonly blockElementAdded: Subject<BlockDataElement>; readonly blockElementRemoved: Subject<BlockDataElement>; constructor(props?: Partial<DocumentInitProps>); get title(): DataBaseElement | undefined; get body(): DataElement; reportBlockyNodeInserted(blockyNode: DataBaseNode): void; reportBlockyNodeRemoved(blockyNode: DataBaseNode): void; toJSON(): JSONNode; } export declare function traverseNode(node: DataBaseNode, fun: (node: DataBaseNode) => void): void; export {};