Hello everybody,
is it somehow possible to provide Wysiwyg editors for certain properies directly in the “Edit macro” dialog for Java rendering macros, XWiki version 16.8.0?
Thanks in advance.
Hello, I don’t think this is possible (cc @mflorea ).
Usually the only part that should contain content is the content of the macro, not its parameters. And for that we have https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/WikiMacroTutorial/#HContent
Maybe you could explain your use case?
Thx
Technically, it is possible to attach any picker (editor) you want to a macro parameter. We lack documentation on this unfortunately, but there are some examples:
- You can use the
@PropertyDisplayType
annotation on a macro parameter. Needs to point to an existing Java type. If you can reuse an existing type that’s good, otherwise you need to define a new / dedicated type, that’s what the office macro does for instance:- xwiki-platform/xwiki-platform-core/xwiki-platform-office/xwiki-platform-office-macro/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java at master · xwiki/xwiki-platform · GitHub
- xwiki-platform/xwiki-platform-core/xwiki-platform-office/xwiki-platform-office-macro/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java at master · xwiki/xwiki-platform · GitHub
- Then you need to define the displayer for this type. The association is done by name. See for instance xwiki-platform/xwiki-platform-core/xwiki-platform-office/xwiki-platform-office-macro/src/main/resources/templates/html_displayer/officeresourcereference at master · xwiki/xwiki-platform · GitHub (simple class name to lower case, IIRC)
- The displayer can load whatever JavaScript / CSS resources it needs, so it can technically load another WYSIWYG editor
The problem that this leads to some kind of “inception”. The macro parameter is displayed in a Bootstrap modal. If it uses a WYSIWYG editor that editor will need to open another modal (to insert a macro, but not only), and on that modal it will be another WYSIWYG editor that could open another modal… and so on.
Unfortunatly the version of Bootstrap we’re using doesn’t support “nested” modals. There can be only one modal displayed at a time. So when you open a modal you need to close the previous one. This will destroy the WYSIWYG editor that opened the modal. So the bottom line is that you can’t use as a macro parameter picker / editor something that requires modals (as long as the macro parameter is displayed on a modal).
Hope this helps,
Marius