sphinx-copybutton icon indicating copy to clipboard operation
sphinx-copybutton copied to clipboard

Post message after all copy buttons added

Open ohrely opened this issue 3 years ago • 3 comments

Describe the problem/need and solution

Context We are logging copy events in documentation built with sphinx. We can clumsily capture these events by listening to all click events on a parent node, but we would prefer to add an event listener to each copybutton.

Problem / Idea Because copy buttons are injected into the page at a non-deterministic time, there is currently no way for us to know when sphinx-copybutton has finished adding all buttons to the document.

Solution Two potential solutions we've thought of:

  1. Trigger a custom event when all buttons are added
  2. Post a message to window when all buttons are added

Benefit This would simplify the task of monitoring copybutton click events for analytics and other purposes.

Guide for implementation

We think the event or message would be triggered at the end of this for loop.

Tasks and updates

No response

ohrely avatar Apr 14 '22 22:04 ohrely

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Apr 14 '22 22:04 welcome[bot]

(We is @fasiha and myself)

If this change would be welcome, we would be happy to take a stab at implementing.

ohrely avatar Apr 14 '22 22:04 ohrely

This seems reasonable to me as long as the implementation isn't too complicated to maintain👍

choldgraf avatar Apr 29 '22 14:04 choldgraf