PHP code example of haosheng0211 / filament-forms-tinymce
1. Go to this page and download the library: Download haosheng0211/filament-forms-tinymce 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/ */
haosheng0211 / filament-forms-tinymce example snippets
use MrJin\FilamentFormsTinymce\TinyMceEditor;
TinyMceEditor::make('content')
TinyMceEditor::make('content')
->profile('simple')
// config/filament-forms-tinymce.php
'profiles' => [
'blog' => [
'plugins' => 'lists link image media code',
'toolbar' => 'blocks | bold italic | link image media | code',
'menubar' => false,
'height' => 500,
],
],
// Profile sets height to 500, but this instance overrides it to 800
TinyMceEditor::make('content')
->profile('blog')
->height(800)
TinyMceEditor::make('content')
->toolbar('bold italic underline | bullist numlist | link image media')
->plugins('lists link image media table code')
->menubar('file edit view insert format')
->height(500)
->language('zh_TW')
->skin('oxide-dark')
->contentCss('dark')
TinyMceEditor::make('content')
->options([
'branding' => false,
'resize' => true,
'paste_as_text' => true,
])
'custom_configs' => [
// Protect Blade raw echo syntax from being rewritten by the editor
'protect' => [
'/\{!!\s*[\s\S]*?\s*!!\}/g',
],
],
TinyMceEditor::make('content')
->fileBrowser(false)
TinyMceEditor::make('content')
->mediaDisk('s3')
->mediaDirectory('uploads/articles')
// Option 1: Use a profile
TinyMceEditor::make('email_body')
->profile('email')
// Option 2: Override inline
TinyMceEditor::make('email_body')
->options(['remove_script_host' => false])
// config/filament-forms-tinymce.php
'profiles' => [
'email' => [
'plugins' => 'lists link image media table code wordcount',
'toolbar' => 'undo redo | blocks | bold italic | mergetags | link image | removeformat',
'menubar' => false,
'height' => 480,
'mergetags' => [
['value' => 'user.name', 'title' => '使用者名稱'],
['value' => 'user.email', 'title' => '使用者信箱'],
['title' => '網站', 'menu' => [
['value' => 'site.name', 'title' => '網站名稱'],
['value' => 'site.url', 'title' => '網站網址'],
]],
],
'mergetag_prefix' => '{{', // optional, defaults to '{{'
'mergetag_suffix' => '}}', // optional, defaults to '}}'
'custom_configs' => [
'relative_urls' => false,
'remove_script_host' => false,
],
],
],
TinyMceEditor::make('email_body')
->profile('email')
TinyMceEditor::make('email_body')
->toolbar('undo redo | blocks | bold italic | mergetags | removeformat')
->mergetags([
['value' => 'user.name', 'title' => 'User Name'],
])
->mergetagPrefix('${')
->mergetagSuffix('}')
// Inserts: ${user.name}
'cdn_url' => 'https://cdn.jsdelivr.net/npm/tinymce@{version}/tinymce.min.js',
'version' => '8.3.2',
return [
'cdn_url' => 'https://cdn.jsdelivr.net/npm/tinymce@{version}/tinymce.min.js',
'version' => '8.3.2',
// SRI hash for CDN (set to null to disable)
'integrity' => 'sha384-...',
'crossorigin' => 'anonymous',
// Profiles (pre-defined editor configurations)
'profiles' => [
'default' => [
'plugins' => 'lists link image media table code wordcount',
'toolbar' => 'undo redo | blocks | bold italic underline strikethrough | ...',
'menubar' => false,
'height' => 480,
'custom_configs' => [
'relative_urls' => false,
'remove_script_host' => true,
],
],
'simple' => [ /* ... */ ],
'full' => [ /* ... */ ],
// 'email' => [
// 'custom_configs' => [
// 'relative_urls' => false,
// 'remove_script_host' => false,
// ],
// ],
],
];
bash
php artisan vendor:publish --tag="filament-forms-tinymce-config"