Giter Site home page Giter Site logo

emojitext's People

Contributors

dimillian avatar divadretlaw avatar kitwtnb avatar mironal avatar nekolaboratory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

emojitext's Issues

Stress test

This issue have been reported on Ice Cubes

Dimillian/IceCubesApp#1738

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.

Displaying emoji in middle of markdown formatted text

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))
}

test_EmojiInMarkdown 1

pre-rednered text doesn't changed if input changes

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.