-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-CKEDITOR.plugins.add( 'format',\r
-{\r
- requires : [ 'richcombo', 'styles' ],\r
-\r
- init : function( editor )\r
- {\r
- var config = editor.config,\r
- lang = editor.lang.format;\r
-\r
- // Gets the list of tags from the settings.\r
- var tags = config.format_tags.split( ';' );\r
-\r
- // Create style objects for all defined styles.\r
- var styles = {};\r
- for ( var i = 0 ; i < tags.length ; i++ )\r
- {\r
- var tag = tags[ i ];\r
- styles[ tag ] = new CKEDITOR.style( config[ 'format_' + tag ] );\r
- styles[ tag ]._.enterMode = editor.config.enterMode;\r
- }\r
-\r
- editor.ui.addRichCombo( 'Format',\r
- {\r
- label : lang.label,\r
- title : lang.panelTitle,\r
- className : 'cke_format',\r
- panel :\r
- {\r
- css : editor.skin.editor.css.concat( config.contentsCss ),\r
- multiSelect : false,\r
- attributes : { 'aria-label' : lang.panelTitle }\r
- },\r
-\r
- init : function()\r
- {\r
- this.startGroup( lang.panelTitle );\r
-\r
- for ( var tag in styles )\r
- {\r
- var label = lang[ 'tag_' + tag ];\r
-\r
- // Add the tag entry to the panel list.\r
- this.add( tag, styles[tag].buildPreview( label ), label );\r
- }\r
- },\r
-\r
- onClick : function( value )\r
- {\r
- editor.focus();\r
- editor.fire( 'saveSnapshot' );\r
-\r
- var style = styles[ value ],\r
- elementPath = new CKEDITOR.dom.elementPath( editor.getSelection().getStartElement() );\r
-\r
- style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document );\r
-\r
- // Save the undo snapshot after all changes are affected. (#4899)\r
- setTimeout( function()\r
- {\r
- editor.fire( 'saveSnapshot' );\r
- }, 0 );\r
- },\r
-\r
- onRender : function()\r
- {\r
- editor.on( 'selectionChange', function( ev )\r
- {\r
- var currentTag = this.getValue();\r
-\r
- var elementPath = ev.data.path;\r
-\r
- for ( var tag in styles )\r
- {\r
- if ( styles[ tag ].checkActive( elementPath ) )\r
- {\r
- if ( tag != currentTag )\r
- this.setValue( tag, editor.lang.format[ 'tag_' + tag ] );\r
- return;\r
- }\r
- }\r
-\r
- // If no styles match, just empty it.\r
- this.setValue( '' );\r
- },\r
- this);\r
- }\r
- });\r
- }\r
-});\r
-\r
-/**\r
- * A list of semi colon separated style names (by default tags) representing\r
- * the style definition for each entry to be displayed in the Format combo in\r
- * the toolbar. Each entry must have its relative definition configuration in a\r
- * setting named "format_(tagName)". For example, the "p" entry has its\r
- * definition taken from config.format_p.\r
- * @type String\r
- * @default 'p;h1;h2;h3;h4;h5;h6;pre;address;div'\r
- * @example\r
- * config.format_tags = 'p;h2;h3;pre'\r
- */\r
-CKEDITOR.config.format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address;div';\r
-\r
-/**\r
- * The style definition to be used to apply the "Normal" format.\r
- * @type Object\r
- * @default { element : 'p' }\r
- * @example\r
- * config.format_p = { element : 'p', attributes : { 'class' : 'normalPara' } };\r
- */\r
-CKEDITOR.config.format_p = { element : 'p' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Normal (DIV)" format.\r
- * @type Object\r
- * @default { element : 'div' }\r
- * @example\r
- * config.format_div = { element : 'div', attributes : { 'class' : 'normalDiv' } };\r
- */\r
-CKEDITOR.config.format_div = { element : 'div' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Formatted" format.\r
- * @type Object\r
- * @default { element : 'pre' }\r
- * @example\r
- * config.format_pre = { element : 'pre', attributes : { 'class' : 'code' } };\r
- */\r
-CKEDITOR.config.format_pre = { element : 'pre' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Address" format.\r
- * @type Object\r
- * @default { element : 'address' }\r
- * @example\r
- * config.format_address = { element : 'address', attributes : { 'class' : 'styledAddress' } };\r
- */\r
-CKEDITOR.config.format_address = { element : 'address' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h1' }\r
- * @example\r
- * config.format_h1 = { element : 'h1', attributes : { 'class' : 'contentTitle1' } };\r
- */\r
-CKEDITOR.config.format_h1 = { element : 'h1' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h2' }\r
- * @example\r
- * config.format_h2 = { element : 'h2', attributes : { 'class' : 'contentTitle2' } };\r
- */\r
-CKEDITOR.config.format_h2 = { element : 'h2' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h3' }\r
- * @example\r
- * config.format_h3 = { element : 'h3', attributes : { 'class' : 'contentTitle3' } };\r
- */\r
-CKEDITOR.config.format_h3 = { element : 'h3' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h4' }\r
- * @example\r
- * config.format_h4 = { element : 'h4', attributes : { 'class' : 'contentTitle4' } };\r
- */\r
-CKEDITOR.config.format_h4 = { element : 'h4' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h5' }\r
- * @example\r
- * config.format_h5 = { element : 'h5', attributes : { 'class' : 'contentTitle5' } };\r
- */\r
-CKEDITOR.config.format_h5 = { element : 'h5' };\r
-\r
-/**\r
- * The style definition to be used to apply the "Heading 1" format.\r
- * @type Object\r
- * @default { element : 'h6' }\r
- * @example\r
- * config.format_h6 = { element : 'h6', attributes : { 'class' : 'contentTitle6' } };\r
- */\r
-CKEDITOR.config.format_h6 = { element : 'h6' };\r