Files
Momento/memento-note/lib/note-change-sync.ts
Antigravity a623454347
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m32s
CI / Deploy production (on server) (push) Has been skipped
perf: memo GridCard, fuse save fns, fix slash tab active color
2026-06-14 14:06:05 +00:00

25 lines
1006 B
TypeScript

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<void>
onDeleteNote?: (note: Note) => void | Promise<void>
onArchiveNote?: (note: Note) => void | Promise<void>
onMoveToNotebook?: (note: Note, notebookId: string | null) => void | Promise<void>
onNotePatch?: (noteId: string, patch: Partial<Note>) => void
onNoteIllustrationGenerated?: (noteId: string) => void | Promise<void>
onNoteIllustrationDeleted?: (noteId: string) => void | Promise<void>
}
export function emitNoteChange(detail: NoteChangeEvent) {
if (typeof window === 'undefined') return
window.dispatchEvent(new CustomEvent(NOTE_CHANGE_EVENT, { detail }))
}