| 444 | * @param {t.TestCase} _tc |
| 445 | */ |
| 446 | export const testUndoNestedUndoIssue = _tc => { |
| 447 | const doc = new Y.Doc({ gc: false }) |
| 448 | const design = doc.get() |
| 449 | const undoManager = new Y.UndoManager(design, { captureTimeout: 0 }) |
| 450 | |
| 451 | const text = new Y.Type() |
| 452 | |
| 453 | const blocks1 = new Y.Type() |
| 454 | const blocks1block = new Y.Type() |
| 455 | |
| 456 | doc.transact(() => { |
| 457 | blocks1block.setAttr('text', 'Type Something') |
| 458 | blocks1.push([blocks1block]) |
| 459 | text.setAttr('blocks', blocks1block) |
| 460 | design.setAttr('text', text) |
| 461 | }) |
| 462 | |
| 463 | const blocks2 = new Y.Type() |
| 464 | const blocks2block = new Y.Type() |
| 465 | doc.transact(() => { |
| 466 | blocks2block.setAttr('text', 'Something') |
| 467 | blocks2.push([blocks2block]) |
| 468 | text.setAttr('blocks', blocks2block) |
| 469 | }) |
| 470 | |
| 471 | const blocks3 = new Y.Type() |
| 472 | const blocks3block = new Y.Type() |
| 473 | doc.transact(() => { |
| 474 | blocks3block.setAttr('text', 'Something Else') |
| 475 | blocks3.push([blocks3block]) |
| 476 | text.setAttr('blocks', blocks3block) |
| 477 | }) |
| 478 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Something Else' }) }) })) |
| 479 | undoManager.undo() |
| 480 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Something' }) }) })) |
| 481 | undoManager.undo() |
| 482 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Type Something' }) }) })) |
| 483 | undoManager.undo() |
| 484 | t.compare(design.toDeltaDeep(), delta.from({})) |
| 485 | undoManager.redo() |
| 486 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Type Something' }) }) })) |
| 487 | undoManager.redo() |
| 488 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Something' }) }) })) |
| 489 | undoManager.redo() |
| 490 | t.compare(design.toDeltaDeep(), delta.from({ text: delta.from({ blocks: delta.from({ text: 'Something Else' }) }) })) |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * This issue has been reported in https://github.com/yjs/yjs/issues/355 |
nothing calls this directly
no test coverage detected
searching dependent graphs…