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

Format mention to include html for UITextView #132

Open
bribar opened this issue Mar 9, 2020 · 3 comments
Open

Format mention to include html for UITextView #132

bribar opened this issue Mar 9, 2020 · 3 comments

Comments

@bribar
Copy link

bribar commented Mar 9, 2020

Hi @szweier,

Nice work on the library!

I was curious if it's possible to wrap a mention in a span tag when inserting the mention into the text view?

I tried modifying the didSelectRowAt, but the CreateMention protocol requires a String for name. Am I able to modify the protocol to allow NSAttributedString?

Thanks for any help!

@szweier
Copy link
Owner

szweier commented Mar 14, 2020

I'm not sure what exactly you're hoping to achieve but if you wanted to have specific attributes for a mention or for plain text you can use mentionTextAttributes and defaultTextAttributes. The attributes provided for those two parameters will be applied to the text. So you should be able to do things like underline, change color etc. If this doesn't cover what you're trying to achieve please describe what the end result you're hoping for is and I'll see if I can help you find a way to achieve it.

@bribar
Copy link
Author

bribar commented Mar 16, 2020

Hi @szweier

I'm aware of the attribute options, but I don't think I can wrap with tags? I'm looking for a way to send the message with the mention wrapped in an html tag like a span tag to the server-side script. Example below

Hi <span class="mention">@James Jones</span>, just following up on our last email.

I could regex search the message on the server-side and wrap it myself. But I prefer this to be applied client-side if possible.

@szweier
Copy link
Owner

szweier commented Mar 17, 2020

I see. Rather than do a regex search I think I’d use the mention range to apply any necessary tags around the mentions when sending it to the server. Is the span tag being used to draw mentions on a web UI? I’m wondering if maybe passing the ranges to the server would be enough to generate the proper setup as well.

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

2 participants