fixed YArray
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
* @module structs
|
||||
*/
|
||||
|
||||
import { AbstractItem, AbstractItemRef, logItemHelper } from './AbstractItem.js'
|
||||
import { AbstractType } from '../types/AbstractType.js' // eslint-disable-line
|
||||
import { AbstractItem, AbstractItemRef } from './AbstractItem.js'
|
||||
import { ItemType } from './ItemType.js' // eslint-disable-line
|
||||
import * as encoding from 'lib0/encoding.js'
|
||||
import * as decoding from 'lib0/decoding.js'
|
||||
@@ -18,7 +19,7 @@ export class ItemEmbed 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 {Object} embed
|
||||
*/
|
||||
@@ -30,28 +31,12 @@ export class ItemEmbed extends AbstractItem {
|
||||
* @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 ItemEmbed(id, left, right, parent, parentSub, this.embed)
|
||||
}
|
||||
/**
|
||||
* Transform this Type to a readable format.
|
||||
* Useful for logging as all Items and Delete implement this method.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
logString () {
|
||||
return logItemHelper('ItemEmbed', this)
|
||||
}
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
get _length () {
|
||||
return 1
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {encoding.Encoder} encoder
|
||||
*/
|
||||
@@ -78,12 +63,14 @@ export class ItemEmbedRef extends AbstractItemRef {
|
||||
* @return {ItemEmbed}
|
||||
*/
|
||||
toStruct (transaction) {
|
||||
const store = transaction.y.store
|
||||
const y = transaction.y
|
||||
const store = y.store
|
||||
return new ItemEmbed(
|
||||
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),
|
||||
this.parentSub,
|
||||
this.embed
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user