JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / htmldataprocessor / plugin.js
index ad3852d..7750cfc 100644 (file)
@@ -38,8 +38,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                }\r
        }\r
 \r
-       function blockNeedsExtension( block )\r
+       function blockNeedsExtension( block, fromSource )\r
        {\r
+        // 1. For IE version >=8,  empty blocks are displayed correctly themself in wysiwiyg;\r
+        // 2. For the rest, at least table cell and list item need no filler space.\r
+        // (#6248)\r
+        if ( fromSource && CKEDITOR.env.ie &&\r
+                ( document.documentMode > 7\r
+                || block.name in CKEDITOR.dtd.tr\r
+                || block.name in CKEDITOR.dtd.$listItem ) )\r
+            return false;\r
+\r
                var lastChild = lastNoneSpaceChild( block );\r
 \r
                return !lastChild\r
@@ -53,7 +62,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        {\r
                trimFillers( block, true );\r
 \r
-               if ( blockNeedsExtension( block ) )\r
+               if ( blockNeedsExtension( block, true ) )\r
                {\r
                        if ( CKEDITOR.env.ie )\r
                                block.add( new CKEDITOR.htmlParser.text( '\xa0' ) );\r
@@ -201,7 +210,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                title : function( element )\r
                                {\r
-                                       element.children[ 0 ].value = element.attributes[ '_cke_title' ];\r
+                                       var titleText = element.children[ 0 ];\r
+                                       titleText && ( titleText.value = element.attributes[ '_cke_title' ] || '' );\r
                                }\r
                        },\r
 \r
@@ -262,7 +272,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly;\r
        }\r
 \r
-       var protectAttributeRegex = /<(?:a|area|img|input)[\s\S]*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;\r
+       var protectAttributeRegex = /<((?:a|area|img|input)\b[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi,\r
+               findSavedSrcRegex = /\s_cke_saved_src\s*=/;\r
 \r
        var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,\r
                encodedElementsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;\r
@@ -274,7 +285,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function protectAttributes( html )\r
        {\r
-               return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );\r
+               return html.replace( protectAttributeRegex, function( tag, beginning, fullAttr, attrName, end )\r
+                       {\r
+                               // We should not rewrite the _cke_saved_src attribute (#5218)\r
+                               if ( attrName == 'src' && findSavedSrcRegex.test( tag ) )\r
+                                       return tag;\r
+                               else\r
+                                       return '<' + beginning + fullAttr + ' _cke_saved_' + fullAttr + end + '>';\r
+                       });\r
        }\r
 \r
        function protectElements( html )\r
@@ -308,6 +326,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return html.replace( protectSelfClosingRegex, '<cke:$1$2></cke:$1>' );\r
        }\r
 \r
+       function protectPreFormatted( html )\r
+       {\r
+               return html.replace( /(<pre\b[^>]*>)(\r\n|\n)/g, '$1$2$2' );\r
+       }\r
+\r
        function protectRealComments( html )\r
        {\r
                return html.replace( /<!--(?!{cke_protected})[\s\S]+?-->/g, function( match )\r
@@ -428,6 +451,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        // protecting them into open-close. (#3591)\r
                        data = protectSelfClosingElements( data );\r
 \r
+                       // Compensate one leading line break after <pre> open as browsers\r
+                       // eat it up. (#5789)\r
+                       data = protectPreFormatted( data );\r
+\r
                        // Call the browser to help us fixing a possibly invalid HTML\r
                        // structure.\r
                        var div = new CKEDITOR.dom.element( 'div' );\r
@@ -474,12 +501,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 /**\r
  * Whether to force using "&" instead of "&amp;amp;" in elements attributes\r
- * values. It's not recommended to change this setting for compliance with the\r
- * W3C XHTML 1.0 standards\r
- * (<a href="http://www.w3.org/TR/xhtml1/#C_12">C.12, XHTML 1.0</a>).\r
+ * values, it's not recommended to change this setting for compliance with the\r
+ * W3C XHTML 1.0 standards (<a href="http://www.w3.org/TR/xhtml1/#C_12">C.12, XHTML 1.0</a>).\r
+ * @name CKEDITOR.config.forceSimpleAmpersand\r
  * @type Boolean\r
  * @default false\r
  * @example\r
  * config.forceSimpleAmpersand = false;\r
  */\r
-CKEDITOR.config.forceSimpleAmpersand = false;\r