agence-adeliom / easy-editor-bundle
A Symfony bundle for EasyAdmin that provide a flexible content editor
Installs: 1 037
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 2
Type:symfony-bundle
Requires
- php: ^7.4|^8.0
- ext-json: *
- agence-adeliom/easy-common-bundle: ^1.0
- agence-adeliom/easy-fields-bundle: ^1.0.1
- easycorp/easyadmin-bundle: ^3.4 || ^v4.0.0
- symfony/config: ^4.4 || ^5.2
- symfony/dependency-injection: ^4.4 || ^5.2
- symfony/deprecation-contracts: ^2.2 || ^v3.0.0
- symfony/event-dispatcher: ^4.4 || ^5.2
- symfony/form: ^4.4 || ^5.2
- symfony/framework-bundle: ^4.4 || ^5.2
- symfony/http-kernel: ^4.4 || ^5.2
- symfony/options-resolver: ^4.4 || ^5.2
- symfony/property-access: ^4.4 || ^5.2
README
Easy Editor Bundle
Provide a flexible content editor for Easyadmin.
Features
- Ability to create custom blocks
- Twig extension to render the content
Installation
Install with composer
composer require agence-adeliom/easy-editor-bundle
Documentation
Usage
Entity
class Article { /** * @ORM\Column(type="json", nullable=true) */ private $content = []; }
CRUD Controller
class ArticleCrudController extends AbstractCrudController { // Add the custom form theme public function configureCrud(Crud $crud): Crud { return $crud ->addFormTheme('@EasyEditor/form/editor_widget.html.twig') ; } public function configureFields(string $pageName): iterable { yield EasyEditorField::new('content'); } }
Twig template
{% for block in object.content %} {{ easy_editor_block(block) }} {% endfor %}
Create a new type
bin/console make:block
Events
easy_editor.render_block
use Symfony\Contracts\EventDispatcher\Event; $dispatcher->addListener('easy_editor.render_block', function (Event $event) { // will be executed when the easy_editor.render_block event is dispatched // Get $block = $event->getArgument('block'); $settings = $event->getArgument('settings'); // Set $event->setArgument("block", $block); $event->setArgument("settings", $settings); });