Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #67 from ckeditor/t/66
Browse files Browse the repository at this point in the history
Fix: List model fixer will not be triggered if a change-to-fix is in a `transparent` batch. Closes #
  • Loading branch information
Reinmar committed Jul 12, 2017
2 parents 73b4cd1 + aca81fb commit 0779f35
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ export function viewToModelPosition( evt, data ) {
*/
export function modelChangePostFixer( document ) {
return ( evt, type, changes, batch ) => {
if ( batch.type == 'transparent' ) {
return;
}

if ( type == 'remove' ) {
// Fix list items after the cut-out range.
// This fix is needed if items in model after cut-out range have now wrong indents compared to their previous siblings.
Expand Down
23 changes: 23 additions & 0 deletions tests/listengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,29 @@ describe( 'ListEngine', () => {
} );

describe( 'post fixer', () => {
it( 'should not be triggered if change-to-fix is in a transparent batch', () => {
// Note that the same example is also tested below in the insert suite, however in a non-transparent batch.
const input =
'<listItem indent="0" type="bulleted">a</listItem>' +
'[]' +
'<listItem indent="1" type="bulleted">b</listItem>';

const inserted = '<paragraph>x</paragraph>';

const output =
'<listItem indent="0" type="bulleted">a</listItem>' +
'<paragraph>x</paragraph>' +
'<listItem indent="1" type="bulleted">b</listItem>';

setModelData( modelDoc, input );

modelDoc.enqueueChanges( () => {
modelDoc.batch( 'transparent' ).insert( modelDoc.selection.getFirstPosition(), parseModel( inserted, modelDoc.schema ) );
} );

expect( getModelData( modelDoc, { withoutSelection: true } ) ).to.equal( output );
} );

describe( 'insert', () => {
function test( testName, input, inserted, output ) {
it( testName, () => {
Expand Down

0 comments on commit 0779f35

Please sign in to comment.