JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / plugins / format / plugin.js
index b28e4c8..6df5edf 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -21,20 +21,19 @@ CKEDITOR.plugins.add( 'format',
                {\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
-                               voiceLabel : lang.voiceLabel,\r
                                className : 'cke_format',\r
-                               multiSelect : false,\r
-\r
                                panel :\r
                                {\r
                                        css : editor.skin.editor.css.concat( config.contentsCss ),\r
-                                       voiceLabel : lang.panelVoiceLabel\r
+                                       multiSelect : false,\r
+                                       attributes : { 'aria-label' : lang.panelTitle }\r
                                },\r
 \r
                                init : function()\r
@@ -46,7 +45,7 @@ CKEDITOR.plugins.add( 'format',
                                                var label = lang[ 'tag_' + tag ];\r
 \r
                                                // Add the tag entry to the panel list.\r
-                                               this.add( tag, '<' + tag + '>' + label + '</' + tag + '>', label );\r
+                                               this.add( tag, styles[tag].buildPreview( label ), label );\r
                                        }\r
                                },\r
 \r
@@ -55,7 +54,10 @@ CKEDITOR.plugins.add( 'format',
                                        editor.focus();\r
                                        editor.fire( 'saveSnapshot' );\r
 \r
-                                       styles[ value ].apply( editor.document );\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
@@ -109,7 +111,7 @@ CKEDITOR.config.format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address;div';
  * @type Object\r
  * @default { element : 'p' }\r
  * @example\r
- * config.format_p = { element : 'p', attributes : { class : 'normalPara' } };\r
+ * config.format_p = { element : 'p', attributes : { 'class' : 'normalPara' } };\r
  */\r
 CKEDITOR.config.format_p = { element : 'p' };\r
 \r
@@ -118,7 +120,7 @@ CKEDITOR.config.format_p = { element : 'p' };
  * @type Object\r
  * @default { element : 'div' }\r
  * @example\r
- * config.format_div = { element : 'div', attributes : { class : 'normalDiv' } };\r
+ * config.format_div = { element : 'div', attributes : { 'class' : 'normalDiv' } };\r
  */\r
 CKEDITOR.config.format_div = { element : 'div' };\r
 \r
@@ -127,7 +129,7 @@ CKEDITOR.config.format_div = { element : 'div' };
  * @type Object\r
  * @default { element : 'pre' }\r
  * @example\r
- * config.format_pre = { element : 'pre', attributes : { class : 'code' } };\r
+ * config.format_pre = { element : 'pre', attributes : { 'class' : 'code' } };\r
  */\r
 CKEDITOR.config.format_pre = { element : 'pre' };\r
 \r
@@ -136,7 +138,7 @@ CKEDITOR.config.format_pre = { element : 'pre' };
  * @type Object\r
  * @default { element : 'address' }\r
  * @example\r
- * config.format_address = { element : 'address', attributes : { class : 'styledAddress' } };\r
+ * config.format_address = { element : 'address', attributes : { 'class' : 'styledAddress' } };\r
  */\r
 CKEDITOR.config.format_address = { element : 'address' };\r
 \r
@@ -145,7 +147,7 @@ CKEDITOR.config.format_address = { element : 'address' };
  * @type Object\r
  * @default { element : 'h1' }\r
  * @example\r
- * config.format_h1 = { element : 'h1', attributes : { class : 'contentTitle1' } };\r
+ * config.format_h1 = { element : 'h1', attributes : { 'class' : 'contentTitle1' } };\r
  */\r
 CKEDITOR.config.format_h1 = { element : 'h1' };\r
 \r
@@ -154,7 +156,7 @@ CKEDITOR.config.format_h1 = { element : 'h1' };
  * @type Object\r
  * @default { element : 'h2' }\r
  * @example\r
- * config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle2' } };\r
+ * config.format_h2 = { element : 'h2', attributes : { 'class' : 'contentTitle2' } };\r
  */\r
 CKEDITOR.config.format_h2 = { element : 'h2' };\r
 \r
@@ -163,7 +165,7 @@ CKEDITOR.config.format_h2 = { element : 'h2' };
  * @type Object\r
  * @default { element : 'h3' }\r
  * @example\r
- * config.format_h3 = { element : 'h3', attributes : { class : 'contentTitle3' } };\r
+ * config.format_h3 = { element : 'h3', attributes : { 'class' : 'contentTitle3' } };\r
  */\r
 CKEDITOR.config.format_h3 = { element : 'h3' };\r
 \r
@@ -172,7 +174,7 @@ CKEDITOR.config.format_h3 = { element : 'h3' };
  * @type Object\r
  * @default { element : 'h4' }\r
  * @example\r
- * config.format_h4 = { element : 'h4', attributes : { class : 'contentTitle4' } };\r
+ * config.format_h4 = { element : 'h4', attributes : { 'class' : 'contentTitle4' } };\r
  */\r
 CKEDITOR.config.format_h4 = { element : 'h4' };\r
 \r
@@ -181,7 +183,7 @@ CKEDITOR.config.format_h4 = { element : 'h4' };
  * @type Object\r
  * @default { element : 'h5' }\r
  * @example\r
- * config.format_h5 = { element : 'h5', attributes : { class : 'contentTitle5' } };\r
+ * config.format_h5 = { element : 'h5', attributes : { 'class' : 'contentTitle5' } };\r
  */\r
 CKEDITOR.config.format_h5 = { element : 'h5' };\r
 \r
@@ -190,6 +192,6 @@ CKEDITOR.config.format_h5 = { element : 'h5' };
  * @type Object\r
  * @default { element : 'h6' }\r
  * @example\r
- * config.format_h6 = { element : 'h6', attributes : { class : 'contentTitle6' } };\r
+ * config.format_h6 = { element : 'h6', attributes : { 'class' : 'contentTitle6' } };\r
  */\r
 CKEDITOR.config.format_h6 = { element : 'h6' };\r