@textbus/collaborate 5.0.0-alpha.4 → 5.0.0-alpha.5

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.
@@ -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,8 +518,8 @@ let Collaborate = class Collaborate {
521
518
  return;
522
519
  }
523
520
  const content = subDocument.getText('content');
524
- const data = subDocument.getMap('data');
525
- this.syncLocalMapToSharedMap(localSlot.data, data);
521
+ const state = subDocument.getMap('state');
522
+ this.syncLocalMapToSharedMap(localSlot.state, state);
526
523
  this.initSharedSlotByLocalSlot(content, localSlot);
527
524
  this.syncSlot(content, localSlot);
528
525
  this.addSubModelEvent.next({
@@ -537,6 +534,9 @@ let Collaborate = class Collaborate {
537
534
  });
538
535
  return sharedSlot;
539
536
  }
537
+ const sharedSlotState = new Map();
538
+ this.syncLocalMapToSharedMap(localSlot.state, sharedSlotState);
539
+ sharedSlot.setAttribute('state', sharedSlotState);
540
540
  const sharedContent = new Text();
541
541
  this.initSharedSlotByLocalSlot(sharedContent, localSlot);
542
542
  sharedSlot.insertEmbed(0, sharedContent);
@@ -579,8 +579,8 @@ let Collaborate = class Collaborate {
579
579
  const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
580
580
  if (loadedSubDocument) {
581
581
  const subContent = loadedSubDocument.getText('content');
582
- const data = loadedSubDocument.getMap('data');
583
- this.syncSharedMapToLocalMap(data, slot.data);
582
+ const data = loadedSubDocument.getMap('state');
583
+ this.syncSharedMapToLocalMap(data, slot.state);
584
584
  this.syncRootSlot(loadedSubDocument, subContent, slot);
585
585
  this.addSubModelEvent.next({
586
586
  yDoc: loadedSubDocument,
@@ -598,8 +598,8 @@ let Collaborate = class Collaborate {
598
598
  }
599
599
  slot.loader.markAsLoaded();
600
600
  const subContent = subDocument.getText('content');
601
- const data = subDocument.getMap('data');
602
- this.syncSharedMapToLocalMap(data, slot.data);
601
+ const state = subDocument.getMap('state');
602
+ this.syncSharedMapToLocalMap(state, slot.state);
603
603
  this.syncRootSlot(subDocument, subContent, slot);
604
604
  this.addSubModelEvent.next({
605
605
  yDoc: subDocument,
@@ -616,7 +616,9 @@ let Collaborate = class Collaborate {
616
616
  if (!(content instanceof Text)) {
617
617
  throw collaborateErrorFn('shared slot content type is not `YText`.');
618
618
  }
619
- const localSlot = new Slot(schema || []);
619
+ const localSlot = new Slot(schema || [], {});
620
+ const sharedSlotState = sharedSlot.getAttribute('state');
621
+ this.syncSharedMapToLocalMap(sharedSlotState, localSlot.state);
620
622
  this.initLocalSlotBySharedSlot(content, localSlot);
621
623
  this.syncSlot(content, localSlot);
622
624
  return localSlot;
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,8 +520,8 @@ exports.Collaborate = class Collaborate {
523
520
  return;
524
521
  }
525
522
  const content = subDocument.getText('content');
526
- const data = subDocument.getMap('data');
527
- this.syncLocalMapToSharedMap(localSlot.data, data);
523
+ const state = subDocument.getMap('state');
524
+ this.syncLocalMapToSharedMap(localSlot.state, state);
528
525
  this.initSharedSlotByLocalSlot(content, localSlot);
529
526
  this.syncSlot(content, localSlot);
530
527
  this.addSubModelEvent.next({
@@ -539,6 +536,9 @@ exports.Collaborate = class Collaborate {
539
536
  });
540
537
  return sharedSlot;
541
538
  }
539
+ const sharedSlotState = new yjs.Map();
540
+ this.syncLocalMapToSharedMap(localSlot.state, sharedSlotState);
541
+ sharedSlot.setAttribute('state', sharedSlotState);
542
542
  const sharedContent = new yjs.Text();
543
543
  this.initSharedSlotByLocalSlot(sharedContent, localSlot);
544
544
  sharedSlot.insertEmbed(0, sharedContent);
@@ -581,8 +581,8 @@ exports.Collaborate = class Collaborate {
581
581
  const loadedSubDocument = this.subModelLoader.getLoadedModelBySlot(slot);
582
582
  if (loadedSubDocument) {
583
583
  const subContent = loadedSubDocument.getText('content');
584
- const data = loadedSubDocument.getMap('data');
585
- this.syncSharedMapToLocalMap(data, slot.data);
584
+ const data = loadedSubDocument.getMap('state');
585
+ this.syncSharedMapToLocalMap(data, slot.state);
586
586
  this.syncRootSlot(loadedSubDocument, subContent, slot);
587
587
  this.addSubModelEvent.next({
588
588
  yDoc: loadedSubDocument,
@@ -600,8 +600,8 @@ exports.Collaborate = class Collaborate {
600
600
  }
601
601
  slot.loader.markAsLoaded();
602
602
  const subContent = subDocument.getText('content');
603
- const data = subDocument.getMap('data');
604
- this.syncSharedMapToLocalMap(data, slot.data);
603
+ const state = subDocument.getMap('state');
604
+ this.syncSharedMapToLocalMap(state, slot.state);
605
605
  this.syncRootSlot(subDocument, subContent, slot);
606
606
  this.addSubModelEvent.next({
607
607
  yDoc: subDocument,
@@ -618,7 +618,9 @@ exports.Collaborate = class Collaborate {
618
618
  if (!(content instanceof yjs.Text)) {
619
619
  throw collaborateErrorFn('shared slot content type is not `YText`.');
620
620
  }
621
- 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);
622
624
  this.initLocalSlotBySharedSlot(content, localSlot);
623
625
  this.syncSlot(content, localSlot);
624
626
  return localSlot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.5",
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,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@hocuspocus/provider": "^2.15.2",
29
29
  "@tanbo/stream": "^1.2.7",
30
- "@textbus/core": "^5.0.0-alpha.3",
30
+ "@textbus/core": "^5.0.0-alpha.5",
31
31
  "@viewfly/core": "^2.0.0-alpha.3",
32
32
  "y-websocket": "^2.1.0",
33
33
  "yjs": "^13.6.23"
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "2a056b755365c23f31ca71abac859edd7e065d85"
53
+ "gitHead": "b9fdc57750c1d2ae44beb4aa7f019757effb4c3f"
54
54
  }