Skip to content

Commit 8da5bfe

Browse files
committed
Further syntax handling
1 parent 97ff8b6 commit 8da5bfe

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

resources/views/syntax-entry.blade.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
@php
2+
use Illuminate\Support\Str;
3+
4+
$value = $getState();
5+
$validJson = !is_string($value) && Str::isJson(json_encode($value));
6+
@endphp
7+
18
<x-dynamic-component class="filament-syntax-entry-component" :component="$getEntryWrapperView()" :entry="$entry" wire:ignore>
29
<div
310
class="filament-syntax-entry"
@@ -33,7 +40,7 @@ class="filament-syntax-entry"
3340
x-init="init()"
3441
x-on:destroyed="cleanup"
3542
>
36-
<pre><code>{{ json_encode($getState(), JSON_PRETTY_PRINT) }}</code></pre>
43+
<pre><code>{{ $validJson ? json_encode($value, JSON_PRETTY_PRINT) : $value }}</code></pre>
3744
</div>
3845
</div>
3946
</x-dynamic-component>

src/SyntaxEntry.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,23 @@ class SyntaxEntry extends Entry implements HasAffixActions
1313

1414
protected string $view = 'filament-syntax-entry::syntax-entry';
1515

16+
protected string | Closure | null $language = null;
17+
1618
protected string | Closure | null $theme = 'filament';
1719

18-
protected string | Closure | null $darkModeTheme = null;
20+
protected string | Closure | null $darkModeTheme = 'filament-dark';
21+
22+
public function language(string | Closure $language): static
23+
{
24+
$this->language = $language;
25+
26+
return $this;
27+
}
28+
29+
public function getLanguage(): string
30+
{
31+
return $this->evaluate($this->language);
32+
}
1933

2034
public function theme(string | Closure $theme): static
2135
{

0 commit comments

Comments
 (0)