marty12321's avatar

Filament RichEditor now showing content

Hi, when I try use richeditor with filament in livewire component it renders only with toolbar, there is no space to put content, in devconsole I don't see any errors. The code is a copy from filament doc https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component What Should I check or how can I trace error?

1 like
4 replies
LaryAI's avatar
Level 58

It sounds like you're experiencing an issue with the RichEditor component from the Filament admin panel within a Livewire component. Here are a few steps you can take to troubleshoot the issue:

  1. Ensure Filament Assets are Published: Make sure that you have published the Filament assets. If you haven't done this, you can publish them by running the following command:

    php artisan vendor:publish --tag=filament-assets --force
    

    After running this command, make sure to clear your browser cache and refresh the page to see if the RichEditor is displayed correctly.

  2. Check Livewire Component Setup: Verify that your Livewire component is set up correctly according to the Filament documentation. Your component should be using the Filament\Forms\HasForms trait and define a form schema. For example:

    use Filament\Forms\HasForms;
    use Filament\Forms\Components\RichEditor;
    
    class YourLivewireComponent extends Component
    {
        use HasForms;
    
        public $content;
    
        protected function getFormSchema(): array
        {
            return [
                RichEditor::make('content')
                    ->required(),
            ];
        }
    
        // ...
    }
    
  3. Check Blade Template: Ensure that your Blade template is correctly rendering the Livewire component. It should look something like this:

    <div>
        {{ $this->form }}
    </div>
    
  4. Check for JavaScript Errors: Even though you mentioned there are no errors in the dev console, double-check for any JavaScript errors that might be preventing the RichEditor from initializing properly. Sometimes, JavaScript errors can be subtle and not immediately obvious.

  5. Check CSS: There might be CSS conflicts that are causing the RichEditor to not display correctly. Check if there are any styles that could be hiding the content area or setting its height to zero.

  6. Clear Cache: Clear your application cache by running the following commands:

    php artisan cache:clear
    php artisan view:clear
    php artisan route:clear
    php artisan config:clear
    
  7. Update Filament and Livewire: Ensure that you are using the latest versions of Filament and Livewire. You can update them using Composer:

    composer update filament/filament livewire/livewire
    

If after following these steps the RichEditor is still not showing the content area, you may want to reach out to the Filament community or check the GitHub issues for similar problems. There might be a known issue or a recent update that addresses this problem.

ali-webdev's avatar

@LaryAI I am also facing somehow a similar issue regarding the rich editor features not showing properly, blockquote, code block, bullet lists, and numbered lists are not showing in the front-end post as they should be! In the browser's Elements section, I can see the tags blockquote, etc used in the HTML code but when I see them in the Blog post they are like plain simple text there are no blockquote, lists, etc... Only Bold, Italic, image embed, heading and links are working, I have also run this command but nothing happens, php artisan vendor:publish --tag=filament-assets --force

Now I have deployed my website to production, but the features are still not working....??

I even added all toolbar Buttons to the RichEditor body in the Post Resource File, But the output is not what I set in the blog post in the Admin Panel!!?

Here is my show.blade.php file code in resources/views/posts See if I have made any mistake in the below files, I am new to the development field, and guide me, please!

        <div
            class="article-actions-bar my-6 flex text-sm items-center justify-between border-t border-b border-gray-300 dark:border-slate-500 py-4 px-2">
            <div class="flex items-center">
                <livewire:like-button :key="'like-' . $post->id" :$post />
            </div>
            <div>
                <div class="flex items-center">
                    {{-- <button>
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 text-gray-500 hover:text-gray-800">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
                    </svg>
                </button> --}}
                </div>
            </div>
        </div>

        <div class="article-content py-3 text-gray-800 dark:text-slate-200 text-lg text-justify max-w-full">
            {!! $post->body !!}
        </div>

        <div class="flex items-center space-x-4 mt-10">
            @foreach ($post->categories as $category)
                <x-posts.category-badge :category="$category" />
            @endforeach
        </div>

        <livewire:post-comments :key="'comments' . $post->id" :$post />
    </article>
@else
    <div class="font-black text-center mt-32 mb-10 mx-auto h-screen">
        <p class="text-gray-600 dark:text-slate-400 tracking-widest mb-2 text-lg">Please login to view this post.</p>
        <a href="{{ route('login') }}" class="text-emerald-500 hover:underline tracking-widest text-xl">Login</a>
    </div>
@endauth

Post Resource File Code Here Below

jleontidis's avatar

Had the same issue and i resolved it by adding the Filament assets (CSS & JS) in my main blade file.

Inside the section of the HTML you should include @filamentStyles for the Filament CSS files to load and inside section of the HTML, preferably at the end, include @filamentScripts so the Filament JS files can be loaded correctly on the frontend within a livewire component.

Please or to participate in this conversation.