|
|
@@ -40,312 +40,310 @@ describe( 'UndoEngine integration', () => {
|
|
|
expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
|
|
|
}
|
|
|
|
|
|
- describe( 'UndoEngine integration', () => {
|
|
|
- describe( 'adding and removing content', () => {
|
|
|
- it( 'add and undo', () => {
|
|
|
- input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ describe( 'adding and removing content', () => {
|
|
|
+ it( 'add and undo', () => {
|
|
|
+ input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
- output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
+ output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'multiple adding and undo', () => {
|
|
|
- input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ it( 'multiple adding and undo', () => {
|
|
|
+ input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch()
|
|
|
- .insert( doc.selection.getFirstPosition(), 'zzz' )
|
|
|
- .insert( new Position( root, [ 1, 0 ] ), 'xxx' );
|
|
|
- output( '<p>fozzz[]o</p><p>xxxbar</p>' );
|
|
|
+ doc.batch()
|
|
|
+ .insert( doc.selection.getFirstPosition(), 'zzz' )
|
|
|
+ .insert( new Position( root, [ 1, 0 ] ), 'xxx' );
|
|
|
+ output( '<p>fozzz[]o</p><p>xxxbar</p>' );
|
|
|
|
|
|
- setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'yyy' );
|
|
|
- output( '<p>fozzzo</p><p>yyy[]xxxbar</p>' );
|
|
|
+ setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'yyy' );
|
|
|
+ output( '<p>fozzzo</p><p>yyy[]xxxbar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fozzzo</p><p>[]xxxbar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fozzzo</p><p>[]xxxbar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'multiple adding mixed with undo', () => {
|
|
|
- input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ it( 'multiple adding mixed with undo', () => {
|
|
|
+ input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
- output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
+ output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
|
|
|
- setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'yyy' );
|
|
|
- output( '<p>fozzzo</p><p>yyy[]bar</p>' );
|
|
|
+ setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'yyy' );
|
|
|
+ output( '<p>fozzzo</p><p>yyy[]bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fozzzo</p><p>[]bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fozzzo</p><p>[]bar</p>' );
|
|
|
|
|
|
- setSelection( [ 0, 0 ], [ 0, 0 ] );
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'xxx' );
|
|
|
- output( '<p>xxx[]fozzzo</p><p>bar</p>' );
|
|
|
+ setSelection( [ 0, 0 ], [ 0, 0 ] );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'xxx' );
|
|
|
+ output( '<p>xxx[]fozzzo</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>[]fozzzo</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>[]fozzzo</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'multiple remove and undo', () => {
|
|
|
- input( '<p>[]foo</p><p>bar</p>' );
|
|
|
+ it( 'multiple remove and undo', () => {
|
|
|
+ input( '<p>[]foo</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().remove( Range.createFromPositionAndShift( doc.selection.getFirstPosition(), 2 ) );
|
|
|
- output( '<p>[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().remove( Range.createFromPositionAndShift( doc.selection.getFirstPosition(), 2 ) );
|
|
|
+ output( '<p>[]o</p><p>bar</p>' );
|
|
|
|
|
|
- setSelection( [ 1, 1 ], [ 1, 1 ] );
|
|
|
- doc.batch().remove( Range.createFromPositionAndShift( doc.selection.getFirstPosition(), 2 ) );
|
|
|
- output( '<p>o</p><p>b[]</p>' );
|
|
|
+ setSelection( [ 1, 1 ], [ 1, 1 ] );
|
|
|
+ doc.batch().remove( Range.createFromPositionAndShift( doc.selection.getFirstPosition(), 2 ) );
|
|
|
+ output( '<p>o</p><p>b[]</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- // Here is an edge case that selection could be before or after `ar`.
|
|
|
- output( '<p>o</p><p>b[]ar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ // Here is an edge case that selection could be before or after `ar`.
|
|
|
+ output( '<p>o</p><p>bar[]</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- // As above.
|
|
|
- output( '<p>[]foo</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ // As above.
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'add and remove different parts and undo', () => {
|
|
|
- input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ it( 'add and remove different parts and undo', () => {
|
|
|
+ input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
- output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
+ output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
|
|
|
- setSelection( [ 1, 2 ], [ 1, 2 ] );
|
|
|
- doc.batch().remove( Range.createFromPositionAndShift( new Position( root, [ 1, 1 ] ), 1 ) );
|
|
|
- output( '<p>fozzzo</p><p>b[]r</p>' );
|
|
|
+ setSelection( [ 1, 2 ], [ 1, 2 ] );
|
|
|
+ doc.batch().remove( Range.createFromPositionAndShift( new Position( root, [ 1, 1 ] ), 1 ) );
|
|
|
+ output( '<p>fozzzo</p><p>b[]r</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fozzzo</p><p>ba[]r</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fozzzo</p><p>ba[]r</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'add and remove same part and undo', () => {
|
|
|
- input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ it( 'add and remove same part and undo', () => {
|
|
|
+ input( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
- output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
+ output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().remove( Range.createFromPositionAndShift( new Position( root, [ 0, 2 ] ), 3 ) );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ doc.batch().remove( Range.createFromPositionAndShift( new Position( root, [ 0, 2 ] ), 3 ) );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fozzz[]o</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[]o</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
} );
|
|
|
+ } );
|
|
|
|
|
|
- describe( 'moving', () => {
|
|
|
- it( 'move same content twice then undo', () => {
|
|
|
- input( '<p>f[o]z</p><p>bar</p>' );
|
|
|
+ describe( 'moving', () => {
|
|
|
+ it( 'move same content twice then undo', () => {
|
|
|
+ input( '<p>f[o]z</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 1, 0 ] ) );
|
|
|
- output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
+ doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 1, 0 ] ) );
|
|
|
+ output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
|
|
|
- doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0, 2 ] ) );
|
|
|
- output( '<p>fz[o]</p><p>bar</p>' );
|
|
|
+ doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0, 2 ] ) );
|
|
|
+ output( '<p>fz[o]</p><p>bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>f[o]z</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>f[o]z</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'move content and new parent then undo', () => {
|
|
|
- input( '<p>f[o]z</p><p>bar</p>' );
|
|
|
+ it( 'move content and new parent then undo', () => {
|
|
|
+ input( '<p>f[o]z</p><p>bar</p>' );
|
|
|
|
|
|
- doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 1, 0 ] ) );
|
|
|
- output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
+ doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 1, 0 ] ) );
|
|
|
+ output( '<p>fz</p><p>[o]bar</p>' );
|
|
|
|
|
|
- setSelection( [ 1 ], [ 2 ] );
|
|
|
- doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0 ] ) );
|
|
|
- output( '[<p>obar</p>]<p>fz</p>' );
|
|
|
+ setSelection( [ 1 ], [ 2 ] );
|
|
|
+ doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0 ] ) );
|
|
|
+ output( '[<p>obar</p>]<p>fz</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fz</p>[<p>obar</p>]' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fz</p>[<p>obar</p>]' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>f[o]z</p><p>bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>f[o]z</p><p>bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
} );
|
|
|
+ } );
|
|
|
|
|
|
- describe( 'attributes with other', () => {
|
|
|
- it( 'attributes then insert inside then undo', () => {
|
|
|
- input( '<p>fo[ob]ar</p>' );
|
|
|
+ describe( 'attributes with other', () => {
|
|
|
+ it( 'attributes then insert inside then undo', () => {
|
|
|
+ input( '<p>fo[ob]ar</p>' );
|
|
|
|
|
|
- doc.batch().setAttribute( doc.selection.getFirstRange(), 'bold', true );
|
|
|
- output( '<p>fo[<$text bold="true">ob</$text>]ar</p>' );
|
|
|
+ doc.batch().setAttribute( doc.selection.getFirstRange(), 'bold', true );
|
|
|
+ output( '<p>fo[<$text bold="true">ob</$text>]ar</p>' );
|
|
|
|
|
|
- setSelection( [ 0, 3 ], [ 0, 3 ] );
|
|
|
- doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
- output( '<p>fo<$text bold="true">o</$text>zzz<$text bold="true">[]b</$text>ar</p>' );
|
|
|
- expect( doc.selection.getAttribute( 'bold' ) ).to.true;
|
|
|
+ setSelection( [ 0, 3 ], [ 0, 3 ] );
|
|
|
+ doc.batch().insert( doc.selection.getFirstPosition(), 'zzz' );
|
|
|
+ output( '<p>fo<$text bold="true">o</$text>zzz<$text bold="true">[]b</$text>ar</p>' );
|
|
|
+ expect( doc.selection.getAttribute( 'bold' ) ).to.true;
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo<$text bold="true">o[]b</$text>ar</p>' );
|
|
|
- expect( doc.selection.getAttribute( 'bold' ) ).to.true;
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo<$text bold="true">o[]b</$text>ar</p>' );
|
|
|
+ expect( doc.selection.getAttribute( 'bold' ) ).to.true;
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[ob]ar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[ob]ar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
} );
|
|
|
+ } );
|
|
|
|
|
|
- describe( 'wrapping, unwrapping, merging, splitting', () => {
|
|
|
- it( 'wrap and undo', () => {
|
|
|
- doc.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
- input( 'fo[zb]ar' );
|
|
|
+ describe( 'wrapping, unwrapping, merging, splitting', () => {
|
|
|
+ it( 'wrap and undo', () => {
|
|
|
+ doc.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
+ input( 'fo[zb]ar' );
|
|
|
|
|
|
- doc.batch().wrap( doc.selection.getFirstRange(), 'p' );
|
|
|
- output( 'fo<p>[zb]</p>ar' );
|
|
|
+ doc.batch().wrap( doc.selection.getFirstRange(), 'p' );
|
|
|
+ output( 'fo<p>[zb]</p>ar' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( 'fo[zb]ar' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( 'fo[zb]ar' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'wrap, move and undo', () => {
|
|
|
- doc.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
- input( 'fo[zb]ar' );
|
|
|
+ it( 'wrap, move and undo', () => {
|
|
|
+ doc.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
+ input( 'fo[zb]ar' );
|
|
|
|
|
|
- doc.batch().wrap( doc.selection.getFirstRange(), 'p' );
|
|
|
- // Would be better if selection was inside P.
|
|
|
- output( 'fo<p>[zb]</p>ar' );
|
|
|
+ doc.batch().wrap( doc.selection.getFirstRange(), 'p' );
|
|
|
+ // Would be better if selection was inside P.
|
|
|
+ output( 'fo<p>[zb]</p>ar' );
|
|
|
|
|
|
- setSelection( [ 2, 0 ], [ 2, 1 ] );
|
|
|
- doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0 ] ) );
|
|
|
- output( '[z]fo<p>b</p>ar' );
|
|
|
+ setSelection( [ 2, 0 ], [ 2, 1 ] );
|
|
|
+ doc.batch().move( doc.selection.getFirstRange(), new Position( root, [ 0 ] ) );
|
|
|
+ output( '[z]fo<p>b</p>ar' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( 'fo<p>[z]b</p>ar' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( 'fo<p>[z]b</p>ar' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( 'fo[zb]ar' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( 'fo[zb]ar' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'unwrap and undo', () => {
|
|
|
- input( '<p>foo[]bar</p>' );
|
|
|
+ it( 'unwrap and undo', () => {
|
|
|
+ input( '<p>foo[]bar</p>' );
|
|
|
|
|
|
- doc.batch().unwrap( doc.selection.getFirstPosition().parent );
|
|
|
- output( 'foo[]bar' );
|
|
|
+ doc.batch().unwrap( doc.selection.getFirstPosition().parent );
|
|
|
+ output( 'foo[]bar' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>foo[]bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>foo[]bar</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'merge and undo', () => {
|
|
|
- input( '<p>foo</p><p>[]bar</p>' );
|
|
|
+ it( 'merge and undo', () => {
|
|
|
+ input( '<p>foo</p><p>[]bar</p>' );
|
|
|
|
|
|
- doc.batch().merge( new Position( root, [ 1 ] ) );
|
|
|
- // Because selection is stuck with <p> it ends up in graveyard. We have to manually move it to correct node.
|
|
|
- setSelection( [ 0, 3 ], [ 0, 3 ] );
|
|
|
- output( '<p>foo[]bar</p>' );
|
|
|
+ doc.batch().merge( new Position( root, [ 1 ] ) );
|
|
|
+ // Because selection is stuck with <p> it ends up in graveyard. We have to manually move it to correct node.
|
|
|
+ setSelection( [ 0, 3 ], [ 0, 3 ] );
|
|
|
+ output( '<p>foo[]bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>foo</p><p>[]bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>foo</p><p>bar[]</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
+ } );
|
|
|
|
|
|
- it( 'split and undo', () => {
|
|
|
- input( '<p>foo[]bar</p>' );
|
|
|
+ it( 'split and undo', () => {
|
|
|
+ input( '<p>foo[]bar</p>' );
|
|
|
|
|
|
- doc.batch().split( doc.selection.getFirstPosition() );
|
|
|
- // Because selection is stuck with <p> it ends up in wrong node. We have to manually move it to correct node.
|
|
|
- setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
- output( '<p>foo</p><p>[]bar</p>' );
|
|
|
+ doc.batch().split( doc.selection.getFirstPosition() );
|
|
|
+ // Because selection is stuck with <p> it ends up in wrong node. We have to manually move it to correct node.
|
|
|
+ setSelection( [ 1, 0 ], [ 1, 0 ] );
|
|
|
+ output( '<p>foo</p><p>[]bar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>foo[]bar</p>' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>foobar[]</p>' );
|
|
|
|
|
|
- undoDisabled();
|
|
|
- } );
|
|
|
+ undoDisabled();
|
|
|
} );
|
|
|
+ } );
|
|
|
|
|
|
- describe( 'other edge cases', () => {
|
|
|
- it( 'deleteContent between two nodes', () => {
|
|
|
- input( '<p>fo[o</p><p>b]ar</p>' );
|
|
|
+ describe( 'other edge cases', () => {
|
|
|
+ it( 'deleteContent between two nodes', () => {
|
|
|
+ input( '<p>fo[o</p><p>b]ar</p>' );
|
|
|
|
|
|
- editor.data.deleteContent( doc.selection, doc.batch() );
|
|
|
- output( '<p>fo[]ar</p>' );
|
|
|
+ editor.data.deleteContent( doc.selection, doc.batch() );
|
|
|
+ output( '<p>fo[]ar</p>' );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- output( '<p>fo[o</p><p>b]ar</p>' );
|
|
|
- } );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ output( '<p>fo[o</p><p>b]ar</p>' );
|
|
|
+ } );
|
|
|
|
|
|
- // Related to ckeditor5-engine#891 and ckeditor5-list#51.
|
|
|
- it( 'change attribute of removed node then undo and redo', () => {
|
|
|
- const gy = doc.graveyard;
|
|
|
- const batch = doc.batch();
|
|
|
- const p = new Element( 'p' );
|
|
|
+ // Related to ckeditor5-engine#891 and ckeditor5-list#51.
|
|
|
+ it( 'change attribute of removed node then undo and redo', () => {
|
|
|
+ const gy = doc.graveyard;
|
|
|
+ const batch = doc.batch();
|
|
|
+ const p = new Element( 'p' );
|
|
|
|
|
|
- root.appendChildren( p );
|
|
|
+ root.appendChildren( p );
|
|
|
|
|
|
- batch.remove( p );
|
|
|
- batch.setAttribute( p, 'bold', true );
|
|
|
+ batch.remove( p );
|
|
|
+ batch.setAttribute( p, 'bold', true );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- editor.execute( 'redo' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ editor.execute( 'redo' );
|
|
|
|
|
|
- expect( p.root ).to.equal( gy );
|
|
|
- expect( p.getAttribute( 'bold' ) ).to.be.true;
|
|
|
- } );
|
|
|
+ expect( p.root ).to.equal( gy );
|
|
|
+ expect( p.getAttribute( 'bold' ) ).to.be.true;
|
|
|
+ } );
|
|
|
|
|
|
- // Related to ckeditor5-engine#891.
|
|
|
- it( 'change attribute of removed node then undo and redo', () => {
|
|
|
- const gy = doc.graveyard;
|
|
|
- const batch = doc.batch();
|
|
|
- const p1 = new Element( 'p' );
|
|
|
- const p2 = new Element( 'p' );
|
|
|
- const p3 = new Element( 'p' );
|
|
|
+ // Related to ckeditor5-engine#891.
|
|
|
+ it( 'change attribute of removed node then undo and redo', () => {
|
|
|
+ const gy = doc.graveyard;
|
|
|
+ const batch = doc.batch();
|
|
|
+ const p1 = new Element( 'p' );
|
|
|
+ const p2 = new Element( 'p' );
|
|
|
+ const p3 = new Element( 'p' );
|
|
|
|
|
|
- root.appendChildren( [ p1, p2 ] );
|
|
|
+ root.appendChildren( [ p1, p2 ] );
|
|
|
|
|
|
- batch.remove( p1 ).remove( p2 ).insert( new Position( root, [ 0 ] ), p3 );
|
|
|
+ batch.remove( p1 ).remove( p2 ).insert( new Position( root, [ 0 ] ), p3 );
|
|
|
|
|
|
- editor.execute( 'undo' );
|
|
|
- editor.execute( 'redo' );
|
|
|
+ editor.execute( 'undo' );
|
|
|
+ editor.execute( 'redo' );
|
|
|
|
|
|
- expect( p1.root ).to.equal( gy );
|
|
|
- expect( p2.root ).to.equal( gy );
|
|
|
- expect( p3.root ).to.equal( root );
|
|
|
- } );
|
|
|
+ expect( p1.root ).to.equal( gy );
|
|
|
+ expect( p2.root ).to.equal( gy );
|
|
|
+ expect( p3.root ).to.equal( root );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|