From e6031c64bca16b30757679995671de977af52d9c Mon Sep 17 00:00:00 2001 From: Zidna Fadla Date: Mon, 20 Jan 2025 14:29:08 +0700 Subject: [PATCH 1/3] feat(forms): add rich editor field type --- src/Enums/TypeFieldEnum.php | 1 + src/Forms/CustomForms.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/Enums/TypeFieldEnum.php b/src/Enums/TypeFieldEnum.php index 19e24a4..4db4957 100644 --- a/src/Enums/TypeFieldEnum.php +++ b/src/Enums/TypeFieldEnum.php @@ -13,4 +13,5 @@ enum TypeFieldEnum: string case Select = 'select'; case Textarea = 'textarea'; case Datetime = 'datetime'; + case RichEditor = 'rich_editor'; } diff --git a/src/Forms/CustomForms.php b/src/Forms/CustomForms.php index 2d51335..98d866f 100644 --- a/src/Forms/CustomForms.php +++ b/src/Forms/CustomForms.php @@ -4,6 +4,7 @@ use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\DateTimePicker; +use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; @@ -50,7 +51,12 @@ public static function get(array $customFields): array ->label(__($field['label'])) ->placeholder(__($field['placeholder'])) ->seconds($field['seconds']); + } elseif ($field['type'] === TypeFieldEnum::RichEditor->value) { + $fields[] = RichEditor::make($fieldKey) + ->label(__($field['label'])) + ->toolbarButtons($field['toolbarButtons'] ?? []); } + } return $fields; From f44f65883517a8095cea7e9fb63946f52bcfed62 Mon Sep 17 00:00:00 2001 From: Zidna Fadla Date: Mon, 20 Jan 2025 14:30:45 +0700 Subject: [PATCH 2/3] feat(forms): add markdown editor support --- src/Enums/TypeFieldEnum.php | 1 + src/Forms/CustomForms.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Enums/TypeFieldEnum.php b/src/Enums/TypeFieldEnum.php index 4db4957..4c48b6c 100644 --- a/src/Enums/TypeFieldEnum.php +++ b/src/Enums/TypeFieldEnum.php @@ -14,4 +14,5 @@ enum TypeFieldEnum: string case Textarea = 'textarea'; case Datetime = 'datetime'; case RichEditor = 'rich_editor'; + case MarkdownEditor = 'markdown_editor'; } diff --git a/src/Forms/CustomForms.php b/src/Forms/CustomForms.php index 98d866f..5162813 100644 --- a/src/Forms/CustomForms.php +++ b/src/Forms/CustomForms.php @@ -4,6 +4,7 @@ use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\DateTimePicker; +use Filament\Forms\Components\MarkdownEditor; use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; @@ -55,6 +56,10 @@ public static function get(array $customFields): array $fields[] = RichEditor::make($fieldKey) ->label(__($field['label'])) ->toolbarButtons($field['toolbarButtons'] ?? []); + } elseif ($field['type'] === TypeFieldEnum::MarkdownEditor->value) { + $fields[] = MarkdownEditor::make($fieldKey) + ->label(__($field['label'])) + ->toolbarButtons($field['toolbarButtons'] ?? []); } } From 86237f4cf19e750f4146b7ac68c133e67b8a78a5 Mon Sep 17 00:00:00 2001 From: Zidna Fadla Date: Mon, 20 Jan 2025 15:13:51 +0700 Subject: [PATCH 3/3] fix(settings): removes unnecessary CustomForms call --- src/Pages/GeneralSettingsPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pages/GeneralSettingsPage.php b/src/Pages/GeneralSettingsPage.php index e0c134c..f0c4854 100644 --- a/src/Pages/GeneralSettingsPage.php +++ b/src/Pages/GeneralSettingsPage.php @@ -148,7 +148,7 @@ public function form(Form $form): Form $arrTabs[] = Tabs\Tab::make($customTab['label']) ->label(__($customTab['label'])) ->icon($customTab['icon']) - ->schema(CustomForms::get($customTab['fields'])) + ->schema($customTab['fields']) ->columns($customTab['columns']) ->statePath('more_configs'); }