I created a prototype npm package that displays a popup for selected text on a website.
npm
https://www.npmjs.com/package/@nakamura196/text-popup
Source code
https://github.com/nakamura196/text-popup
Demo page
https://nakamura196.github.io/text-popup/
The following article was used as a reference for development.
https://zenn.dev/nino_cast/articles/98a0a87f58026f
You can try it by adding the following two lines to your website.
<script src="https://cdn.jsdelivr.net/npm/@nakamura196/text-popup/dist/main.min.js"></script>
<script>textPopup();</script>
I hope this is helpful as a reference for developing and publishing npm libraries.