From 163c252e8d801c8e64e260a6d4f70291fbb2b292 Mon Sep 17 00:00:00 2001 From: Joao Nascimento Date: Sun, 23 Jun 2024 17:27:00 +0100 Subject: [PATCH] Add field editor --- composer.json | 3 ++- src/Livewire/ChangeEnvFileComponent.php | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index cd048c7..675ac34 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "require": { "php": "^8.1", "filament/filament": "^3.0", + "riodwanto/filament-ace-editor": "^1.0", "spatie/laravel-package-tools": "^1.15.0" }, "require-dev": { @@ -68,4 +69,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/src/Livewire/ChangeEnvFileComponent.php b/src/Livewire/ChangeEnvFileComponent.php index 7c43d6f..35ee030 100644 --- a/src/Livewire/ChangeEnvFileComponent.php +++ b/src/Livewire/ChangeEnvFileComponent.php @@ -10,6 +10,7 @@ use Filament\Forms\Contracts\HasForms; use Filament\Notifications\Notification; use Livewire\Component; +use Riodwanto\FilamentAceEditor\AceEditor; class ChangeEnvFileComponent extends Component implements HasActions, HasForms { @@ -30,14 +31,15 @@ public function editAction() ->iconButton() ->modalHeading(__('filament-edit-env::default.heading')) ->form([ - //@todo: change this to a code editor - Textarea::make('envFile') + AceEditor::make('envFile') ->label('.env') + ->mode('php') + ->theme('github') + ->darkTheme('dracula') ->required() ->default(file_get_contents(base_path('.env'))) - ->autofocus() - ->rows(20) - ->hint(__('filament-edit-env::default.hint')), + ->hint(__('filament-edit-env::default.hint')) + ->height('26rem'), ]) ->action(function (array $data) { file_put_contents(base_path('.env'), $data['envFile']);