chore: result file name

This commit is contained in:
Ibrahima G. Coulibaly
2025-03-26 20:24:46 +00:00
parent c3023ae4ef
commit ab587e60d0
7 changed files with 114 additions and 61 deletions

View File

@@ -2,5 +2,10 @@
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ImplicitTypeConversion" enabled="true" level="WARNING" enabled_by_default="true">
<option name="BITS" value="1720" />
<option name="FLAG_EXPLICIT_CONVERSION" value="true" />
<option name="IGNORE_NODESET_TO_BOOLEAN_VIA_STRING" value="true" />
</inspection_tool>
</profile> </profile>
</component> </component>

117
.idea/workspace.xml generated
View File

@@ -4,13 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: split pdf"> <list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: typo">
<change afterPath="$PROJECT_DIR$/src/components/input/ToolPdfInput.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/components/result/ToolTextResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolTextResult.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/tools/json/json-to-xml/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/json/json-to-xml/index.tsx" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -27,61 +28,78 @@
<option name="PUSH_AUTO_UPDATE" value="true" /> <option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="main" /> <entry key="$PROJECT_DIR$" value="chesterkxng" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RESET_MODE" value="HARD" /> <option name="RESET_MODE" value="HARD" />
</component> </component>
<component name="GitHubPullRequestSearchHistory">{ <component name="GitHubPullRequestSearchHistory"><![CDATA[{
&quot;history&quot;: [ "history": [
{ {
&quot;assignee&quot;: &quot;iib0011&quot; "assignee": "iib0011"
},
{
"state": "OPEN"
} }
], ],
&quot;lastFilter&quot;: { "lastFilter": {
&quot;assignee&quot;: &quot;iib0011&quot; "state": "OPEN"
} }
}</component> }]]></component>
<component name="GitHubPullRequestState">{ <component name="GitHubPullRequestState"><![CDATA[{
&quot;prStates&quot;: [ "prStates": [
{ {
&quot;id&quot;: { "id": {
&quot;id&quot;: &quot;PR_kwDOMJIfts51PkS9&quot;, "id": "PR_kwDOMJIfts51PkS9",
&quot;number&quot;: 22 "number": 22
}, },
&quot;lastSeen&quot;: 1741207144695 "lastSeen": 1741207144695
}, },
{ {
&quot;id&quot;: { "id": {
&quot;id&quot;: &quot;PR_kwDOMJIfts6NiNYl&quot;, "id": "PR_kwDOMJIfts6NiNYl",
&quot;number&quot;: 32 "number": 32
}, },
&quot;lastSeen&quot;: 1741209723869 "lastSeen": 1741209723869
}, },
{ {
&quot;id&quot;: { "id": {
&quot;id&quot;: &quot;PR_kwDOMJIfts6Nheyd&quot;, "id": "PR_kwDOMJIfts6Nheyd",
&quot;number&quot;: 31 "number": 31
}, },
&quot;lastSeen&quot;: 1741213371410 "lastSeen": 1741213371410
}, },
{ {
&quot;id&quot;: { "id": {
&quot;id&quot;: &quot;PR_kwDOMJIfts6NmRBs&quot;, "id": "PR_kwDOMJIfts6NmRBs",
&quot;number&quot;: 33 "number": 33
}, },
&quot;lastSeen&quot;: 1741282429036 "lastSeen": 1741282429036
}, },
{ {
&quot;id&quot;: { "id": {
&quot;id&quot;: &quot;PR_kwDOMJIfts5zyFTs&quot;, "id": "PR_kwDOMJIfts5zyFTs",
&quot;number&quot;: 15 "number": 15
}, },
&quot;lastSeen&quot;: 1741535540953 "lastSeen": 1741535540953
},
{
"id": {
"id": "PR_kwDOMJIfts6QQB3c",
"number": 59
},
"lastSeen": 1743018960900
},
{
"id": {
"id": "PR_kwDOMJIfts6QMPEg",
"number": 58
},
"lastSeen": 1743019452983
} }
] ]
}</component> }]]></component>
<component name="GithubPullRequestsUISettings">{ <component name="GithubPullRequestsUISettings">{
&quot;selectedUrlAndAccountId&quot;: { &quot;selectedUrlAndAccountId&quot;: {
&quot;url&quot;: &quot;https://github.com/iib0011/omni-tools.git&quot;, &quot;url&quot;: &quot;https://github.com/iib0011/omni-tools.git&quot;,
@@ -133,7 +151,7 @@
"Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run", "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 (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
"Vitest.replaceText function.executor": "Run", "Vitest.replaceText function.executor": "Run",
"git-widget-placeholder": "split-pdf", "git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true", "kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/components/input", "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/components/input",
@@ -184,7 +202,7 @@
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" /> <recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Vitest.parsePageRanges"> <component name="RunManager" selected="npm.dev">
<configuration name="Create transparent PNG.should make png color transparent" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true"> <configuration name="Create transparent PNG.should make png color transparent" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true">
<node-interpreter value="project" /> <node-interpreter value="project" />
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" /> <playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
@@ -260,9 +278,9 @@
</list> </list>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Vitest.parsePageRanges" />
<item itemvalue="npm.dev" /> <item itemvalue="npm.dev" />
<item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" /> <item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" />
<item itemvalue="Vitest.parsePageRanges" />
<item itemvalue="Playwright.Create transparent PNG.should make png color transparent" /> <item itemvalue="Playwright.Create transparent PNG.should make png color transparent" />
<item itemvalue="npm.test:e2e" /> <item itemvalue="npm.test:e2e" />
</list> </list>
@@ -348,14 +366,7 @@
<workItem from="1741547560596" duration="1671000" /> <workItem from="1741547560596" duration="1671000" />
<workItem from="1741567442768" duration="14127000" /> <workItem from="1741567442768" duration="14127000" />
<workItem from="1741971589699" duration="371000" /> <workItem from="1741971589699" duration="371000" />
</task> <workItem from="1743018497879" duration="2015000" />
<task id="LOCAL-00118" summary="style: background svg">
<option name="closed" value="true" />
<created>1740491737480</created>
<option name="number" value="00118" />
<option name="presentableId" value="LOCAL-00118" />
<option name="project" value="LOCAL" />
<updated>1740491737480</updated>
</task> </task>
<task id="LOCAL-00119" summary="docs: img"> <task id="LOCAL-00119" summary="docs: img">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -741,7 +752,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1742967844908</updated> <updated>1742967844908</updated>
</task> </task>
<option name="localTasksCounter" value="167" /> <task id="LOCAL-00167" summary="fix: typo">
<option name="closed" value="true" />
<created>1743019312699</created>
<option name="number" value="00167" />
<option name="presentableId" value="LOCAL-00167" />
<option name="project" value="LOCAL" />
<updated>1743019312699</updated>
</task>
<option name="localTasksCounter" value="168" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -788,7 +807,6 @@
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" /> <option name="CHECK_NEW_TODO" value="false" />
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="docs: readme" />
<MESSAGE value="feat: remove duplicate lines" /> <MESSAGE value="feat: remove duplicate lines" />
<MESSAGE value="fix: tsc" /> <MESSAGE value="fix: tsc" />
<MESSAGE value="style: optimizations" /> <MESSAGE value="style: optimizations" />
@@ -813,7 +831,8 @@
<MESSAGE value="refactor: file inputs" /> <MESSAGE value="refactor: file inputs" />
<MESSAGE value="feat: background removal" /> <MESSAGE value="feat: background removal" />
<MESSAGE value="feat: split pdf" /> <MESSAGE value="feat: split pdf" />
<option name="LAST_COMMIT_MESSAGE" value="feat: split pdf" /> <MESSAGE value="fix: typo" />
<option name="LAST_COMMIT_MESSAGE" value="fix: typo" />
</component> </component>
<component name="XSLT-Support.FileAssociations.UIState"> <component name="XSLT-Support.FileAssociations.UIState">
<expand /> <expand />

28
package-lock.json generated
View File

@@ -28,6 +28,7 @@
"jimp": "^0.22.12", "jimp": "^0.22.12",
"lint-staged": "^15.4.3", "lint-staged": "^15.4.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mime": "^4.0.6",
"morsee": "^1.0.9", "morsee": "^1.0.9",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"omggif": "^1.0.10", "omggif": "^1.0.10",
@@ -7298,6 +7299,18 @@
"xtend": "^4.0.0" "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": { "node_modules/local-pkg": {
"version": "0.5.0", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz",
@@ -7622,14 +7635,18 @@
} }
}, },
"node_modules/mime": { "node_modules/mime": {
"version": "1.6.0", "version": "4.0.6",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.6.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "integrity": "sha512-4rGt7rvQHBbaSOF9POGkk1ocRP16Md1x36Xma8sz8h8/vfCUI2OtEIeCqe4Ofes853x4xDoPiFLIT47J5fI/7A==",
"funding": [
"https://github.com/sponsors/broofa"
],
"license": "MIT",
"bin": { "bin": {
"mime": "cli.js" "mime": "bin/cli.js"
}, },
"engines": { "engines": {
"node": ">=4" "node": ">=16"
} }
}, },
"node_modules/mime-db": { "node_modules/mime-db": {
@@ -7646,6 +7663,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"mime-db": "1.52.0" "mime-db": "1.52.0"
}, },

View File

@@ -45,6 +45,7 @@
"jimp": "^0.22.12", "jimp": "^0.22.12",
"lint-staged": "^15.4.3", "lint-staged": "^15.4.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mime": "^4.0.6",
"morsee": "^1.0.9", "morsee": "^1.0.9",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"omggif": "^1.0.10", "omggif": "^1.0.10",

View File

@@ -49,7 +49,8 @@ export default function ToolFileResult({
const handleDownload = () => { const handleDownload = () => {
if (value) { 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 blob = new Blob([value], { type: value.type });
const url = window.URL.createObjectURL(blob); const url = window.URL.createObjectURL(blob);

View File

@@ -1,16 +1,19 @@
import { Box, TextField } from '@mui/material'; import { Box, TextField } from '@mui/material';
import React, { useContext, useEffect } from 'react'; import React, { useContext } from 'react';
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext'; import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
import InputHeader from '../InputHeader'; import InputHeader from '../InputHeader';
import ResultFooter from './ResultFooter'; import ResultFooter from './ResultFooter';
import { replaceSpecialCharacters } from '../../utils/string'; import { replaceSpecialCharacters } from '@utils/string';
import mime from 'mime';
export default function ToolTextResult({ export default function ToolTextResult({
title = 'Result', title = 'Result',
value value,
extension = 'txt'
}: { }: {
title?: string; title?: string;
value: string; value: string;
extension?: string;
}) { }) {
const { showSnackBar } = useContext(CustomSnackBarContext); const { showSnackBar } = useContext(CustomSnackBarContext);
const handleCopy = () => { const handleCopy = () => {
@@ -22,9 +25,13 @@ export default function ToolTextResult({
}); });
}; };
const handleDownload = () => { 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 url = window.URL.createObjectURL(blob);
const a = document.createElement('a'); const a = document.createElement('a');
a.href = url; a.href = url;

View File

@@ -86,7 +86,9 @@ export default function JsonToXml({ title }: ToolComponentProps) {
inputComponent={ inputComponent={
<ToolTextInput title="Input Json" value={input} onChange={setInput} /> <ToolTextInput title="Input Json" value={input} onChange={setInput} />
} }
resultComponent={<ToolTextResult title="Output XML" value={result} />} resultComponent={
<ToolTextResult title="Output XML" value={result} extension={'xml'} />
}
getGroups={({ values, updateField }) => [ getGroups={({ values, updateField }) => [
{ {
title: 'Output XML Indentation', title: 'Output XML Indentation',