Packaging CKEditor in a plugin

Hello,

I’m relatively new to Omeka and would like to know if there is a way to add a CKEditor to my plugin. This isn’t really specific to CKEditor but applies to any JS library with the same constraints I suppose. Normally you need to put a directory of the library somewhere on the server. This directory contains scripts, stylesheets, images, etc. spread out in subdirectories.

Is there a way I can put this directory in my plugin and be able to reference it through a regular URL in my code (so without requiring the Omeka administrator to manually install it somewhere on his server and then configure the URL in the plugin settings - which is what I am currently doing)?

It will only be accessed from the admin edit pages for specific item types (in a tab added via filterAdminItemsFormTabs).

Thank you for any help

Yes, you can include pretty much whatever you want in terms of Javascript libraries in a plugin. If you put the files under views/shared/javascripts (or admin or public rather than shared if it should only be used on one “side”) then you can access them with the queue_js_file or js_tag functions in a view. Within a tab on the item edit form you’ll probably have to use js_tag.

Out of curiosity, what’s the reason you want to use CKEditor rather than the already-provided TinyMCE?

you can access them with the queue_js_file or js_tag functions in a view

I was under the impression that this would break the relative references within the CKEditor library (to other scripts, stylesheets and images) based on a similar problem I had with Wordpress - I may just have been mistaken back then as well. I will try it out, thanks.

Out of curiosity, what’s the reason you want to use CKEditor rather than the already-provided TinyMCE?

I need specific plugins in the editor (to enable more styling options and table related tools) and the ability to dynamically add toolbar widgets. I gave up on TinyMCE when I saw that I could not control its initialization from a plugin (if I remember correctly you need to modify Omeka itself to achieve this).

That’s not generally the case. All those functions do really is spit out the URL to the JS file you specify in the proper tag… if the paths work in a relative fashion out of the box, they generally should work with js_tag fine.

It’s true that you can’t change the tinymce.init call we use, but if you’re just making a new input you could do your own tinymce.init that just targets your particular input and uses different settings. This is probably a little easier with Omeka 2.6 which uses a newer version of TinyMCE. Of course if you’d rather use CKEditor you can do that too.