mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(cli): remove copy-text-to-clipboard
This commit is contained in:
parent
8013d2d49f
commit
c1ba5be45d
@ -64,7 +64,6 @@
|
|||||||
"commander": "^6.2.1",
|
"commander": "^6.2.1",
|
||||||
"consola": "^2.15.0",
|
"consola": "^2.15.0",
|
||||||
"conventional-changelog": "^3.1.24",
|
"conventional-changelog": "^3.1.24",
|
||||||
"copy-text-to-clipboard": "^3.0.1",
|
|
||||||
"css-loader": "^4.0.0",
|
"css-loader": "^4.0.0",
|
||||||
"eslint": "^7.17.0",
|
"eslint": "^7.17.0",
|
||||||
"fast-glob": "^3.2.4",
|
"fast-glob": "^3.2.4",
|
||||||
|
@ -33,7 +33,32 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import copy from 'copy-text-to-clipboard';
|
// from https://30secondsofcode.org
|
||||||
|
function copyToClipboard(str) {
|
||||||
|
const el = document.createElement('textarea');
|
||||||
|
el.value = str;
|
||||||
|
el.setAttribute('readonly', '');
|
||||||
|
el.style.position = 'absolute';
|
||||||
|
el.style.left = '-9999px';
|
||||||
|
document.body.appendChild(el);
|
||||||
|
|
||||||
|
const selection = document.getSelection();
|
||||||
|
|
||||||
|
if (!selection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selected = selection.rangeCount > 0 ? selection.getRangeAt(0) : false;
|
||||||
|
|
||||||
|
el.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(el);
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DemoPlayground',
|
name: 'DemoPlayground',
|
||||||
@ -56,7 +81,7 @@ export default {
|
|||||||
this.showSource = !this.showSource;
|
this.showSource = !this.showSource;
|
||||||
},
|
},
|
||||||
copySourceCode() {
|
copySourceCode() {
|
||||||
copy(unescape(this.originCode));
|
copyToClipboard(unescape(this.originCode));
|
||||||
this.copyStatus = 'copied';
|
this.copyStatus = 'copied';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.copyStatus = 'ready';
|
this.copyStatus = 'ready';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user