@textbus/collaborate 2.0.0-alpha.36 → 2.0.0-alpha.39
Sign up to get free protection for your applications and to get access to all the features.
- package/bundles/collab/_api.d.ts +3 -0
- package/bundles/collab/_api.js +4 -0
- package/bundles/collab/_api.js.map +1 -0
- package/bundles/collab/collaborate-cursor.d.ts +25 -0
- package/bundles/collab/collaborate-cursor.js +143 -0
- package/bundles/collab/collaborate-cursor.js.map +1 -0
- package/bundles/collab/local-to-remote.d.ts +11 -0
- package/bundles/collab/local-to-remote.js +155 -0
- package/bundles/collab/local-to-remote.js.map +1 -0
- package/bundles/collab/remote-to-local.d.ts +12 -0
- package/bundles/collab/remote-to-local.js +158 -0
- package/bundles/collab/remote-to-local.js.map +1 -0
- package/bundles/collaborate.d.ts +29 -5
- package/bundles/collaborate.js +191 -20
- package/bundles/collaborate.js.map +1 -1
- package/bundles/public-api.d.ts +1 -0
- package/bundles/public-api.js +1 -0
- package/bundles/public-api.js.map +1 -1
- package/package.json +7 -6
- package/src/collab/_api.ts +3 -0
- package/src/collab/collaborate-cursor.ts +107 -0
- package/src/collab/local-to-remote.ts +158 -0
- package/src/collab/remote-to-local.ts +151 -0
- package/src/collaborate.ts +78 -15
- package/src/public-api.ts +1 -0
- package/tsconfig-build.json +2 -0
- package/bundles/local-to-remote.d.ts +0 -3
- package/bundles/local-to-remote.js +0 -173
- package/bundles/local-to-remote.js.map +0 -1
- package/bundles/remote-to-local.d.ts +0 -3
- package/bundles/remote-to-local.js +0 -143
- package/bundles/remote-to-local.js.map +0 -1
- package/src/local-to-remote.ts +0 -180
- package/src/remote-to-local.ts +0 -140
@@ -0,0 +1,151 @@
|
|
1
|
+
import { Map as YMap, YArrayEvent, YEvent, YMapEvent, Text as YText, YTextEvent, Array as YArray } from 'yjs'
|
2
|
+
import { ComponentInstance, ComponentLiteral, Registry, Slot, Translator } from '@textbus/core'
|
3
|
+
|
4
|
+
type YPath = [number, string][]
|
5
|
+
|
6
|
+
export class RemoteToLocal {
|
7
|
+
constructor(private translator: Translator,
|
8
|
+
private registry: Registry) {
|
9
|
+
}
|
10
|
+
|
11
|
+
transform(events: YEvent[], slot: Slot) {
|
12
|
+
events.forEach(ev => {
|
13
|
+
const path: YPath = []
|
14
|
+
|
15
|
+
for (let i = 0; i < ev.path.length; i += 2) {
|
16
|
+
path.push(ev.path.slice(i, i + 2) as [number, string])
|
17
|
+
}
|
18
|
+
|
19
|
+
if (path.length) {
|
20
|
+
const componentIndex = path.shift()![0] as number
|
21
|
+
const component = slot.getContentAtIndex(componentIndex) as ComponentInstance
|
22
|
+
this.applySharedComponentToComponent(ev, path, component)
|
23
|
+
return
|
24
|
+
}
|
25
|
+
|
26
|
+
this.applySharedSlotToSlot(ev, path, slot)
|
27
|
+
})
|
28
|
+
}
|
29
|
+
|
30
|
+
private applySharedComponentToComponent(ev: YEvent, path: YPath, component: ComponentInstance) {
|
31
|
+
if (path.length) {
|
32
|
+
const childPath = path.shift()!
|
33
|
+
const slot = component.slots.get(childPath[0])!
|
34
|
+
this.applySharedSlotToSlot(ev, path, slot)
|
35
|
+
return
|
36
|
+
}
|
37
|
+
if (ev instanceof YMapEvent) {
|
38
|
+
ev.keysChanged.forEach(key => {
|
39
|
+
if (key === 'state') {
|
40
|
+
const state = (ev.target as YMap<any>).get('state')
|
41
|
+
component.updateState(draft => {
|
42
|
+
Object.assign(draft, state)
|
43
|
+
})
|
44
|
+
}
|
45
|
+
})
|
46
|
+
} else if (ev instanceof YArrayEvent) {
|
47
|
+
const slots = component.slots
|
48
|
+
ev.delta.forEach(action => {
|
49
|
+
if (Reflect.has(action, 'retain')) {
|
50
|
+
slots.retain(action.retain!)
|
51
|
+
} else if (action.insert) {
|
52
|
+
(action.insert as Array<any>).forEach(item => {
|
53
|
+
slots.insert(this.translator.createSlot(item.toJSON())!)
|
54
|
+
})
|
55
|
+
} else if (action.delete) {
|
56
|
+
slots.retain(slots.index)
|
57
|
+
slots.delete(action.delete)
|
58
|
+
}
|
59
|
+
})
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
private applySharedSlotToSlot(ev: YEvent, path: YPath, slot: Slot) {
|
64
|
+
if (path.length) {
|
65
|
+
path.shift()
|
66
|
+
const delta = (ev.target.parent as YText).toDelta()
|
67
|
+
let componentIndex = 0
|
68
|
+
for (let i = 0; i < delta.length; i++) {
|
69
|
+
const action = delta[i]
|
70
|
+
if (action.insert === ev.target) {
|
71
|
+
break
|
72
|
+
}
|
73
|
+
componentIndex += typeof action.insert === 'string' ? action.insert.length : 1
|
74
|
+
}
|
75
|
+
const component = slot.getContentAtIndex(componentIndex) as ComponentInstance
|
76
|
+
this.applySharedComponentToComponent(ev, path, component)
|
77
|
+
return
|
78
|
+
}
|
79
|
+
|
80
|
+
if (ev instanceof YTextEvent) {
|
81
|
+
slot.retain(0)
|
82
|
+
ev.delta.forEach(action => {
|
83
|
+
if (Reflect.has(action, 'retain')) {
|
84
|
+
if (action.attributes) {
|
85
|
+
slot.retain(action.retain!, Object.keys(action.attributes).map(key => {
|
86
|
+
return [this.registry.getFormatter(key)!, action.attributes![key]]
|
87
|
+
}))
|
88
|
+
}
|
89
|
+
slot.retain(action.retain!)
|
90
|
+
} else if (action.insert) {
|
91
|
+
if (typeof action.insert === 'string') {
|
92
|
+
slot.insert(action.insert, action.attributes ? Object.keys(action.attributes).map(key => {
|
93
|
+
return [this.registry.getFormatter(key)!, action.attributes![key]]
|
94
|
+
}) : [])
|
95
|
+
} else {
|
96
|
+
const component = this.createComponentBySharedComponent(action.insert as YMap<any>)
|
97
|
+
slot.insert(component)
|
98
|
+
}
|
99
|
+
} else if (action.delete) {
|
100
|
+
slot.retain(slot.index)
|
101
|
+
slot.delete(action.delete)
|
102
|
+
} else if (action.attributes) {
|
103
|
+
slot.updateState(draft => {
|
104
|
+
Object.assign(draft, action.attributes)
|
105
|
+
})
|
106
|
+
}
|
107
|
+
})
|
108
|
+
} else {
|
109
|
+
throw new Error('xxx')
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
private createComponentBySharedComponent(yMap: YMap<any>): ComponentInstance {
|
114
|
+
const slots = yMap.get('slots') as YArray<YMap<any>>
|
115
|
+
const componentLiteral: ComponentLiteral = {
|
116
|
+
state: yMap.get('state'),
|
117
|
+
name: yMap.get('name'),
|
118
|
+
slots: slots.map(sharedSlot => {
|
119
|
+
return this.createSlotBySharedSlot(sharedSlot).toJSON()
|
120
|
+
})
|
121
|
+
}
|
122
|
+
return this.translator.createComponent(componentLiteral)!
|
123
|
+
}
|
124
|
+
|
125
|
+
private createSlotBySharedSlot(sharedSlot: YMap<any>): Slot {
|
126
|
+
const content = sharedSlot.get('content') as YText
|
127
|
+
const delta = content.toDelta()
|
128
|
+
|
129
|
+
const slot = this.translator.createSlot({
|
130
|
+
schema: sharedSlot.get('schema'),
|
131
|
+
state: sharedSlot.get('state'),
|
132
|
+
formats: {},
|
133
|
+
content: []
|
134
|
+
})
|
135
|
+
|
136
|
+
for (const action of delta) {
|
137
|
+
if (action.insert) {
|
138
|
+
if (typeof action.insert === 'string') {
|
139
|
+
slot.insert(action.insert, action.attributes ? Object.keys(action.attributes).map(key => {
|
140
|
+
return [this.registry.getFormatter(key)!, action.attributes![key]]
|
141
|
+
}) : [])
|
142
|
+
} else {
|
143
|
+
slot.insert(this.createComponentBySharedComponent(action.insert))
|
144
|
+
}
|
145
|
+
} else {
|
146
|
+
throw new Error('xxx')
|
147
|
+
}
|
148
|
+
}
|
149
|
+
return slot
|
150
|
+
}
|
151
|
+
}
|
package/src/collaborate.ts
CHANGED
@@ -1,54 +1,115 @@
|
|
1
1
|
import { Injectable } from '@tanbo/di'
|
2
|
-
import { debounceTime, filter, Subscription, tap } from '@tanbo/stream'
|
2
|
+
import { debounceTime, filter, Observable, Subject, Subscription, tap } from '@tanbo/stream'
|
3
3
|
import {
|
4
4
|
RootComponentRef,
|
5
5
|
Starter,
|
6
6
|
Operation,
|
7
7
|
Translator,
|
8
|
-
|
8
|
+
Registry,
|
9
|
+
Selection,
|
10
|
+
SelectionPaths,
|
11
|
+
History, Renderer
|
9
12
|
} from '@textbus/core'
|
10
|
-
import { Doc as YDoc } from 'yjs'
|
11
|
-
import {
|
12
|
-
import {
|
13
|
-
|
14
|
-
// const collaborateErrorFn = makeError('Collaborate')
|
13
|
+
import { Doc as YDoc, UndoManager } from 'yjs'
|
14
|
+
import { LocalToRemote } from './collab/local-to-remote'
|
15
|
+
import { RemoteToLocal } from './collab/remote-to-local'
|
16
|
+
import { CollaborateCursor, RemoteSelection } from './collab/_api'
|
15
17
|
|
16
18
|
@Injectable()
|
17
|
-
export class Collaborate {
|
19
|
+
export class Collaborate implements History {
|
20
|
+
onSelectionChange: Observable<SelectionPaths>
|
18
21
|
yDoc = new YDoc()
|
22
|
+
onBack: Observable<void>
|
23
|
+
onForward: Observable<void>
|
24
|
+
onChange: Observable<any>
|
25
|
+
onPush: Observable<void>
|
26
|
+
|
27
|
+
get canBack() {
|
28
|
+
return this.manager?.canUndo()
|
29
|
+
}
|
30
|
+
|
31
|
+
get canForward() {
|
32
|
+
return this.manager?.canRedo()
|
33
|
+
}
|
34
|
+
|
35
|
+
private localToRemote = new LocalToRemote()
|
36
|
+
private remoteToLocal = new RemoteToLocal(this.translator, this.registry)
|
37
|
+
|
38
|
+
private backEvent = new Subject<void>()
|
39
|
+
private forwardEvent = new Subject<void>()
|
40
|
+
private changeEvent = new Subject<void>()
|
41
|
+
private pushEvent = new Subject<void>()
|
42
|
+
|
43
|
+
private manager!: UndoManager
|
19
44
|
|
20
45
|
private subscriptions: Subscription[] = []
|
21
46
|
private updateFromSelf = true
|
22
47
|
|
48
|
+
private selectionChangeEvent = new Subject<SelectionPaths>()
|
49
|
+
|
23
50
|
constructor(private rootComponentRef: RootComponentRef,
|
51
|
+
private collaborateCursor: CollaborateCursor,
|
24
52
|
private translator: Translator,
|
25
|
-
private
|
53
|
+
private renderer: Renderer,
|
54
|
+
private registry: Registry,
|
55
|
+
private selection: Selection,
|
26
56
|
private starter: Starter) {
|
57
|
+
this.onSelectionChange = this.selectionChangeEvent.asObservable()
|
58
|
+
this.onBack = this.backEvent.asObservable()
|
59
|
+
this.onForward = this.forwardEvent.asObservable()
|
60
|
+
this.onChange = this.changeEvent.asObservable()
|
61
|
+
this.onPush = this.pushEvent.asObservable()
|
27
62
|
}
|
28
63
|
|
29
64
|
setup() {
|
30
65
|
this.subscriptions.push(
|
31
66
|
this.starter.onReady.subscribe(() => {
|
32
|
-
this.
|
67
|
+
this.listen2()
|
68
|
+
}),
|
69
|
+
this.selection.onChange.subscribe(() => {
|
70
|
+
const paths = this.selection.getPaths()
|
71
|
+
this.selectionChangeEvent.next(paths)
|
33
72
|
})
|
34
73
|
)
|
35
74
|
}
|
36
75
|
|
76
|
+
updateRemoteSelection(paths: RemoteSelection[]) {
|
77
|
+
this.collaborateCursor.draw(paths)
|
78
|
+
}
|
79
|
+
|
80
|
+
listen() {
|
81
|
+
//
|
82
|
+
}
|
83
|
+
|
84
|
+
back() {
|
85
|
+
if (this.canBack) {
|
86
|
+
this.manager.undo()
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
forward() {
|
91
|
+
if (this.canForward) {
|
92
|
+
this.manager.redo()
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
37
96
|
destroy() {
|
38
97
|
this.subscriptions.forEach(i => i.unsubscribe())
|
39
98
|
}
|
40
99
|
|
41
|
-
private
|
42
|
-
const root = this.yDoc.
|
100
|
+
private listen2() {
|
101
|
+
const root = this.yDoc.getText('content')
|
43
102
|
const slot = this.rootComponentRef.component.slots.get(0)!
|
103
|
+
this.manager = new UndoManager(root)
|
44
104
|
root.observeDeep((events, transaction) => {
|
45
105
|
if (transaction.origin === this.yDoc) {
|
46
106
|
return
|
47
107
|
}
|
48
108
|
this.updateFromSelf = false
|
49
109
|
|
50
|
-
remoteToLocal(events, slot
|
51
|
-
|
110
|
+
this.remoteToLocal.transform(events, slot)
|
111
|
+
this.renderer.render()
|
112
|
+
this.selection.restore()
|
52
113
|
this.updateFromSelf = true
|
53
114
|
})
|
54
115
|
const operations: Operation[] = []
|
@@ -64,10 +125,12 @@ export class Collaborate {
|
|
64
125
|
).subscribe(() => {
|
65
126
|
this.yDoc.transact(() => {
|
66
127
|
operations.forEach(operation => {
|
67
|
-
localToRemote(operation, root)
|
128
|
+
this.localToRemote.transform(operation, root)
|
68
129
|
})
|
69
130
|
operations.length = 0
|
70
131
|
}, this.yDoc)
|
132
|
+
this.renderer.render()
|
133
|
+
this.selection.restore()
|
71
134
|
})
|
72
135
|
)
|
73
136
|
}
|
package/src/public-api.ts
CHANGED
package/tsconfig-build.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"declaration": true,
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"emitDecoratorMetadata": true,
|
5
6
|
"experimentalDecorators": true,
|
6
7
|
"allowSyntheticDefaultImports": true,
|
@@ -10,6 +11,7 @@
|
|
10
11
|
"module": "es2020",
|
11
12
|
"moduleResolution": "node",
|
12
13
|
"sourceMap": true,
|
14
|
+
"inlineSources": true,
|
13
15
|
"noImplicitAny": false,
|
14
16
|
"suppressImplicitAnyIndexErrors": true,
|
15
17
|
"outDir": "bundles/",
|
@@ -1,173 +0,0 @@
|
|
1
|
-
import { Format } from '@textbus/core';
|
2
|
-
import { Array as YArray, Map as YMap } from 'yjs';
|
3
|
-
export function localToRemote(operation, root) {
|
4
|
-
const path = [...operation.path];
|
5
|
-
path.shift();
|
6
|
-
if (path.length) {
|
7
|
-
const componentIndex = path.shift();
|
8
|
-
applyComponentOperationToSharedComponent(path, operation.apply, root.get(componentIndex));
|
9
|
-
return;
|
10
|
-
}
|
11
|
-
insertContent(root, operation.apply);
|
12
|
-
}
|
13
|
-
function applyComponentOperationToSharedComponent(path, actions, componentYMap) {
|
14
|
-
const sharedSlots = componentYMap.get('slots');
|
15
|
-
if (path.length) {
|
16
|
-
const slotIndex = path.shift();
|
17
|
-
const sharedSlot = sharedSlots.get(slotIndex);
|
18
|
-
applySlotOperationToSharedSlot(path, actions, sharedSlot);
|
19
|
-
return;
|
20
|
-
}
|
21
|
-
let index;
|
22
|
-
actions.forEach(action => {
|
23
|
-
switch (action.type) {
|
24
|
-
case 'retain':
|
25
|
-
index = action.index;
|
26
|
-
break;
|
27
|
-
case 'insertSlot':
|
28
|
-
sharedSlots.insert(index, [makeSharedSlotBySlotLiteral(action.slot)]);
|
29
|
-
break;
|
30
|
-
case 'apply':
|
31
|
-
componentYMap.set('state', action.value);
|
32
|
-
break;
|
33
|
-
case 'delete':
|
34
|
-
sharedSlots.delete(index, action.count);
|
35
|
-
break;
|
36
|
-
}
|
37
|
-
});
|
38
|
-
}
|
39
|
-
function applySlotOperationToSharedSlot(path, actions, slotYMap) {
|
40
|
-
if (path.length) {
|
41
|
-
const componentIndex = path.shift();
|
42
|
-
const sharedContent = slotYMap.get('content');
|
43
|
-
const sharedComponent = sharedContent.get(componentIndex);
|
44
|
-
applyComponentOperationToSharedComponent(path, actions, sharedComponent);
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
const content = slotYMap.get('content');
|
48
|
-
let index;
|
49
|
-
let len;
|
50
|
-
actions.forEach(action => {
|
51
|
-
switch (action.type) {
|
52
|
-
case 'retain':
|
53
|
-
if (action.formats) {
|
54
|
-
mergeSharedFormats(index, action.index, action.formats, slotYMap);
|
55
|
-
}
|
56
|
-
index = action.index;
|
57
|
-
break;
|
58
|
-
case 'insert':
|
59
|
-
if (typeof action.content === 'string') {
|
60
|
-
len = action.content.length;
|
61
|
-
content.insert(index, action.content.split(''));
|
62
|
-
}
|
63
|
-
else {
|
64
|
-
len = 1;
|
65
|
-
content.insert(index, [makeSharedComponentByComponentLiteral(action.content)]);
|
66
|
-
}
|
67
|
-
if (action.formats) {
|
68
|
-
insertSharedFormats(index, len, action.formats, slotYMap);
|
69
|
-
}
|
70
|
-
break;
|
71
|
-
case 'delete':
|
72
|
-
if (content.length === 0) {
|
73
|
-
// 当内容为空时,slot 实例内容为 ['\n'],触发删除会导致长度溢出
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
content.delete(index, action.count);
|
77
|
-
break;
|
78
|
-
case 'apply':
|
79
|
-
slotYMap.set('state', action.value);
|
80
|
-
break;
|
81
|
-
}
|
82
|
-
});
|
83
|
-
}
|
84
|
-
function insertSharedFormats(index, distance, formats, sharedSlots) {
|
85
|
-
const sharedFormats = sharedSlots.get('formats');
|
86
|
-
const keys = Array.from(sharedFormats.keys());
|
87
|
-
const expandedValues = Array.from({ length: distance });
|
88
|
-
keys.forEach(key => {
|
89
|
-
const formatRanges = sharedFormats.get(key);
|
90
|
-
const values = Format.tileRanges(formatRanges);
|
91
|
-
values.splice(index, 0, ...expandedValues);
|
92
|
-
const newRanges = Format.toRanges(values);
|
93
|
-
sharedFormats.set(key, newRanges);
|
94
|
-
});
|
95
|
-
mergeSharedFormats(index, index + distance, formats, sharedSlots);
|
96
|
-
}
|
97
|
-
function mergeSharedFormats(startIndex, endIndex, formats, sharedSlots) {
|
98
|
-
const sharedFormats = sharedSlots.get('formats');
|
99
|
-
Object.keys(formats).forEach(key => {
|
100
|
-
if (!sharedFormats.has(key)) {
|
101
|
-
sharedFormats.set(key, [{
|
102
|
-
startIndex,
|
103
|
-
endIndex,
|
104
|
-
value: formats[key]
|
105
|
-
}]);
|
106
|
-
}
|
107
|
-
const oldFormatRanges = sharedFormats.get(key);
|
108
|
-
const formatRanges = Format.normalizeFormatRange(oldFormatRanges, {
|
109
|
-
startIndex,
|
110
|
-
endIndex,
|
111
|
-
value: formats[key]
|
112
|
-
});
|
113
|
-
sharedFormats.set(key, formatRanges);
|
114
|
-
});
|
115
|
-
}
|
116
|
-
function insertContent(content, actions) {
|
117
|
-
let index;
|
118
|
-
actions.forEach(action => {
|
119
|
-
switch (action.type) {
|
120
|
-
case 'retain':
|
121
|
-
index = action.index;
|
122
|
-
break;
|
123
|
-
case 'insert':
|
124
|
-
content.insert(index, [
|
125
|
-
typeof action.content === 'string' ?
|
126
|
-
action.content :
|
127
|
-
makeSharedComponentByComponentLiteral(action.content)
|
128
|
-
]);
|
129
|
-
if (action.formats) {
|
130
|
-
// TODO 根节点样式
|
131
|
-
}
|
132
|
-
break;
|
133
|
-
case 'delete':
|
134
|
-
content.delete(index, action.count);
|
135
|
-
break;
|
136
|
-
}
|
137
|
-
});
|
138
|
-
}
|
139
|
-
function makeSharedSlotBySlotLiteral(slotLiteral) {
|
140
|
-
const content = new YArray();
|
141
|
-
let index = 0;
|
142
|
-
slotLiteral.content.forEach(i => {
|
143
|
-
let size;
|
144
|
-
if (typeof i === 'string') {
|
145
|
-
size = i.length;
|
146
|
-
content.insert(index, [i]);
|
147
|
-
}
|
148
|
-
else {
|
149
|
-
size = 1;
|
150
|
-
content.insert(index, [makeSharedComponentByComponentLiteral(i)]);
|
151
|
-
}
|
152
|
-
index += size;
|
153
|
-
});
|
154
|
-
const formats = new YMap();
|
155
|
-
const sharedSlot = new YMap();
|
156
|
-
sharedSlot.set('state', slotLiteral.state);
|
157
|
-
sharedSlot.set('content', content);
|
158
|
-
sharedSlot.set('schema', slotLiteral.schema);
|
159
|
-
sharedSlot.set('formats', formats);
|
160
|
-
return sharedSlot;
|
161
|
-
}
|
162
|
-
function makeSharedComponentByComponentLiteral(componentLiteral) {
|
163
|
-
const slots = new YArray();
|
164
|
-
componentLiteral.slots.forEach(item => {
|
165
|
-
slots.push([makeSharedSlotBySlotLiteral(item)]);
|
166
|
-
});
|
167
|
-
const sharedComponent = new YMap();
|
168
|
-
sharedComponent.set('name', componentLiteral.name);
|
169
|
-
sharedComponent.set('slots', slots);
|
170
|
-
sharedComponent.set('state', componentLiteral.state);
|
171
|
-
return sharedComponent;
|
172
|
-
}
|
173
|
-
//# sourceMappingURL=local-to-remote.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"local-to-remote.js","sourceRoot":"","sources":["../src/local-to-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,MAAM,EAA4B,MAAM,eAAe,CAAA;AAClH,OAA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AA;IAC5C,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAClC,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAS,qCAAqC,CAAC,gBAAkC;IAC/E,MAAM,KAAK,GAAG,IAAI,MAAM,EAAE,CAAA;IAC1B,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpC,KAAK,CAAC,IAAI,CAAC,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IACF,MAAM,eAAe,GAAG,IAAI,IAAI,EAAE,CAAA;IAClC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;IAClD,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpD,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
@@ -1,143 +0,0 @@
|
|
1
|
-
import { YArrayEvent, YMapEvent } from 'yjs';
|
2
|
-
import { FormatType } from '@textbus/core';
|
3
|
-
export function remoteToLocal(events, slot, translator, formatterList) {
|
4
|
-
events.forEach(ev => {
|
5
|
-
const path = [];
|
6
|
-
for (let i = 0; i < ev.path.length; i += 2) {
|
7
|
-
path.push(ev.path.slice(i, i + 2));
|
8
|
-
}
|
9
|
-
if (path.length) {
|
10
|
-
const componentIndex = path.shift()[0];
|
11
|
-
const component = slot.getContentAtIndex(componentIndex);
|
12
|
-
applySharedComponentToComponent(ev, path, component, translator, formatterList);
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
apply(ev, slot, translator);
|
16
|
-
});
|
17
|
-
}
|
18
|
-
function applySharedComponentToComponent(ev, path, component, translator, formatterList) {
|
19
|
-
if (path.length) {
|
20
|
-
const childPath = path.shift();
|
21
|
-
const slot = component.slots.get(childPath[0]);
|
22
|
-
applySharedSlotToSlot(ev, path, slot, translator, formatterList, childPath[1] === 'formats');
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
if (ev instanceof YMapEvent) {
|
26
|
-
ev.keysChanged.forEach(key => {
|
27
|
-
if (key === 'state') {
|
28
|
-
const state = ev.target.get('state');
|
29
|
-
component.updateState(draft => {
|
30
|
-
Object.assign(draft, state);
|
31
|
-
});
|
32
|
-
}
|
33
|
-
});
|
34
|
-
}
|
35
|
-
else if (ev instanceof YArrayEvent) {
|
36
|
-
const slots = component.slots;
|
37
|
-
ev.delta.forEach(action => {
|
38
|
-
if (Reflect.has(action, 'retain')) {
|
39
|
-
slots.retain(action.retain);
|
40
|
-
}
|
41
|
-
else if (action.insert) {
|
42
|
-
action.insert.forEach(item => {
|
43
|
-
slots.insert(translator.createSlot(item.toJSON()));
|
44
|
-
});
|
45
|
-
}
|
46
|
-
else if (action.delete) {
|
47
|
-
slots.retain(slots.index);
|
48
|
-
slots.delete(action.delete);
|
49
|
-
}
|
50
|
-
});
|
51
|
-
}
|
52
|
-
}
|
53
|
-
function applySharedSlotToSlot(ev, path, slot, translator, formatterList, isUpdateFormats) {
|
54
|
-
if (path.length) {
|
55
|
-
const componentIndex = path.shift()[0];
|
56
|
-
const component = slot.getContentAtIndex(componentIndex);
|
57
|
-
applySharedComponentToComponent(ev, path, component, translator, formatterList);
|
58
|
-
return;
|
59
|
-
}
|
60
|
-
if (ev instanceof YArrayEvent) {
|
61
|
-
ev.delta.forEach(action => {
|
62
|
-
if (Reflect.has(action, 'retain')) {
|
63
|
-
slot.retain(action.retain);
|
64
|
-
}
|
65
|
-
else if (action.insert) {
|
66
|
-
action.insert.forEach(item => {
|
67
|
-
if (typeof item === 'string') {
|
68
|
-
slot.insert(item);
|
69
|
-
}
|
70
|
-
else {
|
71
|
-
slot.insert(translator.createComponent(item.toJSON()));
|
72
|
-
}
|
73
|
-
});
|
74
|
-
}
|
75
|
-
else if (action.delete) {
|
76
|
-
slot.retain(slot.index);
|
77
|
-
slot.delete(action.delete);
|
78
|
-
}
|
79
|
-
});
|
80
|
-
}
|
81
|
-
else if (ev instanceof YMapEvent) {
|
82
|
-
if (isUpdateFormats) {
|
83
|
-
const json = ev.target.toJSON();
|
84
|
-
ev.keysChanged.forEach(key => {
|
85
|
-
const formats = json[key];
|
86
|
-
const formatter = formatterList.get(key);
|
87
|
-
if (formatter.type !== FormatType.Block) {
|
88
|
-
slot.applyFormat(formatter, {
|
89
|
-
startIndex: 0,
|
90
|
-
endIndex: slot.length,
|
91
|
-
value: null
|
92
|
-
});
|
93
|
-
}
|
94
|
-
formats.forEach(item => {
|
95
|
-
if (formatter.type === FormatType.Block) {
|
96
|
-
slot.applyFormat(formatter, item.value);
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
slot.applyFormat(formatter, item);
|
100
|
-
}
|
101
|
-
});
|
102
|
-
});
|
103
|
-
}
|
104
|
-
else {
|
105
|
-
ev.keysChanged.forEach(key => {
|
106
|
-
if (key === 'state') {
|
107
|
-
const state = ev.target.get('state');
|
108
|
-
slot.updateState(draft => {
|
109
|
-
Object.assign(draft, state);
|
110
|
-
});
|
111
|
-
}
|
112
|
-
});
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
function apply(ev, slot, translator) {
|
117
|
-
if (ev instanceof YArrayEvent) {
|
118
|
-
slot.retain(0);
|
119
|
-
const delta = ev.delta;
|
120
|
-
delta.forEach(action => {
|
121
|
-
if (action.insert) {
|
122
|
-
action.insert.forEach(item => {
|
123
|
-
if (typeof item === 'string') {
|
124
|
-
slot.insert(item);
|
125
|
-
}
|
126
|
-
else {
|
127
|
-
const json = item.toJSON();
|
128
|
-
const component = translator.createComponent(json);
|
129
|
-
slot.insert(component);
|
130
|
-
}
|
131
|
-
});
|
132
|
-
}
|
133
|
-
else if (action.retain) {
|
134
|
-
slot.retain(action.retain);
|
135
|
-
}
|
136
|
-
else if (action.delete) {
|
137
|
-
slot.retain(slot.index);
|
138
|
-
slot.delete(action.delete);
|
139
|
-
}
|
140
|
-
});
|
141
|
-
}
|
142
|
-
}
|
143
|
-
//# sourceMappingURL=remote-to-local.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"remote-to-local.js","sourceRoot":"","sources":["../src/remote-to-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAU,SAAS,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAoC,UAAU,EAAoB,MAAM,eAAe,CAAA;AAI9F,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,IAAU,EAAE,UAAsB,EAAE,aAA4B;IAC9G,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAClB,MAAM,IAAI,GAAU,EAAE,CAAA;QAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAC1C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAqB,CAAC,CAAA;SACvD;QAED,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC,CAAC,CAAW,CAAA;YACjD,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAsB,CAAA;YAC7E,+BAA+B,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;YAC/E,OAAM;SACP;QAED,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,+BAA+B,CAAC,EAAU,EAAE,IAAW,EAAE,SAA4B,EAAE,UAAsB,EAAE,aAA4B;IAClJ,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,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