Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Dec 6, 2023
1 parent b17c48c commit 0b01281
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions teammapper-frontend/mmp/src/map/handlers/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,16 @@ export default class Export {
// convert all foreignObjects to native svg text to ensure better compatibility with svg readers
d3.select(clone).selectAll("foreignObject").nodes().forEach((fo: HTMLElement) => {
const parent = fo.parentElement
d3.select(parent).attr("width", fo.getAttribute("width")).append("text")
.text(fo.firstChild.textContent)
.attr("y", parseInt(fo.getAttribute('y'), 10) + parseInt((fo.firstElementChild as HTMLElement).style.fontSize, 10))
.attr("x", parseInt(fo.getAttribute('x'), 10) + Math.floor(parseInt(fo.getAttribute('width'), 10) / 2))
.attr("text-anchor", "middle")
.attr("font-family", (fo.firstElementChild as HTMLElement).style.fontFamily)
.attr("font-size", (fo.firstElementChild as HTMLElement).style.fontSize)
.attr("fill", (fo.firstElementChild as HTMLElement).style.color);
d3.select(parent)
.attr("width", fo.getAttribute("width"))
.append("text")
.text(fo.firstChild.textContent)
.attr("y", parseInt(fo.getAttribute('y'), 10) + parseInt((fo.firstElementChild as HTMLElement).style.fontSize, 10))
.attr("x", parseInt(fo.getAttribute('x'), 10) + Math.floor(parseInt(fo.getAttribute('width'), 10) / 2))
.attr("text-anchor", "middle")
.attr("font-family", (fo.firstElementChild as HTMLElement).style.fontFamily)
.attr("font-size", (fo.firstElementChild as HTMLElement).style.fontSize)
.attr("fill", (fo.firstElementChild as HTMLElement).style.color);
fo.remove()
})

Expand Down

0 comments on commit 0b01281

Please sign in to comment.