xn / xn-ckeditor
Easy way to use ckeditor in laravel-admin
v3.0.0
2024-11-07 14:21 UTC
Requires
- php: >=8.0.0
- ext-gd: *
- ext-json: *
- ext-zip: *
- laravel/framework: >=11.0
- league/flysystem: ^3.0
- league/flysystem-aws-s3-v3: ^3.0
- league/flysystem-azure-blob-storage: ^3.0
- league/flysystem-ftp: ^3.0
- pimple/pimple: ~3.0
- spatie/flysystem-dropbox: ^2.0
README
ckeditor for xn/laravel-admin
Installing
composer require xn/xn-ckeditor
php artisan vendor:publish --tag=xn-ckeditor --tag="ckfinder-config"
Configuration
In the extensions section of the config/admin.php file, add some configuration that belongs to this extension.
'extensions' => [
'ckeditor' => [
//Set to false if you want to disable this extension
'enable' => true,
// Editor configuration
'config' => [
'filebrowserBrowseUrl' => '/'.env('ADMIN_ROUTE_PREFIX', 'admin').'/ckfinder/browser',
'filebrowserImageBrowseUrl' => '/'.env('ADMIN_ROUTE_PREFIX', 'admin').'/ckfinder/browser',
]
]
],
add admin/routes.php
Route::group([
'prefix' => config('admin.route.prefix').'/ckfinder',
'middleware' => config('admin.route.middleware'),
], function () {
Route::any('connector', '\Xn\CKEditor\Controller\CKFinderController@requestAction')
->name('ckfinder_connector');
Route::any('browser', '\Xn\CKEditor\Controller\CKFinderController@browserAction')
->name('ckfinder_browser');
});
laravel 11
add bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->encryptCookies([
'ckCsrfToken',
]);
$middleware->validateCsrfTokens([
'admin/ckfinder/*', // admin:your admin path
]);
})
laravel 10
edit app/Http/Middleware/EncryptCookies.php
// app/Http/Middleware/EncryptCookies.php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
'ckCsrfToken',
// ...
];
}
edit app/Http/Middleware/VerifyCsrfToken.php
// app/Http/Middleware/VerifyCsrfToken.php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'admin/ckfinder/*',
// ...
];
}
Usage
$form->ckeditor('content', '內容');
$form->ckeditor('content')->options(['height' => 500,'contentsCss' => '/css/frontend.css']);
$form->ckuploader('image', __('cover'));
License
MIT