mirror of
https://github.com/cudr/slate-collaborative.git
synced 2024-10-27 20:34:06 +00:00
17 lines
386 B
TypeScript
17 lines
386 B
TypeScript
import * as Automerge from 'automerge'
|
|
import { CollabMap, CollabOperation } from '../model'
|
|
|
|
const createByType = (type: Automerge.CollectionType) =>
|
|
type === 'map' ? {} : type === 'list' ? [] : ''
|
|
|
|
const opCreate = (
|
|
{ obj, type }: Automerge.Diff,
|
|
[map, ops]: [CollabMap, CollabOperation[]]
|
|
) => {
|
|
map[obj] = createByType(type)
|
|
|
|
return [map, ops]
|
|
}
|
|
|
|
export default opCreate
|