Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Merge branch 'master' into master

Edison Augusthy2b1a73e04d74
diff --cc pages/index.vue
index ab63fb258,6ca2dd0ec..fe73369a9
--- a/pages/index.vue
+++ b/pages/index.vue
@@@ -373,11 -380,30 +383,35 @@@
removeRequestBodyParam(index) {
this.bodyParams.splice(index, 1)
},
- copyResponse() {
+ 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;
+ }
- }
++
++ },
++ copyResponse() {
+ var copyText = document.getElementById("response-details");
+ copyText.select();
+ document.execCommand("copy");
- }
}
}
</script>