| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042 |
- 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( 'insert', () => {
- describe( 'by insert', () => {
- it( 'elements at same position #1', () => {
- john.setData( '[]<paragraph>Foo</paragraph>' );
- kate.setData( '[]<paragraph>Foo</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.insert( '<paragraph>Xyz</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Xyz</paragraph>' +
- '<paragraph>Foo</paragraph>'
- );
- } );
- it( 'elements at same position #2', () => {
- john.setData( '[]<paragraph>Foo</paragraph>' );
- kate.setData( '[]<paragraph>Foo</paragraph>' );
- kate.insert( '<paragraph>Xyz</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Xyz</paragraph>' +
- '<paragraph>Foo</paragraph>'
- );
- } );
- it( 'elements in same parent', () => {
- john.setData( '[]<paragraph>Foo</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[]' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.insert( '<paragraph>Xyz</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Foo</paragraph>' +
- '<paragraph>Xyz</paragraph>'
- );
- } );
- it( 'elements in same path', () => {
- john.setData( '[]<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
- kate.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.insert( '<paragraph>Xyz</paragraph>' );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<blockQuote>' +
- '<paragraph>Xyz</paragraph>' +
- '<paragraph>Foo</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'text at different paths', () => {
- john.setData( '<paragraph>Abc[]</paragraph><paragraph>Xyz</paragraph>' );
- kate.setData( '<paragraph>Abc</paragraph><paragraph>[]Xyz</paragraph>' );
- john.type( 'Foo' );
- kate.type( 'Bar' );
- syncClients();
- expectClients(
- '<paragraph>AbcFoo</paragraph>' +
- '<paragraph>BarXyz</paragraph>'
- );
- } );
- it( 'text, then wrap and undo', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '<paragraph>Foo[]</paragraph>' );
- john.type( 'Bar' );
- kate.type( 'Abc' );
- syncClients();
- john.setSelection( [ 0 ], [ 1 ] );
- john.wrap( 'blockQuote' );
- kate.undo();
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>FooBar</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'text, then insert element and merge', () => {
- john.setData( '<paragraph>[]</paragraph><paragraph>Abc</paragraph>' );
- kate.setData( '<paragraph>[]</paragraph><paragraph>Abc</paragraph>' );
- john.type( 'Foo' );
- kate.type( ' Bar' );
- syncClients();
- expectClients(
- '<paragraph>Foo Bar</paragraph>' +
- '<paragraph>Abc</paragraph>'
- );
- john.setSelection( [ 1 ] );
- kate.setSelection( [ 1 ] );
- john.insert( '<paragraph>Xyz</paragraph>' );
- kate.merge();
- syncClients();
- expectClients(
- '<paragraph>Foo BarAbc</paragraph>' +
- '<paragraph>Xyz</paragraph>'
- );
- } );
- it( 'text, then split and undo', () => {
- john.setData( '<paragraph>[]</paragraph>' );
- kate.setData( '<paragraph>[]</paragraph>' );
- john.type( 'Foo' );
- kate.type( ' Bar' );
- syncClients();
- john.setSelection( [ 0, 1 ] );
- kate.setSelection( [ 0, 4 ] );
- john.split();
- kate.split();
- syncClients();
- john.undo();
- kate.undo();
- syncClients();
- john.undo();
- kate.undo();
- syncClients();
- expectClients(
- '<paragraph></paragraph>'
- );
- } );
- } );
- describe( 'by move', () => {
- it( 'element at different paths #1', () => {
- john.setData( '[]<paragraph>Foo</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[ar]</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.move( [ 1, 0 ] );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Foo</paragraph>' +
- '<paragraph>arB</paragraph>'
- );
- } );
- it( 'element at different paths #2', () => {
- john.setData( '<blockQuote><paragraph>Foo</paragraph>[]</blockQuote><paragraph>Bar</paragraph>' );
- kate.setData( '<blockQuote><paragraph>Foo</paragraph></blockQuote><paragraph>B[ar]</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.move( [ 0, 0, 0 ] );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>arFoo</paragraph>' +
- '<paragraph>Abc</paragraph>' +
- '</blockQuote>' +
- '<paragraph>B</paragraph>'
- );
- } );
- it( 'text at same path', () => {
- john.setData( '<paragraph>F[]oo Bar</paragraph>' );
- kate.setData( '<paragraph>Foo B[ar]</paragraph>' );
- john.type( 'Abc' );
- kate.move( [ 0, 0 ] );
- syncClients();
- expectClients( '<paragraph>arFAbcoo B</paragraph>' );
- } );
- it( 'text at same position #1', () => {
- john.setData( '<paragraph>Foo[] Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.type( 'Abc' );
- kate.move( [ 0, 3 ] );
- syncClients();
- expectClients( '<paragraph>FooBarAbc </paragraph>' );
- } );
- it( 'text at same position #2', () => {
- john.setData( '<paragraph>Foo []Bar</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.type( 'Abc' );
- kate.move( [ 0, 0 ] );
- syncClients();
- expectClients( '<paragraph>BarFoo Abc</paragraph>' );
- } );
- } );
- describe( 'by wrap', () => {
- it( 'element in same path', () => {
- john.setData( '<paragraph>Foo Bar</paragraph>[]' );
- kate.setData( '[<paragraph>Foo Bar</paragraph>]' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo Bar</paragraph>' +
- '</blockQuote>' +
- '<paragraph>Abc</paragraph>'
- );
- } );
- it( 'element in same path', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.type( ' Bar' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo Bar</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'element in different paths', () => {
- john.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<paragraph>Foo</paragraph>' +
- '<paragraph>Abc</paragraph>' +
- '<blockQuote>' +
- '<paragraph>Bar</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'element in different paths', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>Bar[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- john.type( 'Abc' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo</paragraph>' +
- '</blockQuote>' +
- '<paragraph>BarAbc</paragraph>'
- );
- } );
- it( 'element, then unwrap and split', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.type( ' Bar' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients( '<blockQuote><paragraph>Foo Bar</paragraph></blockQuote>' );
- john.setSelection( [ 0, 0 ] );
- kate.setSelection( [ 0, 0, 2 ] );
- john.unwrap();
- kate.split();
- syncClients();
- expectClients(
- '<paragraph>Fo</paragraph>' +
- '<paragraph>o Bar</paragraph>'
- );
- } );
- it( 'element, then add marker and split', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.type( ' Bar' );
- kate.wrap( 'blockQuote' );
- syncClients();
- john.setSelection( [ 0, 0, 0 ], [ 0, 0, 3 ] );
- kate.setSelection( [ 0, 0, 2 ] );
- john.setMarker( 'm1' );
- kate.split();
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph><m1:start></m1:start>Fo</paragraph>' +
- '<paragraph>o<m1:end></m1:end> Bar</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'element, then insert element and unwrap', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.type( ' Bar' );
- kate.wrap( 'blockQuote' );
- syncClients();
- john.setSelection( [ 0, 0 ] );
- kate.setSelection( [ 0, 0 ] );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Foo Bar</paragraph>'
- );
- } );
- it( 'element, then split at the same position and undo', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.type( ' Bar' );
- kate.wrap( 'blockQuote' );
- syncClients();
- expectClients( '<blockQuote><paragraph>Foo Bar</paragraph></blockQuote>' );
- john.setSelection( [ 0, 0, 3 ] );
- kate.setSelection( [ 0, 0, 3 ] );
- john.split();
- kate.split();
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo</paragraph>' +
- '<paragraph> Bar</paragraph>' +
- '</blockQuote>'
- );
- kate.undo();
- syncClients();
- // Below is not the best result ever but it is acceptable.
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo Bar</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.type( 'Abc' );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph>FooAbc</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.type( ' Bar' );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph>Foo Bar</paragraph>'
- );
- } );
- it( 'element in same path #2', () => {
- john.setData( '<blockQuote><paragraph>Foo</paragraph>[]</blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.unwrap();
- syncClients();
- expectClients(
- '<paragraph>Foo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'element, then insert text and move', () => {
- john.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
- kate.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.unwrap();
- syncClients();
- expectClients( '<paragraph>Bar</paragraph><paragraph>Foo</paragraph>' );
- john.setSelection( [ 0, 0 ] );
- kate.setSelection( [ 0, 2 ], [ 0, 3 ] );
- john.type( 'Abc' );
- kate.move( [ 0, 0 ] );
- syncClients();
- expectClients(
- '<paragraph>rAbcBa</paragraph>' +
- '<paragraph>Foo</paragraph>'
- );
- } );
- it( 'element, then insert text and remove', () => {
- john.setData( '<blockQuote><paragraph>Foo</paragraph>[]</blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.unwrap();
- syncClients();
- john.setSelection( [ 0, 0 ] );
- kate.setSelection( [ 0, 0 ], [ 0, 3 ] );
- john.type( 'Abc' );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'element, then wrap and undo on both clients', () => {
- john.setData( '<blockQuote><paragraph>Foo</paragraph>[]</blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.unwrap();
- syncClients();
- kate.setSelection( [ 0 ], [ 1 ] );
- kate.wrap( 'blockQuote' );
- john.undo();
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo</paragraph>' +
- '</blockQuote>'
- );
- } );
- it( 'element, then wrap, unwrap and undo', () => {
- john.setData( '<blockQuote><paragraph>Foo[]</paragraph></blockQuote>' );
- kate.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
- john.type( ' Bar' );
- kate.unwrap();
- syncClients();
- expectClients( '<paragraph>Foo Bar</paragraph>' );
- john.setSelection( [ 0 ], [ 1 ] );
- john.wrap( 'blockQuote' );
- syncClients();
- expectClients( '<blockQuote><paragraph>Foo Bar</paragraph></blockQuote>' );
- john.undo();
- kate.setSelection( [ 0, 0 ], [ 0, 1 ] );
- kate.unwrap();
- syncClients();
- expectClients( '<paragraph>Foo Bar</paragraph>' );
- } );
- } );
- describe( 'by split', () => {
- it( 'text in same path #1', () => {
- john.setData( '<paragraph>Foo</paragraph>[]' );
- kate.setData( '<paragraph>F[]oo</paragraph>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>oo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'text in same path #2', () => {
- john.setData( '<paragraph>Fo[]o</paragraph>' );
- kate.setData( '<paragraph>F[]oo</paragraph>' );
- john.type( 'Bar' );
- kate.split();
- syncClients();
- expectClients( '<paragraph>F</paragraph><paragraph>oBaro</paragraph>' );
- } );
- it( 'text in different paths #1', () => {
- john.setData( '[]<paragraph>Foo</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[]ar</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Foo</paragraph>' +
- '<paragraph>B</paragraph>' +
- '<paragraph>ar</paragraph>'
- );
- } );
- it( 'text in different paths #2', () => {
- john.setData( '<paragraph>Foo[]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[]ar</paragraph>' );
- john.type( 'Abc' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph>FooAbc</paragraph>' +
- '<paragraph>B</paragraph>' +
- '<paragraph>ar</paragraph>'
- );
- } );
- it( 'text at same position', () => {
- john.setData( '<paragraph>F[]oo</paragraph>' );
- kate.setData( '<paragraph>F[]oo</paragraph>' );
- john.type( 'Bar' );
- kate.split();
- syncClients();
- expectClients( '<paragraph>FBar</paragraph><paragraph>oo</paragraph>' );
- } );
- it( 'text at same position #2', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '<paragraph>Foo[]</paragraph>' );
- john.type( 'Bar' );
- kate.split();
- syncClients();
- expectClients( '<paragraph>FooBar</paragraph><paragraph></paragraph>' );
- } );
- it( 'text, then insert element and split', () => {
- john.setData( '<paragraph>[]Foo</paragraph>' );
- kate.setData( '<paragraph>F[]oo</paragraph>' );
- john.type( 'Bar' );
- kate.split();
- syncClients();
- john.setSelection( [ 1 ] );
- kate.setSelection( [ 1, 1 ] );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph>BarF</paragraph>' +
- '<paragraph>Abc</paragraph>' +
- '<paragraph>o</paragraph>' +
- '<paragraph>o</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.type( 'Abc' );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph>FooAbc</paragraph><paragraph></paragraph>'
- );
- } );
- it( 'text in same path', () => {
- john.setData( '<paragraph>Foo[]</paragraph>' );
- kate.setData( '<paragraph>[Foo]</paragraph>' );
- john.type( 'Bar' );
- kate.remove();
- syncClients();
- expectClients(
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'element in different path', () => {
- john.setData( '<paragraph>Foo[]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );
- john.type( 'Abc' );
- kate.remove();
- syncClients();
- expectClients( '<paragraph>FooAbc</paragraph>' );
- } );
- it( 'element in same path', () => {
- john.setData( '<paragraph>Foo[]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );
- john.type( 'Abc' );
- kate.remove();
- syncClients();
- expectClients( '<paragraph>Bar</paragraph>' );
- } );
- it( 'text, then rename, split and undo', () => {
- john.setData( '<paragraph>Foo Bar[]</paragraph>' );
- kate.setData( '<paragraph>Foo [Bar]</paragraph>' );
- john.type( 'Bar' );
- kate.remove();
- syncClients();
- expectClients( '<paragraph>Foo Bar</paragraph>' );
- john.setSelection( [ 0, 0 ] );
- kate.setSelection( [ 0, 4 ] );
- john.rename( 'heading1' );
- kate.split();
- syncClients();
- expectClients( '<heading1>Foo </heading1><heading1>Bar</heading1>' );
- kate.undo();
- syncClients();
- expectClients( '<heading1>Foo Bar</heading1>' );
- } );
- it( 'element, then add marker, split and undo with type #1', () => {
- john.setData( '<paragraph>Foo</paragraph>[]' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.remove();
- syncClients();
- expectClients( '<paragraph>Bar</paragraph><paragraph></paragraph>' ); // Autoparagraphing.
- john.setSelection( [ 0, 0 ], [ 0, 3 ] );
- kate.setSelection( [ 0, 2 ] );
- john.setMarker( 'm1' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph><m1:start></m1:start>Ba</paragraph>' +
- '<paragraph>r<m1:end></m1:end></paragraph>' +
- '<paragraph></paragraph>'
- );
- john.undo();
- john.setSelection( [ 1, 1 ] );
- john.type( 'Abc' );
- kate.undo();
- syncClients();
- expectClients( '<paragraph>BarAbc</paragraph><paragraph></paragraph>' );
- kate.undo();
- syncClients();
- expectClients( '<paragraph>Foo</paragraph><paragraph>BarAbc</paragraph>' );
- } );
- it( 'element, then add marker, split and undo with type #2', () => {
- john.setData( '<paragraph>Foo</paragraph>[]' );
- kate.setData( '[<paragraph>Foo</paragraph>]' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.remove();
- syncClients();
- expectClients( '<paragraph>Bar</paragraph><paragraph></paragraph>' ); // Autoparagraphing.
- john.setSelection( [ 0, 0 ], [ 0, 3 ] );
- kate.setSelection( [ 0, 2 ] );
- john.setMarker( 'm1' );
- kate.split();
- syncClients();
- expectClients(
- '<paragraph><m1:start></m1:start>Ba</paragraph>' +
- '<paragraph>r<m1:end></m1:end></paragraph>' +
- '<paragraph></paragraph>'
- );
- john.undo();
- john.setSelection( [ 1, 1 ] );
- john.type( 'Abc' );
- kate.undo();
- kate.undo();
- syncClients();
- expectClients( '<paragraph>Foo</paragraph><paragraph>BarAbc</paragraph>' );
- } );
- } );
- describe( 'by merge', () => {
- it( 'element into paragraph', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>[]</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[]<paragraph></paragraph>' );
- john.type( ' Bar' );
- kate.merge();
- syncClients();
- expectClients(
- '<paragraph>Foo Bar</paragraph>'
- );
- } );
- } );
- describe( 'by marker', () => {
- it( 'in different path #1', () => {
- john.setData( '[]<paragraph>Foo</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>Abc</paragraph>' +
- '<paragraph>Foo</paragraph>' +
- '<paragraph><m1:start></m1:start>Bar<m1:end></m1:end></paragraph>'
- );
- } );
- it( 'in different path #2', () => {
- john.setData( '<paragraph>Foo[]</paragraph><paragraph>Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
- john.type( 'Abc' );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>FooAbc</paragraph>' +
- '<paragraph><m1:start></m1:start>Bar<m1:end></m1:end></paragraph>'
- );
- } );
- it( 'in same path', () => {
- john.setData( '<paragraph>[]Foo</paragraph>' );
- kate.setData( '<paragraph>Fo[o]</paragraph>' );
- john.type( 'Bar' );
- kate.setMarker( 'm1' );
- syncClients();
- expectClients(
- '<paragraph>BarFo<m1:start></m1:start>o<m1:end></m1:end></paragraph>'
- );
- } );
- } );
- // This should be moved to attribute.js.
- 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.type( 'Abc' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>AbcFoo</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.type( 'Abc' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>AbcFoo</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.type( 'Bar' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>BarFoo</paragraph>' );
- } );
- it( 'from element in same path', () => {
- john.setData( '<paragraph bold="true">[]Foo</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.type( 'Bar' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>BarFoo</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.type( 'Bar' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>BarFo<$text italic="true">o</$text></paragraph>'
- );
- } );
- } );
- describe( 'by rename', () => {
- it( 'element in different path', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph>[]' );
- kate.setData( '<paragraph>F[]oo</paragraph><paragraph>Bar</paragraph>' );
- john.insert( '<paragraph>Abc</paragraph>' );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<heading1>Foo</heading1>' +
- '<paragraph>Bar</paragraph>' +
- '<paragraph>Abc</paragraph>'
- );
- } );
- it( 'element in same path', () => {
- john.setData( '<paragraph>Foo</paragraph>[]' );
- kate.setData( '<paragraph>F[]oo</paragraph>' );
- john.insert( '<paragraph>Bar</paragraph>' );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<heading1>Foo</heading1>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'text in same path', () => {
- john.setData( '<paragraph>Foo[] Bar</paragraph>' );
- kate.setData( '<paragraph>F[]oo Bar</paragraph>' );
- john.type( 'Abc' );
- kate.rename( 'heading1' );
- syncClients();
- expectClients( '<heading1>FooAbc Bar</heading1>' );
- } );
- it( 'text in different paths', () => {
- john.setData( '<blockQuote><paragraph>Foo</paragraph></blockQuote><paragraph>B[]ar</paragraph>' );
- kate.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote><paragraph>Bar</paragraph>' );
- john.type( 'Abc' );
- kate.rename( 'heading1' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<heading1>Foo</heading1>' +
- '</blockQuote>' +
- '<paragraph>BAbcar</paragraph>'
- );
- } );
- } );
- } );
- } );
|