numaxlab / nova-ckeditor5-classic
A Laravel Nova CKEditor5 Classic Field.
Installs: 118 237
Dependents: 0
Suggesters: 0
Security: 0
Stars: 39
Watchers: 2
Forks: 41
Open Issues: 11
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-10-25 01:54:06 UTC
README
CKEditor5 Classic editor field for Laravel Nova. Use the last version of the popular WYSIWYG editor as a Laravel Nova field.
Installation
You can install the package into a Laravel application that uses Nova via composer:
composer require numaxlab/nova-ckeditor5-classic
After installing publish the config:
php artisan vendor:publish --tag=config --provider=NumaxLab\\NovaCKEditor5Classic\\FieldServiceProvider
Usage
Use the NumaxLab\NovaCKEditor5Classic\CKEditor5Classic
field in your Nova resource:
namespace App\Nova; use NumaxLab\NovaCKEditor5Classic\CKEditor5Classic; class Post extends Resource { // ... public function fields(Request $request) { return [ // ... CKEditor5Classic::make('Content'), // ... ]; } }
Customizing CKEditor
If you want to change the Editor's settings, you can do so by editing the config file
config/ckeditor5Classic.php
or by setting it directly in your filed, if you need different setup per field:
CKEditor5Classic::make('Content')->withFiles('public')
->options([...]);
You can visit the CKEditor configuration reference to check the available options.
Image uploads
This Nova field provides native attachments driver which works similar to Trix File Uploads.
To use this attachments driver, publish and run the migration:
php artisan vendor:publish --tag=migrations --provider=NumaxLab\\NovaCKEditor5Classic\\\FieldServiceProvider php artisan migrate
Then, allow users to upload images, just like with Trix field, chaining the withFiles
method onto the field's definition. When calling this method, you should pass the name of the filesystem disk that images should be stored on:
use NumaxLab\NovaCKEditor5Classic\CKEditor5Classic; CKEditor5Classic::make('Content')->withFiles('public');
And also, in your app/Console/Kernel.php
file, you should register a daily job to prune any stale attachments from the pending attachments table and storage:
use NumaxLab\NovaCKEditor5Classic\Jobs\PruneStaleAttachments; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function () { (new PruneStaleAttachments)(); })->daily(); }
Credits
License
The MIT License (MIT). Please see License File for more information.