diff --git a/resources/views/infolists/components/json-entry.blade.php b/resources/views/infolists/components/json-entry.blade.php index a959a77..40f68c8 100644 --- a/resources/views/infolists/components/json-entry.blade.php +++ b/resources/views/infolists/components/json-entry.blade.php @@ -1,25 +1,67 @@ - @php - $identification = $getId(); - @endphp +
+
{ + var count = undefined; -
+ // Get open / close token + var startToken = '{', endToken = '}'; + var prevLine = codeMirrorEditor.getLine(from.line); + if (prevLine.lastIndexOf('[') > prevLine.lastIndexOf('{')) { + startToken = '[', endToken = ']'; + } - + return count ? `\u21A4${count}\u21A6` : '\u2194'; + } + } + }); + codeMirrorEditor.setSize(null, '100%'); + codeMirrorEditor.setValue({{ json_encode($getState()) }}); + + setTimeout(function() { + codeMirrorEditor.refresh(); + }, 1); + " + > +
+
+
diff --git a/src/Infolists/Components/JsonEntry.php b/src/Infolists/Components/JsonEntry.php index ea17fc0..5ca0dcf 100644 --- a/src/Infolists/Components/JsonEntry.php +++ b/src/Infolists/Components/JsonEntry.php @@ -2,9 +2,66 @@ namespace CodebarAg\FilamentCodemirror\Infolists\Components; +use Closure; use Filament\Infolists\Components\Entry; class JsonEntry extends Entry { protected string $view = 'filament-codemirror::infolists.components.json-entry'; + + protected bool|Closure $hasLineNumbers = true; + + protected bool|Closure $hasAutoCloseBrackets = true; + + protected bool|Closure $hasDarkTheme = false; + + protected bool|Closure $hasFoldingCode = true; + + public function lineNumbers(bool|Closure $condition = true): static + { + $this->hasLineNumbers = $condition; + + return $this; + } + + public function autoCloseBrackets(bool|Closure $condition = true): static + { + $this->hasAutoCloseBrackets = $condition; + + return $this; + } + + public function darkTheme(bool|Closure $condition = true): static + { + $this->hasDarkTheme = $condition; + + return $this; + } + + public function foldingCode(bool|Closure $condition = true): static + { + $this->hasFoldingCode = $condition; + + return $this; + } + + public function getHasLineNumbers(): bool + { + return (bool) $this->evaluate($this->hasLineNumbers); + } + + public function getHasAutoCloseBrackets(): bool + { + return (bool) $this->evaluate($this->hasAutoCloseBrackets); + } + + public function getHasDarkTheme(): bool + { + return (bool) $this->evaluate($this->hasDarkTheme); + } + + public function getHasFoldingCode(): bool + { + return (bool) $this->evaluate($this->hasFoldingCode); + } }