Installation
Run composer require eductool/quill-editor-bundle and register the bundle in config/bundles.php if not using Symfony Flex.
Execute php bin/console assets:install --symlink --relative to ensure assets are symlinked.
First Use Case
Add the quill_editor field type to a form:
use Eductool\QuillEditorBundle\Form\Type\QuillEditorType;
$builder->add('content', QuillEditorType::class);
The editor will render automatically with default options (Snow theme, placeholder, etc.).
Where to Look First
config/packages/quill_editor.yaml for default configurations.public/build/quill-editor/ for asset paths.Basic Form Integration
Use the QuillEditorType in Symfony forms to replace standard textareas:
$builder->add('description', QuillEditorType::class, [
'label' => 'Rich Text Description',
'default_options' => [
'theme' => 'bubble',
'modules' => [
'toolbar' => [
['bold', 'italic', 'underline'],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
],
],
],
]);
Dynamic Initialization
Disable auto_initialize in config and initialize via JavaScript:
quill_editor:
default_options:
auto_initialize: false
document.addEventListener('DOMContentLoaded', () => {
const editor = new Quill('#quill-editor', {
theme: 'snow',
modules: { toolbar: [] }
});
});
Custom Themes/Modules Override CDN assets or bundle them manually:
quill_editor:
include_cdn: false
cdn:
stylesheets:
snow: '/path/to/custom/snow.css'
Data Handling Quill stores content in HTML format. Sanitize output before saving:
$content = $form->get('content')->getData();
$sanitized = filter_var($content, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
default_options in forms or config.assets:install to update assets after Quill.js version changes.$builder->add('content', QuillEditorType::class)
->addModelTransformer(new CallbackTransformer(
function ($html) { return strlen($html) <= 5000; },
function ($plain) { return $plain; }
));
$delta = json_decode($form->get('content')->getData(), true);
getContents() method in JavaScript tests to verify editor state.Asset Loading
assets:install after updates may break the editor.assets:install post-installation or use include_cdn: true (default).Content Sanitization
filter_var() or libraries like HTML Purifier.Module Conflicts
modules in config may break default toolbar functionality.modules:
toolbar:
- [bold, italic] # Extends, not replaces
Auto-Initialization
auto_initialize: false requires manual JS initialization.#quill-editor IDs match form field names.CDN Dependencies
include_cdn: true adds latency. Disable for offline use or custom hosting.include_cdn: false and host Quill assets manually.quill-editor class exists on the <div> and assets are loaded.console.log(editor.getContents()) to inspect raw content.height in default_options uses pixels (not rem/em).Custom Field Types
Extend QuillEditorType to add validation or transformers:
class CustomQuillType extends QuillEditorType {
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(['custom_option' => true]);
}
}
Event Listeners Hook into Quill’s events via JavaScript:
document.querySelector('.quill-editor').addEventListener('text-change', (delta) => {
console.log('Content changed:', delta);
});
Asset Bundling Override default assets by creating a custom bundle or using Webpack Encore:
// webpack.config.js
Encore
.addEntry('quill-custom', './assets/quill-custom.js')
.copyFiles({
from: './vendor/quill/dist/',
to: 'build/quill-custom/[name].[ext]'
});
Symfony Forms
Use quill_editor with form themes or custom templates:
{% block quill_editor_widget %}
{{ form_widget(form) }}
<script>
// Custom init logic
</script>
{% endblock %}
How can I help you explore Laravel packages today?