@textbus/collaborate 4.2.1 → 4.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -442,7 +442,8 @@ let Collaborate = class Collaborate {
442
442
  sharedSlot.setAttribute('type', isAsyncSlot ? 'async' : 'sync');
443
443
  if (isAsyncSlot) {
444
444
  let isDestroyed = false;
445
- sharedSlot.setAttribute('metadata', localSlot.metadata);
445
+ const sharedMetadata = this.createSharedMapByLocalMap(localSlot.metadata);
446
+ sharedSlot.setAttribute('metadata', sharedMetadata);
446
447
  this.subModelLoader.createSubModelBySlot(localSlot).then(subDocument => {
447
448
  if (isDestroyed) {
448
449
  return;
@@ -499,7 +500,8 @@ let Collaborate = class Collaborate {
499
500
  const schema = sharedSlot.getAttribute('schema');
500
501
  if (type === 'async') {
501
502
  const metadata = sharedSlot.getAttribute('metadata');
502
- const slot = new AsyncSlot(schema || [], metadata);
503
+ const slot = new AsyncSlot(schema || [], {});
504
+ this.syncSharedMapToLocalMap(metadata, slot.metadata);
503
505
  const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
504
506
  if (loadedSubDocument) {
505
507
  const subContent = loadedSubDocument.getText('content');
@@ -596,7 +598,8 @@ let Collaborate = class Collaborate {
596
598
  sharedComponent.set('name', component.name);
597
599
  if (component instanceof AsyncComponent) {
598
600
  sharedComponent.set('type', 'async');
599
- sharedComponent.set('metadata', component.getMetadata());
601
+ const sharedMetadata = this.createSharedMapByLocalMap(component.metadata);
602
+ sharedComponent.set('metadata', sharedMetadata);
600
603
  const state = component.state;
601
604
  let isDestroyed = false;
602
605
  state.__changeMarker__.destroyCallbacks.push(() => {
@@ -627,9 +630,10 @@ let Collaborate = class Collaborate {
627
630
  const type = yMap.get('type');
628
631
  let instance;
629
632
  if (type === 'async') {
630
- instance = this.registry.createComponentByData(componentName, {});
633
+ instance = this.registry.createComponentByData(componentName, {}, {});
631
634
  if (instance instanceof AsyncComponent) {
632
- instance.setMetadata(yMap.get('metadata'));
635
+ const sharedMetadata = yMap.get('metadata');
636
+ this.syncSharedMapToLocalMap(sharedMetadata, instance.metadata);
633
637
  const loadedSubDocument = this.subModelLoader.getLoadedModelByComponent(instance);
634
638
  if (loadedSubDocument) {
635
639
  const state = loadedSubDocument.getMap('state');
package/bundles/index.js CHANGED
@@ -444,7 +444,8 @@ exports.Collaborate = class Collaborate {
444
444
  sharedSlot.setAttribute('type', isAsyncSlot ? 'async' : 'sync');
445
445
  if (isAsyncSlot) {
446
446
  let isDestroyed = false;
447
- sharedSlot.setAttribute('metadata', localSlot.metadata);
447
+ const sharedMetadata = this.createSharedMapByLocalMap(localSlot.metadata);
448
+ sharedSlot.setAttribute('metadata', sharedMetadata);
448
449
  this.subModelLoader.createSubModelBySlot(localSlot).then(subDocument => {
449
450
  if (isDestroyed) {
450
451
  return;
@@ -501,7 +502,8 @@ exports.Collaborate = class Collaborate {
501
502
  const schema = sharedSlot.getAttribute('schema');
502
503
  if (type === 'async') {
503
504
  const metadata = sharedSlot.getAttribute('metadata');
504
- const slot = new core.AsyncSlot(schema || [], metadata);
505
+ const slot = new core.AsyncSlot(schema || [], {});
506
+ this.syncSharedMapToLocalMap(metadata, slot.metadata);
505
507
  const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
506
508
  if (loadedSubDocument) {
507
509
  const subContent = loadedSubDocument.getText('content');
@@ -598,7 +600,8 @@ exports.Collaborate = class Collaborate {
598
600
  sharedComponent.set('name', component.name);
599
601
  if (component instanceof core.AsyncComponent) {
600
602
  sharedComponent.set('type', 'async');
601
- sharedComponent.set('metadata', component.getMetadata());
603
+ const sharedMetadata = this.createSharedMapByLocalMap(component.metadata);
604
+ sharedComponent.set('metadata', sharedMetadata);
602
605
  const state = component.state;
603
606
  let isDestroyed = false;
604
607
  state.__changeMarker__.destroyCallbacks.push(() => {
@@ -629,9 +632,10 @@ exports.Collaborate = class Collaborate {
629
632
  const type = yMap.get('type');
630
633
  let instance;
631
634
  if (type === 'async') {
632
- instance = this.registry.createComponentByData(componentName, {});
635
+ instance = this.registry.createComponentByData(componentName, {}, {});
633
636
  if (instance instanceof core.AsyncComponent) {
634
- instance.setMetadata(yMap.get('metadata'));
637
+ const sharedMetadata = yMap.get('metadata');
638
+ this.syncSharedMapToLocalMap(sharedMetadata, instance.metadata);
635
639
  const loadedSubDocument = this.subModelLoader.getLoadedModelByComponent(instance);
636
640
  if (loadedSubDocument) {
637
641
  const state = loadedSubDocument.getMap('state');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "4.2.1",
3
+ "version": "4.2.4",
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",
@@ -26,9 +26,9 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@hocuspocus/provider": "^2.13.6",
29
- "@tanbo/stream": "^1.2.5",
30
- "@textbus/core": "^4.2.1",
31
- "@viewfly/core": "^1.0.5",
29
+ "@tanbo/stream": "^1.2.6",
30
+ "@textbus/core": "^4.2.4",
31
+ "@viewfly/core": "^1.1.0",
32
32
  "y-websocket": "^1.4.3",
33
33
  "yjs": "^13.6.14"
34
34
  },
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "cf4fd289b73bc777124a32fe42bb58eba05a34f1"
53
+ "gitHead": "d26c6771f08dae6ec4f0b9f1929054ccf1e7bcaf"
54
54
  }