ezar101 / easyadmin-trix-extension-bundle
An extension for EasyAdmin that enriches the TextEditorField (Trix) editor with advanced features: Tables, Colors, H2/H3 headings, Underlining, ...
Package info
github.com/Ezar101/EasyAdminTrixExtensionBundle
Language:JavaScript
Type:symfony-bundle
pkg:composer/ezar101/easyadmin-trix-extension-bundle
Requires
- php: >=8.2
- easycorp/easyadmin-bundle: ^4.0|^5.0
- symfony/framework-bundle: ^6.0|^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- symfony/phpunit-bridge: ^6.4.26|^7.0|^8.0
README
This Symfony bundle extends the native capabilities of EasyAdmin's TextEditorField (based on Trix). It offers an enhanced writing experience by adding essential features that are missing by default, all without any complex front-end configuration.
✨ Features
- Table Management : Complete modal interface for inserting, modifying, adding/deleting rows and columns.
- Semantic titles : Adding tags
<h2>and<h3>. - Text formatting : Button to underline the text (
<u>). - Color palette : Integrated color picker to change text color on the fly.
- Ready to use : Pre-compiled and automatically injected assets (CSS/JS).
📦 Installation
Use Composer to install the bundle:
composer require ezar101/easyadmin-trix-extension-bundle
Next, install the public assets of the bundle (if Symfony does not do so automatically):
php bin/console assets:install
🚀 Use
In your EasyAdmin CRUD controllers, simply replace the native TextEditorField with the ExtendedTextEditorField provided by this bundle.
<?php namespace App\Controller\Admin; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use Ezar101\EasyAdminTrixExtensionBundle\Field\ExtendedTextEditorField; // <-- Import of the new field class PostCrudController extends AbstractCrudController { public static function getEntityFqcn(): string { return Post::class; } public function configureFields(string $pageName): iterable { yield ExtendedTextEditorField::new('content') ->setNumOfRows(10) ->setColumns(12); // You can use all the usual TextEditorField methods } }
That's it! The bundle automatically injects the Trix configuration (blockAttributes, textAttributes) as well as the necessary CSS and JS files into the EasyAdmin interface.
🛠 Architecture & Assets
The assets (JavaScript and CSS) required for the operation of the new Trix options (including the complex table manager) are pre-compiled and distributed in the public/ folder of the bundle.
If you are using Webpack Encore, Vite, or Importmap in your main project, you do not need to perform any additional configuration. The ExtendedTextEditorField injects its own dependencies independently via Symfony's asset system.
🤝 Contribution
Pull requests are welcome.
If you wish to modify the JavaScript or CSS source code:
- Clone this repository.
- Edit the files in the
assets/folder. - Recompile the assets to update the
public/folder.
📄 Licence
This project is licensed under the MIT license.