fmeccanici
fmeccanici
FFilament
Created by fmeccanici on 8/30/2023 in #❓┊help
$livewire->dispatchBrowserEvent('copy-to-clipboard') is not working on Safari
Thanks @pboivin, I am able to import the JS! The clipboard functionality still doesn't work on Safari though. I tried every solution from StackOverflow. Could be out of the scope of Filament, but I'm not sure.
12 replies
FFilament
Created by fmeccanici on 8/30/2023 in #❓┊help
$livewire->dispatchBrowserEvent('copy-to-clipboard') is not working on Safari
The second suggestion says that Safari implemented the Clipboard API 1 year ago. Which requires a small amount of javascript code:
navigator.clipboard.writeText("YOUR_TEXT").then(function() {

/* clipboard successfully set */

}, function() {

/* clipboard write failed */

});
navigator.clipboard.writeText("YOUR_TEXT").then(function() {

/* clipboard successfully set */

}, function() {

/* clipboard write failed */

});
What I am missing is how do I execute this piece of javascript code in the action of the table. This the stripped done table I currently have:
public static function table(Table $table): Table
{
return $table->headerActions([
Action::make('create')
->action(function (self $livewire, array $data): void {
$livewire->dispatchBrowserEvent('copy-to-clipboard', [
'text' => 'link-I-want-to-copy',
]);
])
}
public static function table(Table $table): Table
{
return $table->headerActions([
Action::make('create')
->action(function (self $livewire, array $data): void {
$livewire->dispatchBrowserEvent('copy-to-clipboard', [
'text' => 'link-I-want-to-copy',
]);
])
}
Because this table is inside a RelationManager class, which is used inside a Resource. This Resource is used inside a ListRecords class. But there is no associated blade file (or I cannot find it) where I can use a script tag to execute the javascript. I don't see a way to actually execute the Javascript, which is the main question I have. Do you know a way to execute this piece of Javascript?
12 replies
FFilament
Created by fmeccanici on 8/30/2023 in #❓┊help
$livewire->dispatchBrowserEvent('copy-to-clipboard') is not working on Safari
Yes I found it on StackOverflow (https://stackoverflow.com/questions/40147676/javascript-copy-to-clipboard-on-safari). There are multiple suggested implementations on this post.
12 replies