composer require backender/epiceditor-bundle
AppKernel.php:
new Backender\EpiceditorBundle\BackenderEpiceditorBundle(),
php bin/console assets:install web --symlink
$builder->add('description', 'epiceditor', [
'clientSideStorage' => true,
'parser' => 'marked'
]);
config/packages/backender_epiceditor.yaml (auto-generated after installation).Form\Type\EpiceditorType for customization options./web/bundles/backenderepiceditor/ exists post-asset install.Basic Form Integration:
// src/Form/PostType.php
$builder->add('content', 'epiceditor', [
'label' => 'Article Content',
'autoSave' => 60, // Auto-save every 60 seconds
]);
Dynamic Configuration via Twig:
{% form_theme form _self %}
{% block epiceditor_widget %}
{{ form_widget(form.content, {
'theme': {
'editor': '/bundles/yourtheme/editor.css'
}
}) }}
{% endblock %}
Entity Field Mapping:
# config/doctrine/Post.orm.yml
fields:
body:
type: text
column: content
options:
form_type: epiceditor
Custom Theming:
epiceditor.css in web/css/ and reference it in form options:
'theme' => ['editor' => '/css/epiceditor.css']
asset() helper in Twig for paths:
{{ asset('bundles/backenderepiceditor/js/epiceditor.min.js') }}
clientSideStorage for offline persistence.'parser' => 'marked' for Markdown or 'parser' => 'showdown' for alternatives.Asset Installation:
assets:install causes JS/CSS 404s. Run it after every composer update./web/bundles/backenderepiceditor/ exists.Configuration Overrides:
class from config.yml. This is a silent failure.EpiceditorType if you need to modify the underlying class.Parser Dependencies:
marked parser requires marked.js (not bundled by default). Include it manually:
{{ asset('vendor/marked/marked.min.js') }}
LocalStorage Conflicts:
localStorageName collisions can corrupt data if multiple editors use the same key.localStorageName: 'post_{{ post.id }}_editor').Uncaught ReferenceError: EpicEditor is not defined).htmlspecialchars_decode() if needed:
$content = htmlspecialchars_decode($form->get('content')->getData());
Custom Parsers:
EpiceditorType to add new parsers:
// src/Form/Type/CustomEpiceditorType.php
class CustomEpiceditorType extends EpiceditorType {
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(['parser' => 'custom']);
}
}
resources/public/js/epiceditor-extensions.js:
EpicEditor.registerParser('custom', function(markup) { ... });
Event Listeners:
$form->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$event->getForm()->add('content', 'epiceditor', [
'autoSave' => $event->getData()->getAutoSaveInterval()
]);
});
Twig Extensions:
// src/Twig/EpicEditorExtension.php
class EpicEditorExtension extends \Twig_Extension {
public function getFunctions() {
return [
new \Twig_SimpleFunction('epic_editor', [$this, 'renderEditor']),
];
}
public function renderEditor($options = []) {
return $this->render('BackenderEpiceditorBundle:Form:fields.html.twig', [
'type' => new EpiceditorType(),
'options' => $options,
]);
}
}
Usage in Twig:
{{ epic_editor({'theme': {'editor': '/custom.css'}}) }}
How can I help you explore Laravel packages today?