feat: syntax highlighting for cURL and bulk editors

This commit is contained in:
liyasthomas
2021-12-29 08:05:07 +05:30
parent 923c24e3bb
commit a1decaf6ad
34 changed files with 50 additions and 48 deletions

View File

@@ -323,9 +323,9 @@ const bulkHeaders = ref("")
watch(bulkHeaders, () => {
try {
const transformation = bulkHeaders.value.split("\n").map((item) => ({
key: item.substring(0, item.indexOf(":")).trim().replace(/^\/\//, ""),
key: item.substring(0, item.indexOf(":")).trim().replace(/^#/, ""),
value: item.substring(item.indexOf(":") + 1).trim(),
active: !item.trim().startsWith("//"),
active: !item.trim().startsWith("#"),
}))
setGQLHeaders(transformation as GQLHeader[])
} catch (e) {
@@ -414,8 +414,8 @@ const editBulkHeadersLine = (index: number, item?: GQLHeader | null) => {
.reduce((all, header, pIndex) => {
const current =
index === pIndex && item != null
? `${item.active ? "" : "//"}${item.key}: ${item.value}`
: `${header.active ? "" : "//"}${header.key}: ${header.value}`
? `${item.active ? "" : "#"}${item.key}: ${item.value}`
: `${header.active ? "" : "#"}${header.key}: ${header.value}`
return [...all, current]
}, [] as string[])
.join("\n")