mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-19 09:27:29 +02:00
Copy active note path from Info panel
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { showInfo, appConfig } from '$lib/stores/app';
|
import { showInfo, appConfig, activeNotePath } from '$lib/stores/app';
|
||||||
import { getVaultStats, findOrphanedAttachments, trashOrphanedAttachments } from '$lib/api';
|
import { getVaultStats, findOrphanedAttachments, trashOrphanedAttachments } from '$lib/api';
|
||||||
import type { OrphanAttachment } from '$lib/api';
|
import type { OrphanAttachment } from '$lib/api';
|
||||||
import { openUrl } from '$lib/api';
|
import { openUrl } from '$lib/api';
|
||||||
@@ -93,6 +93,7 @@
|
|||||||
let locationCopyState = $state<'idle' | 'copied' | 'error'>('idle');
|
let locationCopyState = $state<'idle' | 'copied' | 'error'>('idle');
|
||||||
let locationCopyTimer: ReturnType<typeof setTimeout> | null = null;
|
let locationCopyTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
const orphanTotal = $derived((orphans ?? []).reduce((a, o) => a + o.size, 0));
|
const orphanTotal = $derived((orphans ?? []).reduce((a, o) => a + o.size, 0));
|
||||||
|
const diskLocation = $derived($activeNotePath ?? $appConfig?.active_vault ?? null);
|
||||||
|
|
||||||
getVersion().then(v => appVersion = v).catch(() => appVersion = '0.0.0');
|
getVersion().then(v => appVersion = v).catch(() => appVersion = '0.0.0');
|
||||||
|
|
||||||
@@ -108,17 +109,16 @@
|
|||||||
openUrl(url).catch(console.error);
|
openUrl(url).catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copyVaultLocation() {
|
async function copyDiskLocation() {
|
||||||
const location = $appConfig?.active_vault;
|
if (!diskLocation) return;
|
||||||
if (!location) return;
|
|
||||||
|
|
||||||
if (locationCopyTimer) clearTimeout(locationCopyTimer);
|
if (locationCopyTimer) clearTimeout(locationCopyTimer);
|
||||||
try {
|
try {
|
||||||
if (!navigator.clipboard?.writeText) throw new Error('Clipboard API unavailable');
|
if (!navigator.clipboard?.writeText) throw new Error('Clipboard API unavailable');
|
||||||
await navigator.clipboard.writeText(location);
|
await navigator.clipboard.writeText(diskLocation);
|
||||||
locationCopyState = 'copied';
|
locationCopyState = 'copied';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to copy vault location:', e);
|
console.error('Failed to copy disk location:', e);
|
||||||
locationCopyState = 'error';
|
locationCopyState = 'error';
|
||||||
}
|
}
|
||||||
locationCopyTimer = setTimeout(() => {
|
locationCopyTimer = setTimeout(() => {
|
||||||
@@ -200,17 +200,17 @@
|
|||||||
<p class="app-version">v{appVersion}</p>
|
<p class="app-version">v{appVersion}</p>
|
||||||
<p class="app-description">A local markdown note-taking app.</p>
|
<p class="app-description">A local markdown note-taking app.</p>
|
||||||
|
|
||||||
{#if $appConfig?.active_vault}
|
{#if diskLocation}
|
||||||
<div class="vault-location">
|
<div class="disk-location">
|
||||||
<div class="vault-location-header">
|
<div class="disk-location-header">
|
||||||
<span class="vault-location-label">Vault location</span>
|
<span class="disk-location-label">Disk location</span>
|
||||||
<button
|
<button
|
||||||
class="copy-location-btn"
|
class="copy-location-btn"
|
||||||
class:copied={locationCopyState === 'copied'}
|
class:copied={locationCopyState === 'copied'}
|
||||||
class:error={locationCopyState === 'error'}
|
class:error={locationCopyState === 'error'}
|
||||||
onclick={copyVaultLocation}
|
onclick={copyDiskLocation}
|
||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
title="Copy vault location"
|
title="Copy disk location"
|
||||||
>
|
>
|
||||||
{#if locationCopyState === 'copied'}
|
{#if locationCopyState === 'copied'}
|
||||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 4 4L19 6" /></svg>
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 4 4L19 6" /></svg>
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<code class="vault-location-path" title={$appConfig.active_vault}>{$appConfig.active_vault}</code>
|
<code class="disk-location-path" title={diskLocation}>{diskLocation}</code>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@
|
|||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-location {
|
.disk-location {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
padding: 11px 14px 12px;
|
padding: 11px 14px 12px;
|
||||||
@@ -478,21 +478,21 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-location-header {
|
.disk-location-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-location-label {
|
.disk-location-label {
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-location-path {
|
.disk-location-path {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 7px;
|
margin-top: 7px;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
@@ -529,7 +529,7 @@
|
|||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-location + .info-stats {
|
.disk-location + .info-stats {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user