JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / entities / plugin.js
index 8dac27f..5729831 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -46,8 +46,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                'upsih,piv';\r
 \r
        /**\r
-        * Create a mapping table between one character and it's entity form from a list of entity names.\r
-        * @param reverse {Boolean} Whether create a reverse map from the entity string form to actual character.\r
+        * Create a mapping table between one character and its entity form from a list of entity names.\r
+        * @param reverse {Boolean} Whether to create a reverse map from the entity string form to an actual character.\r
         */\r
        function buildTable( entities, reverse )\r
        {\r
@@ -62,10 +62,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                shy             : '\u00AD',             // IE\r
                                gt              : '\u003E',             // IE | FF |   --   | Opera\r
                                lt              : '\u003C',             // IE | FF | Safari | Opera\r
-                               amp : '\u0026'          // ALL\r
+                               amp     : '\u0026',             // ALL\r
+                               apos    : '\u0027',             // IE\r
+                               quot    : '\u0022'              // IE\r
                        };\r
 \r
-               entities = entities.replace( /\b(nbsp|shy|gt|lt|amp)(?:,|$)/g, function( match, entity )\r
+               entities = entities.replace( /\b(nbsp|shy|gt|lt|amp|apos|quot)(?:,|$)/g, function( match, entity )\r
                        {\r
                                var org = reverse ? '&' + entity + ';' : specialTable[ entity ],\r
                                        result = reverse ? specialTable[ entity ] : '&' + entity + ';';\r
@@ -114,25 +116,27 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        if ( htmlFilter )\r
                        {\r
                                // Mandatory HTML base entities.\r
-                               var selectedEntities = '';\r
+                               var selectedEntities = [];\r
 \r
                                if ( config.basicEntities !== false )\r
-                                       selectedEntities += htmlbase;\r
+                                       selectedEntities.push( htmlbase );\r
 \r
                                if ( config.entities )\r
                                {\r
-                                       selectedEntities += ',' + entities;\r
+                                       if ( selectedEntities.length )\r
+                                               selectedEntities.push( entities );\r
+\r
                                        if ( config.entities_latin )\r
-                                               selectedEntities += ',' + latin;\r
+                                               selectedEntities.push( latin );\r
 \r
                                        if ( config.entities_greek )\r
-                                               selectedEntities += ',' + greek;\r
+                                               selectedEntities.push( greek );\r
 \r
                                        if ( config.entities_additional )\r
-                                               selectedEntities += ',' + config.entities_additional;\r
+                                               selectedEntities.push( config.entities_additional );\r
                                }\r
 \r
-                               var entitiesTable = buildTable( selectedEntities );\r
+                               var entitiesTable = buildTable( selectedEntities.join( ',' ) );\r
 \r
                                // Create the Regex used to find entities in the text, leave it matches nothing if entities are empty.\r
                                var entitiesRegex = entitiesTable.regex ? '[' + entitiesTable.regex + ']' : 'a^';\r
@@ -174,16 +178,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 })();\r
 \r
 /**\r
- * Whether to escape HTML preserved entities in text, including:\r
+ * Whether to escape basic HTML entities in the document, including:\r
  * <ul>\r
- * <li>nbsp</li>\r
- * <li>gt</li>\r
- * <li>lt</li>\r
- * <li>amp</li>\r
+ * <li><code>nbsp</code></li>\r
+ * <li><code>gt</code></li>\r
+ * <li><code>lt</code></li>\r
+ * <li><code>amp</code></li>\r
  * </ul>\r
- * <strong>Note:</strong> It should not be subjected to change unless you're outputting non-HTML data format like BBCode.\r
+ * <strong>Note:</strong> It should not be subject to change unless when outputting a non-HTML data format like BBCode.\r
  * @type Boolean\r
- * @default true\r
+ * @default <code>true</code>\r
  * @example\r
  * config.basicEntities = false;\r
  */\r
@@ -193,7 +197,7 @@ CKEDITOR.config.basicEntities = true;
  * Whether to use HTML entities in the output.\r
  * @name CKEDITOR.config.entities\r
  * @type Boolean\r
- * @default true\r
+ * @default <code>true</code>\r
  * @example\r
  * config.entities = false;\r
  */\r
@@ -201,11 +205,11 @@ CKEDITOR.config.entities = true;
 \r
 /**\r
  * Whether to convert some Latin characters (Latin alphabet No&#46; 1, ISO 8859-1)\r
- * to HTML entities. The list of entities can be found at the\r
+ * to HTML entities. The list of entities can be found in the\r
  * <a href="http://www.w3.org/TR/html4/sgml/entities.html#h-24.2.1">W3C HTML 4.01 Specification, section 24.2.1</a>.\r
  * @name CKEDITOR.config.entities_latin\r
  * @type Boolean\r
- * @default true\r
+ * @default <code>true</code>\r
  * @example\r
  * config.entities_latin = false;\r
  */\r
@@ -214,37 +218,37 @@ CKEDITOR.config.entities_latin = true;
 /**\r
  * Whether to convert some symbols, mathematical symbols, and Greek letters to\r
  * HTML entities. This may be more relevant for users typing text written in Greek.\r
- * The list of entities can be found at the\r
+ * The list of entities can be found in the\r
  * <a href="http://www.w3.org/TR/html4/sgml/entities.html#h-24.3.1">W3C HTML 4.01 Specification, section 24.3.1</a>.\r
  * @name CKEDITOR.config.entities_greek\r
  * @type Boolean\r
- * @default true\r
+ * @default <code>true</code>\r
  * @example\r
  * config.entities_greek = false;\r
  */\r
 CKEDITOR.config.entities_greek = true;\r
 \r
 /**\r
- * Whether to convert all remaining characters, not comprised in the ASCII\r
- * character table, to their relative decimal numeric representation of HTML entity.\r
- * When specified as the value 'force', it will simply convert all entities into the above form.\r
- * For example, the phrase "This is Chinese: &#27721;&#35821;." is outputted\r
+ * Whether to convert all remaining characters not included in the ASCII\r
+ * character table to their relative decimal numeric representation of HTML entity.\r
+ * When set to <code>force</code>, it will convert all entities into this format.\r
+ * For example the phrase "This is Chinese: &#27721;&#35821;." is output\r
  * as "This is Chinese: &amp;#27721;&amp;#35821;."\r
  * @name CKEDITOR.config.entities_processNumerical\r
  * @type Boolean|String\r
- * @default false\r
+ * @default <code>false</code>\r
  * @example\r
  * config.entities_processNumerical = true;\r
- * config.entities_processNumerical = 'force';         //Convert from "&nbsp;" into "&#160;";\r
+ * config.entities_processNumerical = 'force';         //Converts from "&nbsp;" into "&#160;";\r
  */\r
 \r
 /**\r
- * An additional list of entities to be used. It's a string containing each\r
- * entry separated by a comma. Entities names or number must be used, exclusing\r
- * the "&amp;" preffix and the ";" termination.\r
+ * A comma separated list of  additional entities to be used. Entity names\r
+ * or numbers must be used in a form that excludes the "&amp;" prefix and the ";" ending.\r
  * @name CKEDITOR.config.entities_additional\r
- * @default '#39'  // The single quote (') character.\r
+ * @default <code>'#39'</code>  (The single quote (') character.)\r
  * @type String\r
  * @example\r
+ * config.entities_additional = '#1049';               // Adds Cyrillic capital letter Short I (&#1049;).\r
  */\r
 CKEDITOR.config.entities_additional = '#39';\r