PHP code example of nitsnets / filament-wysiwyg-json-formatter
1. Go to this page and download the library: Download nitsnets/filament-wysiwyg-json-formatter 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/ */
nitsnets / filament-wysiwyg-json-formatter example snippets
use Nitsnets\FilamentWysiwygJsonFormatter\Forms\Components\WysiwygJsonFormatter;
WysiwygJsonFormatter::make('content')
->label('Content')
->
WysiwygJsonFormatter::make('content')
->toolbarButtons([
'bold',
'italic',
'underline',
'strike',
'code',
'codeBlock',
'link',
'unorderedList',
'orderedList',
'checklist',
'divider',
'h1',
'h2',
'h3',
'blockquote',
'textColor',
])
use App\Models\User;
WysiwygJsonFormatter::make('content')
->mentions(
User::all()->map(fn (User $user) => [
'id' => (string) $user->id,
'label' => $user->name,
])->toArray()
)
use Nitsnets\FilamentWysiwygJsonFormatter\Forms\Components\WysiwygJsonFormatter;
use App\Models\User;
WysiwygJsonFormatter::make('comment_content')
->label('Comment')
->placeholder('Write a comment or press «@» to mention users')
->er::query()
->get()
->map(fn (User $user) => [
'id' => (string) $user->id,
'label' => $user->name ?? $user->email,
])
->toArray()
)
->columnSpanFull()
WysiwygJsonFormatter::make('content')
->
return [
'toolbar' => [
'bold' => 'Bold',
'italic' => 'Italic',
// ... more buttons
],
'mentions' => [
'title' => 'Mention users',
'no_users_found' => 'No users found',
'close' => 'Close',
],
'json_preview' => [
'title' => 'JSON Preview',
'close' => 'Close',
],
'prompts' => [
'enter_url' => 'Enter URL:',
],
];
bash
php artisan vendor:publish --tag=filament-wysiwyg-json-formatter-translations