feat: cursors should works with annotations

This commit is contained in:
cudr
2019-10-13 19:37:56 +03:00
parent 242a836ce8
commit 0ceb38bbfd
19 changed files with 214 additions and 186 deletions

View File

@@ -14,7 +14,7 @@ const byAction = {
const rootKey = '00000000-0000-0000-0000-000000000000'
const toSlateOp = (ops: Automerge.Diff[], currentTree) => {
const toSlateOp = (ops: Automerge.Diff[], doc) => {
const iterate = (acc, op) => {
const action = byAction[op.action]
@@ -30,9 +30,7 @@ const toSlateOp = (ops: Automerge.Diff[], currentTree) => {
[]
])
const res = defer.flatMap(op => op(tempTree, currentTree))
console.log('toSlate@@@', ops, res)
const res = defer.flatMap(op => op(tempTree, doc)).filter(op => op)
return res
}

View File

@@ -41,9 +41,13 @@ const removeNodesOp = ({ index, obj, path }: Automerge.Diff) => (map, doc) => {
}
const removeAnnotationOp = ({ key }: Automerge.Diff) => (map, doc) => {
return {
type: 'remove_annotation',
annotation: toJS(doc.annotations[key])
const annotation = toJS(doc.annotations[key])
if (annotation) {
return {
type: 'remove_annotation',
annotation
}
}
}

View File

@@ -33,8 +33,6 @@ const AnnotationSetOp = ({ key, value }: Automerge.Diff) => (map, doc) => {
// }
// }
console.log('opSET!!', key, map[value], op)
return op
}