| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616 |
- /**
- * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- import { Client, syncClients, expectClients, clearBuffer } 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( () => {
- clearBuffer();
- 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>' );
- } );
- // https://github.com/ckeditor/ckeditor5/issues/6265
- it( 'on elements on different but intersecting "levels"', () => {
- john.setData( '[<table><tableRow><tableCell><paragraph>Foo</paragraph></tableCell></tableRow></table>]' );
- kate.setData( '<table><tableRow>[<tableCell><paragraph>Foo</paragraph></tableCell>]</tableRow></table>' );
- john.setAttribute( 'attr', 'foo' );
- kate.setAttribute( 'attr', 'bar' );
- syncClients();
- expectClients(
- '<table attr="foo"><tableRow><tableCell attr="bar"><paragraph>Foo</paragraph></tableCell></tableRow></table>'
- );
- } );
- } );
- 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( 'text between changed nodes', () => {
- john.setData( '<paragraph>[Foo</paragraph><paragraph>Bar]</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph>B[]ar</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'Abc' );
- syncClients();
- expectClients(
- '<paragraph><$text bold="true">Foo</$text></paragraph>' +
- '<paragraph><$text bold="true">BAbcar</$text></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>'
- );
- } );
- it( 'remove attribute 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( 'remove attribute 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( 'remove attribute from text while typing in client\'s range', () => {
- john.setData( '<paragraph>F<$text bold="true">o[]o</$text></paragraph>' );
- kate.setData( '<paragraph>F<$text bold="true">[oo]</$text></paragraph>' );
- john.type( 'Bar' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>FoBaro</paragraph>' );
- } );
- it( 'remove attribute 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( 'remove attribute from text with 2 attributes while typing in client\'s range', () => {
- john.setData( '<paragraph>F<$text bold="true" italic="true">o[]o</$text></paragraph>' );
- kate.setData( '<paragraph>F<$text bold="true" italic="true">[oo]</$text></paragraph>' );
- john.type( 'Bar', john.document.selection.getAttributes() );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>F<$text italic="true">oBaro</$text></paragraph>' );
- } );
- it( 'multiple typing', () => {
- john.setData( '<paragraph>[Foo]</paragraph>' );
- kate.setData( '<paragraph>Fo[]o</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.setSelection( [ 0, 2 ] );
- kate.type( 'x' );
- kate.setSelection( [ 0, 3 ] );
- kate.type( 'x' );
- kate.setSelection( [ 0, 4 ] );
- kate.type( 'x' );
- syncClients();
- expectClients( '<paragraph><$text bold="true">Foxxxo</$text></paragraph>' );
- } );
- it( 'type inside element which attribute changes', () => {
- john.setData( '[<paragraph></paragraph>]' );
- kate.setData( '<paragraph>[]</paragraph>' );
- john.setAttribute( 'bold', true );
- kate.type( 'x' );
- syncClients();
- expectClients( '<paragraph bold="true">x</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 ] );
- 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>' );
- } );
- it( 'remove attribute from element in different path', () => {
- john.setData( '<paragraph>F[oo]</paragraph><paragraph bold="true">Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );
- john.move( [ 1, 0 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>ooBar</paragraph>'
- );
- } );
- it( 'remove attribute from text in different path', () => {
- john.setData( '<paragraph>F[oo]</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.move( [ 1, 0 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>ooBar</paragraph>'
- );
- } );
- it( 'remove attribute 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.move( [ 0, 3 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>oFo</paragraph>' );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '<paragraph bold="true">[Fo]o</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.move( [ 0, 3 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>oFo</paragraph>' );
- } );
- it( 'remove attribute 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.move( [ 0, 3 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><$text italic="true">o</$text>Fo</paragraph>' );
- } );
- it( 'remove attribute from text in other user\'s selection', () => {
- john.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph><paragraph></paragraph>' );
- kate.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph><paragraph></paragraph>' );
- john.move( [ 1, 0 ] );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph></paragraph>' +
- '<paragraph>Foo</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>'
- );
- } );
- it( 'remove attribute 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.wrap( 'blockQuote' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo</paragraph>' +
- '</blockQuote>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute 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.wrap( 'blockQuote' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Foo</paragraph>' +
- '</blockQuote>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute 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.wrap( 'blockQuote' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.wrap( 'blockQuote' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
- } );
- it( 'remove attribute 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.wrap( 'blockQuote' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<blockQuote>' +
- '<paragraph>Fo<$text italic="true">o</$text></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( 'text 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>' +
- '<blockQuote>Bar</blockQuote>'
- );
- } );
- 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>' );
- } );
- it( 'text in same path', () => {
- john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
- kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );
- john.setAttribute( 'bold', true );
- kate.unwrap();
- syncClients();
- expectClients( '<blockQuote><$text bold="true">Foo</$text></blockQuote>' );
- } );
- it( 'remove attribute from element in different path', () => {
- john.setData(
- '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' +
- '<paragraph bold="true">Bar</paragraph>' );
- kate.setData(
- '<blockQuote><paragraph>Foo</paragraph></blockQuote>' +
- '[<paragraph bold="true">Bar</paragraph>]' );
- john.unwrap();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>Foo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in different path', () => {
- john.setData(
- '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' +
- '<paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData(
- '<blockQuote><paragraph>Foo</paragraph></blockQuote>' +
- '<paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.unwrap();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<blockQuote>Foo</blockQuote>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in same path', () => {
- john.setData( '<blockQuote><paragraph>[]Fo<$text bold="true">o</$text></paragraph></blockQuote>' );
- kate.setData( '<blockQuote><paragraph>Fo<$text bold="true">[o]</$text></paragraph></blockQuote>' );
- john.unwrap();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<blockQuote>Foo</blockQuote>' );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '<blockQuote><paragraph bold="true">[]Foo</paragraph></blockQuote>' );
- kate.setData( '<blockQuote>[<paragraph bold="true">Foo</paragraph>]</blockQuote>' );
- john.unwrap();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<blockQuote>Foo</blockQuote>' );
- } );
- it( 'remove attribute from text with 2 attributes in same path', () => {
- john.setData( '<blockQuote><paragraph>[]Fo<$text bold="true" italic="true">o</$text></paragraph></blockQuote>' );
- kate.setData( '<blockQuote><paragraph>Fo<$text bold="true" italic="true">[o]</$text></paragraph></blockQuote>' );
- john.unwrap();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<blockQuote>Fo<$text italic="true">o</$text></blockQuote>' );
- } );
- } );
- 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>'
- );
- } );
- it( 'remove attribute from element in different path', () => {
- john.setData( '<paragraph>F[]oo</paragraph><paragraph bold="true">Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>oo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in different path', () => {
- john.setData( '<paragraph>F[]oo</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>oo</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in same path #1', () => {
- john.setData( '<paragraph>F[]o<$text bold="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>oo</paragraph>' );
- } );
- it( 'remove attribute from text in same path #2', () => {
- john.setData( '<paragraph>F<$text bold="true">o[]o</$text></paragraph>' );
- kate.setData( '<paragraph>F<$text bold="true">[oo]</$text></paragraph>' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>Fo</paragraph>' +
- '<paragraph>o</paragraph>' );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '<paragraph bold="true">F[]oo</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>oo</paragraph>' );
- } );
- it( 'remove attribute from text with 2 attributes in same path', () => {
- john.setData( '<paragraph>F<$text bold="true" italic="true">o[]o</$text></paragraph>' );
- kate.setData( '<paragraph>F<$text bold="true" italic="true">[oo]</$text></paragraph>' );
- john.split();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F<$text italic="true">o</$text></paragraph>' +
- '<paragraph><$text italic="true">o</$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>' );
- } );
- it( 'remove attribute from element in different path', () => {
- john.setData( '<paragraph>F[oo]</paragraph><paragraph bold="true">Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in different path', () => {
- john.setData( '<paragraph>F[oo]</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F</paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in same path #1', () => {
- john.setData( '<paragraph>[Fo]<$text bold="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>o</paragraph>' );
- } );
- it( 'remove attribute from text in same path #2', () => {
- john.setData( '<paragraph>F[o<$text bold="true">o]z</$text>Bar</paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[oz]</$text>Bar</paragraph>' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>FzBar</paragraph>'
- );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '<paragraph bold="true">[Fo]o</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph>o</paragraph>' );
- } );
- it( 'remove attribute from text with 2 attributes in same path #1', () => {
- 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.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><$text italic="true">o</$text></paragraph>' );
- } );
- it( 'remove attribute from text with 2 attributes in same path #2', () => {
- john.setData( '<paragraph>F[o<$text bold="true" italic="true">o]z</$text>Bar</paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[oz]</$text>Bar</paragraph>' );
- john.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph>F<$text italic="true">z</$text>Bar</paragraph>'
- );
- } );
- it( 'remove attribute 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.remove();
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph></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>' );
- } );
- it( 'remove attribute 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.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><m1:start></m1:start>Foo<m1:end></m1:end></paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute 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.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<paragraph><m1:start></m1:start>Foo<m1:end></m1:end></paragraph>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute 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.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><m1:start></m1:start>Fo<m1:end></m1:end>o</paragraph>' );
- } );
- it( 'remove attribute from text in same path, then undo', () => {
- john.setData( '<paragraph>[Fo]<$text bold="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
- john.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- kate.undo();
- syncClients();
- expectClients( '<paragraph><m1:start></m1:start>Fo<m1:end></m1:end><$text bold="true">o</$text></paragraph>' );
- } );
- it( 'remove attribute 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.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><m1:start></m1:start>Fo<m1:end></m1:end><$text italic="true">o</$text></paragraph>' );
- } );
- it( 'remove attribute 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.setMarker( 'm1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<paragraph><m1:start></m1:start>Foo<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>' );
- } );
- it( 'element in same path', () => {
- john.setData( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph>[<paragraph>Baz</paragraph>]' );
- kate.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph><paragraph>Baz</paragraph>' );
- john.setAttribute( 'bold', 'true' );
- kate.merge();
- syncClients();
- expectClients( '<paragraph>FooBar</paragraph><paragraph bold="true">Baz</paragraph>' );
- kate.undo();
- john.undo();
- syncClients();
- expectClients( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph><paragraph>Baz</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>' );
- } );
- it( 'remove attribute from element in different path', () => {
- john.setData( '<paragraph>F[]oo</paragraph><paragraph bold="true">Bar</paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );
- john.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<heading1>Foo</heading1>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in different path', () => {
- john.setData( '<paragraph>F[]oo</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
- kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );
- john.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients(
- '<heading1>Foo</heading1>' +
- '<paragraph>Bar</paragraph>'
- );
- } );
- it( 'remove attribute from text in same path', () => {
- john.setData( '<paragraph>F[]o<$text bold="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
- john.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<heading1>Foo</heading1>' );
- } );
- it( 'remove attribute from element in same path', () => {
- john.setData( '<paragraph bold="true">F[]oo</paragraph>' );
- kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
- john.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<heading1>Foo</heading1>' );
- } );
- it( 'remove attribute from text with 2 attributes in same path', () => {
- john.setData( '<paragraph>F[o]<$text bold="true" italic="true">o</$text></paragraph>' );
- kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[o]</$text></paragraph>' );
- john.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<heading1>Fo<$text italic="true">o</$text></heading1>' );
- } );
- it( 'remove attribute 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.rename( 'heading1' );
- kate.removeAttribute( 'bold' );
- syncClients();
- expectClients( '<heading1>Foo</heading1>' );
- } );
- } );
- } );
|