Here’s a version independent of tailwind. I made the button invisible by default, greyed out when codeblock hoveredgreyed out by default, and more prominent when button hovered (using palette colors), similarly to how it looks here on discourse.
Also @oeyoews the inner div (with position: absolute) can be skipped I guess and its properties/classes assigned to the button itself, the $button widget supports class attribute.
Good point. I simplified it a bit and made it visible all the time, more prominent when button hovered. This is actually less distracting and flickery.
Same idea, but with an indication of the language used by the codeblock when there is enough space, and the ability to add a title with the full notation (I wonder if this could be possible with the short wikitext syntax, like for block quote..)
I have quickly fixed it by making my button conditionally not displayed if the currentTiddler has code-body=yes, the newly introduced core button takes precedence. The widget code is now:
I would have liked it more to always show the custom button and never show the core button, but I don’t see a way of doing it without overriding the core view template or introducing a custom view template with the cascade.