feat: update

This commit is contained in:
cudr
2019-10-19 23:29:09 +03:00
parent 20c44d369f
commit 65bb9b134d
9 changed files with 34 additions and 16 deletions

View File

@@ -17,7 +17,7 @@ const opType: any = {
// set_value: setValue
}
export const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => {
const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => {
try {
const applyOp = opType[op.type]
@@ -34,5 +34,7 @@ export const applyOperation = (doc: SyncDoc, op: Operation): SyncDoc => {
}
}
export const applySlateOps = (doc: SyncDoc, operations: Operations) =>
const applySlateOps = (doc: SyncDoc, operations: Operations) =>
operations.reduce(applyOperation, doc)
export { applyOperation, applySlateOps }

View File

@@ -1,7 +1,7 @@
import toSync from './toSync'
import hexGen from './hexGen'
export const toJS = node => {
const toJS = node => {
try {
return JSON.parse(JSON.stringify(node))
} catch (e) {
@@ -10,8 +10,8 @@ export const toJS = node => {
}
}
export const cloneNode = node => toSync(toJS(node))
const cloneNode = node => toSync(toJS(node))
const toSlatePath = path => (path ? path.filter(d => Number.isInteger(d)) : [])
export { toSync, toSlatePath, hexGen }
export { toSync, toJS, toSlatePath, hexGen, cloneNode }