partridgejiang / Kekule.js

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

How to save one Kekule document/reaction? #224

Closed weasteam closed 3 years ago

weasteam commented 3 years ago

Kekule can save each molecular but the lines are missing in a reaction when I reload the saved data.

However, I tested the Savefile function in the UI with the .kcj and kcx, I am able to display the exact reaction (include the lines).

May I know what function should I call to get a .kcj or kcx of a whole document/reaction?

partridgejiang commented 3 years ago

Hi @weasteam, the same I/O function can be used to save chem document to .kcj/.kcx. For example, to save the document inside a composer widget:

let obj = composer.getChemObj();
let kcxData = Kekule.IO.saveFormatData(obj, Kekule.IO.DataFormat.KEKULE_XML);  // save to .kcx
let kcjData = Kekule.IO.saveFormatData(obj, Kekule.IO.DataFormat.KEKULE_JSON);  // save to .kcj
weasteam commented 3 years ago

Thank you @partridgejiang

It worked.