diff --git a/packages/ketcher-react/src/script/ui/state/hotkeys.ts b/packages/ketcher-react/src/script/ui/state/hotkeys.ts index 7513110cff..1ee6e1cd71 100644 --- a/packages/ketcher-react/src/script/ui/state/hotkeys.ts +++ b/packages/ketcher-react/src/script/ui/state/hotkeys.ts @@ -354,13 +354,23 @@ async function safelyGetMimeType( async function getStructStringFromClipboardData( data: ClipboardItem[], ): Promise { - const clipboardItem = data[0] as ClipboardItem; - const structStr = - (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.KET}`)) || - (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.Mol}`)) || - (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.Rxn}`)) || - (await safelyGetMimeType(clipboardItem, 'text/plain')); - return structStr === '' ? '' : structStr.text(); + const clipboardItem = data[0]; + + if (clipboardItem instanceof ClipboardItem) { + const structStr = + (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.KET}`)) || + (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.Mol}`)) || + (await safelyGetMimeType(clipboardItem, `web ${ChemicalMimeType.Rxn}`)) || + (await safelyGetMimeType(clipboardItem, 'text/plain')); + return structStr === '' ? '' : structStr.text(); + } else { + return ( + data[ChemicalMimeType.KET] || + data[ChemicalMimeType.Mol] || + data[ChemicalMimeType.Rxn] || + data['text/plain'] + ); + } } function isAbleToCopy(editor: Editor): boolean {