fix all types but yxmlelement
This commit is contained in:
parent
1bc1e88d6a
commit
73c28952c2
@ -4,11 +4,9 @@
|
||||
|
||||
import { AbstractItem } from '../structs/AbstractItem.js' // eslint-disable-line
|
||||
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
|
||||
import { AbstractType, typeArrayGet, typeArrayToArray, typeArrayForEach, typeArrayCreateIterator, typeArrayInsertGenerics } from './AbstractType.js'
|
||||
import { AbstractType, typeArrayGet, typeArrayToArray, typeArrayForEach, typeArrayCreateIterator, typeArrayInsertGenerics, typeArrayDelete } from './AbstractType.js'
|
||||
import { YEvent } from '../utils/YEvent.js'
|
||||
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
|
||||
import { getItemCleanStart, getItemCleanEnd } from '../utils/StructStore.js'
|
||||
import { createID } from '../utils/ID.js'
|
||||
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
|
||||
|
||||
/**
|
||||
@ -180,28 +178,7 @@ export class YArray extends AbstractType {
|
||||
delete (index, length = 1) {
|
||||
if (this._y !== null) {
|
||||
this._y.transact(transaction => {
|
||||
const store = transaction.y.store
|
||||
let item = this._start
|
||||
let count = 0
|
||||
while (item !== null && length > 0) {
|
||||
if (!item.deleted && item.countable) {
|
||||
if (count <= index && index < count + item.length) {
|
||||
const diffDel = index - count
|
||||
if (diffDel > 0) {
|
||||
item = getItemCleanStart(store, transaction, createID(item.id.client, item.id.clock + diffDel))
|
||||
}
|
||||
if (length < item.length) {
|
||||
getItemCleanEnd(store, transaction, createID(item.id.client, item.id.clock + length))
|
||||
}
|
||||
length -= item.length
|
||||
item.delete(transaction)
|
||||
count += diffDel
|
||||
} else {
|
||||
count += item.length
|
||||
}
|
||||
}
|
||||
item = item.right
|
||||
}
|
||||
typeArrayDelete(transaction, this, index, length)
|
||||
})
|
||||
} else {
|
||||
// @ts-ignore _prelimContent is defined because this is not yet integrated
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import { YEvent } from '../utils/YEvent.js'
|
||||
|
||||
import { Type } from './AbstractType.js' // eslint-disable-line
|
||||
import { AbstractType } from './AbstractType.js' // eslint-disable-line
|
||||
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
|
||||
|
||||
/**
|
||||
@ -14,7 +14,7 @@ import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
|
||||
*/
|
||||
export class YXmlEvent extends YEvent {
|
||||
/**
|
||||
* @param {Type} target The target on which the event is created.
|
||||
* @param {AbstractType} target The target on which the event is created.
|
||||
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
||||
* child list changed.
|
||||
* @param {Boolean} remote Whether this change was created by a remote peer.
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import { YText } from './YText.js'
|
||||
import { Y } from '../utils/Y.js' // eslint-disable-line
|
||||
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
|
||||
|
||||
/**
|
||||
* Represents text in a Dom Element. In the future this type will also handle
|
||||
@ -18,7 +18,7 @@ export class YXmlText extends YText {
|
||||
* nodejs)
|
||||
* @param {Object<string, any>} [hooks] Optional property to customize how hooks
|
||||
* are presented in the DOM
|
||||
* @param {DomBinding} [binding] You should not set this property. This is
|
||||
* @param {any} [binding] You should not set this property. This is
|
||||
* used if DomBinding wants to create a
|
||||
* association to the created DOM type.
|
||||
* @return {Text} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}
|
||||
@ -32,21 +32,10 @@ export class YXmlText extends YText {
|
||||
}
|
||||
return dom
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this Item as deleted.
|
||||
*
|
||||
* @param {Y} y The Yjs instance
|
||||
* @param {boolean} createDelete Whether to propagate a message that this
|
||||
* Type was deleted.
|
||||
* @param {boolean} [gcChildren=y._hasUndoManager===false] Whether to garbage
|
||||
* collect the children of this type.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_delete (y, createDelete, gcChildren) {
|
||||
super._delete(y, createDelete, gcChildren)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {decoding.Decoder} decoder
|
||||
* @return {YXmlText}
|
||||
*/
|
||||
export const readYXmlText = decoder => new YXmlText()
|
||||
|
Loading…
x
Reference in New Issue
Block a user