import * as Y from "yjs"; import { BaseEditor, BasePoint, BaseRange, Descendant, Editor, Element, Node, Operation, Point, Range } from "slate"; import { Awareness } from "y-protocols/awareness"; //#region src/module/custom-types.d.ts type DeltaInsert = { insert: string | Y.XmlText; attributes?: Record; }; type InsertDelta = Array; type RelativeRange = { anchor: Y.RelativePosition; focus: Y.RelativePosition; }; //#endregion //#region src/plugins/withYjs.d.ts type LocalChange = { op: Operation; doc: Descendant[]; origin: unknown; }; type YjsEditor = BaseEditor & { sharedRoot: Y.XmlText; localOrigin: unknown; positionStorageOrigin: unknown; applyRemoteEvents: (events: Y.YEvent[], origin: unknown) => void; storeLocalChange: (op: Operation) => void; flushLocalChanges: () => void; isLocalOrigin: (origin: unknown) => boolean; connect: () => void; disconnect: () => void; }; declare const YjsEditor: { isYjsEditor(value: unknown): value is YjsEditor; localChanges(editor: YjsEditor): LocalChange[]; applyRemoteEvents(editor: YjsEditor, events: Y.YEvent[], origin: unknown): void; storeLocalChange(editor: YjsEditor, op: Operation): void; flushLocalChanges(editor: YjsEditor): void; connected(editor: YjsEditor): boolean; connect(editor: YjsEditor): void; disconnect(editor: YjsEditor): void; isLocal(editor: YjsEditor): boolean; origin(editor: YjsEditor): unknown; withOrigin(editor: YjsEditor, origin: unknown, fn: () => void): void; storePosition(editor: YjsEditor, key: string, point: Point): void; removeStoredPosition(editor: YjsEditor, key: string): void; position(editor: YjsEditor, key: string): Point | null | undefined; storedPositionsRelative(editor: YjsEditor): Record; }; type WithYjsOptions = { autoConnect?: boolean; localOrigin?: unknown; positionStorageOrigin?: unknown; }; declare function withYjs(sharedRoot: Y.XmlText, options?: WithYjsOptions): (editor: T) => T & YjsEditor; //#endregion //#region src/plugins/withCursors.d.ts type CursorStateChangeEvent = { added: number[]; updated: number[]; removed: number[]; }; type RemoteCursorChangeEventListener = (event: CursorStateChangeEvent) => void; type CursorState = Record> = { relativeSelection: RelativeRange | null; data?: TCursorData; clientId: number; }; type CursorEditor = Record> = YjsEditor & { awareness: Awareness; cursorDataField: string; selectionStateField: string; sendCursorPosition: (range: Range | null) => void; sendCursorData: (data: TCursorData) => void; }; declare const CursorEditor: { isCursorEditor(value: unknown): value is CursorEditor; sendCursorPosition>(editor: CursorEditor, range?: Range | null): void; sendCursorData>(editor: CursorEditor, data: TCursorData): void; on>(editor: CursorEditor, event: "change", handler: RemoteCursorChangeEventListener): void; off>(editor: CursorEditor, event: "change", listener: RemoteCursorChangeEventListener): void; cursorState>(editor: CursorEditor, clientId: number): CursorState | null; cursorStates>(editor: CursorEditor): Record>; }; type WithCursorsOptions = Record> = { cursorStateField?: string; cursorDataField?: string; data?: TCursorData; autoSend?: boolean; }; declare function withCursors>(awareness: Awareness, options?: WithCursorsOptions): (editor: T) => T & CursorEditor; //#endregion //#region src/plugins/withYHistory.d.ts type YHistoryEditor = YjsEditor & { undoManager: Y.UndoManager; withoutSavingOrigin: unknown; undo: () => void; redo: () => void; }; declare const YHistoryEditor: { isYHistoryEditor(value: unknown): value is YHistoryEditor; canUndo(editor: YHistoryEditor): boolean; canRedo(editor: YHistoryEditor): boolean; isSaving(editor: YHistoryEditor): boolean; withoutSaving(editor: YHistoryEditor, fn: () => void): void; }; type WithYHistoryOptions = NonNullable[1]> & { withoutSavingOrigin?: unknown; }; declare function withYHistory(options?: WithYHistoryOptions): (editor: T) => T & YHistoryEditor; //#endregion //#region src/utils/convert.d.ts declare function yTextToSlateElement(yText: Y.XmlText): Element; declare function slateNodesToInsertDelta(nodes: Node[]): InsertDelta; //#endregion //#region src/utils/position.d.ts declare function slatePointToRelativePosition(sharedRoot: Y.XmlText, slateRoot: Node, point: BasePoint): Y.RelativePosition; declare function relativePositionToSlatePoint(sharedRoot: Y.XmlText, slateRoot: Node, pos: Y.RelativePosition): BasePoint | null; declare function slateRangeToRelativeRange(sharedRoot: Y.XmlText, slateRoot: Node, range: BaseRange): RelativeRange; declare function relativeRangeToSlateRange(sharedRoot: Y.XmlText, slateRoot: Node, range: RelativeRange): BaseRange | null; //#endregion export { CursorEditor, type CursorState, type CursorStateChangeEvent, type RelativeRange, type RemoteCursorChangeEventListener, type WithCursorsOptions, type WithYHistoryOptions, type WithYjsOptions, YHistoryEditor, YjsEditor, relativePositionToSlatePoint, relativeRangeToSlateRange, slateNodesToInsertDelta, slatePointToRelativePosition, slateRangeToRelativeRange, withCursors, withYHistory, withYjs, yTextToSlateElement }; //# sourceMappingURL=index.d.ts.map