nakipelo/orchid-ckeditor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nakipelo/orchid-ckeditor

最新稳定版本:5.1.7

Composer 安装命令:

composer require nakipelo/orchid-ckeditor

包简介

CKEditor editor for Laravel Orchid

README 文档

README

Latest Version on Packagist Total Downloads License

CKEditor 4 integration with Laravel Orchid Platform for creating rich text editors in the admin panel.

Important: This package uses CKEditor 4.22.1, which is the last free version. All subsequent versions (4.23+) are LTS versions that require a commercial license purchase.

Features

  • ✅ Full integration with Laravel Orchid Platform
  • ✅ CKEditor 4.22.1 (last free version) with file upload support
  • ✅ Laravel File Manager integration
  • ✅ Stimulus controller for modern JavaScript
  • ✅ Customizable editor options
  • ✅ CSRF token support
  • ✅ Automatic asset publishing

Requirements

  • PHP ^8.1
  • Laravel Orchid ^14.0
  • Laravel File Manager (optional)

Installation

1. Install via Composer

composer require nakipelo/orchid-ckeditor

2. Publish Assets

php artisan vendor:publish --provider="Nakipelo\Orchid\CKEditor\CKEditorServiceProvider"

3. Publish Configuration (optional)

php artisan vendor:publish --tag=ckeditor-config

Usage

Basic Usage

use Nakipelo\Orchid\CKEditor\CKEditor;

// In your Screen class
public function fields(): array
{
    return [
        CKEditor::make('content')
            ->title('Content')
            ->required(),
    ];
}

Advanced Usage with Custom Options

use Nakipelo\Orchid\CKEditor\CKEditor;

public function fields(): array
{
    return [
        CKEditor::make('content')
            ->title('Content')
            ->setOptions([
                'toolbar' => [
                    ['Bold', 'Italic', 'Underline'],
                    ['NumberedList', 'BulletedList'],
                    ['Link', 'Unlink'],
                    ['Image', 'Table'],
                ],
                'height' => 300,
            ])
            ->mergeOptions([
                'filebrowserImageBrowseUrl' => '/filemanager?type=Images',
                'filebrowserImageUploadUrl' => '/filemanager/upload?type=Images&_token=' . csrf_token(),
            ]),
    ];
}

Configuration

After publishing the configuration, the config/ckeditor.php file will contain:

return [
    /**
     * URL for loading CKEditor
     */
    'editorUrl' => '//cdn.ckeditor.com/4.22.1/full/ckeditor.js',

    /**
     * Default editor options
     */
    'options' => [
        'filebrowserImageBrowseUrl' => '/filemanager?type=Images',
        'filebrowserImageUploadUrl' => '/filemanager/upload?type=Images&_token=',
        'filebrowserBrowseUrl' => '/filemanager?type=Files',
        'filebrowserUploadUrl' => '/filemanager/upload?type=Files&_token=',
    ]
];

File Manager Setup

For file management, it's recommended to use Laravel File Manager:

composer require unisharp/laravel-filemanager:^2.2

Then add routes to routes/web.php:

Route::group(['prefix' => 'filemanager', 'middleware' => ['web', 'auth']], function () {
    \UniSharp\LaravelFilemanager\Lfm::routes();
});

API

CKEditor Class

Methods

  • make(?string $name = null): static - Create a new instance
  • setOptions(array $options): CKEditor - Set editor options
  • mergeOptions(array $options): CKEditor - Merge with existing options

Options Examples

$editor = CKEditor::make('content')
    ->setOptions([
        'toolbar' => [
            ['Bold', 'Italic', 'Underline'],
            ['NumberedList', 'BulletedList'],
            ['Link', 'Unlink'],
            ['Image', 'Table'],
            ['Source'],
        ],
        'height' => 400,
        'width' => '100%',
        'language' => 'en',
        'uiColor' => '#f0f0f0',
        'removeDialogTabs' => 'image:advanced;link:advanced',
    ]);

JavaScript API

The package uses a Stimulus controller ckeditor with the following capabilities:

Data Attributes

  • data-controller="ckeditor" - Activate controller
  • data-ckeditor-id-value - Field ID
  • data-ckeditor-options-value - JSON editor options
  • data-ckeditor-editor-url-value - URL for loading CKEditor

Events

The controller automatically handles:

  • Editor content changes
  • CSRF tokens for file uploads
  • Source/visual mode switching
  • Fullscreen mode closing on navigation

Development

Install Dependencies

npm install

Build Assets

npm run dev
# or for production
npm run production

Project Structure

src/
├── CKEditor.php              # Main field class
└── CKEditorServiceProvider.php # Service Provider

resources/js/
├── ckeditor.js               # Stimulus entry point
└── ckeditor_controller.js    # Stimulus controller

views/
└── field.blade.php           # Blade field template

config/
└── config.php                # Default configuration

License

MIT License. See the LICENSE file for details.

Author

Egor Gruzdev

Support

If you have questions or suggestions, please create an Issue in the project repository.

Changelog

See CHANGELOG.md for a list of changes.

Note: This package uses CKEditor 4.22.1, which is the last free version. All subsequent versions (4.23+) are LTS versions that require a commercial license purchase. For CKEditor 5 usage, consider other solutions or create a fork with updated integration.

Русская Документация

统计信息

  • 总下载量: 9.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固