
﻿
CKEDITOR.plugins.add('format',{requires:'richcombo',lang:'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,ug,uk,vi,zh,zh-cn',init:function(editor){if(editor.blockless)
return;var config=editor.config,lang=editor.lang.format;var tags=config.format_tags.split(';');var styles={},stylesCount=0,allowedContent=[];for(var i=0;i<tags.length;i++){var tag=tags[i];var style=new CKEDITOR.style(config['format_'+tag]);if(!editor.filter.customConfig||editor.filter.check(style)){stylesCount++;styles[tag]=style;styles[tag]._.enterMode=editor.config.enterMode;allowedContent.push(style);}}
if(stylesCount===0)
return;editor.ui.addRichCombo('Format',{label:lang.label,title:lang.panelTitle,toolbar:'styles,20',allowedContent:allowedContent,panel:{css:[CKEDITOR.skin.getPath('editor')].concat(config.contentsCss),multiSelect:false,attributes:{'aria-label':lang.panelTitle}},init:function(){this.startGroup(lang.panelTitle);for(var tag in styles){var label=lang['tag_'+tag];this.add(tag,styles[tag].buildPreview(label),label);}},onClick:function(value){editor.focus();editor.fire('saveSnapshot');var style=styles[value],elementPath=editor.elementPath();editor[style.checkActive(elementPath)?'removeStyle':'applyStyle'](style);setTimeout(function(){editor.fire('saveSnapshot');},0);},onRender:function(){editor.on('selectionChange',function(ev){var currentTag=this.getValue(),elementPath=ev.data.path;this.refresh();for(var tag in styles){if(styles[tag].checkActive(elementPath)){if(tag!=currentTag)
this.setValue(tag,editor.lang.format['tag_'+tag]);return;}}
this.setValue('');},this);},onOpen:function(){this.showAll();for(var name in styles){var style=styles[name];if(!editor.activeFilter.check(style)){this.hideItem(name);}}},refresh:function(){var elementPath=editor.elementPath();if(!elementPath)
return;if(!elementPath.isContextFor('p')){this.setState(CKEDITOR.TRISTATE_DISABLED);return;}
for(var name in styles){if(editor.activeFilter.check(styles[name]))
return;}
this.setState(CKEDITOR.TRISTATE_DISABLED);}});}});CKEDITOR.config.format_tags='p;h1;h2;h3;h4;h5;h6;pre;address;div';CKEDITOR.config.format_p={element:'p'};CKEDITOR.config.format_div={element:'div'};CKEDITOR.config.format_pre={element:'pre'};CKEDITOR.config.format_address={element:'address'};CKEDITOR.config.format_h1={element:'h1'};CKEDITOR.config.format_h2={element:'h2'};CKEDITOR.config.format_h3={element:'h3'};CKEDITOR.config.format_h4={element:'h4'};CKEDITOR.config.format_h5={element:'h5'};CKEDITOR.config.format_h6={element:'h6'};