X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhtmldataprocessor%2Fplugin.js;h=f8cf91d637b4efb90b40e29ac1def101c87f1b33;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=47bdb7c5bf1122b0130643bc4375a88bbd10b56c;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/htmldataprocessor/plugin.js b/_source/plugins/htmldataprocessor/plugin.js index 47bdb7c..f8cf91d 100644 --- a/_source/plugins/htmldataprocessor/plugin.js +++ b/_source/plugins/htmldataprocessor/plugin.js @@ -16,7 +16,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var lastIndex = block.children.length, last = block.children[ lastIndex - 1 ]; - while( last && last.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.trim( last.value ) ) + while ( last && last.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.trim( last.value ) ) last = block.children[ --lastIndex ]; return last; } @@ -41,7 +41,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function blockNeedsExtension( block ) { var lastChild = lastNoneSpaceChild( block ); - return !lastChild || lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'; + + return !lastChild + || lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br' + // Some of the controls in form needs extension too, + // to move cursor at the end of the form. (#4791) + || block.name == 'form' && lastChild.name == 'input'; } function extendBlockForDisplay( block ) @@ -79,6 +84,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 @@ -172,6 +178,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; @@ -185,6 +197,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !element.attributes.type ) element.attributes.type = 'text/css'; + }, + + title : function( element ) + { + var titleText = element.children[ 0 ]; + titleText && ( titleText.value = element.attributes[ '_cke_title' ] || '' ); } }, @@ -230,7 +248,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)[\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; @@ -242,7 +276,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 ) @@ -276,6 +317,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 ) @@ -396,6 +442,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' );
@@ -450,4 +500,3 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  * @example
  * config.forceSimpleAmpersand = false;
  */
-CKEDITOR.config.forceSimpleAmpersand = false;