Skip to content
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

Unable to pre-fill field with formatted mentions #43

Closed
robinwkurtz opened this issue Mar 24, 2021 · 7 comments
Closed

Unable to pre-fill field with formatted mentions #43

robinwkurtz opened this issue Mar 24, 2021 · 7 comments

Comments

@robinwkurtz
Copy link

robinwkurtz commented Mar 24, 2021

Hello, thanks for the library!

When using defaultText, the field does not show the formatted mention(s) as expected but the markup text. I've assured that my mention's data has the user previously mentioned.

I've tried with a custommarkupBuilder and the default one.

Here you can see the defaultText not formatted, but that if I add a new mention it works as expected:

Mar-24-2021.14-27-44.mp4

Thanks

@robinwkurtz robinwkurtz changed the title Unable to pre-fill field with mentions Unable to pre-fill field with formatted mentions Mar 24, 2021
@fayeed
Copy link
Owner

fayeed commented Mar 28, 2021

@robinwkurtz you don't need to pass the markup text to defaultText, you can just pass the normalized text. The reason is the package maintains markup text as an internal data to keep track of the mentions present in the textfield.

@fayeed fayeed closed this as completed Mar 28, 2021
@andrepo
Copy link

andrepo commented May 11, 2021

@fayeed I second @robinwkurtz 's point. What if I want to edit an existing text that already contains mentions? If I pass in the sanitized text to defaultText the previous mentions are lost. The AnnotationEditingController should support a setter for markuText

@fayeed
Copy link
Owner

fayeed commented May 12, 2021

@andrepo The markup text has nothing to do with how mentions are rendered it is there for the developer so that they can use it with some other package like flutter_parsed_text, internally when you type anything or the text property is updated we run a function that goes in the Mentions array and finds a match for the @____ keyword and renders the mentions, this also recreates the markupText every time.

Now, that you know how it works internally it's really simple to write a function that can take care of sanitizing the text. & give you a mentioned array. You could write a function that uses a regex to get the markup for mention then extract the id & the name and recreate a string only using the name. Also after you sanitize the string don't forget to pass in the mentions array with mentioned users.

I know this can be a little work on the developer side, but that's how it works right now.

@ashut08
Copy link

ashut08 commented Aug 11, 2022

@robinwkurtz @andrepo have you find any solution till now?

@amr1tv1rd1
Copy link

@robinwkurtz @andrepo have you find any solution till now?

Looking for the same.

@JosePabloGoni
Copy link

JosePabloGoni commented Dec 7, 2022

@ashut08 @amr1tv1rd1 I was able to find a quick solution to the problem, if you put the initial text with the mentions as "@__" and rebuild the screen, it takes all the mentions in the correct format "@ [id] (name)". I hope it works for you.

@amr1tv1rd1
Copy link

amr1tv1rd1 commented Jan 26, 2023

@ashut08 @amr1tv1rd1 I was able to find a quick solution to the problem, if you put the initial text with the mentions as "@__" and rebuild the screen, it takes all the mentions in the correct format "@ [id] (name)". I hope it works for you.

Can you explain it with a little code @JosePabloGoni ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants