Use lib0/any-encoding instead of JSON

This commit is contained in:
Kevin Jahns
2019-08-09 01:15:33 +02:00
parent 36203af88e
commit 0e7da017fe
8 changed files with 164 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ import {
nextID,
isVisible,
ContentType,
ContentJSON,
ContentAny,
ContentBinary,
createID,
getItemCleanStart,
@@ -374,7 +374,7 @@ export const typeListInsertGenericsAfter = (transaction, parent, referenceItem,
let jsonContent = []
const packJsonContent = () => {
if (jsonContent.length > 0) {
left = new Item(nextID(transaction), left, left === null ? null : left.lastId, right, right === null ? null : right.id, parent, null, new ContentJSON(jsonContent))
left = new Item(nextID(transaction), left, left === null ? null : left.lastId, right, right === null ? null : right.id, parent, null, new ContentAny(jsonContent))
left.integrate(transaction)
jsonContent = []
}
@@ -503,7 +503,7 @@ export const typeMapSet = (transaction, parent, key, value) => {
const left = parent._map.get(key) || null
let content
if (value == null) {
content = new ContentJSON([value])
content = new ContentAny([value])
} else {
switch (value.constructor) {
case Number:
@@ -511,7 +511,7 @@ export const typeMapSet = (transaction, parent, key, value) => {
case Boolean:
case Array:
case String:
content = new ContentJSON([value])
content = new ContentAny([value])
break
case Uint8Array:
content = new ContentBinary(value)