X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Fentities%2Fplugin.js;h=1745348018377aaec62a80de12483a520dbbe3ef;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=3c267650eab817af4e61299c9f6a8cf9458d17ca;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/plugins/entities/plugin.js b/_source/plugins/entities/plugin.js index 3c26765..1745348 100644 --- a/_source/plugins/entities/plugin.js +++ b/_source/plugins/entities/plugin.js @@ -1,12 +1,12 @@ /* -Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { // Base HTML entities. - var htmlbase = 'nbsp,gt,lt'; + var htmlbase = 'nbsp,gt,lt,amp'; var entities = // Latin-1 Entities @@ -46,8 +46,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license 'upsih,piv'; /** - * Create a mapping table between one character and it's entity form from a list of entity names. - * @param reverse {Boolean} Whether create a reverse map from the entity string form to actual character. + * Create a mapping table between one character and its entity form from a list of entity names. + * @param reverse {Boolean} Whether to create a reverse map from the entity string form to an actual character. */ function buildTable( entities, reverse ) { @@ -61,10 +61,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license nbsp : '\u00A0', // IE | FF shy : '\u00AD', // IE gt : '\u003E', // IE | FF | -- | Opera - lt : '\u003C' // IE | FF | Safari | Opera + lt : '\u003C', // IE | FF | Safari | Opera + amp : '\u0026', // ALL + apos : '\u0027', // IE + quot : '\u0022' // IE }; - entities = entities.replace( /\b(nbsp|shy|gt|lt|amp)(?:,|$)/g, function( match, entity ) + entities = entities.replace( /\b(nbsp|shy|gt|lt|amp|apos|quot)(?:,|$)/g, function( match, entity ) { var org = reverse ? '&' + entity + ';' : specialTable[ entity ], result = reverse ? specialTable[ entity ] : '&' + entity + ';'; @@ -113,25 +116,30 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( htmlFilter ) { // Mandatory HTML base entities. - var selectedEntities = htmlbase; + var selectedEntities = []; + + if ( config.basicEntities !== false ) + selectedEntities.push( htmlbase ); if ( config.entities ) { - selectedEntities += ',' + entities; + if ( selectedEntities.length ) + selectedEntities.push( entities ); + if ( config.entities_latin ) - selectedEntities += ',' + latin; + selectedEntities.push( latin ); if ( config.entities_greek ) - selectedEntities += ',' + greek; + selectedEntities.push( greek ); if ( config.entities_additional ) - selectedEntities += ',' + config.entities_additional; + selectedEntities.push( config.entities_additional ); } - var entitiesTable = buildTable( selectedEntities ); + var entitiesTable = buildTable( selectedEntities.join( ',' ) ); - // Create the Regex used to find entities in the text. - var entitiesRegex = '[' + entitiesTable.regex + ']'; + // Create the Regex used to find entities in the text, leave it matches nothing if entities are empty. + var entitiesRegex = entitiesTable.regex ? '[' + entitiesTable.regex + ']' : 'a^'; delete entitiesTable.regex; if ( config.entities && config.entities_processNumerical ) @@ -170,9 +178,26 @@ For licensing, see LICENSE.html or http://ckeditor.com/license })(); /** + * Whether to escape basic HTML entities in the document, including: + *
nbsp
gt
lt
amp
true
+ * @example
+ * config.basicEntities = false;
+ */
+CKEDITOR.config.basicEntities = true;
+
+/**
* Whether to use HTML entities in the output.
+ * @name CKEDITOR.config.entities
* @type Boolean
- * @default true
+ * @default true
* @example
* config.entities = false;
*/
@@ -180,10 +205,11 @@ CKEDITOR.config.entities = true;
/**
* Whether to convert some Latin characters (Latin alphabet No. 1, ISO 8859-1)
- * to HTML entities. The list of entities can be found at the
+ * to HTML entities. The list of entities can be found in the
* W3C HTML 4.01 Specification, section 24.2.1.
+ * @name CKEDITOR.config.entities_latin
* @type Boolean
- * @default true
+ * @default true
* @example
* config.entities_latin = false;
*/
@@ -192,35 +218,37 @@ CKEDITOR.config.entities_latin = true;
/**
* Whether to convert some symbols, mathematical symbols, and Greek letters to
* HTML entities. This may be more relevant for users typing text written in Greek.
- * The list of entities can be found at the
+ * The list of entities can be found in the
* W3C HTML 4.01 Specification, section 24.3.1.
+ * @name CKEDITOR.config.entities_greek
* @type Boolean
- * @default true
+ * @default true
* @example
* config.entities_greek = false;
*/
CKEDITOR.config.entities_greek = true;
/**
- * Whether to convert all remaining characters, not comprised in the ASCII
- * character table, to their relative decimal numeric representation of HTML entity.
- * When specified as the value 'force', it will simply convert all entities into the above form.
- * For example, the phrase "This is Chinese: 汉语." is outputted
+ * Whether to convert all remaining characters not included in the ASCII
+ * character table to their relative decimal numeric representation of HTML entity.
+ * When set to force
, it will convert all entities into this format.
+ * For example the phrase "This is Chinese: 汉语." is output
* as "This is Chinese: 汉语."
- * @type Boolean
+ * @name CKEDITOR.config.entities_processNumerical
* @type Boolean|String
- * @default false
+ * @default false
* @example
* config.entities_processNumerical = true;
- * config.entities_processNumerical = 'force'; //Convert from " " into " ";
+ * config.entities_processNumerical = 'force'; //Converts from " " into " ";
*/
/**
- * An additional list of entities to be used. It's a string containing each
- * entry separated by a comma. Entities names or number must be used, exclusing
- * the "&" preffix and the ";" termination.
- * @default '#39' // The single quote (') character.
+ * A comma separated list of additional entities to be used. Entity names
+ * or numbers must be used in a form that excludes the "&" prefix and the ";" ending.
+ * @name CKEDITOR.config.entities_additional
+ * @default '#39'
(The single quote (') character.)
* @type String
* @example
+ * config.entities_additional = '#1049'; // Adds Cyrillic capital letter Short I (Й).
*/
CKEDITOR.config.entities_additional = '#39';