You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/forms/docs/10-rich-editor.md
+62Lines changed: 62 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -617,6 +617,68 @@ RichEditor::make('content')
617
617
->activePanel('mergeTags')
618
618
```
619
619
620
+
## Using mentions
621
+
622
+
Mentions let users type a trigger character (like `@`) to search and insert inline references (e.g., users, tasks). Mentions are rendered inline as non-editable tokens (e.g. `@ Jane Doe`).
623
+
624
+
Configure mentions with providers using `mentions()`. Each provider handles a trigger `char` and either static items or async search:
625
+
626
+
```php
627
+
use Filament\Forms\Components\RichEditor;
628
+
use Filament\Forms\Components\RichEditor\MentionProviders\MentionProvider;
629
+
630
+
// Static items for multiple triggers
631
+
RichEditor::make('content')
632
+
->mentions([
633
+
MentionProvider::make('@')
634
+
->options([
635
+
['id' => 1, 'label' => 'Jane Doe'],
636
+
['id' => 2, 'label' => 'John Smith'],
637
+
]),
638
+
MentionProvider::make('#')
639
+
->options(['Laravel', 'Filament', 'Livewire']),
640
+
])
641
+
```
642
+
643
+
For large datasets, provide async results with `getSearchResultsUsing()`. The callback receives the search term and should return an array of items (strings, or objects with `id` and `label`).
644
+
645
+
```php
646
+
use Filament\Forms\Components\RichEditor;
647
+
use Filament\Forms\Components\RichEditor\MentionProviders\MentionProvider;
You may apply extra HTML attributes to the rendered mention element:
666
+
667
+
```php
668
+
MentionProvider::make('@')
669
+
->options([
670
+
['id' => 1, 'label' => 'Jane Doe'],
671
+
])
672
+
->extraAttributes([
673
+
'type' => 'user',
674
+
'class' => 'mention-user text-blue-600',
675
+
])
676
+
```
677
+
678
+
### Notes
679
+
680
+
- You can provide multiple providers, each with a different `char` (default `@`).
681
+
620
682
## Registering rich content attributes
621
683
622
684
There are elements of the rich editor configuration that apply to both the editor and the renderer. For example, if you are using [private images](#using-private-images-in-the-editor), [custom blocks](#using-custom-blocks), [merge tags](#using-merge-tags), or [plugins](#extending-the-rich-editor), you need to ensure that the same configuration is used in both places. To do this, Filament provides you with a way to register rich content attributes that can be used in both the editor and the renderer.
0 commit comments