From b00d882e5211e1eaa470f21b4cff7369734b8c50 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 10 May 2024 00:43:04 +0800 Subject: [PATCH] https://github.com/solutionforest/Filament-SimpleLightBox/issues/13 --- src/SimpleLightBoxPlugin.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/SimpleLightBoxPlugin.php b/src/SimpleLightBoxPlugin.php index 2accbe5..c716a50 100644 --- a/src/SimpleLightBoxPlugin.php +++ b/src/SimpleLightBoxPlugin.php @@ -27,27 +27,33 @@ public function register(Panel $panel): void public function boot(Panel $panel): void { ImageColumn::macro('simpleLightbox', macro: function ($url = null) { + $extraAttributes = $this->extraAttributes[0] ?? []; + $extraImgAttributes = $this->extraImgAttributes[0] ?? []; /** @phpstan-ignore-next-line */ return $this - ->extraAttributes(['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')']) - ->extraImgAttributes(['class' => 'simple-light-box-img-indicator']); + ->extraAttributes(array_merge($extraAttributes, ['x-on:click' => 'SimpleLightBox.open(event, \''.$url.'\')'])) + ->extraImgAttributes(array_merge($extraImgAttributes, ['class' => 'simple-light-box-img-indicator'])); }); ImageEntry::macro('simpleLightbox', function ($url = null) { + $extraAttributes = $this->extraAttributes[0] ?? []; + $extraImgAttributes = $this->extraImgAttributes[0] ?? []; /** @phpstan-ignore-next-line */ return $this - ->extraAttributes(['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')']) - ->extraImgAttributes(['class' => 'simple-light-box-img-indicator']); + ->extraAttributes(array_merge($extraAttributes, ['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')'])) + ->extraImgAttributes(array_merge($extraImgAttributes, ['class' => 'simple-light-box-img-indicator'])); }); TextColumn::macro('simpleLightbox', function ($url) { + $extraAttributes = $this->extraAttributes[0] ?? []; /** @phpstan-ignore-next-line */ - return $this->extraAttributes(['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')']); + return $this->extraAttributes(array_merge($extraAttributes,['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')'])); }); TextEntry::macro('simpleLightbox', function ($url) { + $extraAttributes = $this->extraAttributes[0] ?? []; /** @phpstan-ignore-next-line */ - return $this->extraAttributes(['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')']); + return $this->extraAttributes(array_merge($extraAttributes,['x-on:click' => 'SimpleLightBox.open(event, \'' . $url . '\')'])); }); }