X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhtmldataprocessor%2Fplugin.js;h=7750cfcf5ea10b27486760bb3760ee72c94f8973;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=264f5044265fef2ae8cddfe6e18dfe6e6d0dc3a3;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/htmldataprocessor/plugin.js b/_source/plugins/htmldataprocessor/plugin.js index 264f504..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' ) ); @@ -84,6 +93,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license delete blockLikeTags.pre; var defaultDataFilterRules = { + elements : {}, attributeNames : [ // Event attributes (onXYZ) must not be directly set. They can become @@ -177,6 +187,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } }, + html : function( element ) + { + delete element.attributes.contenteditable; + delete element.attributes[ 'class' ]; + }, + body : function( element ) { delete element.attributes.spellcheck; @@ -194,7 +210,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license title : function( element ) { - element.children[ 0 ].value = element.attributes[ '_cke_title' ]; + var titleText = element.children[ 0 ]; + titleText && ( titleText.value = element.attributes[ '_cke_title' ] || '' ); } }, @@ -240,7 +257,23 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; } - var protectAttributeRegex = /<(?:a|area|img|input)[\s\S]*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi; + function protectReadOnly( element ) + { + element.attributes.contenteditable = "false"; + } + function unprotectReadyOnly( element ) + { + delete element.attributes.contenteditable; + } + // Disable form elements editing mode provided by some browers. (#5746) + for ( i in { input : 1, textarea : 1 } ) + { + defaultDataFilterRules.elements[ i ] = protectReadOnly; + defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly; + } + + 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; @@ -252,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 ) @@ -286,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 ) @@ -406,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' );
@@ -452,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;