import { Doc, Op } from 'sharedb/lib/client'; import DeltaOp from 'quill-delta/dist/Op'; import { Event } from 'reconnecting-websocket'; import { AuthMessage } from "../../../commons/auth-message"; import { LocalPresence } from 'sharedb/lib/sharedb'; import { AuthConnection, ReAuthFunc } from "./auth-connection"; import { DocContainer, DocBlock, MessageCallback, DocComment, EditorDoc } from "./doc-container"; import { OnProgress } from "./request"; export { OnProgress }; export { Op } from 'sharedb/lib/client'; export { DocComment, DocContainer, DocBlock, BlockLockInfo, EditorDoc, BlockBase, TextAlign, Doc2MarkdownOptionalOptions, } from "./doc-container"; export interface EditorOp { c: string; d: string; meta: { createdBy: { userId: string; displayName: string; }; }; op: Op[]; seq: number; src: string; v: number; create?: { data: EditorDoc; type: string; }; } export interface EditorChangeSet { ops: EditorOp[]; userId: string; displayName: string; } export interface DocVersion { version: number; tag?: string; published?: boolean; type?: 'major' | 'minor'; minorVersions?: DocVersion[]; authors?: { userId: string; displayName: string; }[]; source?: 'timeout' | 'op' | 'manual' | 'system' | { restore: number | string; } | 'unknown' | 'auto'; created?: number; createdBy?: { userId: string; displayName: string; }; } export interface LinkDetails { type?: 'iframe' | 'video' | 'audio' | 'image'; providerName?: string; url: string; } export declare class RemoteDocContainer implements DocContainer { doc: Doc; localPresence?: LocalPresence; messageCallbacks: MessageCallback[]; constructor(doc: Doc, callback: MessageCallback); submitOp: (ops: any) => Promise; delDoc: () => Promise; createDoc: (data: EditorDoc) => Promise; insertObject: (rootObjectName: string, index: number, obj: Object) => Promise; deleteObject: (rootObjectName: string, index: number) => Promise; replaceObject: (rootObjectName: string, index: number, obj: Object) => Promise; updateObject: (rootObjectName: string, index: number, obj: { [index: string]: any; }) => boolean; insertBlock: (rootObjectName: string, index: number, block: DocBlock) => Promise; submitRichTextBlockOps: (rootObjectName: string, index: number, ops: DeltaOp[]) => Promise; insertRootObject: (rootObjectName: string, obj: Object) => Promise; deleteRootObject: (rootObjectName: string) => Promise; createComment: (id: string, groupId: string, userId: string, displayName: string, avatarUrl: string, doc: EditorDoc, abstract: string, created?: number | undefined) => Promise; deleteComment: (id: string) => Promise; updateComment: (id: string, doc: EditorDoc) => Promise; getComment(id: string): DocComment; getComments(): DocComment[][]; getGroupComments(groupId: string): DocComment[]; broadcastMessage: (msg: object) => Promise; registerMessageCallback(callback: MessageCallback): void; initPresence: () => Promise; subscribe: (callback: (err: { code: number; message: string; }) => void) => void; onOp(callback: ((ops: Op[], source: boolean) => void)): void; onNothingPending(callback: () => void): void; onCreate(callback: (source: boolean) => void): void; onDelete(callback: (data: any, source: boolean) => void): void; data: () => any; applyOps(ops: any): void; destroy(): void; } export default class OTClient { connection: AuthConnection; auth: AuthMessage; private docContainer; private reAuthFunc?; constructor(auth: AuthMessage, serverUrl?: string, reAuthFunc?: ReAuthFunc); editorServer(): string; close(logout: boolean): void; on(event: 'open' | 'close' | 'error', callback: (event: Event | Error) => void): void; onWriteConflictError(callback: (error: Error) => void): void; onMaxUsersError(callback: () => void): void; onRequestReloadError(callback: (error: Error) => void): void; /** * 根据Id生成一个文档对象,如果文档不存在,则创建一个新的。 * @param id 待获取的containerId */ getDocContainer: (callback: MessageCallback, autoCreateDoc?: boolean, templateData?: EditorDoc | undefined) => Promise; recreateDoc(data: EditorDoc): Promise; authOnly(): Promise; getResourceToken(): string | null; createLocalDocContainer: (doc: EditorDoc) => Promise; hasDocContainer(): boolean; apiServer(): string; getFileUrlByHash(uploadFileUrl: string, hash: string, name: string, size: number, headers: { [index: string]: string; }): Promise; getFileUrlsByHashes(resourceHashes: string[]): Promise; uploadFile(url: string, file: File, headers: { [index: string]: string; }, onProgress: OnProgress, options?: { thumbnail?: boolean; }): Promise; uploadResource(file: File, onProgress: OnProgress, options?: { thumbnail?: boolean; }): Promise; request(url: string | any, opt?: any): Promise>; getVersions(): Promise; getVersion(ver: number): Promise; getLatestVersion(): Promise; getVersionOps(version: number, from?: number): Promise<{ doc: EditorDoc; ops: EditorOp[]; }>; revertVersion(ver: number): Promise; createVersion(tag: string, publish: boolean): Promise; recognizeLink(url: string): Promise; }