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

Modifications to allow Emoji-Mart to use custom fallback images, and properly respect provided image and spritesheet URLs #874

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

antsstyle
Copy link

Hi all - I have been figuring out how to make Emoji-Mart work without adding any React to my project (I know Emoji-Mart compiles with preact, but nonetheless).

These changes have a few purposes:

  • EmojiProps originally did not have any knowledge of the image and spritesheet URLs, causing it to invariably fall back to the hardcoded JSDelivr URLs. I'm not sure if this is something to do with not using React; partly it is likely to do with web components not being able to have functions as attributes. Therefore I have changed the getImageURL and getSpritesheetURL functions to imageURL and spritesheetURL strings, respectively. The imageURL string does not require a specific emoji code; it expects a URL in the form with "emojiskin-unified" in the name, and then replaces this text with the unified code.

  • PickerProps and EmojiProps now have fallback properties, so that instead of using the hardcoded JSDelivr URLs, the user can either supply those or (as a default) use no fallback.

  • The EmojiElement class now removes the imageURL, spritesheetURL, and associated fallback attributes prior to rendering in connectedCallback(). I have found these attributes aren't needed in the final HTML, and bloat the elements considerably (an issue when e.g. saving them to a database, and just a bit unsightedly in the final HTML).

I've built and tested this for my project, with only the browser.js script needed for both the picker and emoji elements to function correctly.

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

Successfully merging this pull request may close these issues.

None yet

1 participant