Search code examples
javascriptckeditor

How to add a custom button to the toolbar that calls a JavaScript function?


I'd like to add a button to the toolbar that calls a JavaScript function like Tada()?

Any ideas on how to add this?


Solution

  • I am in the process of developing a number of custom Plugins for CKEditor and here's my survival pack of bookmarks:

    For your purpose, I would recommend look at one of the plugins in the _source/plugins directory, for example the "print" button. Adding a simple Javascript function is quite easy to achieve. You should be able to duplicate the print plugin (take the directory from _source into the actual plugins/ directory, worry about minification later), rename it, rename every mention of "print" within it, give the button a proper name you use later in your toolbar setup to include the button, and add your function.