-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propose Clipboard Interaction specs #90
Conversation
@pavish and @ghislaineguerin I have assigned you to review these proposed UX specs for the Clipboard Interaction design as motivated by mathesar-foundation/mathesar#2377. I've assigned you two since you're designated helpers on the Usability Improvements project which contains this work. I also have a draft PR which begins to implement the "copy" functionality. @pavish and @Anish9901 I'll highlight that this design work seems to have some overlap with the UI for Importing data into existing tables GSoC project, which you are mentoring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seancolsen The spec looks good to me.
- It would be nice to add **context menu entries for copy/paste**, but there are some challenges here. | ||
|
||
- When copying: If we use the synchronous clipboard API it seems[^1] that we can't trigger copy events programmatically. Somehow Google Sheets is doing it, but I haven't dug deeper to figure out how. With the async clipboard API Firefox lacks support for MIME types other than `text/plain`. | ||
|
||
- When pasting: The synchronous clipboard API doesn't allow programmatic pasting at all. The async clipboard API doesn't work allow pasting in Firefox and requires a special permission in other browsers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the clipboard API support this?
https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText
We could use navigator.clipboard.writeText()
method to write to the clipboard, the only caveat being Firefox only supports this event from a user action, which will be the case for context menus.
For paste, we'd be reading from the clipboard using the navigator.clipboard.readText()
method, and performing "paste" manually i.e. updating the cells ourselves.
I remember doing this a long time ago and there were some challenges like the elements need to be in focus.
I'm adding this comment here, perhaps we could update the document with this as well, so that when we want to implement this, this comment can be a starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pavish Firefox supports writeText
but it doesn't support write
, and I want to use write
so that I can write clipboard data with custom MIME types. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. Perhaps for Firefox we can limit support to text/plain
and try working with that, and/or we could write items to localstorage as a way to improve copy/paste support within Mathesar.
Either way, I agree this isn't a high priority at the moment, and we can consider picking it up later.
@seancolsen The spec looks good. Regarding your design notes, I think having no contextual menu option is fine for now since content of our cells is very consistent with no styling, so we can do without paste options. I'm assuming that's what you meant by "How to Paste." Is that correct? What other paste options did you had in mind? One feature I find very helpful is the ability to paste a list of text with line breaks, creating new rows for each entry. I'm not sure if that's a consideration, but it's something we should explore in the future. |
|
I'm going to merge this now since it's seems like we have sufficient approval. We can continue to tweak smaller details as necessary. |
Rendered