fix undoing of content containing subdocs

This commit is contained in:
Kevin Jahns
2021-11-19 13:47:10 +01:00
parent 4154b12f14
commit 9a7250f192
3 changed files with 25 additions and 13 deletions

View File

@@ -213,3 +213,18 @@ export const testSubdocLoadEdgeCasesAutoload = tc => {
t.assert(lastEvent !== null && lastEvent.added.has(subdoc3))
t.assert(lastEvent !== null && lastEvent.loaded.has(subdoc3))
}
/**
* @param {t.TestCase} tc
*/
export const testSubdocsUndo = tc => {
const ydoc = new Y.Doc()
const elems = ydoc.getXmlFragment()
const undoManager = new Y.UndoManager(elems)
const subdoc = new Y.Doc()
// @ts-ignore
elems.insert(0, [subdoc])
undoManager.undo()
undoManager.redo()
t.assert(elems.length === 1)
}