JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://editor.mestrelab.com/moleculeEditor/MolEditorExport/MolEditorExport.nocache.js"></script>
<div id="editor"></div>
<input type="button" onclick="show()" value="Show Image (Default Margin)"/>
<input type="button" onclick="getMoleculeFormula()" value="moleculeFormula"/>
<input type="button" onclick="getAverageMass()" value="averageMass"/>
<input type="button" onclick="getMonoisotopicMass()" value="monoisotopicMass"/>
<br/>
<img id="image"></img>
JavaScript
var a =null;
function jscOnLoad(){
a =new mestrelab.JsMoleculeEditor('editor',400,200,'true');
}
function show(){
if (a != null)
document.getElementById('image').src = a.exportImage(400,200);//width , height
else
alert("Variable null");
}
function getMoleculeFormula(){
if (a != null)
alert(a.getMoleculeFormula());
else
alert("Variable null");
}
function getAverageMass(){
if (a != null)
alert(a.getAverageMass());
else
alert("Variable null");
}
function getMonoisotopicMass(){
if (a != null)
alert(a.getMonoisotopicMass());
else
alert("Variable null");
}