We have build 4.0 CKeditor plugin for great open source CMS ProcessWire. I am testing it with 4.1 and our custom link and image plugins are not working because Advanced Content Filter doesn't know they will output img and a tags (with few attributes).
How can I say from plugin that "Hello ACF, please allow img tags when this plugin is on toolbar"?
The docs explaining plugins
The docs explaining plugins integration with ACF aren't ready yet, but they will be published here (I'm posting this link so in the future people can easily find it :).
First of all, please read the CKEDITOR.feature doc. It may help you understanding the concept that is used. Also, if you haven't seen it, check ACF guide.
Basically, you don't say that "plugin allows img tag" (at least not now). Plugin may include many features allowing many things (e.g. basicstyles adds 4 buttons). You rather say that "this button, when is in toolbar, allows some content". Therefore you can set property of the button's definition that tells that, or even better, if button just triggers a command, then in this command's definition.
So as you can see, a command and button have something in common - they represent the concept of the editor feature which in the code is an interface. That's exactly what CKEDITOR.feature is. Currently only buttons, richcombos and commands implement it, but in the future plugin may do that too.
Anyway, this magical property of a feature that tells the editor that this feature, when it is activated (e.g. button is added to toolbar), allows some content is CKEDITOR.feature#allowedContent. Add it to button's, or better, command's definition and voila!
Second important property is CKEDITOR.feature#requiredContent which tells editor what is the minimal HTML required by the feature to be activated. E.g. image plugin allows 'img[!src,alt,width,height], but to work it needs only 'img[!src]' (+ of course alt if it has to produce valid output).
Check our plugins code where you'll find how we integrated them with ACF. Hopefully, this week we'll update guides.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thanks Reinmar!
Thanks Reinmar!
That definitely answered my question and I got that part working nicely! I will post here when I am finished with this plugin.
BTW. I forgot to mention that
BTW. I forgot to mention that dialog integration is also possible. You can use requiredContent flag on dialog ui elements such as fields and tabs. They will be hidden if not allowed.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thanks! I thought about using
Thanks! I thought about using dialogs. but since ProcessWire has implemented images in TinyMCE through iframe/jquery, I implemented this in the similar fashion. Here is the plugin currently: https://github.com/ryancramerdesign/InputfieldCKEditor/blob/master/ckeditor-4.1.0/plugins/pwimage/plugin.js
The CKeditor part of it is pretty short and straightforward. The iframe-part is a bit more verbose and there might be some strange parts (I copied and transformed it from TinyMCE plugin).
ACF not working for me yet
Hi,
I have a plugin working in 4.0 branch. Introducing ACF in 4.1RC the output of the plugin is 'eating' my tag when going to sourcemode and back to WYSIWYG!
In detail. My plugin produces a
<a onclick="iLink(2);" class="iLink" title="Go to page">page</a>
In CKeditor I have the link plugin active and my own plugin. So both are dealing with the <a>-tag!
In my plugin I use: var allowed = 'a(iLink)[!title,!onclick,href]', required = 'a(iLink)[title,onclick]';
and apply this according to the link plugin.js
editor.addCommand( 'ilink', new CKEDITOR.dialogCommand( 'ilink', {
allowedContent: allowed, requiredContent: required } ) );
But href appears to be mandatory (because of the link plugin !?).
When in sourcemode I put the href inside my link it retains the link. When href is not there it reverts to <p>page</p>.
I'm reluctant to make a ticket.. maybe it's a bug but maybe it is something I do wrong!
I opened a ticket for this
I opened a ticket for this issue: http://dev.ckeditor.com/ticket/10224.
We'll fix it before releasing 4.1.
I implemented special rules validating elements and they are too strict. This behaviour should be driven by ACF rules, but now it is not configurable.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thanx
Hi Reinmar,
Thank you... so it was a kind of bug afterall. Glad I stumbled over it!
Keep up the good work. You are doing an amazing job!