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

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

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

nakipelo/orchid-ckeditor

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.

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

nakipelo/orchid-ckeditor 适用场景与选型建议

nakipelo/orchid-ckeditor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.06k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 08 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nakipelo/orchid-ckeditor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nakipelo/orchid-ckeditor 我们能提供哪些服务?
定制开发 / 二次开发

基于 nakipelo/orchid-ckeditor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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