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 = {
|
||||
placeholder: 'Join Character',
|
||||
description:
|
||||
'Symbol that connects broken\n' + 'pieces of text. (Space by default.)\n',
|
||||
accessor: 'joinCharacter' as keyof typeof initialValues
|
||||
@@ -41,29 +42,33 @@ const blankTrailingOptions: {
|
||||
}[] = [
|
||||
{
|
||||
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'
|
||||
},
|
||||
{
|
||||
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'
|
||||
}
|
||||
];
|
||||
|
||||
const InputWithDesc = ({
|
||||
placeholder,
|
||||
description,
|
||||
value,
|
||||
onChange
|
||||
}: {
|
||||
placeholder: string;
|
||||
description: string;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
}) => {
|
||||
return (
|
||||
<Box>
|
||||
<Box width={240}>
|
||||
<TextField
|
||||
sx={{ backgroundColor: 'white' }}
|
||||
sx={{ backgroundColor: 'white', padding: 0 }}
|
||||
size="small"
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
/>
|
||||
@@ -116,6 +121,7 @@ export default function JoinText() {
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
console.log('Form values:', values['joinCharacter']);
|
||||
setResult(mergeText(input, deleteBlank, deleteTrailing, joinCharacter));
|
||||
} catch (exception: unknown) {
|
||||
if (exception instanceof Error)
|
||||
@@ -123,6 +129,7 @@ export default function JoinText() {
|
||||
}
|
||||
}, [values, input]);
|
||||
|
||||
console.log('deleteBlank', deleteBlank);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -153,8 +160,11 @@ export default function JoinText() {
|
||||
<Box>
|
||||
<Typography fontSize={22}>Text Merged Options</Typography>
|
||||
<InputWithDesc
|
||||
value={values.joinCharacter}
|
||||
onChange={(value) => setFieldValue('joinCharacter', value)}
|
||||
placeholder={mergeOptions.placeholder}
|
||||
value={values['joinCharacter']}
|
||||
onChange={(value) =>
|
||||
setFieldValue(mergeOptions.accessor, value)
|
||||
}
|
||||
description={mergeOptions.description}
|
||||
/>
|
||||
</Box>
|
||||
|
@@ -6,11 +6,29 @@ export function mergeText(
|
||||
): string {
|
||||
const lines = text.split('\n');
|
||||
|
||||
const processedLines = lines
|
||||
.map((line) =>
|
||||
deleteTrailingSpaces ? line.replace(/ |\r\n|\n|\r/gm, '') : line
|
||||
)
|
||||
.filter((line) => !deleteBlankLines || line.trim() !== '');
|
||||
let processedLines = lines;
|
||||
if (deleteBlankLines) {
|
||||
lines.map((line) =>
|
||||
deleteTrailingSpaces
|
||||
? 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);
|
||||
}
|
||||
|
||||
@@ -21,7 +39,4 @@ Another line with trailing spaces
|
||||
Final line without trailing spaces`;
|
||||
|
||||
export const mergedTextWithBlankLines: string = mergeText(text, false);
|
||||
console.log('With blank lines:\n', mergedTextWithBlankLines);
|
||||
|
||||
export const mergedTextWithoutBlankLines: string = mergeText(text, true);
|
||||
console.log('Without blank lines:\n', mergedTextWithoutBlankLines);
|
||||
|
Reference in New Issue
Block a user