mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: fancyBackgrounds in svg
This commit is contained in:
parent
94f20566d1
commit
e8cc787edc
4 changed files with 106 additions and 16 deletions
|
@ -123,3 +123,24 @@ export const normalizeSVG = async (SVGString: string) => {
|
|||
return svg.outerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
export const loadSVGElement = (filePath: string) => {
|
||||
return new Promise<SVGSVGElement>((resolve, reject) => {
|
||||
fetch(filePath)
|
||||
.then((response) => response.text())
|
||||
.then((svgString) => {
|
||||
const parser = new DOMParser();
|
||||
const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
|
||||
const svgElement = svgDoc.documentElement;
|
||||
|
||||
if (svgElement instanceof SVGSVGElement) {
|
||||
resolve(svgElement);
|
||||
} else {
|
||||
reject(new Error("Parsed element is not an SVGSVGElement"));
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue