Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Dragging images into a fresh editor

Open Keavon opened this issue 2 years ago • 8 comments

If a user drags an image into the welcome screen (shown when zero documents are open), it should create a new document with an artboard matching the dimensions of the image, and the image placed at 100% scale with the top left corner at the document's origin coordinates. Pasting an image from the clipboard should have the same effect.

Additionally, when the welcome screen is not shown, users should be able to drag an image into the tab bar (the dark horizontal bar occupied by the tabs, including the tabs themselves).

All this should also work for .graphite files.

Related: we'd like to support URLs (similar to https://editor.graphite.rs/#demo/red-dress) where we can open a bitmap or SVG as a new document. Care should be taken to ensure security for potentially malicious files that could be loaded and opened by the editor (someday stealing account info, for example, if the user is logged into Graphite?).

Keavon avatar Apr 17 '23 00:04 Keavon

Hi! I can work on this if it's not being worked on already

abumsoo avatar Jul 16 '24 04:07 abumsoo

Sure, go for it! Just please be careful about which places in the frontend that the drop handler should exist. When on the welcome screen (no docs open), it should be everywhere. When a document is open, it needs to exclude parts related to the currently open document (so at least the viewport) but still allow it being dropped in the tab bar and other editor areas. In the layer panel would probably be fine for now but eventually that should probably be inserted into the currently open document equivalent to dropping it in the viewport of the document (feel free to work on that change too if you'd like).

You can also reuse this functionality to open .graphite files dropped into the editor.

Keavon avatar Jul 16 '24 04:07 Keavon

Currently, trying to open an non-graphite image file by clicking on 'Open Document' gives an error. Do we want 'Open Document' for an image file to have the same behavior as what's described in this issue?

abumsoo avatar Jul 18 '24 20:07 abumsoo

Probably not because we'd like the file picker dialog to filter by .graphite files (which it also currently doesn't do), however File > Import should probably work from an empty editor.

Keavon avatar Jul 18 '24 20:07 Keavon

Understood. I think it does filter by .graphite files as I had to manually change the filter to "All Files". File > Import seems to be disabled on the welcome screen (if that's what you mean by empty editor).

abumsoo avatar Jul 18 '24 20:07 abumsoo

Yeah, you'd have to reenable File > Import on the welcome screen once that functionality is added.

Keavon avatar Jul 18 '24 20:07 Keavon

I would like to remove myself from this task as I wasn't able to make much progress and I will be busy for the next couple of weeks. I don't want to keep someone else from taking on this task. But maybe I'll pick it up again in a few weeks if it's still here.

abumsoo avatar Aug 07 '24 18:08 abumsoo

Sounds good @abumsoo, thanks for the update.

Keavon avatar Aug 08 '24 05:08 Keavon