This code works fine, using version 3.0.3 of an external library:
HTML:
<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js"></script>
<button id="emoji-button">Click Me</button>
<input type="text" id="input" />
Javascript:
const button = document.querySelector('#emoji-button');
const picker = new EmojiButton();
picker.on('emoji', emoji => {
document.querySelector('#input').value += emoji;
});
button.addEventListener('click', () => {
picker.togglePicker(button);
});
The new version of the library (https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js) no longer works - as I get an error in the JS:
Uncaught SyntaxError: Unexpected token 'export'
This is a known issue, and the developer confirmed:
As of version 4, Emoji Button is exported as an ES module only
The person who raised the issue said:
I found a workaround by using the browser modules functionality:
<script type='module' src="/js/emoji.js"></script>
import { EmojiButton } from '/js/vendor/emojibutton.min.js'
Unfortunately I am not clear how to adjust the code that works for 3.0.3 to work for version 4+.
I tried changing this:
<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js"></script>
To this:
<script type="module" src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js"></script>
But from there - how do I edit my 3.0.3 code to include the import section mentioned in the workaround?