clementtalleu/easyadmin-markdown-bundle
A Markdown editor field for EasyAdmin, powered by the EasyMDE JavaScript editor.
It provides a MarkdownEditorField that behaves like EasyAdmin's built-in
TextEditorField (which uses Trix), but lets your users write Markdown with
a live preview, a toolbar and keyboard shortcuts. On the detail page the stored
Markdown is rendered as sanitized HTML.

| PHP | >= 8.2 |
| Symfony | 7.x and 8.x |
| EasyAdmin | 4.x and 5.x |
| Asset pipeline | AssetMapper (no build step required) |
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
composer require clementtalleu/easyadmin-markdown-bundle
If your application uses Symfony Flex, the bundle is enabled
automatically. Otherwise, enable it by hand in config/bundles.php:
// config/bundles.php
return [
// ...
ClementTalleu\EasyAdminMarkdownBundle\ClementTalleuEasyAdminMarkdownBundle::class => ['all' => true],
];
The bundle never ships third-party JavaScript itself, so you add EasyMDE to your application's importmap. Use the self-contained build (it bundles CodeMirror and marked), which works reliably with AssetMapper:
php bin/console importmap:require easymde/dist/easymde.min.js
php bin/console importmap:require easymde/dist/easymde.min.css
That's it — the field automatically loads its own JavaScript (as an ES module)
and stylesheet from the bundle, and the editor resolves EasyMDE from your
importmap. No importmap.php editing is required.
To render the Markdown as HTML on the detail page, install a Markdown parser:
composer require league/commonmark
If you skip this step, the detail page falls back to displaying the raw Markdown source as plain text.
Use the field in any EasyAdmin CRUD controller, exactly like the native fields:
use ClementTalleu\EasyAdminMarkdownBundle\Field\MarkdownEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
class ArticleCrudController extends AbstractCrudController
{
public function configureFields(string $pageName): iterable
{
yield MarkdownEditorField::new('content');
}
}
setNumOfRows()Sets the initial height (in rows) of the editor when its content is empty:
MarkdownEditorField::new('content')->setNumOfRows(20);
setEasyMdeConfig()Passes any EasyMDE configuration option to the editor. The array is JSON-encoded and forwarded to the EasyMDE constructor on the client side:
MarkdownEditorField::new('content')->setEasyMdeConfig([
'hideIcons' => ['guide', 'fullscreen'],
'tabSize' => 4,
'placeholder' => 'Write your story…',
]);
By default the bundle disables EasyMDE's built-in spell checker and status bar,
and does not download Font Awesome (EasyAdmin already provides icons). You can
re-enable any of these through setEasyMdeConfig().
renderAsHtml()Forces (or disables) HTML rendering on the detail page, regardless of whether
league/commonmark is installed:
MarkdownEditorField::new('content')->renderAsHtml(false); // always show raw Markdown
<textarea> whose configuration is exposed
through data-* attributes.<textarea> in sync so the form submits the
Markdown source and EasyAdmin's "unsaved changes" detection keeps working.The Markdown rendered on the detail page is converted with
league/commonmark configured with html_input: escape and
allow_unsafe_links: false. Any HTML embedded in the Markdown source is escaped
rather than executed.
composer install
vendor/bin/phpunit
vendor/bin/phpstan analyse
vendor/bin/php-cs-fixer fix --dry-run --diff
This bundle is released under the MIT license.
How can I help you explore Laravel packages today?