Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-16389: Dedicated macro for inline editing of wikimacro content #1109

Merged
merged 2 commits into from May 16, 2019

Conversation

surli
Copy link
Member

@surli surli commented May 7, 2019

Issue

https://jira.xwiki.org/browse/XWIKI-16389

Solution

  • Create a dedicated macro for wikimacro content that insert the content of a wikimacro and put a dedicated metadata around it for inline editing
  • Process in DefaultWikiMacroRenderer the rendered wikimacro to remove the macro markers that could prevent from inline editing.

Test

Unit tests has been added to the new module and some manual tests have been performed.
I mostly use this macro for testing manually my changes:

{{velocity}}
{{box}}
{{wikimacrocontent/}}
{{/box}}

This content is $xcontext.macro.content.length() characters length.
{{/velocity}}

I needed the fix provided for https://jira.xwiki.org/browse/XRENDERING-562 (see xwiki/xwiki-rendering#174) to avoid some issues with the two consecutive metadatablocks created by box macro and wikimacrocontent.
I'm able to inline edit the content of this macro with this change and the fix from xwiki-rendering.

However I encountered an issue when adding inside the macro box an error macro when inline editing it: it seems that any content added after the error box is removed when saving from the inline editor. I suspect another issue from xwiki-rendering.

@surli surli requested a review from tmortagne May 7, 2019 17:47
@mflorea
Copy link
Member

mflorea commented May 8, 2019

I'm not sure this is the main use case:

{{velocity}}
{{box}}
{{wikimacrocontent/}}
{{/box}}

IMO the main use case is: being able to implement a wiki-based rendering macro whose content can be edited in-line in the WYSIWYG editor. The code of the macro will look like this most of the time:

{{velocity}}
{{html clean="false"}}
<div ...><!-- Some wrapping around the content that may depend on the macro parameters  -->
  ...
  <!-- Output the macro content here so that it can be edited in-line in the WYSIWYG editor. -->
  ...
</div>
{{/html}}
{{/velocity}}

IMO someone developing a wiki-based rendering macro will want to:

  • use scripting macros (such as Velocity or Groovy) in order to access the macro content and parameters
  • use the HTML macro (not wiki syntax) for the wrapping around the macro content (because it's UI)

An example of such a macro could be:

{{figure src="someImage.png"}}some description{{/figure}}

The macro code would look like this:

{{velocity}}
{{html clean="false"}}
<div class="figure">
  <div class="figure-image-wrapper">
    <img src="..." class="figure-image" />
  </div>
  <div class="figure-caption">
    <!-- Output the figure caption here so that it can be edited in-line in the WYSIWYG editor. -->
  </div>
</div>
{{/html}}
{{/velocity}}

To conclude: I don't think wikimacrocontent is that useful (if it's only purpose is to help you output the non-generated-content DIV).

@surli
Copy link
Member Author

surli commented May 14, 2019

@mflorea so after our mail exchange, do you agree with this macro? I don't have much time until the release so I'd like to merge this one.

@mflorea
Copy link
Member

mflorea commented May 15, 2019

@surli OK, go. We can improve it later.

surli added 2 commits May 15, 2019 15:06
  * Create a dedicated macro for wikimacro content.
  * Add some more information on the new macro
  * Use the metadata wikimacrocontent for cleaning macro marker
instead of WikiMacroContent marker.
  * Also clean the non generated content metadata that are not inside
the wikimacro content, so that we only allow inline edit for content of
the wikimacro.
  * Set the target syntax in the context in DefaultHTMLConverter so it
can be used in HTML Macro
@surli surli merged commit 20c5ae6 into master May 16, 2019
@surli surli deleted the XWIKI-16389 branch May 16, 2019 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants