Änderungen von Dokument Expand

Zuletzt geändert von xwikiadmin am 2025/12/11 07:47

Von Version 5.1
bearbeitet von xwikiadmin
am 2025/05/21 09:22
Änderungskommentar: Migrated property [feature] from class [XWiki.WikiMacroParameterClass]
Auf Version 8.1
bearbeitet von xwikiadmin
am 2025/12/11 07:47
Änderungskommentar: Install extension [com.xwiki.pro:xwiki-pro-macros-ui/1.28.5]

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -11,5 +11,5 @@
11 11  = Example Usage =
12 12  
13 13  {{expand expanded="false"}}
14 -Hello 👀
14 +Hello
15 15  {{/expand}}
XWiki.StyleSheetExtension[0]
Code
... ... @@ -10,7 +10,7 @@
10 10  
11 11  .confluence-expand-macro .panel-title{
12 12   padding: @panel-heading-padding;
13 - display: block;
13 + display: flex;
14 14  }
15 15  
16 16  .confluence-expand-macro .panel-body {
... ... @@ -23,6 +23,10 @@
23 23  
24 24  .confluence-expand-macro summary:hover {
25 25   cursor: pointer;
26 +}
27 +
28 +.panel-title:hover .title-text {
29 + cursor: pointer;
26 26   text-decoration: underline;
27 27  }
28 28  
XWiki.WikiMacroClass[0]
Makro-Code
... ... @@ -1,30 +1,83 @@
1 1  {{velocity output="false"}}
2 -#macro (executeMacro)
3 - #set ($discard = $xwiki.ssx.use('Confluence.Macros.Expand'))
4 - #set ($opened = $xcontext.action == 'edit' || $xcontext.action == 'export' || $wikimacro.parameters.expanded)
2 +#macro (exportMode $escapedTitle)
3 + ## Use a different structure when exporting to make sure that the pagedjs can properly parse the content.
4 +
5 5   {{html clean="false" wiki="true"}}
6 - <details class="confluence-expand-macro panel panel-default" #if ($opened)open#end>
7 - <summary>
6 + <div class = "panel panel-default confluence-expand-macro">
7 + <div class>
8 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>
19 - </summary>
9 + <span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span>
10 + <span class="title-text">
11 + $escapedTitle
12 + </span>
13 + </span>
14 + </div>
20 20   <div class="panel-body">
21 21  
22 22   {{wikimacrocontent /}}
23 23  
24 24   </div>
25 - </details>
20 + </div>
26 26   {{/html}}
22 +
27 27  #end
24 +
25 +#macro (executeMacro)
26 +
27 + #set ($discard = $xwiki.ssx.use('Confluence.Macros.Expand'))
28 + #set ($title = $wikimacro.parameters.title)
29 + #if ("$!title" == "")
30 + #set ($title = $services.promacroexpand.getAutoTitle($wikimacro.content, $xwiki.currentContentSyntaxId))
31 + #end
32 + #if ("$!title" == "")
33 + #set ($title = $services.localization.render("rendering.macro.expand.defaultexpandtitle"))
34 + #end
35 + #set ($escapedTitle = $services.rendering.escape($escapetool.xml($title), $xwiki.currentContentSyntaxId))
36 + #if ($xcontext.action == 'export')
37 + #exportMode($escapedTitle)
38 + #else
39 + ## To avoid an issue regarding {{wikimacroparameter}} and {{wikimacrocontent}} that fail to render when in
40 + ## edit mode while inside a HTML macro, we need to manually write the HTML by using XWiki syntax. This way,
41 + ## while the macro will always be expanded when in edit mode, the user will be able to modify the text inline.
42 + #set ($targetSyntaxId = $wikimacro.context.transformationContext.targetSyntax.type.id)
43 + #if ($targetSyntaxId == 'annotatedhtml' || $targetSyntaxId == 'annotatedxhtml' || $request.outputSyntax == 'annotatedhtml')
44 + (% class="confluence-expand-macro panel panel-default" %)
45 + (((
46 + (((
47 + (% class="panel-title" %)
48 + (((
49 + (% class="glyphicon glyphicon-menu-down" aria-hidden="true" %)
50 + ((()))
51 + {{wikimacroparameter name='title' /}}
52 + )))
53 + )))
54 + (% class="panel-body" %)
55 + (((
56 + {{wikimacrocontent /}}
57 + )))
58 + )))
59 + #else
60 + #set ($opened = $xcontext.action == 'edit'|| $wikimacro.parameters.expanded)
61 + {{html clean="false" wiki="true"}}
62 + <details class="confluence-expand-macro panel panel-default" #if ($opened)open#end>
63 + <summary>
64 + <span class="panel-title">
65 + <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
66 + <span class="title-text">
67 + $escapedTitle
68 + </span>
69 + </span>
70 + </summary>
71 + <div class="panel-body">
72 +
73 + {{wikimacrocontent /}}
74 +
75 + </div>
76 + </details>
77 + {{/html}}
78 + #end
79 + #end
80 +#end
28 28  {{/velocity}}
29 29  
30 30  {{velocity}}
Makrobeschreibung
... ... @@ -1,5 +1,0 @@
1 -Add the Expand macro to your page to provide content in an expandable / collapsible section.
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.
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.
Verfügbarkeit von Makroinhalten
... ... @@ -1,1 +1,1 @@
1 -Optional
1 +Mandatory
XWiki.WikiMacroParameterClass[0]
Parameter-Vorgabe
... ... @@ -1,0 +1,1 @@
1 +Click here to expand...
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -Defines the text that appears next to the expand/collapse icon.