added copy to clipboard button
This commit is contained in:
parent
a66a7fc7bf
commit
e0022951ce
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = '<span class="hidden md:inline">✓ Copied!</span><span class="md:hidden">✓</span>';
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1852,12 +1852,24 @@
|
|||
<button
|
||||
@click="exportToHTML()"
|
||||
class="px-2 md:px-3 py-1 md:py-1.5 text-xs md:text-sm rounded transition hover:opacity-80"
|
||||
style="background-color: var(--accent-secondary); color: var(--text-primary);"
|
||||
style="background-color: var(--bg-tertiary); color: var(--text-secondary);"
|
||||
title="Export as HTML"
|
||||
>
|
||||
<span class="hidden md:inline">📄 Export HTML</span>
|
||||
<span class="md:hidden">📄</span>
|
||||
</button>
|
||||
|
||||
<!-- Copy Link Button -->
|
||||
<button
|
||||
@click="copyNoteLink()"
|
||||
x-show="currentNote"
|
||||
class="px-2 md:px-3 py-1 md:py-1.5 text-xs md:text-sm rounded transition hover:opacity-80"
|
||||
style="background-color: var(--bg-tertiary); color: var(--text-secondary);"
|
||||
title="Copy link to clipboard"
|
||||
>
|
||||
<span class="hidden md:inline">🔗 Copy Link</span>
|
||||
<span class="md:hidden">🔗</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue