imported_svg = {
const replacedText = await local_file.text()
.then(svgText => svgText
.replace(/"(eb_(text|color)_[0-9]{3})[^"]+"/g, '"$1"')
.replace(/(<g id="eb_color_[0-9]{3}"[^>]*>\s*<path[^>]*) id="[^"]*"([^>]*>(?:.*?)<\/\s*path>\s*<\/g>)/g, '$1$2')
.replace(/(<g id="eb_text_[0-9]{3}"[^>]*>\s*<text[^>]*) id="[^"]*"([^>]*>(?:.*?)<\/\s*text>\s*<\/g>)/g, '$1$2')
.replace(/<g id="(eb_color_[0-9]{3})"[^>]*>\s*<path([^>]*[^>]*(?:>(?:.*?)<\/\s*path>|\/>))\s*<\/g>/g, '<path id="$1"$2')
.replace(/<g id="(eb_text_[0-9]{3})"[^>]*>\s*<text([^>]*>(?:.*?)<\/\s*text>)\s*<\/g>/g, '<text id="$1"$2'));
const ids = replacedText.match(/eb_(?:text|color)_[0-9]{3}/g);
const duplicated_ids = _(ids).groupBy().pickBy(x => x.length > 1).keys().value();
const replacedTextBlob = new Blob([replacedText], {type: 'image/svg+xml'});
return {
blob_url: URL.createObjectURL(replacedTextBlob),
duplicated_ids: duplicated_ids
}
}