X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhtmldataprocessor%2Fplugin.js;h=7750cfcf5ea10b27486760bb3760ee72c94f8973;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=24e4830bec000a6d625c2a5ff5345ed3ca025fa9;hpb=055b6b0792ce7dc53d47af606b367c04b927c2ab;p=ckeditor.git diff --git a/_source/plugins/htmldataprocessor/plugin.js b/_source/plugins/htmldataprocessor/plugin.js index 24e4830..7750cfc 100644 --- a/_source/plugins/htmldataprocessor/plugin.js +++ b/_source/plugins/htmldataprocessor/plugin.js @@ -38,8 +38,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } - function blockNeedsExtension( block ) + function blockNeedsExtension( block, fromSource ) { + // 1. For IE version >=8, empty blocks are displayed correctly themself in wysiwiyg; + // 2. For the rest, at least table cell and list item need no filler space. + // (#6248) + if ( fromSource && CKEDITOR.env.ie && + ( document.documentMode > 7 + || block.name in CKEDITOR.dtd.tr + || block.name in CKEDITOR.dtd.$listItem ) ) + return false; + var lastChild = lastNoneSpaceChild( block ); return !lastChild @@ -53,7 +62,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { trimFillers( block, true ); - if ( blockNeedsExtension( block ) ) + if ( blockNeedsExtension( block, true ) ) { if ( CKEDITOR.env.ie ) block.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); @@ -263,7 +272,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly; } - var protectAttributeRegex = /<(?:a|area|img|input)[\s\S]*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi; + var protectAttributeRegex = /<((?:a|area|img|input)\b[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi, + findSavedSrcRegex = /\s_cke_saved_src\s*=/; var protectElementsRegex = /(?:])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi, encodedElementsRegex = /([^<]*)<\/cke:encoded>/gi; @@ -275,7 +285,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function protectAttributes( html ) { - return html.replace( protectAttributeRegex, '$& _cke_saved_$1' ); + return html.replace( protectAttributeRegex, function( tag, beginning, fullAttr, attrName, end ) + { + // We should not rewrite the _cke_saved_src attribute (#5218) + if ( attrName == 'src' && findSavedSrcRegex.test( tag ) ) + return tag; + else + return '<' + beginning + fullAttr + ' _cke_saved_' + fullAttr + end + '>'; + }); } function protectElements( html ) @@ -309,6 +326,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return html.replace( protectSelfClosingRegex, '' ); } + function protectPreFormatted( html ) + { + return html.replace( /(]*>)(\r\n|\n)/g, '$1$2$2' ); + } + function protectRealComments( html ) { return html.replace( //g, function( match ) @@ -429,6 +451,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // protecting them into open-close. (#3591) data = protectSelfClosingElements( data ); + // Compensate one leading line break after
 open as browsers
+			// eat it up. (#5789)
+			data = protectPreFormatted( data );
+
 			// Call the browser to help us fixing a possibly invalid HTML
 			// structure.
 			var div = new CKEDITOR.dom.element( 'div' );
@@ -475,12 +501,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 
 /**
  * Whether to force using "&" instead of "&amp;" in elements attributes
- * values. It's not recommended to change this setting for compliance with the
- * W3C XHTML 1.0 standards
- * (C.12, XHTML 1.0).
+ * values, it's not recommended to change this setting for compliance with the
+ * W3C XHTML 1.0 standards (C.12, XHTML 1.0).
+ * @name CKEDITOR.config.forceSimpleAmpersand
  * @type Boolean
  * @default false
  * @example
  * config.forceSimpleAmpersand = false;
  */
-CKEDITOR.config.forceSimpleAmpersand = false;