feat: migrate all copy to clipboard actions to v-clipboard

This commit is contained in:
liyasthomas
2021-07-27 18:17:41 +05:30
parent 37ad8e08fc
commit 78fccc8583
21 changed files with 120 additions and 129 deletions

View File

@@ -53,13 +53,6 @@
<label for="generatedCode" class="font-semibold px-4 pt-4 pb-4">
{{ $t("generated_code") }}
</label>
<ButtonSecondary
ref="copyRequestCode"
v-tippy="{ theme: 'tooltip' }"
:title="$t('copy')"
:icon="copyIcon"
@click.native="copyRequestCode"
/>
</div>
<SmartAceEditor
v-if="codegenType"
@@ -67,8 +60,8 @@
:value="requestCode"
:lang="codegens.find((x) => x.id === codegenType).language"
:options="{
maxLines: '16',
minLines: '8',
maxLines: 16,
minLines: 8,
fontSize: '12px',
autoScrollEditorIntoView: true,
readOnly: true,
@@ -79,6 +72,15 @@
/>
</div>
</template>
<template #footer>
<ButtonPrimary
ref="copyRequestCode"
:label="$t('copy')"
:icon="copyIcon"
@click.native="copyRequestCode"
/>
<ButtonSecondary :label="$t('cancel')" @click.native="hideModal" />
</template>
</SmartModal>
</template>
@@ -149,16 +151,12 @@ export default defineComponent({
this.$emit("handle-import")
},
copyRequestCode() {
const editor: any = this.$refs.generatedCode
editor.editor.selectAll()
editor.editor.focus()
document.execCommand("copy")
this.$clipboard(this.requestCode)
this.copyIcon = "done"
this.$toast.success(this.$t("copied_to_clipboard").toString(), {
icon: "done",
})
setTimeout(() => (this.copyIcon = "content_copy"), 1000)
},
},
})

View File

@@ -27,8 +27,8 @@
<SmartJsEditor
v-model="preRequestScript"
:options="{
maxLines: '16',
minLines: '8',
maxLines: 16,
minLines: 8,
fontSize: '12px',
autoScrollEditorIntoView: true,
showPrintMargin: false,

View File

@@ -53,8 +53,8 @@
v-model="rawParamsBody"
:lang="rawInputEditorLang"
:options="{
maxLines: '16',
minLines: '8',
maxLines: 16,
minLines: 8,
fontSize: '12px',
autoScrollEditorIntoView: true,
showPrintMargin: false,

View File

@@ -276,12 +276,7 @@ export default defineComponent({
.then(() => {})
.catch(() => {})
} else {
const dummy = document.createElement("input")
document.body.appendChild(dummy)
dummy.value = window.location.href
dummy.select()
document.execCommand("copy")
document.body.removeChild(dummy)
this.$clipboard(window.location.href)
this.$toast.info(this.$t("copied_to_clipboard"), {
icon: "done",
})

View File

@@ -27,8 +27,8 @@
<SmartJsEditor
v-model="testScript"
:options="{
maxLines: '16',
minLines: '8',
maxLines: 16,
minLines: 8,
fontSize: '12px',
autoScrollEditorIntoView: true,
showPrintMargin: false,