wip - some raw text formtting with one small return bug to fix
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div><div v-else>
|
||||
<textarea v-model="rawParams" style="font-family: monospace;" rows="16"></textarea>
|
||||
<textarea v-model="rawParams" style="font-family: monospace;" rows="16" @keydown="formatRawParams"></textarea>
|
||||
</div>
|
||||
</pw-section>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user