setono / editorjs-bundle
Symfony bundle that integrates the editorjs-php library
Package info
github.com/Setono/editorjs-bundle
Type:symfony-bundle
pkg:composer/setono/editorjs-bundle
Fund package maintenance!
v1.4.0
2026-05-01 07:50 UTC
Requires
- php: >=8.2
- psr/log: ^1.1 || ^2.0 || ^3.0
- setono/editorjs-php: ^1.4
- symfony/config: ^6.4 || ^7.4 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.4 || ^8.0
- symfony/string: ^6.4 || ^7.4 || ^8.0
- symfony/twig-bundle: ^6.4 || ^7.4 || ^8.0
- twig/twig: ^3.5
Requires (Dev)
- ergebnis/composer-normalize: ^2.51
- infection/infection: ^0.29.14 || ^0.30.3 || ^0.31.9 || ^0.32.7
- jangregor/phpstan-prophecy: ^2.3
- matthiasnoback/symfony-dependency-injection-test: ^4.3 || ^5.1 || ^6.3
- phpspec/prophecy-phpunit: ^2.5
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.54
- phpstan/phpstan-phpunit: ^2.0.16
- phpstan/phpstan-strict-rules: ^2.0.10
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^10.5.63
- rector/rector: ^2.4.2
- shipmonk/composer-dependency-analyser: ^1.8.4
- sylius-labs/coding-standard: ^4.5
README
This bundle integrates the editorjs-php library into Symfony.
Instead of using the default block renderers in the library, this bundle creates a TwigBlockRenderer which renders all blocks as twig templates. This makes it very easy for you to override the rendered HTML for each block.
Install
composer require setono/editorjs-bundle
Usage
<?php use Setono\EditorJS\Parser\ParserInterface; use Setono\EditorJS\Renderer\RendererInterface; final class YourService { public function __construct( private readonly ParserInterface $parser, private readonly RendererInterface $renderer ) { } public function __invoke(string $json): string { return $this->renderer->render($this->parser->parse($json)); } }
Override rendered HTML
Each block has a corresponding Twig template inside the block directory.
The template for the ListBlock looks like this for example:
{# @var block \Setono\EditorJS\Block\ListBlock #} <{{ block.tag }}> {% for item in block.items %} <li>{{ item|raw }}</li> {% endfor %} </{{ block.tag }}>
Just as other Twig templates you can easily override these templates.