Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-750

The empty lines before an inline editable macro are removed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 14.10.21
    • Syntax - xwiki/2.1
    • None
    • Unknown

    Description

      Follow these steps to reproduce with the WYSIWYG editor:

      • Set the content of a wiki page to:
        before
        
        
        
        
        
        {{info}}test{{/info}}
        
      • Edit the page with the WYSIWYG editor.
      • Notice that the empty lines are present.
      • Edit the parameters of the info macro and modify some parameter (e.g. set a CSS class, doesn't matter)
      • The empty lines disappear after the content is re-rendered due to the macro parameter change

      With the network tab I can see that the HTML converter is called with something like:

      <p>before</p><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><!--startmacro:info|-|--><div data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container"><p>test</p></div><!--stopmacro-->
      

      and the result of parsing to XDOM and rendering back to XWiki 2.1 syntax is:

      <p>before</p><!--startmacro:info|-||-|test--><div class="box infomessage"><div data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container"><p>test</p></div></div><!--stopmacro-->
      

      As you can see the empty lines are missing.

      Note that the problem doesn't reproduce when the macro is initially inserted, where the HTML converter is called with:

      <p>before</p><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><p><!--startmacro:info|-||-|test--><!--stopmacro--></p>
      

      and correctly produces:

      <p>before</p><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><div class="wikimodel-emptyline"></div><!--startmacro:info|-||-|test--><div class="box infomessage"><div data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container"><p>test</p></div></div><!--stopmacro-->
      

      This suggests that the problem is in the code that handles the "data-xwiki-non-generated-content", i.e. the content of macros editable inline.

      Note that this issue is very annoying when editing in realtime because realtime editing makes it reproduce more easily:

      • Alice inserts some empty lines and then inserts an info box
      • While Alice is typing inside the info box:
        • the changes are propagated to Bob and since there's a new macro, the content is re-rendered for Bob, but due to the realtime sync the "data-xwiki-non-generated-content" DIV is present, and thus the empty lines are removed for Bob, which produces a change that gets propagated to Alice
        • Alice sees the empty lines (she just entered) disappear and blames it on Bob

      Attachments

        Activity

          People

            Unassigned Unassigned
            mflorea Marius Dumitru Florea
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: