diff --git a/documentation/FEATURES.md b/documentation/FEATURES.md index f9959c1..a1ff48f 100644 --- a/documentation/FEATURES.md +++ b/documentation/FEATURES.md @@ -49,6 +49,7 @@ - **Browser history** - Back/forward buttons navigate between notes - **Shareable links** - Bookmark or share direct links to notes with highlighted terms - **Refresh safe** - Page reload keeps you on the same note with search context +- **Copy link button** - One-click copy of note URL to clipboard ## 🎨 Customization diff --git a/frontend/app.js b/frontend/app.js index 9ae9bc2..41ecda1 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -4014,6 +4014,40 @@ function noteApp() { } }, + // Copy current note link to clipboard + async copyNoteLink() { + if (!this.currentNote) { + alert('No note selected'); + return; + } + + // Build the full URL + const pathWithoutExtension = this.currentNote.replace('.md', ''); + const encodedPath = pathWithoutExtension.split('/').map(segment => encodeURIComponent(segment)).join('/'); + const url = `${window.location.origin}/${encodedPath}`; + + try { + await navigator.clipboard.writeText(url); + + // Brief visual feedback (change button text temporarily) + const btn = event.target.closest('button'); + const originalHTML = btn.innerHTML; + btn.innerHTML = '✓'; + setTimeout(() => { + btn.innerHTML = originalHTML; + }, 1500); + } catch (error) { + // Fallback for older browsers + const textArea = document.createElement('textarea'); + textArea.value = url; + document.body.appendChild(textArea); + textArea.select(); + document.execCommand('copy'); + document.body.removeChild(textArea); + alert('Link copied to clipboard!'); + } + }, + // Homepage folder navigation methods goToHomepageFolder(folderPath) { this.showGraph = false; // Close graph when navigating diff --git a/frontend/index.html b/frontend/index.html index 527e5ff..ba71ace 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1852,12 +1852,24 @@ + + +