From bb36e0062b9450159b7380523e77cd24d8fbb833 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Wed, 21 Nov 2018 21:29:24 -0600 Subject: [PATCH] fix tab characters in SVG - closes #586 --- components/Editor.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/Editor.js b/components/Editor.js index fb16717..622e29e 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -175,12 +175,16 @@ class Editor extends React.Component { try { if (type === 'blob') { if (format === 'svg') { - return domtoimage - .toSvg(node, config) - .then(dataUrl => dataUrl.replace(/ /g, ' ')) - .then(uri => uri.slice(uri.indexOf(',') + 1)) - .then(data => new Blob([data], { type: 'image/svg+xml' })) - .then(data => window.URL.createObjectURL(data)) + return ( + domtoimage + .toSvg(node, config) + .then(dataUrl => dataUrl.replace(/ /g, ' ')) + // https://stackoverflow.com/questions/7604436/xmlparseentityref-no-name-warnings-while-loading-xml-into-a-php-file + .then(dataUrl => dataUrl.replace(/&(?!#?[a-z0-9]+;)/g, '&')) + .then(uri => uri.slice(uri.indexOf(',') + 1)) + .then(data => new Blob([data], { type: 'image/svg+xml' })) + .then(data => window.URL.createObjectURL(data)) + ) } return await domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob))