定制 emilianotisato/nova-tinymce 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

emilianotisato/nova-tinymce

Composer 安装命令:

composer require emilianotisato/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

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 right there on the content without leaving the text editor!! Editor

Installation

(backward compatibility)

Nova Package
V 1, 2, 3 V 1
V 4 V 2
composer require emilianotisato/nova-tinymce

Run the command bellow, to publish TinyMCE JavaScript and CSS assets.

php artisan vendor:publish --provider="Emilianotisato\NovaTinyMCE\FieldServiceProvider"

Usage

In your Nova resource add the use declaration and use the NovaTinyMCE field:

use Emilianotisato\NovaTinyMCE\NovaTinyMCE;

// ...

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            NovaTinyMCE::make('body'),
        ];
    }

By default, the editor comes with some basic options and the image management without the filemanager (inserted just as links).

You can use custome options like this:

NovaTinyMCE::make('body')->options([
                'plugins' => [
                    'lists','preview','anchor','pagebreak','image','wordcount','fullscreen','directionality'
                ],
                'toolbar' => 'undo redo | styles | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | image | bullist numlist outdent indent | link'
            ]),

Using the upload images feature with LFM

Now if you need to upload images from the text editor, we need to install UniSharp Laravel Filemanager, and pass the use_lfm => true option to your options array:

NovaTinyMCE::make('body')->options([
                'plugins' => [
                    'lists','preview','anchor','pagebreak','image','wordcount','fullscreen','directionality'
                ],
                'toolbar' => 'undo redo | styles | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | image | bullist numlist outdent indent | link',
                'use_lfm' => true
            ]),

ONLY if you use laravel-filemanager v1

If you use LFM v1 , the last step is to run this command to fix some Filemanager files:

php artisan nova-tinymce:support-lfm

Finally you will need to update the lfm_url key to match the old url version like this lfm_url' => 'laravel-filemanager.

IMPORTANT: if you are in laravel 6 using laravel-filemanager v1, you will need to import the helper lib coz legacy Filemanager need them: composer require laravel/helpers.

Optional Configuration

Laravel Filemanager URL

Optional, in case you change the laravel-filemanager URL in the package config file (config/lmf.php), you need to pass that info to this nova field with the lfm_url key in the options array.

// ...
    'use_lfm' => true,
    'lfm_url' => 'my-custom-filemanager-url'
// ...

Override config file

In case you have in mind a default options array to load any time you instantiate the NovaTinyMCE field, you can optionally publish the config file and override the default_options array:

php artisan vendor:publish --provider="Emilianotisato\NovaTinyMCE\FieldServiceProvider" --tag="config"

This is the contents of the published config file:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Options
    |--------------------------------------------------------------------------
    |
    | Here you can define the options that are passed to all NovaTinyMCE
    | fields by default.
    |
    */

    'default_options' => [
        'content_css' => '/vendor/tinymce/skins/ui/oxide/content.min.css',
        'skin_url' => '/vendor/tinymce/skins/ui/oxide',
        'path_absolute' => '/',
        'plugins' => [
            'lists','preview','anchor','pagebreak','image','wordcount','fullscreen','directionality'
        ],
        'toolbar' => 'undo redo | styles | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | image | bullist numlist outdent indent | link',
        'relative_urls' => false,
        'use_lfm' => false,
        'lfm_url' => 'filemanager'
    ],
];

Plugin customization

You can virtually pass any configuration option for the javascript SDK to the array in the options() method.

For example, you like to have increased the height of the text area:

            NovaTinyMCE::make('body')->options([
                'height' => '980'
                ]),

You can see the full list of parameters in the docs: https://www.tiny.cloud/docs/configure/

Using JSON syntax on attribute property

If you use JSON syntax on attribute name, TinyMCE won't initialize because the default id will be an invalid HTML id attribute. To solve this you can define a custom id. For example:

    NovaTinyMCE::make('Value', 'text->en')->id('custom-id');

emilianotisato/nova-tinymce 适用场景与选型建议

emilianotisato/nova-tinymce 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 942.48k 次下载、GitHub Stars 达 116, 最近一次更新时间为 2018 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 942.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 116
  • 点击次数: 29
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 116
  • Watchers: 5
  • Forks: 44
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-02