From 048bc4ae943509dea2946764efaa69f845b6c478 Mon Sep 17 00:00:00 2001
From: Corentin Thomasset <corentin.thomasset74@gmail.com>
Date: Sat, 14 May 2022 16:29:50 +0200
Subject: refactor(json-viewer): add clear button

---
 src/tools/json-viewer/json-viewer.vue | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

(limited to 'src/tools/json-viewer/json-viewer.vue')

diff --git a/src/tools/json-viewer/json-viewer.vue b/src/tools/json-viewer/json-viewer.vue
index 3307cba..5535282 100644
--- a/src/tools/json-viewer/json-viewer.vue
+++ b/src/tools/json-viewer/json-viewer.vue
@@ -5,8 +5,21 @@
       :feedback="rawJsonValidation.message"
       :validation-status="rawJsonValidation.status"
     >
-      <n-input v-model:value="rawJson" class="json-input" type="textarea" placeholder="Paste your raw json here..." />
+      <n-input
+        v-model:value="rawJson"
+        class="json-input"
+        type="textarea"
+        placeholder="Paste your raw json here..."
+        autocomplete="off"
+        autocorrect="off"
+        autocapitalize="off"
+        spellcheck="false"
+      />
     </n-form-item>
+
+    <n-space justify="center">
+      <n-button secondary @click="rawJson = ''">Clear</n-button>
+    </n-space>
   </n-card>
 
   <n-card v-if="cleanJson.length > 0">
@@ -39,7 +52,7 @@ const rawJsonValidation = useValidation({
   source: rawJson,
   rules: [
     {
-      validator: (v) => JSON.parse(v),
+      validator: (v) => v === '' || JSON.parse(v),
       message: 'Invalid json string',
     },
   ],
-- 
cgit v1.2.3

