Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

reaz's avatar
Level 5

Filament Richtext Editor

Hi, recently I have started to use filamentphp as a backend for a Blog. Now while creating the blog using the Rich text editor, if i enter a code block it is saving it with <pre></pre> tag not <pre><code></code></pre>, tag, . So i cannot use any of the JS syntax highlighter like prismjs. Does anyone knows a way to change the behaviour of Filamentphp rich text editor, or any other rich text editor which can be used with filamentphp , that supports this?

0 likes
2 replies
dhelbertlv's avatar

You can replace the pre with code in the mutateFormDataBeforeSave in your Resources/XXXResource/Pages/EditXXX.php

protected function mutateFormDataBeforeSave(array $data): array
{
    $data['content'] = str_replace(['<pre>', '</pre>'], ['<code>', '</code>'], $data['content']);

    return $data;
}
1 like

Please or to participate in this conversation.