mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 09:29:16 +01:00
Better XML formatting, fix pointer cursor in sidebar, copy/create URL in response
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user