承接 murdercode/nova4-tinymce-editor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

murdercode/nova4-tinymce-editor

Composer 安装命令:

composer require murdercode/nova4-tinymce-editor

包简介

Boost your Laravel Nova with the TinyMCE editor.

README 文档

README

Logo Nova4 TinyMce

Latest Version on Packagist Code Style Analyze Maintainability Total Downloads License Mit

Introduction

Unleash creativity within Laravel Nova using the TinyMCE plugin, making content creation a breeze with its user-friendly and dynamic editing capabilities.

Features

  • 📷 Upload images support (BETA)
  • 🌙 Dark mode support
  • 🔀 Switch between 5 or 6 versions of TinyMCE
  • ❌ Can be disabled (by passing readonly() to make method)

Extra

Important

Want some steroids for your TinyMCE? Check out our new * ChatGTP for TinyMCE* plugin! 🚀🚀🚀

Demo & Screenshots

Demo Nova4 TinyMce

Versioning

This package follows the following versioning scheme:

  • v2.x - Nova 5 - TinyMCE 5 or 6
  • v1.x - Nova 4 - TinyMCE 5 or 6
  • v0.x - TinyMCE version 5 (deprecated)

Prerequisites

  • Laravel >= 9
  • PHP >= 8.0
  • Laravel Nova >= 4
  • TinyMCE API Key (get one here)

How to install

In the root of your Laravel installation launch:

composer require murdercode/nova4-tinymce-editor

Then publish the config:

php artisan vendor:publish --provider="Murdercode\TinymceEditor\FieldServiceProvider"

A file in config/nova_tinymce_editor.php will appear as follows (you can change the default values):

<?php

return [
    'cloudChannel' => '6', // 5 or 6

    /**
     * Get your API key at https://www.tiny.cloud and put it here or in your .env file
     */
    'apiKey' => env('TINYMCE_API_KEY', ''),

    /**
     * The default skin to use.
     */
    'skin' => 'oxide-dark',

    /**
     * The default options to send to the editor.
     * See https://www.tiny.cloud/docs/configure/ for all available options (check for 5 or 6 version).
     */
    'init' => [
        'menubar' => false,
        'autoresize_bottom_margin' => 40,
        'branding' => false,
        'image_caption' => true,
        'paste_as_text' => true,
        'autosave_interval' => '20s',
        'autosave_retention' => '30m',
        'browser_spellcheck' => true,
        'contextmenu' => false,
        //'images_upload_url' => '/nova-vendor/murdercode/tinymce/upload', // Uncomment to enable image upload
    ],
    'plugins' => [
        'advlist',
        'anchor',
        'autolink',
        'autosave',
        'fullscreen',
        'lists',
        'link',
        'image',
        'media',
        'table',
        'code',
        'wordcount',
        'autoresize',
    ],
    'toolbar' => [
        'undo redo restoredraft | h2 h3 h4 |
                 bold italic underline strikethrough blockquote removeformat |
                 align bullist numlist outdent indent | link anchor table | code fullscreen spoiler',
    ],

    /**
     * Extra configurations for the editor.
     */
    'extra' => [
        'upload_images' => [
            'enabled' => false, // Uncomment to enable
            'folder' => 'images',
            'maxSize' => 2048, // KB
            'disk' => 'public',
        ],
    ],
];

In your .env file please add the key (get one here):

TINYMCE_API_KEY=[YOUR_PRECIOUS_PRIVATE_KEY]

Please make sure that you have added domain in your tiny.cloud account list or you will get an error notice message.

Register the Field

In your Nova/Resource.php add the field as following:

<?php

use Murdercode\TinymceEditor\TinymceEditor;

class Article extends Resource
{
    //...
    public function fields(NovaRequest $request)
    {
        return [
            TinymceEditor::make(__('Content'), 'content')
                ->rules(['required', 'min:20'])
                ->fullWidth()
                ->help(__('The content of the article.')),
        ];
    }
}
                //...

Enable Image Upload

Demo Nova4 TinyMce

Warning

This feature is in BETA and can be unstable or contain bugs/security flaws. We provide it as is, without any warranty. For this reason, is disabled by default.

To enable image upload, you must publish the configuration file with:

php artisan vendor:publish --provider="Murdercode\TinymceEditor\FieldServiceProvider"

then in your config file config/nova-tinymce-editor.php:

<?php

// Uncomment the following line
'images_upload_url' => '/nova-vendor/murdercode/tinymce/upload',

// Set the following to true
    'extra' => [
        'upload_images' => [
            'enabled' => false, // Uncomment to enable
            'folder' => 'images',
            'maxSize' => 2048, // KB
            'disk' => 'public',
        ],
    ],

Please be sure that image plugin and toolbar button are enabled in your config file.

Protect code

You can to control what contents should be protected from editing while it gets passed into the editor. This is useful for example when you want to protect PHP code from been formatted.

To do this, you must publish the configuration file and add the following line:

<?php

return [
'init' => [
        // ... Your awesome init config ...
         /**
         * Set what content should be protected while editing
         * This should be a regular expression
         * E.g "/<\?php.*?\?>/g" - Protect PHP code from been formatted
         */
         'protect' => []
];
//...

Use Alternative CDN / Self Hosted scripts

TinyMCE allows you to use an alternative mirror for scripts. It will be useful if you want to use a non-cloud version (and avoid the new mechanism pricing of Tiny.cloud).

You can simply add in app/Providers/NovaServiceProvider.php:

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        parent::boot();

        // TinyMCE Mirror
        Nova::script('custom', 'https://cdn.jsdelivr.net/npm/tinymce@6/tinymce.min.js');

        // ...
    }
}

TinyMCE will automatic check if there's a script and I'll ignore his script from tiny cloud.

Upgrade from 1.0.x to 1.1.x

The transition to 1.1 involves the use of a new configuration layout compatible with the previous version.

However, if you want to use the new image upload and version change features, it is recommended that you make a new php artisan vendor:publish.

Upgrade from 0.x to 1.x

In composer.json change the version of the package to

"murdercode/nova4-tinymce-editor": "^1.0"

and run composer update.

Also, you must change the format of the plugin snippet in nova-tinymce-editor as follows:

0.x

'plugins' => [
            'anchor advlist autolink autoresize autosave code fullscreen link lists image imagetools media
            paste wordcount',
        ],

1.x

'plugins' => [
            'anchor',
            'advlist',
            // etc...
        ],

Upgrade from Nova 4 to Nova 5

To upgrade this package for use with Nova 5, update your composer.json to use version 2:

composer require murdercode/nova4-tinymce-editor:^2.0

The v2.x branch is fully compatible with Nova 5 while maintaining all the features from v1.x. No additional configuration changes are needed.

Feedback and Support

Test, PR (also of this doc) are welcome.

murdercode/nova4-tinymce-editor 适用场景与选型建议

murdercode/nova4-tinymce-editor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 188.39k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2022 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「tinymce」 「editor」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 murdercode/nova4-tinymce-editor 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 188.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 26
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 17
  • Watchers: 1
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-20