✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
add jpeg download option
AykutSarac0b7fa80ca629
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 1b29e452..b3f11804 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -11,6 +11,7 @@"linebreak-style": ["error", "unix"],"quotes": ["error", "double", { "avoidEscape": true }],"semi": ["error", "always"],+ "prefer-const": "error","space-before-function-paren": ["error",{diff --git a/src/containers/Modals/DownloadModal/index.tsx b/src/containers/Modals/DownloadModal/index.tsxindex 1df3633b..957b08e0 100644--- a/src/containers/Modals/DownloadModal/index.tsx+++ b/src/containers/Modals/DownloadModal/index.tsx@@ -12,7 +12,7 @@ import {ColorInput,Stack,} from "@mantine/core";-import { toBlob, toPng, toSvg } from "html-to-image";+import { toBlob, toJpeg, toPng, toSvg } from "html-to-image";import { event } from "react-ga";import toast from "react-hot-toast";import { FiCopy, FiDownload } from "react-icons/fi";@@ -20,8 +20,20 @@ import { FiCopy, FiDownload } from "react-icons/fi";enum Extensions {SVG = "svg",PNG = "png",+ JPEG = "jpeg",}+const getDownloadFormat = (format: Extensions) => {+ switch (format) {+ case Extensions.SVG:+ return toSvg;+ case Extensions.PNG:+ return toPng;+ case Extensions.JPEG:+ return toJpeg;+ }+};+const swatches = ["#B80000","#DB3E00",@@ -95,9 +107,7 @@ export const DownloadModal: React.FC<ModalProps> = ({ opened, onClose }) => {const imageElement = document.querySelector("svg[id*='ref']") as HTMLElement;- let exportImage = extension === Extensions.SVG ? toSvg : toPng;-- const dataURI = await exportImage(imageElement, {+ const dataURI = await getDownloadFormat(extension)(imageElement, {quality: fileDetails.quality,backgroundColor: fileDetails.backgroundColor,});@@ -129,11 +139,12 @@ export const DownloadModal: React.FC<ModalProps> = ({ opened, onClose }) => {<SegmentedControlvalue={extension}onChange={e => setExtension(e as Extensions)}+ fullWidthdata={[{ label: "SVG", value: Extensions.SVG },{ label: "PNG", value: Extensions.PNG },+ { label: "JPEG", value: Extensions.JPEG },]}- fullWidth/></Grid.Col></Grid>diff --git a/src/lib/utils/core/traverse.ts b/src/lib/utils/core/traverse.tsindex f03695c3..995e0c13 100644--- a/src/lib/utils/core/traverse.ts+++ b/src/lib/utils/core/traverse.ts@@ -245,7 +245,7 @@ export const traverse = ({parentType,}: Traverse) => {const graph = states.graph;- let { type, children, value } = objectToTraverse;+ const { type, children, value } = objectToTraverse;if (!children) {handleNoChildren(value, states, graph, myParentId, parentType, nextType);diff --git a/src/store/useFile.ts b/src/store/useFile.tsindex 1e9869ee..8321a103 100644--- a/src/store/useFile.ts+++ b/src/store/useFile.ts@@ -76,7 +76,7 @@ const debouncedUpdateJson = debounce(const filterArrayAndObjectFields = (obj: object) => {const result = {};- for (let key in obj) {+ for (const key in obj) {if (obj.hasOwnProperty(key)) {if (Array.isArray(obj[key]) || typeof obj[key] === "object") {result[key] = obj[key];diff --git a/src/store/useGraph.ts b/src/store/useGraph.tsindex d02cd219..596027f8 100644--- a/src/store/useGraph.ts+++ b/src/store/useGraph.ts@@ -89,7 +89,7 @@ const useGraph = create<Graph & GraphActions>((set, get) => ({);const childrenEdges = getChildrenEdges(childrenNodes, get().edges);- let nodesConnectedToParent = childrenEdges.reduce((nodes: string[], edge) => {+ const nodesConnectedToParent = childrenEdges.reduce((nodes: string[], edge) => {edge.from && !nodes.includes(edge.from) && nodes.push(edge.from);edge.to && !nodes.includes(edge.to) && nodes.push(edge.to);return nodes;