UNPKG

@textbus/collaborate

Version:

Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.

87 lines (86 loc) 4.21 kB
import { Observable, Subject, Subscription } from '@tanbo/stream'; import { AbstractSelection, ComponentInstance, Controller, Registry, History, RootComponentRef, Scheduler, Selection, SelectionPaths, Slot, Starter } from '@textbus/core'; import { Array as YArray, Doc as YDoc, Map as YMap, RelativePosition, Text as YText, Transaction, UndoManager, Item } from 'yjs'; interface CursorPosition { anchor: RelativePosition; focus: RelativePosition; } declare class ContentMap { private slotAndYTextMap; private yTextAndSLotMap; set(key: Slot, value: YText): void; set(key: YText, value: Slot): void; get(key: Slot): YText | null; get(key: YText): Slot | null; delete(key: Slot | YText): void; } interface UpdateItem { record: boolean; action(): void; } export declare abstract class CustomUndoManagerConfig { abstract captureTransaction?(arg0: Transaction): boolean; abstract deleteFilter?(arg0: Item): boolean; } interface CollaborateHistorySelectionPosition { before: CursorPosition | null; after: CursorPosition | null; } export declare class Collaborate implements History { protected stackSize: number; protected rootComponentRef: RootComponentRef; protected controller: Controller; protected scheduler: Scheduler; protected registry: Registry; protected selection: Selection; protected starter: Starter; protected undoManagerConfig: CustomUndoManagerConfig; onLocalChangesApplied: Observable<void>; yDoc: YDoc; onBack: Observable<void>; onForward: Observable<void>; onChange: Observable<void>; onPush: Observable<void>; get canBack(): boolean; get canForward(): boolean; protected backEvent: Subject<void>; protected forwardEvent: Subject<void>; protected changeEvent: Subject<void>; protected pushEvent: Subject<void>; protected manager: UndoManager | null; protected subscriptions: Subscription[]; protected updateFromRemote: boolean; protected contentSyncCaches: WeakMap<Slot<any>, () => void>; protected slotStateSyncCaches: WeakMap<Slot<any>, () => void>; protected slotsSyncCaches: WeakMap<ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>, () => void>; protected componentStateSyncCaches: WeakMap<ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>, () => void>; protected localChangesAppliedEvent: Subject<void>; protected selectionChangeEvent: Subject<SelectionPaths>; protected contentMap: ContentMap; protected updateRemoteActions: Array<UpdateItem>; protected noRecord: {}; protected historyItems: Array<CollaborateHistorySelectionPosition>; protected index: number; constructor(stackSize: number, rootComponentRef: RootComponentRef, controller: Controller, scheduler: Scheduler, registry: Registry, selection: Selection, starter: Starter, undoManagerConfig: CustomUndoManagerConfig); listen(): void; back(): void; forward(): void; clear(): void; destroy(): void; protected syncRootComponent(root: YMap<any>, rootComponent: ComponentInstance): void; protected getAbstractSelection(position: CursorPosition): AbstractSelection | null; protected getRelativeCursorLocation(): CursorPosition | null; protected syncSlotContent(content: YText, slot: Slot): void; protected syncSlotState(remoteSlot: YMap<any>, slot: Slot): void; protected syncComponentSlots(remoteSlots: YArray<any>, component: ComponentInstance): void; protected syncComponentState(remoteComponent: YMap<any>, component: ComponentInstance): void; protected runLocalUpdate(fn: () => void, record?: boolean): void; protected runRemoteUpdate(tr: Transaction, fn: () => void): void; protected createSharedComponentByComponent(component: ComponentInstance): YMap<any>; protected createSharedSlotBySlot(slot: Slot): YMap<any>; protected createComponentBySharedComponent(yMap: YMap<any>): ComponentInstance; protected createSlotBySharedSlot(sharedSlot: YMap<any>): Slot; protected cleanSubscriptionsBySlot(slot: Slot): void; protected cleanSubscriptionsByComponent(component: ComponentInstance): void; } export {};