mohamedsabil83/filament-forms-tinyeditor
Installation Add the package via Composer:
composer require mohamedsabil83/filament-forms-tinyeditor
Publish the config (if needed):
php artisan vendor:publish --provider="MohamedSabil83\FilamentFormsTinyEditor\FilamentFormsTinyEditorServiceProvider"
First Use Case Register the editor in a Filament form:
use MohamedSabil83\FilamentFormsTinyEditor\Forms\Components\TinyEditor;
TinyEditor::make('content')
->required()
->columnSpanFull(),
Where to Look First
config/filament-forms-tinyeditor.php for default TinyMCE settings (e.g., toolbar, plugins).app/Providers/FilamentFormsTinyEditorServiceProvider.php for service registration.Basic Integration Replace default Filament textareas with TinyMCE in forms:
public static function form(Form $form): Form
{
return $form
->schema([
TinyEditor::make('description')
->rows(5),
]);
}
Customizing TinyMCE
Override default config via the config() method:
TinyEditor::make('bio')
->config([
'plugins' => 'advlist autolink lists link image charmap print preview',
'toolbar' => 'undo redo | bold italic | alignleft aligncenter alignright',
]),
Validation & Sanitization Use Filament’s built-in validation alongside TinyMCE:
TinyEditor::make('article')
->required()
->maxLength(5000)
->afterStateUpdated(fn (string $state, TinyEditor $component) => $component->sanitize($state)),
Dynamic Toolbars Conditionally load plugins based on user roles:
TinyEditor::make('editor')
->config(fn (User $user) => [
'toolbar' => $user->can('publish') ? 'publish' : '',
]),
Reusing Components Create a reusable form component:
// app/Filament/Forms/Components/TinyEditorWithPresets.php
class TinyEditorWithPresets extends TinyEditor
{
protected string $presets = 'bold,italic,|,alignleft,aligncenter,alignright';
public function configure(): static
{
return $this->config(['toolbar' => $this->presets]);
}
}
TinyEditor::make('content')
->lang('es'), // Spanish
TinyEditor::make('notes')
->lazy(true),
Deprecation Warning The package is unmaintained (as noted in the README). Consider alternatives like:
filament-spatie/laravel-medialibrary (for rich text + media).filament/tiny-mce (official Filament TinyMCE wrapper).Asset Conflicts
public function boot()
{
Filament::registerAsset(
path: 'vendor/mohamedsabil83/filament-forms-tinyeditor/dist/tinymce.min.js',
integrity: false
);
}
Configuration Overrides
config/filament-forms-tinyeditor.php) may override per-field settings.->config() to merge settings:
TinyEditor::make('content')
->config(array_merge(config('filament-forms-tinyeditor.defaults'), [
'plugins' => 'additional_plugin',
])),
Sanitization Gaps
<script> tags).use Purifier;
TinyEditor::make('html')
->afterStateUpdated(fn (string $state) => Purifier::clean($state)),
Filament Version Compatibility
tinymce is not defined → Asset loading issue.Invalid configuration → Malformed config() array.TinyEditor::make('debug')
->config(fn () => [
'setup' => fn (editor) => logger()->debug($editor.getConfig()),
]),
tinymce.min.js).Custom Plugins
Extend TinyMCE with plugins like table or codesample:
TinyEditor::make('editor')
->config([
'plugins' => 'table codesample',
'toolbar' => 'codesample | table',
]),
Event Listeners
Hook into TinyMCE events (e.g., init, change):
TinyEditor::make('content')
->config([
'setup' => fn (editor) => $editor.on('change', fn () => logger()->info('Content changed!')),
]),
Themes Switch to a dark theme:
TinyEditor::make('bio')
->config([
'skin' => 'oxide-dark',
'content_style' => 'body { background: #222; color: #eee; }',
]),
Cloud Services Integrate with TinyMCE Cloud for plugins/themes:
TinyEditor::make('article')
->config([
'api_key' => config('services.tinymce.api_key'),
'cloud_channel' => 'stable',
]),
How can I help you explore Laravel packages today?