Files
pds/resources/views/filament/pages/shared-editor.blade.php
dhanabalan 05b34cbb90
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 18s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Laravel Pint / pint (pull_request) Successful in 3m7s
Laravel Larastan / larastan (pull_request) Failing after 5m27s
Added copy button and relevant logic
2026-11-25 12:18:14 +05:30

141 lines
3.9 KiB
PHP

{{--
<x-filament-panels::page>
<div
wire:poll.2s="refreshSharedContent"
class="space-y-4"
>
<div>
<p class="text-sm text-gray-500">
Paste or type your text below.
Changes are shared with users on this page.
</p>
</div>
<textarea
wire:model.live.debounce.500ms="content"
rows="18"
placeholder="Paste your text here..."
class="w-full rounded-xl border-gray-300
shadow-sm focus:border-primary-500
focus:ring-primary-500
dark:border-gray-700
dark:bg-gray-900 dark:text-white"
></textarea>
<div class="flex items-center justify-between gap-4">
<span class="text-sm text-gray-500">
Automatically saved to temporary file cache.
</span>
<x-filament::button
color="danger"
wire:click="clearContent"
wire:confirm="Clear the shared text for everyone?"
>
Clear text
</x-filament::button>
</div>
</div>
</x-filament-panels::page> --}}
<x-filament-panels::page>
<div wire:poll.1s="refreshSharedContent" class="space-y-4">
{{-- Header --}}
<div class="flex items-center justify-between gap-4">
<div>
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">
Shared Clipboard
</h2>
<p class="text-sm text-gray-500 dark:text-gray-400">
Type here to share content with other users.
</p>
</div>
{{-- Clear Button --}}
<x-filament::button
color="info"
icon="heroicon-o-clipboard"
wire:click="copyContent"
>
Copy To ClipBoard
</x-filament::button>
</div>
{{-- Shared Textarea --}}
<div>
<textarea
wire:model.live.debounce.500ms="content"
rows="20"
class="w-full rounded-lg border border-gray-300 bg-white p-4 text-sm text-gray-900 shadow-sm focus:border-primary-500 focus:ring-primary-500 dark:border-gray-700 dark:bg-gray-900 dark:text-white"
placeholder="Start typing here..."
spellcheck="false"
></textarea>
</div>
{{-- Footer --}}
<div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400">
<span>
<x-filament::loading-indicator
wire:loading
wire:target="updatedContent"
class="h-3 w-3"
/>
Changes are automatically synchronized.
</span>
<span>
Characters: <span x-data x-text="$wire.content.length"></span>
</span>
</div>
</div>
@script
<script>
$wire.on('copy-to-clipboard', (event) => {
const content = event.content;
const textarea = document.createElement('textarea');
textarea.value = content;
textarea.style.position = 'fixed';
textarea.style.left = '-9999px';
textarea.style.top = '0';
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
try {
const successful = document.execCommand('copy');
if (successful) {
new FilamentNotification()
.title('Content copied successfully!')
.success()
.send();
} else {
throw new Error('Copy command failed');
}
} catch (error) {
console.error('Clipboard copy failed:', error);
}
document.body.removeChild(textarea);
});
</script>
@endscript
</x-filament-panels::page>