partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

download file function #238

Closed niuzhenjiang closed 3 years ago

niuzhenjiang commented 3 years ago

i want to add custom button: it can download .smi,.sdf,*.mol format file. i believe kekule have this functions. but i can't search this functions from doc. how can i do it can bind these download event.

partridgejiang commented 3 years ago

Hi @niuzhenjiang, this function is encapsulated in Kekule.NativeServices.saveFileData method (you can check it in html/kekule.nativeServices.js, line 174). The download code may be something like the following:

btn.onclick = function(e){
   Kekule.NativeServices.saveFileData(document, data, null, {'initialFileName': 'myData.smi'});
}
niuzhenjiang commented 3 years ago

thank you so much ,it worked~