X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fformat%2Fplugin.js;h=6df5edf05df3d171d19380cfba8cfbacc9aa1f17;hb=3fe9cac293e090ea459a3ee10d78cbe9e1dd0e03;hp=1e4dab3193ac7698c328cd335cab31f37237b95f;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/plugins/format/plugin.js b/_source/plugins/format/plugin.js index 1e4dab3..6df5edf 100644 --- a/_source/plugins/format/plugin.js +++ b/_source/plugins/format/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, 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 */ @@ -21,20 +21,19 @@ 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', { label : lang.label, title : lang.panelTitle, - voiceLabel : lang.voiceLabel, className : 'cke_format', - multiSelect : false, - panel : { - css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ), - voiceLabel : lang.panelVoiceLabel + css : editor.skin.editor.css.concat( config.contentsCss ), + multiSelect : false, + attributes : { 'aria-label' : lang.panelTitle } }, init : function() @@ -46,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 ); } }, @@ -55,9 +54,16 @@ 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() ); - editor.fire( 'saveSnapshot' ); + style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); + + // Save the undo snapshot after all changes are affected. (#4899) + setTimeout( function() + { + editor.fire( 'saveSnapshot' ); + }, 0 ); }, onRender : function() @@ -105,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' }; @@ -114,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' }; @@ -123,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' }; @@ -132,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' }; @@ -141,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' }; @@ -150,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' }; @@ -159,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' }; @@ -168,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' }; @@ -177,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' }; @@ -186,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' };