Export current document as SVG when pressing Ctrl+Shift+S (#160)

* Export current document when pressing Ctrl+Shift+S

* Use a blob for download

* Add Ctrl + E shortcut, match on lower case

* Don't mount element in DOM

* Polish some keybindings

* Add initialization for MappingEntries

* Implement svg coloring

* Add newline after svg tag

* Add spaces to svg style format

* Fix more svg formatting

* Add space before />

* Remove duplicate whitespace
This commit is contained in:
TrueDoctor
2021-05-28 20:43:51 +02:00
committed by GitHub
parent 9f63c6e8ea
commit eb48fbd180
16 changed files with 137 additions and 43 deletions
+7 -4
View File
@@ -24,10 +24,13 @@ impl LayerData for PolyLine {
return;
}
let _ = write!(svg, r#"<polyline points=""#);
for p in &self.points {
let _ = write!(svg, " {:.3} {:.3}", p.x, p.y);
let mut points = self.points.iter();
let first = points.next().unwrap();
let _ = write!(svg, "{:.3} {:.3}", first.x, first.y);
for point in points {
let _ = write!(svg, " {:.3} {:.3}", point.x, point.y);
}
let _ = write!(svg, r#"" {}/>"#, self.style.render());
let _ = write!(svg, r#""{} />"#, self.style.render());
}
}
@@ -41,5 +44,5 @@ fn polyline_should_render() {
let mut svg = String::new();
polyline.render(&mut svg);
assert_eq!(r#"<polyline points=" 3.000 4.124 1.000 5.540" style="stroke: #00FF00FF;stroke-width:0.4;"/>"#, svg);
assert_eq!(r##"<polyline points="3.000 4.124 1.000 5.540" stroke="#00FF00" stroke-width="0.4" />"##, svg);
}