diff --git a/src/lib/components/NoteCard.svelte b/src/lib/components/NoteCard.svelte
index 4e009dd..2bcc54a 100644
--- a/src/lib/components/NoteCard.svelte
+++ b/src/lib/components/NoteCard.svelte
@@ -4,6 +4,7 @@
import { togglePin, trashNote, archiveNote, unarchiveNote, restoreNote, deleteNote, leaveNote, currentFilter } from '$lib/stores/notes.js';
import ImageLightbox from './ImageLightbox.svelte';
import CollaboratorPopover from './CollaboratorPopover.svelte';
+ import SharingIndicator from './SharingIndicator.svelte';
import type { Note } from '$lib/types/index.js';
import Undo2 from 'lucide-svelte/icons/undo-2';
import Trash2 from 'lucide-svelte/icons/trash-2';
@@ -101,10 +102,11 @@
- {#if note.isShared && note.collaborators}
-
{/if}
{#if note.pinned}
diff --git a/src/lib/components/NoteEditor.svelte b/src/lib/components/NoteEditor.svelte
index 940ac21..ea9cf9f 100644
--- a/src/lib/components/NoteEditor.svelte
+++ b/src/lib/components/NoteEditor.svelte
@@ -21,6 +21,7 @@
import FileText from 'lucide-svelte/icons/file-text';
import UserPlus from 'lucide-svelte/icons/user-plus';
import Users from 'lucide-svelte/icons/users';
+ import Globe from 'lucide-svelte/icons/globe';
import History from 'lucide-svelte/icons/history';
interface Props {
@@ -70,14 +71,16 @@
let showHistory = $state(false);
// svelte-ignore state_referenced_locally
let collaboratorsList = $state
(note?.collaborators ?? []);
+ // svelte-ignore state_referenced_locally
+ let currentShareToken = $state(note?.shareToken);
const isOwner = $derived(note?.isOwner !== false);
const isShared = $derived(collaboratorsList.length > 0);
+ const hasPublicLink = $derived(!!currentShareToken);
// Use displayName from first user or 'You' for owner
const ownerName = $derived(isOwner ? 'You' : 'Owner');
function handleCollaboratorsUpdate(updated: Collaborator[]) {
collaboratorsList = updated;
- // Update the note in the store
if (noteId) {
notes.update((list) =>
list.map((n) =>
@@ -89,6 +92,19 @@
}
}
+ function handleShareUpdate(token: string | null) {
+ currentShareToken = token ?? undefined;
+ if (noteId) {
+ notes.update((list) =>
+ list.map((n) =>
+ n.id === noteId
+ ? { ...n, shareToken: token ?? undefined }
+ : n
+ )
+ );
+ }
+ }
+
async function toggleShareDialog() {
if (currentlyNew) {
const id = await autoSave();
@@ -401,7 +417,9 @@
title="Share note"
data-testid="share-toggle"
>
- {#if isShared}
+ {#if hasPublicLink}
+
+ {:else if isShared}
{:else}
@@ -442,8 +460,10 @@
noteId={noteId}
collaborators={collaboratorsList}
{ownerName}
+ shareToken={currentShareToken}
onClose={() => (showShareDialog = false)}
onUpdate={handleCollaboratorsUpdate}
+ onShareUpdate={handleShareUpdate}
/>
{/if}
diff --git a/src/lib/components/SharingIndicator.svelte b/src/lib/components/SharingIndicator.svelte
new file mode 100644
index 0000000..1910aed
--- /dev/null
+++ b/src/lib/components/SharingIndicator.svelte
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+ {#if showPopover}
+
+ {#if hasPublicLink}
+
+
+ Public link active
+
+ {/if}
+ {#if hasCollaborators}
+
Shared with
+
+ {#if isOwner}
+ -
+ You (Owner)
+
+ {/if}
+ {#each collaborators as collab}
+ -
+ {collab.displayName || collab.email}
+
+ {/each}
+
+ {/if}
+
+ {/if}
+