mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-12 02:52:40 +05:30
fix: remove xml viewer
This commit is contained in:
parent
57fe32d15f
commit
82df4ee475
8 changed files with 21 additions and 132 deletions
35
.idea/workspace.xml
generated
35
.idea/workspace.xml
generated
|
|
@ -4,11 +4,14 @@
|
||||||
<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="chore: white logo">
|
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: png icon">
|
||||||
<change afterPath="$PROJECT_DIR$/public/favicon.png" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/assets/logo.svg" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/xml/index.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/index.html" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/xml-viewer/index.tsx" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/public/favicon.svg" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/xml-viewer/meta.ts" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/xml-viewer/service.ts" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/xml-viewer/types.ts" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/xml/xml-viewer/xml-viewer.service.test.ts" beforeDir="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" />
|
||||||
|
|
@ -495,14 +498,6 @@
|
||||||
<workItem from="1749047510481" duration="879000" />
|
<workItem from="1749047510481" duration="879000" />
|
||||||
<workItem from="1751846528195" duration="4358000" />
|
<workItem from="1751846528195" duration="4358000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00159" summary="refactor: sum">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1741544086061</created>
|
|
||||||
<option name="number" value="00159" />
|
|
||||||
<option name="presentableId" value="LOCAL-00159" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1741544086061</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00160" summary="fix: tools by category scroll">
|
<task id="LOCAL-00160" summary="fix: tools by category scroll">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1741548044897</created>
|
<created>1741548044897</created>
|
||||||
|
|
@ -887,7 +882,15 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1752022731608</updated>
|
<updated>1752022731608</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="208" />
|
<task id="LOCAL-00208" summary="chore: png icon">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1752023182341</created>
|
||||||
|
<option name="number" value="00208" />
|
||||||
|
<option name="presentableId" value="LOCAL-00208" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1752023182341</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="209" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
|
@ -934,7 +937,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="refactor: compress pdf" />
|
|
||||||
<MESSAGE value="refactor: lib" />
|
<MESSAGE value="refactor: lib" />
|
||||||
<MESSAGE value="fix: path" />
|
<MESSAGE value="fix: path" />
|
||||||
<MESSAGE value="fix: vite worker format" />
|
<MESSAGE value="fix: vite worker format" />
|
||||||
|
|
@ -959,7 +961,8 @@
|
||||||
<MESSAGE value="fix: tsc" />
|
<MESSAGE value="fix: tsc" />
|
||||||
<MESSAGE value="chore: new logo and font" />
|
<MESSAGE value="chore: new logo and font" />
|
||||||
<MESSAGE value="chore: white logo" />
|
<MESSAGE value="chore: white logo" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="chore: white logo" />
|
<MESSAGE value="chore: png icon" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="chore: png icon" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<integration-enabled>false</integration-enabled>
|
<integration-enabled>false</integration-enabled>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
<svg width="410" height="410" viewBox="0 0 410 410" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M205 410C318.218 410 410 318.218 410 205C410 91.7816 318.218 0 205 0C91.7816 0 0 91.7816 0 205C0 318.218 91.7816 410 205 410ZM205 360C290.604 360 360 290.604 360 205C360 119.396 290.604 50 205 50C119.396 50 50 119.396 50 205C50 290.604 119.396 360 205 360Z" fill="#4F46E5" />
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 434 B |
|
|
@ -1,4 +1,4 @@
|
||||||
import { tool as xmlXmlValidator } from './xml-validator/meta';
|
import { tool as xmlXmlValidator } from './xml-validator/meta';
|
||||||
import { tool as xmlXmlBeautifier } from './xml-beautifier/meta';
|
import { tool as xmlXmlBeautifier } from './xml-beautifier/meta';
|
||||||
import { tool as xmlXmlViewer } from './xml-viewer/meta';
|
|
||||||
export const xmlTools = [xmlXmlViewer, xmlXmlBeautifier, xmlXmlValidator];
|
export const xmlTools = [xmlXmlBeautifier, xmlXmlValidator];
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
import { Box } from '@mui/material';
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
import ToolContent from '@components/ToolContent';
|
|
||||||
import { ToolComponentProps } from '@tools/defineTool';
|
|
||||||
import ToolTextInput from '@components/input/ToolTextInput';
|
|
||||||
import ToolTextResult from '@components/result/ToolTextResult';
|
|
||||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
|
||||||
import { prettyPrintXml } from './service';
|
|
||||||
import { InitialValuesType } from './types';
|
|
||||||
|
|
||||||
const initialValues: InitialValuesType = {};
|
|
||||||
|
|
||||||
const exampleCards: CardExampleType<InitialValuesType>[] = [
|
|
||||||
{
|
|
||||||
title: 'Pretty Print XML',
|
|
||||||
description: 'View and pretty-print a compact XML string.',
|
|
||||||
sampleText: '<root><item>1</item><item>2</item></root>',
|
|
||||||
sampleResult: `<root>\n <item>1</item>\n <item>2</item>\n</root>`,
|
|
||||||
sampleOptions: {}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function XmlViewer({
|
|
||||||
title,
|
|
||||||
longDescription
|
|
||||||
}: ToolComponentProps) {
|
|
||||||
const [input, setInput] = useState<string>('');
|
|
||||||
const [result, setResult] = useState<string>('');
|
|
||||||
|
|
||||||
const compute = (_values: InitialValuesType, input: string) => {
|
|
||||||
setResult(prettyPrintXml(input, {}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ToolContent
|
|
||||||
title={title}
|
|
||||||
input={input}
|
|
||||||
inputComponent={
|
|
||||||
<ToolTextInput
|
|
||||||
value={input}
|
|
||||||
onChange={setInput}
|
|
||||||
placeholder="Paste or import XML here..."
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
resultComponent={<ToolTextResult value={result} extension="xml" />}
|
|
||||||
initialValues={initialValues}
|
|
||||||
exampleCards={exampleCards}
|
|
||||||
getGroups={null}
|
|
||||||
setInput={setInput}
|
|
||||||
compute={compute}
|
|
||||||
toolInfo={{ title: `What is a ${title}?`, description: longDescription }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
import { defineTool } from '@tools/defineTool';
|
|
||||||
import { lazy } from 'react';
|
|
||||||
|
|
||||||
export const tool = defineTool('xml', {
|
|
||||||
name: 'XML Viewer',
|
|
||||||
path: 'xml-viewer',
|
|
||||||
icon: 'mdi:eye-outline',
|
|
||||||
description:
|
|
||||||
'View and pretty-print XML files or strings for easier reading and debugging.',
|
|
||||||
shortDescription: 'Pretty-print and view XML.',
|
|
||||||
keywords: ['xml', 'viewer', 'pretty print', 'format', 'inspect'],
|
|
||||||
component: lazy(() => import('./index'))
|
|
||||||
});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { InitialValuesType } from './types';
|
|
||||||
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
|
|
||||||
|
|
||||||
export function prettyPrintXml(
|
|
||||||
input: string,
|
|
||||||
_options: InitialValuesType
|
|
||||||
): string {
|
|
||||||
const valid = XMLValidator.validate(input);
|
|
||||||
if (valid !== true) {
|
|
||||||
if (typeof valid === 'object' && valid.err) {
|
|
||||||
return `Invalid XML: ${valid.err.msg} (line ${valid.err.line}, col ${valid.err.col})`;
|
|
||||||
}
|
|
||||||
return 'Invalid XML';
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const parser = new XMLParser();
|
|
||||||
const obj = parser.parse(input);
|
|
||||||
const builder = new XMLBuilder({ format: true, indentBy: ' ' });
|
|
||||||
return builder.build(obj);
|
|
||||||
} catch (e: any) {
|
|
||||||
return `Invalid XML: ${e.message}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export type InitialValuesType = {
|
|
||||||
// splitSeparator: string;
|
|
||||||
};
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { expect, describe, it } from 'vitest';
|
|
||||||
import { prettyPrintXml } from './service';
|
|
||||||
|
|
||||||
describe('xml-viewer', () => {
|
|
||||||
it('pretty prints valid XML', () => {
|
|
||||||
const input = '<root><a>1</a><b>2</b></root>';
|
|
||||||
const result = prettyPrintXml(input, {});
|
|
||||||
expect(result).toContain('<root>');
|
|
||||||
expect(result).toContain(' <a>1</a>');
|
|
||||||
expect(result).toContain(' <b>2</b>');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns error for invalid XML', () => {
|
|
||||||
const input = '<root><a>1</b></root>';
|
|
||||||
const result = prettyPrintXml(input, {});
|
|
||||||
expect(result).toMatch(/Invalid XML/i);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue