🎉 API documentation page

This commit is contained in:
Liyas Thomas
2019-12-20 14:40:16 +05:30
parent 001c4818a0
commit f0868f383b
3 changed files with 109 additions and 33 deletions

View File

@@ -227,7 +227,6 @@
<Editor
v-model="rawParams"
:lang="'json'"
@keydown="formatRawParams"
:options="{
maxLines: '16',
minLines: '8',
@@ -1816,38 +1815,6 @@ export default {
}
});
},
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;
}
},
copyRequest() {
if (navigator.share) {
let time = new Date().toLocaleTimeString();