awcodes/richer-editor
Enhance Filament’s Rich Editor with a suite of plugins and tools—embeds, emojis, fullscreen, links, source code, IDs, debugging, faker content, and Shiki code blocks. Designed to extend the editor experience in Filament 4/5.
composer require awcodes/richer-editor
resources/css/app.css or resources/css/filament/theme.css):
@import '../../../../vendor/awcodes/richer-editor/resources/css/index.css';
@source '../../../../vendor/awcodes/richer-editor/resources/views/**/*.blade.php';
use Awcodes\RicherEditor\Plugins\EmojiPlugin;
use Awcodes\RicherEditor\Plugins\LinkPlugin;
RichEditor::make('content')
->plugins([
EmojiPlugin::make(),
LinkPlugin::make(),
])
->toolbarButtons([
'bold', 'italic', 'link', 'emoji',
]);
Replace a basic RichEditor field with this package to add plugins like syntax highlighting, embeds, or emojis. Example:
RichEditor::make('article_content')
->plugins([
CodeBlockShikiPlugin::make()->defaultTheme('github-dark'),
EmbedPlugin::make(),
])
->toolbarButtons([
'bold', 'italic', 'codeBlock', 'embed',
]);
Select Plugins:
Choose plugins based on use case (e.g., CodeBlockShikiPlugin for developers, EmbedPlugin for media-rich content).
->plugins([
CodeBlockShikiPlugin::make()->languages(['php', 'js']),
FullScreenPlugin::make(),
])
Organize Toolbar: Group related tools (e.g., headings, developer tools) into dropdowns for cleaner UIs.
->tools([
ToolGroup::make('headings')
->items(['h1', 'h2', 'h3'])
->icon('heroicon-o-text-increase'),
])
->toolbarButtons(['headings', 'bold', 'italic']);
Customize Rendering: Extend rendering behavior (e.g., convert headings to links or markdown).
RichContentRenderer::make($content)
->linkHeadings(level: 2)
->toHtml();
Syntax Highlighting:
Use CodeBlockShikiPlugin for live code editing with themes. Sync themes between editor and server-side rendering:
// Editor
CodeBlockShikiPlugin::make()
->defaultTheme('tokyo-night')
->themes(light: 'github-light', dark: 'github-dark');
// Renderer
RichContentRenderer::make($content)
->plugins([
CodeBlockShikiPlugin::make()
->themes(light: 'github-light', dark: 'github-dark'),
]);
Faker for Testing:
Generate realistic test content with RichContentFaker:
$fakeContent = RichContentFaker::make()
->heading(level: 1)
->paragraphs(count: 3)
->codeBlock(language: 'php')
->asHtml();
Custom Blocks:
Add custom blocks (e.g., highlighted code) via blocks():
RichEditor::make('content')
->blocks([HighlightedCodeBlock::class]);
Theme Dependency:
CodeBlockShikiPlugin require index.css to be imported. Forgetting this breaks dark mode.Plugin Conflicts:
LinkPlugin requires IdPlugin (for anchor IDs). Omitting it causes errors.->plugins([
IdPlugin::make(),
LinkPlugin::make(),
]);
Experimental Plugins:
FigurePlugin and VideoPlugin are marked experimental. Use at your own risk.Server-Side Rendering:
PhikiCodeBlockPlugin for server-side syntax highlighting:
RichContentRenderer::make($content)
->plugins([PhikiCodeBlockPlugin::make()])
->phikiCodeBlocks();
Deprecated Tools:
HeadingFourTool, HeadingFiveTool, and HeadingSixTool are deprecated. Use Filament’s built-in heading tools instead.DebugPlugin::make(), // Only works locally
Custom Themes:
Extend CodeBlockShikiPlugin to support custom Shiki themes:
CodeBlockShikiPlugin::make()
->themes(light: 'my-custom-theme', dark: 'my-dark-theme');
RichContentFaker:
Extend RichContentFaker to add domain-specific content:
class CustomRichContentFaker extends RichContentFaker {
public function customBlock(): self {
$this->content .= '<custom-block data="example"></custom-block>';
return $this;
}
}
Toolbar Customization: Dynamically hide/show buttons based on user roles:
->toolbarButtons(fn (User $user) => $user->isAdmin ? ['debug'] : []),
github-dark) to reduce bundle size.CodeBlockShikiPlugin) only when needed via conditional toolbar buttons.How can I help you explore Laravel packages today?