bbs-lab/nova-toast-ui-editor-field
Composer 安装命令:
composer require bbs-lab/nova-toast-ui-editor-field
包简介
A Laravel Nova field.
README 文档
README
A Toast UI Editor field for Laravel Nova.
Contents
Installation
You can install the package via composer:
composer require bbs-lab/nova-toast-ui-editor-field
The package will automatically register itself.
You can publish the config-file with:
php artisan vendor:publish --provider="BbsLab\NovaToastUiEditorField\FieldServiceProvider" --tag="config"
This is the contents of the published config file:
<?php declare(strict_types=1); use BbsLab\NovaToastUiEditorField\Enums\ToastUiEditType; use BbsLab\NovaToastUiEditorField\Enums\ToastUiPreviewStyle; return [ 'allowIframe' => (bool) env('TOAST_UI_EDITOR_ALLOW_IFRAME', false), 'height' => env('TOAST_UI_EDITOR_HEIGHT', 'auto'), 'hideModeSwitch' => (bool)env('TOAST_UI_EDITOR_HIDE_MODE_SWITCH', false), 'initialEditType' => env('TOAST_UI_EDITOR_INITIAL_EDIT_TYPE', ToastUiEditType::WYSIWYG->value), 'language' => env('TOAST_UI_EDITOR_LANGUAGE', 'en-US'), 'minHeight' => env('TOAST_UI_EDITOR_MIN_HEIGHT', '300px'), 'plugins' => ['chart', 'tableMergedCell', 'uml', 'colorSyntax', 'codeSyntaxHighlight'], 'previewStyle' => env('TOAST_UI_EDITOR_PREVIEW_STYLE', ToastUiPreviewStyle::TAB->value), 'toolbarItems' => [ [ 'heading', 'bold', 'italic', 'strike', ], [ 'hr', 'quote', ], [ 'ul', 'ol', 'task', 'indent', 'outdent', ], [ 'table', 'image', 'link', ], [ 'code', 'codeblock', ], ], 'usageStatistics' => (bool)env('TOAST_UI_EDITOR_USAGE_STATISTICS', false), 'useCloudinary' => (bool) env('TOAST_UI_EDITOR_USE_CLOUDINARY', false), 'cloudinary' => [ 'cloud_name' => env('CLOUDINARY_CLOUD_NAME', ''), 'api_key' => env('CLOUDINARY_API_KEY', ''), 'api_secret' => env('CLOUDINARY_API_SECRET', ''), 'username' => env('CLOUDINARY_USERNAME', ''), ], 'useCommandShortcut' => (bool)env('TOAST_UI_EDITOR_USE_COMMAND_SHORTCUT', true), ];
Usage
You can use the BBSLab\NovaToastUiEditorField\ToastUiEditor field in your Nova resource:
<?php namespace App\Nova; use BBSLab\NovaToastUiEditorField\ToastUiEditor; use Illuminate\Http\Request; class BlogPost extends Resource { // ... public function fields(Request $request) { return [ // ... ToastUiEditor::make('Content'), // ... ]; } }
Important
The field will store the markdown content in the database.
Advanced usage
Dependent Fields
You may use the dependsOn method to conditionally display the field based on the value of another field. See the example below:
<?php declare(strict_types=1); namespace Workbench\App\Nova; use BbsLab\NovaToastUiEditorField\Enums\ToastUiEditType; use BbsLab\NovaToastUiEditorField\Enums\ToastUiLanguage; use BbsLab\NovaToastUiEditorField\ToastUiEditor; use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\FormData; use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; class Post extends Resource { public static $model = \Workbench\App\Models\Post::class; public static $title = 'title'; public static $search = [ 'id', 'title', ]; public function fields(NovaRequest $request): array { return [ ID::make()->sortable(), Text::make('Title') ->sortable() ->rules('required', 'max:255'), Boolean::make('Has Content') ->sortable() ->rules('required'), ToastUiEditor::make('Content') ->rules('nullable') ->fullWidth() ->hide() ->dependsOn('has_content', function (ToastUiEditor $field, NovaRequest $request, FormData $formData) { if ($formData->has_content) { $field ->show() ->rules('required'); } else { $field->hide(); } }), ]; } }
Tip
More information about dependent fields can be found in the official documentation.
Toast UI Editor configuration
You may configure the underlying Toast UI Editor instance with the following field's methods. Checkout Toast UI - Vue Editor documentation.
Note
You may also configure defaults in config-file.
height(string $height)hideModeSwitch(bool $hideModeSwitch = true)initialEditType(ToastUiEditType $editType)language(ToastUiLanguage $language)minHeight(string $minHeight)plugins(array $plugins)previewStyle(ToastUiPreviewStyle $previewStyle)toolbarItems(array $toolbarItems)usageStatistics(bool $usageStatistics = true)useCommandShortcut(bool $useCommandShortcut = true)
Allow iframe in markdown/html
allowIframe(bool $allowIframe = true)
Use Cloudinary as image picker
useCloudinary(bool $useCloudinary = true)
Important
You must configure your Cloudinary credentials as described in nova-toast-ui-editor-field config file.
Changelog
Please see CHANGELOG for more information on recent changes.
Security
If you discover any security related issues, please email paris@big-boss-studio.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
bbs-lab/nova-toast-ui-editor-field 适用场景与选型建议
bbs-lab/nova-toast-ui-editor-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.16k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bbs-lab/nova-toast-ui-editor-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bbs-lab/nova-toast-ui-editor-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bbs-lab/nova-toast-ui-editor-field 相关的其它包
同方向 / 同关键字的高下载量 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
A Laravel Nova Image field. you can paste or drag or chose an image
A Laravel Nova Mail testing tool.
统计信息
- 总下载量: 2.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-07
