EmojiText
EmojiText copied to clipboard
Allow URLs to be embedded in emoji (as markdown)
@divadretlaw Thanks for developing such a great library!
I have one request.
This library doesn't allow to embed URLs in emoji with Markdown notation. When I convert the following String, it looks like this image.
[hoge](https://sample.com)
[:test:](https://sample.com)
The ideal behavior would be for the URL to be embedded in the emoji.
Is there any way to implement this? I can't come up with any good ideas. π
Hello, sadly no this is definitely a current limitation.
The way EmojiText works is by using AttributedString(markdown:options:baseURL:) and splitting the runs of the AttributedString into Image and Text parts then merging them into a single Text via LocalizedStringKey.StringInterpolation & Text concatenation .
There are two main issues:
- The runs in
AttributedString(markdown:options:baseURL:)doesn't contain the image information of the emoji. Seems like Apple's Markdown Renderer forAttributedStringwill simply drop this information
:test: [:test:](https://sample.com)
becomes the following AttributedString
test {
NSImageURL = custom-emoji://test
}
{
}
test {
NSLink = https://sample.com
}
Here you can see that the 'emoji with a link' lost the NSImageURL as part of its attributes. I assume this is a limitation of AttributedString
- Even if I had the information, the link would possibly span multiple
Textelements that then get concatenated together. Not sure if you could merge the Link for all of them into one or if it simply would result in multiple links.
Also which version of EmojiText is this? With 3.3.0 the render should look different. At least when I try this
EmojiText(
markdown: "[hoge](https://sample.com)\n[:test:](https://sample.com)",
emojis: [
RemoteEmoji(
shortcode: "test",
url: URL(string: "https://dummyimage.com/64x64/00f/fff&text=A")!
)
]
)
it renders it like this
Thanks for the detailed explanation! I will update to the latest version :+1:
which version of EmojiText is this?
I was using 3.0.2 by the way. π€£ It's important to check the library for updates.γ