Installation:
composer require caiquebispo/quill-editor
Publish the config (if needed):
php artisan vendor:publish --provider="CaiqueBispo\QuillEditor\QuillEditorServiceProvider"
First Use Case: Add the component to a Livewire blade view:
@livewire('post-editor')
In your Livewire component:
use CaiqueBispo\QuillEditor\Livewire\QuillEditor;
public function mount() {
$this->content = '<p>Default content</p>';
}
public function render() {
return view('livewire.post-editor', [
'config' => [
'modules' => [
'toolbar' => [
['bold', 'italic', 'underline'],
[{'header': [1, 2, 3]}],
['link']
]
]
]
]);
}
Where to Look First:
config/quill-editor.php for default settings (e.g., default toolbar, theme).resources/views/vendor/quill-editor.blade.php for customization hooks.Basic Rich Text Editing:
<x-quill-editor
wire:model="post.content"
:config="['modules' => ['toolbar' => [...]]]"
/>
wire:model) for seamless reactivity.Dynamic Configuration:
public function getConfig() {
return [
'theme' => 'snow',
'modules' => [
'toolbar' => $this->isAdmin ? $this->fullToolbar : $this->simplifiedToolbar,
'history' => true,
],
'placeholder' => 'Type here...',
];
}
Image Uploads:
public function uploadImage($file) {
$path = $file->store('uploads');
return asset("storage/{$path}");
}
imageUpload module with a Livewire handler for custom uploads.Responsive Design:
<x-quill-editor
:config="[
'height' => request()->wantsJson ? 'auto' : '300px',
'responsive' => true,
]"
/>
responsive config and media queries for mobile-friendly editing.Form Validation:
Use Laravel’s validation rules on the bound property (e.g., required|string).
protected $rules = ['content' => 'required|string'];
Sanitization:
Sanitize HTML before saving (e.g., with Purifier or Str::of($content)->markdown()).
Custom Modules: Extend Quill’s functionality by registering custom modules in the config:
'modules' => [
'customModule' => new class {
public function __invoke($quill) {
quill.register('modules/customModule', CustomModuleClass);
}
},
]
Livewire Events:
Trigger actions on Quill events (e.g., on-change, on-text-change):
<x-quill-editor
wire:model="content"
@change="dispatch('content-updated')"
/>
Duplicate Toolbars:
wire:key is unique:
<x-quill-editor wire:key="'editor-'.$id" />
CSS Conflicts:
theme config:
'theme' => 'bubble', // or 'snow'
Mobile Input:
responsive config and adjust height dynamically:
'height' => request()->isMobile() ? '200px' : '400px',
Large Content:
Console Errors: Check browser console for Quill/QuillEditor errors. Common causes:
wire:ignore.self (handled by the package, but verify in custom views).Livewire Logs: Enable Livewire logging to debug property updates:
Livewire::configureLogging();
Custom Toolbar Buttons: Extend the toolbar with custom buttons by registering Quill modules:
'modules' => [
'customButton' => new class {
public function __invoke($quill) {
quill.register('modules/customButton', CustomButtonModule);
}
},
],
Hooks: Use Livewire hooks to modify behavior:
protected $listeners = ['content-updated' => 'handleUpdate'];
public function handleUpdate() {
// Custom logic after content changes
}
Asset Management: Override default assets (e.g., Quill CSS/JS) by publishing the package’s assets:
php artisan vendor:publish --tag=quill-editor-assets
Localization:
Customize Quill’s UI text (e.g., toolbar labels) via the locale config:
'locale' => 'es', // Spanish
How can I help you explore Laravel packages today?