Skip to content

Commit

Permalink
Fix for: SVG export of styles in Firefox is broken. #149
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuebner committed Dec 4, 2023
1 parent 781c032 commit 3b613cd
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/circlegraph/circlegraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>Sprotty Circles Example</h1>
<div id="sprotty" class="sprotty" />
</div>
<div class="copyright">
&copy; 2017 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
</div>
</div>
</div>
Expand Down
26 changes: 24 additions & 2 deletions examples/classdiagram/class-diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
<link rel="stylesheet" href="css/page.css">
<!-- support Microsoft browsers -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dom4/3.0.0/dom4.js">
<script>
document.addEventListener("DOMContentLoaded", function toggleShortcuts(){
var isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
var mac = document.getElementById('mac');
var other = document.getElementById('other');
if (isMac) {
mac.style.display = 'block';
other.style.display = 'none';
} else {
mac.style.display = 'none';
other.style.display = 'block';
}
});
</script>
</head>
<body>
<div class="container">
Expand All @@ -25,8 +39,16 @@ <h1>Sprotty Class Diagram Example</h1>
<div class="col-md-12">
<div id="sprotty" class="sprotty"/>
</div>
<div class="copyright">
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
<div class="footer">
<div id="mac" class="shortcuts">
<b>Fit to screen:</b> Cmd+Shift+F, <b>Center selected:</b> Cmd+Shift+C, <b>Export SVG:</b> Cmd+Shift+E
</div>
<div id="other" class="shortcuts" style="display: none;">
<b>Fit to screen:</b> Ctrl+Shift+F, <b>Center selected:</b> Ctrl+Shift+C, <b>Export SVG:</b> Ctrl+Shift+E
</div>
<div class="copyright">
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
</div>
</div>
</div>
</div>
Expand Down
14 changes: 13 additions & 1 deletion examples/classdiagram/css/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

.copyright {

.footer {
margin-top: 10px;
text-align: right;
font-size: 10px;
color: #888;

display: flex;
justify-content: space-between;
}

.shortcuts {
text-align: left;
}

.copyright {
text-align: right;
}

.help {
Expand Down
2 changes: 1 addition & 1 deletion examples/multicore/multicore.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Sprotty Multicore Example</h1>
</div>
<div class="col-md-12">
<div class="copyright">
&copy; 2017 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/random-graph-distributed/random-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>Sprotty Random Graph Example</h1>
<div id="sprotty" class="sprotty"/>
</div>
<div class="copyright">
&copy; 2022 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
</div>
If no diagram shows up here, you probably haven't started the elk-server yet.
Please follow the steps below:
Expand Down
2 changes: 1 addition & 1 deletion examples/random-graph/random-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>Sprotty Random Graph Example</h1>
<div id="sprotty" class="sprotty"/>
</div>
<div class="copyright">
&copy; 2021 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/svg/svg-prerendered.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Sprotty Prerendered SVG / HTML Example</h1>
</div>
<div class="col-md-12">
<div class="copyright">
&copy; 2017 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
&copy; 2023 <a href="https://www.typefox.io/">TypeFox GmbH</a>.
SVG Logo &copy; 2006 <a href="https://www.w3.org/Graphics/SVG/">W3C</a> (<a href="http://creativecommons.org/licenses/by/2.5">CC BY 2.5</a>).
Tiger &copy; 2002 <a href="https://ghostscript.com">Ghostscript</a> (<a href="https://www.gnu.org/copyleft/gpl-3.0.html">GPL</a>)
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/sprotty/src/features/export/svg-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class SvgExporter {
docCopy.close();
const svgElementNew = docCopy.getElementById(svgElementOrig.id)!;
svgElementNew.removeAttribute('opacity');
this.copyStyles(svgElementOrig, svgElementNew, ['width', 'height', 'opacity']);
// inline-size copied from sprotty-hidden svg shrinks the svg so it is not visible.
this.copyStyles(svgElementOrig, svgElementNew, ['width', 'height', 'opacity', 'inline-size']);
svgElementNew.setAttribute('version', '1.1');
const bounds = this.getBounds(root);
svgElementNew.setAttribute('viewBox', `${bounds.x} ${bounds.y} ${bounds.width} ${bounds.height}`);
Expand Down

0 comments on commit 3b613cd

Please sign in to comment.