WYSIWYG editors like to wrap everything in paragraph tags, so a common scenario is this:

<p>My first paragraph.</p>
<p>[caption]<img src="" alt="" />This is an image caption[/caption] My second paragraph.</p>
<p>My third paragraph.</p>

Caption Filter borks replacement of the caption:

<p>My first paragraph.</p>
<div class="caption-inner">
  <img alt="" src="" />
  This is an image caption
</div>
My second paragraph.</p>
<p>My third paragraph.</p>

Note the missing opening p tag for the second paragraph. The problem lies in Drupal.captionFilter.toHTML(). The regex includes the opening paragraph tag in co.replace(), but doesn't include it in the replacement.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kmonty’s picture

Status: Active » Postponed (maintainer needs more info)

Can you give me steps to reproduce? I'm not even certain what editor you are using...

dalin’s picture

ckeditor + caption filter + media module (though I don't *think* that matters).

Reproduction steps are very straightforward:

1) Create some paragraphs.
2) Insert an image at the beginning of paragraph #2.
3) Add a caption.
4) Save the form.

It looks to be a straightforward fix. I'll take a stab at it tomorrow.

dalin’s picture

I'm guessing that looking at that regex that tinymce might do things slightly different - I bet it wraps the image in a dedicated p tag, rather than allowing it to be within one of the existing paragraphs.

dalin’s picture

Assigned: dalin » Unassigned
Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.3 KB

This relies on
https://drupal.org/node/696734#comment-7192676
since it seems to only apply to CKEditor.

Perhaps this should be rolled back into the other ticket :-P

theunraveler’s picture

The previous patch seem to introduce a bug that inserts a "undefined" string into the WYSIWYG contents whenever the WYSIWYG is disabled, the re-enabled (using the "Disable rich-text" link provides by the WYSIWYG module).

Here's a patch that fixes that.

kmonty’s picture

Status: Needs review » Closed (duplicate)

The work on this issue should be done within the main #696734: Integration with CKEditor or WYSIWYG? issue.