-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention Feature #549
base: 3.x
Are you sure you want to change the base?
Mention Feature #549
Conversation
Mention extension
# Conflicts: # package-lock.json # resources/dist/filament-tiptap-editor.js
Thank you for the detailed PR. It's a lot and I'll review as best I can as soon as I can. |
I just saw your update on X and I wish you a speedy recovery first and foremost. If you have any questions once you're able to review this (it's a pretty big PR indeed) then ask away. 👍 |
…ed to categorize mentions
…rtsWith or Tokenized)
…ntent contains headings
Converting this to a draft for now since it looks like you are sill working on it. When you are feel free to change it back. |
@awcodes I was integrating user mentions in our project, so along the way I made some additional adjustments. It's all ready now! :) I notice the CI pipelines are failing since this commit, but I can't see why. Is there anything obvious I miss? 🤔 |
Can you merge in the latest updates from 3.x and resolve the conflicts please? |
# Conflicts: # resources/dist/filament-tiptap-editor.css # resources/dist/filament-tiptap-editor.js
@awcodes All done! |
Description
This PR integrates the mention extension. I wanted to implement this feature to support user mentions in my project, and noticed that others have expressed interest in a mention plugin as well. I have tried to make this feature as flexible as possible, since I realize it can be used in many ways. That's why you'll have full control over the mention suggestions and the data passed along.
Two types of mentions: static and dynamic
Ths implementation supports two approaches for providing mention suggestions:
->getMentionItemsUsing(function (string $query))
method to retrieve suggestions dynamically based on user input. This is perfect for when you want to fetch results from the database or from an API.For detailed instructions and examples, please refer to the updated README.
Documentation
Please read the documentation to learn more about the usage of this feature.
How to test
I invite you to check out the README.md to read the instructions before you start testing. I have also added some quick examples below to make it easier for you to test:
Test 1
Pass a hardcoded array. You may use MentionItem as a convenience , but that's not required:
Result
![test_0](https://private-user-images.githubusercontent.com/3017676/404945446-195f10d2-8512-4261-bd4a-3bd5dc2f6c40.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTY2ODMsIm5iZiI6MTczOTE1NjM4MywicGF0aCI6Ii8zMDE3Njc2LzQwNDk0NTQ0Ni0xOTVmMTBkMi04NTEyLTQyNjEtYmQ0YS0zYmQ1ZGMyZjZjNDAuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDI1OTQzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTRjMTQ4OWMwMWNiM2MwMTc1NzY2YjBmNWY0NDcxYTMwNjJiZWVkNjY5MDE1ZTMyZjQ1YzZhYzI0YzAxZTNlYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.h0Z2TDd_uHseFhaDhEdUB5CyID2z_LqnqtU5_iIZ8GA)
Test 2: Static User search with avatars
Let's add some images to our static mention items!
Result
![test1](https://github.com/user-attachments/assets/6e2e5d62-4c40-459c-b388-6702580411b8)
Test 3: Dynamic User search with API
Make sure you have a
User
model with a name that can be searched. In the code example, onlygetMentionItemsUsing
is required to make this work. However, I have added some additional customization methods so you can see how those work as well.Result
![test2](https://github.com/user-attachments/assets/83fc1b5f-c514-466a-bfe2-1a7cffb6ec2d)
Test 4: Add some custom data
You might want to pass some additional data, for example the type of the mentions. You can do this by passing a data array:
Output result
![afbeelding](https://private-user-images.githubusercontent.com/3017676/404946653-0efa5c79-8bce-4a30-a733-bb4fd264ac5c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTY2ODMsIm5iZiI6MTczOTE1NjM4MywicGF0aCI6Ii8zMDE3Njc2LzQwNDk0NjY1My0wZWZhNWM3OS04YmNlLTRhMzAtYTczMy1iYjRmZDI2NGFjNWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDI1OTQzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGI5NmM5OGZlNjUwYTI5NDczZWEyYzIyNWJmMzM3ZjZmYzI0YjlhMWIyYzY5NDVkZGRlMjk3ZmNhYmQzMTZjMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.bZJenzf6je1vLvg1POEf8m6oV5LTm895Ime6iz5FuXM)
Test 5: Attach a URL
You can attach a URL which will be used in the output. For example:
Output result (HTML)