PHP code example of murdercode / nova4-tinymce-editor
1. Go to this page and download the library: Download murdercode/nova4-tinymce-editor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
murdercode / nova4-tinymce-editor example snippets
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',
],
],
];
use Murdercode\TinymceEditor\TinymceEditor;
class Article extends Resource
{
//...
public function fields(NovaRequest $request)
{
return [
TinymceEditor::make(__('Content'), 'content')
->rules(['
// 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',
],
],
return [
'init' => [
// ... Your awesome init config ...
/**
* Set what content should be protected while editing
* This should be a regular expression
* E.g "/<\?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');
// ...
}
}
'plugins' => [
'anchor advlist autolink autoresize autosave code fullscreen link lists image imagetools media
paste wordcount',
],