Skip to content

Commit

Permalink
Merge pull request #22 from zhinea/main
Browse files Browse the repository at this point in the history
feat(custom tabs): add Rich Editor & Markdown Editor support
  • Loading branch information
joaopaulolndev authored Jan 20, 2025
2 parents 4fe7c96 + 86237f4 commit 4113ff2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Enums/TypeFieldEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ enum TypeFieldEnum: string
case Select = 'select';
case Textarea = 'textarea';
case Datetime = 'datetime';
case RichEditor = 'rich_editor';
case MarkdownEditor = 'markdown_editor';
}
11 changes: 11 additions & 0 deletions src/Forms/CustomForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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;
use Filament\Forms\Components\TextInput;
Expand Down Expand Up @@ -50,7 +52,16 @@ 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'] ?? []);
} elseif ($field['type'] === TypeFieldEnum::MarkdownEditor->value) {
$fields[] = MarkdownEditor::make($fieldKey)
->label(__($field['label']))
->toolbarButtons($field['toolbarButtons'] ?? []);
}

}

return $fields;
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/GeneralSettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 4113ff2

Please sign in to comment.