Image caption turns into paragraph when editing

Hi.

When I add an image with caption and save the page, everything is fine, but when I hit edit again (In-place Editor), the caption turns into a paragraph. Am I missing something or is this a bug?

Edit: I also couldn’t find a way to add a link and a caption that survives saving the page from WYSIWYG Editor or In-place Editor. It looks fine while editing but the caption turns into a paragraph when saving.

Regards

1 Like

Hi, what version of XWiki are you using? I’ve just tested and it worked fine for me on 14.5-SNAPSHOT. Could you record a small video and attach it? (or list very precisely how to reproduce with all the steps). Thx

Hi, it’s a fresh install of the 14.4.1 Demo (Standard Flavor Pre-installed).
While recording the video, I found out that the link seems to be the problem. I couldn’t reproduce the first part today, but here’s the link part:
Bildschirmaufnahme 2022-06-17 um 15.16.08

Thank you very much! It looks like we/I totally missed this option in CKEditor to wrap the image in a link when developing the caption feature. Captions should work fine as long as you don’t put a link on the image (you can put a link in the caption itself, this works). I see two solutions for this, I’ll investigate what we can do:

  • Disable the link feature when there is a caption/disable the caption feature when there is a link.
  • Find a way to represent a link to an image with a caption in XWiki syntax (currently there is no support for it, unfortunately).

I hope that we can implement the second point which would be much nicer in my opinion. A possibility would be a syntax like

[[~[~[Caption Content~>~>image:Sandbox.WebHome@XWikiLogo.png~]~]>>doc:Sandbox.TestPage2]]

I’m not a huge fan of it, but it seems like the most logical choice given what we have already. I’ll check if we can extend the parsing and rendering code to produce and accept this code (currently, the caption is just ignored which is expected).

I don’t understand the need for the escapes. Why would the following not be better:

[[[[Caption Content>>image:Sandbox.WebHome@XWikiLogo.png]]>>doc:Sandbox.TestPage2]]

This just needs some javacc lookahead IMO. You notice the first [[ and then count the [[ occurences till you find the matching number of closing ]]

This syntax would need a parser grammar change which is risky/would mean we would need a new syntax version. On the other hand, with the escaping the change can be implemented without changing the actual parser, it would only mean not ignoring the image label in some more cases.

The thing I don’t like about it is that this syntax looks to me like the whole figure was nested in a link which is not actually the case - only the image is nested in a link in HTML. Also, how would we parse the following:

[[An image: ~[~[Caption Content~>~>image:Sandbox.WebHome@XWikiLogo.png~]~]>>doc:Sandbox.TestPage2]]

would we ignore the caption again as soon as the link contains anything apart from the image? From my point of view something like [[Caption Content>>~[~[image:Sandbox.WebHome@XWikiLogo.png~>~>doc:Sandbox.TestPage2~]~]]] would actually be more logical but doesn’t really fit with the current syntax specification (and also has it’s own flaws).

I’ve created a bug report XRENDERING-670 to track this issue.