X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fformat%2Fplugin.js;h=8e96529eae7c8b8a8c2dcd9ec10631ae8a46e0be;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=402672dbfe916b61599002fc154a09e538f4c9dd;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/format/plugin.js b/_source/plugins/format/plugin.js index 402672d..8e96529 100644 --- a/_source/plugins/format/plugin.js +++ b/_source/plugins/format/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -21,6 +21,7 @@ CKEDITOR.plugins.add( 'format', { var tag = tags[ i ]; styles[ tag ] = new CKEDITOR.style( config[ 'format_' + tag ] ); + styles[ tag ]._.enterMode = editor.config.enterMode; } editor.ui.addRichCombo( 'Format', @@ -44,7 +45,7 @@ CKEDITOR.plugins.add( 'format', var label = lang[ 'tag_' + tag ]; // Add the tag entry to the panel list. - this.add( tag, '<' + tag + '>' + label + '', label ); + this.add( tag, styles[tag].buildPreview( label ), label ); } }, @@ -53,7 +54,10 @@ CKEDITOR.plugins.add( 'format', editor.focus(); editor.fire( 'saveSnapshot' ); - styles[ value ].apply( editor.document ); + var style = styles[ value ], + elementPath = new CKEDITOR.dom.elementPath( editor.getSelection().getStartElement() ); + + style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); // Save the undo snapshot after all changes are affected. (#4899) setTimeout( function() @@ -107,7 +111,7 @@ CKEDITOR.config.format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address;div'; * @type Object * @default { element : 'p' } * @example - * config.format_p = { element : 'p', attributes : { class : 'normalPara' } }; + * config.format_p = { element : 'p', attributes : { 'class' : 'normalPara' } }; */ CKEDITOR.config.format_p = { element : 'p' }; @@ -116,7 +120,7 @@ CKEDITOR.config.format_p = { element : 'p' }; * @type Object * @default { element : 'div' } * @example - * config.format_div = { element : 'div', attributes : { class : 'normalDiv' } }; + * config.format_div = { element : 'div', attributes : { 'class' : 'normalDiv' } }; */ CKEDITOR.config.format_div = { element : 'div' }; @@ -125,7 +129,7 @@ CKEDITOR.config.format_div = { element : 'div' }; * @type Object * @default { element : 'pre' } * @example - * config.format_pre = { element : 'pre', attributes : { class : 'code' } }; + * config.format_pre = { element : 'pre', attributes : { 'class' : 'code' } }; */ CKEDITOR.config.format_pre = { element : 'pre' }; @@ -134,7 +138,7 @@ CKEDITOR.config.format_pre = { element : 'pre' }; * @type Object * @default { element : 'address' } * @example - * config.format_address = { element : 'address', attributes : { class : 'styledAddress' } }; + * config.format_address = { element : 'address', attributes : { 'class' : 'styledAddress' } }; */ CKEDITOR.config.format_address = { element : 'address' }; @@ -143,7 +147,7 @@ CKEDITOR.config.format_address = { element : 'address' }; * @type Object * @default { element : 'h1' } * @example - * config.format_h1 = { element : 'h1', attributes : { class : 'contentTitle1' } }; + * config.format_h1 = { element : 'h1', attributes : { 'class' : 'contentTitle1' } }; */ CKEDITOR.config.format_h1 = { element : 'h1' }; @@ -152,7 +156,7 @@ CKEDITOR.config.format_h1 = { element : 'h1' }; * @type Object * @default { element : 'h2' } * @example - * config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle2' } }; + * config.format_h2 = { element : 'h2', attributes : { 'class' : 'contentTitle2' } }; */ CKEDITOR.config.format_h2 = { element : 'h2' }; @@ -161,7 +165,7 @@ CKEDITOR.config.format_h2 = { element : 'h2' }; * @type Object * @default { element : 'h3' } * @example - * config.format_h3 = { element : 'h3', attributes : { class : 'contentTitle3' } }; + * config.format_h3 = { element : 'h3', attributes : { 'class' : 'contentTitle3' } }; */ CKEDITOR.config.format_h3 = { element : 'h3' }; @@ -170,7 +174,7 @@ CKEDITOR.config.format_h3 = { element : 'h3' }; * @type Object * @default { element : 'h4' } * @example - * config.format_h4 = { element : 'h4', attributes : { class : 'contentTitle4' } }; + * config.format_h4 = { element : 'h4', attributes : { 'class' : 'contentTitle4' } }; */ CKEDITOR.config.format_h4 = { element : 'h4' }; @@ -179,7 +183,7 @@ CKEDITOR.config.format_h4 = { element : 'h4' }; * @type Object * @default { element : 'h5' } * @example - * config.format_h5 = { element : 'h5', attributes : { class : 'contentTitle5' } }; + * config.format_h5 = { element : 'h5', attributes : { 'class' : 'contentTitle5' } }; */ CKEDITOR.config.format_h5 = { element : 'h5' }; @@ -188,6 +192,6 @@ CKEDITOR.config.format_h5 = { element : 'h5' }; * @type Object * @default { element : 'h6' } * @example - * config.format_h6 = { element : 'h6', attributes : { class : 'contentTitle6' } }; + * config.format_h6 = { element : 'h6', attributes : { 'class' : 'contentTitle6' } }; */ CKEDITOR.config.format_h6 = { element : 'h6' };