Découvrez les nouveautés de cette version : Fonctionnalités, améliorations et évolutions vous attendent ! 👉 Cliquez ici pour en savoir plus

Modifications pour le document Expand

Modifié par superadmin le 21/07/2025 - 08:55

Depuis la version 1.1
modifié par Admin
sur 24/06/2024 - 15:21
Commentaire de modification : Install extension [com.xwiki.pro:xwiki-pro-macros/1.18.3]
À la version 7.1
modifié par Admin
sur 10/02/2025 - 13:08
Commentaire de modification : Install extension [com.xwiki.pro:xwiki-pro-macros-ui/1.26.2]

Résumé

Détails

Propriétés de la Page
Parent
... ... @@ -1,1 +1,1 @@
1 -Confluence.Macros
1 +WebHome
Contenu
... ... @@ -3,11 +3,13 @@
3 3  = Parameters =
4 4  
5 5  |=Parameter|=Description|=Required|=Default
6 -|**title**|Text displayed on the collaspse toggle|No|Click here to expand...
6 +|**title**|Text displayed on the collaspse toggle|No|(empty)
7 +|**expanded**|If selected the expand will be opened automatically when loading the page.|No|False
7 7  
9 +Note: if no title is provided, the title of the first panel or the first header appearing in the content will be used. if there is no such header or panel title, "Click here to expand…" will be used.
8 8  
9 9  = Example Usage =
10 10  
11 -{{expand}}
13 +{{expand expanded="false"}}
12 12  Hello 👀
13 13  {{/expand}}
XWiki.StyleSheetExtension[0]
Code
... ... @@ -8,8 +8,9 @@
8 8   transform: rotate(90deg);
9 9  }
10 10  
11 -.confluence-expand-macro .panel-title {
11 +.confluence-expand-macro .panel-title{
12 12   padding: @panel-heading-padding;
13 + display: flex;
13 13  }
14 14  
15 15  .confluence-expand-macro .panel-body {
... ... @@ -22,6 +22,10 @@
22 22  
23 23  .confluence-expand-macro summary:hover {
24 24   cursor: pointer;
26 +}
27 +
28 +.panel-title:hover .title-text {
29 + cursor: pointer;
25 25   text-decoration: underline;
26 26  }
27 27  
... ... @@ -30,6 +30,11 @@
30 30   border: none;
31 31  }
32 32  
38 +.confluence-expand-macro.panel.panel-default .panel-body ul {
39 + list-style-type: revert;
40 + padding-left: revert;
41 +}
42 +
33 33  .confluence-expand-macro.panel {
34 34   background: unset;
35 35  }
XWiki.WikiMacroClass[0]
Code de la macro
... ... @@ -1,15 +1,45 @@
1 1  {{velocity output="false"}}
2 2  #macro (executeMacro)
3 - $xwiki.ssx.use('Confluence.Macros.Expand')
4 - #set ($opened = $xcontext.action == 'edit')
5 -
3 + ## To avoid an issue regarding {{wikimacroparameter}} and {{wikimacrocontent}} that fail to render when in
4 + ## edit mode while inside a HTML macro, we need to manually write the HTML by using XWiki syntax. This way,
5 + ## while the macro will always be expanded when in edit mode, the user will be able to modify the text inline.
6 + #set ($targetSyntaxId = $wikimacro.context.transformationContext.targetSyntax.type.id)
7 + #set ($discard = $xwiki.ssx.use('Confluence.Macros.Expand'))
8 + #if ($targetSyntaxId == 'annotatedhtml' || $targetSyntaxId == 'annotatedxhtml' ||
9 + $request.outputSyntax == 'annotatedhtml')
10 + (% class="confluence-expand-macro panel panel-default" %)
11 + (((
12 + (((
13 + (% class="panel-title" %)
14 + (((
15 + (% class="glyphicon glyphicon-menu-down" aria-hidden="true" %)
16 + ((()))
17 + {{wikimacroparameter name='title' /}}
18 + )))
19 + )))
20 + (% class="panel-body" %)
21 + (((
22 + {{wikimacrocontent /}}
23 + )))
24 + )))
25 + #else
26 + #set ($opened = $xcontext.action == 'edit' || $xcontext.action == 'export' || $wikimacro.parameters.expanded)
6 6   {{html clean="false" wiki="true"}}
7 7   <details class="confluence-expand-macro panel panel-default" #if ($opened)open#end>
8 8   <summary>
9 - <div class="panel-title">
30 + <span class="panel-title">
10 10   <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
11 - $services.rendering.escape($escapetool.xml("${wikimacro.parameters.title}"), 'xwiki/2.1')
12 - </div>
32 + #set ($title = $wikimacro.parameters.title)
33 + #if ("$!title" == "")
34 + #set ($title = $services.promacroexpand.getAutoTitle($wikimacro.content, $xwiki.currentContentSyntaxId))
35 + #if ("$!title" == "")
36 + #set ($title = $services.localization.render("rendering.macro.expand.defaultexpandtitle"))
37 + #end
38 + #end
39 + <span class="title-text">
40 + $services.rendering.escape($escapetool.xml($title), $xwiki.currentContentSyntaxId)
41 + </span>
42 + </span>
13 13   </summary>
14 14   <div class="panel-body">
15 15  
... ... @@ -18,6 +18,7 @@
18 18   </div>
19 19   </details>
20 20   {{/html}}
51 + #end
21 21  #end
22 22  {{/velocity}}
23 23  
... ... @@ -25,7 +25,7 @@
25 25  ## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right
26 26  ## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that
27 27  ## don't have view right on those pages.
28 -#if ($services.licensing.licensor.hasLicensureForEntity($xcontext.macro.doc.documentReference))
59 +#if ($services.promacrolicensing.hasLicensureForEntity($xcontext.macro.doc.documentReference))
29 29   #executeMacro
30 30  #else
31 31   {{missingLicenseMessage extensionName="proMacros.extension.name"/}}
Disponibilité du contenu de la macro
... ... @@ -1,1 +1,1 @@
1 -Optional
1 +Mandatory
XWiki.WikiMacroParameterClass[1]
Valeur par défaut du paramètre
... ... @@ -1,0 +1,1 @@
1 +0
Paramètre obligatoire
... ... @@ -1,0 +1,1 @@
1 +Non
Nom du paramètre
... ... @@ -1,0 +1,1 @@
1 +expanded
Type du paramètre
... ... @@ -1,0 +1,1 @@
1 +java.lang.Boolean