JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / htmlwriter / plugin.js
index c0dea03..4408402 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -67,7 +67,7 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 \r
                var dtd = CKEDITOR.dtd;\r
 \r
-               for ( var e in CKEDITOR.tools.extend( {}, dtd.$block, dtd.$listItem, dtd.$tableContent ) )\r
+               for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )\r
                {\r
                        this.setRules( e,\r
                                {\r
@@ -78,15 +78,29 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
                                        breakAfterClose : true\r
                                });\r
                }\r
+\r
                this.setRules( 'br',\r
                        {\r
                                breakAfterOpen : true\r
                        });\r
+\r
+               this.setRules( 'title',\r
+                       {\r
+                               indent : false,\r
+                               breakAfterOpen : false\r
+                       });\r
+\r
+               this.setRules( 'style',\r
+                       {\r
+                               indent : false,\r
+                               breakBeforeClose : true\r
+                       });\r
+\r
                // Disable indentation on <pre>.\r
                this.setRules( 'pre',\r
-               {\r
-                 indent: false\r
-               } );\r
+                       {\r
+                         indent: false\r
+                       });\r
        },\r
 \r
        proto :\r
@@ -157,8 +171,13 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
                 */\r
                attribute : function( attName, attValue )\r
                {\r
-                       if ( this.forceSimpleAmpersand )\r
-                               attValue = attValue.replace( /&amp;/, '&' );\r
+\r
+                       if ( typeof attValue == 'string' )\r
+                       {\r
+                               this.forceSimpleAmpersand && ( attValue = attValue.replace( /&amp;/g, '&' ) );\r
+                               // Browsers don't always escape quote in attribute values. (#4683)\r
+                               attValue = attValue.replace( /"/g, '&quot;' );\r
+                       }\r
 \r
                        this._.output.push( ' ', attName, '="', attValue, '"' );\r
                },\r
@@ -262,7 +281,8 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
                 *      <li><b>breakAfterClose</b>: break line after the closer tag for this element.</li>\r
                 * </ul>\r
                 *\r
-                * All rules default to "false".\r
+                * All rules default to "false". Each call to the function overrides\r
+                * already present rules, leaving the undefined untouched.\r
                 *\r
                 * By default, all elements available in the {@link CKEDITOR.dtd.$block),\r
                 * {@link CKEDITOR.dtd.$listItem} and {@link CKEDITOR.dtd.$tableContent}\r
@@ -283,7 +303,12 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
                 */\r
                setRules : function( tagName, rules )\r
                {\r
-                       this._.rules[ tagName ] = rules;\r
+                       var currentRules = this._.rules[ tagName ];\r
+\r
+                       if ( currentRules )\r
+                               CKEDITOR.tools.extend( currentRules, rules, true );\r
+                       else\r
+                               this._.rules[ tagName ] = rules;\r
                }\r
        }\r
 });\r