gregsphotography/tinymce-nova
Composer 安装命令:
composer require gregsphotography/tinymce-nova
包简介
A Laravel Nova field that integrates TinyMCE editor with your local TinyMCE installation.
README 文档
README
A custom Laravel Nova field that integrates TinyMCE editor with your local TinyMCE installation.
Features
- Uses local TinyMCE from
/public/tinymce/directory - Fully customizable toolbar and plugins
- Support for images, tables, code, and fullscreen editing
- No external CDN dependencies
- Dark mode compatible
- Paste handling with image support
- Laravel Package Tools integration
- Comprehensive test coverage
Installation
You can install the package via Composer:
composer require gregsphotography/tinymce-nova
Publish Configuration
After installation, publish the configuration file:
php artisan vendor:publish --provider="Greg\TinymceNova\TinymceNovaServiceProvider" --tag="config"
This will create config/tinymce-nova.php with all available configuration options.
Configuration
Environment Variables
Add these to your .env file:
# TinyMCE Source (local or cdn) TINYMCE_SOURCE=local # For Local Installation TINYMCE_LOCAL_URL=/tinymce TINYMCE_SCRIPT_PATH=/js/tinymce/tinymce.min.js TINYMCE_LICENSE_KEY=gpl # For CDN Installation TINYMCE_CDN_URL=https://cdn.tiny.cloud/1 TINYMCE_API_KEY=your-api-key-here TINYMCE_VERSION=7
Configuration File
The published config/tinymce-nova.php file contains all available options:
return [ 'source' => env('TINYMCE_SOURCE', 'local'), 'local' => [ 'base_url' => env('TINYMCE_LOCAL_URL', '/tinymce'), 'script_path' => env('TINYMCE_SCRIPT_PATH', '/js/tinymce/tinymce.min.js'), 'license_key' => env('TINYMCE_LICENSE_KEY', 'gpl'), ], 'cdn' => [ 'base_url' => env('TINYMCE_CDN_URL', 'https://cdn.tiny.cloud/1'), 'api_key' => env('TINYMCE_API_KEY', 'no-api-key'), 'license_key' => env('TINYMCE_LICENSE_KEY', 'gpl'), 'version' => env('TINYMCE_VERSION', '7'), ], 'defaults' => [ 'height' => 400, 'toolbar' => 'undo redo | blocks | bold italic...', 'plugins' => 'lists link image code table', // ... more options ], ];
Usage
Basic Usage
use Greg\TinymceNova\Tinymce; Tinymce::make('Content') ->rules('required')
With Configuration
Tinymce::make('Content') ->rules('required') ->alwaysShow() ->height(500) ->plugins(['lists', 'link', 'image', 'paste', 'code', 'table', 'fullscreen', 'wordcount']) ->toolbar('undo redo | blocks | bold italic | link image')
Using CDN
Tinymce::make('Content') ->useCdn() ->apiKey('your-api-key') ->licenseKey('your-license-key')
Using Local Installation
Tinymce::make('Content') ->useLocal() ->baseUrl('/tinymce') ->scriptPath('/js/tinymce/tinymce.min.js') ->licenseKey('gpl') // or your commercial license
Available Methods
height(int $height)
Set the editor height in pixels.
Tinymce::make('Content')->height(600)
toolbar(string $toolbar)
Customize the toolbar buttons.
Tinymce::make('Content')->toolbar('undo redo | bold italic | link')
plugins(string|array $plugins)
Set the TinyMCE plugins to use.
Tinymce::make('Content')->plugins(['lists', 'link', 'image', 'code'])
menubar(bool $menubar)
Show or hide the menubar.
Tinymce::make('Content')->menubar(false)
statusbar(bool $statusbar)
Show or hide the status bar.
Tinymce::make('Content')->statusbar(false)
branding(bool $branding)
Show or hide TinyMCE branding.
Tinymce::make('Content')->branding(true)
resize(bool $resize)
Enable or disable editor resizing.
Tinymce::make('Content')->resize(false)
options(array $options)
Pass custom TinyMCE configuration options.
Tinymce::make('Content')->options([ 'content_css' => '/css/custom-editor.css', 'body_class' => 'my-editor-class' ])
useLocal()
Force the field to use local TinyMCE installation.
Tinymce::make('Content')->useLocal()
useCdn()
Force the field to use TinyMCE from CDN.
Tinymce::make('Content')->useCdn()
licenseKey(string $licenseKey)
Set the TinyMCE license key (GPL or commercial).
Tinymce::make('Content')->licenseKey('your-license-key')
apiKey(string $apiKey)
Set the TinyMCE API key for CDN usage.
Tinymce::make('Content')->apiKey('your-api-key')
baseUrl(string $baseUrl)
Set the base URL for TinyMCE (local or CDN).
Tinymce::make('Content')->baseUrl('/tinymce')
scriptPath(string $scriptPath)
Set the script path for local TinyMCE installation.
Tinymce::make('Content')->scriptPath('/js/tinymce/tinymce.min.js')
version(string $version)
Set the TinyMCE version for CDN usage.
Tinymce::make('Content')->version('7')
Available Plugins
lists- Bulleted and numbered listslink- Insert/edit linksimage- Insert/edit imagespaste- Paste from Word with formattingcode- Edit HTML source codetable- Insert/edit tablesfullscreen- Fullscreen editing modewordcount- Word and character count
Default Configuration
[
'height' => 400,
'toolbar' => 'undo redo | blocks | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | removeformat | code',
'plugins' => 'lists link image code table',
'menubar' => true,
'statusbar' => true,
'branding' => false,
'resize' => true,
]
Example: Article Resource
<?php declare(strict_types=1); namespace App\Nova; use Greg\TinymceNova\Tinymce; use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Slug; use Laravel\Nova\Fields\Textarea; use Laravel\Nova\Fields\Image; use Laravel\Nova\Http\Requests\NovaRequest; final class Article extends Resource { public function fields(NovaRequest $request) { return [ ID::make()->sortable(), Text::make('Title') ->sortable() ->rules('required', 'max:255'), Slug::make('Slug') ->from('Title') ->separator('-') ->rules('required', 'max:255') ->hideFromIndex(), Textarea::make('Excerpt') ->alwaysShow() ->rules('required', 'max:500'), Tinymce::make('Content') ->rules('required') ->alwaysShow() ->height(500) ->plugins(['lists', 'link', 'image', 'paste', 'code', 'table', 'fullscreen', 'wordcount']), Image::make('Image') ->disk('public') ->rules('required', 'image', 'mimes:jpeg,png,jpg,gif,webp', 'max:5120'), ]; } }
TinyMCE Installation
The field expects TinyMCE to be installed at:
/public/tinymce/js/tinymce/tinymce.min.js
Installing TinyMCE
- Download TinyMCE from tinymce.com
- Extract the files to your
public/tinymce/directory - Ensure the structure is:
public/tinymce/js/tinymce/tinymce.min.js
Development
Building Assets
If you make changes to the Vue components or JavaScript:
npm install npm run production
Testing
composer test
Code Style
The package follows PSR-12 coding standards and uses PHPStan for static analysis.
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 security@gbrown.ch instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Tools
This package uses Laravel Package Tools to provide a clean and consistent package development experience.
gregsphotography/tinymce-nova 适用场景与选型建议
gregsphotography/tinymce-nova 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wysiwyg」 「tinymce」 「editor」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gregsphotography/tinymce-nova 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gregsphotography/tinymce-nova 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gregsphotography/tinymce-nova 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Adds links to data objects in TinyMCE editor
TinyMCE Silverstripe 4 inspired theme
Adds more BBCode
WYSIWYG editor for Yii2 based on Bootstrap 3
UEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 UEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-03