diff --git a/config/admin-kit-articles.php b/config/admin-kit-articles.php index dcc0d23..a32a928 100644 --- a/config/admin-kit-articles.php +++ b/config/admin-kit-articles.php @@ -24,4 +24,9 @@ 'published_at' => [ 'with_time' => true, ], + + 'short_content' => [ + 'enabled' => false, + 'is_wysiwyg' => false, + ], ]; diff --git a/src/UI/Filament/Resources/ArticleResource.php b/src/UI/Filament/Resources/ArticleResource.php index f140dae..a269387 100644 --- a/src/UI/Filament/Resources/ArticleResource.php +++ b/src/UI/Filament/Resources/ArticleResource.php @@ -9,6 +9,8 @@ use Filament\Forms; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\DateTimePicker; +use Filament\Forms\Components\RichEditor; +use Filament\Forms\Components\Textarea; use Filament\Forms\Form; use Filament\Forms\Get; use Filament\Forms\Set; @@ -46,6 +48,18 @@ public static function form(Form $form): Form ->columnSpan(12); } + $shortContent = function ($locale): array { + $shortContentClass = config('admin-kit-articles.short_content.is_wysiwyg') ? RichEditor::class : Textarea::class; + + if (config('admin-kit-articles.short_content.enabled')) { + return [$shortContentClass::make("short_content.$locale") + ->label(__('admin-kit-articles::articles.resource.short_content')) + ->columnSpan(2)]; + } + + return []; + }; + $components[] = TranslatableTabs::make(fn ($locale) => [ Forms\Components\TextInput::make("title.$locale") ->label(__('admin-kit-articles::articles.resource.title')) @@ -59,14 +73,12 @@ function (string $context, string $state, Set $set, Get $get) use ($locale) { }) ->columnSpan(2), - Forms\Components\RichEditor::make("content.$locale") + RichEditor::make("content.$locale") ->label(__('admin-kit-articles::articles.resource.content')) ->required($locale === app()->getLocale()) ->columnSpan(2), - Forms\Components\RichEditor::make("short_content.$locale") - ->label(__('admin-kit-articles::articles.resource.short_content')) - ->columnSpan(2), + ...$shortContent($locale), ]) ->columnSpan([ 12,