JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.1
[ckeditor.git] / _source / plugins / domiterator / plugin.js
index dcb592d..f0b1835 100644 (file)
@@ -44,6 +44,9 @@ CKEDITOR.plugins.add( 'domiterator' );
                        // Indicats that the current element in the loop is the last one.\r
                        var isLast;\r
 \r
+                       // Indicate at least one of the range boundaries is inside a preformat block.\r
+                       var touchPre;\r
+\r
                        // Instructs to cleanup remaining BRs.\r
                        var removePreviousBr, removeLastBr;\r
 \r
@@ -55,7 +58,10 @@ CKEDITOR.plugins.add( 'domiterator' );
                                // Shrink the range to exclude harmful "noises" (#4087, #4450, #5435).\r
                                range.shrink( CKEDITOR.NODE_ELEMENT, true );\r
 \r
-                               range.enlarge( this.forceBrBreak || !this.enlargeBr ?\r
+                               touchPre = range.endContainer.hasAscendant( 'pre', true )\r
+                                       || range.startContainer.hasAscendant( 'pre', true );\r
+\r
+                               range.enlarge( this.forceBrBreak && !touchPre || !this.enlargeBr ?\r
                                                           CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );\r
 \r
                                var walker = new CKEDITOR.dom.walker( range ),\r
@@ -106,7 +112,8 @@ CKEDITOR.plugins.add( 'domiterator' );
                        {\r
                                // closeRange indicates that a paragraph boundary has been found,\r
                                // so the range can be closed.\r
-                               var closeRange = false;\r
+                               var closeRange = false,\r
+                                               parentPre = currentNode.hasAscendant( 'pre' );\r
 \r
                                // includeNode indicates that the current node is good to be part\r
                                // of the range. By default, any non-element node is ok for it.\r
@@ -119,7 +126,8 @@ CKEDITOR.plugins.add( 'domiterator' );
                                {\r
                                        var nodeName = currentNode.getName();\r
 \r
-                                       if ( currentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) )\r
+                                       if ( currentNode.isBlockBoundary( this.forceBrBreak &&\r
+                                                       !parentPre && { br : 1 } ) )\r
                                        {\r
                                                // <br> boundaries must be part of the range. It will\r
                                                // happen only if ForceBrBreak.\r
@@ -193,7 +201,8 @@ CKEDITOR.plugins.add( 'domiterator' );
                                        {\r
                                                var parentNode = currentNode.getParent();\r
 \r
-                                               if ( parentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) )\r
+                                               if ( parentNode.isBlockBoundary( this.forceBrBreak\r
+                                                               && !parentPre && { br : 1 } ) )\r
                                                {\r
                                                        closeRange = true;\r
                                                        isLast = isLast || ( parentNode.equals( lastNode) );\r