1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 CKEDITOR.plugins.add( 'basicstyles', 7 { 8 requires : [ 'styles', 'button' ], 9 10 init : function( editor, pluginPath ) 11 { 12 // All buttons use the same code to register. So, to avoid 13 // duplications, let's use this tool function. 14 var addButtonCommand = function( buttonName, buttonLabel, commandName, styleDefiniton ) 15 { 16 var style = new CKEDITOR.style( styleDefiniton ); 17 18 editor.attachStyleStateChange( style, function( state ) 19 { 20 var command = editor.getCommand( commandName ); 21 command.state = state; 22 command.fire( 'state' ); 23 }); 24 25 editor.addCommand( commandName, new CKEDITOR.styleCommand( style ) ); 26 27 editor.ui.addButton( buttonName, 28 { 29 label : buttonLabel, 30 command : commandName 31 }); 32 }; 33 34 var config = editor.config; 35 var lang = editor.lang; 36 37 addButtonCommand( 'Bold' , lang.bold , 'bold' , config.coreStyles_bold ); 38 addButtonCommand( 'Italic' , lang.italic , 'italic' , config.coreStyles_italic ); 39 addButtonCommand( 'Underline' , lang.underline , 'underline' , config.coreStyles_underline ); 40 addButtonCommand( 'Strike' , lang.strike , 'strike' , config.coreStyles_strike ); 41 addButtonCommand( 'Subscript' , lang.subscript , 'subscript' , config.coreStyles_subscript ); 42 addButtonCommand( 'Superscript' , lang.superscript , 'superscript' , config.coreStyles_superscript ); 43 } 44 }); 45 46 // Basic Inline Styles. 47 CKEDITOR.config.coreStyles_bold = { element : 'strong', overrides : 'b' }; 48 CKEDITOR.config.coreStyles_italic = { element : 'em', overrides : 'i' }; 49 CKEDITOR.config.coreStyles_underline = { element : 'u' }; 50 CKEDITOR.config.coreStyles_strike = { element : 'strike' }; 51 CKEDITOR.config.coreStyles_subscript = { element : 'sub' }; 52 CKEDITOR.config.coreStyles_superscript = { element : 'sup' }; 53