@textbus/collaborate 5.0.0-alpha.1 → 5.0.0-alpha.10
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
@@ -356,11 +356,8 @@ let Collaborate = class Collaborate {
|
|
356
356
|
if (formats.length) {
|
357
357
|
localSlot.retain(action.retain, formats);
|
358
358
|
}
|
359
|
-
localSlot.retain(localSlot.index + action.retain);
|
360
|
-
}
|
361
|
-
else {
|
362
|
-
localSlot.retain(action.retain);
|
363
359
|
}
|
360
|
+
localSlot.retain(localSlot.index + action.retain);
|
364
361
|
}
|
365
362
|
else if (action.insert) {
|
366
363
|
const index = localSlot.index;
|
@@ -521,6 +518,8 @@ let Collaborate = class Collaborate {
|
|
521
518
|
return;
|
522
519
|
}
|
523
520
|
const content = subDocument.getText('content');
|
521
|
+
const state = subDocument.getMap('state');
|
522
|
+
this.syncLocalMapToSharedMap(localSlot.state, state);
|
524
523
|
this.initSharedSlotByLocalSlot(content, localSlot);
|
525
524
|
this.syncSlot(content, localSlot);
|
526
525
|
this.addSubModelEvent.next({
|
@@ -535,6 +534,9 @@ let Collaborate = class Collaborate {
|
|
535
534
|
});
|
536
535
|
return sharedSlot;
|
537
536
|
}
|
537
|
+
const sharedSlotState = new Map();
|
538
|
+
this.syncLocalMapToSharedMap(localSlot.state, sharedSlotState);
|
539
|
+
sharedSlot.setAttribute('state', sharedSlotState);
|
538
540
|
const sharedContent = new Text();
|
539
541
|
this.initSharedSlotByLocalSlot(sharedContent, localSlot);
|
540
542
|
sharedSlot.insertEmbed(0, sharedContent);
|
@@ -572,11 +574,13 @@ let Collaborate = class Collaborate {
|
|
572
574
|
const schema = sharedSlot.getAttribute('schema');
|
573
575
|
if (type === 'async') {
|
574
576
|
const metadata = sharedSlot.getAttribute('metadata');
|
575
|
-
const slot = new AsyncSlot(schema || [], {});
|
577
|
+
const slot = new AsyncSlot(schema || [], {}, {});
|
576
578
|
this.syncSharedMapToLocalMap(metadata, slot.metadata);
|
577
579
|
const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
|
578
580
|
if (loadedSubDocument) {
|
579
581
|
const subContent = loadedSubDocument.getText('content');
|
582
|
+
const data = loadedSubDocument.getMap('state');
|
583
|
+
this.syncSharedMapToLocalMap(data, slot.state);
|
580
584
|
this.syncRootSlot(loadedSubDocument, subContent, slot);
|
581
585
|
this.addSubModelEvent.next({
|
582
586
|
yDoc: loadedSubDocument,
|
@@ -592,13 +596,15 @@ let Collaborate = class Collaborate {
|
|
592
596
|
if (isDestroyed) {
|
593
597
|
return;
|
594
598
|
}
|
595
|
-
slot.loader.markAsLoaded();
|
596
599
|
const subContent = subDocument.getText('content');
|
600
|
+
const state = subDocument.getMap('state');
|
601
|
+
this.syncSharedMapToLocalMap(state, slot.state);
|
597
602
|
this.syncRootSlot(subDocument, subContent, slot);
|
598
603
|
this.addSubModelEvent.next({
|
599
604
|
yDoc: subDocument,
|
600
605
|
yType: subContent
|
601
606
|
});
|
607
|
+
slot.loader.markAsLoaded();
|
602
608
|
});
|
603
609
|
slot.__changeMarker__.addDetachCallback(() => {
|
604
610
|
isDestroyed = true;
|
@@ -610,7 +616,9 @@ let Collaborate = class Collaborate {
|
|
610
616
|
if (!(content instanceof Text)) {
|
611
617
|
throw collaborateErrorFn('shared slot content type is not `YText`.');
|
612
618
|
}
|
613
|
-
const localSlot = new Slot(schema || []);
|
619
|
+
const localSlot = new Slot(schema || [], {});
|
620
|
+
const sharedSlotState = sharedSlot.getAttribute('state');
|
621
|
+
this.syncSharedMapToLocalMap(sharedSlotState, localSlot.state);
|
614
622
|
this.initLocalSlotBySharedSlot(content, localSlot);
|
615
623
|
this.syncSlot(content, localSlot);
|
616
624
|
return localSlot;
|
@@ -726,13 +734,13 @@ let Collaborate = class Collaborate {
|
|
726
734
|
if (isDestroyed) {
|
727
735
|
return;
|
728
736
|
}
|
729
|
-
instance.loader.markAsLoaded();
|
730
737
|
const state = subDocument.getMap('state');
|
731
738
|
this.syncComponent(subDocument, state, instance);
|
732
739
|
this.addSubModelEvent.next({
|
733
740
|
yType: state,
|
734
741
|
yDoc: subDocument
|
735
742
|
});
|
743
|
+
instance.loader.markAsLoaded();
|
736
744
|
});
|
737
745
|
state.__changeMarker__.addDetachCallback(() => {
|
738
746
|
isDestroyed = true;
|
@@ -946,7 +954,7 @@ let CollabHistory = class CollabHistory {
|
|
946
954
|
var _a;
|
947
955
|
return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
|
948
956
|
}
|
949
|
-
constructor(rootComponentRef, collaborate, scheduler,
|
957
|
+
constructor(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
|
950
958
|
Object.defineProperty(this, "rootComponentRef", {
|
951
959
|
enumerable: true,
|
952
960
|
configurable: true,
|
@@ -965,12 +973,6 @@ let CollabHistory = class CollabHistory {
|
|
965
973
|
writable: true,
|
966
974
|
value: scheduler
|
967
975
|
});
|
968
|
-
Object.defineProperty(this, "selection", {
|
969
|
-
enumerable: true,
|
970
|
-
configurable: true,
|
971
|
-
writable: true,
|
972
|
-
value: selection
|
973
|
-
});
|
974
976
|
Object.defineProperty(this, "stackSize", {
|
975
977
|
enumerable: true,
|
976
978
|
configurable: true,
|
@@ -1157,12 +1159,11 @@ let CollabHistory = class CollabHistory {
|
|
1157
1159
|
};
|
1158
1160
|
CollabHistory = __decorate([
|
1159
1161
|
Injectable(),
|
1160
|
-
__param(
|
1161
|
-
__param(
|
1162
|
+
__param(3, Inject(HISTORY_STACK_SIZE)),
|
1163
|
+
__param(4, Optional()),
|
1162
1164
|
__metadata("design:paramtypes", [RootComponentRef,
|
1163
1165
|
Collaborate,
|
1164
|
-
Scheduler,
|
1165
|
-
Selection, Number, CustomUndoManagerConfig])
|
1166
|
+
Scheduler, Number, CustomUndoManagerConfig])
|
1166
1167
|
], CollabHistory);
|
1167
1168
|
|
1168
1169
|
/**
|
@@ -1644,10 +1645,17 @@ class CollaborateModule {
|
|
1644
1645
|
}
|
1645
1646
|
]
|
1646
1647
|
});
|
1648
|
+
Object.defineProperty(this, "timer", {
|
1649
|
+
enumerable: true,
|
1650
|
+
configurable: true,
|
1651
|
+
writable: true,
|
1652
|
+
value: null
|
1653
|
+
});
|
1647
1654
|
}
|
1648
1655
|
setup(textbus) {
|
1649
1656
|
const messageBus = textbus.get(MessageBus, null);
|
1650
1657
|
const connector = textbus.get(SyncConnector);
|
1658
|
+
const collab = textbus.get(Collaborate);
|
1651
1659
|
if (messageBus) {
|
1652
1660
|
const selection = textbus.get(Selection);
|
1653
1661
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1659,13 +1667,33 @@ class CollaborateModule {
|
|
1659
1667
|
messageBus.consume(states, textbus);
|
1660
1668
|
}));
|
1661
1669
|
}
|
1662
|
-
return connector.onLoad.toPromise()
|
1670
|
+
return connector.onLoad.toPromise().then(() => {
|
1671
|
+
if (!this.config.onlyLoad) {
|
1672
|
+
return;
|
1673
|
+
}
|
1674
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1675
|
+
if (root.has('state')) {
|
1676
|
+
return;
|
1677
|
+
}
|
1678
|
+
return new Promise(resolve => {
|
1679
|
+
const testing = () => {
|
1680
|
+
if (root.has('state')) {
|
1681
|
+
resolve();
|
1682
|
+
}
|
1683
|
+
else {
|
1684
|
+
this.timer = setTimeout(testing, 1000);
|
1685
|
+
}
|
1686
|
+
};
|
1687
|
+
this.timer = setTimeout(testing, 1000);
|
1688
|
+
});
|
1689
|
+
});
|
1663
1690
|
}
|
1664
1691
|
onDestroy(textbus) {
|
1665
1692
|
this.subscription.unsubscribe();
|
1666
1693
|
textbus.get(Collaborate).destroy();
|
1667
1694
|
textbus.get(History).destroy();
|
1668
1695
|
textbus.get(SyncConnector).onDestroy();
|
1696
|
+
clearTimeout(this.timer);
|
1669
1697
|
}
|
1670
1698
|
}
|
1671
1699
|
|
@@ -1707,10 +1735,17 @@ class MultipleDocumentCollaborateModule {
|
|
1707
1735
|
}
|
1708
1736
|
]
|
1709
1737
|
});
|
1738
|
+
Object.defineProperty(this, "timer", {
|
1739
|
+
enumerable: true,
|
1740
|
+
configurable: true,
|
1741
|
+
writable: true,
|
1742
|
+
value: null
|
1743
|
+
});
|
1710
1744
|
}
|
1711
1745
|
setup(textbus) {
|
1712
1746
|
const messageBus = textbus.get(MessageBus, null);
|
1713
1747
|
const connector = textbus.get(SyncConnector);
|
1748
|
+
const collab = textbus.get(Collaborate);
|
1714
1749
|
if (messageBus) {
|
1715
1750
|
const selection = textbus.get(Selection);
|
1716
1751
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1722,13 +1757,33 @@ class MultipleDocumentCollaborateModule {
|
|
1722
1757
|
messageBus.consume(states, textbus);
|
1723
1758
|
}));
|
1724
1759
|
}
|
1725
|
-
return connector.onLoad.toPromise()
|
1760
|
+
return connector.onLoad.toPromise().then(() => {
|
1761
|
+
if (!this.config.onlyLoad) {
|
1762
|
+
return;
|
1763
|
+
}
|
1764
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1765
|
+
if (root.has('state')) {
|
1766
|
+
return;
|
1767
|
+
}
|
1768
|
+
return new Promise(resolve => {
|
1769
|
+
const testing = () => {
|
1770
|
+
if (root.has('state')) {
|
1771
|
+
resolve();
|
1772
|
+
}
|
1773
|
+
else {
|
1774
|
+
this.timer = setTimeout(testing, 1000);
|
1775
|
+
}
|
1776
|
+
};
|
1777
|
+
this.timer = setTimeout(testing, 1000);
|
1778
|
+
});
|
1779
|
+
});
|
1726
1780
|
}
|
1727
1781
|
onDestroy(textbus) {
|
1728
1782
|
this.subscription.unsubscribe();
|
1729
1783
|
textbus.get(Collaborate).destroy();
|
1730
1784
|
textbus.get(History).destroy();
|
1731
1785
|
textbus.get(SyncConnector).onDestroy();
|
1786
|
+
clearTimeout(this.timer);
|
1732
1787
|
}
|
1733
1788
|
}
|
1734
1789
|
|
package/bundles/index.js
CHANGED
@@ -358,11 +358,8 @@ exports.Collaborate = class Collaborate {
|
|
358
358
|
if (formats.length) {
|
359
359
|
localSlot.retain(action.retain, formats);
|
360
360
|
}
|
361
|
-
localSlot.retain(localSlot.index + action.retain);
|
362
|
-
}
|
363
|
-
else {
|
364
|
-
localSlot.retain(action.retain);
|
365
361
|
}
|
362
|
+
localSlot.retain(localSlot.index + action.retain);
|
366
363
|
}
|
367
364
|
else if (action.insert) {
|
368
365
|
const index = localSlot.index;
|
@@ -523,6 +520,8 @@ exports.Collaborate = class Collaborate {
|
|
523
520
|
return;
|
524
521
|
}
|
525
522
|
const content = subDocument.getText('content');
|
523
|
+
const state = subDocument.getMap('state');
|
524
|
+
this.syncLocalMapToSharedMap(localSlot.state, state);
|
526
525
|
this.initSharedSlotByLocalSlot(content, localSlot);
|
527
526
|
this.syncSlot(content, localSlot);
|
528
527
|
this.addSubModelEvent.next({
|
@@ -537,6 +536,9 @@ exports.Collaborate = class Collaborate {
|
|
537
536
|
});
|
538
537
|
return sharedSlot;
|
539
538
|
}
|
539
|
+
const sharedSlotState = new yjs.Map();
|
540
|
+
this.syncLocalMapToSharedMap(localSlot.state, sharedSlotState);
|
541
|
+
sharedSlot.setAttribute('state', sharedSlotState);
|
540
542
|
const sharedContent = new yjs.Text();
|
541
543
|
this.initSharedSlotByLocalSlot(sharedContent, localSlot);
|
542
544
|
sharedSlot.insertEmbed(0, sharedContent);
|
@@ -574,11 +576,13 @@ exports.Collaborate = class Collaborate {
|
|
574
576
|
const schema = sharedSlot.getAttribute('schema');
|
575
577
|
if (type === 'async') {
|
576
578
|
const metadata = sharedSlot.getAttribute('metadata');
|
577
|
-
const slot = new core.AsyncSlot(schema || [], {});
|
579
|
+
const slot = new core.AsyncSlot(schema || [], {}, {});
|
578
580
|
this.syncSharedMapToLocalMap(metadata, slot.metadata);
|
579
581
|
const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
|
580
582
|
if (loadedSubDocument) {
|
581
583
|
const subContent = loadedSubDocument.getText('content');
|
584
|
+
const data = loadedSubDocument.getMap('state');
|
585
|
+
this.syncSharedMapToLocalMap(data, slot.state);
|
582
586
|
this.syncRootSlot(loadedSubDocument, subContent, slot);
|
583
587
|
this.addSubModelEvent.next({
|
584
588
|
yDoc: loadedSubDocument,
|
@@ -594,13 +598,15 @@ exports.Collaborate = class Collaborate {
|
|
594
598
|
if (isDestroyed) {
|
595
599
|
return;
|
596
600
|
}
|
597
|
-
slot.loader.markAsLoaded();
|
598
601
|
const subContent = subDocument.getText('content');
|
602
|
+
const state = subDocument.getMap('state');
|
603
|
+
this.syncSharedMapToLocalMap(state, slot.state);
|
599
604
|
this.syncRootSlot(subDocument, subContent, slot);
|
600
605
|
this.addSubModelEvent.next({
|
601
606
|
yDoc: subDocument,
|
602
607
|
yType: subContent
|
603
608
|
});
|
609
|
+
slot.loader.markAsLoaded();
|
604
610
|
});
|
605
611
|
slot.__changeMarker__.addDetachCallback(() => {
|
606
612
|
isDestroyed = true;
|
@@ -612,7 +618,9 @@ exports.Collaborate = class Collaborate {
|
|
612
618
|
if (!(content instanceof yjs.Text)) {
|
613
619
|
throw collaborateErrorFn('shared slot content type is not `YText`.');
|
614
620
|
}
|
615
|
-
const localSlot = new core.Slot(schema || []);
|
621
|
+
const localSlot = new core.Slot(schema || [], {});
|
622
|
+
const sharedSlotState = sharedSlot.getAttribute('state');
|
623
|
+
this.syncSharedMapToLocalMap(sharedSlotState, localSlot.state);
|
616
624
|
this.initLocalSlotBySharedSlot(content, localSlot);
|
617
625
|
this.syncSlot(content, localSlot);
|
618
626
|
return localSlot;
|
@@ -728,13 +736,13 @@ exports.Collaborate = class Collaborate {
|
|
728
736
|
if (isDestroyed) {
|
729
737
|
return;
|
730
738
|
}
|
731
|
-
instance.loader.markAsLoaded();
|
732
739
|
const state = subDocument.getMap('state');
|
733
740
|
this.syncComponent(subDocument, state, instance);
|
734
741
|
this.addSubModelEvent.next({
|
735
742
|
yType: state,
|
736
743
|
yDoc: subDocument
|
737
744
|
});
|
745
|
+
instance.loader.markAsLoaded();
|
738
746
|
});
|
739
747
|
state.__changeMarker__.addDetachCallback(() => {
|
740
748
|
isDestroyed = true;
|
@@ -948,7 +956,7 @@ exports.CollabHistory = class CollabHistory {
|
|
948
956
|
var _a;
|
949
957
|
return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
|
950
958
|
}
|
951
|
-
constructor(rootComponentRef, collaborate, scheduler,
|
959
|
+
constructor(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
|
952
960
|
Object.defineProperty(this, "rootComponentRef", {
|
953
961
|
enumerable: true,
|
954
962
|
configurable: true,
|
@@ -967,12 +975,6 @@ exports.CollabHistory = class CollabHistory {
|
|
967
975
|
writable: true,
|
968
976
|
value: scheduler
|
969
977
|
});
|
970
|
-
Object.defineProperty(this, "selection", {
|
971
|
-
enumerable: true,
|
972
|
-
configurable: true,
|
973
|
-
writable: true,
|
974
|
-
value: selection
|
975
|
-
});
|
976
978
|
Object.defineProperty(this, "stackSize", {
|
977
979
|
enumerable: true,
|
978
980
|
configurable: true,
|
@@ -1159,12 +1161,11 @@ exports.CollabHistory = class CollabHistory {
|
|
1159
1161
|
};
|
1160
1162
|
exports.CollabHistory = __decorate([
|
1161
1163
|
core$1.Injectable(),
|
1162
|
-
__param(
|
1163
|
-
__param(
|
1164
|
+
__param(3, core$1.Inject(core.HISTORY_STACK_SIZE)),
|
1165
|
+
__param(4, core$1.Optional()),
|
1164
1166
|
__metadata("design:paramtypes", [core.RootComponentRef,
|
1165
1167
|
exports.Collaborate,
|
1166
|
-
core.Scheduler,
|
1167
|
-
core.Selection, Number, CustomUndoManagerConfig])
|
1168
|
+
core.Scheduler, Number, CustomUndoManagerConfig])
|
1168
1169
|
], exports.CollabHistory);
|
1169
1170
|
|
1170
1171
|
/**
|
@@ -1646,10 +1647,17 @@ class CollaborateModule {
|
|
1646
1647
|
}
|
1647
1648
|
]
|
1648
1649
|
});
|
1650
|
+
Object.defineProperty(this, "timer", {
|
1651
|
+
enumerable: true,
|
1652
|
+
configurable: true,
|
1653
|
+
writable: true,
|
1654
|
+
value: null
|
1655
|
+
});
|
1649
1656
|
}
|
1650
1657
|
setup(textbus) {
|
1651
1658
|
const messageBus = textbus.get(MessageBus, null);
|
1652
1659
|
const connector = textbus.get(SyncConnector);
|
1660
|
+
const collab = textbus.get(exports.Collaborate);
|
1653
1661
|
if (messageBus) {
|
1654
1662
|
const selection = textbus.get(core.Selection);
|
1655
1663
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1661,13 +1669,33 @@ class CollaborateModule {
|
|
1661
1669
|
messageBus.consume(states, textbus);
|
1662
1670
|
}));
|
1663
1671
|
}
|
1664
|
-
return connector.onLoad.toPromise()
|
1672
|
+
return connector.onLoad.toPromise().then(() => {
|
1673
|
+
if (!this.config.onlyLoad) {
|
1674
|
+
return;
|
1675
|
+
}
|
1676
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1677
|
+
if (root.has('state')) {
|
1678
|
+
return;
|
1679
|
+
}
|
1680
|
+
return new Promise(resolve => {
|
1681
|
+
const testing = () => {
|
1682
|
+
if (root.has('state')) {
|
1683
|
+
resolve();
|
1684
|
+
}
|
1685
|
+
else {
|
1686
|
+
this.timer = setTimeout(testing, 1000);
|
1687
|
+
}
|
1688
|
+
};
|
1689
|
+
this.timer = setTimeout(testing, 1000);
|
1690
|
+
});
|
1691
|
+
});
|
1665
1692
|
}
|
1666
1693
|
onDestroy(textbus) {
|
1667
1694
|
this.subscription.unsubscribe();
|
1668
1695
|
textbus.get(exports.Collaborate).destroy();
|
1669
1696
|
textbus.get(core.History).destroy();
|
1670
1697
|
textbus.get(SyncConnector).onDestroy();
|
1698
|
+
clearTimeout(this.timer);
|
1671
1699
|
}
|
1672
1700
|
}
|
1673
1701
|
|
@@ -1709,10 +1737,17 @@ class MultipleDocumentCollaborateModule {
|
|
1709
1737
|
}
|
1710
1738
|
]
|
1711
1739
|
});
|
1740
|
+
Object.defineProperty(this, "timer", {
|
1741
|
+
enumerable: true,
|
1742
|
+
configurable: true,
|
1743
|
+
writable: true,
|
1744
|
+
value: null
|
1745
|
+
});
|
1712
1746
|
}
|
1713
1747
|
setup(textbus) {
|
1714
1748
|
const messageBus = textbus.get(MessageBus, null);
|
1715
1749
|
const connector = textbus.get(SyncConnector);
|
1750
|
+
const collab = textbus.get(exports.Collaborate);
|
1716
1751
|
if (messageBus) {
|
1717
1752
|
const selection = textbus.get(core.Selection);
|
1718
1753
|
connector.setLocalStateField('message', messageBus.get(textbus));
|
@@ -1724,13 +1759,33 @@ class MultipleDocumentCollaborateModule {
|
|
1724
1759
|
messageBus.consume(states, textbus);
|
1725
1760
|
}));
|
1726
1761
|
}
|
1727
|
-
return connector.onLoad.toPromise()
|
1762
|
+
return connector.onLoad.toPromise().then(() => {
|
1763
|
+
if (!this.config.onlyLoad) {
|
1764
|
+
return;
|
1765
|
+
}
|
1766
|
+
const root = collab.yDoc.getMap('RootComponent');
|
1767
|
+
if (root.has('state')) {
|
1768
|
+
return;
|
1769
|
+
}
|
1770
|
+
return new Promise(resolve => {
|
1771
|
+
const testing = () => {
|
1772
|
+
if (root.has('state')) {
|
1773
|
+
resolve();
|
1774
|
+
}
|
1775
|
+
else {
|
1776
|
+
this.timer = setTimeout(testing, 1000);
|
1777
|
+
}
|
1778
|
+
};
|
1779
|
+
this.timer = setTimeout(testing, 1000);
|
1780
|
+
});
|
1781
|
+
});
|
1728
1782
|
}
|
1729
1783
|
onDestroy(textbus) {
|
1730
1784
|
this.subscription.unsubscribe();
|
1731
1785
|
textbus.get(exports.Collaborate).destroy();
|
1732
1786
|
textbus.get(core.History).destroy();
|
1733
1787
|
textbus.get(SyncConnector).onDestroy();
|
1788
|
+
clearTimeout(this.timer);
|
1734
1789
|
}
|
1735
1790
|
}
|
1736
1791
|
|
@@ -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.10",
|
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.10",
|
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": "438501b25fd5388d8e55c1a693f25bf282a90a86"
|
54
54
|
}
|