mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: extract cursor component
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Operation, SyncDoc } from '../model'
|
||||
import { Operation, SyncDoc } from '../model/index'
|
||||
|
||||
export const addAnnotation = (doc: SyncDoc, op: Operation): SyncDoc => {
|
||||
console.log('addAnnotation!!!', op.toJS())
|
||||
|
||||
@@ -21,7 +21,10 @@ export const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => {
|
||||
try {
|
||||
const applyOp = opType[op.type]
|
||||
|
||||
if (!applyOp) throw new TypeError('Unsupported operation type!')
|
||||
if (!applyOp) {
|
||||
console.log('operation', op.toJS())
|
||||
throw new TypeError(`Unsupported operation type: ${op.type}!`)
|
||||
}
|
||||
|
||||
return applyOp(doc, op)
|
||||
} catch (e) {
|
||||
|
||||
@@ -30,9 +30,7 @@ const toSlateOp = (ops: Automerge.Diff[], doc) => {
|
||||
[]
|
||||
])
|
||||
|
||||
const res = defer.flatMap(op => op(tempTree, doc)).filter(op => op)
|
||||
|
||||
return res
|
||||
return defer.flatMap(op => op(tempTree, doc)).filter(op => op)
|
||||
}
|
||||
|
||||
export { toSlateOp }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Operation, Selection } from 'slate'
|
||||
import { List } from 'immutable'
|
||||
import * as Immutable from 'immutable'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
import { toJS } from '../utils'
|
||||
@@ -51,7 +51,7 @@ export const removeCursor = (doc: SyncDoc, key: CursorKey) => {
|
||||
return doc
|
||||
}
|
||||
|
||||
export const cursorOpFilter = (ops: List<Operation>, type: string) =>
|
||||
export const cursorOpFilter = (ops: Immutable.List<Operation>, type: string) =>
|
||||
ops.filter(op => {
|
||||
if (op.type === 'set_annotation') {
|
||||
return !(
|
||||
|
||||
Reference in New Issue
Block a user