mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-25 23:24:09 +03:00
e8f0677f94
Compare two pasted XML documents and highlight the differences, mirroring the JSON diff tool's UI and diff engine. XML is parsed with a native DOMParser-based normalizer (attributes as @name, text-only leaves as plain strings) instead of xml-js, and a reconciliation step coerces mismatched single/repeated element shapes into arrays before diffing so a repeated element compares cleanly instead of producing a garbled type-mismatch diff. From PR #1840 Fix #1839 Co-Authored-By: @sharevb Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.3 KiB
Vue
48 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
import { useI18n } from 'vue-i18n';
|
|
const { t } = useI18n();
|
|
import DiffsViewer from './diff-viewer/xml-diff-viewer.vue';
|
|
import { isValidXML, parseXml } from './xml-diff.parser';
|
|
|
|
const rawLeftXml = ref('');
|
|
const rawRightXml = ref('');
|
|
|
|
const leftXml = computed(() => parseXml(rawLeftXml.value));
|
|
const rightXml = computed(() => parseXml(rawRightXml.value));
|
|
|
|
const xmlValidationRules = [
|
|
{
|
|
validator: (value: string) => isValidXML(value),
|
|
message: t('tools.xml-diff.texts.message-invalid-xml-format'),
|
|
},
|
|
];
|
|
</script>
|
|
|
|
<template>
|
|
<c-input-text
|
|
v-model:value="rawLeftXml"
|
|
:validation-rules="xmlValidationRules"
|
|
:label="t('tools.xml-diff.texts.label-your-first-xml')"
|
|
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-first-xml-here')"
|
|
rows="20"
|
|
test-id="leftXml"
|
|
raw-text
|
|
multiline
|
|
monospace
|
|
/>
|
|
|
|
<c-input-text
|
|
v-model:value="rawRightXml"
|
|
:validation-rules="xmlValidationRules"
|
|
:label="t('tools.xml-diff.texts.label-your-xml-to-compare')"
|
|
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-xml-to-compare-here')"
|
|
rows="20"
|
|
multiline
|
|
test-id="rightXml"
|
|
raw-text
|
|
monospace
|
|
/>
|
|
|
|
<DiffsViewer :left-xml="leftXml" :right-xml="rightXml" />
|
|
</template>
|