softbery/laravel-wweditor
Zaawansowany edytor WYSIWYG dla Laravela (alternatywa dla CKEditor) z komponentem Blade, autozapisem, trybami WYSIWYG/HTML/CSS/podgląd, uploadem i storage, konfiguracją przez plik i .env oraz trasami i middleware.
Installation:
composer require softbery-org/laravel-wweditor
php artisan vendor:publish --tag=wweditor-assets
php artisan vendor:publish --tag=wweditor-config
Add the service provider to config/app.php:
Softbery\WwEditor\WwEditorServiceProvider::class
First Use Case: Embed a basic editor in a Blade view:
<x-wweditor::editor id="post-content" content="{{ old('content', $post->content ?? '') }}" />
config/wweditor.php for route prefix, middleware, and storage settings..env (e.g., WWEDITOR_AUTO_SAVE=true).<x-wweditor::editor
id="dynamic-editor"
:content="$model->description"
:css="$model->custom_css"
height="400px"
/>
<form method="POST" action="/posts">
@csrf
<x-wweditor::editor id="post-body" name="content" />
<button type="submit">Save</button>
</form>
public function edit(Post $post) {
return view('posts.edit', compact('post'));
}
public function update(Request $request, Post $post) {
$post->update([
'content' => $request->input('content'),
'css' => $request->input('css', '')
]);
}
const editor = new WwEditorLaravel('editor-id', {
saveUrl: '/wweditor/save',
loadUrl: '/wweditor/load/{{ $post->id }}',
autoSave: true
});
@foreach($posts as $post)
<x-wweditor::editor
id="editor-{{ $post->id }}"
content="{{ $post->content }}"
data-post-id="{{ $post->id }}"
/>
@endforeach
Asset Loading Issues:
php artisan optimize:clear after publishing assets.public_path() in config/wweditor.php points to the correct directory.Auto-Save Failures:
web middleware is included (or your custom middleware supports CSRF).Storage Permissions:
WWEDITOR_DISK in .env (e.g., public) and ensure the disk is writable:
php artisan storage:link
/wweditor/save and /wweditor/load endpoints for errors.storage/logs/laravel.log for storage/disk issues.editor.on('error', (e) => console.log(e)) to catch editor events.Custom Toolbar:
<x-wweditor::editor
:toolbar="['bold', 'italic', 'customButton']"
custom-button="{
text: 'My Button',
action: () => alert('Clicked!')
}"
/>
Override Default Routes:
Route::prefix('admin')->group(function () {
Route::post('content/save', [WwEditorController::class, 'save']);
});
Disable Modes:
<x-wweditor::editor :modes="['wysiwyg']" /> // Only WYSIWYG mode
<x-wweditor::editor :auto-save="false" />
editor.loadAssets().then(() => editor.init());
Str::of($content)->markdown() or a package like htmlpurifier for user-uploaded HTML.'middleware' => ['web', 'auth'],
How can I help you explore Laravel packages today?