1/** 2 * Basic sample plugin inserting current date and time into CKEditor editing area. 3 */ 4 5// Register the plugin with the editor. 6// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.plugins.html 7CKEDITOR.plugins.add( 'truetype', 8{ 9 // The plugin initialization logic goes inside this method. 10 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.pluginDefinition.html#init 11 12 icons: 'truetype', 13 lang: 'en,de,da,es,ja,sv,nl,fi,zh,zh-tw,it,ru', 14 init: function( editor ) 15 { 16 17 // Define an editor command 18 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#addCommand 19 editor.addCommand( 'truetype', 20 { 21 22 // Define a function that will be fired when the command is executed. 23 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.commandDefinition.html#exec 24 exec : function( editor ) 25 { 26 27 var selection = editor.getSelection(); 28 var text = selection.getSelectedText(); 29 30 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#insertHtml 31 editor.insertHtml('<code>' + text + '</code>'); 32 } 33 }); 34 // Create a toolbar button that executes the plugin command. 35 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.ui.html#addButton 36 editor.ui.addButton( 'TrueType', 37 { 38 // Toolbar button tooltip. 39 40 label: editor.lang.truetype.title, 41 // Reference to the plugin command name. 42 command: 'truetype', 43 // Button's icon file path. 44 icon: this.path + 'images/truetype.gif' 45 } ); 46 47 } 48} );