X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdomiterator%2Fplugin.js;h=f0b18357659138979c2f5c292ff6d93d26e7a66e;hb=refs%2Ftags%2Fv3.4.1;hp=dcb592dae089dec49092c68af06d421129ee72b7;hpb=9873d66421922c7aef8be0f5d2ab51e547b19e66;p=ckeditor.git diff --git a/_source/plugins/domiterator/plugin.js b/_source/plugins/domiterator/plugin.js index dcb592d..f0b1835 100644 --- a/_source/plugins/domiterator/plugin.js +++ b/_source/plugins/domiterator/plugin.js @@ -44,6 +44,9 @@ CKEDITOR.plugins.add( 'domiterator' ); // Indicats that the current element in the loop is the last one. var isLast; + // Indicate at least one of the range boundaries is inside a preformat block. + var touchPre; + // Instructs to cleanup remaining BRs. var removePreviousBr, removeLastBr; @@ -55,7 +58,10 @@ CKEDITOR.plugins.add( 'domiterator' ); // Shrink the range to exclude harmful "noises" (#4087, #4450, #5435). range.shrink( CKEDITOR.NODE_ELEMENT, true ); - range.enlarge( this.forceBrBreak || !this.enlargeBr ? + touchPre = range.endContainer.hasAscendant( 'pre', true ) + || range.startContainer.hasAscendant( 'pre', true ); + + range.enlarge( this.forceBrBreak && !touchPre || !this.enlargeBr ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS ); var walker = new CKEDITOR.dom.walker( range ), @@ -106,7 +112,8 @@ CKEDITOR.plugins.add( 'domiterator' ); { // closeRange indicates that a paragraph boundary has been found, // so the range can be closed. - var closeRange = false; + var closeRange = false, + parentPre = currentNode.hasAscendant( 'pre' ); // includeNode indicates that the current node is good to be part // of the range. By default, any non-element node is ok for it. @@ -119,7 +126,8 @@ CKEDITOR.plugins.add( 'domiterator' ); { var nodeName = currentNode.getName(); - if ( currentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) ) + if ( currentNode.isBlockBoundary( this.forceBrBreak && + !parentPre && { br : 1 } ) ) { //
boundaries must be part of the range. It will // happen only if ForceBrBreak. @@ -193,7 +201,8 @@ CKEDITOR.plugins.add( 'domiterator' ); { var parentNode = currentNode.getParent(); - if ( parentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) ) + if ( parentNode.isBlockBoundary( this.forceBrBreak + && !parentPre && { br : 1 } ) ) { closeRange = true; isLast = isLast || ( parentNode.equals( lastNode) );