divadretlaw / emojitext Goto Github PK
View Code? Open in Web Editor NEW๐ Render Custom Emoji in Text
License: Apache License 2.0
๐ Render Custom Emoji in Text
License: Apache License 2.0
This issue have been reported on Ice Cubes
If you want to have fun optimizing memory consumption. I haven't looked yet in detail, but the app is spiking around 700 MB of RAM instantly.
Presently, Xcode does not support version tags with a "v" prefix (cf. https://forums.swift.org/t/support-for-v-prefixed-version-tags-in-spm-swift-playgrounds-for-ipad/54845/5) and as a result, it's only possible to depend on EmojiText by branch or a commit which is not always optimal.
Would it be possible to tag releases as semantic version numbers from now on? e.g. "v2.0.0" -> "2.0.0"
Thank you!
I would like to format part of text that might contain emoji using markdown.
Current implementation doesn't allow me to do that as anywhere where there is an emoji formatting breaks. Is there a known workaround? What I want to achieve is <bold text with emoji> <regular text>
combined into correctly wrapping text.
Non working example:
func test_EmojiInMarkdown() async throws {
let view = EmojiText(markdown: "**Hello :mastodon:** _Mastodon :mastodon:_ :mastodon:", emojis: [Emojis.mastodon])
await assertSnapshot(matching: view, as: .rendered(size: CGSize(width: 300, height: 100), delay: 2))
}
Due to the way how SwiftUI View state works there is an issue in EmojiText where, when I modify text provided via initializer it will stay unchanged.
The problem appears when identity of EmojiText doesn't change but the user provides input that might change. The way how pre-rendering works is that it will store modified raw input in internal state. Unfortunately that internal state will survive even if users provide different values keeping previously displayed text unchanged.
A workaround is to explicitly change identity of EmojiText from call site, but it would be better if this library handled input changes automatically.
Below is example code that reproduces the issue. Tapping on "Switch" button doesn't change visible text unless I uncomment the line with id.
struct Preview: View {
@State private var text = "mastodon :mastodon:"
private let emojis: [any CustomEmoji] = [
RemoteEmoji(shortcode: "mastodon", url: URL(string: "https://files.mastodon.social/custom_emojis/images/000/003/675/original/089aaae26a2abcc1.png")!),
SFSymbolEmoji(shortcode: "iphone")
]
var body: some View {
VStack {
EmojiText(verbatim: text, emojis: emojis)
//.id(text) // Uncommenting this line fixes issue
Button("Switch") {
if text.starts(with: "m") {
text = "iphone :iphone:"
} else {
text = "mastodon :mastodon:"
}
}
}
}
}
I tried experimented with a way to resolve it internally by adding onChange(of: raw)
inside of EmojiText but that doesn't seem to work for initial change. I'm not sure why and don't have any other ideas currently so I'm submitting this as issue instead of pull request.
Similar issue might happen if provided emojis change but I didn't check that case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.