prepare to import svg

This commit is contained in:
fyears
2021-12-11 22:45:21 +08:00
parent b6bae792c6
commit e6591721e2
5 changed files with 32 additions and 0 deletions
+8
View File
@@ -155,3 +155,11 @@ export const getPathFolder = (a: string) => {
export const setToString = (a: Set<string>, delimiter: string = ",") => {
return [...a].join(delimiter);
};
export const extractSvgSub = (x: string, subEl: string = "rect") => {
const parser = new window.DOMParser();
const dom = parser.parseFromString(x, "image/svg+xml");
const svg = dom.querySelector("svg");
svg.setAttribute("viewbox", "0 0 10 10");
return svg.innerHTML;
};