From 1f8fb4624c379420bbf3456e43ded0471a2005e9 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 25 Nov 2026 11:41:20 +0530 Subject: [PATCH] Added shared editor page --- app/Filament/Pages/SharedEditor.php | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 app/Filament/Pages/SharedEditor.php diff --git a/app/Filament/Pages/SharedEditor.php b/app/Filament/Pages/SharedEditor.php new file mode 100644 index 00000000..58210c50 --- /dev/null +++ b/app/Filament/Pages/SharedEditor.php @@ -0,0 +1,75 @@ + 1], + ['content' => ''] + ); + + $this->content = $clipboard->content ?? ''; + + $this->lastSyncedContent = $this->content; + } + + public function updatedContent(): void + { + SharedClipBoard::where('id', 1)->update([ + 'content' => $this->content, + ]); + + $this->lastSyncedContent = $this->content; + } + + public function refreshSharedContent(): void + { + $sharedContent = SharedClipBoard::find(1)?->content ?? ''; + + // Do not overwrite text that this user is editing. + if ( + $this->content === $this->lastSyncedContent + && $sharedContent !== $this->lastSyncedContent + ) { + $this->content = $sharedContent; + + $this->lastSyncedContent = $sharedContent; + } + } + + public function clearContent(): void + { + SharedClipBoard::where('id', 1)->update([ + 'content' => '', + ]); + + $this->content = ''; + + $this->lastSyncedContent = ''; + } + + public static function canAccess(): bool + { + return Auth::check() && Auth::user()->can('view shared clipboard page'); + } + +}