@textbus/collaborate 2.0.0-alpha.36 → 2.0.0-alpha.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ export * from './collaborate-history';
2
+ export * from './local-to-remote';
3
+ export * from './remote-to-local';
@@ -0,0 +1,4 @@
1
+ export * from './collaborate-history';
2
+ export * from './local-to-remote';
3
+ export * from './remote-to-local';
4
+ //# sourceMappingURL=_api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_api.js","sourceRoot":"","sources":["../../src/collab/_api.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { History } from '@textbus/core';
2
+ import { Observable } from '@tanbo/stream';
3
+ import { Array as YArray } from 'yjs';
4
+ export declare class CollaborateHistory implements History {
5
+ onBack: Observable<void>;
6
+ onForward: Observable<void>;
7
+ onChange: Observable<any>;
8
+ onPush: Observable<void>;
9
+ get canBack(): boolean;
10
+ get canForward(): boolean;
11
+ private backEvent;
12
+ private forwardEvent;
13
+ private changeEvent;
14
+ private pushEvent;
15
+ private manager;
16
+ constructor();
17
+ init(yArray: YArray<any>): void;
18
+ listen(): void;
19
+ back(): void;
20
+ forward(): void;
21
+ destroy(): void;
22
+ }
@@ -0,0 +1,53 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Injectable } from '@tanbo/di';
11
+ import { Subject } from '@tanbo/stream';
12
+ import { UndoManager } from 'yjs';
13
+ let CollaborateHistory = class CollaborateHistory {
14
+ constructor() {
15
+ this.backEvent = new Subject();
16
+ this.forwardEvent = new Subject();
17
+ this.changeEvent = new Subject();
18
+ this.pushEvent = new Subject();
19
+ this.onBack = this.backEvent.asObservable();
20
+ this.onForward = this.forwardEvent.asObservable();
21
+ this.onChange = this.changeEvent.asObservable();
22
+ this.onPush = this.pushEvent.asObservable();
23
+ }
24
+ get canBack() {
25
+ var _a;
26
+ return (_a = this.manager) === null || _a === void 0 ? void 0 : _a.canUndo();
27
+ }
28
+ get canForward() {
29
+ var _a;
30
+ return (_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo();
31
+ }
32
+ init(yArray) {
33
+ this.manager = new UndoManager(yArray);
34
+ }
35
+ listen() {
36
+ //
37
+ }
38
+ back() {
39
+ //
40
+ }
41
+ forward() {
42
+ //
43
+ }
44
+ destroy() {
45
+ //
46
+ }
47
+ };
48
+ CollaborateHistory = __decorate([
49
+ Injectable(),
50
+ __metadata("design:paramtypes", [])
51
+ ], CollaborateHistory);
52
+ export { CollaborateHistory };
53
+ //# sourceMappingURL=collaborate-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaborate-history.js","sourceRoot":"","sources":["../../src/collab/collaborate-history.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,OAAO,EAAc,OAAO,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,WAAW,EAAmB,MAAM,KAAK,CAAA;AAGlD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAsB7B;QAPQ,cAAS,GAAG,IAAI,OAAO,EAAQ,CAAA;QAC/B,iBAAY,GAAG,IAAI,OAAO,EAAQ,CAAA;QAClC,gBAAW,GAAG,IAAI,OAAO,EAAQ,CAAA;QACjC,cAAS,GAAG,IAAI,OAAO,EAAQ,CAAA;QAKrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAA;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAA;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAA;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAA;IAC7C,CAAC;IArBD,IAAI,OAAO;;QACT,OAAO,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,EAAE,CAAA;IAChC,CAAC;IAED,IAAI,UAAU;;QACZ,OAAO,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,EAAE,CAAA;IAChC,CAAC;IAiBD,IAAI,CAAC,MAAmB;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,MAAM;QACJ,EAAE;IACJ,CAAC;IAED,IAAI;QACF,EAAE;IACJ,CAAC;IAED,OAAO;QACL,EAAE;IACJ,CAAC;IAED,OAAO;QACL,EAAE;IACJ,CAAC;CACF,CAAA;AAhDY,kBAAkB;IAD9B,UAAU,EAAE;;GACA,kBAAkB,CAgD9B;SAhDY,kBAAkB"}
@@ -152,6 +152,9 @@ function makeSharedSlotBySlotLiteral(slotLiteral) {
152
152
  index += size;
153
153
  });
154
154
  const formats = new YMap();
155
+ Object.keys(slotLiteral.formats).forEach(key => {
156
+ formats.set(key, slotLiteral.formats[key]);
157
+ });
155
158
  const sharedSlot = new YMap();
156
159
  sharedSlot.set('state', slotLiteral.state);
157
160
  sharedSlot.set('content', content);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-to-remote.js","sourceRoot":"","sources":["../../src/collab/local-to-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,MAAM,EAA4B,M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AAG,IAAI,IAAI,EAAE,CAAA;IAC7B,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IAC1C,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAClC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC5C,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAClC,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAS,qCAAqC,CAAC,gBAAkC;IAC/E,MAAM,KAAK,GAAG,IAAI,MAAM,EAAE,CAAA;IAC1B,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpC,KAAK,CAAC,IAAI,CAAC,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IACF,MAAM,eAAe,GAAG,IAAI,IAAI,EAAE,CAAA;IAClC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;IAClD,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpD,OAAO,eAAe,CAAA;AACxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { YEvent } from 'yjs';
2
+ import { Registry, Slot, Translator } from '@textbus/core';
3
+ export declare function remoteToLocal(events: YEvent[], slot: Slot, translator: Translator, registry: Registry): void;
@@ -1,6 +1,6 @@
1
1
  import { YArrayEvent, YMapEvent } from 'yjs';
2
2
  import { FormatType } from '@textbus/core';
3
- export function remoteToLocal(events, slot, translator, formatterList) {
3
+ export function remoteToLocal(events, slot, translator, registry) {
4
4
  events.forEach(ev => {
5
5
  const path = [];
6
6
  for (let i = 0; i < ev.path.length; i += 2) {
@@ -9,17 +9,17 @@ export function remoteToLocal(events, slot, translator, formatterList) {
9
9
  if (path.length) {
10
10
  const componentIndex = path.shift()[0];
11
11
  const component = slot.getContentAtIndex(componentIndex);
12
- applySharedComponentToComponent(ev, path, component, translator, formatterList);
12
+ applySharedComponentToComponent(ev, path, component, translator, registry);
13
13
  return;
14
14
  }
15
15
  apply(ev, slot, translator);
16
16
  });
17
17
  }
18
- function applySharedComponentToComponent(ev, path, component, translator, formatterList) {
18
+ function applySharedComponentToComponent(ev, path, component, translator, registry) {
19
19
  if (path.length) {
20
20
  const childPath = path.shift();
21
21
  const slot = component.slots.get(childPath[0]);
22
- applySharedSlotToSlot(ev, path, slot, translator, formatterList, childPath[1] === 'formats');
22
+ applySharedSlotToSlot(ev, path, slot, translator, registry, childPath[1] === 'formats');
23
23
  return;
24
24
  }
25
25
  if (ev instanceof YMapEvent) {
@@ -50,11 +50,11 @@ function applySharedComponentToComponent(ev, path, component, translator, format
50
50
  });
51
51
  }
52
52
  }
53
- function applySharedSlotToSlot(ev, path, slot, translator, formatterList, isUpdateFormats) {
53
+ function applySharedSlotToSlot(ev, path, slot, translator, registry, isUpdateFormats) {
54
54
  if (path.length) {
55
55
  const componentIndex = path.shift()[0];
56
56
  const component = slot.getContentAtIndex(componentIndex);
57
- applySharedComponentToComponent(ev, path, component, translator, formatterList);
57
+ applySharedComponentToComponent(ev, path, component, translator, registry);
58
58
  return;
59
59
  }
60
60
  if (ev instanceof YArrayEvent) {
@@ -83,7 +83,7 @@ function applySharedSlotToSlot(ev, path, slot, translator, formatterList, isUpda
83
83
  const json = ev.target.toJSON();
84
84
  ev.keysChanged.forEach(key => {
85
85
  const formats = json[key];
86
- const formatter = formatterList.get(key);
86
+ const formatter = registry.getFormatter(key);
87
87
  if (formatter.type !== FormatType.Block) {
88
88
  slot.applyFormat(formatter, {
89
89
  startIndex: 0,
@@ -130,7 +130,7 @@ function apply(ev, slot, translator) {
130
130
  }
131
131
  });
132
132
  }
133
- else if (action.retain) {
133
+ else if (Reflect.has(action, 'retain')) {
134
134
  slot.retain(action.retain);
135
135
  }
136
136
  else if (action.delete) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-to-local.js","sourceRoot":"","sources":["../../src/collab/remote-to-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAU,SAAS,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAqB,UAAU,EAA8B,MAAM,eAAe,CAAA;AAIzF,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,IAAU,EAAE,UAAsB,EAAE,QAAkB;IACpG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAClB,MAAM,IAAI,GAAU,EAAE,CAAA;QAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAC1C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAqB,CAAC,CAAA;SACvD;QAED,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC,CAAC,CAAW,CAAA;YACjD,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAsB,CAAA;YAC7E,+BAA+B,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC1E,OAAM;SACP;QAED,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,+BAA+B,CAAC,EAAU,EAAE,IAAW,EAAE,SAA4B,EAAE,UAAsB,EAAE,QAAkB;IACxI,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAG,CAAA;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SACH;KACF;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,IAAU,EAAE,UAAsB;IAC3D,IAAI,EAAE,YAAY,WAAW,EAAE;QAC7B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACd,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAA;QACtB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrB,IAAI,MAAM,CAAC,MAAM,EAAE;gBAChB,MAAM,CAAC,MAAoC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAC1D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;wBAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;qBAClB;yBAAM;wBACL,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;wBAC1B,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAE,CAAA;wBACnD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;qBACvB;gBACH,CAAC,CAAC,CAAA;aACH;iBAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;gBACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAO,CAAC,CAAA;aAC5B;iBAAM,IAAI,MAAM,CAAC,MAAM,EAAE;gBACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACvB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;aAC3B;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC"}
@@ -1,15 +1,18 @@
1
- import { RootComponentRef, Starter, Translator, FormatterList } from '@textbus/core';
1
+ import { RootComponentRef, Starter, Translator, Registry } from '@textbus/core';
2
2
  import { Doc as YDoc } from 'yjs';
3
+ import { Awareness } from 'y-protocols/awareness';
4
+ import { CollaborateHistory } from './collab/_api';
3
5
  export declare class Collaborate {
4
6
  private rootComponentRef;
5
7
  private translator;
6
- private formatterList;
8
+ private registry;
9
+ private collaborateHistory;
7
10
  private starter;
8
11
  yDoc: YDoc;
9
12
  private subscriptions;
10
13
  private updateFromSelf;
11
- constructor(rootComponentRef: RootComponentRef, translator: Translator, formatterList: FormatterList, starter: Starter);
12
- setup(): void;
14
+ constructor(rootComponentRef: RootComponentRef, translator: Translator, registry: Registry, collaborateHistory: CollaborateHistory, starter: Starter);
15
+ setup(awareness: Awareness): void;
13
16
  destroy(): void;
14
17
  private listen;
15
18
  }
@@ -9,25 +9,36 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { Injectable } from '@tanbo/di';
11
11
  import { debounceTime, filter, tap } from '@tanbo/stream';
12
- import { RootComponentRef, Starter, Translator, FormatterList } from '@textbus/core';
12
+ import { RootComponentRef, Starter, Translator, Registry } from '@textbus/core';
13
13
  import { Doc as YDoc } from 'yjs';
14
- import { localToRemote } from './local-to-remote';
15
- import { remoteToLocal } from './remote-to-local';
14
+ import { localToRemote } from './collab/local-to-remote';
15
+ import { remoteToLocal } from './collab/remote-to-local';
16
+ import { CollaborateHistory } from './collab/_api';
16
17
  // const collaborateErrorFn = makeError('Collaborate')
17
18
  let Collaborate = class Collaborate {
18
- constructor(rootComponentRef, translator, formatterList, starter) {
19
+ constructor(rootComponentRef, translator, registry, collaborateHistory, starter) {
19
20
  this.rootComponentRef = rootComponentRef;
20
21
  this.translator = translator;
21
- this.formatterList = formatterList;
22
+ this.registry = registry;
23
+ this.collaborateHistory = collaborateHistory;
22
24
  this.starter = starter;
23
25
  this.yDoc = new YDoc();
24
26
  this.subscriptions = [];
25
27
  this.updateFromSelf = true;
26
28
  }
27
- setup() {
29
+ setup(awareness) {
28
30
  this.subscriptions.push(this.starter.onReady.subscribe(() => {
29
31
  this.listen();
30
32
  }));
33
+ awareness.on('update', () => {
34
+ const users = [];
35
+ awareness.getStates().forEach(state => {
36
+ if (state.user) {
37
+ users.push(state.user);
38
+ }
39
+ });
40
+ console.log(users);
41
+ });
31
42
  }
32
43
  destroy() {
33
44
  this.subscriptions.forEach(i => i.unsubscribe());
@@ -35,12 +46,13 @@ let Collaborate = class Collaborate {
35
46
  listen() {
36
47
  const root = this.yDoc.getArray('content');
37
48
  const slot = this.rootComponentRef.component.slots.get(0);
49
+ this.collaborateHistory.init(root);
38
50
  root.observeDeep((events, transaction) => {
39
51
  if (transaction.origin === this.yDoc) {
40
52
  return;
41
53
  }
42
54
  this.updateFromSelf = false;
43
- remoteToLocal(events, slot, this.translator, this.formatterList);
55
+ remoteToLocal(events, slot, this.translator, this.registry);
44
56
  this.updateFromSelf = true;
45
57
  });
46
58
  const operations = [];
@@ -62,7 +74,8 @@ Collaborate = __decorate([
62
74
  Injectable(),
63
75
  __metadata("design:paramtypes", [RootComponentRef,
64
76
  Translator,
65
- FormatterList,
77
+ Registry,
78
+ CollaborateHistory,
66
79
  Starter])
67
80
  ], Collaborate);
68
81
  export { Collaborate };
@@ -1 +1 @@
1
- {"version":3,"file":"collaborate.js","sourceRoot":"","sources":["../src/collaborate.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAgB,GAAG,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EACL,gBAAgB,EAChB,OAAO,EAEP,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,sDAAsD;AAGtD,IAAa,WAAW,GAAxB,MAAa,WAAW;IAMtB,YAAoB,gBAAkC,EAClC,UAAsB,EACtB,aAA4B,EAC5B,OAAgB;QAHhB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,eAA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AAW,CAoEvB;SApEY,WAAW"}
@@ -1 +1,2 @@
1
+ export * from './collab/_api';
1
2
  export * from './collaborate';
@@ -1,2 +1,3 @@
1
+ export * from './collab/_api';
1
2
  export * from './collaborate';
2
3
  //# sourceMappingURL=public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "2.0.0-alpha.36",
3
+ "version": "2.0.0-alpha.37",
4
4
  "description": "TextBus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/public-api.js",
6
6
  "module": "./bundles/public-api.js",
@@ -27,10 +27,10 @@
27
27
  "dependencies": {
28
28
  "@tanbo/di": "^1.0.5",
29
29
  "@tanbo/stream": "^0.0.11",
30
- "@textbus/core": "^2.0.0-alpha.36",
30
+ "@textbus/core": "^2.0.0-alpha.37",
31
31
  "reflect-metadata": "^0.1.13",
32
- "yjs": "^13.5.27",
33
- "y-protocols": "^1.0.5"
32
+ "y-protocols": "^1.0.5",
33
+ "yjs": "^13.5.27"
34
34
  },
35
35
  "author": {
36
36
  "name": "Tanbo",
@@ -43,5 +43,5 @@
43
43
  "bugs": {
44
44
  "url": "https://github.com/textbus/textbus.git/issues"
45
45
  },
46
- "gitHead": "536327fc2609d3f2bbf3b0720738d3ed918d612c"
46
+ "gitHead": "fca1880bd4a9fb21d4c28a76c492a6b98ba6dd8d"
47
47
  }
@@ -0,0 +1,3 @@
1
+ export * from './collaborate-history'
2
+ export * from './local-to-remote'
3
+ export * from './remote-to-local'
@@ -0,0 +1,55 @@
1
+ import { Injectable } from '@tanbo/di'
2
+ import { History } from '@textbus/core'
3
+ import { Observable, Subject } from '@tanbo/stream'
4
+ import { UndoManager, Array as YArray } from 'yjs'
5
+
6
+ @Injectable()
7
+ export class CollaborateHistory implements History {
8
+ onBack: Observable<void>
9
+ onForward: Observable<void>
10
+ onChange: Observable<any>
11
+ onPush: Observable<void>
12
+
13
+ get canBack() {
14
+ return this.manager?.canUndo()
15
+ }
16
+
17
+ get canForward() {
18
+ return this.manager?.canRedo()
19
+ }
20
+
21
+
22
+ private backEvent = new Subject<void>()
23
+ private forwardEvent = new Subject<void>()
24
+ private changeEvent = new Subject<void>()
25
+ private pushEvent = new Subject<void>()
26
+
27
+ private manager!: UndoManager
28
+
29
+ constructor() {
30
+ this.onBack = this.backEvent.asObservable()
31
+ this.onForward = this.forwardEvent.asObservable()
32
+ this.onChange = this.changeEvent.asObservable()
33
+ this.onPush = this.pushEvent.asObservable()
34
+ }
35
+
36
+ init(yArray: YArray<any>) {
37
+ this.manager = new UndoManager(yArray)
38
+ }
39
+
40
+ listen() {
41
+ //
42
+ }
43
+
44
+ back() {
45
+ //
46
+ }
47
+
48
+ forward() {
49
+ //
50
+ }
51
+
52
+ destroy() {
53
+ //
54
+ }
55
+ }
@@ -159,6 +159,10 @@ function makeSharedSlotBySlotLiteral(slotLiteral: SlotLiteral): YMap<any> {
159
159
  index += size
160
160
  })
161
161
  const formats = new YMap()
162
+ Object.keys(slotLiteral.formats).forEach(key => {
163
+ formats.set(key, slotLiteral.formats[key])
164
+ })
165
+
162
166
  const sharedSlot = new YMap()
163
167
  sharedSlot.set('state', slotLiteral.state)
164
168
  sharedSlot.set('content', content)
@@ -1,9 +1,9 @@
1
1
  import { Map as YMap, YArrayEvent, YEvent, YMapEvent } from 'yjs'
2
- import { ComponentInstance, FormatterList, FormatType, Slot, Translator } from '@textbus/core'
2
+ import { ComponentInstance, FormatType, Registry, Slot, Translator } from '@textbus/core'
3
3
 
4
4
  type YPath = [number, string][]
5
5
 
6
- export function remoteToLocal(events: YEvent[], slot: Slot, translator: Translator, formatterList: FormatterList) {
6
+ export function remoteToLocal(events: YEvent[], slot: Slot, translator: Translator, registry: Registry) {
7
7
  events.forEach(ev => {
8
8
  const path: YPath = []
9
9
 
@@ -14,7 +14,7 @@ export function remoteToLocal(events: YEvent[], slot: Slot, translator: Translat
14
14
  if (path.length) {
15
15
  const componentIndex = path.shift()![0] as number
16
16
  const component = slot.getContentAtIndex(componentIndex) as ComponentInstance
17
- applySharedComponentToComponent(ev, path, component, translator, formatterList)
17
+ applySharedComponentToComponent(ev, path, component, translator, registry)
18
18
  return
19
19
  }
20
20
 
@@ -22,11 +22,11 @@ export function remoteToLocal(events: YEvent[], slot: Slot, translator: Translat
22
22
  })
23
23
  }
24
24
 
25
- function applySharedComponentToComponent(ev: YEvent, path: YPath, component: ComponentInstance, translator: Translator, formatterList: FormatterList,) {
25
+ function applySharedComponentToComponent(ev: YEvent, path: YPath, component: ComponentInstance, translator: Translator, registry: Registry,) {
26
26
  if (path.length) {
27
27
  const childPath = path.shift()!
28
28
  const slot = component.slots.get(childPath[0])!
29
- applySharedSlotToSlot(ev, path, slot, translator, formatterList, childPath[1] === 'formats')
29
+ applySharedSlotToSlot(ev, path, slot, translator, registry, childPath[1] === 'formats')
30
30
  return
31
31
  }
32
32
  if (ev instanceof YMapEvent) {
@@ -55,11 +55,11 @@ function applySharedComponentToComponent(ev: YEvent, path: YPath, component: Com
55
55
  }
56
56
  }
57
57
 
58
- function applySharedSlotToSlot(ev: YEvent, path: YPath, slot: Slot, translator: Translator, formatterList: FormatterList, isUpdateFormats: boolean) {
58
+ function applySharedSlotToSlot(ev: YEvent, path: YPath, slot: Slot, translator: Translator, registry: Registry, isUpdateFormats: boolean) {
59
59
  if (path.length) {
60
60
  const componentIndex = path.shift()![0]
61
61
  const component = slot.getContentAtIndex(componentIndex) as ComponentInstance
62
- applySharedComponentToComponent(ev, path, component, translator, formatterList)
62
+ applySharedComponentToComponent(ev, path, component, translator, registry)
63
63
  return
64
64
  }
65
65
 
@@ -85,7 +85,7 @@ function applySharedSlotToSlot(ev: YEvent, path: YPath, slot: Slot, translator:
85
85
  const json = ev.target.toJSON()
86
86
  ev.keysChanged.forEach(key => {
87
87
  const formats = json[key]
88
- const formatter = formatterList.get(key)!
88
+ const formatter = registry.getFormatter(key)!
89
89
  if (formatter.type !== FormatType.Block) {
90
90
  slot.applyFormat(formatter, {
91
91
  startIndex: 0,
@@ -129,8 +129,8 @@ function apply(ev: YEvent, slot: Slot, translator: Translator) {
129
129
  slot.insert(component)
130
130
  }
131
131
  })
132
- } else if (action.retain) {
133
- slot.retain(action.retain)
132
+ } else if (Reflect.has(action, 'retain')) {
133
+ slot.retain(action.retain!)
134
134
  } else if (action.delete) {
135
135
  slot.retain(slot.index)
136
136
  slot.delete(action.delete)
@@ -5,11 +5,13 @@ import {
5
5
  Starter,
6
6
  Operation,
7
7
  Translator,
8
- FormatterList
8
+ Registry
9
9
  } from '@textbus/core'
10
10
  import { Doc as YDoc } from 'yjs'
11
- import { localToRemote } from './local-to-remote'
12
- import { remoteToLocal } from './remote-to-local'
11
+ import { Awareness } from 'y-protocols/awareness'
12
+ import { localToRemote } from './collab/local-to-remote'
13
+ import { remoteToLocal } from './collab/remote-to-local'
14
+ import { CollaborateHistory } from './collab/_api'
13
15
 
14
16
  // const collaborateErrorFn = makeError('Collaborate')
15
17
 
@@ -22,16 +24,26 @@ export class Collaborate {
22
24
 
23
25
  constructor(private rootComponentRef: RootComponentRef,
24
26
  private translator: Translator,
25
- private formatterList: FormatterList,
27
+ private registry: Registry,
28
+ private collaborateHistory: CollaborateHistory,
26
29
  private starter: Starter) {
27
30
  }
28
31
 
29
- setup() {
32
+ setup(awareness: Awareness) {
30
33
  this.subscriptions.push(
31
34
  this.starter.onReady.subscribe(() => {
32
35
  this.listen()
33
36
  })
34
37
  )
38
+ awareness.on('update', () => {
39
+ const users: any[] = []
40
+ awareness.getStates().forEach(state => {
41
+ if (state.user) {
42
+ users.push(state.user)
43
+ }
44
+ })
45
+ console.log(users)
46
+ })
35
47
  }
36
48
 
37
49
  destroy() {
@@ -41,13 +53,14 @@ export class Collaborate {
41
53
  private listen() {
42
54
  const root = this.yDoc.getArray('content')
43
55
  const slot = this.rootComponentRef.component.slots.get(0)!
56
+ this.collaborateHistory.init(root)
44
57
  root.observeDeep((events, transaction) => {
45
58
  if (transaction.origin === this.yDoc) {
46
59
  return
47
60
  }
48
61
  this.updateFromSelf = false
49
62
 
50
- remoteToLocal(events, slot, this.translator, this.formatterList)
63
+ remoteToLocal(events, slot, this.translator, this.registry)
51
64
 
52
65
  this.updateFromSelf = true
53
66
  })
package/src/public-api.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from './collab/_api'
1
2
  export * from './collaborate'
@@ -1 +0,0 @@
1
- {"version":3,"file":"local-to-remote.js","sourceRoot":"","sources":["../src/local-to-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,MAAM,EAA4B,MAAM,eAAe,CAAA;AAClH,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,KAAK,CAAA;AAElD,MAAM,UAAU,aAAa,CAAC,SAAoB,EAAE,IAAiB;IACnE,MAAM,IAAI,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,CAAC,KAAK,EAAE,CAAA;IACZ,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,EAAG,CAAA;QACpC,wCAAwC,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAA;QACzF,OAAM;KACP;IACD,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,wCAAwC,CAAC,IAAc,EAAE,OAAiB,EAAE,aAAwB;IAC3G,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAgB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AAA;AACxB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { YEvent } from 'yjs';
2
- import { FormatterList, Slot, Translator } from '@textbus/core';
3
- export declare function remoteToLocal(events: YEvent[], slot: Slot, translator: Translator, formatterList: FormatterList): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-to-local.js","sourceRoot":"","sources":["../src/remote-to-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAU,SAAS,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAoC,UAAU,EAAoB,MAAM,eAAe,CAAA;AAI9F,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,IAAU,EAAE,UAAsB,EAAE,aAA4B;IAC9G,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAClB,MAAM,IAAI,GAAU,EAAE,CAAA;QAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAC1C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAqB,CAAC,CAAA;SACvD;QAED,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC,CAAC,CAAW,CAAA;YACjD,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAsB,CAAA;YAC7E,+BAA+B,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;YAC/E,OAAM;SACP;QAED,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,+BAA+B,CAAC,EAAU,EAAE,IAAW,EAAE,SAA4B,EAAE,UAAsB,EAAE,aAA4B;IAClJ,IAAI,I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