Open derks opened 2 years ago
Have you looked at this library? https://github.com/zenorocha/clipboard.js This is what codecopy uses "under the hood".
@Glennmen Yes, I am familiar with that... and that project helped get the built-in support for copy to clipboard. What I'm looking for is the "automatically for any code block" feature... which, funny enough, that library references this project for.
I guess I'm looking for best of both worlds, built into my apps that do not require the end-user to install anything (primarily for users who are unable to install anything due to restrictions noted in the op). I'm perfectly OK forking my own internal project to solve this, just feels like it makes sense that one of these two projects would support it as it is in the same wheel house and I think a valid use-case.
Really appreciate the feedback and consideration. Should I move this request to clipboard.js?
So you are looking for exactly this project but compiled into a library.
@Glennmen yes, that's correct. This request might fit better in clipboard.js, but since that project links to this project I landed here. Happy to move it to clipboard.js and/or provide any other details that might help.
Some additional context: Often the HTML is automatically generated (for example, from Markdown) so having a library that operates on any <pre>
or <code>
(like codecopy does) fits well since adding id's/classes might not be possible (easily) for many use cases even if plugging into an app I own.
I've been digging to find a JS library that will add this natively to a web app, rather than a user having to install an extension in their browser. It would be great if this project also supported that use-case, rather than creating/forking a new project.
Ideally, I would be able to just import this library locally, or from something like CDNJS and load it on any web app. Similar to how highlight.js works:
Context: In some use-cases, users are required to disable all browser extensions before proceeding with a task (ex: taking an exam/certification/etc using an online proctoring service).