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">
<option name="myName" value="Project Default" />
<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>
</component>

117
.idea/workspace.xml generated
View File

@@ -4,13 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: split pdf">
<change afterPath="$PROJECT_DIR$/src/components/input/ToolPdfInput.tsx" afterDir="false" />
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: typo">
<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$/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/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/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/components/result/ToolTextResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolTextResult.tsx" 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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -27,61 +28,78 @@
<option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="main" />
<entry key="$PROJECT_DIR$" value="chesterkxng" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RESET_MODE" value="HARD" />
</component>
<component name="GitHubPullRequestSearchHistory">{
&quot;history&quot;: [
<component name="GitHubPullRequestSearchHistory"><![CDATA[{
"history": [
{
&quot;assignee&quot;: &quot;iib0011&quot;
"assignee": "iib0011"
},
{
"state": "OPEN"
}
],
&quot;lastFilter&quot;: {
&quot;assignee&quot;: &quot;iib0011&quot;
"lastFilter": {
"state": "OPEN"
}
}</component>
<component name="GitHubPullRequestState">{
&quot;prStates&quot;: [
}]]></component>
<component name="GitHubPullRequestState"><![CDATA[{
"prStates": [
{
&quot;id&quot;: {
&quot;id&quot;: &quot;PR_kwDOMJIfts51PkS9&quot;,
&quot;number&quot;: 22
"id": {
"id": "PR_kwDOMJIfts51PkS9",
"number": 22
},
&quot;lastSeen&quot;: 1741207144695
"lastSeen": 1741207144695
},
{
&quot;id&quot;: {
&quot;id&quot;: &quot;PR_kwDOMJIfts6NiNYl&quot;,
&quot;number&quot;: 32
"id": {
"id": "PR_kwDOMJIfts6NiNYl",
"number": 32
},
&quot;lastSeen&quot;: 1741209723869
"lastSeen": 1741209723869
},
{
&quot;id&quot;: {
&quot;id&quot;: &quot;PR_kwDOMJIfts6Nheyd&quot;,
&quot;number&quot;: 31
"id": {
"id": "PR_kwDOMJIfts6Nheyd",
"number": 31
},
&quot;lastSeen&quot;: 1741213371410
"lastSeen": 1741213371410
},
{
&quot;id&quot;: {
&quot;id&quot;: &quot;PR_kwDOMJIfts6NmRBs&quot;,
&quot;number&quot;: 33
"id": {
"id": "PR_kwDOMJIfts6NmRBs",
"number": 33
},
&quot;lastSeen&quot;: 1741282429036
"lastSeen": 1741282429036
},
{
&quot;id&quot;: {
&quot;id&quot;: &quot;PR_kwDOMJIfts5zyFTs&quot;,
&quot;number&quot;: 15
"id": {
"id": "PR_kwDOMJIfts5zyFTs",
"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">{
&quot;selectedUrlAndAccountId&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.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 @@
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" />
</key>
</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">
<node-interpreter value="project" />
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
@@ -260,9 +278,9 @@
</list>
<recent_temporary>
<list>
<item itemvalue="Vitest.parsePageRanges" />
<item itemvalue="npm.dev" />
<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="npm.test:e2e" />
</list>
@@ -348,14 +366,7 @@
<workItem from="1741547560596" duration="1671000" />
<workItem from="1741567442768" duration="14127000" />
<workItem from="1741971589699" duration="371000" />
</task>
<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>
<workItem from="1743018497879" duration="2015000" />
</task>
<task id="LOCAL-00119" summary="docs: img">
<option name="closed" value="true" />
@@ -741,7 +752,15 @@
<option name="project" value="LOCAL" />
<updated>1742967844908</updated>
</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 />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -788,7 +807,6 @@
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" />
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="docs: readme" />
<MESSAGE value="feat: remove duplicate lines" />
<MESSAGE value="fix: tsc" />
<MESSAGE value="style: optimizations" />
@@ -813,7 +831,8 @@
<MESSAGE value="refactor: file inputs" />
<MESSAGE value="feat: background removal" />
<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 name="XSLT-Support.FileAssociations.UIState">
<expand />

28
package-lock.json generated
View File

@@ -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"
},

View File

@@ -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",

View File

@@ -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);

View File

@@ -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;

View File

@@ -86,7 +86,9 @@ export default function JsonToXml({ title }: ToolComponentProps) {
inputComponent={
<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 }) => [
{
title: 'Output XML Indentation',