diff --git a/packages/Chem/package.json b/packages/Chem/package.json index e15ee0b81c..905a13db1a 100644 --- a/packages/Chem/package.json +++ b/packages/Chem/package.json @@ -49,7 +49,7 @@ "@types/pako": "^2.0.3", "@webgpu/types": "^0.1.40", "cash-dom": "^8.1.5", - "datagrok-api": "^1.27.2", + "datagrok-api": "../../js-api", "dayjs": "^1.11.13", "file-loader": "^6.2.0", "js-yaml": "^4.1.1", diff --git a/packages/Chem/src/open-chem/ocl-sketcher.ts b/packages/Chem/src/open-chem/ocl-sketcher.ts index 1865732caa..d890bbbc72 100644 --- a/packages/Chem/src/open-chem/ocl-sketcher.ts +++ b/packages/Chem/src/open-chem/ocl-sketcher.ts @@ -60,48 +60,49 @@ export class OpenChemLibSketcher extends grok.chem.SketcherBase { } get smiles() { - if (this.explicitMol?.notation === 'smiles') + if (this.explicitMol?.notation === DG.chem.Notation.Smiles) return this.explicitMol.value; return this._sketcher ? this._sketcher.getSmiles() : ''; } set smiles(s) { - this.explicitMol = {notation: 'smiles', value: s}; + this.explicitMol = {notation: DG.chem.Notation.Smiles, value: s}; this.importing = true; this._sketcher?.setSmiles(s); } get molFile() { - if (this.explicitMol?.notation === 'molblock') + if (this.explicitMol?.notation === DG.chem.Notation.MolBlock) return this.explicitMol.value; return this._sketcher ? this._sketcher.getMolFile() : ''; } set molFile(s) { - this.explicitMol = {notation: 'molblock', value: s}; + this.explicitMol = {notation: DG.chem.Notation.MolBlock, value: s}; this.importing = true; this._sketcher?.setMolFile(s); } get molV3000() { - if (this.explicitMol?.notation === 'molblockV3000') + if (this.explicitMol?.notation === DG.chem.Notation.V3KMolBlock) return this.explicitMol.value; return this._sketcher ? this._sketcher.getMolFileV3() : ''; } set molV3000(s) { - this.explicitMol = {notation: 'molblockV3000', value: s}; + this.explicitMol = {notation: DG.chem.Notation.V3KMolBlock, value: s}; this.importing = true; this._sketcher?.setMolFile(s); } async getSmarts(): Promise { + if (this.explicitMol?.notation === DG.chem.Notation.Smarts) + return this.explicitMol.value; return PackageFunctions.convertMolNotation(this.molFile, DG.chem.Notation.MolBlock, DG.chem.Notation.Smarts); } set smarts(s: string) { - //@ts-ignore - this.explicitMol = {notation: 'smarts', value: s}; + this.explicitMol = {notation: DG.chem.Notation.Smarts, value: s}; this.importing = true; this.convertAndSetSmarts(s); } diff --git a/packages/KetcherSketcher/package.json b/packages/KetcherSketcher/package.json index 65698a2975..37227f222b 100644 --- a/packages/KetcherSketcher/package.json +++ b/packages/KetcherSketcher/package.json @@ -15,7 +15,7 @@ "dependencies": { "@datagrok-libraries/utils": "^4.6.5", "@types/react-dom": "^18.2.0", - "datagrok-api": "^1.27.0", + "datagrok-api": "../../js-api", "file-loader": "^6.2.0", "ketcher-core": "^3.12.0", "ketcher-react": "^3.12.0", diff --git a/packages/KetcherSketcher/src/ketcher.tsx b/packages/KetcherSketcher/src/ketcher.tsx index c245e252a2..7346acfb39 100644 --- a/packages/KetcherSketcher/src/ketcher.tsx +++ b/packages/KetcherSketcher/src/ketcher.tsx @@ -12,7 +12,7 @@ import 'ketcher-react/dist/index.css'; import '../css/editor.css'; import {KETCHER_MOLV2000, KETCHER_MOLV3000} from './constants'; -type NotationKey = 'smiles' | 'molblock' | 'molblockV3000' | 'smarts'; +type NotationKey = DG.chem.Notation.Smiles | DG.chem.Notation.MolBlock | DG.chem.Notation.V3KMolBlock | DG.chem.Notation.Smarts; export class KetcherSketcher extends grok.chem.SketcherBase { _smiles: string | null = null; @@ -141,7 +141,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase { } get smiles() { - if (this.explicitMol?.notation === 'smiles') + if (this.explicitMol?.notation === DG.chem.Notation.Smiles) return this.explicitMol.value; if (this._smiles !== null) return this._smiles; @@ -162,11 +162,11 @@ export class KetcherSketcher extends grok.chem.SketcherBase { this._molV3000 = null; this._smarts = null; this.importedMoleculesCounter++; - this._setNotation('smiles', smiles); + this._setNotation(DG.chem.Notation.Smiles, smiles); } get molFile() { - if (this.explicitMol?.notation === 'molblock') + if (this.explicitMol?.notation === DG.chem.Notation.MolBlock) return this.explicitMol.value; if (this._molV2000 !== null) return this._molV2000; @@ -185,11 +185,11 @@ export class KetcherSketcher extends grok.chem.SketcherBase { this._molV3000 = null; this._smarts = null; this.importedMoleculesCounter++; - this._setNotation('molblock', molfile); + this._setNotation(DG.chem.Notation.MolBlock, molfile); } get molV3000() { - if (this.explicitMol?.notation === 'molblockV3000') + if (this.explicitMol?.notation === DG.chem.Notation.V3KMolBlock) return this.explicitMol.value; if (this._molV3000 !== null) return this._molV3000; @@ -208,7 +208,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase { this._smiles = null; this._smarts = null; this.importedMoleculesCounter++; - this._setNotation('molblockV3000', molfile); + this._setNotation(DG.chem.Notation.V3KMolBlock, molfile); } async getSmarts(): Promise { @@ -223,7 +223,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase { this._molV2000 = null; this._smiles = null; this.importedMoleculesCounter++; - this._setNotation('smarts', smarts); + this._setNotation(DG.chem.Notation.Smarts, smarts); } get isInitialized() { @@ -265,7 +265,6 @@ export class KetcherSketcher extends grok.chem.SketcherBase { private _setNotation(notation: NotationKey, value: string): void { this.updatingMolecule = true; this.setKetcherMolecule(value); - //@ts-ignore this.explicitMol = {notation, value}; }