InfoPanel: handle missing Clipboard API silently

This commit is contained in:
rektdeckard
2020-08-18 14:14:56 -04:00
parent 1b3fde3c30
commit 7cc707a942

View File

@@ -60,8 +60,8 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
event.currentTarget.blur();
setCopied(type);
const data = snippets[type];
if (!navigator.clipboard) throw new Error("no clipboard!");
data && navigator.clipboard.writeText(data);
// if (!navigator.clipboard) throw new Error("no clipboard!");
data && void(navigator.clipboard?.writeText(data));
};
const handleDownloadSVG = (
@@ -78,7 +78,7 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
) => {
event.currentTarget.blur();
setCopied("svg");
ref.current && navigator.clipboard.writeText(ref.current.outerHTML);
ref.current && void(navigator.clipboard?.writeText(ref.current.outerHTML));
};
return (