forked from enviPath/enviPy
[Feature] Ketcher V3 (#427)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#427
This commit is contained in:
@ -28,11 +28,8 @@
|
||||
drawMode: false,
|
||||
smiles: '',
|
||||
loadExample(smilesStr, linkEl) {
|
||||
if (this.drawMode && window.indexKetcher && window.indexKetcher.setMolecule) {
|
||||
window.indexKetcher.setMolecule(smilesStr);
|
||||
} else {
|
||||
this.smiles = smilesStr;
|
||||
}
|
||||
this.smiles = smilesStr;
|
||||
console.log(this.smiles, this.drawMode)
|
||||
const original = linkEl.textContent;
|
||||
linkEl.textContent = 'loaded!';
|
||||
setTimeout(() => linkEl.textContent = original, 1000);
|
||||
@ -41,23 +38,26 @@
|
||||
const ketcher = getKetcherInstance('index-ketcher');
|
||||
if (ketcher && ketcher.getSmiles) {
|
||||
try {
|
||||
const s = ketcher.getSmiles();
|
||||
if (s && s.trim()) this.smiles = s;
|
||||
ketcher.getSmiles().then((smiles) => {
|
||||
if(smiles.trim()) {
|
||||
this.smiles = smiles.trim()
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to sync from Ketcher:', err);
|
||||
}
|
||||
}
|
||||
},
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
let finalSmiles = '';
|
||||
if (this.drawMode) {
|
||||
const ketcher = getKetcherInstance('index-ketcher');
|
||||
if (ketcher && ketcher.getSmiles) {
|
||||
try {
|
||||
finalSmiles = ketcher.getSmiles().trim();
|
||||
finalSmiles = await getSmilesFromKetcher('index-ketcher')
|
||||
} catch (err) {
|
||||
console.error('Failed to get SMILES from Ketcher:', err);
|
||||
alert('Unable to extract structure. Please try again or switch to SMILES input.');
|
||||
alert('BBUnable to extract structure. Please try again or switch to SMILES input.');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -198,13 +198,11 @@
|
||||
x-transition:leave-end="opacity-0 scale-95"
|
||||
class="w-full"
|
||||
>
|
||||
<iframe
|
||||
id="index-ketcher"
|
||||
src="{% static '/js/ketcher2/ketcher.html' %}"
|
||||
width="100%"
|
||||
height="400"
|
||||
class="rounded-lg"
|
||||
></iframe>
|
||||
<div class="mb-8 w-full">
|
||||
{% with iframe_id="index-ketcher" height="400" text_input_id="index-form-smiles" %}
|
||||
{% include "components/ketcher.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-lg bg-primary-950 text-primary-50 join-item mt-2 w-full"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user