rio-labs / rio

WebApps in pure Python. No JavaScript, HTML and CSS needed
https://rio.dev
Apache License 2.0
453 stars 14 forks source link

Add get_clipboard and set_clipboard to session. #34

Closed 16amattice closed 1 month ago

16amattice commented 1 month ago

What does it do?

This PR adds the ability to interact with the client's clipboard in the Rio framework. Specifically, it introduces two new methods:

Why is it needed?

Clipboard operations enhance user experience by allowing easy copying and pasting of text programmatically.

How to test it?

  1. Environment: Ensure you have the development environment set up with the Rio framework.
  2. Path to Verify:
    • Create buttons in your test app with on_press events.
    • Use self.session.set_clipboard and self.session.get_clipboard in these event handlers.
    • Click the buttons to test clipboard functionality.

Related issue(s)/PR(s)

None

Aran-Fey commented 1 month ago

Great work! Just one thing: According to MDN, navigator.clipboard is only available in certain situations. Could you add a ClipboardError that's raised when the browser doesn't support navigator.clipboard?