marshmallow/nova-tinymce
Composer 安装命令:
composer require marshmallow/nova-tinymce
包简介
This Nova package allow you to use TinyMCE editor for text areas.You can customize the editor options and... you can upload images to your server and put them rigth there on the text without leaving the text editor!
README 文档
README
Laravel Nova TinyMCE editor
This Nova package allows you to use the TinyMCE editor for text areas. You can fully customize the editor options, define reusable styling, add custom buttons and variables, and optionally upload images straight into the editor.
Requirements
- PHP
^8.0 - Laravel Nova
^4.0or^5.0
Installation
Install the package via Composer:
composer require marshmallow/nova-tinymce
Publish the TinyMCE JavaScript, CSS, and skin assets to your public directory:
php artisan vendor:publish --provider="Marshmallow\Nova\TinyMCE\FieldServiceProvider" --tag="resources"
This publishes the assets to public/vendor/tinymce. Republish them after every package update so the editor assets stay in sync.
Publish the config file (optional)
Publish the config to override any of the default TinyMCE settings:
php artisan vendor:publish --provider="Marshmallow\Nova\TinyMCE\FieldServiceProvider" --tag="config"
Usage
Add the TinyMCE field to the fields array of your Nova resource. The field is hidden on the index view by default.
use Marshmallow\Nova\TinyMCE\TinyMCE; public function fields(Request $request) { return [ ID::make()->sortable(), TinyMCE::make(__('Content'), 'content'), ]; }
Set the height
The default height is defined in the nova-tinymce.php config file. Override it per field with the height() method:
TinyMCE::make('body')->height(300),
Add custom HTML (buttons)
Insert buttons or custom HTML with a single click using the buttons() method. The array key is the button label, the value is the HTML that gets inserted:
TinyMCE::make('body')->buttons([ 'Name button' => 'value of HTML', 'Name button2' => '<p>More HTML</p>', ]),
Add variables
Insert variables with a single click using the variables() method:
TinyMCE::make('body')->variables([ 'name_var' => 'value_var', ]),
Set the toolbar
Override the toolbar string for a single field with the toolbar() method:
TinyMCE::make('body')->toolbar('undo redo | bold italic | link'),
Set the plugins
Override the active TinyMCE plugins for a single field with the plugins() method:
TinyMCE::make('body')->plugins(['lists', 'link', 'image', 'table']),
Pass any TinyMCE option
Pass any option supported by the TinyMCE JavaScript SDK through the options() method. The given options are merged on top of the defaults:
TinyMCE::make('body')->options([ 'height' => '980', ]),
See the full list of options in the TinyMCE configuration docs.
Add styling options per field
Add one or more entries to the field's style format ("Content type") selector at runtime with addStyle() and addStyles():
TinyMCE::make('body')->addStyle([ 'title' => 'Lead Paragraph', 'block' => 'p', 'classes' => 'lead', ]), TinyMCE::make('body')->addStyles([ ['title' => 'Lead Paragraph', 'block' => 'p', 'classes' => 'lead'], ['title' => 'Muted', 'inline' => 'span', 'classes' => 'text-muted'], ]),
Add custom styling for all fields
To add styling options available on every TinyMCE field, publish the config and add entries to the custom_items array. These appear in the editor's "Content type" selector:
'custom_items' => [ // This adds a .lead class on the paragraph tag. [ 'title' => 'Lead Paragraph', 'block' => 'p', 'classes' => 'lead', ], ],
File manager support
The package ships a use_lfm config option to integrate with a Laravel file manager (set use_lfm to true and configure lfm_url). After installing your file manager, run the bundled command to drop in the package's file manager view override:
php artisan nova-tinymce:support-lfm
Configuration
The published config/nova-tinymce.php file exposes the defaults that are applied to every field. The most common keys:
| Key | Default | Description |
|---|---|---|
custom_items |
one Lead Paragraph entry |
Styling items shown in the "Content type" selector for every field. |
license_key |
'gpl' |
TinyMCE license key. Use 'gpl' for the self-hosted GPL build. |
cloud_api_key |
null |
TinyMCE Cloud API key, or null for self-hosted. |
height |
350 |
Default editor height in pixels. |
content_css |
oxide + custom.css |
Stylesheet(s) loaded inside the editor content area. |
skin_url |
oxide skin path | Path to the editor UI skin. |
content_css_dark |
oxide-dark content css | Content stylesheet used in dark mode. |
skin_url_dark |
oxide-dark skin path | UI skin used in dark mode. |
plugins |
array of TinyMCE plugins | Plugins enabled on every field. |
menubar |
'file edit view insert format tools table' |
The editor menu bar. |
toolbar |
toolbar string | The editor toolbar layout. |
relative_urls |
false |
Whether URLs are converted to relative paths. |
use_lfm |
false |
Enable Laravel file manager integration. |
lfm_url |
'filemanager' |
URL of the file manager. |
use_dark |
true |
Enable dark-mode skins. |
browser_spellcheck |
false |
Use the browser's native spell checker. |
link_class_list |
preset button classes | Class options offered when inserting a link. |
table_class_list |
Default |
Class options for tables. |
image_class_list |
Default |
Class options for images. |
color_map |
preset palette | The editor color picker palette. |
formats |
[] |
Custom TinyMCE formats definitions. |
extra_options |
[] |
Any additional raw TinyMCE options merged into every field. |
See config/nova-tinymce.php for the complete list of available keys.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security
If you discover any security related issues, please email stef@marshmallow.dev instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.
marshmallow/nova-tinymce 适用场景与选型建议
marshmallow/nova-tinymce 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 21.95k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「editor」 「nova」 「laravel」 「tiny」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 marshmallow/nova-tinymce 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marshmallow/nova-tinymce 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 marshmallow/nova-tinymce 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
Adds more BBCode
A Laravel Nova Image field. you can paste or drag or chose an image
统计信息
- 总下载量: 21.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 25
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-05
