Skip to content

Commit

Permalink
#5121 - copy does not work in the firefox browser (#5282)
Browse files Browse the repository at this point in the history
- added fallback to text mimetype if custom mimetypes not supported
  • Loading branch information
matejaivosevic authored Aug 14, 2024
1 parent 3aa4f24 commit e573d30
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,21 @@ async function copy(data) {
}),
);
});
await navigator.clipboard.write([new ClipboardItem(clipboardItemData)]);

const clipboardItem = new ClipboardItem(clipboardItemData);

if (
clipboardItem.presentationStyle &&
clipboardItem.presentationStyle === 'unspecified'
) {
if (navigator.clipboard.writeText) {
// Fallback to simple text copy
const textData = data['text/plain'] || JSON.stringify(data);
await navigator.clipboard.writeText(textData);
}
} else {
await navigator.clipboard.write([clipboardItem]);
}
} catch (e) {
KetcherLogger.error('cliparea.jsx::copy', e);
console.info(`Could not write exact type ${data && data.toString()}`);
Expand Down

0 comments on commit e573d30

Please sign in to comment.