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
Add support for dragging attachments from file browser and pasting #5913
Conversation
Hi all, this is mostly complete. It would be really helpful if this could be reviewed. Thank you! |
Is there a way to get the binder-bot to make a link here (or does anybody know how to do it manually)? |
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.
Looking at the binder, I see that there is an issue when dragging an image from the file browser: The default behavior of the image being dragged as a tab for viewing is not cancelled when dragging over a cell. It correctly drops the file as an attachment, but the blue box is then stuck on screen until you start a new widget drag operation.
See also specific code comment about trying to coordinate with https://github.com/agoose77/jupyterlab-attachments .
IIRC, this is because of this phosphor bug: phosphorjs/phosphor#300 |
@jasongrout Thank you so much, I couldn't figure this out ! This was the reason I added [WIP] to the PR. It seems like this isn't a trivial fix though? Should we use a UI similar to @agoose77's extension, until we fix the phosphor issue? This extension uses the context menu for lab's filebrowser, not the phosphor drag and drop. |
Well, I think the fix is as easy as merging that PR and releasing a phosphor patch update :), but apparently others may disagree? I agree it's not easy to fix outside of phosphor, though perhaps @sccolbert's idea of using multiple mimetypes mentioned in the issue may also be a way to do it. I don't think I tried that, though apparently I thought through it a bit in our conversation several years ago. |
@jasongrout Multiple mime types are being used here, so I am not sure if I've understood right. |
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.
Mostly looking OK, but minor fixes and tweaks. Also, there is still the outstanding issue in the OP about removing attachments when the references are dropped (probably on MD render and/or save/serialization?).
packages/cells/src/widget.ts
Outdated
if (protocol !== 'data:') { | ||
return; | ||
} | ||
const content = href.split(':')[1]; |
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.
I think you can use pathname
from URLExt.parse
instead :)
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.
This had an issue with firefox where pathname came out to be '', I'm not sure why
Also: When testing on Binder with Chrome, I couldn't get pasting of files from the system clipboard to work (pasting was greyed out in the system context menu, and Ctrl+V didn't do anything). Is this expected? |
@Madhu94 I'm wondering, does the 'drop non-referenced attachments' feature exist in classic notebook? If not, could this lead to UX confusion for users? |
@agoose77 Yes, it's been in from the start. See here: https://github.com/jupyter/notebook/blob/6a96754208aa054a91781eabff06cf89e1b1e37c/notebook/static/notebook/js/textcell.js#L220-L274 |
ad5faf6
to
d8d4525
Compare
@fperez mentions that this might be considered a 1.0 issue, in that it is a missing feature from the classic notebook. |
Counterpoint: this feature didn't exist in notebook when we made a 1.0 milestone. |
@Madhu94 - how close do you think this is to being finished? |
[Apologies for my long absence from Github] I took care of the first set of review comments, pending work is removing unreferenced attachments (on it now) and the phosphor issue mentioned in this comment (IMO, more of a usability issue than unreferenced attachments) Please add any other review comments, if needed |
Strange. Can you tell me how you tested ? I opened random images from Google images, clicked 'Copy Image' from the right-click context menu and then did Ctrl+V after focusing on the markdown cell in the notebook. |
@vidartf Just for my curiosity, could you please explain what issues you foresee? In case I have to upgrade stuff again, in the future |
files from filebrowser, native drag/drop or by pasting
@phosphor/widgets@1.9.0 has a bug fix - dockpanel overlay did not hide itself even if markdown cell handled the p-drop event.
Change from a custom attachments mimetype to mimetype of the contents model with the suffix ";closure=true"
Adds a rich contents mime type to allow extensions to more directly use the already fetched content models of the filebrowser. This is then used in the attachment cell widgets to synchronously insert the name (which will initially resolve to a broken image), and then start the async fetch. Also reefactors `updateCellSourceWithAttachment`.
fd1d764
to
cea5098
Compare
cea5098
to
b874b3a
Compare
Whoo ! Finally ! :) Thanks for your help @vidartf . |
Thanks for you efforts and your patience @Madhu94 :) |
Thanks for the incredible work and patience @Madhu94! |
Did this also sove #7085? |
Will fix #5744