| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626 |
- /**
- * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- /* global document */
- 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 ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
- import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
- 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>'
- );
- } );
- // See: #8262.
- describe( 'list conversion with surrounding text nodes', () => {
- let editor;
- beforeEach( () => {
- return VirtualTestEditor
- .create( {
- plugins: [ ListStyleEditing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- it( 'should convert a list if raw text is before the list', () => {
- editor.setData( 'Foo<ul><li>Foo</li></ul>' );
- expect( editor.getData() ).to.equal( '<p>Foo</p><ul><li>Foo</li></ul>' );
- } );
- it( 'should convert a list if raw text is after the list', () => {
- editor.setData( '<ul><li>Foo</li></ul>Foo' );
- expect( editor.getData() ).to.equal( '<ul><li>Foo</li></ul><p>Foo</p>' );
- } );
- it( 'should convert a list if it is surrender by two text nodes', () => {
- editor.setData( 'Foo<ul><li>Foo</li></ul>Foo' );
- expect( editor.getData() ).to.equal( '<p>Foo</p><ul><li>Foo</li></ul><p>Foo</p>' );
- } );
- } );
- } );
- } );
- // 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>'
- );
- } );
- // See: #8081.
- it( 'should convert properly nested list styles', () => {
- // ■ Level 0
- // ▶ Level 0.1
- // ○ Level 0.1.1
- // ▶ Level 0.2
- // ○ Level 0.2.1
- setModelData( model,
- '<listItem listIndent="0" listType="bulleted" listStyle="default">Level 0</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="default">Level 0.1</listItem>' +
- '<listItem listIndent="2" listType="bulleted" listStyle="circle">Level 0.1.1</listItem>' +
- '<listItem listIndent="1" listType="bulleted" listStyle="default">Level 0.2</listItem>' +
- '<listItem listIndent="2" listType="bulleted" listStyle="circle">Level 0.2.1</listItem>'
- );
- expect( getViewData( view, { withoutSelection: true } ) ).to.equal(
- '<ul>' +
- '<li>Level 0' +
- '<ul>' +
- '<li>Level 0.1' +
- '<ul style="list-style-type:circle">' +
- '<li>Level 0.1.1</li>' +
- '</ul>' +
- '</li>' +
- '<li>Level 0.2' +
- '<ul style="list-style-type:circle">' +
- '<li>Level 0.2.1</li>' +
- '</ul>' +
- '</li>' +
- '</ul>' +
- '</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>'
- );
- } );
- // See: #8072.
- it( 'should not throw when indenting a list without any other content in the editor', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="0" listStyle="default" listType="bulleted">[]</listItem>'
- );
- editor.execute( 'indentList' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">[]</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( 'delete + undo', () => {
- let editor, model, view;
- beforeEach( () => {
- return VirtualTestEditor
- .create( {
- plugins: [ Paragraph, ListStyleEditing, Typing, UndoEditing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- view = editor.editing.view;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- // See: #7930.
- it( 'should restore proper list style attribute after undo merging lists', () => {
- // ○ 1.
- // ○ 2.
- // ○ 3.
- // <paragraph>
- // ■ 1.
- // ■ 2.
- 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>' +
- '<paragraph>[]</paragraph>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>'
- );
- expect( getViewData( view, { withoutSelection: true } ), 'initial data' ).to.equal(
- '<ul style="list-style-type:circle">' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '<li>3.</li>' +
- '</ul>' +
- '<p></p>' +
- '<ul style="list-style-type:square">' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '</ul>'
- );
- // After removing the paragraph.
- // ○ 1.
- // ○ 2.
- // ○ 3.
- // ○ 1.
- // ○ 2.
- editor.execute( 'delete' );
- expect( getViewData( view, { withoutSelection: true } ), 'executing delete' ).to.equal(
- '<ul style="list-style-type:circle">' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '<li>3.</li>' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '</ul>'
- );
- // After undo.
- // ○ 1.
- // ○ 2.
- // ○ 3.
- // <paragraph>
- // ■ 1.
- // ■ 2.
- editor.execute( 'undo' );
- expect( getViewData( view, { withoutSelection: true } ), 'initial data' ).to.equal(
- '<ul style="list-style-type:circle">' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '<li>3.</li>' +
- '</ul>' +
- '<p></p>' +
- '<ul style="list-style-type:square">' +
- '<li>1.</li>' +
- '<li>2.</li>' +
- '</ul>'
- );
- } );
- } );
- 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="decimal" listType="numbered">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="numbered">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="decimal" listType="numbered">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="numbered">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>'
- );
- } );
- // See: #8073.
- it( 'should not crash when removing a content between intended lists', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="default" listType="bulleted">aaaa</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">bb[bb</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="bulleted">cc]cc</listItem>' +
- '<listItem listIndent="3" listStyle="default" listType="bulleted">dddd</listItem>'
- );
- editor.execute( 'delete' );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="default" listType="bulleted">aaaa</listItem>' +
- '<listItem listIndent="1" listStyle="default" listType="bulleted">bb[]cc</listItem>' +
- '<listItem listIndent="2" listStyle="default" listType="bulleted">dddd</listItem>'
- );
- } );
- it( 'should read the `listStyle` attribute from the most outer selected list while removing content between lists', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="square" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="0" listStyle="square" listType="bulleted">2.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="lower-latin" listType="numbered">2.1.1[foo</listItem>' +
- '<paragraph>Foo</paragraph>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">1.</listItem>' +
- '<listItem listIndent="1" listStyle="circle" listType="bulleted">bar]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="decimal" listType="numbered">2.1.</listItem>' +
- '<listItem listIndent="2" listStyle="lower-latin" listType="numbered">2.1.1[]2.</listItem>'
- );
- } );
- function simulateTyping( text ) {
- // While typing, every character is an atomic change.
- text.split( '' ).forEach( character => {
- editor.execute( 'input', {
- text: character
- } );
- } );
- }
- } );
- // #8160
- describe( 'pasting a list into another list', () => {
- let element;
- beforeEach( () => {
- element = document.createElement( 'div' );
- document.body.append( element );
- return ClassicTestEditor
- .create( element, {
- plugins: [ Paragraph, Clipboard, ListStyleEditing, UndoEditing ]
- } )
- .then( newEditor => {
- editor = newEditor;
- model = editor.model;
- } );
- } );
- afterEach( () => {
- return editor.destroy()
- .then( () => {
- element.remove();
- } );
- } );
- it( 'should inherit attributes from the previous sibling element (collapsed selection)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- pasteHtml( editor,
- '<ul style="list-style-type: square">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2</li>' +
- '</ul>'
- );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 1</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 2[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should inherit attributes from the previous sibling element (non-collapsed selection)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">[Foo]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- pasteHtml( editor,
- '<ul style="list-style-type: square">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2</li>' +
- '</ul>'
- );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 1</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 2[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should inherit attributes from the previous sibling element (non-collapsed selection over a few elements)', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">[Foo 1.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 2.</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 3.]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- pasteHtml( editor,
- '<ul style="list-style-type: square">' +
- '<li>Foo 1</li>' +
- '<li>Foo 2</li>' +
- '</ul>'
- );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 1</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo 2[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should do nothing when pasting the similar list', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- pasteHtml( editor,
- '<ol style="list-style-type: decimal">' +
- '<li>Foo</li>' +
- '</ol>'
- );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo Bar</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">Foo[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- it( 'should replace the entire list if selected', () => {
- setModelData( model,
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="decimal" listType="numbered">[Foo Bar]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- pasteHtml( editor,
- '<ul style="list-style-type: square">' +
- '<li>Foo</li>' +
- '</ul>'
- );
- expect( getModelData( model ) ).to.equal(
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Foo</listItem>' +
- '<listItem listIndent="1" listStyle="square" listType="bulleted">Foo[]</listItem>' +
- '<listItem listIndent="0" listStyle="circle" listType="bulleted">Bar</listItem>'
- );
- } );
- function pasteHtml( editor, html ) {
- editor.editing.view.document.fire( 'paste', {
- dataTransfer: createDataTransfer( { 'text/html': html } ),
- stopPropagation() {},
- preventDefault() {}
- } );
- }
- function createDataTransfer( data ) {
- return {
- getData( type ) {
- return data[ type ];
- },
- setData() {}
- };
- }
- } );
- } );
- } );
|