waynestate/nova-ckeditor4-field
Composer 安装命令:
composer require waynestate/nova-ckeditor4-field
包简介
This nova package allows you to use CKEditor 4 for text areas.
README 文档
README
⚠️ CKEditor4 End of Life ⚠️
The time has come where CKEditor4 has reached it's semi End of Life, which you can read more about at CKEditor 4: End of Life June 2023
Unforunately to use the CKEditor4 LTS (anything greater than v4.22.1), it requires that you have a Long Term Support.
This package isn't going anywhere soon, but if you are using CKEditor4 v4.22.1 or less, you may encounter a Security Warning due to the CKEditor checking a version file on the CKEditor side.
This disables the security warning option by default within the configuration since by default it points to v4.22.1 non-LTS CKEditor4.
If you do have the LTS package for CKEditor4, please renable your version check within your configuration, before updating this package to v1.4.0.
Overview
This nova package allows you to use CKEditor 4 for text areas using Nova v4.
Installation
Nova v1, v2, v3 compatibility instructions
Nova v4 compatibility instructions
You can install the package into a Laravel application that uses Nova via composer:
composer require waynestate/nova-ckeditor4-field
By default the CKEditor 4 instance used is the latest (4.22.1) Full All version (https://cdn.ckeditor.com/). If you wish to use a different CKEditor 4 you can do so by publishing and editing the configuration.
Usage
<?php namespace App\Nova; use Waynestate\Nova\CKEditor4Field\CKEditor; class Article extends Resource { // ... public function fields(Request $request) { return [ // ... CKEditor::make('Body', 'body'); // ... ]; } }
Overriding Config Values
To change any of config values, publish a config file:
php artisan vendor:publish --tag=nova-ckeditor4-field-config
Customization
Configuration options
You can change the configuration options of the CKEditor instance by either editing the published config file at nova.ckeditor-field.options
/* |-------------------------------------------------------------------------------- | CKEditor Options |-------------------------------------------------------------------------------- | | To view a list of all available options checkout the CKEditor API documentation | https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html | */ 'options' => [ 'toolbar' => [ ['Source','-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Image','Table','HorizontalRule','SpecialChar','PageBreak'], '/', ['Bold','Italic','Strike','-','Subscript','Superscript'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight'], ['Link','Unlink','Anchor'], '/', ['Format','FontSize'], ['Maximize', 'ShowBlocks','-','About'] ] ],
or you can pass it with the options method using:
public function fields(Request $request) { return [ // ... CKEditor::make('Body', 'body')->options([ 'height' => 300, 'toolbar' => [ ['Source','-','Cut','Copy','Paste'], ], ]), // ... ]; }
File Uploads
The nova-ckeditor4-field allows the use of file uploads by extending the attachment functionality of the Trix field
php artisan vendor:publish --tag=nova-ckeditor4-field-config # Make sure the config file is published php artisan migrate # Run the migrations
The package migrations will automatically run when running php artisan migrate.
If you are not going to use the Files and have no need for the migrations, you can disable migrations in config/nova/ckeditor-field.php, set the enable_migrations to false.
'migrations' => [ 'enable_migrations' => false, // ... ],
If you do not wish to use the Laravel Migration, but publish the migration yourself to your project.
Within the published /config/nova/ckeditor-field.php, set the auto_migrate to false.
'migrations' => [ 'enable_migrations' => true, 'auto_migrate' => false, ],
and then publish the migration to your project.
php artisan vendor:publish --tag=nova-ckeditor4-field-migrations
if you wish to not use the default Attachment and/or PendingAttachment models. You could replace with your own within the published /config/nova/ckeditor-field.php,
'attachment_model' => \Waynestate\Nova\CKEditor4Field\Models\Attachment::class, 'pending_attachment_model' => \Waynestate\Nova\CKEditor4Field\Models\PendingAttachment::class,
Using the File Uploads feature requires that the CKEditor uses the plugins Enhanced Image (image2) and UploadImage. If they are not included within your configuration, they will be added automatically.
Like the Trix field you'll be able to chain the method withFiles onto the field's definition, while passing the name of the filesystem disk where the images should be stored:
use Waynestate\Nova\CKEditor4Field\CKEditor; CKEditor::make('Body')->withFiles('public');
Also to prune any stale attachments from the storage and table, you'll want to register a job to run periodically:
use Waynestate\Nova\CKEditor4Field\Jobs\PruneStaleAttachments; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function () { (new PruneStaleAttachments)(); })->daily(); }
Limitations using File Uploads
Images are not removed from the filesystem when they are removed from the editor. For the time being you'll need to rectrify this on your own.
Custom CKEditor Instance
If you wish to not use the CKEditor from the CKEditor CDN, you can change the ckeditor_url under config/nova/ckeditor-field.php to point to the URL of the CKEditor you wish to use.
If you wish to go the route of a Custom CKEditor Instance using Composer then follow the steps at Using Composer for Custom CKEditor Instance
Nova v1, v2, or v3 compatibility
If you require the use of nova-ckeditor4-field using Nova v1, v2 or v3, you can install using version 0.7.0
composer require waynestate/nova-ckeditor4-field:"^0.7.0"
Nova v4 compatibility
If you require the use of nova-ckeditor4-field using Nova v4 you can install using version 1.4.0
composer require waynestate/nova-ckeditor4-field:"^1.4.0"
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email web@wayne.edu instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
waynestate/nova-ckeditor4-field 适用场景与选型建议
waynestate/nova-ckeditor4-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 768.7k 次下载、GitHub Stars 达 62, 最近一次更新时间为 2018 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「CKEditor」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 waynestate/nova-ckeditor4-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 waynestate/nova-ckeditor4-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 waynestate/nova-ckeditor4-field 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
This nova package allows you to use CKEditor 4 for text areas.
统计信息
- 总下载量: 768.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 63
- 点击次数: 26
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-23
