xn/xn-ckeditor

Easy way to use ckeditor in laravel-admin

v2.0.4 2023-03-10 06:33 UTC

This package is auto-updated.

Last update: 2024-05-10 08:55:40 UTC


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' =>   '/admin/ckfinder/browser',
                  'filebrowserImageBrowseUrl' =>  '/admin/ckfinder/browser',
              ]
          ]
      ],

add admin/routes.php

Route::group([
    'prefix' => 'admin/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');
});

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