Closed spencertr closed 1 year ago
Hi @spencertr, thanks a lot for the reminding. I have made a version number mistake in the package.json which causes the failure of installation. Now the bug should be fixed, please try npm i kekule-react
again, :).
great, thanks @partridgejiang ! it's working now. another additional question, how do i get the smiles string from the composer? in your docs it states:
// Get all molecules inside editor
var mols = getComposer().exportObjs(Kekule.Molecule);
I tried this.composer.exportObjs(Kekule.Molecule)
however I got, this.composer.exportObjs is not a function
. Is there a different method to call?
this.composer
is just a React Component wrapper object, to access the real Kekule widget inside it, you'll need to call the getWidget
method of React wrapper:
let composerWidget = this.composer.getWidget();
let mols = getComposer().exportObjs(Kekule.Molecule);
let smiles = Kekule.IO.saveFormatData(mols[0], 'smi');
thanks for explanation. however, when i tried your code i got:
ERROR in [eslint]
src/components/ComposerViewer.js
Line 90:15: 'getComposer' is not defined no-undef
I don't see where composerWidget
is being used after you declare it on the first line. Thanks for responses!
Oops, a typo there, should be:
let composerWidget = this.composer.current.getWidget();
let mols = composerWidget.exportObjs(Kekule.Molecule);
let smiles = Kekule.IO.saveFormatData(mols[0], 'smi');
great, thanks, working now. I just added, this.composer.current.getWdiget()
and it works. Btw, I used your library for a personal project back in 2017. Now I am using your library for a work-related project. Thanks for all your hard work on this!
Glad to do some little help to your work as well, :).
Hi, thank you for maintaing this wonderful library and sharing this code. I did a
git clone
andnpm i
and when i started up the app I got:I tried to do
npm i kekule-react
but that does not exist. I don't know where you are importing this from? Please assist, thanks.