Snippets

snippets

ArgumentTypeRequiredDefault

snippets

array

This method allows you to set snippet items within the CKEditor field, providing a convenient way to insert predefined content or code snippets into the editor.

By utilizing the snippets method, you can define an array of snippet items to be available in the CKEditor field. Each snippet item represents a specific HTML view (blade template) that should be located in the resources/views/ckeditor directory of your Laravel application.

use Mostafaznv\NovaCkEditor\CkEditor;

class Article extends Resource
{
    public function fields(Request $request): array
    {
        return [
            CkEditor::make(trans('Content'), 'content')
                ->snippets([
                    ['name' => 'Image', 'html' => 'ckeditor.image'],
                    ['name' => 'Media', 'html' => 'ckeditor.media'],
                    ['name' => 'Table', 'html' => 'ckeditor.table']
                ])
        ];
    }
}

Last updated