X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fentities%2Fplugin.js;h=1745348018377aaec62a80de12483a520dbbe3ef;hb=3fe9cac293e090ea459a3ee10d78cbe9e1dd0e03;hp=ce0f34e421afe350d9ffaa49a428e9576479d7e3;hpb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7;p=ckeditor.git diff --git a/_source/plugins/entities/plugin.js b/_source/plugins/entities/plugin.js index ce0f34e..1745348 100644 --- a/_source/plugins/entities/plugin.js +++ b/_source/plugins/entities/plugin.js @@ -1,16 +1,16 @@ /* -Copyright (c) 2003-2010, 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,quot'; + var htmlbase = 'nbsp,gt,lt,amp'; var entities = // Latin-1 Entities - 'iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,' + + 'quot,iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,' + 'not,shy,reg,macr,deg,plusmn,sup2,sup3,acute,micro,para,middot,' + 'cedil,sup1,ordm,raquo,frac14,frac12,frac34,iquest,times,divide,' + @@ -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 + ';'; @@ -74,7 +77,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return ''; }); - if ( !reverse ) + if ( !reverse && entities ) { // Transforms the entities string into an array. entities = entities.split( ',' ); @@ -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: + * + * Note: It should not be subject to change unless when outputting a non-HTML data format like BBCode. + * @type Boolean + * @default 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,36 +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 " "; */ -CKEDITOR.config.entities_processNumerical = false; /** - * 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';