From e8798cf7ea5fcc1a8fba8e79f9009c3940ff0587 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Wed, 1 Oct 2025 14:09:56 +0200 Subject: [PATCH 1/7] XWIKI-20944: Include macro fails to execute when no reference is specified * Use the new feature mandatory parameter --- .../rendering/macro/include/IncludeMacroParameters.java | 4 ++-- .../macro/include/IncludeMacroRefactoringTest.java | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/main/java/org/xwiki/rendering/macro/include/IncludeMacroParameters.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/main/java/org/xwiki/rendering/macro/include/IncludeMacroParameters.java index 171a926368d..90818cba3c4 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/main/java/org/xwiki/rendering/macro/include/IncludeMacroParameters.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/main/java/org/xwiki/rendering/macro/include/IncludeMacroParameters.java @@ -114,7 +114,7 @@ public enum Author */ @PropertyDescription("the reference of the resource to display") @PropertyDisplayType(EntityReferenceString.class) - @PropertyFeature("reference") + @PropertyFeature(value = "reference", mandatory = true) @PropertyGroup("stringReference") public void setReference(String reference) { @@ -223,7 +223,7 @@ public EntityType getType() */ @PropertyDescription("The reference of the page to include") @PropertyDisplayType(PageReference.class) - @PropertyFeature("reference") + @PropertyFeature(value = "reference", mandatory = true) // Display hidden because we don't want to confuse our users by proposing two ways to enter the reference to // include and ATM we don't have a picker for PageReference types and we do have a picker for EntityReference string // one so we choose to keep the other one visible and hide this one. We're keeping the property so that we don't diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/include/IncludeMacroRefactoringTest.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/include/IncludeMacroRefactoringTest.java index 67b78ddd6e6..cfefdeb92b1 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/include/IncludeMacroRefactoringTest.java +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/include/IncludeMacroRefactoringTest.java @@ -106,14 +106,6 @@ class IncludeMacroRefactoringTest @RegisterExtension private LogCaptureExtension logCapture = new LogCaptureExtension(LogLevel.WARN); - @Test - void replaceDocumentReferenceWhenNoReferenceParameterSet() throws Exception - { - MacroBlock block = new MacroBlock("include", Collections.emptyMap(), false); - assertEquals(Optional.empty(), this.includeMacroRefactoring.replaceReference(block, null, null, - (DocumentReference) null, false, Map.of())); - } - @Test void replaceDocumentReferenceWhenEmptyReferenceParameterSet() throws Exception { From 9272afde127f3f8f719d07276267b85c104e77df Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Wed, 1 Oct 2025 19:40:04 +0200 Subject: [PATCH 2/7] XWIKI-20944: Include macro fails to execute when no reference is specified * Fix the display of include macro mandatory parameter by handling the specific case of a feature containing a group containing a single parameter to display --- .../main/webjar/xwiki-macro/macroEditor.js | 6 ++++ .../main/webjar/xwiki-macro/macroWizard.css | 14 ++++---- .../macro/MacroDescriptorUIFactory.java | 1 + .../wysiwyg/macro/AbstractMacroUINode.java | 28 +++++++++++++++ .../macro/MacroDescriptorUIFactoryTest.java | 36 +++++++++++++++---- 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js index 4a2b2521491..8182837107f 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js @@ -73,6 +73,12 @@ define('macroParameterEnhancer', ['jquery'], function($) { // if the group contains a single parameter then we don't consider it's a feature only. } else if (group.children.length === 1) { group.featureOnly = false; + // if it's a group of a single parameter inside a feature, we just drop the group. + if (typeof group.parent === 'string' && group.parent.startsWith('FEATURE:')) { + let featureChildren = parametersMap[group.parent].children; + group.hidden = true; + featureChildren.push(group.children[0]); + } } visitedGroups.push(group.id); }, diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroWizard.css b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroWizard.css index ce6a736373b..9bcb40897bb 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroWizard.css +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroWizard.css @@ -47,13 +47,13 @@ ul.macro-list .macro-extension { margin-right: 1em; } -.macro-name::first-letter, -.macro-description::first-letter, -.macro-parameter-name::first-letter, -.macro-parameter-description::first-letter, -.macro-parameter-group-name::first-letter, -.feature-title:first-letter, -.feature-choice-name:first-letter { +.macro-name, +.macro-description, +.macro-parameter-name, +.macro-parameter-description, +.macro-parameter-group-name, +.feature-title, +.feature-choice-name { text-transform: capitalize; } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactory.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactory.java index 8ab235d128d..9b6d7884194 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactory.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactory.java @@ -233,6 +233,7 @@ private void handleFeaturesAndGroups(Map> feature } if (!children.isEmpty()) { groupNode.setChildren(children.stream().map(AbstractMacroUINode::getKey).toList()); + children.forEach(child -> child.setParent(groupNode.getKey())); parametersMap.put(groupNode.getKey(), groupNode); } } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/macro/AbstractMacroUINode.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/macro/AbstractMacroUINode.java index 8d92028aaec..fee82e72570 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/macro/AbstractMacroUINode.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/macro/AbstractMacroUINode.java @@ -40,6 +40,7 @@ public abstract class AbstractMacroUINode private boolean hidden; private boolean mandatory; private int order; + private String parent; /** * Default constructor. @@ -172,6 +173,30 @@ public T setOrder(int order) return (T) this; } + /** + * @return the identifier of the group the parameter belongs to or {@code null} if it doesn't belong to any group. + * @since 17.9.0RC1 + */ + @Unstable + public String getParent() + { + return parent; + } + + /** + * + * @param parent see {@link #getParent()}. + * @param the concrete type + * @return the current instance + * @since 17.9.0RC1 + */ + @Unstable + public T setParent(String parent) + { + this.parent = parent; + return (T) this; + } + @Override public boolean equals(Object o) { @@ -193,6 +218,7 @@ public boolean equals(Object o) .append(id, that.id) .append(name, that.name) .append(description, that.description) + .append(parent, that.parent) .isEquals(); } @@ -207,6 +233,7 @@ public int hashCode() .append(hidden) .append(mandatory) .append(order) + .append(parent) .toHashCode(); } @@ -221,6 +248,7 @@ public String toString() .append("hidden", hidden) .append("mandatory", mandatory) .append("order", order) + .append("parent", parent) .toString(); } } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/test/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactoryTest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/test/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactoryTest.java index ca47c7c0b21..5b87585c332 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/test/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactoryTest.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/test/java/org/xwiki/wysiwyg/internal/macro/MacroDescriptorUIFactoryTest.java @@ -231,6 +231,7 @@ void buildMacroDescriptorUI() nodeParam2.setDisplayType("java.lang.Boolean"); nodeParam2.setEditTemplate("\n" + ""); + nodeParam2.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam3 = new MacroUINodeParameter("param3"); nodeParam3.setName("rendering.macro.myMacro.parameter.param3.nameTranslated"); @@ -239,6 +240,7 @@ void buildMacroDescriptorUI() nodeParam3.setDeprecated(true); nodeParam3.setDisplayType("java.lang.String"); nodeParam3.setEditTemplate(""); + nodeParam3.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam4 = new MacroUINodeParameter("param4"); nodeParam4.setName("rendering.macro.myMacro.parameter.param4.nameTranslated"); @@ -246,6 +248,7 @@ void buildMacroDescriptorUI() nodeParam4.setOrder(4); nodeParam4.setDisplayType("java.lang.String"); nodeParam4.setEditTemplate(""); + nodeParam4.setParent("FEATURE:myFeature"); MacroUINodeParameter nodeParam5 = new MacroUINodeParameter("param5"); nodeParam5.setName("rendering.macro.myMacro.parameter.param5.nameTranslated"); @@ -266,12 +269,14 @@ void buildMacroDescriptorUI() nodeParam6.setOrder(6); nodeParam6.setDisplayType("java.lang.String"); nodeParam6.setEditTemplate(""); + nodeParam6.setParent("FEATURE:myFeature"); MacroUINodeParameter nodeParam7 = new MacroUINodeParameter("param7"); nodeParam7.setName("rendering.macro.myMacro.parameter.param7.nameTranslated"); nodeParam7.setDescription("rendering.macro.myMacro.parameter.param7.descriptionTranslated"); nodeParam7.setDisplayType("java.lang.String"); nodeParam7.setEditTemplate(""); + nodeParam7.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam8 = new MacroUINodeParameter("param8"); nodeParam8.setName("rendering.macro.myMacro.parameter.param8.nameTranslated"); @@ -285,6 +290,7 @@ void buildMacroDescriptorUI() nodeParam9.setDescription("rendering.macro.myMacro.parameter.param9.descriptionTranslated"); nodeParam9.setDisplayType("java.lang.String"); nodeParam9.setEditTemplate(""); + nodeParam9.setParent("GROUP:someGroup"); MacroUINodeParameter nodeParam10 = new MacroUINodeParameter("param10"); nodeParam10.setName("rendering.macro.myMacro.parameter.param10.nameTranslated"); @@ -292,6 +298,7 @@ void buildMacroDescriptorUI() nodeParam10.setOrder(8); nodeParam10.setDisplayType("java.lang.String"); nodeParam10.setEditTemplate(""); + nodeParam10.setParent("GROUP:someGroup"); MacroUINodeParameter nodeParam11 = new MacroUINodeParameter("param11"); nodeParam11.setName("rendering.macro.myMacro.parameter.param11.nameTranslated"); @@ -300,6 +307,7 @@ void buildMacroDescriptorUI() nodeParam11.setHidden(true); nodeParam11.setDisplayType("java.lang.String"); nodeParam11.setEditTemplate(""); + nodeParam11.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam12 = new MacroUINodeParameter("param12"); nodeParam12.setName("rendering.macro.myMacro.parameter.param12.nameTranslated"); @@ -308,6 +316,7 @@ void buildMacroDescriptorUI() nodeParam12.setAdvanced(true); nodeParam12.setDisplayType("java.lang.String"); nodeParam12.setEditTemplate(""); + nodeParam12.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam13 = new MacroUINodeParameter("param13"); nodeParam13.setName("rendering.macro.myMacro.parameter.param13.nameTranslated"); @@ -315,6 +324,7 @@ void buildMacroDescriptorUI() nodeParam13.setOrder(11); nodeParam13.setDisplayType("java.lang.String"); nodeParam13.setEditTemplate(""); + nodeParam13.setParent("GROUP:someGroup"); MacroUINodeParameter nodeParam14 = new MacroUINodeParameter("param14"); nodeParam14.setName("rendering.macro.myMacro.parameter.param14.nameTranslated"); @@ -322,12 +332,14 @@ void buildMacroDescriptorUI() nodeParam14.setAdvanced(true); nodeParam14.setDisplayType("java.lang.String"); nodeParam14.setEditTemplate(""); + nodeParam14.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam15 = new MacroUINodeParameter("param15"); nodeParam15.setName("rendering.macro.myMacro.parameter.param15.nameTranslated"); nodeParam15.setDescription("rendering.macro.myMacro.parameter.param15.descriptionTranslated"); nodeParam15.setDisplayType("java.lang.String"); nodeParam15.setEditTemplate(""); + nodeParam15.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeParam16 = new MacroUINodeParameter("param16"); nodeParam16.setName("rendering.macro.myMacro.parameter.param16.nameTranslated"); @@ -335,6 +347,7 @@ void buildMacroDescriptorUI() nodeParam16.setOrder(12); nodeParam16.setDisplayType("java.lang.String"); nodeParam16.setEditTemplate(""); + nodeParam16.setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter nodeContent = new MacroUINodeParameter("$content"); nodeContent.setName("rendering.macroContentTranslated"); @@ -343,6 +356,7 @@ void buildMacroDescriptorUI() nodeContent.setDisplayType("java.util.List"); nodeContent.setEditTemplate(""); nodeContent.setOrder(0); + nodeContent.setParent("GROUP:defaultOptionalGroup"); MacroUINodeGroup featureNode = new MacroUINodeGroup("myFeature"); featureNode.setFeature(true); @@ -509,23 +523,27 @@ void buildMacroDescriptorUIWithIncludeMacroParameters() MacroUINodeParameter referenceNode = new MacroUINodeParameter("reference") .setEditTemplate("") - .setDisplayType("org.xwiki.model.reference.EntityReferenceString"); + .setDisplayType("org.xwiki.model.reference.EntityReferenceString") + .setParent("GROUP:stringReference"); MacroUINodeParameter sectionNode = new MacroUINodeParameter("section") .setEditTemplate("") .setDisplayType("java.lang.String") - .setAdvanced(true); + .setAdvanced(true) + .setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter excludeFirstHeadingNode = new MacroUINodeParameter("excludeFirstHeading") .setEditTemplate("") .setDisplayType("java.lang.String") - .setAdvanced(true); + .setAdvanced(true) + .setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter contextNode = new MacroUINodeParameter("context") .setEditTemplate("") .setDisplayType("java.lang.String") .setAdvanced(true) - .setDeprecated(true); + .setDeprecated(true) + .setParent("GROUP:defaultOptionalGroup"); MacroUINodeParameter typeNode = new MacroUINodeParameter("type") .setDisplayType("org.xwiki.model.EntityType") @@ -546,12 +564,14 @@ void buildMacroDescriptorUIWithIncludeMacroParameters() + "") .setCaseInsensitive(true) .setAdvanced(true) - .setHidden(true); + .setHidden(true) + .setParent("GROUP:stringReference"); MacroUINodeParameter pageNode = new MacroUINodeParameter("page") .setDisplayType("org.xwiki.model.reference.PageReference") .setEditTemplate("") - .setHidden(true); + .setHidden(true) + .setParent("FEATURE:reference"); MacroUINodeParameter authorNode = new MacroUINodeParameter("author") .setDisplayType("org.xwiki.wysiwyg.internal.macro.MacroDescriptorUIFactoryTest$TestEnum") @@ -560,7 +580,8 @@ void buildMacroDescriptorUIWithIncludeMacroParameters() + "" + "" + "") - .setAdvanced(true); + .setAdvanced(true) + .setParent("GROUP:defaultOptionalGroup"); MacroUINodeGroup stringReferenceGroup = new MacroUINodeGroup("stringReference") .setFeature(true) @@ -569,6 +590,7 @@ void buildMacroDescriptorUIWithIncludeMacroParameters() "PARAMETER:reference", "PARAMETER:type" )) + .setParent("FEATURE:reference") .setName("stringReference"); MacroUINodeGroup referenceFeature = new MacroUINodeGroup("reference") From 3556e0a622d6c87f92f6ad83c833b6f46f4e56b8 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Fri, 3 Oct 2025 10:40:16 +0200 Subject: [PATCH 3/7] XWIKI-20944: Include macro fails to execute when no reference is specified * Add revapi ignores for the new mandatory boolean --- xwiki-platform-core/pom.xml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/pom.xml b/xwiki-platform-core/pom.xml index edaeb1e4e31..ac317133aa6 100644 --- a/xwiki-platform-core/pom.xml +++ b/xwiki-platform-core/pom.xml @@ -149,9 +149,30 @@ --> - - - + + Change the annotation value of the parameter group to make it mandatory, + while it was already mandatory in the facts (the macro displays an error when no + parameter from the group is used) + allowed + + + true + java.annotation.attributeAdded + method void org.xwiki.rendering.macro.include.IncludeMacroParameters::setPage(java.lang.String) + method void org.xwiki.rendering.macro.include.IncludeMacroParameters::setPage(java.lang.String) + @org.xwiki.properties.annotation.PropertyFeature(value = "reference", mandatory = true) + mandatory + + + true + java.annotation.attributeAdded + method void org.xwiki.rendering.macro.include.IncludeMacroParameters::setReference(java.lang.String) + method void org.xwiki.rendering.macro.include.IncludeMacroParameters::setReference(java.lang.String) + @org.xwiki.properties.annotation.PropertyFeature(value = "reference", mandatory = true) + mandatory + + + From 789ed72a981fc1b0b3dabb5a710934a524a53159 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Fri, 3 Oct 2025 10:40:39 +0200 Subject: [PATCH 4/7] XWIKI-20944: Include macro fails to execute when no reference is specified * Fix a small bug related to validation of mandatory features --- .../src/main/webjar/xwiki-macro/macroEditor.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js index 8182837107f..ff2814a06d9 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js @@ -560,8 +560,15 @@ define( let emptyMandatoryParams = []; // Include the mandatory features for which no option is checked. macroEditor.find('.feature-container.mandatory').filter(function () { - return $(this).find('.feature-radio').length > 0 && - $(this).find('.feature-radio:checked').length === 0; + if ($(this).find('.feature-radio').length > 0) { + return $(this).find('.feature-radio:checked').length === 0; + } else { + return $(this).find('.macro-parameter:not(.hidden)').filter(function() { + let id = $(this).attr('data-id'); + let value = id === '$content' ? macroCall.content : macroCall.parameters[id]; + return value === undefined || value === ''; + }).first().length !== 0; + } }).map((index, elt) => emptyMandatoryParams.push(elt)); // Exclude the hidden mandatory parameters macroEditor.find('.macro-parameter.mandatory:not(.hidden)').filter(function() { From 03eb9795646851b5fc151c006dbdfd16aed3f0d3 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Fri, 3 Oct 2025 11:21:06 +0200 Subject: [PATCH 5/7] XWIKI-20944: Include macro fails to execute when no reference is specified * Fix handling of features with a single group --- .../src/main/webjar/xwiki-macro/macroEditor.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js index ff2814a06d9..ea4b2ffdb38 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js @@ -73,11 +73,10 @@ define('macroParameterEnhancer', ['jquery'], function($) { // if the group contains a single parameter then we don't consider it's a feature only. } else if (group.children.length === 1) { group.featureOnly = false; - // if it's a group of a single parameter inside a feature, we just drop the group. - if (typeof group.parent === 'string' && group.parent.startsWith('FEATURE:')) { - let featureChildren = parametersMap[group.parent].children; - group.hidden = true; - featureChildren.push(group.children[0]); + // if the single children is a group, we actually remove it to display directly the parameters + let uniqueChildKey = group.children[0]; + if (isNodeAGroup(uniqueChildKey)) { + group.children = parametersMap[uniqueChildKey].children; } } visitedGroups.push(group.id); From e7a55b25079c65a6eb0dd622b007ea6ba08bd9c0 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Wed, 8 Oct 2025 10:10:31 +0200 Subject: [PATCH 6/7] XWIKI-23576: No picker displayed for the page parameter when inserting a new include macro WIP: currently it breaks the UI * Stop removing hidden parameters from the dom --- .../src/main/webjar/xwiki-macro/macroEditor.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js index ea4b2ffdb38..becd54f9221 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js @@ -66,15 +66,15 @@ define('macroParameterEnhancer', ['jquery'], function($) { childrenToRemove.push(childId); } } - group.children = group.children.filter(element => !childrenToRemove.includes(element)); + let displayedChildren = group.children.filter(element => !childrenToRemove.includes(element)); // if the group doesn't contain any children anymore we can just hide it - if (group.children.length === 0) { + if (displayedChildren === 0) { group.hidden = true; // if the group contains a single parameter then we don't consider it's a feature only. - } else if (group.children.length === 1) { + } else if (displayedChildren === 1) { group.featureOnly = false; // if the single children is a group, we actually remove it to display directly the parameters - let uniqueChildKey = group.children[0]; + let uniqueChildKey = displayedChildren[0]; if (isNodeAGroup(uniqueChildKey)) { group.children = parametersMap[uniqueChildKey].children; } @@ -242,6 +242,7 @@ define('macroParameterTreeDisplayer', ['jquery', 'l10n!macroEditor'], function($ let paramNode = parametersMap[nodeKey]; let radioName = 'feature-radio-' + featureName; let radioId = radioName + '-' + paramNode.id; + let hidden = paramNode.hidden; let nodeOutput = $(macroFeatureContentTemplate); nodeOutput.find('.feature-radio').attr({ @@ -252,7 +253,7 @@ define('macroParameterTreeDisplayer', ['jquery', 'l10n!macroEditor'], function($ nodeOutput.find('.feature-choice-name').attr('for', radioId); nodeOutput.find('.feature-choice-name').text(translations.get('selectFeature', paramNode.name)); - if (isFeature && isMandatory) { + if (isFeature && isMandatory && !hidden) { nodeOutput.find('.feature-radio').on('change', function() { $(this).parents('.feature-container').find('.feature-choice-body').removeClass('mandatory'); $(this).parents('.feature-parameter').find('.feature-choice-body').addClass('mandatory'); From 7c96a569b039176fe978ca7e6a08a743a6fb36fc Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Mon, 13 Oct 2025 10:48:33 +0200 Subject: [PATCH 7/7] XWIKI-23576: No picker displayed for the page parameter when inserting a new include macro * Fix the display --- .../src/main/webjar/xwiki-macro/macroEditor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js index becd54f9221..4f1bbbc6b3f 100644 --- a/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js +++ b/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/macroEditor.js @@ -68,10 +68,10 @@ define('macroParameterEnhancer', ['jquery'], function($) { } let displayedChildren = group.children.filter(element => !childrenToRemove.includes(element)); // if the group doesn't contain any children anymore we can just hide it - if (displayedChildren === 0) { + if (displayedChildren.length === 0) { group.hidden = true; // if the group contains a single parameter then we don't consider it's a feature only. - } else if (displayedChildren === 1) { + } else if (displayedChildren.length === 1) { group.featureOnly = false; // if the single children is a group, we actually remove it to display directly the parameters let uniqueChildKey = displayedChildren[0];