PHPackages                             gregsphotography/tinymce-nova - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gregsphotography/tinymce-nova

ActiveLibrary

gregsphotography/tinymce-nova
=============================

A Laravel Nova field that integrates TinyMCE editor with your local TinyMCE installation.

v1.2.1(1mo ago)022MITPHPPHP ^8.3CI passing

Since Oct 9Pushed 1mo agoCompare

[ Source](https://github.com/Gregsphotography/tinymce-nova)[ Packagist](https://packagist.org/packages/gregsphotography/tinymce-nova)[ RSS](/packages/gregsphotography-tinymce-nova/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (13)Used By (0)

TinyMCE Field for Laravel Nova
==============================

[](#tinymce-field-for-laravel-nova)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4e1c86557283d635da2a2d492adebb9b75f4ac91082fef46d1c36268946932a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677265677370686f746f6772617068792f74696e796d63652d6e6f76612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gregsphotography/tinymce-nova)[![Total Downloads](https://camo.githubusercontent.com/e3daf3283b186c69003f4011c5f3b3073e7a1908783818e59cf5f06b88c3df2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677265677370686f746f6772617068792f74696e796d63652d6e6f76612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gregsphotography/tinymce-nova)[![Tests](https://github.com/gregsphotography/tinymce-nova/workflows/Tests/badge.svg)](https://github.com/gregsphotography/tinymce-nova/actions)[![License](https://camo.githubusercontent.com/8b86ce80e6796d38edc47a268aff52c1dc74af2bab7b38503586c8e980f4290b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f677265677370686f746f6772617068792f74696e796d63652d6e6f76612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gregsphotography/tinymce-nova)

A custom Laravel Nova field that integrates TinyMCE editor with your local TinyMCE installation.

Features
--------

[](#features)

- Uses local TinyMCE from `/public/tinymce/` directory
- Fully customizable toolbar and plugins
- Support for images, tables, code, and fullscreen editing
- No external CDN dependencies
- Dark mode compatible
- Paste handling with image support
- Laravel Package Tools integration
- Comprehensive test coverage

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require gregsphotography/tinymce-nova
```

### Publish Configuration

[](#publish-configuration)

After installation, publish the configuration file:

```
php artisan vendor:publish --provider="Greg\TinymceNova\TinymceNovaServiceProvider" --tag="config"
```

This will create `config/tinymce-nova.php` with all available configuration options.

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
# TinyMCE Source (local or cdn)
TINYMCE_SOURCE=local

# For Local Installation
TINYMCE_LOCAL_URL=/tinymce
TINYMCE_SCRIPT_PATH=/js/tinymce/tinymce.min.js
TINYMCE_LICENSE_KEY=gpl

# For CDN Installation
TINYMCE_CDN_URL=https://cdn.tiny.cloud/1
TINYMCE_API_KEY=your-api-key-here
TINYMCE_VERSION=7
```

### Configuration File

[](#configuration-file)

The published `config/tinymce-nova.php` file contains all available options:

```
return [
    'source' => env('TINYMCE_SOURCE', 'local'),

    'local' => [
        'base_url' => env('TINYMCE_LOCAL_URL', '/tinymce'),
        'script_path' => env('TINYMCE_SCRIPT_PATH', '/js/tinymce/tinymce.min.js'),
        'license_key' => env('TINYMCE_LICENSE_KEY', 'gpl'),
    ],

    'cdn' => [
        'base_url' => env('TINYMCE_CDN_URL', 'https://cdn.tiny.cloud/1'),
        'api_key' => env('TINYMCE_API_KEY', 'no-api-key'),
        'license_key' => env('TINYMCE_LICENSE_KEY', 'gpl'),
        'version' => env('TINYMCE_VERSION', '7'),
    ],

    'defaults' => [
        'height' => 400,
        'toolbar' => 'undo redo | blocks | bold italic...',
        'plugins' => 'lists link image code table',
        // ... more options
    ],
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Greg\TinymceNova\Tinymce;

Tinymce::make('Content')
    ->rules('required')
```

### With Configuration

[](#with-configuration)

```
Tinymce::make('Content')
    ->rules('required')
    ->alwaysShow()
    ->height(500)
    ->plugins(['lists', 'link', 'image', 'paste', 'code', 'table', 'fullscreen', 'wordcount'])
    ->toolbar('undo redo | blocks | bold italic | link image')
```

### Using CDN

[](#using-cdn)

```
Tinymce::make('Content')
    ->useCdn()
    ->apiKey('your-api-key')
    ->licenseKey('your-license-key')
```

### Using Local Installation

[](#using-local-installation)

```
Tinymce::make('Content')
    ->useLocal()
    ->baseUrl('/tinymce')
    ->scriptPath('/js/tinymce/tinymce.min.js')
    ->licenseKey('gpl') // or your commercial license
```

Available Methods
-----------------

[](#available-methods)

### `height(int $height)`

[](#heightint-height)

Set the editor height in pixels.

```
Tinymce::make('Content')->height(600)
```

### `toolbar(string $toolbar)`

[](#toolbarstring-toolbar)

Customize the toolbar buttons.

```
Tinymce::make('Content')->toolbar('undo redo | bold italic | link')
```

### `plugins(string|array $plugins)`

[](#pluginsstringarray-plugins)

Set the TinyMCE plugins to use.

```
Tinymce::make('Content')->plugins(['lists', 'link', 'image', 'code'])
```

### `menubar(bool $menubar)`

[](#menubarbool-menubar)

Show or hide the menubar.

```
Tinymce::make('Content')->menubar(false)
```

### `statusbar(bool $statusbar)`

[](#statusbarbool-statusbar)

Show or hide the status bar.

```
Tinymce::make('Content')->statusbar(false)
```

### `branding(bool $branding)`

[](#brandingbool-branding)

Show or hide TinyMCE branding.

```
Tinymce::make('Content')->branding(true)
```

### `resize(bool $resize)`

[](#resizebool-resize)

Enable or disable editor resizing.

```
Tinymce::make('Content')->resize(false)
```

### `options(array $options)`

[](#optionsarray-options)

Pass custom TinyMCE configuration options.

```
Tinymce::make('Content')->options([
    'content_css' => '/css/custom-editor.css',
    'body_class' => 'my-editor-class'
])
```

### `useLocal()`

[](#uselocal)

Force the field to use local TinyMCE installation.

```
Tinymce::make('Content')->useLocal()
```

### `useCdn()`

[](#usecdn)

Force the field to use TinyMCE from CDN.

```
Tinymce::make('Content')->useCdn()
```

### `licenseKey(string $licenseKey)`

[](#licensekeystring-licensekey)

Set the TinyMCE license key (GPL or commercial).

```
Tinymce::make('Content')->licenseKey('your-license-key')
```

### `apiKey(string $apiKey)`

[](#apikeystring-apikey)

Set the TinyMCE API key for CDN usage.

```
Tinymce::make('Content')->apiKey('your-api-key')
```

### `baseUrl(string $baseUrl)`

[](#baseurlstring-baseurl)

Set the base URL for TinyMCE (local or CDN).

```
Tinymce::make('Content')->baseUrl('/tinymce')
```

### `scriptPath(string $scriptPath)`

[](#scriptpathstring-scriptpath)

Set the script path for local TinyMCE installation.

```
Tinymce::make('Content')->scriptPath('/js/tinymce/tinymce.min.js')
```

### `version(string $version)`

[](#versionstring-version)

Set the TinyMCE version for CDN usage.

```
Tinymce::make('Content')->version('7')
```

Available Plugins
-----------------

[](#available-plugins)

- `lists` - Bulleted and numbered lists
- `link` - Insert/edit links
- `image` - Insert/edit images
- `paste` - Paste from Word with formatting
- `code` - Edit HTML source code
- `table` - Insert/edit tables
- `fullscreen` - Fullscreen editing mode
- `wordcount` - Word and character count

Default Configuration
---------------------

[](#default-configuration)

```
[
    'height' => 400,
    'toolbar' => 'undo redo | blocks | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | removeformat | code',
    'plugins' => 'lists link image code table',
    'menubar' => true,
    'statusbar' => true,
    'branding' => false,
    'resize' => true,
]
```

Example: Article Resource
-------------------------

[](#example-article-resource)

```
