1
0

Include bundle in view data

This commit is contained in:
Richard Dern 2024-05-11 16:35:34 +02:00
parent ee00d22095
commit fc15d21314
8 changed files with 14 additions and 12 deletions

View File

@ -384,11 +384,11 @@ private function getBladeComponent(array $data, ?array $variant, ?array $options
{
switch ($this->kind) {
case self::Images:
return new Image($data, $variant, $options);
return new Image($this->bundle, $data, $variant, $options);
case self::Sounds:
return new Sound($data);
return new Sound($this->bundle, $data);
case self::Videos:
return new Video($data);
return new Video($this->bundle, $data);
default:
throw new Exception(sprintf('Unknown Blade Component for attachment kind "%s"', $this->kind));
}

View File

@ -2,6 +2,7 @@
namespace App\View\Components;
use App\Classes\Bundle;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Storage;
@ -15,7 +16,7 @@ abstract class BaseMediaComponent extends Component
/**
* Create a new component instance.
*/
public function __construct(protected array $data, protected ?array $variant = [], protected ?array $options = [])
public function __construct(protected Bundle $bundle, protected array $data, protected ?array $variant = [], protected ?array $options = [])
{
}
@ -33,6 +34,7 @@ public function render(): View|Closure|string
'originalData' => $this->data,
'variantData' => $this->variant,
'options' => $this->options,
'bundle' => $this->bundle,
]);
}

View File

@ -1 +1 @@
<div class="chat-me markdown-body">{!! (new \App\Services\Markdown\Formatter($slot))->render() !!}</div>
<div class="chat-me markdown-body">{!! (new \App\Services\Markdown\Formatter($slot, $mainBundle))->render() !!}</div>

View File

@ -1,3 +1,3 @@
@props(['name'])
<div class="chat-other markdown-body">{!! (new \App\Services\Markdown\Formatter($slot))->render() !!}</div>
<div class="chat-other markdown-body">{!! (new \App\Services\Markdown\Formatter($slot, $mainBundle))->render() !!}</div>

View File

@ -1,7 +1,7 @@
<figure>
@if (!empty($originalData['prompt']) && empty($options['nolink']))
<figcaption class="markdown-body">
{!! (new \App\Services\Markdown\Formatter($originalData['prompt']))->render() !!}
{!! (new \App\Services\Markdown\Formatter($originalData['prompt'], $bundle))->render() !!}
</figcaption>
@endif
@if(!empty($options['nolink']))
@ -14,10 +14,10 @@
@if (empty($options['nolink']) && (!empty($originalData['title']) || !empty($originalData['attribution'])))
<figcaption class="markdown-body">
@if (!empty($originalData['title']))
{!! (new \App\Services\Markdown\Formatter($originalData['title']))->render() !!}
{!! (new \App\Services\Markdown\Formatter($originalData['title'], $bundle))->render() !!}
@endif
@if (!empty($originalData['attribution']))
{!! (new \App\Services\Markdown\Formatter($originalData['attribution']))->render() !!}
{!! (new \App\Services\Markdown\Formatter($originalData['attribution'], $bundle))->render() !!}
@endif
</figcaption>
@endif

View File

@ -4,7 +4,7 @@
</audio>
<figcaption class="markdown-body">
@if (!empty($originalData['title']))
{!! (new \App\Services\Markdown\Formatter($originalData['title']))->render() !!}
{!! (new \App\Services\Markdown\Formatter($originalData['title'], $bundle))->render() !!}
@endif
</figcaption>
</figure>

View File

@ -1,4 +1,4 @@
<details class="spoiler">
<summary>Spoiler</summary>
<div class="markdown-body">{!! (new \App\Services\Markdown\Formatter($slot))->render() !!}</div>
<div class="markdown-body">{!! (new \App\Services\Markdown\Formatter($slot, $mainBundle))->render() !!}</div>
</details>

View File

@ -1,4 +1,4 @@
<details class="update">
<summary>{{ $title }}</summary>
<div class="markdown-body">{!! (new \App\Services\Markdown\Formatter($slot))->render() !!}</div>
<div class="markdown-body">{!! (new \App\Services\Markdown\Formatter($slot, $mainBundle))->render() !!}</div>
</details>