Skip to content

Commit 4db4b49

Browse files
authored
🐛 Fix editor clipboard (#127)
1 parent 3a66ab4 commit 4db4b49

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

public/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/js/app.js": "/js/app.js?id=771d5d47a2ec2c3ddfd6ca0852da949e",
2+
"/js/app.js": "/js/app.js?id=e624a82705e66ddf8f8774361377693b",
33
"/css/app.css": "/css/app.css?id=3542b9735c706c26665a33113b79c212"
44
}

resources/js/utils/clipboard.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ codeBlocks.forEach((element, key) => {
1919
copyNotification: false,
2020
copyToClipboard() {
2121
this.copyNotification = true
22+
let that = this
2223
const clipboardItem = new ClipboardItem({
23-
'text/plain': new Blob([\`${codeElement.innerText}\`], { type: 'text/plain' })
24+
'text/plain': new Blob([\`${codeElement.innerText.replaceAll('"', '\\`')}\`], { type: 'text/plain' })
2425
})
2526
navigator.clipboard.write([clipboardItem]).then(() => {
26-
console.log('Copied to clipboard')
27+
setTimeout(function() {
28+
that.copyNotification = false
29+
}, 3000)
2730
})
28-
let that = this
29-
setTimeout(function() {
30-
that.copyNotification = false
31-
}, 3000)
3231
}
3332
}" class="relative z-20 flex items-center">
3433
<div x-show="copyNotification" x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 translate-x-2" x-transition:enter-end="opacity-100 translate-x-0" x-transition:leave="transition ease-in duration-300" x-transition:leave-start="opacity-100 translate-x-0" x-transition:leave-end="opacity-0 translate-x-2" class="absolute left-0" x-cloak>

0 commit comments

Comments
 (0)