mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-18 05:29:33 +02:00
Adding tool links
This commit is contained in:
@@ -29,6 +29,7 @@ const validationSchema = Yup.object().shape({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mergeOptions = {
|
const mergeOptions = {
|
||||||
|
placeholder: 'Join Character',
|
||||||
description:
|
description:
|
||||||
'Symbol that connects broken\n' + 'pieces of text. (Space by default.)\n',
|
'Symbol that connects broken\n' + 'pieces of text. (Space by default.)\n',
|
||||||
accessor: 'joinCharacter' as keyof typeof initialValues
|
accessor: 'joinCharacter' as keyof typeof initialValues
|
||||||
@@ -41,29 +42,33 @@ const blankTrailingOptions: {
|
|||||||
}[] = [
|
}[] = [
|
||||||
{
|
{
|
||||||
title: 'Delete Blank Lines',
|
title: 'Delete Blank Lines',
|
||||||
description: "Delete lines that don't have\n" + 'text symbols.\n',
|
description: "Delete lines that don't have\n text symbols.\n",
|
||||||
accessor: 'deleteBlank'
|
accessor: 'deleteBlank'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Delete Trailing Spaces',
|
title: 'Delete Trailing Spaces',
|
||||||
description: 'Remove spaces and tabs at\n' + 'the end of the lines.\n',
|
description: 'Remove spaces and tabs at\n the end of the lines.\n',
|
||||||
accessor: 'deleteTrailing'
|
accessor: 'deleteTrailing'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const InputWithDesc = ({
|
const InputWithDesc = ({
|
||||||
|
placeholder,
|
||||||
description,
|
description,
|
||||||
value,
|
value,
|
||||||
onChange
|
onChange
|
||||||
}: {
|
}: {
|
||||||
|
placeholder: string;
|
||||||
description: string;
|
description: string;
|
||||||
value: string;
|
value: string;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box width={240}>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{ backgroundColor: 'white' }}
|
sx={{ backgroundColor: 'white', padding: 0 }}
|
||||||
|
size="small"
|
||||||
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(event) => onChange(event.target.value)}
|
onChange={(event) => onChange(event.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -116,6 +121,7 @@ export default function JoinText() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
|
console.log('Form values:', values['joinCharacter']);
|
||||||
setResult(mergeText(input, deleteBlank, deleteTrailing, joinCharacter));
|
setResult(mergeText(input, deleteBlank, deleteTrailing, joinCharacter));
|
||||||
} catch (exception: unknown) {
|
} catch (exception: unknown) {
|
||||||
if (exception instanceof Error)
|
if (exception instanceof Error)
|
||||||
@@ -123,6 +129,7 @@ export default function JoinText() {
|
|||||||
}
|
}
|
||||||
}, [values, input]);
|
}, [values, input]);
|
||||||
|
|
||||||
|
console.log('deleteBlank', deleteBlank);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,8 +160,11 @@ export default function JoinText() {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography fontSize={22}>Text Merged Options</Typography>
|
<Typography fontSize={22}>Text Merged Options</Typography>
|
||||||
<InputWithDesc
|
<InputWithDesc
|
||||||
value={values.joinCharacter}
|
placeholder={mergeOptions.placeholder}
|
||||||
onChange={(value) => setFieldValue('joinCharacter', value)}
|
value={values['joinCharacter']}
|
||||||
|
onChange={(value) =>
|
||||||
|
setFieldValue(mergeOptions.accessor, value)
|
||||||
|
}
|
||||||
description={mergeOptions.description}
|
description={mergeOptions.description}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
@@ -6,11 +6,29 @@ export function mergeText(
|
|||||||
): string {
|
): string {
|
||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
|
|
||||||
const processedLines = lines
|
let processedLines = lines;
|
||||||
.map((line) =>
|
if (deleteBlankLines) {
|
||||||
deleteTrailingSpaces ? line.replace(/ |\r\n|\n|\r/gm, '') : line
|
lines.map((line) =>
|
||||||
)
|
deleteTrailingSpaces
|
||||||
.filter((line) => !deleteBlankLines || line.trim() !== '');
|
? line
|
||||||
|
// .split(' ')
|
||||||
|
// .join('')
|
||||||
|
// .replace(/|\r\n|\n|\r/gm, '')
|
||||||
|
.trimEnd()
|
||||||
|
: line
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deleteBlankLines) {
|
||||||
|
processedLines = lines.filter(
|
||||||
|
(line) => !deleteBlankLines || line.trim() !== ''
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
lines;
|
||||||
|
}
|
||||||
|
|
||||||
return processedLines.join(joinCharacter);
|
return processedLines.join(joinCharacter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +39,4 @@ Another line with trailing spaces
|
|||||||
Final line without trailing spaces`;
|
Final line without trailing spaces`;
|
||||||
|
|
||||||
export const mergedTextWithBlankLines: string = mergeText(text, false);
|
export const mergedTextWithBlankLines: string = mergeText(text, false);
|
||||||
console.log('With blank lines:\n', mergedTextWithBlankLines);
|
|
||||||
|
|
||||||
export const mergedTextWithoutBlankLines: string = mergeText(text, true);
|
export const mergedTextWithoutBlankLines: string = mergeText(text, true);
|
||||||
console.log('Without blank lines:\n', mergedTextWithoutBlankLines);
|
|
||||||
|
Reference in New Issue
Block a user