@textbus/collaborate 4.4.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { History, RootComponentRef, Scheduler, Selection } from '@textbus/core';
1
+ import { History, RootComponentRef, Scheduler } from '@textbus/core';
2
2
  import { Observable } from '@tanbo/stream';
3
3
  import { Item, Transaction } from 'yjs';
4
4
  import { Collaborate } from './collaborate';
@@ -10,7 +10,6 @@ export declare class CollabHistory implements History {
10
10
  private rootComponentRef;
11
11
  private collaborate;
12
12
  private scheduler;
13
- private selection;
14
13
  private stackSize;
15
14
  private undoManagerConfig;
16
15
  onBack: Observable<void>;
@@ -27,7 +26,7 @@ export declare class CollabHistory implements History {
27
26
  private forwardEvent;
28
27
  private changeEvent;
29
28
  private pushEvent;
30
- constructor(rootComponentRef: RootComponentRef, collaborate: Collaborate, scheduler: Scheduler, selection: Selection, stackSize: number, undoManagerConfig: CustomUndoManagerConfig);
29
+ constructor(rootComponentRef: RootComponentRef, collaborate: Collaborate, scheduler: Scheduler, stackSize: number, undoManagerConfig: CustomUndoManagerConfig);
31
30
  listen(): void;
32
31
  back(): void;
33
32
  forward(): void;
@@ -4,6 +4,7 @@ import { Doc as YDoc } from 'yjs';
4
4
  import { SyncConnector } from './base/_api';
5
5
  export interface CollaborateConfig {
6
6
  createConnector(yDoc: YDoc): SyncConnector;
7
+ beforeSync?(yDoc: YDoc): Promise<void> | void;
7
8
  }
8
9
  export declare class CollaborateModule implements Module {
9
10
  config: CollaborateConfig;
@@ -946,7 +946,7 @@ let CollabHistory = class CollabHistory {
946
946
  var _a;
947
947
  return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
948
948
  }
949
- constructor(rootComponentRef, collaborate, scheduler, selection, stackSize, undoManagerConfig) {
949
+ constructor(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
950
950
  Object.defineProperty(this, "rootComponentRef", {
951
951
  enumerable: true,
952
952
  configurable: true,
@@ -965,12 +965,6 @@ let CollabHistory = class CollabHistory {
965
965
  writable: true,
966
966
  value: scheduler
967
967
  });
968
- Object.defineProperty(this, "selection", {
969
- enumerable: true,
970
- configurable: true,
971
- writable: true,
972
- value: selection
973
- });
974
968
  Object.defineProperty(this, "stackSize", {
975
969
  enumerable: true,
976
970
  configurable: true,
@@ -1157,12 +1151,11 @@ let CollabHistory = class CollabHistory {
1157
1151
  };
1158
1152
  CollabHistory = __decorate([
1159
1153
  Injectable(),
1160
- __param(4, Inject(HISTORY_STACK_SIZE)),
1161
- __param(5, Optional()),
1154
+ __param(3, Inject(HISTORY_STACK_SIZE)),
1155
+ __param(4, Optional()),
1162
1156
  __metadata("design:paramtypes", [RootComponentRef,
1163
1157
  Collaborate,
1164
- Scheduler,
1165
- Selection, Number, CustomUndoManagerConfig])
1158
+ Scheduler, Number, CustomUndoManagerConfig])
1166
1159
  ], CollabHistory);
1167
1160
 
1168
1161
  /**
@@ -1648,6 +1641,7 @@ class CollaborateModule {
1648
1641
  setup(textbus) {
1649
1642
  const messageBus = textbus.get(MessageBus, null);
1650
1643
  const connector = textbus.get(SyncConnector);
1644
+ const collab = textbus.get(Collaborate);
1651
1645
  if (messageBus) {
1652
1646
  const selection = textbus.get(Selection);
1653
1647
  connector.setLocalStateField('message', messageBus.get(textbus));
@@ -1659,7 +1653,10 @@ class CollaborateModule {
1659
1653
  messageBus.consume(states, textbus);
1660
1654
  }));
1661
1655
  }
1662
- return connector.onLoad.toPromise();
1656
+ return connector.onLoad.toPromise().then(() => {
1657
+ var _a, _b;
1658
+ return (_b = (_a = this.config).beforeSync) === null || _b === void 0 ? void 0 : _b.call(_a, collab.yDoc);
1659
+ });
1663
1660
  }
1664
1661
  onDestroy(textbus) {
1665
1662
  this.subscription.unsubscribe();
package/bundles/index.js CHANGED
@@ -948,7 +948,7 @@ exports.CollabHistory = class CollabHistory {
948
948
  var _a;
949
949
  return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
950
950
  }
951
- constructor(rootComponentRef, collaborate, scheduler, selection, stackSize, undoManagerConfig) {
951
+ constructor(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
952
952
  Object.defineProperty(this, "rootComponentRef", {
953
953
  enumerable: true,
954
954
  configurable: true,
@@ -967,12 +967,6 @@ exports.CollabHistory = class CollabHistory {
967
967
  writable: true,
968
968
  value: scheduler
969
969
  });
970
- Object.defineProperty(this, "selection", {
971
- enumerable: true,
972
- configurable: true,
973
- writable: true,
974
- value: selection
975
- });
976
970
  Object.defineProperty(this, "stackSize", {
977
971
  enumerable: true,
978
972
  configurable: true,
@@ -1159,12 +1153,11 @@ exports.CollabHistory = class CollabHistory {
1159
1153
  };
1160
1154
  exports.CollabHistory = __decorate([
1161
1155
  core$1.Injectable(),
1162
- __param(4, core$1.Inject(core.HISTORY_STACK_SIZE)),
1163
- __param(5, core$1.Optional()),
1156
+ __param(3, core$1.Inject(core.HISTORY_STACK_SIZE)),
1157
+ __param(4, core$1.Optional()),
1164
1158
  __metadata("design:paramtypes", [core.RootComponentRef,
1165
1159
  exports.Collaborate,
1166
- core.Scheduler,
1167
- core.Selection, Number, CustomUndoManagerConfig])
1160
+ core.Scheduler, Number, CustomUndoManagerConfig])
1168
1161
  ], exports.CollabHistory);
1169
1162
 
1170
1163
  /**
@@ -1650,6 +1643,7 @@ class CollaborateModule {
1650
1643
  setup(textbus) {
1651
1644
  const messageBus = textbus.get(MessageBus, null);
1652
1645
  const connector = textbus.get(SyncConnector);
1646
+ const collab = textbus.get(exports.Collaborate);
1653
1647
  if (messageBus) {
1654
1648
  const selection = textbus.get(core.Selection);
1655
1649
  connector.setLocalStateField('message', messageBus.get(textbus));
@@ -1661,7 +1655,10 @@ class CollaborateModule {
1661
1655
  messageBus.consume(states, textbus);
1662
1656
  }));
1663
1657
  }
1664
- return connector.onLoad.toPromise();
1658
+ return connector.onLoad.toPromise().then(() => {
1659
+ var _a, _b;
1660
+ return (_b = (_a = this.config).beforeSync) === null || _b === void 0 ? void 0 : _b.call(_a, collab.yDoc);
1661
+ });
1665
1662
  }
1666
1663
  onDestroy(textbus) {
1667
1664
  this.subscription.unsubscribe();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "4.4.2",
3
+ "version": "4.5.0",
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/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -27,16 +27,16 @@
27
27
  "dependencies": {
28
28
  "@hocuspocus/provider": "^2.15.2",
29
29
  "@tanbo/stream": "^1.2.7",
30
- "@textbus/core": "^4.4.2",
31
- "@viewfly/core": "^1.2.1",
30
+ "@textbus/core": "^4.5.0",
31
+ "@viewfly/core": "^1.2.3",
32
32
  "y-websocket": "^2.1.0",
33
33
  "yjs": "^13.6.23"
34
34
  },
35
35
  "devDependencies": {
36
- "@rollup/plugin-commonjs": "^23.0.2",
37
- "@rollup/plugin-typescript": "^9.0.2",
36
+ "@rollup/plugin-commonjs": "^28.0.2",
37
+ "@rollup/plugin-typescript": "^12.1.2",
38
38
  "rimraf": "^3.0.2",
39
- "rollup": "^3.2.5",
39
+ "rollup": "4.22.4",
40
40
  "tslib": "^2.4.1"
41
41
  },
42
42
  "author": {
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "5132df31e69783964c69512d22f037204162681a"
53
+ "gitHead": "327e764487545a35d97eae525b61307642b8f386"
54
54
  }