mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 22:19:36 +02:00
fix: tsc
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Box, Typography, Alert, Paper } from '@mui/material';
|
import { Alert, Box, Paper, Typography } from '@mui/material';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ToolContent from '@components/ToolContent';
|
import ToolContent from '@components/ToolContent';
|
||||||
import { ToolComponentProps } from '@tools/defineTool';
|
import { ToolComponentProps } from '@tools/defineTool';
|
||||||
@@ -7,7 +7,6 @@ import { InitialValuesType } from './types';
|
|||||||
import { analyzeHiddenCharacters } from './service';
|
import { analyzeHiddenCharacters } from './service';
|
||||||
import ToolTextInput from '@components/input/ToolTextInput';
|
import ToolTextInput from '@components/input/ToolTextInput';
|
||||||
import ToolTextResult from '@components/result/ToolTextResult';
|
import ToolTextResult from '@components/result/ToolTextResult';
|
||||||
import { GetGroupsType } from '@components/options/ToolOptions';
|
|
||||||
|
|
||||||
const initialValues: InitialValuesType = {
|
const initialValues: InitialValuesType = {
|
||||||
showUnicodeCodes: true,
|
showUnicodeCodes: true,
|
||||||
@@ -33,41 +32,35 @@ export default function HiddenCharacterDetector({
|
|||||||
setAnalysis(analysisResult);
|
setAnalysis(analysisResult);
|
||||||
|
|
||||||
if (analysisResult.totalHiddenChars === 0) {
|
if (analysisResult.totalHiddenChars === 0) {
|
||||||
setResult(t('string:hiddenCharacterDetector.noHiddenChars'));
|
setResult(t('hiddenCharacterDetector.noHiddenChars'));
|
||||||
} else {
|
} else {
|
||||||
let output = t('string:hiddenCharacterDetector.foundChars', {
|
let output = t('hiddenCharacterDetector.foundChars', {
|
||||||
count: analysisResult.totalHiddenChars
|
count: analysisResult.totalHiddenChars
|
||||||
});
|
});
|
||||||
|
|
||||||
analysisResult.hiddenCharacters.forEach((char: any) => {
|
analysisResult.hiddenCharacters.forEach((char: any) => {
|
||||||
output += `${t('string:hiddenCharacterDetector.position')} ${
|
output += `${t('hiddenCharacterDetector.position')} ${
|
||||||
char.position
|
char.position
|
||||||
}: ${char.name} (${char.unicode})\n`;
|
}: ${char.name} (${char.unicode})\n`;
|
||||||
if (values.showUnicodeCodes) {
|
if (values.showUnicodeCodes) {
|
||||||
output += ` ${t('string:hiddenCharacterDetector.unicode')}: ${
|
output += ` ${t('hiddenCharacterDetector.unicode')}: ${
|
||||||
char.unicode
|
char.unicode
|
||||||
}\n`;
|
}\n`;
|
||||||
}
|
}
|
||||||
output += ` ${t('string:hiddenCharacterDetector.category')}: ${
|
output += ` ${t('hiddenCharacterDetector.category')}: ${
|
||||||
char.category
|
char.category
|
||||||
}\n`;
|
}\n`;
|
||||||
if (char.isRTL)
|
if (char.isRTL)
|
||||||
output += ` ⚠️ ${t(
|
output += ` ⚠️ ${t('hiddenCharacterDetector.rtlOverride')}\n`;
|
||||||
'string:hiddenCharacterDetector.rtlOverride'
|
|
||||||
)}\n`;
|
|
||||||
if (char.isInvisible)
|
if (char.isInvisible)
|
||||||
output += ` 👁️ ${t(
|
output += ` 👁️ ${t('hiddenCharacterDetector.invisibleChar')}\n`;
|
||||||
'string:hiddenCharacterDetector.invisibleChar'
|
|
||||||
)}\n`;
|
|
||||||
if (char.isZeroWidth)
|
if (char.isZeroWidth)
|
||||||
output += ` 📏 ${t(
|
output += ` 📏 ${t('hiddenCharacterDetector.zeroWidthChar')}\n`;
|
||||||
'string:hiddenCharacterDetector.zeroWidthChar'
|
|
||||||
)}\n`;
|
|
||||||
output += '\n';
|
output += '\n';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (analysisResult.hasRTLOverride) {
|
if (analysisResult.hasRTLOverride) {
|
||||||
output += `⚠️ ${t('string:hiddenCharacterDetector.rtlWarning')}\n`;
|
output += `⚠️ ${t('hiddenCharacterDetector.rtlWarning')}\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(output);
|
setResult(output);
|
||||||
@@ -77,22 +70,6 @@ export default function HiddenCharacterDetector({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGroups: GetGroupsType<InitialValuesType> = ({
|
|
||||||
values,
|
|
||||||
updateField
|
|
||||||
}) => [
|
|
||||||
{
|
|
||||||
title: t('string:hiddenCharacterDetector.analysisOptions'),
|
|
||||||
component: (
|
|
||||||
<Box>
|
|
||||||
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
|
|
||||||
{t('string:hiddenCharacterDetector.optionsDescription')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolContent
|
<ToolContent
|
||||||
title={title}
|
title={title}
|
||||||
@@ -101,31 +78,31 @@ export default function HiddenCharacterDetector({
|
|||||||
<ToolTextInput
|
<ToolTextInput
|
||||||
value={input}
|
value={input}
|
||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
title={t('string:hiddenCharacterDetector.inputTitle')}
|
title={t('hiddenCharacterDetector.inputTitle')}
|
||||||
placeholder={t('string:hiddenCharacterDetector.inputPlaceholder')}
|
placeholder={t('hiddenCharacterDetector.inputPlaceholder')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{analysis && analysis.hasRTLOverride && (
|
{analysis && analysis.hasRTLOverride && (
|
||||||
<Alert severity="warning" sx={{ mt: 2 }}>
|
<Alert severity="warning" sx={{ mt: 2 }}>
|
||||||
{t('string:hiddenCharacterDetector.rtlAlert')}
|
{t('hiddenCharacterDetector.rtlAlert')}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{analysis && analysis.totalHiddenChars > 0 && (
|
{analysis && analysis.totalHiddenChars > 0 && (
|
||||||
<Paper sx={{ p: 2, mt: 2, backgroundColor: '#fff3cd' }}>
|
<Paper sx={{ p: 2, mt: 2, backgroundColor: '#fff3cd' }}>
|
||||||
<Typography variant="h6" gutterBottom>
|
<Typography variant="h6" gutterBottom>
|
||||||
{t('string:hiddenCharacterDetector.summary')}
|
{t('hiddenCharacterDetector.summary')}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2">
|
<Typography variant="body2">
|
||||||
{t('string:hiddenCharacterDetector.totalChars', {
|
{t('hiddenCharacterDetector.totalChars', {
|
||||||
count: analysis.totalHiddenChars
|
count: analysis.totalHiddenChars
|
||||||
})}
|
})}
|
||||||
{analysis.hasRTLOverride &&
|
{analysis.hasRTLOverride &&
|
||||||
` • ${t('string:hiddenCharacterDetector.rtlFound')}`}
|
` • ${t('hiddenCharacterDetector.rtlFound')}`}
|
||||||
{analysis.hasInvisibleChars &&
|
{analysis.hasInvisibleChars &&
|
||||||
` • ${t('string:hiddenCharacterDetector.invisibleFound')}`}
|
` • ${t('hiddenCharacterDetector.invisibleFound')}`}
|
||||||
{analysis.hasZeroWidthChars &&
|
{analysis.hasZeroWidthChars &&
|
||||||
` • ${t('string:hiddenCharacterDetector.zeroWidthFound')}`}
|
` • ${t('hiddenCharacterDetector.zeroWidthFound')}`}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Paper>
|
</Paper>
|
||||||
)}
|
)}
|
||||||
@@ -133,7 +110,7 @@ export default function HiddenCharacterDetector({
|
|||||||
}
|
}
|
||||||
resultComponent={<ToolTextResult value={result} />}
|
resultComponent={<ToolTextResult value={result} />}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
getGroups={getGroups}
|
getGroups={null}
|
||||||
compute={compute}
|
compute={compute}
|
||||||
input={input}
|
input={input}
|
||||||
setInput={setInput}
|
setInput={setInput}
|
||||||
|
@@ -6,7 +6,8 @@ export const tool = defineTool('string', {
|
|||||||
name: 'string:hiddenCharacterDetector.title',
|
name: 'string:hiddenCharacterDetector.title',
|
||||||
description: 'string:hiddenCharacterDetector.description',
|
description: 'string:hiddenCharacterDetector.description',
|
||||||
shortDescription: 'string:hiddenCharacterDetector.shortDescription',
|
shortDescription: 'string:hiddenCharacterDetector.shortDescription',
|
||||||
longDescription: 'string:hiddenCharacterDetector.longDescription'
|
longDescription: 'string:hiddenCharacterDetector.longDescription',
|
||||||
|
userTypes: ['developers']
|
||||||
},
|
},
|
||||||
path: 'hidden-character-detector',
|
path: 'hidden-character-detector',
|
||||||
icon: 'material-symbols:visibility-off',
|
icon: 'material-symbols:visibility-off',
|
||||||
|
@@ -44,5 +44,6 @@ export const stringTools = [
|
|||||||
stringCensor,
|
stringCensor,
|
||||||
stringPasswordGenerator,
|
stringPasswordGenerator,
|
||||||
stringEncodeUrl,
|
stringEncodeUrl,
|
||||||
StringDecodeUrl
|
StringDecodeUrl,
|
||||||
|
stringHiddenCharacterDetector
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user