Skip to content

Commit

Permalink
fix: add width and height from viewBox if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrosman committed May 31, 2024
1 parent 370ba09 commit 27d95c8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/export/exportSvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export function exportSvg({ svg, history, tools }: ExportParameters) {
// get svg data
const clone = unref(svg).cloneNode(true) as SVGElement
tools.forEach((tool) => tool.beforeExport?.({ svg: clone, history, tools }))
if ((!clone.hasAttribute('width') || !clone.hasAttribute('height')) && clone.hasAttribute('viewBox')) {
const viewBox = clone.getAttribute('viewBox')!.split(' ')
clone.setAttribute('width', viewBox[2])
clone.setAttribute('height', viewBox[3])
}
const xml = new XMLSerializer().serializeToString(clone)

// make it base64
Expand Down

0 comments on commit 27d95c8

Please sign in to comment.