Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWiki export doesn't work properly when a diagram is present. #311 #312

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions application-diagram-ui/src/main/resources/Diagram/DiagramMacro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,19 @@
#if ($xcontext.action == 'export' && $diagramObj.getValue('exportUsingSVG') == 0
&& $diagram.getAttachment($pngFileName))
#set ($fileName = $pngFileName)
#elseif ($xcontext.action == 'export')
#set ($reference = $xcontext.macro.params.reference)
#if ($stringtool.isEmpty($reference))
#set ($reference = $services.model.createDocumentReference('Diagram', $doc.documentReference.parent))
#else
#set ($reference = $services.model.resolveDocument($reference))
#end
#set ($diagram = $xwiki.getDocument($reference))
#set ($output = "{{html}}<div>$diagram.getAttachment('diagram.svg').getContentAsString()</div>{{/html}}")
#else
#set ($diagramURL = $diagram.getAttachmentURL($fileName, 'download', "v=$!diagram.version"))
#set ($output = "{{html clean='false'}}<img src='$diagramURL' alt='$escapetool.xml($diagramTitle)'/>{{/html}}")
#end
#set ($diagramURL = $diagram.getAttachmentURL($fileName, 'download', "v=$!diagram.version"))
#set ($output = "{{html clean='false'}}<img src='$diagramURL' alt='$escapetool.xml($diagramTitle)'/>{{/html}}")
#else
#set ($output = "{{display reference='$services.rendering.escape($reference, $xcontext.macro.doc.syntax)' /}}")
#set ($showCaption = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@
#end
{{html clean="false"}}
## Check if the query contains the parameter for getting the diagram from URL.
<div class="diagram"

#set ($dispalyDiv = "show")
#if ($xcontext.action == "export")
#set ($displayDiv = "hidden")
<div>
$doc.getAttachment('diagram.svg').getContentAsString()
<div>
#end

<div class="diagram $displayDiv"
data-diagram-config="$escapetool.xml($jsontool.serialize($diagramConfig))"
data-toolbar="$escapetool.xml($toolbar)"
#if ("$!request.source" == '')
Expand Down