Skip to content

Instantly share code, notes, and snippets.

@phylaxis
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phylaxis/9237824 to your computer and use it in GitHub Desktop.
Save phylaxis/9237824 to your computer and use it in GitHub Desktop.
Add CKButton JS code
/**
* Basic sample plugin inserting current date and time into CKEditor editing area.
*
* Created out of the CKEditor Plugin SDK:
* http://docs.ckeditor.com/#!/guide/plugin_sdk_intro
*/
// Register the plugin within the editor.
CKEDITOR.plugins.add( 'tmo-addpage', {
// Register the icons. They must match command names.
icons: 'page_add.png',
// The plugin initialization logic goes inside this method.
init: function( editor ) {
// Define an editor command that inserts a timestamp.
editor.addCommand( 'addPagebreak', {
// Define the function that will be fired when the command is executed.
exec: function( editor ) {
var now = new Date();
// Insert the {pagebreak} tag into the document.
editor.insertHtml( '{pagebreak}' );
}
});
// Create the toolbar button that executes the above command.
editor.ui.addButton( 'Addpage', {
label: 'Add Pagebreak',
command: 'addPagebreak'
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment