I've written a small plugin using the instructions at http://syrinx.ph/articles/CkEditorPluginGuide.aspx
My plugin.js looks like this:
(function(){ var a={ exec:function(editor){ alert("Got to the new plugin"); } } b='examenLink'; CKEDITOR.plugins.add(b,{ init:function(c){ c.addCommand(b,a); c.ui.addButton('ExamenLink',{ label:'Link', icon: this.path + 'images/anchor.gif', command:b }); } }); })();
Re: Another Plugin Question
I tried your code as is throwing it in the plugins folder and adding the definition to the custom toolbar. The only extra option I had to use to get the button to show up was extraPlugins : 'examenLink'. Below is an example of how I called the editor
Re: Another Plugin Question
Thank you for the quick response.
Greg
Re: Another Plugin Question
And also as a side note, it is not absolutely necessary that you have to package your plugin with the other source files. If you get your plugin to work in the _source directory, then you can also just copy it to the ckeditor\plugins directory (under the main ckeditor folder) and then include the ckeditor.js file in your page with the same config options. That should work too.
Repackaging the files I think would be needed (recommended) if your plugin code is quite large and you see performance impacts. I don't have any metrics with me on when and why custom plugins should or should not be packaged. I'll leave that question to be answered by the developers.
Re: Another Plugin Question
Re: Another Plugin Question
What you will need for packaging the files is a tool called CKPackager http://svn.fckeditor.net/CKPackager/trunk/bin/. I am not sure if there is another place where you can download it from but I work directly with the SVN so I have it checked out directly from there. What you would need from that page is those two files, the .exe and .jar.
Now I myself haven't played a lot with the packager tool and its options but have successfully been able to package the source files. So here are the steps -
1. Place both those files in your main ckeditor directory. Doesn't have to be in the same directory really but I just do it for the ease of command line use.
2. In your root ckeditor folder open the file named ckeditor.pack. This file contains the definitions/declarations for the source files being packaged. Under output : 'ckeditor.js' if you scroll to the bottom you will see how the other plugins are referenced to be packaged in the ckeditor.js file. Add your custom plugin definition to the end of the file, example in your case '_source/plugins/examenLink/plugin.js'.
3. Open the command prompt to your ckeditor root directory and run the following (Note: The -v at the end is optional. It just spits out a verbose log of all the files that got packaged and the compression details.)
Re: Another Plugin Question
I'll be trying this today and I'll let you know how it goes.
Re: Another Plugin Question
Aarrggh! I had written a long post and then lost it. I'll try again:
I repackaged my code and tried it but the editor didn't show up at all. That turned out to be a javascript error in my plugin. I was missing a comma just before the line that said
b='examenLink';
After fixing that the editor did show up. If I look inside the newly created (and obfuscated) ckeditor.js file I can find my examenLink code.
However, I can't get the darn icon to show up in the toolbar.
So I tried re-writing my code to match the style used in the existing plugins/link/plugin.js code. That code looks like this:
Re: Another Plugin Question
Re: Another Plugin Question
Well if the icon showed up when you were working with the _source files it should work with the compressed file as well. Remember that there is a "plugins" folder under the root ckeditor as well. I think you can place your custom plugin directory (with the "images" directory) under ckeditor\plugins the icon should be displayed.
As I said before it is not absolutely necessary that you package your plugin code with the ckeditor.js and it can be just placed under the root directory as is
Re: Another Plugin Question
I see that the icons.css file has the type cke_button_link which gives the index into the icons.png file. That's appears to be how the ckeditor finds the icon for the existing link toolbar button.
I'll keep searching to see how ckeditor makes that connection between the link button and the icons.css file.
I know that the code that is rendered in the toolbar is
Once I figure out how the toolbar button renders the
class="cke_off cke_button_link"
I think I'll have it.
Re: Another Plugin Question
If it is under the root plugins folder then the path should be ckeditor\plugins\examenLink\images\anchor.gif. I tested both cases and the image showed up just fine for me.
Re: Another Plugin Question
Got it!
You know what I missed? The addition of the line
extraPlugins : 'examenLink',
in my CKEditor.replace.
You told me that way back at the beginning and I missed it.
I really do appreciate the help you've given me. If you ever come to the Sacramento area I owe you a beer or two Thank you very much for all your help.
Greg
Re: Another Plugin Question
Not a problem. Glad to be of help