Fixed FileDialog.save to require FileSaver.js when using CommonJS

This commit is contained in:
Joshua Granick
2018-02-16 13:03:22 -08:00
parent 5c20d63a1f
commit fe4eb688a3

View File

@@ -274,7 +274,11 @@ class FileDialog {
var path = defaultPath != null ? Path.withoutDirectory (defaultPath) : "download" + defaultExtension; var path = defaultPath != null ? Path.withoutDirectory (defaultPath) : "download" + defaultExtension;
var buffer = (data:Bytes).getData (); var buffer = (data:Bytes).getData ();
#if commonjs
untyped __js__ ("require ('file-saverjs')") (new Blob ([ buffer ], { type: type }), path, true);
#else
untyped window.saveAs (new Blob ([ buffer ], { type: type }), path, true); untyped window.saveAs (new Blob ([ buffer ], { type: type }), path, true);
#end
onSave.dispatch (path); onSave.dispatch (path);
return true; return true;