diff --git a/pages/index.vue b/pages/index.vue
index bc1c3f052..6ca2dd0ec 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -36,34 +36,42 @@
+
+
+
+
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
-
+
+
+
@@ -213,6 +221,8 @@
bearerToken: '',
params: [],
bodyParams: [],
+ rawParams: '',
+ rawInput: false,
contentType: 'application/json',
response: {
status: '',
@@ -329,7 +339,7 @@
xhr.setRequestHeader('Authorization', 'Bearer ' + this.bearerToken);
}
if (this.method === 'POST' || this.method === 'PUT') {
- const requestBody = this.rawRequestBody
+ const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody;
xhr.setRequestHeader('Content-Length', requestBody.length)
xhr.setRequestHeader('Content-Type', `${this.contentType}; charset=utf-8`)
xhr.send(requestBody)
@@ -369,6 +379,30 @@
},
removeRequestBodyParam(index) {
this.bodyParams.splice(index, 1)
+ },
+ formatRawParams(event) {
+ if ((event.which !== 13 && event.which !== 9)) {
+ return;
+ }
+ const textBody = event.target.value;
+ const textBeforeCursor = textBody.substring(0, event.target.selectionStart);
+ const textAfterCursor = textBody.substring(event.target.selectionEnd);
+
+ if (event.which === 13) {
+ event.preventDefault();
+ const oldSelectionStart = event.target.selectionStart;
+ const lastLine = textBeforeCursor.split('\n').slice(-1)[0];
+ const rightPadding = lastLine.match(/([\s\t]*).*/)[1] || "";
+ event.target.value = textBeforeCursor + '\n' + rightPadding + textAfterCursor;
+ setTimeout(() => event.target.selectionStart = event.target.selectionEnd = oldSelectionStart + rightPadding.length + 1, 1);
+ }
+ else if (event.which === 9) {
+ event.preventDefault();
+ const oldSelectionStart = event.target.selectionStart;
+ event.target.value = textBeforeCursor + '\xa0\xa0' + textAfterCursor;
+ event.target.selectionStart = event.target.selectionEnd = oldSelectionStart + 2;
+ return false;
+ }
}
}
}