@textbus/collaborate 4.0.4 → 4.1.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ import { History, RootComponentRef, Scheduler, Selection } from '@textbus/core';
2
+ import { Observable } from '@tanbo/stream';
3
+ import { Item, Transaction } from 'yjs';
4
+ import { Collaborate } from './collaborate';
5
+ export declare abstract class CustomUndoManagerConfig {
6
+ abstract captureTransaction?(arg0: Transaction): boolean;
7
+ abstract deleteFilter?(arg0: Item): boolean;
8
+ }
9
+ export declare class CollabHistory implements History {
10
+ private rootComponentRef;
11
+ private collaborate;
12
+ private scheduler;
13
+ private selection;
14
+ private stackSize;
15
+ private undoManagerConfig;
16
+ onBack: Observable<void>;
17
+ onForward: Observable<void>;
18
+ onChange: Observable<void>;
19
+ onPush: Observable<void>;
20
+ get canBack(): boolean;
21
+ get canForward(): boolean;
22
+ private manager;
23
+ private historyItems;
24
+ private index;
25
+ private subscriptions;
26
+ private backEvent;
27
+ private forwardEvent;
28
+ private changeEvent;
29
+ private pushEvent;
30
+ constructor(rootComponentRef: RootComponentRef, collaborate: Collaborate, scheduler: Scheduler, selection: Selection, stackSize: number, undoManagerConfig: CustomUndoManagerConfig);
31
+ listen(): void;
32
+ back(): void;
33
+ forward(): void;
34
+ clear(): void;
35
+ destroy(): void;
36
+ }
@@ -1,46 +1,55 @@
1
1
  import { Observable } from '@tanbo/stream';
2
- import { Registry, History, RootComponentRef, Scheduler, Selection } from '@textbus/core';
3
- import { Doc as YDoc, Transaction, Item } from 'yjs';
4
- export declare abstract class CustomUndoManagerConfig {
5
- abstract captureTransaction?(arg0: Transaction): boolean;
6
- abstract deleteFilter?(arg0: Item): boolean;
2
+ import { Component, Registry, Scheduler, Selection, Slot, AbstractSelection } from '@textbus/core';
3
+ import { AbstractType, Doc as YDoc, Map as YMap, RelativePosition, Text as YText } from 'yjs';
4
+ import { SubModelLoader } from './sub-model-loader';
5
+ export interface RelativePositionRecord {
6
+ doc: YDoc;
7
+ position: RelativePosition;
7
8
  }
8
- export declare class Collaborate implements History {
9
- private stackSize;
10
- private rootComponentRef;
9
+ export interface CursorPosition {
10
+ anchor: RelativePositionRecord;
11
+ focus: RelativePositionRecord;
12
+ }
13
+ export interface CollaborateHistorySelectionPosition {
14
+ before: CursorPosition | null;
15
+ after: CursorPosition | null;
16
+ }
17
+ declare class SlotMap {
18
+ private slotAndYTextMap;
19
+ private yTextAndSlotMap;
20
+ set(key: Slot, value: YText): void;
21
+ set(key: YText, value: Slot): void;
22
+ get(key: Slot): YText | null;
23
+ get(key: YText): Slot | null;
24
+ delete(key: Slot | YText): void;
25
+ }
26
+ export interface SubModelLoaded {
27
+ yType: AbstractType<any>;
28
+ yDoc: YDoc;
29
+ }
30
+ export declare class Collaborate {
11
31
  private scheduler;
12
32
  private registry;
13
33
  private selection;
14
- private undoManagerConfig;
15
- onLocalChangesApplied: Observable<void>;
34
+ private subModelLoader;
16
35
  yDoc: YDoc;
17
- onBack: Observable<void>;
18
- onForward: Observable<void>;
19
- onChange: Observable<void>;
20
- onPush: Observable<void>;
21
- get canBack(): boolean;
22
- get canForward(): boolean;
23
- private backEvent;
24
- private forwardEvent;
25
- private changeEvent;
26
- private pushEvent;
27
- private manager;
36
+ slotMap: SlotMap;
37
+ onAddSubModel: Observable<SubModelLoaded>;
28
38
  private subscriptions;
29
39
  private updateFromRemote;
30
- private localChangesAppliedEvent;
31
- private selectionChangeEvent;
32
- private slotMap;
40
+ private addSubModelEvent;
33
41
  private updateRemoteActions;
34
42
  private noRecord;
35
- private historyItems;
36
- private index;
37
- constructor(stackSize: number, rootComponentRef: RootComponentRef, scheduler: Scheduler, registry: Registry, selection: Selection, undoManagerConfig: CustomUndoManagerConfig);
38
- listen(): void;
39
- back(): void;
40
- forward(): void;
41
- clear(): void;
43
+ constructor(scheduler: Scheduler, registry: Registry, selection: Selection, subModelLoader: SubModelLoader);
44
+ syncRootComponent(yDoc: YDoc, sharedComponent: YMap<any>, localComponent: Component<any>): void;
45
+ syncRootSlot(yDoc: YDoc, sharedSlot: YText, localSlot: Slot): void;
46
+ getAbstractSelection(position: CursorPosition): AbstractSelection | null;
47
+ getRelativeCursorLocation(): CursorPosition | null;
48
+ restoreCursorPosition(position: CursorPosition | null): void;
49
+ private initSyncEvent;
50
+ private syncComponent;
51
+ private syncSlot;
42
52
  destroy(): void;
43
- private syncRootComponent;
44
53
  private syncSharedMapToLocalMap;
45
54
  private createLocalMapBySharedMap;
46
55
  private createLocalArrayBySharedArray;
@@ -48,12 +57,11 @@ export declare class Collaborate implements History {
48
57
  private createSharedMapByLocalMap;
49
58
  private createSharedArrayByLocalArray;
50
59
  private createSharedSlotByLocalSlot;
60
+ private initSharedSlotByLocalSlot;
51
61
  private createLocalSlotBySharedSlot;
62
+ private initLocalSlotBySharedSlot;
52
63
  private createSharedModelByLocalModel;
53
64
  private createLocalModelBySharedByModel;
54
- private getAbstractSelection;
55
- private getRelativeCursorLocation;
56
- private syncSlot;
57
65
  private createSharedComponentByLocalComponent;
58
66
  private createLocalComponentBySharedComponent;
59
67
  /**
@@ -73,3 +81,4 @@ export declare class Collaborate implements History {
73
81
  private runLocalUpdate;
74
82
  private runRemoteUpdate;
75
83
  }
84
+ export {};
@@ -1,7 +1,8 @@
1
+ import { HocuspocusProvider } from '@hocuspocus/provider';
1
2
  import { HocuspocusProviderConfiguration } from '@hocuspocus/provider';
2
3
  import { SyncConnector } from '../sync-connector';
3
4
  export declare class HocuspocusConnector extends SyncConnector {
4
- private provide;
5
+ provide: HocuspocusProvider;
5
6
  constructor(config: HocuspocusProviderConfiguration);
6
7
  setLocalStateField(key: string, data: Record<string, any>): void;
7
8
  onDestroy(): void;
@@ -1,7 +1,8 @@
1
1
  import { Doc as YDoc } from 'yjs';
2
+ import { WebsocketProvider } from 'y-websocket';
2
3
  import { SyncConnector } from '../sync-connector';
3
4
  export declare class YWebsocketConnector extends SyncConnector {
4
- private provide;
5
+ provide: WebsocketProvider;
5
6
  constructor(url: string, roomName: string, yDoc: YDoc);
6
7
  setLocalStateField(key: string, data: Record<string, any>): void;
7
8
  onDestroy(): void;