@@ -193,14 +193,20 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
193193 [ molecules , currentIndex , copyHandler , saveAsPNGHandler , saveAsSVGHandler ] ,
194194 ) ;
195195
196- function handlePasteMolfileAction ( ) {
196+ function handlePasteMoleculeAction ( ) {
197197 onClickPastMolecule ?.( ) ;
198- void readText ( ) . then ( handlePasteMolfile ) ;
198+ void readText ( ) . then ( handlePasteMolecule ) ;
199199 }
200- async function handlePasteMolfile ( molfile : string | undefined ) {
201- if ( ! molfile ) return ;
200+
201+ /**
202+ * The moleecule pasted could be SMILES, molfile or SDF
203+ * @param text - text from clipboard
204+ * @returns
205+ */
206+ async function handlePasteMolecule ( text : string | undefined ) {
207+ if ( ! text ) return ;
202208 try {
203- const molecules = getMolecules ( molfile ) ;
209+ const molecules = getMolecules ( text ) ;
204210 dispatch ( { type : 'ADD_MOLECULES' , payload : { molecules } } ) ;
205211 } catch {
206212 toaster . show ( {
@@ -296,7 +302,7 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
296302 < Toolbar . Item
297303 tooltip = "Paste SMILES or molfile"
298304 icon = { < FaPaste /> }
299- onClick = { handlePasteMolfileAction }
305+ onClick = { handlePasteMoleculeAction }
300306 />
301307 { renderSource === 'moleculePanel' && (
302308 < Toolbar . Item
@@ -350,7 +356,7 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
350356 < ClipboardFallbackModal
351357 mode = { shouldFallback }
352358 onDismiss = { cleanShouldFallback }
353- onReadText = { handlePasteMolfile }
359+ onReadText = { handlePasteMolecule }
354360 text = { text }
355361 label = "Molfile"
356362 />
0 commit comments