You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
648 B
27 lines
648 B
import toSync from './toSync'
|
|
import hexGen from './hexGen'
|
|
|
|
import { CollabAction } from '../model'
|
|
|
|
export * from './testUtils'
|
|
|
|
const toJS = (node: any) => {
|
|
try {
|
|
return JSON.parse(JSON.stringify(node))
|
|
} catch (e) {
|
|
console.error('Convert to js failed!!! Return null')
|
|
return null
|
|
}
|
|
}
|
|
|
|
const cloneNode = (node: any) => toSync(toJS(node))
|
|
|
|
const toSlatePath = (path: any) =>
|
|
path ? path.filter((d: any) => Number.isInteger(d)) : []
|
|
|
|
const toCollabAction = (type: any, fn: (action: CollabAction) => void) => (
|
|
payload: any
|
|
) => fn({ type, payload })
|
|
|
|
export { toSync, toJS, toSlatePath, hexGen, cloneNode, toCollabAction }
|