diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 03d9549..fa6b8a3 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -2,5 +2,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 53a0e44..7c452ec 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,14 @@
-
-
+
+
-
+
+
-
-
+
+
@@ -27,61 +28,78 @@
- {
- "history": [
+
- {
- "prStates": [
+}]]>
+
+}]]>
{
"selectedUrlAndAccountId": {
"url": "https://github.com/iib0011/omni-tools.git",
@@ -133,7 +151,7 @@
"Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
"Vitest.replaceText function.executor": "Run",
- "git-widget-placeholder": "split-pdf",
+ "git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/components/input",
@@ -184,7 +202,7 @@
-
+
@@ -260,9 +278,9 @@
-
+
@@ -348,14 +366,7 @@
-
-
-
- 1740491737480
-
-
-
- 1740491737480
+
@@ -741,7 +752,15 @@
1742967844908
-
+
+
+ 1743019312699
+
+
+
+ 1743019312699
+
+
@@ -788,7 +807,6 @@
-
@@ -813,7 +831,8 @@
-
+
+
diff --git a/package-lock.json b/package-lock.json
index d23e3e9..b2074f9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -28,6 +28,7 @@
"jimp": "^0.22.12",
"lint-staged": "^15.4.3",
"lodash": "^4.17.21",
+ "mime": "^4.0.6",
"morsee": "^1.0.9",
"notistack": "^3.0.1",
"omggif": "^1.0.10",
@@ -7298,6 +7299,18 @@
"xtend": "^4.0.0"
}
},
+ "node_modules/load-bmfont/node_modules/mime": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "license": "MIT",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/local-pkg": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz",
@@ -7622,14 +7635,18 @@
}
},
"node_modules/mime": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
- "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.6.tgz",
+ "integrity": "sha512-4rGt7rvQHBbaSOF9POGkk1ocRP16Md1x36Xma8sz8h8/vfCUI2OtEIeCqe4Ofes853x4xDoPiFLIT47J5fI/7A==",
+ "funding": [
+ "https://github.com/sponsors/broofa"
+ ],
+ "license": "MIT",
"bin": {
- "mime": "cli.js"
+ "mime": "bin/cli.js"
},
"engines": {
- "node": ">=4"
+ "node": ">=16"
}
},
"node_modules/mime-db": {
@@ -7646,6 +7663,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
diff --git a/package.json b/package.json
index d97f8e3..68dfa2d 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,7 @@
"jimp": "^0.22.12",
"lint-staged": "^15.4.3",
"lodash": "^4.17.21",
+ "mime": "^4.0.6",
"morsee": "^1.0.9",
"notistack": "^3.0.1",
"omggif": "^1.0.10",
diff --git a/src/components/result/ToolFileResult.tsx b/src/components/result/ToolFileResult.tsx
index 315ed63..d34eea3 100644
--- a/src/components/result/ToolFileResult.tsx
+++ b/src/components/result/ToolFileResult.tsx
@@ -49,7 +49,8 @@ export default function ToolFileResult({
const handleDownload = () => {
if (value) {
- const filename = 'output-omni-tools.' + extension;
+ const hasExtension = value.name.includes('.');
+ const filename = hasExtension ? value.name : `${value.name}.${extension}`;
const blob = new Blob([value], { type: value.type });
const url = window.URL.createObjectURL(blob);
diff --git a/src/components/result/ToolTextResult.tsx b/src/components/result/ToolTextResult.tsx
index 1d85720..2f9cef0 100644
--- a/src/components/result/ToolTextResult.tsx
+++ b/src/components/result/ToolTextResult.tsx
@@ -1,16 +1,19 @@
import { Box, TextField } from '@mui/material';
-import React, { useContext, useEffect } from 'react';
+import React, { useContext } from 'react';
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
import InputHeader from '../InputHeader';
import ResultFooter from './ResultFooter';
-import { replaceSpecialCharacters } from '../../utils/string';
+import { replaceSpecialCharacters } from '@utils/string';
+import mime from 'mime';
export default function ToolTextResult({
title = 'Result',
- value
+ value,
+ extension = 'txt'
}: {
title?: string;
value: string;
+ extension?: string;
}) {
const { showSnackBar } = useContext(CustomSnackBarContext);
const handleCopy = () => {
@@ -22,9 +25,13 @@ export default function ToolTextResult({
});
};
const handleDownload = () => {
- const filename = 'output-omni-tools.txt';
+ const filename = `output-omni-tools.${extension}`;
- const blob = new Blob([value], { type: 'text/plain' });
+ const mimeType = mime.getType(extension) || 'text/plain';
+
+ const blob = new Blob([value], {
+ type: mimeType
+ });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
diff --git a/src/pages/tools/json/json-to-xml/index.tsx b/src/pages/tools/json/json-to-xml/index.tsx
index 78cec17..11977a4 100644
--- a/src/pages/tools/json/json-to-xml/index.tsx
+++ b/src/pages/tools/json/json-to-xml/index.tsx
@@ -86,7 +86,9 @@ export default function JsonToXml({ title }: ToolComponentProps) {
inputComponent={
}
- resultComponent={}
+ resultComponent={
+
+ }
getGroups={({ values, updateField }) => [
{
title: 'Output XML Indentation',