amidesfahani/filament-tinyeditor
composer require amidesfahani/filament-tinyeditor:^5.0 # For Filament 5.x
php artisan vendor:publish --provider="AmidEsfahani\FilamentTinyEditor\TinyeditorServiceProvider" --tag="config,views,public"
Create/Edit resource):
use AmidEsfahani\FilamentTinyEditor\TinyEditor;
TinyEditor::make('content')
->profile('default') // or 'simple', 'full', 'minimal'
->required();
Replace a Textarea or RichEditor field in a Filament form with a TinyMCE-powered editor for richer content editing (e.g., for blog posts, CMS pages, or documentation). Example:
// In a Filament Resource Form
public static function form(Form $form): Form
{
return $form
->schema([
TinyEditor::make('body')
->profile('full')
->columnSpan('full'),
]);
}
Profile-Based Configuration
Leverage predefined profiles (default, simple, full, minimal) to quickly configure toolbars and plugins. Extend with custom profiles via config/filament-tinyeditor.php:
'profiles' => [
'custom' => [
'plugins' => 'link image lists',
'toolbar' => 'bold italic | link image',
],
],
Use in code:
TinyEditor::make('content')->profile('custom');
File Attachments Enable image/media uploads with:
TinyEditor::make('content')
->fileAttachmentsDisk('public')
->fileAttachmentsDirectory('uploads')
->fileAttachmentsVisibility('public');
public) is configured in config/filesystems.php.RTL/LTR Direction
For multilingual apps, set direction globally in config/filament-tinyeditor.php or per-field:
TinyEditor::make('arabic_content')->direction('rtl');
Modal Integration The editor opens in a modal by default. Customize modal behavior via:
TinyEditor::make('content')
->resize('both') // 'vertical' or 'horizontal'
->columnSpan('full');
Dynamic Profiles Use closures to conditionally set profiles:
TinyEditor::make('content')
->profile(fn () => auth()->user()->isAdmin() ? 'full' : 'simple');
External Plugins
Add third-party TinyMCE plugins (e.g., paste_from_word):
TinyEditor::make('content')
->profile('default')
->customConfig([
'external_plugins' => [
'paste_from_word' => 'https://unpkg.com/@pangaeatech/tinymce-paste-from-word-plugin@latest/index.js',
],
]);
Custom Configs Override TinyMCE defaults (e.g., paste behavior, styles):
TinyEditor::make('content')
->customConfig([
'paste_webkit_styles' => 'color font-size',
'content_style' => 'body { font-family: Arial; }',
]);
Livewire Integration For custom Livewire components, manually initialize TinyMCE via JavaScript:
tinymce.init({
selector: '#my-custom-editor',
// ...config
});
Use the published resources/js/tinyeditor.js as a reference.
Asset Publishing
php artisan vendor:publish --tag="public" to publish JS/CSS assets.php artisan view:clear) if issues persist.File Uploads Not Working
fileAttachmentsDisk points to a valid storage disk.storage/logs/laravel.log for upload errors.storage/app/public/uploads).// In config/filament-tinyeditor.php
'upload_directory' => 'uploads',
Profile Not Applying
config/filament-tinyeditor.php for typos in profile names.->profile('custom') with a valid key from the config.Modal Overlap Conflicts
->resize('vertical') or adjust Filament’s modal stack order.PHP Version Mismatch
^4.0 for Filament 4.vendor/amidesfahani/filament-tinyeditor/dist/tinymce.min.js).tinymce.get('editor-id').settings in browser console to inspect runtime config.Custom Plugins
Extend TinyMCE by adding plugins to the external_plugins config array (see TinyMCE Plugin Docs).
Event Handling
Listen to TinyMCE events (e.g., init, change) via JavaScript:
tinymce.init({
selector: '#editor',
setup: (editor) => {
editor.on('change', () => {
console.log('Content changed!');
});
},
});
Theming
Override TinyMCE’s CSS by publishing the views tag and modifying resources/views/vendor/filament-tinyeditor/tiny-editor.blade.php.
API Keys
For commercial TinyMCE features, add your license key to config/filament-tinyeditor.php:
'license_key' => env('TINYMCE_LICENSE_KEY'),
->profile('minimal') for forms where rich editing isn’t critical.php artisan cache:clear
php artisan view:clear
How can I help you explore Laravel packages today?