File tree Expand file tree Collapse file tree 6 files changed +6079
-9
lines changed
Expand file tree Collapse file tree 6 files changed +6079
-9
lines changed Original file line number Diff line number Diff line change 2222 "require" : {
2323 "php" : " ^8.1" ,
2424 "filament/filament" : " ^3.0" ,
25+ "illuminate/contracts" : " ^10.0" ,
2526 "spatie/laravel-package-tools" : " ^1.15.0" ,
26- "illuminate/contracts " : " ^10.0 "
27+ "tempest/highlight " : " dev-main "
2728 },
2829 "require-dev" : {
2930 "laravel/pint" : " ^1.0" ,
Original file line number Diff line number Diff line change 11@import '../../vendor/filament/filament/resources/css/theme.css' ;
2+ @import "../../vendor/tempest/highlight/src/Themes/highlight-light-lite.css" ;
23
34.filament-syntax-entry-component .grid {
45 @apply block;
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ class="filament-syntax-entry"
66 package : ' parallax/filament-syntax-entry'
77 ) )]"
88 >
9- <div >
10- {{-- <pre><code>{{ $$getState() }}</code></pre> --}}
11- {{ $getState () } }
12- </div >
9+ <pre >{{ $getValue () } } </pre >
1310 </div >
1411</x-dynamic-component >
Original file line number Diff line number Diff line change 33namespace Parallax \FilamentSyntaxEntry ;
44
55use Closure ;
6- use Filament \Infolists \Components \Concerns \ HasAffixes ;
6+ use Filament \Infolists \Components \Concerns ;
77use Filament \Infolists \Components \Contracts \HasAffixActions ;
88use Filament \Infolists \Components \Entry ;
9+ use Illuminate \Support \HtmlString ;
10+ use Illuminate \Support \Str ;
11+ use Tempest \Highlight \Highlighter ;
912
1013class SyntaxEntry extends Entry implements HasAffixActions
1114{
12- use HasAffixes;
15+ use Concerns \CanFormatState;
16+ use Concerns \HasAffixes;
1317
1418 protected string $ view = 'filament-syntax-entry::syntax-entry ' ;
1519
@@ -19,6 +23,16 @@ class SyntaxEntry extends Entry implements HasAffixActions
1923
2024 protected string | Closure | null $ darkModeTheme = 'filament-dark ' ;
2125
26+ public function getValue (): HtmlString
27+ {
28+ $ state = $ this ->getState ();
29+ $ language = $ this ->language ;
30+ $ toParse = !is_string ($ state ) || $ language === 'json ' ? json_encode ($ state , JSON_PRETTY_PRINT ) : $ state ;
31+ $ parsed = (new Highlighter ())->parse ($ toParse , 'json ' );
32+
33+ return Str::of ($ parsed )->toHtmlString ();
34+ }
35+
2236 public function language (string | Closure $ language ): static
2337 {
2438 $ this ->language = $ language ;
Original file line number Diff line number Diff line change @@ -9,6 +9,6 @@ module.exports = {
99 ] ,
1010 safelist : [
1111 / s y n t a x - e n t r y - .+ / ,
12- / h l j s - .+ /
12+ / h l - .+ /
1313 ]
1414}
You can’t perform that action at this time.
0 commit comments