From ffabdff3d5bbf99c472fb1c90f8d92a33f4b8b6f Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 10 Jan 2026 13:36:49 +0100 Subject: [PATCH] remove insertAfter --- src/ytype.js | 22 ---------------------- tests/y-xml.tests.js | 28 ---------------------------- 2 files changed, 50 deletions(-) diff --git a/src/ytype.js b/src/ytype.js index 1c4391d0..19615f63 100644 --- a/src/ytype.js +++ b/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>} 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. * diff --git a/tests/y-xml.tests.js b/tests/y-xml.tests.js index 021720c1..f42441ae 100644 --- a/tests/y-xml.tests.js +++ b/tests/y-xml.tests.js @@ -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 */