Better XML formatting, fix pointer cursor in sidebar, copy/create URL in response

This commit is contained in:
Gregory Schier
2025-10-24 09:50:42 -07:00
parent 17ddc76223
commit bbf85c953d
9 changed files with 404 additions and 26 deletions

View File

@@ -1,12 +1,5 @@
import XmlBeautify from 'xml-beautify';
import { invokeCmd } from './tauri';
const INDENT = ' ';
const xmlBeautifier = new XmlBeautify({
INDENT,
});
export async function tryFormatJson(text: string): Promise<string> {
if (text === '') return text;
@@ -15,13 +8,12 @@ export async function tryFormatJson(text: string): Promise<string> {
return result;
} catch (err) {
console.warn('Failed to format JSON', err);
// Nothing
}
try {
return JSON.stringify(JSON.parse(text), null, 2);
} catch (err) {
console.log("JSON beautify failed", err);
console.log('JSON beautify failed', err);
}
return text;
@@ -31,9 +23,11 @@ export async function tryFormatXml(text: string): Promise<string> {
if (text === '') return text;
try {
return xmlBeautifier.beautify(text);
const result = await invokeCmd<string>('cmd_format_xml', { text });
return result;
} catch (err) {
console.log("XML beautify failed", err);
return text;
console.warn('Failed to format XML', err);
}
return text;
}

View File

@@ -15,6 +15,7 @@ type TauriCmd =
| 'cmd_dismiss_notification'
| 'cmd_export_data'
| 'cmd_format_json'
| 'cmd_format_xml'
| 'cmd_get_http_authentication_config'
| 'cmd_get_http_authentication_summaries'
| 'cmd_get_sse_events'