From: Alexander Wilms Date: Thu, 26 Jun 2025 22:34:48 +0000 (+0200) Subject: fix(mermaid-viewer): Handle clipboard API failure gracefully X-Git-Url: http://source.bookstackapp.com/hacks/commitdiff_plain/166089ff950c32ce37c800b522e2631721d0b07d fix(mermaid-viewer): Handle clipboard API failure gracefully Adds a fallback mechanism and logs the error when the clipboard API fails. --- diff --git a/content/mermaid-viewer/head.html b/content/mermaid-viewer/head.html index 0f76bfd..b2c3383 100644 --- a/content/mermaid-viewer/head.html +++ b/content/mermaid-viewer/head.html @@ -365,8 +365,9 @@ try { await navigator.clipboard.writeText(this.mermaidCode); this.showNotification('Copied!'); - } catch (_error) { + } catch (error) { // Fallback for older browsers or if clipboard API fails + console.error('Clipboard API copy failed, attempting fallback:', error); const textArea = document.createElement('textarea'); textArea.value = this.mermaidCode; // Style to make it invisible