fast-reflexes / better-react-mathjax

MIT License
124 stars 16 forks source link

How to copy to clipboard #52

Closed atigm closed 7 months ago

atigm commented 7 months ago

Hi,

I'm using React/TypeScript. Can I use this repository to copy formatted text to the clipboard? I want to copy all text, not just the math expressions. Alternatively, can I use it directly with CopyToClipboard?

for example

mathjax

Thank you

fast-reflexes commented 7 months ago

This is advanced use of MathJax and not necessarily something I can help out with within the scope of this library :)

If I just mark some text with MathJax expressions and copy it, it works, but some of the expressions do not even have equivalents in regular text .. for example the limit or the square root, I don't know what ASCII character you would use for those... So some of the copied text will contain odd characters.

You could also store the unprocessed text in a variable and use regular Javascript event listeners and listen for CTRL-C and then use the Javascript Clipboard API (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard) to manually copy it to the clipboard. You can also preprocess the text in any way you would like to remove MathJax delimiters and such...

Good luck!

atigm commented 7 months ago

Alright, thank you.