| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- import { Client, syncClients, expectClients } from './utils.js';
- describe( 'transform', () => {
- let john, kate;
- beforeEach( () => {
- return Promise.all( [
- Client.get( 'john' ).then( client => ( john = client ) ),
- Client.get( 'kate' ).then( client => ( kate = client ) )
- ] );
- } );
- afterEach( () => {
- return Promise.all( [ john.destroy(), kate.destroy() ] );
- } );
- describe( 'attribute', () => {
- describe( 'by attribute', () => {
- it( 'in text at same path', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foo</$text> <$text italic="true">Bar</$text></paragraph>' );
- } );
- it( 'in text at same path, then undo', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foo</$text> <$text italic="true">Bar</$text></paragraph>' );
- john.undo();
- syncClients();
- expectClients( '<paragraph>Foo <$text italic="true">Bar</$text></paragraph>' );
- } );
- it( 'in text in different path', () => {
- john.setData( '<paragraph>F[o]o</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[a]r</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients(
- '<paragraph>F<$text bold="true">o</$text>o</paragraph>' +
- '<paragraph>B<$text italic="true">a</$text>r</paragraph>'
- );
- } );
- it( 'in text with selection inside other client\'s selection #1', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>Fo[o B]ar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients(
- '<paragraph>' +
- '<$text bold="true">Fo</$text><$text bold="true" italic="true">o B</$text><$text bold="true">ar</$text>' +
- '</paragraph>'
- );
- } );
- it( 'in text with selection inside other client\'s selection #2', () => {
- john.setData( '<paragraph>F[oo Ba]r</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients(
- '<paragraph>' +
- 'F' +
- '<$text bold="true">oo </$text>' +
- '<$text bold="true" italic="true">Ba</$text>' +
- '<$text italic="true">r</$text>' +
- '</paragraph>'
- );
- } );
- it( 'in text with selection inside other client\'s selection #3', () => {
- john.setData( '<paragraph><$text bold="true">[Foo Bar]</$text></paragraph>' );
- kate.setData( '<paragraph><$text bold="true">Fo[o] Bar</$text></paragraph>' );
- john.setAttribute( 'italic', true );
- kate.setAttribute( 'underline', true );
- syncClients();
- expectClients(
- '<paragraph>' +
- '<$text bold="true" italic="true">Fo</$text>' +
- '<$text bold="true" italic="true" underline="true">o</$text>' +
- '<$text bold="true" italic="true"> Bar</$text>' +
- '</paragraph>'
- );
- } );
- it( 'in text at same position', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>[Foo Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients( '<paragraph><$text bold="true" italic="true">Foo Bar</$text></paragraph>' );
- } );
- it( 'in element at same position', () => {
- john.setData( '[<paragraph>Foo Bar</paragraph>]' );
- kate.setData( '[<paragraph>Foo Bar</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients( '<paragraph bold="true" italic="true">Foo Bar</paragraph>' );
- } );
- it( 'in collapsed selection', () => {
- john.setData( '<paragraph>F[]oo Bar</paragraph>' );
- kate.setData( '<paragraph>F[]oo Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setAttribute( 'italic', true );
- syncClients();
- expectClients( '<paragraph>Foo Bar</paragraph>' );
- } );
- it( 'in same range, then change attribute', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>[Foo Bar]</paragraph>' );
- john.setAttribute( 'attr', 'foo' );
- kate.setAttribute( 'attr', 'bar' );
- syncClients();
- expectClients( '<paragraph><$text attr="foo">Foo Bar</$text></paragraph>' );
- kate.setAttribute( 'attr', 'bar' );
- syncClients();
- expectClients( '<paragraph><$text attr="bar">Foo Bar</$text></paragraph>' );
- } );
- } );
- describe( 'by insert', () => {
- it( 'text in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>[]Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'Abc' );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foo</$text></paragraph><paragraph>AbcBar</paragraph>' );
- } );
- it( 'text in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>[]Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'Abc' );
- syncClients();
- expectClients( '<paragraph bold="true">Foo</paragraph><paragraph>AbcBar</paragraph>' );
- } );
- it( 'text at same path', () => {
- john.setData( '<paragraph>[F]oo</paragraph>' );
- kate.setData( '<paragraph>Foo[]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'Abc' );
- syncClients();
- expectClients( '<paragraph><$text bold="true">F</$text>ooAbc</paragraph>' );
- } );
- it( 'text inside other client\'s selection', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>Fo[]o</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'Abc' );
- syncClients();
- expectClients( '<paragraph><$text bold="true">FoAbco</$text></paragraph>' );
- } );
- it( 'element between changed elements', () => {
- john.setData( '[<paragraph>Foo</paragraph><paragraph>Bar</paragraph>]' );
- kate.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.insert( '<paragraph>Abc</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<paragraph>Abc</paragraph>' +
- '<paragraph bold="true">Bar</paragraph>'
- );
- } );
- it( 'element in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph>[]' );
- john.setAttribute( 'bold', true );
- kate.insert( '<paragraph>Abc</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>Bar</paragraph>' +
- '<paragraph>Abc</paragraph>'
- );
- } );
- it( 'element in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph>[]' );
- john.setAttribute( 'bold', true );
- kate.insert( '<paragraph>Abc</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<paragraph>Bar</paragraph>' +
- '<paragraph>Abc</paragraph>'
- );
- } );
- } );
- describe( 'by move', () => {
- it( 'text in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[ar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 1, 0 ] );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>arB</paragraph>'
- );
- } );
- it( 'text in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[ar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 1, 0 ] );
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<paragraph>arB</paragraph>'
- );
- } );
- it( 'text in same path', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo B[ar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 0, 4 ] );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foo</$text> arB</paragraph>' );
- } );
- it( 'text to other client\'s selection', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 0, 1 ] );
- syncClients();
- expectClients( '<paragraph><$text bold="true">F</$text>Bar<$text bold="true">oo</$text> </paragraph>' );
- } );
- it( 'text from other client\'s selection', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>F[oo] Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 0, 7 ], [ 0, 1 ], [ 0, 3 ] );
- syncClients();
- expectClients( '<paragraph><$text bold="true">F</$text> Bar<$text bold="true">oo</$text></paragraph>' );
- } );
- it( 'text from other client\'s selection #2', () => {
- john.setData( '[<paragraph>Foo Bar</paragraph>]' );
- kate.setData( '<paragraph>F[oo] Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.move( [ 0, 7 ] );
- syncClients();
- expectClients( '<paragraph bold="true">F Baroo</paragraph>' );
- } );
- } );
- describe( 'by wrap', () => {
- it( 'element into blockQuote in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<blockQuote><paragraph>Bar</paragraph></blockQuote>'
- );
- } );
- it( 'element into blockQuote in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<blockQuote><paragraph>Bar</paragraph></blockQuote>'
- );
- } );
- it( 'element into blockQuote in same path #1', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'element into blockQuote in same path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph bold="true">Foo</paragraph>' +
- '</blockQuote>'
- );
- } );
- } );
- describe( 'by unwrap', () => {
- it( 'element in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
- kate.setData( '<paragraph>Foo</paragraph><blockQuote>[<paragraph>Bar</paragraph>]</blockQuote>' );
- john.setAttribute( 'bold', true );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'element in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<blockQuote><paragraph>Bar</paragraph></blockQuote>' );
- kate.setData( '<paragraph>Foo</paragraph><blockQuote>[<paragraph>Bar</paragraph>]</blockQuote>' );
- john.setAttribute( 'bold', true );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'element in same path #1', () => {
- john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- john.setAttribute( 'bold', true );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>'
- );
- } );
- it( 'element in same path #2', () => {
- john.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- john.setAttribute( 'bold', true );
- kate.unwrap();
- syncClients();
- expectClients( '<paragraph bold="true">Foo</paragraph>' );
- } );
- } );
- describe( 'by split', () => {
- it( 'text in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>Ba[]r</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>Ba</paragraph>' +
- '<paragraph>r</paragraph>'
- );
- } );
- it( 'text in different path #2', () => {
- john.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>Ba[]r</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo</paragraph>' +
- '<paragraph>Ba</paragraph>' +
- '<paragraph>r</paragraph>'
- );
- } );
- it( 'text in same path #1', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo B[]ar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text> B</paragraph>' +
- '<paragraph>ar</paragraph>'
- );
- } );
- it( 'text in other user\'s selection', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>Fo[]o</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.split();
- syncClients();
- expect(
- '<paragraph><$text bold="true">Fo</$text></paragraph>' +
- '<paragraph><$text bold="true">o</$text></paragraph>'
- );
- } );
- it( 'text in other user\'s selection #2', () => {
- john.setData( '[<paragraph>Foo Bar</paragraph>]' );
- kate.setData( '<paragraph>Foo B[]ar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph bold="true">Foo B</paragraph>' +
- '<paragraph bold="true">ar</paragraph>'
- );
- } );
- it( 'text while changing attribute', () => {
- john.setData( '<paragraph><$text attr="foo">Foo B[ar]</$text></paragraph>' );
- kate.setData( '<paragraph><$text attr="foo">Foo B[]ar</$text></paragraph>' );
- john.setAttribute( 'attr', 'bar' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph><$text attr="foo">Foo B</$text></paragraph>' +
- '<paragraph><$text attr="bar">ar</$text></paragraph>'
- );
- } );
- } );
- describe( 'by remove', () => {
- it( 'text in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph></paragraph>'
- );
- } );
- it( 'text in same path', () => {
- john.setData( '<paragraph>[Fo]o</paragraph>' );
- kate.setData( '<paragraph>Fo[o]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Fo</$text></paragraph>'
- );
- } );
- it( 'text in other user\'s selection', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>F[oo]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">F</$text></paragraph>'
- );
- } );
- } );
- describe( 'by remove attribute', () => {
- it( 'from element in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph bold="true">Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );
- john.setAttribute( 'bold', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'from text in different path', () => {
- john.setData( '<paragraph>[Foo]</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.setAttribute( 'bold', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'from text in same path', () => {
- john.setData( '<paragraph>[Fo]<$text bold="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
- john.setAttribute( 'bold', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Fo</$text>o</paragraph>'
- );
- } );
- it( 'from element in same path', () => {
- john.setData( '<paragraph bold="true">[Fo]o</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.setAttribute( 'italic', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><$text italic="true">Fo</$text>o</paragraph>' );
- } );
- it( 'from text with 2 attributes in same path', () => {
- john.setData( '<paragraph>[Fo]<$text bold="true" italic="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[o]</$text></paragraph>' );
- john.setAttribute( 'bold', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Fo</$text><$text italic="true">o</$text></paragraph>'
- );
- } );
- it( 'from text in other user\'s selection', () => {
- john.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph>' );
- kate.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph>' );
- john.setAttribute( 'italic', true );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><$text italic="true">Foo</$text></paragraph>'
- );
- } );
- } );
- describe( 'by marker', () => {
- it( 'in text at same path', () => {
- john.setData( '<paragraph>[Foo] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foo</$text> <m1:start></m1:start>Bar<m1:end></m1:end></paragraph>' );
- } );
- it( 'in text at same path #2', () => {
- john.setData( '[<paragraph>Foo Bar</paragraph>]' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph bold="true">' +
- 'Foo <m1:start></m1:start>Bar<m1:end></m1:end>' +
- '</paragraph>'
- );
- } );
- it( 'in text in different path', () => {
- john.setData( '<paragraph>F[o]o</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[a]r</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>F<$text bold="true">o</$text>o</paragraph>' +
- '<paragraph>B<m1:start></m1:start>a<m1:end></m1:end>r</paragraph>'
- );
- } );
- it( 'in text with selection inside other client\'s selection #1', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>Fo[o B]ar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>' +
- '<$text bold="true">Fo</$text><m1:start></m1:start>' +
- '<$text bold="true">o B</$text><m1:end></m1:end><$text bold="true">ar</$text>' +
- '</paragraph>'
- );
- } );
- it( 'in text with selection inside other client\'s selection #2', () => {
- john.setData( '<paragraph>F[oo Ba]r</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>' +
- 'F<$text bold="true">oo </$text><m1:start></m1:start><$text bold="true">Ba</$text>r<m1:end></m1:end>' +
- '</paragraph>'
- );
- } );
- it( 'in text at same position', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>[Foo Bar]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients( '<paragraph><m1:start></m1:start><$text bold="true">Foo Bar</$text><m1:end></m1:end></paragraph>' );
- } );
- } );
- describe( 'by merge', () => {
- it( 'element into paragraph #1', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>B[ar]</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph>' );
- john.setAttribute( 'bold', 'true' );
- kate.merge();
- syncClients();
- expectClients( '<paragraph>FooB<$text bold="true">ar</$text></paragraph>' );
- } );
- it( 'element into paragraph #2, then undo', () => {
- john.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
- kate.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph>' );
- john.setAttribute( 'bold', 'true' );
- kate.merge();
- syncClients();
- expectClients( '<paragraph>FooBar</paragraph>' );
- kate.undo();
- syncClients();
- expectClients( '<paragraph>Foo</paragraph><paragraph bold="true">Bar</paragraph>' );
- } );
- } );
- } );
- describe( 'by rename', () => {
- it( 'element in different path', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>[Ba]r</paragraph>' );
- kate.setData( '<paragraph>F[]oo</paragraph><paragraph>Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<heading1>Foo</heading1>' +
- '<paragraph><$text bold="true">Ba</$text>r</paragraph>'
- );
- } );
- it( 'element in same path', () => {
- john.setData( '<paragraph>[Foo Bar]</paragraph>' );
- kate.setData( '<paragraph>[]Foo Bar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<heading1><$text bold="true">Foo Bar</$text></heading1>'
- );
- } );
- it( 'element in user\'s selection', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>[Foo]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<heading1><$text bold="true">Foo</$text></heading1>'
- );
- } );
- it( 'element in user\'s selection, then undo', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>[Foo]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.rename( 'heading1' );
- syncClients();
- john.undo();
- kate.undo();
- syncClients();
- expectClients(
- '<paragraph>Foo</paragraph>'
- );
- } );
- } );
- } );
|