more comments

This commit is contained in:
Bartosz Sypytkowski 2023-06-15 11:13:38 +02:00
parent c7f069318e
commit 170a80a25f
2 changed files with 6 additions and 1 deletions

View File

@ -385,6 +385,7 @@ export class Item extends AbstractStruct {
return this.parent.client
}
if (this.content.constructor === ContentType && /** @type {ContentType} */ (this.content).type.constructor === YWeakLink) {
// make sure that linked content is integrated first
const content = /** @type {any} */ (this.content).type
if (content._id.client !== this.id.client) {
return content._id.client
@ -523,8 +524,9 @@ export class Item extends AbstractStruct {
// set as current parent value if right === null and this is parentSub
/** @type {AbstractType<any>} */ (this.parent)._map.set(this.parentSub, this)
if (this.left !== null) {
// this is the current attribute value of parent. delete right
// inherit links from block we're overriding
this.linkedBy = this.left.linkedBy
// this is the current attribute value of parent. delete right
this.left.delete(transaction)
}
}

View File

@ -77,6 +77,9 @@ export class YWeakLink extends AbstractType {
super._integrate(y, item)
if (item !== null) {
transact(y, (transaction) => {
// link may refer to a single element in multi-element block
// in such case we need to cut of the linked element into a
// separate block
let sourceItem = this._linkedItem !== null ? this._linkedItem : getItemCleanStart(transaction, this._id)
if (sourceItem.constructor === Item && sourceItem.parentSub !== null) {
// for maps, advance to most recent item