@@ -3,6 +3,8 @@ import { useEffect, useState } from 'react';
33import { ResponsiveChart } from 'react-d3-utils' ;
44import { BsArrowsMove } from 'react-icons/bs' ;
55import { FaTimes } from 'react-icons/fa' ;
6+ import type { MolfileSvgRendererProps } from 'react-ocl' ;
7+ import { MolfileSvgRenderer } from 'react-ocl' ;
68import OCLnmr from 'react-ocl-nmr' ;
79import { Rnd } from 'react-rnd' ;
810
@@ -24,6 +26,7 @@ import useAtomAssignment from '../../../panels/MoleculesPanel/useAtomAssignment.
2426interface DraggableMoleculeProps extends DraggableStructureProps {
2527 width : number ;
2628 height : number ;
29+ renderAsSVG ?: boolean ;
2730}
2831
2932interface DraggableStructureProps {
@@ -126,7 +129,7 @@ export function DraggableStructure(props: DraggableStructureProps) {
126129 if ( isExportProcessStart ) {
127130 return (
128131 < g transform = { `translate(${ x } ${ y } )` } >
129- < DraggableMolecule { ...{ width, height } } { ...props } />
132+ < DraggableMolecule renderAsSVG { ...{ width, height } } { ...props } />
130133 </ g >
131134 ) ;
132135 }
@@ -188,7 +191,14 @@ export function DraggableStructure(props: DraggableStructureProps) {
188191}
189192
190193function DraggableMolecule ( props : DraggableMoleculeProps ) {
191- const { molecule, index, moleculeView, width, height } = props ;
194+ const {
195+ molecule,
196+ index,
197+ moleculeView,
198+ width,
199+ height,
200+ renderAsSVG = false ,
201+ } = props ;
192202 const {
193203 currentDiaIDsToHighlight,
194204 handleOnAtomHover,
@@ -198,20 +208,29 @@ function DraggableMolecule(props: DraggableMoleculeProps) {
198208 const highlightColor = useHighlightColor ( ) ;
199209 const dispatch = useDispatch ( ) ;
200210
211+ const atomHighlightColor =
212+ currentDiaIDsToHighlight ?. length > 0 ? '#ff000080' : highlightColor ;
213+ const baseProps : MolfileSvgRendererProps = {
214+ id : `molSVG${ index || '' } ` ,
215+ height,
216+ width,
217+ label : molecule . label ,
218+ labelFontSize : 15 ,
219+ labelColor : 'rgb(0,0,0)' ,
220+ molfile : molecule . molfile ,
221+ atomHighlightColor,
222+ atomHighlightOpacity : 1 ,
223+ showAtomNumber : moleculeView . showAtomNumber ,
224+ } ;
225+
226+ if ( renderAsSVG ) {
227+ return < MolfileSvgRenderer { ...baseProps } /> ;
228+ }
229+
201230 return (
202231 < OCLnmr
203- id = { `molSVG${ index || '' } ` }
204- height = { height }
205- width = { width }
206- label = { molecule . label }
207- labelFontSize = { 15 }
208- labelColor = "rgb(0,0,0)"
209- molfile = { molecule . molfile }
232+ { ...baseProps }
210233 setSelectedAtom = { handleOnClickAtom }
211- atomHighlightColor = {
212- currentDiaIDsToHighlight ?. length > 0 ? '#ff000080' : highlightColor
213- }
214- atomHighlightOpacity = { 1 }
215234 highlights = {
216235 currentDiaIDsToHighlight ?. length > 0
217236 ? currentDiaIDsToHighlight
@@ -229,7 +248,6 @@ function DraggableMolecule(props: DraggableMoleculeProps) {
229248 } ,
230249 } ) ;
231250 } }
232- showAtomNumber = { moleculeView . showAtomNumber }
233251 />
234252 ) ;
235253}
0 commit comments