mirror of
https://github.com/yjs/yjs.git
synced 2026-02-23 19:49:59 +01:00
remove insertAfter
This commit is contained in:
22
src/ytype.js
22
src/ytype.js
@@ -1204,28 +1204,6 @@ export class YType {
|
||||
this.applyDelta(delta.create().retain(index).retain(length, formats))
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts new content after another element.
|
||||
*
|
||||
* @example
|
||||
* // Insert character 'a' at position 0
|
||||
* xml.insert(0, [new Y.XmlText('text')])
|
||||
*
|
||||
* @param {null|Item|YType} ref The index to insert content at
|
||||
* @param {Array<delta.DeltaConfGetChildren<DConf>>} content The array of content
|
||||
*/
|
||||
insertAfter (ref, content) {
|
||||
if (this.doc !== null) {
|
||||
transact(this.doc, transaction => {
|
||||
const refItem = ref && ref instanceof YType ? ref._item : ref
|
||||
typeListInsertGenericsAfter(transaction, this, refItem, content)
|
||||
})
|
||||
} else {
|
||||
// only possible once this item has been integrated
|
||||
error.unexpectedCase()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends content to this YArray.
|
||||
*
|
||||
|
||||
@@ -85,34 +85,6 @@ export const testSiblings = _tc => {
|
||||
t.assert(yxml.parent === null)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {t.TestCase} _tc
|
||||
*/
|
||||
export const testInsertafter = _tc => {
|
||||
const ydoc = new Y.Doc()
|
||||
const yxml = ydoc.get()
|
||||
const first = new Y.Type()
|
||||
const second = new Y.Type('p')
|
||||
const third = new Y.Type('p')
|
||||
const deepsecond1 = new Y.Type('span')
|
||||
const deepsecond2 = new Y.Type()
|
||||
yxml.insertAfter(null, [first, second])
|
||||
yxml.insertAfter(second, [third])
|
||||
second.insertAfter(null, [deepsecond1])
|
||||
second.insertAfter(deepsecond1, [deepsecond2])
|
||||
|
||||
t.assert(yxml.length === 3)
|
||||
t.assert(second.get(0) === deepsecond1)
|
||||
t.assert(second.get(1) === deepsecond2)
|
||||
|
||||
t.compareArrays(yxml.toArray(), [first, second, third])
|
||||
|
||||
t.fails(() => {
|
||||
const el = new Y.Type('p')
|
||||
el.insertAfter(deepsecond1, [new Y.Type()])
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {t.TestCase} _tc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user