diff options
author | Sunil Shetye | 2025-02-26 12:36:58 +0530 |
---|---|---|
committer | Sunil Shetye | 2025-02-26 12:46:23 +0530 |
commit | b0b317b9162f9e855bc719fcba0844b5845c0edb (patch) | |
tree | 6606ba4cb0adea847cae8e5218a3c88e9c4e4a84 | |
parent | de413fc0bf5f3121e414f399ead466dc519cfa42 (diff) | |
download | Common-Interface-Project-b0b317b9162f9e855bc719fcba0844b5845c0edb.tar.gz Common-Interface-Project-b0b317b9162f9e855bc719fcba0844b5845c0edb.tar.bz2 Common-Interface-Project-b0b317b9162f9e855bc719fcba0844b5845c0edb.zip |
add saveFile in utils
-rw-r--r-- | blocks/eda-frontend/src/utils/GalleryUtils.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js index 1dad8222..84811c28 100644 --- a/blocks/eda-frontend/src/utils/GalleryUtils.js +++ b/blocks/eda-frontend/src/utils/GalleryUtils.js @@ -1,3 +1,5 @@ +import { saveAs } from 'file-saver' + const getXsltProcessor = async () => { const xcos2xml = '/xcos2xml.xsl' const response = await fetch(xcos2xml) @@ -173,3 +175,14 @@ export const styleToObject = (style) => { return styleObject } + +export const saveToFile = (filename, filetype, data) => { + const blob = new Blob([data], { type: filetype + ';charset=utf-8' }) + saveAs(blob, filename) +} + +export const saveXmlToFile = (filename, xmlDoc) => { + const serializer = new XMLSerializer() + const data = serializer.serializeToString(xmlDoc) + saveToFile(filename, 'application/xml', data) +} |