fixed YArray
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
|
||||
// TODO: ItemBinary should be able to merge with right (similar to other items). Or the other items (ItemJSON) should not be able to merge - extra byte + consistency
|
||||
|
||||
import { AbstractItem, logItemHelper, AbstractItemRef } from './AbstractItem.js'
|
||||
import { AbstractItem, AbstractItemRef } from './AbstractItem.js'
|
||||
import { AbstractType } from '../types/AbstractType.js' // eslint-disable-line
|
||||
import * as encoding from 'lib0/encoding.js'
|
||||
import * as decoding from 'lib0/decoding.js'
|
||||
import { ID } from '../utils/ID.js' // eslint-disable-line
|
||||
import { ItemType } from './ItemType.js' // eslint-disable-line
|
||||
import { Y } from '../utils/Y.js' // eslint-disable-line
|
||||
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
|
||||
import { getItemCleanEnd, getItemCleanStart, getItemType } from '../utils/StructStore.js'
|
||||
@@ -20,7 +20,7 @@ export class ItemBinary extends AbstractItem {
|
||||
* @param {ID} id
|
||||
* @param {AbstractItem | null} left
|
||||
* @param {AbstractItem | null} right
|
||||
* @param {ItemType | null} parent
|
||||
* @param {AbstractType} parent
|
||||
* @param {string | null} parentSub
|
||||
* @param {ArrayBuffer} content
|
||||
*/
|
||||
@@ -28,25 +28,19 @@ export class ItemBinary extends AbstractItem {
|
||||
super(id, left, right, parent, parentSub)
|
||||
this.content = content
|
||||
}
|
||||
getContent () {
|
||||
return [this.content]
|
||||
}
|
||||
/**
|
||||
* @param {ID} id
|
||||
* @param {AbstractItem | null} left
|
||||
* @param {AbstractItem | null} right
|
||||
* @param {ItemType | null} parent
|
||||
* @param {AbstractType} parent
|
||||
* @param {string | null} parentSub
|
||||
*/
|
||||
copy (id, left, right, parent, parentSub) {
|
||||
return new ItemBinary(id, left, right, parent, parentSub, this.content)
|
||||
}
|
||||
/**
|
||||
* Transform this Type to a readable format.
|
||||
* Useful for logging as all Items and Delete implement this method.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
logString () {
|
||||
return logItemHelper('ItemBinary', this)
|
||||
}
|
||||
/**
|
||||
* @param {encoding.Encoder} encoder
|
||||
*/
|
||||
@@ -73,12 +67,14 @@ export class ItemBinaryRef extends AbstractItemRef {
|
||||
* @return {ItemBinary}
|
||||
*/
|
||||
toStruct (transaction) {
|
||||
const store = transaction.y.store
|
||||
const y = transaction.y
|
||||
const store = y.store
|
||||
return new ItemBinary(
|
||||
this.id,
|
||||
this.left === null ? null : getItemCleanEnd(store, transaction, this.left),
|
||||
this.right === null ? null : getItemCleanStart(store, transaction, this.right),
|
||||
this.parent === null ? null : getItemType(store, this.parent),
|
||||
// @ts-ignore
|
||||
this.parent === null ? y.get(this.parentYKey) : getItemType(store, this.parent).type,
|
||||
this.parentSub,
|
||||
this.content
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user