Ticket #4543: 4543_2.patch
File 4543_2.patch, 3.2 KB (added by , 14 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
15 15 */ 16 16 var nonExitableElementNames = { table:1,pre:1 }; 17 17 // Matching an empty paragraph at the end of document. 18 var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>| |\u00A0| ) \s*(:?<\/\1>)?\s*$/gi;18 var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>| |\u00A0| )?\s*(:?<\/\1>)?\s*$/gi; 19 19 20 20 function onInsertHtml( evt ) 21 21 { … … 175 175 && !path.block ) 176 176 { 177 177 restoreDirty( editor ); 178 var bms = selection.createBookmarks(), 179 fixedBlock = range.fixBlock( true, 178 var fixedBlock = range.fixBlock( true, 180 179 editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); 181 180 182 181 // For IE, we should remove any filler node which was introduced before. … … 186 185 first && isNbsp( first ) && first.remove(); 187 186 } 188 187 189 selection.selectBookmarks( bms ); 188 // If the fixed block is blank and already followed by a exitable 189 // block, we should revert the fix. (#3684) 190 if( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) ) 191 { 192 var previousElement = fixedBlock.getPrevious( isNotWhitespace ), 193 nextElement = fixedBlock.getNext( isNotWhitespace ); 190 194 191 // If the fixed block is blank and is already followed by a exitable192 // block, we should drop it and move to the exist block(#3684).193 var children = fixedBlock.getChildren(),194 count = children.count(),195 firstChild,196 previousElement = fixedBlock.getPrevious( isNotWhitespace ),197 nextElement = fixedBlock.getNext( isNotWhitespace ),198 enterBlock;199 if ( previousElement && previousElement.getName200 && !( previousElement.getName() in nonExitableElementNames ) )201 enterBlock = previousElement;202 else if ( nextElement && nextElement.getName203 && !( nextElement.getName() in nonExitableElementNames ) )204 enterBlock = nextElement;205 195 206 // Not all blocks are editable, e.g. <hr />, further checking it.(#3994)207 if( ( !count208 || ( firstChild = children.getItem( 0 ) ) && firstChild.is && firstChild.is( 'br' ))209 && enterBlock210 && range.moveToElementEditStart( enterBlock ))211 {212 fixedBlock.remove();213 range.select();214 }215 }196 if ( previousElement && previousElement.getName 197 && !( previousElement.getName() in nonExitableElementNames ) 198 && range.moveToElementEditStart( previousElement ) 199 || nextElement && nextElement.getName 200 && !( nextElement.getName() in nonExitableElementNames ) 201 && range.moveToElementEditStart( nextElement ) ) 202 { 203 fixedBlock.remove(); 204 } 205 } 216 206 207 range.select(); 208 // Notify non-IE that selection has changed. 209 if( !CKEDITOR.env.ie ) 210 editor.selectionChange(); 211 } 212 217 213 // All browsers are incapable to moving cursor out of certain non-exitable 218 214 // blocks (e.g. table, list, pre) at the end of document, make this happen by 219 215 // place a bogus node there, which would be later removed by dataprocessor.