composer require awcodes/richer-editor
resources/css/app.css):
@import '../../../../vendor/awcodes/richer-editor/resources/css/index.css';
@source '../../../../vendor/awcodes/richer-editor/resources/views/**/*.blade.php';
use Awcodes\RicherEditor\Plugins\EmbedPlugin;
use Awcodes\RicherEditor\Plugins\EmojiPlugin;
RichEditor::make('content')
->plugins([
EmbedPlugin::make(),
EmojiPlugin::make(),
])
->toolbarButtons(['embed', 'emoji'])
Add the EmbedPlugin to allow users to embed YouTube videos, tweets, or other media:
RichEditor::make('description')
->plugins([EmbedPlugin::make()])
->toolbarButtons(['embed'])
LinkPlugin for internal linking, SourceCodePlugin for code snippets).
RichEditor::make('content')
->plugins([
LinkPlugin::make(), // Requires IdPlugin
SourceCodePlugin::make(),
])
->toolbarButtons([
['bold', 'italic', 'underline'],
['h1', 'h2', 'h3'],
['embed', 'sourceCode'],
])
RichContentRenderer to transform content post-submission:
RichContentRenderer::make($content)
->linkHeadings(level: 3) // Auto-link H3 headings
->toHtml();
HighlightedCodeBlock for syntax-highlighted code with Phiki:
RichEditor::make('code_example')
->blocks([HighlightedCodeBlock::class])
->plugins([PhikiCodeBlockPlugin::make()]);
$toc = TableOfContents::make($content)->asHtml();
$fakeContent = RichContentFaker::make()
->heading(level: 2)
->paragraphs(count: 3)
->asHtml();
RichEditor field in Filament forms/resources.RichEditor logic.return response()->json([
'content' => RichContentRenderer::make($content)->toMarkdown(),
]);
LinkPlugin requires IdPlugin (adds IDs to headings for linking).CodeBlockLowlightPlugin, VideoPlugin) may need manual setup.@import paths in app.css match your project structure. Use npx tailwindcss to debug.phikiCodeBlocks() globally—it breaks Filament’s rich content attributes. Use only for rendering.document.querySelector('.rich-editor-toolbar').insertAdjacentHTML('beforeend', '<button data-tooltip="Emoji">😊</button>');
SourceCodePlugin fails, check for malformed HTML tags (e.g., unclosed <pre>). Use ->debug() in local environments.shift to ToolGroup dropdowns (fixed in v2.1.2+):
ToolGroup::make('tools')
->shift(true) // Ensures proper dropdown positioning
Theme::GithubLight) against Phiki’s docs.HighlightedCodeBlock for domain-specific syntax:
class CustomCodeBlock extends HighlightedCodeBlock {
public static function getTheme(): string { return Theme::Dracula; }
}
document.addEventListener('filament-rich-editor-initialized', (e) => {
e.detail.editor.addButton('custom', 'Custom Tool', () => {
// Logic here
});
});
RichContentFaker methods to generate domain-specific content:
RichContentFaker::make()
->customBlock(id: 'api-reference', config: ['endpoint' => '/users']);
PhikiCodeBlockPlugin) only when needed:
if (request()->has('render_as_code')) {
$renderer->plugins([PhikiCodeBlockPlugin::make()]);
}
$toc = Cache::remember("toc_{$content}", now()->addHours(1), fn() =>
TableOfContents::make($content)->asArray()
);
How can I help you explore Laravel packages today?