Downloads
Stars
Version
This package provides a custom field for Laravel Nova that integrates the SunEditor, a lightweight and flexible WYSIWYG editor.
To install the custom field, follow these steps:
Install the package via Composer:
composer require webard/nova-suneditor
Publish the assets:
php artisan vendor:publish --provider="Webard\NovaSunEditor\FieldServiceProvider"
To use the SunEditor field in your Laravel Nova resource, follow these steps:
Import the field in your Nova resource file:
use Webard\NovaSunEditor\SunEditor;
Add the field to the fields
method of your Nova resource:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
SunEditor::make('Content', 'content')
->rules('required', 'string')
->hideFromIndex(),
];
}
SunEditor supports uploading by drag&drop or pasting image directly into editor field. To enable upload, provide withFiles()
method, like in Trix
field:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
SunEditor::make('Content', 'content')
->withFiles('disk','path/to/attachments')
];
}
Unfortunately, upload does not work out of the box with fields in Nova Actions (Trix has same problem). If you need to upload files in Action modal, provide path to upload in settings and handle upload by yourself:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
SunEditor::make('Content', 'content')
->withFiles('disk','path/to/attachments')
->settings([
'imageUploadUrl' => '/your/path/to/handle/upload',
]),
];
}
The SunEditor field can be customized by some methods:
nova-suneditor.php
you can define more buttonLists and name them. Then, you can use buttonList using buttonListName
method.SunEditor::make('Content', 'content')
->buttonListName('my-buttons')
SunEditor::make('Content', 'content')
->buttonList([
[
'undo',
'redo',
'bold'
]
]);
SunEditor::make('Content', 'content')
->settings([
'minHeight' => '500px'
]);
I'm are actively seeking contributions to enhance this package. Here are some features I would love to see implemented:
Trix
fieldWe welcome contributions to improve this plugin! Please follow these steps to contribute:
This project is licensed under the MIT License. See the LICENSE.md file for more details.
For questions or support, please open an issue on GitHub.