Browse Source

fix undefined navigator.clipboard

David Sehnal 4 years ago
parent
commit
7d7c1241d4

+ 1 - 1
src/mol-plugin-ui/viewport/screenshot.tsx

@@ -63,7 +63,7 @@ export class DownloadScreenshotControls extends PluginUIComponent<{ close: () =>
     }
 
     render() {
-        const hasClipboardApi = !!(navigator.clipboard as any).write;
+        const hasClipboardApi = !!(navigator.clipboard as any)?.write;
 
         return <div>
             {this.state.showPreview && <div className='msp-image-preview'>

+ 1 - 1
src/mol-plugin/util/viewport-screenshot.ts

@@ -302,7 +302,7 @@ class ViewportScreenshotHelper extends PluginComponent {
     private copyToClipboardTask() {
         const cb = navigator.clipboard as any;
 
-        if (!cb.write) {
+        if (!cb?.write) {
             this.plugin.log.error('clipboard.write not supported!');
             return;
         }