1/** 2 * Copyright (c) 2014-2016, CKSource - Frederico Knabben. All rights reserved. 3 * Licensed under the terms of the MIT License (see LICENSE.md). 4 * 5 * Basic sample plugin inserting current date and time into the CKEditor editing area. 6 * 7 * Created out of the CKEditor Plugin SDK: 8 * http://docs.ckeditor.com/#!/guide/plugin_sdk_intro 9 */ 10 11// Register the plugin within the editor. 12CKEDITOR.plugins.add( 'timestamp', { 13 14 // Register the icons. They must match command names. 15 icons: 'timestamp', 16 lang: 'en,de,fr', 17 18 // The plugin initialization logic goes inside this method. 19 init: function( editor ) { 20 21 // Define the editor command that inserts a timestamp. 22 editor.addCommand( 'insertTimestamp', { 23 24 // Define the function that will be fired when the command is executed. 25 exec: function( editor ) { 26 var now = new Date(); 27 // Insert the timestamp into the document. 28 editor.insertHtml( now.toLocaleString()); 29 } 30 }); 31 32 // Create the toolbar button that executes the above command. 33 editor.ui.addButton( 'Timestamp', { 34 label: editor.lang.timestamp.title, //'Insert Timestamp', 35 command: 'insertTimestamp', 36 toolbar: 'insert', 37 icon: this.path + 'icons/timestamp.png', 38 }); 39 } 40}); 41