Comment #⁨1⁩

Toby Toby Waterhole Founder May 27, 2024

Good question @riegel02!

default.js is bundled at runtime from a few separate JS files under vendor/waterhole/core/resources/dist - you might have more luck making changes in those files, but then they will still be overwritten whenever you update Waterhole, so this wouldn't be the recommended way to do it.

I don't think what ChatGPT has suggested will work, because the browser's request to cdn.jsdelivr.net will bypass your server completely.

In theory, the way to do this would be to add a custom script to monitor for <emoji-picker> elements and switch their data source to your own:

  1. Create a new file at resources/js/emojiPicker.js:
function updateEmojiPickerDataSource() {
  document.querySelectorAll('emoji-picker').forEach((el) => {
    // https://github.com/nolanlawson/emoji-picker-element?tab=readme-ov-file#javascript-api
    el.dataSource = "DATA_SOURCE_URL";
  });
}

// Update emoji-picker elements already on the page
updateEmojiPickerDataSource();

// Observer for new emoji-picker elements added to the page
const observer = new MutationObserver(updateEmojiPickerDataSource);
observer.observe(document.documentElement, {
  childList: true,
  subtree: true,
});
  1. Add it to your forum using the Script extender in app/Providers/WaterholeServiceProvider.php:
Extend\Script::add(resource_path('js/emojiPicker.js'));

However, unfortunately this is not actually working - I am still seeing requests to the cdn.jsdelivr.net domain when navigating between pages. I've run out of time to debug right now, but will keep thinking about how this can be achieved!

  1. In reply to Toby Toby

    Hey Toby!

    Just wanted to update that changing file in /core/resources/dist/emoji.js does the job! However it took me couple of minutes to understand why there was still jsdeliver in the background. But after quick debugging I found out that all of emojis are hosted on jsdeliver.

    So for example this 😂 laughing emoji https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/1f602.svg

    Either way this is not biggie and can be replaced in the admin. Wish we had an option to upload .svg files as images. Right now it is not possible, but I can just replace it with icons from Blade with different icon pack.

    Thanks a lot for the help! This is all I wanted and I got used to changing this kind of things manually 😀

  2. In reply to Toby Toby

    Okay, I was too happy that I found solution and didn't notice that I cannot turn off or replace emojis in the editor. Users can still pick up emojis and they all are coming from CDN instead of being hosted on the server. I will try to find a way to fix this, but let me know if you know a workaround :)

    #update

    Possible way around would be to selfhost data? emoji-picker-element? However I see no option for Laravel and don't really understand how to make it.