import type { Note } from '@/lib/types' export const NOTE_CHANGE_EVENT = 'memento-note-changed' export const NOTE_REQUEST_SAVE_EVENT = 'memento-request-note-save' export type NoteChangeEvent = | { type: 'updated'; note: Note } | { type: 'deleted'; noteId: string; notebookId?: string | null } | { type: 'created'; note: Note } export type NoteCollectionActions = { onTogglePin?: (note: Note) => void | Promise onDeleteNote?: (note: Note) => void | Promise onArchiveNote?: (note: Note) => void | Promise onMoveToNotebook?: (note: Note, notebookId: string | null) => void | Promise onNotePatch?: (noteId: string, patch: Partial) => void onNoteIllustrationGenerated?: (noteId: string) => void | Promise onNoteIllustrationDeleted?: (noteId: string) => void | Promise } export function emitNoteChange(detail: NoteChangeEvent) { if (typeof window === 'undefined') return window.dispatchEvent(new CustomEvent(NOTE_CHANGE_EVENT, { detail })) }