feat: note history modal with restore, diff comparison, and dynamic UI updates
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m14s

- Complete rewrite of note-history-modal: version list with inline restore/delete,
  split diff view with synced scrolling, rich preview for markdown/richtext/checklist
- Fix restore not updating editor: use key={id-updatedAt} on NoteInlineEditor to
  force remount on restore, and add sync useEffect to reset local state on prop changes
- Add sync useEffect in NoteEditor for external note updates
- Add historyEnabled to NOTE_LIST_SELECT (no more 'Activer' on every modal open)
- Replace browser confirm() with shadcn AlertDialog for delete confirmation
- Add i18n keys: currentVersion, compareVersions, diffTitle, diffSelectHint, deleteVersionDesc
- Install diff + @types/diff for visual line diffing
- Fix MasonryGrid render-phase sync to preserve local sizes
- Update notes-tabs-view merge logic for restored note propagation
- Remove debug console.log from restoreNoteVersion
This commit is contained in:
2026-05-02 16:51:12 +02:00
parent bd4dd0e9eb
commit 3818eb8237
13 changed files with 1012 additions and 302 deletions

View File

@@ -66,8 +66,10 @@ export async function createNoteHistorySnapshot({
if (!note || !note.userId) return
const ownerId = note.userId
await prisma.$transaction(async (tx) => {
const lastVersionEntry = await (tx as any).noteHistory.findFirst({
const lastVersionEntry = await tx.noteHistory.findFirst({
where: { noteId },
orderBy: { version: 'desc' },
select: { version: true },
@@ -75,10 +77,10 @@ export async function createNoteHistorySnapshot({
const nextVersion = ((lastVersionEntry?.version as number | undefined) ?? 0) + 1
await (tx as any).noteHistory.create({
await tx.noteHistory.create({
data: {
noteId: note.id,
userId: note.userId,
userId: ownerId,
version: nextVersion,
reason: reason ?? null,
title: note.title,
@@ -157,7 +159,7 @@ export async function shouldCreateAutoSnapshot(params: {
if (!contentChanged && !titleChanged) return false
// Check cooldown: find the most recent snapshot for this note
const lastSnapshot = await (prisma as any).noteHistory.findFirst({
const lastSnapshot = await prisma.noteHistory.findFirst({
where: { noteId },
orderBy: { createdAt: 'desc' },
select: { createdAt: true },