Skip to content

Commit

Permalink
#3967 - Exception if you paste from clipboard using Ctrl+Alt+V (Smile…
Browse files Browse the repository at this point in the history
… insert)

- added fallback to old clipboard api for smarts
  • Loading branch information
rrodionov91 committed Jan 31, 2024
1 parent aeb8c22 commit 8ea4e8c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/ketcher-react/src/script/ui/state/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,23 @@ async function safelyGetMimeType(
async function getStructStringFromClipboardData(
data: ClipboardItem[],
): Promise<string> {
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 {
Expand Down

0 comments on commit 8ea4e8c

Please sign in to comment.