| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246 |
- /**
- * @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 VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
- import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
- import Typing from '@ckeditor/ckeditor5-typing/src/typing';
- import UndoEditing from '@ckeditor/ckeditor5-undo/src/undoediting';
- import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
- import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
- import ListStyleEditing from '../src/liststyleediting';
- import TodoListEditing from '../src/todolistediting';
- import ListStyleCommand from '../src/liststylecommand';
- describe( 'ListStyleEditing', () => {
- let editor, model, view;
- beforeEach( () => {
- return VirtualTestEditor
- .create( {
- plugins: [ Paragraph, ListStyleEditing, UndoEditing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- view = editor.editing.view;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- it( 'should have pluginName', () => {
- expect( ListStyleEditing.pluginName ).to.equal( 'ListStyleEditing' );
- } );
- it( 'should be loaded', () => {
- expect( editor.plugins.get( ListStyleEditing ) ).to.be.instanceOf( ListStyleEditing );
- } );
- describe( 'schema rules', () => {
- it( 'should allow set `listStyle` on the `listItem`', () => {
- expect( model.schema.checkAttribute( [ '$root', 'listItem' ], 'listStyle' ) ).to.be.true;
- } );
- } );
- describe( 'command', () => {
- it( 'should register listStyle command', () => {
- const command = editor.commands.get( 'listStyle' );
- expect( command ).to.be.instanceOf( ListStyleCommand );
- } );
- } );
- describe( 'conversion in data pipeline', () => {
- describe( 'model to data', () => {
- it( 'should convert single list (type: bulleted)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listType="bulleted">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ul><li>Foo</li><li>Bar</li></ul>' );
- } );
- it( 'should convert single list (type: numbered)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listType="numbered">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ol><li>Foo</li><li>Bar</li></ol>' );
- } );
- it( 'should convert single list (type: bulleted, style: default)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="default">Foo</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="default">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ul><li>Foo</li><li>Bar</li></ul>' );
- } );
- it( 'should convert single list (type: numbered, style: default)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered" listStyle="default">Foo</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="default">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ol><li>Foo</li><li>Bar</li></ol>' );
- } );
- it( 'should convert single list (type: bulleted, style: circle)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ul style="list-style-type:circle;"><li>Foo</li><li>Bar</li></ul>' );
- } );
- it( 'should convert single list (type: numbered, style: upper-alpha)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered" listStyle="upper-alpha">Foo</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="upper-alpha">Bar</listItem>'
- );
- expect( editor.getData() ).to.equal( '<ol style="list-style-type:upper-alpha;"><li>Foo</li><li>Bar</li></ol>' );
- } );
- it( 'should convert nested bulleted lists (main: circle, nested: disc)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 1</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="disc">Bar 1</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="disc">Bar 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 3</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ul style="list-style-type:circle;">' +
- '<li>Foo 1' +
- '<ul style="list-style-type:disc;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ul>' +
- '</li>' +
- '<li>Foo 2</li>' +
- '<li>Foo 3</li>' +
- '</ul>'
- );
- } );
- it( 'should convert nested numbered lists (main: decimal-leading-zero, nested: lower-latin)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered" listStyle="decimal-leading-zero">Foo 1</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="lower-latin">Bar 1</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="lower-latin">Bar 2</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="decimal-leading-zero">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="decimal-leading-zero">Foo 3</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ol style="list-style-type:decimal-leading-zero;">' +
- '<li>Foo 1' +
- '<ol style="list-style-type:lower-latin;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ol>' +
- '</li>' +
- '<li>Foo 2</li>' +
- '<li>Foo 3</li>' +
- '</ol>'
- );
- } );
- it( 'should convert nested mixed lists (ul>ol, main: square, nested: lower-roman)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="square">Foo 1</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="lower-roman">Bar 1</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="lower-roman">Bar 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="square">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="square">Foo 3</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ul style="list-style-type:square;">' +
- '<li>Foo 1' +
- '<ol style="list-style-type:lower-roman;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ol>' +
- '</li>' +
- '<li>Foo 2</li>' +
- '<li>Foo 3</li>' +
- '</ul>'
- );
- } );
- it( 'should produce nested lists (different `listIndent` attribute)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered" listStyle="decimal">Foo 1</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="decimal">Foo 2</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="decimal">Bar 1</listItem>' +
- '<listItem listIndent="1" listType="numbered" listStyle="decimal">Bar 2</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ol style="list-style-type:decimal;">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2' +
- '<ol style="list-style-type:decimal;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ol>' +
- '</li>' +
- '</ol>'
- );
- } );
- it( 'should produce two different lists (different `listType` attribute)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="numbered" listStyle="decimal">Foo 1</listItem>' +
- '<listItem listIndent="0" listType="numbered" listStyle="decimal">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="disc">Bar 1</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="disc">Bar 2</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ol style="list-style-type:decimal;">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2</li>' +
- '</ol>' +
- '<ul style="list-style-type:disc;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ul>'
- );
- } );
- it( 'should produce two different lists (different `listStyle` attribute)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="disc">Foo 1</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="disc">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Bar 1</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Bar 2</listItem>'
- );
- expect( editor.getData() ).to.equal(
- '<ul style="list-style-type:disc;">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2</li>' +
- '</ul>' +
- '<ul style="list-style-type:circle;">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ul>'
- );
- } );
- it( 'should not allow to set the `listStyle` attribute in to-do list item', () => {
- setModelData( model, '<listItem listIndent="0" listType="todo">Foo</listItem>' );
- const listItem = model.document.getRoot().getChild( 0 );
- expect( listItem.hasAttribute( 'listItem' ) ).to.be.false;
- model.change( writer => {
- writer.setAttribute( 'listType', 'foo', listItem );
- } );
- expect( listItem.hasAttribute( 'listItem' ) ).to.be.false;
- } );
- } );
- describe( 'view to model', () => {
- it( 'should convert single list (type: bulleted)', () => {
- editor.setData( '<ul><li>Foo</li><li>Bar</li></ul>' );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should convert single list (type: numbered)', () => {
- editor.setData( '<ol><li>Foo</li><li>Bar</li></ol>' );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="numbered">Bar</listItem>'
- );
- } );
- it( 'should convert single list (type: bulleted, style: circle)', () => {
- editor.setData( '<ul style="list-style-type:circle;"><li>Foo</li><li>Bar</li></ul>' );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should convert single list (type: numbered, style: upper-alpha)', () => {
- editor.setData( '<ol style="list-style-type:upper-alpha;"><li>Foo</li><li>Bar</li></ol>' );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">Bar</listItem>'
- );
- } );
- it( 'should convert nested and mixed lists', () => {
- editor.setData(
- '<ol style="list-style-type:upper-alpha;">' +
- '<li>OL 1</li>' +
- '<li>OL 2' +
- '<ul style="list-style-type:circle;">' +
- '<li>UL 1</li>' +
- '<li>UL 2</li>' +
- '</ul>' +
- '</li>' +
- '<li>OL 3</li>' +
- '</ol>'
- );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">OL 1</listItem>' +
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">OL 2</listItem>' +
- '<listItem listIndent="1" listStyle="circle" listType="bulleted">UL 1</listItem>' +
- '<listItem listIndent="1" listStyle="circle" listType="bulleted">UL 2</listItem>' +
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">OL 3</listItem>'
- );
- } );
- it( 'should convert when the list is in the middle of the content', () => {
- editor.setData(
- '<p>Paragraph.</p>' +
- '<ol style="list-style-type:upper-alpha;">' +
- '<li>Foo</li>' +
- '<li>Bar</li>' +
- '</ol>' +
- '<p>Paragraph.</p>'
- );
- expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
- '<paragraph>Paragraph.</paragraph>' +
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="upper-alpha" listType="numbered">Bar</listItem>' +
- '<paragraph>Paragraph.</paragraph>'
- );
- } );
- } );
- } );
- // At this moment editing and data pipelines produce exactly the same content.
- // Just a few tests will be enough here. `model to data` block contains all cases checked.
- describe( 'conversion in editing pipeline', () => {
- describe( 'model to view', () => {
- it( 'should convert single list (type: bulleted, style: default)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="default">Foo</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="default">Bar</listItem>'
- );
- expect( getViewData( view, { withoutSelection: true } ) ).to.equal(
- '<ul><li>Foo</li><li>Bar</li></ul>'
- );
- } );
- it( 'should convert single list (type: bulleted, style: circle)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Bar</listItem>'
- );
- expect( getViewData( view, { withoutSelection: true } ) ).to.equal(
- '<ul style="list-style-type:circle"><li>Foo</li><li>Bar</li></ul>'
- );
- } );
- it( 'should convert nested bulleted lists (main: circle, nested: disc)', () => {
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 1</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="disc">Bar 1</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="disc">Bar 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 2</listItem>' +
- '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo 3</listItem>'
- );
- expect( getViewData( view, { withoutSelection: true } ) ).to.equal(
- '<ul style="list-style-type:circle">' +
- '<li>Foo 1' +
- '<ul style="list-style-type:disc">' +
- '<li>Bar 1</li>' +
- '<li>Bar 2</li>' +
- '</ul>' +
- '</li>' +
- '<li>Foo 2</li>' +
- '<li>Foo 3</li>' +
- '</ul>'
- );
- } );
- } );
- } );
- describe( 'integrations', () => {
- describe( 'merging a list into a styled list', () => {
- it( 'should inherit the list style attribute when merging the same kind of lists (from top, merge a single item)', () => {
- setModelData( model,
- '<paragraph>Foo Bar.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should inherit the list style attribute when merging the same kind of lists (from top, merge a few items)', () => {
- setModelData( model,
- '<paragraph>[Foo Bar 1.</paragraph>' +
- '<paragraph>Foo Bar 2.]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">[Foo Bar 1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar 2.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should not inherit anything if there is no list below the inserted list', () => {
- setModelData( model,
- '<paragraph>Foo Bar 1.[]</paragraph>' +
- '<paragraph>Foo Bar 2.</paragraph>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar 1.[]</listItem>' +
- '<paragraph>Foo Bar 2.</paragraph>'
- );
- } );
- it( 'should not inherit anything if replacing the entire content with a list', () => {
- setModelData( model,
- '<paragraph>Foo Bar 1.[]</paragraph>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar 1.[]</listItem>'
- );
- } );
- it( 'should not inherit the list style attribute when merging different kind of lists (from top, merge a single item)', () => {
- setModelData( model,
- '<paragraph>Foo Bar.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Bar</listItem>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Bar</listItem>'
- );
- } );
- it(
- 'should not inherit the list style attribute when merging different kind of lists (from bottom, merge a single item)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Bar</listItem>' +
- '<paragraph>Foo Bar.[]</paragraph>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="decimal-leading-zero" listType="numbered">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar.[]</listItem>'
- );
- }
- );
- it( 'should inherit the list style attribute when merging the same kind of lists (from bottom, merge a single item)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<paragraph>Foo Bar.[]</paragraph>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar.[]</listItem>'
- );
- } );
- it(
- 'should inherit the list style attribute from listIndent=0 element when merging the same kind of lists (from bottom)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="2" listStyle="disc" listType="bulleted">Foo Bar</listItem>' +
- '<paragraph>Foo Bar.[]</paragraph>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="2" listStyle="disc" listType="bulleted">Foo Bar</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar.[]</listItem>'
- );
- }
- );
- } );
- describe( 'modifying "listType" attribute', () => {
- it( 'should inherit the list style attribute when the modified list is the same kind of the list as next sibling', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="default" listType="numbered">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should inherit the list style attribute when the modified list is the same kind of the list as previous sibling', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="numbered">Foo Bar.[]</listItem>'
- );
- editor.execute( 'bulletedList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo Bar.[]</listItem>'
- );
- } );
- it( 'should not inherit the list style attribute when the modified list already has defined it (next sibling check)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- editor.execute( 'listStyle', { type: 'disc' } );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="disc" listType="bulleted">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it(
- 'should not inherit the list style attribute when the modified list already has defined it (previous sibling check)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo Bar.[]</listItem>'
- );
- editor.execute( 'listStyle', { type: 'disc' } );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>' +
- '<listItem listIndent="0" listStyle="disc" listType="bulleted">Foo Bar.[]</listItem>'
- );
- }
- );
- } );
- describe( 'indenting lists', () => {
- it( 'should restore the default value for the list style attribute when indenting a single item', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">1A.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2B.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">1A.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2B.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- } );
- it( 'should restore the default value for the list style attribute when indenting a few items', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">[2.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.]</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">[2.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">3.]</listItem>'
- );
- } );
- it(
- 'should copy the value for the list style attribute when indenting a single item into a nested list (default value)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">3.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- }
- );
- it(
- 'should copy the value for the list style attribute when indenting a single item into a nested list (changed value)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">3.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- }
- );
- it( 'should copy the value for the list style attribute when indenting a single item into a nested list', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- } );
- it(
- 'should copy the value for the list style attribute when indenting a single item into a nested list ' +
- '(many nested lists check)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.[]</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">4.[]</listItem>'
- );
- }
- );
- it( 'should inherit the list style attribute from nested list if the `listType` is other than indenting element', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">2.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.[]</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">2.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">3.[]</listItem>'
- );
- } );
- } );
- describe( 'outdenting lists', () => {
- it( 'should inherit the list style attribute from parent list (change the first nested item)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- } );
- it( 'should inherit the list style attribute from parent list (change the second nested item)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">3.[]</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.[]</listItem>'
- );
- } );
- it( 'should inherit the list style attribute from parent list (modifying nested lists)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">[2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.]</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">[2.</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.]</listItem>'
- );
- } );
- it(
- 'should inherit the list style attribute from parent list (outdenting many items, including the first one in the list)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">[1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>[1.</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">4.</listItem>'
- );
- }
- );
- it(
- 'should inherit the list style attribute from parent list (outdenting the first item that is a parent for next list)',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.[]</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="3" listStyle="disc" listType="bulleted">4.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">5.</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>1.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.</listItem>' +
- '<listItem listIndent="2" listStyle="disc" listType="bulleted">4.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">5.</listItem>'
- );
- }
- );
- it( 'should not inherit the list style if outdented the only one item in the list', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.[]</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>1.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.</listItem>'
- );
- } );
- it( 'should not inherit the list style if outdented the only one item in the list (a paragraph below the list)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.[]</listItem>' +
- '<listItem listIndent="1" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="2" listStyle="square" listType="bulleted">3.</listItem>' +
- '<paragraph>Foo</paragraph>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>1.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="disc" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">3.</listItem>' +
- '<paragraph>Foo</paragraph>'
- );
- } );
- it( 'should not inherit the list style attribute from parent list if the `listType` is other than outdenting element', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="decimal" listType="numbered">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- } );
- it( 'should not do anything if there is no list after outdenting', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.[]</listItem>'
- );
- editor.execute( 'outdentList' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>1.[]</paragraph>'
- );
- } );
- } );
- describe( 'indent/outdent + undo', () => {
- it( 'should use the same batch for indenting a list and updating `listType` attribute', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">1A.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2B.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'indentList' );
- editor.execute( 'undo' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">1A.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2B.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- } );
- it( 'should use the same batch for outdenting a list and updating `listType` attribute', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- editor.execute( 'outdentList' );
- editor.execute( 'undo' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">3.</listItem>'
- );
- } );
- } );
- describe( 'todo list', () => {
- let editor, model;
- beforeEach( () => {
- return VirtualTestEditor
- .create( {
- // TodoListEditing is at the end by design. Check `ListStyleEditing.afterInit()` call.
- plugins: [ Paragraph, ListStyleEditing, TodoListEditing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- it( 'should not add the `listStyle` attribute while creating a todo list', () => {
- setModelData( model, '<paragraph>Foo[]</paragraph>' );
- editor.execute( 'todoList' );
- expect( getModelData( model ), '<listItem listIndent="0" listType="todo">Foo[]</listItem>' );
- } );
- it( 'should not add the `listStyle` attribute while switching the list type', () => {
- setModelData( model, '<listItem listIndent="0" listType="bulleted">Foo[]</listItem>' );
- editor.execute( 'todoList' );
- expect( getModelData( model ), '<listItem listIndent="0" listType="todo">Foo[]</listItem>' );
- } );
- it( 'should remove the `listStyle` attribute while switching the list type that uses the list style feature', () => {
- setModelData( model, '<listItem listIndent="0" listType="bulleted" listStyle="circle">Foo[]</listItem>' );
- editor.execute( 'todoList' );
- expect( getModelData( model ), '<listItem listIndent="0" listType="todo">Foo[]</listItem>' );
- } );
- it( 'should not inherit the list style attribute when inserting a todo list item', () => {
- setModelData( model,
- '<paragraph>Foo Bar.[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- editor.execute( 'todoList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listType="todo">Foo Bar.[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- } );
- describe( 'removing content between two lists', () => {
- let editor, model;
- beforeEach( () => {
- return VirtualTestEditor
- .create( {
- plugins: [ Paragraph, ListStyleEditing, Typing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- it( 'should not do anything while removing a letter inside a listItem', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.[]</listItem>' +
- '<paragraph></paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2[]</listItem>' +
- '<paragraph></paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- } );
- it( 'should not do anything if there is a non-listItem before the removed content', () => {
- setModelData( model,
- '<paragraph>Foo</paragraph>' +
- '<paragraph>[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>Foo[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- } );
- it( 'should not do anything if there is a non-listItem after the removed content', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>' +
- '<paragraph>[]</paragraph>' +
- '<paragraph>Foo</paragraph>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>' +
- '<paragraph>Foo</paragraph>'
- );
- } );
- it( 'should not do anything if there is no element after the removed content', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>' +
- '<paragraph>[]</paragraph>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.[]</listItem>'
- );
- } );
- it(
- 'should modify the the `listStyle` attribute for the merged (second) list when removing content between those lists',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<paragraph>[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>'
- );
- }
- );
- it( 'should read the `listStyle` attribute from the most outer list', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="numbered" listType="decimal">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="default">2.1.1</listItem>' +
- '<paragraph>[]</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="numbered" listType="decimal">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="default">2.1.1[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>'
- );
- } );
- it(
- 'should not modify the the `listStyle` attribute for the merged (second) list if merging different `listType` attribute',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<paragraph>[]</paragraph>' +
- '<listItem listIndent="0" listStyle="decimal" listType="numbered">1.</listItem>' +
- '<listItem listIndent="0" listStyle="decimal" listType="numbered">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="decimal" listType="numbered">1.</listItem>' +
- '<listItem listIndent="0" listStyle="decimal" listType="numbered">2.</listItem>'
- );
- }
- );
- it(
- 'should modify the the `listStyle` attribute for the merged (second) list when removing content from both lists',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">[3.</listItem>' +
- '<paragraph>Foo</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>'
- );
- }
- );
- it(
- 'should modify the the `listStyle` attribute for the merged (second) list when typing over content from both lists',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">[3.</listItem>' +
- '<paragraph>Foo</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'input', { text: 'Foo' } );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">Foo[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>'
- );
- }
- );
- it(
- 'should not modify the the `listStyle` if lists were not merged but the content was partially removed',
- () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">111.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">222.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">[333.</listItem>' +
- '<paragraph>Foo</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1]11.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">111.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">222.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">[]11.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- }
- );
- it( 'should not do anything while typing in a list item', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">3.</listItem>' +
- '<paragraph></paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- const modelChangeStub = sinon.stub( model, 'change' ).callThrough();
- simulateTyping( ' Foo' );
- // Each character calls `editor.model.change()`.
- expect( modelChangeStub.callCount ).to.equal( 4 );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2. Foo[]</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">3.</listItem>' +
- '<paragraph></paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">2.</listItem>'
- );
- } );
- function simulateTyping( text ) {
- // While typing, every character is an atomic change.
- text.split( '' ).forEach( character => {
- editor.execute( 'input', {
- text: character
- } );
- } );
- }
- } );
- } );
- } );
|