adobe / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
33.25k stars 7.63k forks source link

Downloading a file inside an Extension #12902

Open photopea opened 7 years ago

photopea commented 7 years ago

Hi, I am developing a photo editor https://www.Photopea.com

I decided to make it a Brackets extension. You can find and install it by searching for "photopea" in an extension manager.

I have noticed, that files can not be saved (File - Save as PSD does nothing). My editor saves files through a "download" attribute of an anchor tag.

<a href="...." download>XY</a>

It executes a new MouseEvent on this tag. This works in all browsers, but it seems it does not work in Brackets. Are you going to support this in an Extension environment any time soon?

It also seems like you don't support a filter-invert of CSS styles (icons in Photopea should be gray, not black).

filter: invert(  0.2  );
ficristo commented 7 years ago

Keep in mind that ATM Brackets is build on top of Chrome 49 on Windows and macOS and Chrome 29 on Linux. So for the filter attribute you probabily need to add the -webkit prefix. For the MouseEvent we should know more. For example how did you create Save as PSD?

photopea commented 7 years ago

Chrome is updated like every month. Why do you use 1.5 years and 3 years old versions? Is it because you haven't released a new Brackets version for Linux since 2013?

I am saving files this way:

var data = new Uint8Array(arrayBuffer);
var a = document.createElement( "a" );
var blob = new Blob([data]);
var url = window.URL.createObjectURL( blob );
a.href = url;
a.download = "file.psd";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
ficristo commented 7 years ago

I tryed that snippet on Brackets console (Debug \ Show Developer Tools) replacing arrayBuffer with []. I see a <a> tag created and Brackets ask me to download the file. It seems to work to me. Maybe some other @adobe/brackets-committers can help more here.

Just FYI updating CEF (which is the Chrome based software used by Brackets) is a big task, usually done by Adobe. I don't know if there is any change to update it (or switch the shell). Brackets is divided in two parts: the shell code and the browser one. It is possible to release newer versions of the browser code without touching the shell. So Linux builds are updated every release.