| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323 |
- /**
- * @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 Model from '../../../src/model/model';
- import { injectSelectionPostFixer } from '../../../src/model/utils/selection-post-fixer';
- import { getData as getModelData, setData as setModelData } from '../../../src/dev-utils/model';
- import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
- describe( 'Selection post-fixer', () => {
- describe( 'injectSelectionPostFixer()', () => {
- it( 'is a function', () => {
- expect( injectSelectionPostFixer ).to.be.a( 'function' );
- } );
- } );
- describe( 'injected behavior', () => {
- let model, modelRoot;
- beforeEach( () => {
- model = new Model();
- modelRoot = model.document.createRoot();
- model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
- model.schema.register( 'table', {
- allowWhere: '$block',
- allowAttributes: [ 'headingRows', 'headingColumns' ],
- isLimit: true,
- isObject: true
- } );
- model.schema.register( 'tableRow', {
- allowIn: 'table',
- isLimit: true
- } );
- model.schema.register( 'tableCell', {
- allowIn: 'tableRow',
- allowAttributes: [ 'colspan', 'rowspan' ],
- isObject: true
- } );
- model.schema.extend( '$block', { allowIn: 'tableCell' } );
- model.schema.register( 'image', {
- isObject: true,
- isBlock: true,
- allowWhere: '$block'
- } );
- model.schema.extend( '$block', { allowIn: 'tableCell' } );
- model.schema.register( 'caption', {
- allowIn: 'image',
- allowContentOf: '$block',
- isLimit: true
- } );
- model.schema.register( 'inlineWidget', {
- isObject: true,
- allowIn: [ '$block', '$clipboardHolder' ]
- } );
- model.schema.register( 'figure', {
- allowIn: '$root',
- allowAttributes: [ 'name', 'title' ]
- } );
- } );
- it( 'should not crash if there is no correct position for model selection', () => {
- setModelData( model, '' );
- expect( getModelData( model ) ).to.equal( '[]' );
- } );
- it( 'should react to structure changes', () => {
- setModelData( model, '<paragraph>[]foo</paragraph><image></image>' );
- model.change( writer => {
- writer.remove( modelRoot.getChild( 0 ) );
- } );
- expect( getModelData( model ) ).to.equal( '[<image></image>]' );
- } );
- it( 'should react to selection changes', () => {
- setModelData( model, '<paragraph>[]foo</paragraph><image></image>' );
- // <paragraph>foo</paragraph>[]<image></image>
- model.change( writer => {
- writer.setSelection(
- writer.createRange( writer.createPositionAt( modelRoot, 1 ), writer.createPositionAt( modelRoot, 1 ) )
- );
- } );
- expect( getModelData( model ) ).to.equal( '<paragraph>foo[]</paragraph><image></image>' );
- } );
- describe( 'selection - table scenarios', () => {
- beforeEach( () => {
- setModelData( model,
- '<paragraph>[]foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #1 (range start outside table, end on table cell)', () => {
- // <paragraph>f[oo</paragraph><table><tableRow><tableCell></tableCell>]<tableCell>...
- model.change( writer => {
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 1 ).getChild( 0 ), 1 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #2 (range start on table cell, end outside table)', () => {
- // ...<table><tableRow><tableCell></tableCell>[<tableCell></tableCell></tableRow></table><paragraph>b]ar</paragraph>
- model.change( writer => {
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 1 ).getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 2 ), 1 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b]ar</paragraph>'
- );
- } );
- it( 'should fix #3', () => {
- // <paragraph>f[oo</paragraph><table>]<tableRow>...
- model.change( writer => {
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 1 ), 0 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #4', () => {
- // <paragraph>foo</paragraph><table><tableRow><tableCell>a[aa</tableCell><tableCell>b]bb</tableCell>
- model.change( writer => {
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getNodeByPath( [ 1, 0, 0, 0 ] ), 1 ),
- writer.createPositionAt( modelRoot.getNodeByPath( [ 1, 0, 1, 0 ] ), 2 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #5 (collapsed selection between tables)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '[]' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>xxx</paragraph></tableCell>' +
- '<tableCell><paragraph>yyy</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>baz</paragraph>'
- );
- assertEqualMarkup( getModelData( model ),
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>xxx</paragraph></tableCell>' +
- '<tableCell><paragraph>yyy</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>baz</paragraph>'
- );
- } );
- // There's a chance that this and the following test will not be up to date with
- // how the table feature is really implemented once we'll introduce row/cells/columns selection
- // in which case all these elements will need to be marked as objects.
- it( 'should fix #6 (element selection of not an object)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '[<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>]' +
- '</table>' +
- '<paragraph>baz</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>baz</paragraph>'
- );
- } );
- it( 'should fix #7 (element selection of non-objects)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '[<tableRow>' +
- '<tableCell><paragraph>1</paragraph></tableCell>' +
- '<tableCell><paragraph>2</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>3</paragraph></tableCell>' +
- '<tableCell><paragraph>4</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>5</paragraph></tableCell>' +
- '<tableCell><paragraph>6</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>baz</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>1</paragraph></tableCell>' +
- '<tableCell><paragraph>2</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>3</paragraph></tableCell>' +
- '<tableCell><paragraph>4</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>5</paragraph></tableCell>' +
- '<tableCell><paragraph>6</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>baz</paragraph>'
- );
- } );
- it( 'should fix #8 (cross-limit selection which starts in a non-limit elements)', () => {
- model.schema.extend( 'paragraph', { allowIn: 'tableCell' } );
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>f[oo</paragraph></tableCell>' +
- '<tableCell><paragraph>b]ar</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>baz</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>foo</paragraph></tableCell>' +
- '<tableCell><paragraph>bar</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>baz</paragraph>'
- );
- } );
- it( 'should not fix #1 (selection over paragraphs outside table)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b[ar</paragraph>' +
- '<paragraph>ba]z</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b[ar</paragraph>' +
- '<paragraph>ba]z</paragraph>'
- );
- } );
- it( 'should not fix #2 (selection over image in table)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>foo</paragraph><image></image></tableCell>' +
- '<tableCell><paragraph>[]bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- model.change( writer => {
- const image = model.document.getRoot().getNodeByPath( [ 1, 0, 0, 1 ] );
- writer.setSelection( writer.createRangeOn( image ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>foo</paragraph>[<image></image>]</tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should not fix #3 (selection over paragraph & image in table)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>foo</paragraph><image></image></tableCell>' +
- '<tableCell><paragraph>[]bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- model.change( writer => {
- const tableCell = model.document.getRoot().getNodeByPath( [ 1, 0, 0 ] );
- writer.setSelection( writer.createRangeIn( tableCell ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>[foo</paragraph><image></image>]</tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should not fix #4 (selection over image & paragraph in table)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><image></image><paragraph>foo</paragraph></tableCell>' +
- '<tableCell><paragraph>[]bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- model.change( writer => {
- const tableCell = model.document.getRoot().getNodeByPath( [ 1, 0, 0 ] );
- writer.setSelection( writer.createRangeIn( tableCell ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell>[<image></image><paragraph>foo]</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should not fix #5 (selection over blockQuote in table)', () => {
- model.schema.register( 'blockQuote', {
- allowWhere: '$block',
- allowContentOf: '$root'
- } );
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><blockQuote><paragraph>foo</paragraph></blockQuote></tableCell>' +
- '<tableCell><paragraph>[]bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- model.change( writer => {
- const tableCell = model.document.getRoot().getNodeByPath( [ 1, 0, 0 ] );
- writer.setSelection( writer.createRangeIn( tableCell ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><blockQuote><paragraph>[foo]</paragraph></blockQuote></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should fix multiple ranges #1', () => {
- model.change( writer => {
- const ranges = [
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 0, 1 ] ),
- writer.createPositionFromPath( modelRoot, [ 1, 0 ] )
- ),
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 1, 0, 0, 0 ] ),
- writer.createPositionFromPath( modelRoot, [ 1, 1 ] )
- )
- ];
- writer.setSelection( ranges );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix multiple ranges #2', () => {
- model.change( writer => {
- const ranges = [
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 0, 1 ] ),
- writer.createPositionFromPath( modelRoot, [ 1, 0 ] )
- ),
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 1, 0, 0, 0 ] ),
- writer.createPositionFromPath( modelRoot, [ 2, 2 ] )
- )
- ];
- writer.setSelection( ranges );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>ba]r</paragraph>'
- );
- } );
- it( 'should fix multiple ranges #3', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>[aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>]' +
- '<tableCell><paragraph>[aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>]' +
- '<tableCell><paragraph>[aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>]' +
- '<tableCell><paragraph>[aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b]az</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b]az</paragraph>'
- );
- } );
- it( 'should not fix multiple ranges #1 (not overlapping ranges)', () => {
- model.change( writer => {
- const ranges = [
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 0, 1 ] ),
- writer.createPositionFromPath( modelRoot, [ 1, 0 ] )
- ),
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 1, 0, 0, 0 ] ),
- writer.createPositionFromPath( modelRoot, [ 2, 1 ] )
- ),
- writer.createRange(
- writer.createPositionFromPath( modelRoot, [ 2, 2 ] ),
- writer.createPositionFromPath( modelRoot, [ 2, 3 ] )
- )
- ];
- writer.setSelection( ranges );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>b]a[r]</paragraph>'
- );
- } );
- it( 'should not fix multiple ranges on objects (table selection)', () => {
- setModelData( model,
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>a</paragraph></tableCell>]' +
- '[<tableCell><paragraph>b</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>c</paragraph></tableCell>]' +
- '<tableCell><paragraph>d</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>a</paragraph></tableCell>]' +
- '[<tableCell><paragraph>b</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>c</paragraph></tableCell>]' +
- '<tableCell><paragraph>d</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should fix selection on block', () => {
- model.schema.extend( '$block', { allowIn: 'tableCell' } );
- setModelData( model,
- '<table>' +
- '<tableRow><tableCell>[<paragraph>aaa</paragraph>]</tableCell></tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<table>' +
- '<tableRow><tableCell><paragraph>[aaa]</paragraph></tableCell></tableRow>' +
- '</table>'
- );
- } );
- it( 'should allow multi-range selection on non-continues blocks (column selected)', () => {
- setModelData( model,
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A1</paragraph></tableCell>]' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A2</paragraph></tableCell>]' +
- '<tableCell><paragraph>B2</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A3</paragraph></tableCell>]' +
- '<tableCell><paragraph>B3</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A1</paragraph></tableCell>]' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A2</paragraph></tableCell>]' +
- '<tableCell><paragraph>B2</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A3</paragraph></tableCell>]' +
- '<tableCell><paragraph>B3</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should allow multi-range selection on continues blocks (row selected)', () => {
- setModelData( model,
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>A1</paragraph></tableCell>' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '<tableCell><paragraph>C1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>B2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C2</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A3</paragraph></tableCell>' +
- '<tableCell><paragraph>B3</paragraph></tableCell>' +
- '<tableCell><paragraph>C3</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>A1</paragraph></tableCell>' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '<tableCell><paragraph>C1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '[<tableCell><paragraph>A2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>B2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C2</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A3</paragraph></tableCell>' +
- '<tableCell><paragraph>B3</paragraph></tableCell>' +
- '<tableCell><paragraph>C3</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should allow multi-range selection with mixed continues/non-continues blocks (part of table selected)', () => {
- setModelData( model,
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>A1</paragraph></tableCell>' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '<tableCell><paragraph>C1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A2</paragraph></tableCell>' +
- '[<tableCell><paragraph>B2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C2</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A3</paragraph></tableCell>' +
- '[<tableCell><paragraph>B3</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C3</paragraph></tableCell>]' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>A1</paragraph></tableCell>' +
- '<tableCell><paragraph>B1</paragraph></tableCell>' +
- '<tableCell><paragraph>C1</paragraph></tableCell>' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A2</paragraph></tableCell>' +
- '[<tableCell><paragraph>B2</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C2</paragraph></tableCell>]' +
- '</tableRow>' +
- '<tableRow>' +
- '<tableCell><paragraph>A3</paragraph></tableCell>' +
- '[<tableCell><paragraph>B3</paragraph></tableCell>]' +
- '[<tableCell><paragraph>C3</paragraph></tableCell>]' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should not fix ranges in multi-range selection (each range set differently - but valid)', () => {
- setModelData( model,
- '<paragraph>[foo]</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>aaa</paragraph></tableCell>]' +
- '<tableCell><paragraph>[bbb]</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '<paragraph>[foo]</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>aaa</paragraph></tableCell>]' +
- '<tableCell><paragraph>[bbb]</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>'
- );
- } );
- it( 'should fix partially wrong selection (last range is post-fixed on whole table)', () => {
- setModelData( model,
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>aaa</paragraph></tableCell>]' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '[<tableCell><paragraph>ccc</paragraph></tableCell>' +
- '</tableRow>]' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '<tableCell><paragraph>ccc</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]'
- );
- } );
- it( 'should fix partially wrong selection (first range is post-fixed on whole table)', () => {
- setModelData( model,
- '<table>' +
- '[<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>]' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '[<tableCell><paragraph>ccc</paragraph></tableCell>]' +
- '</tableRow>' +
- '</table>'
- );
- assertEqualMarkup( getModelData( model ),
- '[<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '<tableCell><paragraph>ccc</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>]'
- );
- } );
- } );
- describe( 'non-collapsed selection - image scenarios', () => {
- beforeEach( () => {
- setModelData( model,
- '<paragraph>[]foo</paragraph>' +
- '<image>' +
- '<caption>xxx</caption>' +
- '</image>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #1 (crossing object and limit boundaries)', () => {
- model.change( writer => {
- // <paragraph>f[oo</paragraph><image><caption>x]xx</caption>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 1 ).getChild( 0 ), 1 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<image>' +
- '<caption>xxx</caption>' +
- '</image>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #2 (crossing object boundary)', () => {
- model.change( writer => {
- // <paragraph>f[oo</paragraph><image>]<caption>xxx</caption>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 1 ), 0 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<image>' +
- '<caption>xxx</caption>' +
- '</image>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #3 (crossing object boundary)', () => {
- model.change( writer => {
- // <paragraph>f[oo</paragraph><image><caption>xxx</caption>]</image>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 0 ), 1 ),
- writer.createPositionAt( modelRoot.getChild( 1 ), 1 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>f[oo</paragraph>' +
- '<image>' +
- '<caption>xxx</caption>' +
- '</image>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #4 (element selection of not an object)', () => {
- model.change( writer => {
- // <paragraph>foo</paragraph><image>[<caption>xxx</caption>]</image>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot.getChild( 1 ), 0 ),
- writer.createPositionAt( modelRoot.getChild( 1 ), 1 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<image>' +
- '<caption>xxx</caption>' +
- '</image>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should not fix #1 (element selection of an object)', () => {
- model.change( writer => {
- // <paragraph>foo</paragraph>[<image><caption>xxx</caption></image>]...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( modelRoot, 1 ),
- writer.createPositionAt( modelRoot, 2 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '[<image>' +
- '<caption>xxx</caption>' +
- '</image>]' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should not fix #2 (inside a limit)', () => {
- model.change( writer => {
- const caption = modelRoot.getChild( 1 ).getChild( 0 );
- // <paragraph>foo</paragraph><image><caption>[xxx]</caption></image>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( caption, 0 ),
- writer.createPositionAt( caption, 3 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<image>' +
- '<caption>[xxx]</caption>' +
- '</image>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should not fix #3 (inside a limit - partial text selection)', () => {
- model.change( writer => {
- const caption = modelRoot.getChild( 1 ).getChild( 0 );
- // <paragraph>foo</paragraph><image><caption>[xx]x</caption></image>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( caption, 0 ),
- writer.createPositionAt( caption, 2 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<image>' +
- '<caption>[xx]x</caption>' +
- '</image>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should not fix #4 (inside a limit - partial text selection)', () => {
- model.change( writer => {
- const caption = modelRoot.getChild( 1 ).getChild( 0 );
- // <paragraph>foo</paragraph><image><caption>x[xx]</caption></image>...
- writer.setSelection( writer.createRange(
- writer.createPositionAt( caption, 1 ),
- writer.createPositionAt( caption, 3 )
- ) );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<image>' +
- '<caption>x[xx]</caption>' +
- '</image>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should not fix #5 (selection in root on non limit element that doesn\'t allow text)', () => {
- setModelData( model,
- '[<figure></figure>]'
- );
- expect( getModelData( model ) ).to.equal(
- '[<figure></figure>]'
- );
- } );
- } );
- describe( 'non-collapsed selection - other scenarios', () => {
- it( 'should fix #1 (element selection of not an object)', () => {
- setModelData( model,
- '<paragraph>aaa</paragraph>' +
- '[<paragraph>bbb</paragraph>]' +
- '<paragraph>ccc</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>aaa</paragraph>' +
- '<paragraph>[bbb]</paragraph>' +
- '<paragraph>ccc</paragraph>'
- );
- } );
- it( 'should fix #2 (elements selection of not an object)', () => {
- setModelData( model,
- '<paragraph>aaa</paragraph>' +
- '[<paragraph>bbb</paragraph>' +
- '<paragraph>ccc</paragraph>]'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>aaa</paragraph>' +
- '<paragraph>[bbb</paragraph>' +
- '<paragraph>ccc]</paragraph>'
- );
- } );
- it( 'should fix #3 (partial selection of not an object)', () => {
- setModelData( model,
- '<paragraph>aaa</paragraph>' +
- '[<paragraph>bbb</paragraph>' +
- '<paragraph>ccc]</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>aaa</paragraph>' +
- '<paragraph>[bbb</paragraph>' +
- '<paragraph>ccc]</paragraph>'
- );
- } );
- it( 'should fix #4 (partial selection of not an object)', () => {
- setModelData( model,
- '<paragraph>aaa</paragraph>' +
- '<paragraph>b[bb</paragraph>]' +
- '<paragraph>ccc</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>aaa</paragraph>' +
- '<paragraph>b[bb]</paragraph>' +
- '<paragraph>ccc</paragraph>'
- );
- } );
- it( 'should fix #5 (partial selection of not an object)', () => {
- setModelData( model,
- '<paragraph>aaa</paragraph>' +
- '[<paragraph>bb]b</paragraph>' +
- '<paragraph>ccc</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>aaa</paragraph>' +
- '<paragraph>[bb]b</paragraph>' +
- '<paragraph>ccc</paragraph>'
- );
- } );
- it( 'should fix #6 (selection must not cross a limit element; starts in a root)', () => {
- model.schema.register( 'a', { isLimit: true, allowIn: '$root' } );
- model.schema.register( 'b', { isLimit: true, allowIn: 'a' } );
- model.schema.register( 'c', { allowIn: 'b' } );
- model.schema.extend( '$text', { allowIn: 'c' } );
- setModelData( model,
- '<a><b><c>[</c></b></a>]'
- );
- expect( getModelData( model ) ).to.equal( '[<a><b><c></c></b></a>]' );
- } );
- it( 'should fix #7 (selection must not cross a limit element; ends in a root)', () => {
- model.schema.register( 'a', { isLimit: true, allowIn: '$root' } );
- model.schema.register( 'b', { isLimit: true, allowIn: 'a' } );
- model.schema.register( 'c', { allowIn: 'b' } );
- model.schema.extend( '$text', { allowIn: 'c' } );
- setModelData( model,
- '[<a><b><c>]</c></b></a>'
- );
- expect( getModelData( model ) ).to.equal( '[<a><b><c></c></b></a>]' );
- } );
- it( 'should fix #8 (selection must not cross a limit element; starts in a non-limit)', () => {
- model.schema.register( 'div', { allowIn: '$root' } );
- model.schema.register( 'a', { isLimit: true, allowIn: 'div' } );
- model.schema.register( 'b', { isLimit: true, allowIn: 'a' } );
- model.schema.register( 'c', { allowIn: 'b' } );
- model.schema.extend( '$text', { allowIn: 'c' } );
- setModelData( model,
- '<div>[<a><b><c>]</c></b></a></div>'
- );
- expect( getModelData( model ) ).to.equal( '<div>[<a><b><c></c></b></a>]</div>' );
- } );
- it( 'should fix #9 (selection must not cross a limit element; ends in a non-limit)', () => {
- model.schema.register( 'div', { allowIn: '$root' } );
- model.schema.register( 'a', { isLimit: true, allowIn: 'div' } );
- model.schema.register( 'b', { isLimit: true, allowIn: 'a' } );
- model.schema.register( 'c', { allowIn: 'b' } );
- model.schema.extend( '$text', { allowIn: 'c' } );
- setModelData( model,
- '<div><a><b><c>[</c></b></a>]</div>'
- );
- expect( getModelData( model ) ).to.equal( '<div>[<a><b><c></c></b></a>]</div>' );
- } );
- it( 'should not fix #1 (selection on text node)', () => {
- setModelData( model, '<paragraph>foob[a]r</paragraph>', { lastRangeBackward: true } );
- expect( getModelData( model ) ).to.equal( '<paragraph>foob[a]r</paragraph>' );
- } );
- it( 'should not fix #2 (inline widget selected)', () => {
- setModelData( model,
- '<paragraph>[<inlineWidget></inlineWidget>]</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>[<inlineWidget></inlineWidget>]</paragraph>'
- );
- } );
- it( 'should not fix #3 (text around inline widget)', () => {
- setModelData( model,
- '<paragraph>fo[o<inlineWidget></inlineWidget>b]ar</paragraph>'
- );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>fo[o<inlineWidget></inlineWidget>b]ar</paragraph>'
- );
- } );
- it( 'should not fix #4 (object in object)', () => {
- model.schema.register( 'div', {
- allowIn: [ '$root', 'div' ],
- isObject: true
- } );
- setModelData( model, '<div>[<div></div>]</div>' );
- model.change( writer => {
- const innerDiv = model.document.getRoot().getNodeByPath( [ 0, 0 ] );
- writer.setSelection( writer.createRangeOn( innerDiv ) );
- } );
- expect( getModelData( model ) ).to.equal( '<div>[<div></div>]</div>' );
- } );
- } );
- describe( 'non-collapsed selection - inline widget scenarios', () => {
- beforeEach( () => {
- model.schema.register( 'placeholder', {
- allowWhere: '$text',
- isInline: true
- } );
- } );
- it( 'should fix selection that ends in inline element', () => {
- setModelData( model, '<paragraph>aaa[<placeholder>]</placeholder>bbb</paragraph>' );
- expect( getModelData( model ) ).to.equal( '<paragraph>aaa[]<placeholder></placeholder>bbb</paragraph>' );
- } );
- it( 'should fix selection that starts in inline element', () => {
- setModelData( model, '<paragraph>aaa<placeholder>[</placeholder>]bbb</paragraph>' );
- expect( getModelData( model ) ).to.equal( '<paragraph>aaa<placeholder></placeholder>[]bbb</paragraph>' );
- } );
- it( 'should fix selection that ends in inline element that is also an object', () => {
- model.schema.extend( 'placeholder', {
- isObject: true
- } );
- setModelData( model, '<paragraph>aaa[<placeholder>]</placeholder>bbb</paragraph>' );
- expect( getModelData( model ) ).to.equal( '<paragraph>aaa[<placeholder></placeholder>]bbb</paragraph>' );
- } );
- it( 'should fix selection that starts in inline element that is also an object', () => {
- model.schema.extend( 'placeholder', {
- isObject: true
- } );
- setModelData( model, '<paragraph>aaa<placeholder>[</placeholder>]bbb</paragraph>' );
- expect( getModelData( model ) ).to.equal( '<paragraph>aaa[<placeholder></placeholder>]bbb</paragraph>' );
- } );
- } );
- describe( 'collapsed selection', () => {
- beforeEach( () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #1 (selection in limit element & before limit element)', () => {
- // <table>[]<tableRow>...
- model.change( writer => {
- writer.setSelection(
- writer.createRange( writer.createPositionAt( modelRoot.getChild( 1 ), 0 ) )
- );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo[]</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #2 (selection in limit element & before limit+object element)', () => {
- // <table><tableRow>[]<tableCell>...
- model.change( writer => {
- const row = modelRoot.getChild( 1 ).getChild( 0 );
- writer.setSelection(
- writer.createRange( writer.createPositionAt( row, 0 ) )
- );
- } );
- expect( getModelData( model ) ).to.equal(
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '[<tableCell><paragraph>aaa</paragraph></tableCell>]' +
- '<tableCell><paragraph>bbb</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix #3 (selection inside object element and before block element)', () => {
- setModelData( model,
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell>[]<paragraph>aaa</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- assertEqualMarkup( getModelData( model ),
- '<paragraph>foo</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>[]aaa</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- it( 'should fix multiple ranges outside block element (but not merge them)', () => {
- setModelData( model,
- '[]<paragraph>foo</paragraph>[]' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- assertEqualMarkup( getModelData( model ),
- '<paragraph>[]foo[]</paragraph>' +
- '<table>' +
- '<tableRow>' +
- '<tableCell><paragraph>aaa</paragraph></tableCell>' +
- '</tableRow>' +
- '</table>' +
- '<paragraph>bar</paragraph>'
- );
- } );
- } );
- } );
- } );
|