Hi,
In hope that this helps some1, here's a summary of this morning's bug chase:
1. A client informed us that in cke 4.3.4, our plugin didn't work well. Turned out that the fake object was not converted back into its original form on calls to getData()
2. After following the flow, I found out that the culprit was the attribute contentEditable="false" that I had set on the image. It was placed there to prevent FF and IE from displaying resize handles on the fake image when it was selected.
3. There's supposed to be a way around this in cke, with rules that have the property applyToAll in their options, but the relevant rule for transforming fake objects back to the original form hasn't got this property.
4. My solution was to add event handlers to beforeGetData and getData, setting my fake objects' contentEditable to true in the former and resetting it to false in the latter. The handler is set at priority 1 to run before the built in event handlers for *getData:
function setEditable(e, bSet) {
var doc = e && e.editor && e.editor.document;
if (! doc) {
return;
}
var nodes = doc.find("img.cke_annotation");
for (var len = nodes.count() - 1; len >=0; --len) {
var n = nodes.getItem(len);
n && n.setAttribute("contentEditable", bSet);
}
}
editor.on("beforeGetData", function(e) {
setEditable(e, true);
}, null, null, 1);
editor.on("getData", function(e) {
setEditable(e, false);
}, null, null, 1);
Recently I had a similar
Recently I had a similar problem (although I used spans instead of images) but instead of modifying the state of my elements I opted to copy the rules in my plugin so that they are properly applied.
alfonsoml, I'd be grateful if
alfonsoml, I'd be grateful if u provided the code (or the gist of it) here.
Thanks for sharing. I think
Thanks for sharing. I think that we could consider adding applyToAll to the rule options. It should not cause any problems, because the rule is very specific and there's no reason why it couldn't apply to non-editable elements too. Please open a ticket if you agree. We'll try to fix it in 4.4.1.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
alfonsoml, I'd be grateful if
No problem, it's just the code found in the fakeobjects plugin, but with the modifier so it's executed no matter what.
This is part of other code patching other problems with CKEditor that they don't want to fix, so I guess that you can find out the context.
As you might noticed I've applied the rule only to spans because I'm reusing part of other code, so you can opt to use it only with images and even if they fix this problem in a future release, I guess that you'll have to keep this patch in your plugin forever because I guess that you might want to allow everybody to use it, no matter which version of CKEditor they are using.
Ticket
https://dev.ckeditor.com/ticket/11850
10x