mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: cursors should works with annotations
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ const AnnotationSetOp = ({ key, value }: Automerge.Diff) => (map, doc) => {
|
||||
// }
|
||||
// }
|
||||
|
||||
console.log('opSET!!', key, map[value], op)
|
||||
|
||||
return op
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user