Added minimizing to XML Formatter

This commit is contained in:
2023-06-20 13:15:23 +02:00
parent 11091258b9
commit b33d20fc91
3 changed files with 9 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ function sendProcessedData(data: JSON) {
</script>
<template>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format"}}</button>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format" }}</button>
</template>
<style scoped></style>

View File

@@ -1,7 +1,8 @@
<script setup lang="ts">
const props = defineProps({
xml: {type: String, required: true}
xml: {type: String, required: true},
isMinimizer: {type: Boolean}
})
const emit = defineEmits(["update:result"])
@@ -22,7 +23,10 @@ function prepareRequest():Request {
}
function prepareURL(): string {
return document.location.protocol + "//" + document.location.hostname + "/libxml/prettify";
var mode = "prettify";
if (props.isMinimizer)
mode = "minimize";
return document.location.protocol + "//" + document.location.hostname + "/libxml/" + mode;
}
function prepareRequestBody():string {
@@ -48,7 +52,7 @@ function sendProcessedData(data: JSON) {
</script>
<template>
<button class="tool-button" @click="process()">Format</button>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format" }}</button>
</template>
<style scoped></style>

View File

@@ -27,6 +27,7 @@ function clear() {
<div class="space-x-2">
<InsertTemplateComponent pretty-name="XML" @update:defaultData="(data: string) => setTextFieldValue(data)"></InsertTemplateComponent>
<button class="tool-button" @click="clear()">Clear</button>
<XMLButtonFormatterComponent is-minimizer :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
<XMLButtonFormatterComponent :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
</div>
</div>