@textbus/collaborate 3.0.0-alpha.31 → 3.0.0-alpha.33
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.
- package/bundles/collaborate.d.ts +3 -3
- package/bundles/index.esm.js +16 -16
- package/bundles/index.js +15 -15
- package/package.json +3 -3
package/bundles/collaborate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable, Subject, Subscription } from '@tanbo/stream';
|
|
2
|
-
import { AbstractSelection, ComponentInstance, Controller,
|
|
2
|
+
import { AbstractSelection, ComponentInstance, Controller, Registry, History, RootComponentRef, Scheduler, Selection, SelectionPaths, Slot, Starter } from '@textbus/core';
|
|
3
3
|
import { Array as YArray, Doc as YDoc, Map as YMap, RelativePosition, Text as YText, Transaction, UndoManager } from 'yjs';
|
|
4
4
|
interface CursorPosition {
|
|
5
5
|
anchor: RelativePosition;
|
|
@@ -23,7 +23,7 @@ export declare class Collaborate implements History {
|
|
|
23
23
|
protected rootComponentRef: RootComponentRef;
|
|
24
24
|
protected controller: Controller;
|
|
25
25
|
protected scheduler: Scheduler;
|
|
26
|
-
protected
|
|
26
|
+
protected registry: Registry;
|
|
27
27
|
protected selection: Selection;
|
|
28
28
|
protected starter: Starter;
|
|
29
29
|
onLocalChangesApplied: Observable<void>;
|
|
@@ -52,7 +52,7 @@ export declare class Collaborate implements History {
|
|
|
52
52
|
protected noRecord: {};
|
|
53
53
|
protected historyItems: Array<CursorPosition | null>;
|
|
54
54
|
protected index: number;
|
|
55
|
-
constructor(stackSize: number, rootComponentRef: RootComponentRef, controller: Controller, scheduler: Scheduler,
|
|
55
|
+
constructor(stackSize: number, rootComponentRef: RootComponentRef, controller: Controller, scheduler: Scheduler, registry: Registry, selection: Selection, starter: Starter);
|
|
56
56
|
listen(): void;
|
|
57
57
|
back(): void;
|
|
58
58
|
forward(): void;
|
package/bundles/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeError, HISTORY_STACK_SIZE, ChangeOrigin, Slot, RootComponentRef, Controller, Scheduler,
|
|
1
|
+
import { makeError, HISTORY_STACK_SIZE, ChangeOrigin, Slot, RootComponentRef, Controller, Scheduler, Registry, Selection, Starter, History } from '@textbus/core';
|
|
2
2
|
import { Injectable, Inject } from '@tanbo/di';
|
|
3
3
|
import { Subject, map, filter } from '@tanbo/stream';
|
|
4
4
|
import { Doc, UndoManager, Array, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Text } from 'yjs';
|
|
@@ -73,12 +73,12 @@ class ContentMap {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
let Collaborate = class Collaborate {
|
|
76
|
-
constructor(stackSize, rootComponentRef, controller, scheduler,
|
|
76
|
+
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter) {
|
|
77
77
|
this.stackSize = stackSize;
|
|
78
78
|
this.rootComponentRef = rootComponentRef;
|
|
79
79
|
this.controller = controller;
|
|
80
80
|
this.scheduler = scheduler;
|
|
81
|
-
this.
|
|
81
|
+
this.registry = registry;
|
|
82
82
|
this.selection = selection;
|
|
83
83
|
this.starter = starter;
|
|
84
84
|
this.yDoc = new Doc();
|
|
@@ -314,13 +314,13 @@ let Collaborate = class Collaborate {
|
|
|
314
314
|
}
|
|
315
315
|
const updateType = change.action;
|
|
316
316
|
if (updateType === 'update' || updateType === 'add') {
|
|
317
|
-
const attribute = this.
|
|
317
|
+
const attribute = this.registry.getAttribute(key);
|
|
318
318
|
if (attribute) {
|
|
319
319
|
slot.setAttribute(attribute, content.getAttribute(key));
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
else if (updateType === 'delete') {
|
|
323
|
-
const attribute = this.
|
|
323
|
+
const attribute = this.registry.getAttribute(key);
|
|
324
324
|
if (attribute) {
|
|
325
325
|
slot.removeAttribute(attribute);
|
|
326
326
|
}
|
|
@@ -329,7 +329,7 @@ let Collaborate = class Collaborate {
|
|
|
329
329
|
ev.delta.forEach(action => {
|
|
330
330
|
if (Reflect.has(action, 'retain')) {
|
|
331
331
|
if (action.attributes) {
|
|
332
|
-
const formats = remoteFormatsToLocal(this.
|
|
332
|
+
const formats = remoteFormatsToLocal(this.registry, action.attributes);
|
|
333
333
|
if (formats.length) {
|
|
334
334
|
slot.retain(action.retain, formats);
|
|
335
335
|
}
|
|
@@ -344,7 +344,7 @@ let Collaborate = class Collaborate {
|
|
|
344
344
|
let length = 1;
|
|
345
345
|
if (typeof action.insert === 'string') {
|
|
346
346
|
length = action.insert.length;
|
|
347
|
-
slot.insert(action.insert, remoteFormatsToLocal(this.
|
|
347
|
+
slot.insert(action.insert, remoteFormatsToLocal(this.registry, action.attributes));
|
|
348
348
|
}
|
|
349
349
|
else {
|
|
350
350
|
const sharedComponent = action.insert;
|
|
@@ -391,7 +391,7 @@ let Collaborate = class Collaborate {
|
|
|
391
391
|
const keys = Object.keys(formats);
|
|
392
392
|
let length = keys.length;
|
|
393
393
|
keys.forEach(key => {
|
|
394
|
-
const formatter = this.
|
|
394
|
+
const formatter = this.registry.getFormatter(key);
|
|
395
395
|
if (!formatter) {
|
|
396
396
|
length--;
|
|
397
397
|
Reflect.deleteProperty(formats, key);
|
|
@@ -643,7 +643,7 @@ let Collaborate = class Collaborate {
|
|
|
643
643
|
});
|
|
644
644
|
const name = yMap.get('name');
|
|
645
645
|
const state = yMap.get('state');
|
|
646
|
-
const instance = this.
|
|
646
|
+
const instance = this.registry.createComponentByData(name, {
|
|
647
647
|
state,
|
|
648
648
|
slots
|
|
649
649
|
});
|
|
@@ -664,7 +664,7 @@ let Collaborate = class Collaborate {
|
|
|
664
664
|
createSlotBySharedSlot(sharedSlot) {
|
|
665
665
|
const content = sharedSlot.get('content');
|
|
666
666
|
const delta = content.toDelta();
|
|
667
|
-
const slot = this.
|
|
667
|
+
const slot = this.registry.createSlot({
|
|
668
668
|
schema: sharedSlot.get('schema'),
|
|
669
669
|
state: sharedSlot.get('state'),
|
|
670
670
|
attributes: {},
|
|
@@ -673,7 +673,7 @@ let Collaborate = class Collaborate {
|
|
|
673
673
|
});
|
|
674
674
|
const attrs = content.getAttributes();
|
|
675
675
|
Object.keys(attrs).forEach(key => {
|
|
676
|
-
const attribute = this.
|
|
676
|
+
const attribute = this.registry.getAttribute(key);
|
|
677
677
|
if (attribute) {
|
|
678
678
|
slot.setAttribute(attribute, attrs[key]);
|
|
679
679
|
}
|
|
@@ -681,13 +681,13 @@ let Collaborate = class Collaborate {
|
|
|
681
681
|
for (const action of delta) {
|
|
682
682
|
if (action.insert) {
|
|
683
683
|
if (typeof action.insert === 'string') {
|
|
684
|
-
const formats = remoteFormatsToLocal(this.
|
|
684
|
+
const formats = remoteFormatsToLocal(this.registry, action.attributes);
|
|
685
685
|
slot.insert(action.insert, formats);
|
|
686
686
|
}
|
|
687
687
|
else {
|
|
688
688
|
const sharedComponent = action.insert;
|
|
689
689
|
const component = this.createComponentBySharedComponent(sharedComponent);
|
|
690
|
-
slot.insert(component, remoteFormatsToLocal(this.
|
|
690
|
+
slot.insert(component, remoteFormatsToLocal(this.registry, action.attributes));
|
|
691
691
|
this.syncComponentSlots(sharedComponent.get('slots'), component);
|
|
692
692
|
this.syncComponentState(sharedComponent, component);
|
|
693
693
|
}
|
|
@@ -728,15 +728,15 @@ Collaborate = __decorate([
|
|
|
728
728
|
__metadata("design:paramtypes", [Number, RootComponentRef,
|
|
729
729
|
Controller,
|
|
730
730
|
Scheduler,
|
|
731
|
-
|
|
731
|
+
Registry,
|
|
732
732
|
Selection,
|
|
733
733
|
Starter])
|
|
734
734
|
], Collaborate);
|
|
735
|
-
function remoteFormatsToLocal(
|
|
735
|
+
function remoteFormatsToLocal(registry, attrs) {
|
|
736
736
|
const formats = [];
|
|
737
737
|
if (attrs) {
|
|
738
738
|
Object.keys(attrs).forEach(key => {
|
|
739
|
-
const formatter =
|
|
739
|
+
const formatter = registry.getFormatter(key);
|
|
740
740
|
if (formatter) {
|
|
741
741
|
formats.push([formatter, attrs[key]]);
|
|
742
742
|
}
|
package/bundles/index.js
CHANGED
|
@@ -75,12 +75,12 @@ class ContentMap {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
exports.Collaborate = class Collaborate {
|
|
78
|
-
constructor(stackSize, rootComponentRef, controller, scheduler,
|
|
78
|
+
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter) {
|
|
79
79
|
this.stackSize = stackSize;
|
|
80
80
|
this.rootComponentRef = rootComponentRef;
|
|
81
81
|
this.controller = controller;
|
|
82
82
|
this.scheduler = scheduler;
|
|
83
|
-
this.
|
|
83
|
+
this.registry = registry;
|
|
84
84
|
this.selection = selection;
|
|
85
85
|
this.starter = starter;
|
|
86
86
|
this.yDoc = new yjs.Doc();
|
|
@@ -316,13 +316,13 @@ exports.Collaborate = class Collaborate {
|
|
|
316
316
|
}
|
|
317
317
|
const updateType = change.action;
|
|
318
318
|
if (updateType === 'update' || updateType === 'add') {
|
|
319
|
-
const attribute = this.
|
|
319
|
+
const attribute = this.registry.getAttribute(key);
|
|
320
320
|
if (attribute) {
|
|
321
321
|
slot.setAttribute(attribute, content.getAttribute(key));
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
else if (updateType === 'delete') {
|
|
325
|
-
const attribute = this.
|
|
325
|
+
const attribute = this.registry.getAttribute(key);
|
|
326
326
|
if (attribute) {
|
|
327
327
|
slot.removeAttribute(attribute);
|
|
328
328
|
}
|
|
@@ -331,7 +331,7 @@ exports.Collaborate = class Collaborate {
|
|
|
331
331
|
ev.delta.forEach(action => {
|
|
332
332
|
if (Reflect.has(action, 'retain')) {
|
|
333
333
|
if (action.attributes) {
|
|
334
|
-
const formats = remoteFormatsToLocal(this.
|
|
334
|
+
const formats = remoteFormatsToLocal(this.registry, action.attributes);
|
|
335
335
|
if (formats.length) {
|
|
336
336
|
slot.retain(action.retain, formats);
|
|
337
337
|
}
|
|
@@ -346,7 +346,7 @@ exports.Collaborate = class Collaborate {
|
|
|
346
346
|
let length = 1;
|
|
347
347
|
if (typeof action.insert === 'string') {
|
|
348
348
|
length = action.insert.length;
|
|
349
|
-
slot.insert(action.insert, remoteFormatsToLocal(this.
|
|
349
|
+
slot.insert(action.insert, remoteFormatsToLocal(this.registry, action.attributes));
|
|
350
350
|
}
|
|
351
351
|
else {
|
|
352
352
|
const sharedComponent = action.insert;
|
|
@@ -393,7 +393,7 @@ exports.Collaborate = class Collaborate {
|
|
|
393
393
|
const keys = Object.keys(formats);
|
|
394
394
|
let length = keys.length;
|
|
395
395
|
keys.forEach(key => {
|
|
396
|
-
const formatter = this.
|
|
396
|
+
const formatter = this.registry.getFormatter(key);
|
|
397
397
|
if (!formatter) {
|
|
398
398
|
length--;
|
|
399
399
|
Reflect.deleteProperty(formats, key);
|
|
@@ -645,7 +645,7 @@ exports.Collaborate = class Collaborate {
|
|
|
645
645
|
});
|
|
646
646
|
const name = yMap.get('name');
|
|
647
647
|
const state = yMap.get('state');
|
|
648
|
-
const instance = this.
|
|
648
|
+
const instance = this.registry.createComponentByData(name, {
|
|
649
649
|
state,
|
|
650
650
|
slots
|
|
651
651
|
});
|
|
@@ -666,7 +666,7 @@ exports.Collaborate = class Collaborate {
|
|
|
666
666
|
createSlotBySharedSlot(sharedSlot) {
|
|
667
667
|
const content = sharedSlot.get('content');
|
|
668
668
|
const delta = content.toDelta();
|
|
669
|
-
const slot = this.
|
|
669
|
+
const slot = this.registry.createSlot({
|
|
670
670
|
schema: sharedSlot.get('schema'),
|
|
671
671
|
state: sharedSlot.get('state'),
|
|
672
672
|
attributes: {},
|
|
@@ -675,7 +675,7 @@ exports.Collaborate = class Collaborate {
|
|
|
675
675
|
});
|
|
676
676
|
const attrs = content.getAttributes();
|
|
677
677
|
Object.keys(attrs).forEach(key => {
|
|
678
|
-
const attribute = this.
|
|
678
|
+
const attribute = this.registry.getAttribute(key);
|
|
679
679
|
if (attribute) {
|
|
680
680
|
slot.setAttribute(attribute, attrs[key]);
|
|
681
681
|
}
|
|
@@ -683,13 +683,13 @@ exports.Collaborate = class Collaborate {
|
|
|
683
683
|
for (const action of delta) {
|
|
684
684
|
if (action.insert) {
|
|
685
685
|
if (typeof action.insert === 'string') {
|
|
686
|
-
const formats = remoteFormatsToLocal(this.
|
|
686
|
+
const formats = remoteFormatsToLocal(this.registry, action.attributes);
|
|
687
687
|
slot.insert(action.insert, formats);
|
|
688
688
|
}
|
|
689
689
|
else {
|
|
690
690
|
const sharedComponent = action.insert;
|
|
691
691
|
const component = this.createComponentBySharedComponent(sharedComponent);
|
|
692
|
-
slot.insert(component, remoteFormatsToLocal(this.
|
|
692
|
+
slot.insert(component, remoteFormatsToLocal(this.registry, action.attributes));
|
|
693
693
|
this.syncComponentSlots(sharedComponent.get('slots'), component);
|
|
694
694
|
this.syncComponentState(sharedComponent, component);
|
|
695
695
|
}
|
|
@@ -730,15 +730,15 @@ exports.Collaborate = __decorate([
|
|
|
730
730
|
__metadata("design:paramtypes", [Number, core.RootComponentRef,
|
|
731
731
|
core.Controller,
|
|
732
732
|
core.Scheduler,
|
|
733
|
-
core.
|
|
733
|
+
core.Registry,
|
|
734
734
|
core.Selection,
|
|
735
735
|
core.Starter])
|
|
736
736
|
], exports.Collaborate);
|
|
737
|
-
function remoteFormatsToLocal(
|
|
737
|
+
function remoteFormatsToLocal(registry, attrs) {
|
|
738
738
|
const formats = [];
|
|
739
739
|
if (attrs) {
|
|
740
740
|
Object.keys(attrs).forEach(key => {
|
|
741
|
-
const formatter =
|
|
741
|
+
const formatter = registry.getFormatter(key);
|
|
742
742
|
if (formatter) {
|
|
743
743
|
formats.push([formatter, attrs[key]]);
|
|
744
744
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/collaborate",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.33",
|
|
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
|
"@tanbo/di": "^1.1.4",
|
|
29
29
|
"@tanbo/stream": "^1.1.8",
|
|
30
|
-
"@textbus/core": "^3.0.0-alpha.
|
|
30
|
+
"@textbus/core": "^3.0.0-alpha.33",
|
|
31
31
|
"reflect-metadata": "^0.1.13",
|
|
32
32
|
"y-protocols": "^1.0.5",
|
|
33
33
|
"yjs": "^13.5.39"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"bugs": {
|
|
51
51
|
"url": "https://github.com/textbus/textbus.git/issues"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7888d3b0a0977343c4f8483bb5792cb24a32939a"
|
|
54
54
|
}
|