Giter Site home page Giter Site logo

rubenestevao / nova-tinymce Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emilianotisato/nova-tinymce

0.0 1.0 0.0 1.37 MB

Laravel Nova TinyMCE editor (with images upload capabilities!)

Vue 10.57% JavaScript 39.59% CSS 0.06% PHP 15.81% HTML 33.98%

nova-tinymce's Introduction

Laravel Nova TinyMCE editor (with images upload capabilities!)

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 text without leaving the text editor!!

Installation

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 hr anchor pagebreak image wordcount fullscreen directionality paste textpattern'
                ],
                'toolbar' => 'undo redo | styleselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | image | bullist numlist outdent indent | link'
            ]),

Using the upload images feature

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

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

The last step is to run this command to fix some Filemanager files: php artisan nova-tinymcs:suport-lfm

IMPORTANT: if you are in laravel 6 you will need to import the helper lib cos Filemanager need them: composer require laravel/helpers.

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

// ...
    'use_lfm' => true,
    'lfm_url' => 'laravel-filemanager'
// ...

Extra configuration and 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');

nova-tinymce's People

Contributors

emilianotisato avatar rubenestevao avatar alberto-bottarini avatar mist-01 avatar yhbyun avatar rodrigore avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.