@textbus/collaborate 5.0.0-alpha.1 → 5.0.0-alpha.2
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
|
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,
|
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,11 +4,13 @@ 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
|
+
onlyLoad?: boolean;
|
7
8
|
}
|
8
9
|
export declare class CollaborateModule implements Module {
|
9
10
|
config: CollaborateConfig;
|
10
11
|
private subscription;
|
11
12
|
providers: Provider[];
|
13
|
+
private timer;
|
12
14
|
constructor(config: CollaborateConfig);
|
13
15
|
setup(textbus: Textbus): Promise<(() => void) | void> | (() => void) | void;
|
14
16
|
onDestroy(textbus: Textbus): void;
|
package/bundles/index.esm.js
CHANGED
@@ -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,
|
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(
|
1161
|
-
__param(
|
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
|
/**
|
@@ -1644,10 +1637,17 @@ class CollaborateModule {
|
|
1644
1637
|
}
|
1645
1638
|
]
|
1646
1639
|
});
|
1640
|
+
Object.defineProperty(this, "timer", {
|
1641
|
+
enumerable: true,
|
1642
|
+
configurable: true,
|
1643
|
+
writable: true,
|
1644
|
+
value: null
|
1645
|
+
});
|
1647
1646
|
}
|
1648
1647
|
setup(textbus) {
|
1649
1648
|
const messageBus = textbus.get(MessageBus, null);
|
1650
1649
|
const connector = textbus.get(SyncConnector);
|
1650
|
+
const collab = textbus.get(Collaborate);
|
1651
1651
|
if (messageBus) {
|
1652
1652
|
const selection = textbus.get(Selection);
|
1653
1653
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1659,13 +1659,33 @@ class CollaborateModule {
|
|
1659
1659
|
messageBus.consume(states, textbus);
|
1660
1660
|
}));
|
1661
1661
|
}
|
1662
|
-
return connector.onLoad.toPromise()
|
1662
|
+
return connector.onLoad.toPromise().then(() => {
|
1663
|
+
if (!this.config.onlyLoad) {
|
1664
|
+
return;
|
1665
|
+
}
|
1666
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1667
|
+
if (root.has('state')) {
|
1668
|
+
return;
|
1669
|
+
}
|
1670
|
+
return new Promise(resolve => {
|
1671
|
+
const testing = () => {
|
1672
|
+
if (root.has('state')) {
|
1673
|
+
resolve();
|
1674
|
+
}
|
1675
|
+
else {
|
1676
|
+
this.timer = setTimeout(testing, 1000);
|
1677
|
+
}
|
1678
|
+
};
|
1679
|
+
this.timer = setTimeout(testing, 1000);
|
1680
|
+
});
|
1681
|
+
});
|
1663
1682
|
}
|
1664
1683
|
onDestroy(textbus) {
|
1665
1684
|
this.subscription.unsubscribe();
|
1666
1685
|
textbus.get(Collaborate).destroy();
|
1667
1686
|
textbus.get(History).destroy();
|
1668
1687
|
textbus.get(SyncConnector).onDestroy();
|
1688
|
+
clearTimeout(this.timer);
|
1669
1689
|
}
|
1670
1690
|
}
|
1671
1691
|
|
@@ -1707,10 +1727,17 @@ class MultipleDocumentCollaborateModule {
|
|
1707
1727
|
}
|
1708
1728
|
]
|
1709
1729
|
});
|
1730
|
+
Object.defineProperty(this, "timer", {
|
1731
|
+
enumerable: true,
|
1732
|
+
configurable: true,
|
1733
|
+
writable: true,
|
1734
|
+
value: null
|
1735
|
+
});
|
1710
1736
|
}
|
1711
1737
|
setup(textbus) {
|
1712
1738
|
const messageBus = textbus.get(MessageBus, null);
|
1713
1739
|
const connector = textbus.get(SyncConnector);
|
1740
|
+
const collab = textbus.get(Collaborate);
|
1714
1741
|
if (messageBus) {
|
1715
1742
|
const selection = textbus.get(Selection);
|
1716
1743
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1722,13 +1749,33 @@ class MultipleDocumentCollaborateModule {
|
|
1722
1749
|
messageBus.consume(states, textbus);
|
1723
1750
|
}));
|
1724
1751
|
}
|
1725
|
-
return connector.onLoad.toPromise()
|
1752
|
+
return connector.onLoad.toPromise().then(() => {
|
1753
|
+
if (!this.config.onlyLoad) {
|
1754
|
+
return;
|
1755
|
+
}
|
1756
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1757
|
+
if (root.has('state')) {
|
1758
|
+
return;
|
1759
|
+
}
|
1760
|
+
return new Promise(resolve => {
|
1761
|
+
const testing = () => {
|
1762
|
+
if (root.has('state')) {
|
1763
|
+
resolve();
|
1764
|
+
}
|
1765
|
+
else {
|
1766
|
+
this.timer = setTimeout(testing, 1000);
|
1767
|
+
}
|
1768
|
+
};
|
1769
|
+
this.timer = setTimeout(testing, 1000);
|
1770
|
+
});
|
1771
|
+
});
|
1726
1772
|
}
|
1727
1773
|
onDestroy(textbus) {
|
1728
1774
|
this.subscription.unsubscribe();
|
1729
1775
|
textbus.get(Collaborate).destroy();
|
1730
1776
|
textbus.get(History).destroy();
|
1731
1777
|
textbus.get(SyncConnector).onDestroy();
|
1778
|
+
clearTimeout(this.timer);
|
1732
1779
|
}
|
1733
1780
|
}
|
1734
1781
|
|
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,
|
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(
|
1163
|
-
__param(
|
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
|
/**
|
@@ -1646,10 +1639,17 @@ class CollaborateModule {
|
|
1646
1639
|
}
|
1647
1640
|
]
|
1648
1641
|
});
|
1642
|
+
Object.defineProperty(this, "timer", {
|
1643
|
+
enumerable: true,
|
1644
|
+
configurable: true,
|
1645
|
+
writable: true,
|
1646
|
+
value: null
|
1647
|
+
});
|
1649
1648
|
}
|
1650
1649
|
setup(textbus) {
|
1651
1650
|
const messageBus = textbus.get(MessageBus, null);
|
1652
1651
|
const connector = textbus.get(SyncConnector);
|
1652
|
+
const collab = textbus.get(exports.Collaborate);
|
1653
1653
|
if (messageBus) {
|
1654
1654
|
const selection = textbus.get(core.Selection);
|
1655
1655
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1661,13 +1661,33 @@ class CollaborateModule {
|
|
1661
1661
|
messageBus.consume(states, textbus);
|
1662
1662
|
}));
|
1663
1663
|
}
|
1664
|
-
return connector.onLoad.toPromise()
|
1664
|
+
return connector.onLoad.toPromise().then(() => {
|
1665
|
+
if (!this.config.onlyLoad) {
|
1666
|
+
return;
|
1667
|
+
}
|
1668
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1669
|
+
if (root.has('state')) {
|
1670
|
+
return;
|
1671
|
+
}
|
1672
|
+
return new Promise(resolve => {
|
1673
|
+
const testing = () => {
|
1674
|
+
if (root.has('state')) {
|
1675
|
+
resolve();
|
1676
|
+
}
|
1677
|
+
else {
|
1678
|
+
this.timer = setTimeout(testing, 1000);
|
1679
|
+
}
|
1680
|
+
};
|
1681
|
+
this.timer = setTimeout(testing, 1000);
|
1682
|
+
});
|
1683
|
+
});
|
1665
1684
|
}
|
1666
1685
|
onDestroy(textbus) {
|
1667
1686
|
this.subscription.unsubscribe();
|
1668
1687
|
textbus.get(exports.Collaborate).destroy();
|
1669
1688
|
textbus.get(core.History).destroy();
|
1670
1689
|
textbus.get(SyncConnector).onDestroy();
|
1690
|
+
clearTimeout(this.timer);
|
1671
1691
|
}
|
1672
1692
|
}
|
1673
1693
|
|
@@ -1709,10 +1729,17 @@ class MultipleDocumentCollaborateModule {
|
|
1709
1729
|
}
|
1710
1730
|
]
|
1711
1731
|
});
|
1732
|
+
Object.defineProperty(this, "timer", {
|
1733
|
+
enumerable: true,
|
1734
|
+
configurable: true,
|
1735
|
+
writable: true,
|
1736
|
+
value: null
|
1737
|
+
});
|
1712
1738
|
}
|
1713
1739
|
setup(textbus) {
|
1714
1740
|
const messageBus = textbus.get(MessageBus, null);
|
1715
1741
|
const connector = textbus.get(SyncConnector);
|
1742
|
+
const collab = textbus.get(exports.Collaborate);
|
1716
1743
|
if (messageBus) {
|
1717
1744
|
const selection = textbus.get(core.Selection);
|
1718
1745
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1724,13 +1751,33 @@ class MultipleDocumentCollaborateModule {
|
|
1724
1751
|
messageBus.consume(states, textbus);
|
1725
1752
|
}));
|
1726
1753
|
}
|
1727
|
-
return connector.onLoad.toPromise()
|
1754
|
+
return connector.onLoad.toPromise().then(() => {
|
1755
|
+
if (!this.config.onlyLoad) {
|
1756
|
+
return;
|
1757
|
+
}
|
1758
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1759
|
+
if (root.has('state')) {
|
1760
|
+
return;
|
1761
|
+
}
|
1762
|
+
return new Promise(resolve => {
|
1763
|
+
const testing = () => {
|
1764
|
+
if (root.has('state')) {
|
1765
|
+
resolve();
|
1766
|
+
}
|
1767
|
+
else {
|
1768
|
+
this.timer = setTimeout(testing, 1000);
|
1769
|
+
}
|
1770
|
+
};
|
1771
|
+
this.timer = setTimeout(testing, 1000);
|
1772
|
+
});
|
1773
|
+
});
|
1728
1774
|
}
|
1729
1775
|
onDestroy(textbus) {
|
1730
1776
|
this.subscription.unsubscribe();
|
1731
1777
|
textbus.get(exports.Collaborate).destroy();
|
1732
1778
|
textbus.get(core.History).destroy();
|
1733
1779
|
textbus.get(SyncConnector).onDestroy();
|
1780
|
+
clearTimeout(this.timer);
|
1734
1781
|
}
|
1735
1782
|
}
|
1736
1783
|
|
@@ -9,6 +9,7 @@ export declare class MultipleDocumentCollaborateModule implements Module {
|
|
9
9
|
config: MultipleDocCollaborateConfig;
|
10
10
|
private subscription;
|
11
11
|
providers: Provider[];
|
12
|
+
private timer;
|
12
13
|
constructor(config: MultipleDocCollaborateConfig);
|
13
14
|
setup(textbus: Textbus): Promise<(() => void) | void> | (() => void) | void;
|
14
15
|
onDestroy(textbus: Textbus): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/collaborate",
|
3
|
-
"version": "5.0.0-alpha.
|
3
|
+
"version": "5.0.0-alpha.2",
|
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": "^5.0.0-alpha.
|
30
|
+
"@textbus/core": "^5.0.0-alpha.2",
|
31
31
|
"@viewfly/core": "^2.0.0-alpha.3",
|
32
32
|
"y-websocket": "^2.1.0",
|
33
33
|
"yjs": "^13.6.23"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
|
-
"@rollup/plugin-commonjs": "^
|
37
|
-
"@rollup/plugin-typescript": "^
|
36
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
37
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
38
38
|
"rimraf": "^3.0.2",
|
39
|
-
"rollup": "
|
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": "
|
53
|
+
"gitHead": "97907867dcabead654d9269cbf241da769c17dbd"
|
54
54
|
}
|