Modifications to allow Emoji-Mart to use custom fallback images, and properly respect provided image and spritesheet URLs #874
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.