Changes for page Expand

Last modified by Yana Oksner on 2025/04/30 10:28

From version 2.1
edited by Yana Oksner
on 2024/02/23 13:49
Change comment: Install extension [com.xwiki.pro:xwiki-pro-macros/1.15.0]
To version 5.1
edited by Yana Oksner
on 2024/12/03 16:51
Change comment: Install extension [com.xwiki.pro:xwiki-pro-macros-ui/1.25.1]

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,1 @@
1 -Confluence.Macros
1 +WebHome
Content
... ... @@ -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
... ... @@ -4,12 +4,13 @@
4 4   transition: transform 0.3s;
5 5  }
6 6  
7 -.confluence-expand-macro[open] .glyphicon {
7 +.confluence-expand-macro[open] > summary .glyphicon {
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: block;
13 13  }
14 14  
15 15  .confluence-expand-macro .panel-body {
... ... @@ -30,6 +30,11 @@
30 30   border: none;
31 31  }
32 32  
34 +.confluence-expand-macro.panel.panel-default .panel-body ul {
35 + list-style-type: revert;
36 + padding-left: revert;
37 +}
38 +
33 33  .confluence-expand-macro.panel {
34 34   background: unset;
35 35  }
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,18 +1,26 @@
1 1  {{velocity output="false"}}
2 2  #macro (executeMacro)
3 - $xwiki.ssx.use('Confluence.Macros.Expand')
4 - #set ($opened = $xcontext.action == 'edit')
5 -
3 + #set ($discard = $xwiki.ssx.use('Confluence.Macros.Expand'))
4 + #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">
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>
8 + <span class="panel-title">
9 + <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
10 + #set ($title = $wikimacro.parameters.title)
11 + #if ("$!title" == "")
12 + #set ($title = $services.promacroexpand.getAutoTitle($wikimacro.content, $xwiki.currentContentSyntaxId))
13 + #if ("$!title" == "")
14 + #set ($title = $services.localization.render("rendering.macro.expand.defaultexpandtitle"))
15 + #end
16 + #end
17 + $services.rendering.escape($escapetool.xml($title), $xwiki.currentContentSyntaxId)
18 + </span>
13 13   </summary>
14 14   <div class="panel-body">
21 +
15 15   {{wikimacrocontent /}}
23 +
16 16   </div>
17 17   </details>
18 18   {{/html}}
... ... @@ -23,7 +23,7 @@
23 23  ## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right
24 24  ## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that
25 25  ## don't have view right on those pages.
26 -#if ($services.licensing.licensor.hasLicensureForEntity($xcontext.macro.doc.documentReference))
34 +#if ($services.promacrolicensing.hasLicensureForEntity($xcontext.macro.doc.documentReference))
27 27   #executeMacro
28 28  #else
29 29   {{missingLicenseMessage extensionName="proMacros.extension.name"/}}
Macro description
... ... @@ -1,5 +1,5 @@
1 -Add the Expand macro to your page to provide content in an expandable / collapsible section. 
1 +Add the Expand macro to your page to provide content in an expandable / collapsible section.
2 2  
3 -This is one of Confluence's most popular macros. It's great for: visually reducing the amount of information on a page, breaking process information down into clickable steps, hiding background or obsolete information, while still keeping it on the page for future reference.
3 +This is one of Confluence's most popular macros. It's great for: visually reducing the amount of information on a page, breaking process information down into clickable steps, hiding background or obsolete information, while still keeping it on the page for future reference.
4 4  
5 -The macro is collapsed by default, people need to click each one to expand it. There's no way to expand all macros on a page at once, however all Expand macros are automatically expanded when you print or export the page to PDF.
5 +The macro is collapsed by default, people need to click each one to expand it. There's no way to expand all macros on a page at once, however all Expand macros are automatically expanded when you print or export the page to PDF.
XWiki.WikiMacroParameterClass[0]
Parameter default value
... ... @@ -1,1 +1,0 @@
1 -Click here to expand...
XWiki.WikiMacroParameterClass[1]
Parameter default value
... ... @@ -1,0 +1,1 @@
1 +0
Parameter mandatory
... ... @@ -1,0 +1,1 @@
1 +No
Parameter name
... ... @@ -1,0 +1,1 @@
1 +expanded
Parameter type
... ... @@ -1,0 +1,1 @@
1 +java.lang.Boolean