8000 Copy button · mohammedaktaa/paste.laravel.io@8114132 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8114132

Browse files
committed
Copy button
1 parent ac49ce9 commit 8114132

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

package-lock.json

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"dependencies": {
1919
"alpinejs": "^2.8.0",
20+
"clipboard": "^2.0.6",
2021
"highlight.js": "^10.5.0",
2122
"highlightjs-line-numbers.js": "^2.8.0",
2223
"indent-textarea": "^2.0.3",

resources/js/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ document.addEventListener('DOMContentLoaded', (event) => {
2424
hljs.lineNumbersBlock(block);
2525
});
2626
});
27+
28+
// Clipboard
29+
import ClipboardJS from 'clipboard';
30+
31+
new ClipboardJS('.copy-btn');
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@isset($link)
22
<a
33
href="{{ $link }}"
4-
class="text-gray-600 hover:bg-gray-50 hover:text-gray-900 group flex items-center py-2 text-base font-medium rounded-md"
54
@isset($blank) target="_blank" @endisset
5+
{{ $attributes->merge(['class' => 'text-gray-600 hover:bg-gray-50 hover:text-gray-900 group flex items-center py-2 text-base font-medium rounded-md']) }}
66
>
77
@svg($icon, 'text-gray-400 group-hover:text-gray-500 mr-3 h-6 w-6')
88

@@ -12,6 +12,6 @@ class="text-gray-600 hover:bg-gray-50 hover:text-gray-900 group flex items-cente
1212
<div class="text-gray-600 hover:bg-gray-50 hover:text-gray-900 group flex items-center py-2 text-base font-medium rounded-md">
1313
@svg($icon, 'text-gray-400 group-hover:text-gray-500 mr-3 h-6 w-6')
1414

15-
<input type="{{ $type }}" value="{{ $label }}" class="bg-transparent cursor-pointer font-medium" />
15+
<input type="{{ $type }}" value="{{ $label }}" {{ $attributes->merge(['class' => 'bg-transparent cursor-pointer font-medium']) }} />
1616
</div>
1717
@endisset

resources/views/show.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
<div x-data="{ isOpen: false }" class="h-screen flex overflow-hidden">
55
<x-main>
66
<pre
7+
id="code"
78
class="h-full font-mono text-sm prettyprint linenums selectable" data-line-numbers="true"
89
><code>{{ $paste->code }}</code></pre>
910
</x-main>
1011

1112
<x-nav>
1213
<x-nav-item label="New" :link="route('home')" icon="heroicon-o-document-add" />
14+
<x-nav-item
15+
label="Copy"
16+
type="button"
17+
icon="heroicon-o-clipboard"
18+
class="copy-btn"
19+
data-clipboard-text="{{ 507B $paste->code }}"
20+
/>
1321
<x-nav-item label="Fork" :link="route('edit', $paste->hash)" icon="heroicon-o-document-duplicate" />
1422
<x-nav-item label="Raw" :link="route('raw', $paste->hash)" icon="heroicon-o-external-link" blank />
1523
</x-nav>

0 commit comments

Comments
 (0)
0