Files
pds/resources/views/filament/pages/shared-editor.blade.php
dhanabalan d97bcd7abd
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Laravel Pint / pint (pull_request) Successful in 2m6s
Laravel Larastan / larastan (pull_request) Failing after 4m55s
Added download button in shared editor page
2026-11-25 12:46:04 +05:30

142 lines
4.0 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">
<div class="flex items-center justify-start">
<p class="text-sm text-gray-500 dark:text-gray-400">
Type here to share content with other users.
</p>
</div>
<div class="flex items-center justify-end gap-2">
<x-filament::button
color="info"
icon="heroicon-o-clipboard"
wire:click="copyContent"
>
Copy To ClipBoard
</x-filament::button>
{{-- @if (auth()->user()?->hasRole('Super Admin')) --}}
<x-filament::button
color="success"
icon="heroicon-o-arrow-down-tray"
wire:click="downloadTxt"
>
Download Txt
</x-filament::button>
{{-- @endif --}}
</div>
<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>
<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>