jeffersongoncalves / filament-carve
Carve markup for Filament: editor field, rendered entry and table column, built on laravel-carve.
Package info
github.com/jeffersongoncalves/filament-carve
pkg:composer/jeffersongoncalves/filament-carve
Requires
- php: ^8.2
- filament/filament: ^5.0
- jeffersongoncalves/laravel-carve: ^1.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.0|^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Filament Carve
Carve markup for Filament, built on jeffersongoncalves/laravel-carve:
CarveEditor: a textarea that validates Carve source and previews the rendered HTML in a modal.CarveEntry: an infolist entry that renders Carve source as HTML.CarveColumn: a table column that shows Carve source as plain text, or as HTML.
Compatibility
| Package Version | Filament Version |
|---|---|
| 1.x | 3.x |
| 2.x | 4.x |
| 3.x | 5.x |
Installation
You can install the package via composer:
composer require jeffersongoncalves/filament-carve
Rendering is configured by laravel-carve. Publish its config to change the render profiles (default, comment, trusted, ...):
php artisan vendor:publish --tag="carve-config"
Usage
Editor
use JeffersonGoncalves\Filament\Carve\Forms\Components\CarveEditor; CarveEditor::make('body') ->profile('comment') // laravel-carve profile used by the preview ->preset('comment') // fail validation on markup the preset does not allow ->strict() // fail validation on parse warnings ->lint() // fail validation on lint findings, such as Markdown's **bold** ->previewable(false); // hide the preview action
CarveEditor extends Filament's Textarea, so every textarea method (rows(), autosize(), maxLength(), ...) still works. The source is always checked with laravel-carve's ValidCarve rule.
Infolist entry
use JeffersonGoncalves\Filament\Carve\Infolists\Components\CarveEntry; CarveEntry::make('body') ->profile('trusted');
Table column
use JeffersonGoncalves\Filament\Carve\Tables\Columns\CarveColumn; CarveColumn::make('body')->limit(80); // plain text excerpt CarveColumn::make('body')->html(); // rendered HTML
Security
Rendered HTML is printed unescaped. Safety comes from the laravel-carve profile: use a safe_mode profile (the default and comment profiles are safe) for user supplied content, and a profile with safe_mode => false only for content you trust.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
