visualbuilder/filament-tinyeditor
Installation:
composer require visualbuilder/filament-tinyeditor:^5.0 # For Filament 5.x
Publish assets/config:
php artisan vendor:publish --provider="Visualbuilder\FilamentTinyEditor\TinyeditorServiceProvider" --tag=config,views,public
First Use Case:
Replace a standard Textarea field in a Filament form with the TinyMCE editor:
use Visualbuilder\FilamentTinyEditor\TinyEditor;
TinyEditor::make('description')
->columnSpanFull()
->required();
Where to Look First:
config/tinyeditor.php (published config for TinyMCE settings like toolbar buttons, plugins, etc.)resources/views/vendor/filament-tinyeditor/ (customizable blade templates for editor UI)Basic Form Integration:
// In a Filament Resource Form
TinyEditor::make('body')
->rules(['required', 'min:100'])
->columnSpan('full');
Dynamic Configuration:
Use the config() method to pass TinyMCE-specific settings:
TinyEditor::make('content')
->config([
'toolbar' => 'bold italic bullist numlist link',
'plugins' => 'link lists',
]);
File Attachments: Enable file uploads with:
TinyEditor::make('article')
->fileAttachmentsDisk('s3')
->fileAttachmentsVisibility('private')
->fileAttachmentsDirectory('articles/{year}');
Profiles (Predefined Configs):
Leverage built-in profiles (e.g., default, simple, mini):
TinyEditor::make('short_desc')->profile('mini');
Livewire Component Integration: Use the editor in custom Livewire components:
use Visualbuilder\FilamentTinyEditor\Widgets\TinyEditorWidget;
TinyEditorWidget::make('custom_editor')
->config(['height' => 300]);
Custom Toolbar: Override the default toolbar via config:
// config/tinyeditor.php
'toolbar' => 'undo redo | bold italic | alignleft aligncenter alignright',
Image Uploads:
Configure image handling in config/tinyeditor.php:
'images_upload_url' => '/filament-tinyeditor/upload-image',
'images_upload_handler' => \App\Actions\UploadImage::class,
Table of Contents (ToC): Enable ToC plugin:
TinyEditor::make('long_form')
->config(['plugins' => 'toc', 'toolbar' => 'toc']);
Custom CSS/JS:
Extend the editor’s assets via published public tag:
// resources/js/filament-tinyeditor-extensions.js
tinymce.PluginManager.add('custom_plugin', function(editor) {
editor.addButton('custom_btn', { ... });
});
Multi-Language Support: Pass language config:
TinyEditor::make('multilingual_content')
->config(['language' => 'es']);
Asset Publishing:
--tag=public) will break editor initialization.php artisan vendor:publish --tag=public after installation.File Uploads:
fileAttachmentsDisk is not set, uploads will fail silently.config/filesystems.php.TinyMCE Version Mismatch:
^5.0 with Filament 4.x will cause errors. Stick to version table compatibility.Livewire Conflicts:
mounted() hook in Livewire to initialize the editor.CORS Issues:
Console Errors:
Check browser console for tinymce errors (e.g., missing plugins or API keys).
Editor Not Loading:
tinymce script is loaded (check published public assets).php artisan cache:clear) if editor fails to initialize.Configuration Overrides:
config/tinyeditor.php overrides per-field settings.File Attachments:
fileAttachmentsVisibility('public') for debugging.Custom Plugins:
Extend TinyMCE via the config method:
TinyEditor::make('editor')
->config([
'plugins' => 'custom_plugin',
'setup' => 'function(editor) { editor.plugins.custom_plugin.init(); }',
]);
Event Listeners:
Listen to TinyMCE events (e.g., init, change) via JavaScript:
tinymce.init({
selector: '#filament-tinyeditor',
setup: function(editor) {
editor.on('change', function() { /* ... */ });
}
});
Blade Templates: Override editor templates by publishing views and modifying:
resources/views/vendor/filament-tinyeditor/editor.blade.phpresources/views/vendor/filament-tinyeditor/field.blade.phpAPI Key Management:
For TinyMCE Cloud, store the API key in .env:
TINYMCE_API_KEY=your_key_here
Then reference it in config/tinyeditor.php:
'api_key' => env('TINYMCE_API_KEY'),
Performance:
profile('mini') for lightweight editors.How can I help you explore Laravel packages today?