From fddd41f6b41a7bbf7e60aa2963669d4cb07c2f4f Mon Sep 17 00:00:00 2001 From: Nicholas Palenchar Date: Sun, 25 Aug 2019 14:41:34 -0400 Subject: [PATCH] wip - some raw text formtting with one small return bug to fix --- pages/index.vue | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index 501be50c..82788ad0 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -68,7 +68,7 @@
- +
@@ -379,6 +379,31 @@ }, removeRequestBodyParam(index) { this.bodyParams.splice(index, 1) + }, + formatRawParams(event) { + if ((event.which !== 13 && event.which !== 9)) { + console.log('not not returning'); + 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) { + const lastLine = textBody.split('\n').slice(-1)[0]; + const rightPadding = lastLine.match(/([\s\t]*).*/)[1] || ""; + setTimeout(() => event.target.value = textBeforeCursor + '\n' + rightPadding + textAfterCursor, 1); + } + else if (event.which === 9) { + event.preventDefault(); + const oldSelectionStart = event.target.selectionStart; + const oldSelectionEnd = event.target.selectionEnd; + event.target.value = textBeforeCursor + '\xa0\xa0' + textAfterCursor; + debugger; + event.target.selectionStart = event.target.selectionEnd = oldSelectionStart + 2; + return false; + } } } }