import Delta from "quill-delta-es"; import { type DataBaseElement, type AttributesObject, type DataBaseNode, type BlockDataElement, DataNode } from "./tree"; import { type Operation, type OperationMessage } from "./operations"; import { NodeLocation } from "./location"; import type { CursorState } from "./cursor"; export declare enum ChangesetRecordOption { Undo = 0, Redo = 1, None = 2 } export interface ChangesetApplyOptions { updateView: boolean; ignoreCursor: boolean; record: ChangesetRecordOption; refreshCursor: boolean; } export interface ChangesetStateLogger { userId: string; get appliedVersion(): number; get cursorState(): CursorState | null; getLocationOfNode(node: DataBaseNode): NodeLocation; apply(changeset: FinalizedChangeset): void; } /** * Changeset is a collection of changes which can be * applied to the document's state. * * Each changeset has it's own ID. * So it can be applied repeatedly. */ export declare class Changeset { readonly state: ChangesetStateLogger; version: number; operations: Operation[]; beforeCursor: CursorState | null; afterCursor?: CursorState | null; forceUpdate: boolean; constructor(state: ChangesetStateLogger); /** * Update the attributes of a `BlockyNode`. */ updateAttributes(node: DataBaseElement, attributes: AttributesObject): Changeset; /** * Set the cursor after the changeset is applied. */ setCursorState(cursorState: CursorState | null): Changeset; /** * Append a node at the end of another node. */ appendChild(node: DataNode, child: DataBaseNode): Changeset; removeChild(parent: DataBaseElement, child: DataBaseNode): Changeset; /** * Remove a node from the parent. */ removeNode(node: DataBaseNode): Changeset; /** * Delete a sequences of children of a node. */ deleteChildrenAt(parent: DataBaseElement, index: number, count: number): Changeset; /** * Insert a sequences of children after another node. */ insertChildrenAfter(parent: DataBaseElement, children: DataBaseNode[], after?: DataBaseNode | null): Changeset; /** * Insert children at the position of a node. */ insertChildrenAt(parent: DataBaseElement, index: number, children: DataBaseNode[]): Changeset; /** * Apply the quill delta to the BlockyNode. * For a `Text` block, the `propName` is usually called `textContent`. */ textEdit(node: BlockDataElement, propName: string, delta: () => Delta): Changeset; textConcat(node: BlockDataElement, propName: string, delta: () => Delta): Changeset; /** * This method will transform path. * If you don't want to transform path, call [pushWillMerge]. */ push(operation: Operation): void; pushWillMerge(operation: Operation): void; /** * Apply this changeset to the `EditorState`. * The editor will render automatically after the changeset is applied. */ apply(options?: Partial): FinalizedChangeset | void; finalize(options?: Partial): FinalizedChangeset; /** * @param that Can be either a [Changeset] or a [FinalizedChangeset] */ append(that: Changeset | FinalizedChangeset): void; } export interface FinalizedChangeset { userId: string; version: number; operations: Operation[]; beforeCursor: CursorState | null; afterCursor?: CursorState | null; forceUpdate: boolean; options: ChangesetApplyOptions; needsRender?: boolean; } /** * A changeset interface used to transmit. * Can be serialized as JSON. */ export interface ChangesetMessage { userId: string; version: number; operations: OperationMessage[]; beforeCursor: CursorState | null; afterCursor?: CursorState | null; forceUpdate: boolean; options: ChangesetApplyOptions; } /** * Convert a {@link FinalizedChangeset} to {@link ChangesetMessage}. */ export declare function changesetToMessage(changeset: FinalizedChangeset): ChangesetMessage; /** * Convert a {@link ChangesetMessage} to {@link FinalizedChangeset}. */ export declare function changesetFromMessage(msg: ChangesetMessage): FinalizedChangeset;