mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-17 13:09:31 +02:00
feat: result copy and download
This commit is contained in:
53
.idea/workspace.xml
generated
53
.idea/workspace.xml
generated
@@ -4,10 +4,9 @@
|
|||||||
<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="fix: join text service">
|
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="test: join service">
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/string/join/string-join.test.ts" 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/pages/string/join/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/string/join/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" />
|
||||||
</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" />
|
||||||
@@ -44,6 +43,7 @@
|
|||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"Vitest.mergeText.executor": "Run",
|
"Vitest.mergeText.executor": "Run",
|
||||||
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
|
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
|
||||||
|
"Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
|
||||||
"git-widget-placeholder": "main",
|
"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",
|
||||||
@@ -87,34 +87,7 @@
|
|||||||
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\tools" />
|
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\tools" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="Vitest.mergeText">
|
<component name="RunManager" selected="npm.dev">
|
||||||
<configuration name="mergeText" type="JavaScriptTestRunnerVitest" temporary="true" nameIsGenerated="true">
|
|
||||||
<node-interpreter value="project" />
|
|
||||||
<vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
|
|
||||||
<working-dir value="$PROJECT_DIR$" />
|
|
||||||
<vitest-options value="--run" />
|
|
||||||
<envs />
|
|
||||||
<scope-kind value="SUITE" />
|
|
||||||
<test-file value="$PROJECT_DIR$/src/pages/string/join/string-join.test.ts" />
|
|
||||||
<test-names>
|
|
||||||
<test-name value="mergeText" />
|
|
||||||
</test-names>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="mergeText.should merge lines and preserve blank lines when deleteBlankLines is false" type="JavaScriptTestRunnerVitest" temporary="true" nameIsGenerated="true">
|
|
||||||
<node-interpreter value="project" />
|
|
||||||
<vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
|
|
||||||
<working-dir value="$PROJECT_DIR$" />
|
|
||||||
<vitest-options value="--run" />
|
|
||||||
<envs />
|
|
||||||
<scope-kind value="TEST" />
|
|
||||||
<test-file value="$PROJECT_DIR$/src/pages/string/join/string-join.test.ts" />
|
|
||||||
<test-names>
|
|
||||||
<test-name value="mergeText" />
|
|
||||||
<test-name value="should merge lines and preserve blank lines when deleteBlankLines is false" />
|
|
||||||
</test-names>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="dev" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
<configuration name="dev" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
||||||
<package-json value="$PROJECT_DIR$/package.json" />
|
<package-json value="$PROJECT_DIR$/package.json" />
|
||||||
<command value="run" />
|
<command value="run" />
|
||||||
@@ -137,8 +110,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Vitest.mergeText" />
|
|
||||||
<item itemvalue="Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false" />
|
|
||||||
<item itemvalue="npm.dev" />
|
<item itemvalue="npm.dev" />
|
||||||
<item itemvalue="npm.prebuild" />
|
<item itemvalue="npm.prebuild" />
|
||||||
</list>
|
</list>
|
||||||
@@ -161,7 +132,7 @@
|
|||||||
<workItem from="1719006951159" duration="2377000" />
|
<workItem from="1719006951159" duration="2377000" />
|
||||||
<workItem from="1719021128819" duration="3239000" />
|
<workItem from="1719021128819" duration="3239000" />
|
||||||
<workItem from="1719083989394" duration="7971000" />
|
<workItem from="1719083989394" duration="7971000" />
|
||||||
<workItem from="1719092003308" duration="13183000" />
|
<workItem from="1719092003308" duration="14114000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="feat: use vite and ts">
|
<task id="LOCAL-00001" summary="feat: use vite and ts">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -403,7 +374,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1719153044395</updated>
|
<updated>1719153044395</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="31" />
|
<task id="LOCAL-00031" summary="test: join service">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1719154187887</created>
|
||||||
|
<option name="number" value="00031" />
|
||||||
|
<option name="presentableId" value="LOCAL-00031" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1719154187887</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="32" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -424,7 +403,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="feat: initial commit" />
|
|
||||||
<MESSAGE value="feat: example tools" />
|
<MESSAGE value="feat: example tools" />
|
||||||
<MESSAGE value="feat: Split string" />
|
<MESSAGE value="feat: Split string" />
|
||||||
<MESSAGE value="fix: netlify" />
|
<MESSAGE value="fix: netlify" />
|
||||||
@@ -449,7 +427,8 @@
|
|||||||
<MESSAGE value="feat: copy and import file" />
|
<MESSAGE value="feat: copy and import file" />
|
||||||
<MESSAGE value="refactor: tool options components" />
|
<MESSAGE value="refactor: tool options components" />
|
||||||
<MESSAGE value="fix: join text service" />
|
<MESSAGE value="fix: join text service" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix: join text service" />
|
<MESSAGE value="test: join service" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="test: join service" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
@@ -3,7 +3,8 @@ import { Box, Stack, TextField } from '@mui/material';
|
|||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import DownloadIcon from '@mui/icons-material/Download';
|
import DownloadIcon from '@mui/icons-material/Download';
|
||||||
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
|
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
|
||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
|
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
|
||||||
|
|
||||||
export default function ToolTextResult({
|
export default function ToolTextResult({
|
||||||
title = 'Result',
|
title = 'Result',
|
||||||
@@ -12,6 +13,28 @@ export default function ToolTextResult({
|
|||||||
title?: string;
|
title?: string;
|
||||||
value: string;
|
value: string;
|
||||||
}) {
|
}) {
|
||||||
|
const { showSnackBar } = useContext(CustomSnackBarContext);
|
||||||
|
const handleCopy = () => {
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(value)
|
||||||
|
.then(() => showSnackBar('Text copied', 'success'))
|
||||||
|
.catch((err) => {
|
||||||
|
showSnackBar('Failed to copy: ' + err, 'error');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const handleDownload = () => {
|
||||||
|
const filename = 'output-omni-tools.txt';
|
||||||
|
|
||||||
|
const blob = new Blob([value], { type: 'text/plain' });
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography fontSize={30} color={'primary'}>
|
<Typography fontSize={30} color={'primary'}>
|
||||||
@@ -19,8 +42,12 @@ export default function ToolTextResult({
|
|||||||
</Typography>
|
</Typography>
|
||||||
<TextField value={value} fullWidth multiline rows={10} />
|
<TextField value={value} fullWidth multiline rows={10} />
|
||||||
<Stack mt={1} direction={'row'} spacing={2}>
|
<Stack mt={1} direction={'row'} spacing={2}>
|
||||||
<Button startIcon={<DownloadIcon />}>Save as</Button>
|
<Button onClick={handleDownload} startIcon={<DownloadIcon />}>
|
||||||
<Button startIcon={<ContentPasteIcon />}>Copy to clipboard</Button>
|
Save as
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleCopy} startIcon={<ContentPasteIcon />}>
|
||||||
|
Copy to clipboard
|
||||||
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user