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.
cudr_slate-collaborative/packages/bridge/src/utils/testUtils.ts

28 lines
559 B

import * as Automerge from 'automerge'
import { TextJSON } from 'slate'
export const createTextJSON = (text: string = ''): TextJSON => ({
object: 'text',
marks: [],
text
})
export const createBlockJSON = (
type: string = 'paragraph',
text: string = ''
) => ({
object: 'block',
type,
nodes: [createTextJSON(text)]
})
export const createValueJSON = () => ({
document: {
nodes: [createBlockJSON()]
}
})
export const createDoc = () => Automerge.from(createValueJSON())
export const cloneDoc = doc => Automerge.change(doc, '', d => d)