Skip to content

Commit

Permalink
fix missing text from export (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek authored Jan 16, 2024
1 parent 7a2b7a8 commit d1b2f97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion teammapper-frontend/mmp/src/map/handlers/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default class Export {
const splittedText = fo.firstChild.textContent.split('\n')
// line breaks are created via tspan elements that are relatively positioned using dy property
const svgTextWithLineBreaks = splittedText.map((text, i) => `<tspan dy="${(i === 0 || i === splittedText.length - 1) ? '0' : '1.2em'}" x="${x}">${text}</tspan>`)
const textSVG = DOMPurify.sanitize(svgTextWithLineBreaks.join(''), { USE_PROFILES: { svg: true }, NAMESPACE: 'http://www.w3.org/2000/svg'})
d3.select(parent)
.attr('width', fo.getAttribute('width'))
.append('text')
Expand All @@ -145,7 +146,7 @@ export default class Export {
.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)
.html(DOMPurify.sanitize(svgTextWithLineBreaks.join('')))
.html(textSVG)
fo.remove()
})

Expand Down
14 changes: 10 additions & 4 deletions teammapper-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion teammapper-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@ngx-translate/http-loader": "^7.0.0",
"angular2-hotkeys": "^13.1.0",
"d3": "7.6.1",
"dompurify": "2.4.0",
"dompurify": "3.0.6",
"eslint-config-standard": "^17.0.0",
"jspdf": "^2.5.1",
"localforage": "1.10.0",
Expand Down

0 comments on commit d1b2f97

Please sign in to comment.