Skip to content
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

Support dragging files in browser #14756

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support dragging files in browser #14756

wants to merge 1 commit into from

Conversation

msujew
Copy link
Member

@msujew msujew commented Jan 22, 2025

What it does

Adds a feature that wasn't originally included in #12065. We currently support dragging files from the OS explorer to the main area of Theia, which results in opening the exact file (via its original URI) that was dropped into the application.

This won't work in browser based Theia apps for obvious reasons. Instead, this PRs adjusts the behavior for non-Electron apps. We now simply read the file name and text data of the dropped file into an untitled resource that we then attempt to open. Reusing untitled resources has a few benefits, mainly that it automatically handles disposal in case the editor is closed and also that it has special behavior when it comes to saving the file (it will automatically open the "Save As..." dialog).

How to test

  1. Open the browser example app
  2. Drag & drop a text (!) file into the main area. Dropping a non-text file (like an image) into the editor will usually result in unexpected behavior. However, it seems like vscode.dev also struggles with that, so it's at least as good as VS Code.
  3. The file should open, contain the expected file name and otherwise behave as any other untitled resource.

Follow-ups

We could potentially also support non-text files later on.

Review checklist

Reminder for reviewers

@msujew msujew added dnd issues related to drag & drop browser issues specific to the browser use-case labels Jan 22, 2025
@msujew msujew requested a review from tsmaeder January 22, 2025 16:35
@msujew msujew force-pushed the msujew/dnd-browser branch from 6e24f8d to f111561 Compare January 22, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser issues specific to the browser use-case dnd issues related to drag & drop
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

1 participant