fix: improve note interactions and markdown LaTeX support

## Bug Fixes

### Note Card Actions
- Fix broken size change functionality (missing state declaration)
- Implement React 19 useOptimistic for instant UI feedback
- Add startTransition for non-blocking updates
- Ensure smooth animations without page refresh
- All note actions now work: pin, archive, color, size, checklist

### Markdown LaTeX Rendering
- Add remark-math and rehype-katex plugins
- Support inline equations with dollar sign syntax
- Support block equations with double dollar sign syntax
- Import KaTeX CSS for proper styling
- Equations now render correctly instead of showing raw LaTeX

## Technical Details

- Replace undefined currentNote references with optimistic state
- Add optimistic updates before server actions for instant feedback
- Use router.refresh() in transitions for smart cache invalidation
- Install remark-math, rehype-katex, and katex packages

## Testing

- Build passes successfully with no TypeScript errors
- Dev server hot-reloads changes correctly
This commit is contained in:
2026-01-09 22:13:49 +01:00
parent 3c4b9d6176
commit 640fcb26f7
218 changed files with 51363 additions and 902 deletions

View File

@@ -0,0 +1,76 @@
// Import directly from the generated client
const { PrismaClient } = require('./node_modules/@prisma/client')
const prisma = new PrismaClient()
async function checkLabels() {
try {
console.log('\n=== TOUS LES LABELS DANS LA TABLE Label ===')
const allLabels = await prisma.label.findMany({
select: { id: true, name: true, userId: true }
})
console.log(`Total: ${allLabels.length} labels`)
allLabels.forEach(l => {
console.log(` - ${l.name} (userId: ${l.userId}, id: ${l.id})`)
})
console.log('\n=== TOUS LES LABELS DANS LES NOTES (Note.labels) ===')
const allNotes = await prisma.note.findMany({
select: { id: true, labels: true, userId: true }
})
const labelsInNotes = new Set()
allNotes.forEach(note => {
if (note.labels) {
try {
const parsed = JSON.parse(note.labels)
if (Array.isArray(parsed)) {
parsed.forEach(l => labelsInNotes.add(l))
}
} catch (e) {}
}
})
console.log(`Total unique: ${labelsInNotes.size} labels`)
labelsInNotes.forEach(l => console.log(` - ${l}`))
console.log('\n=== LABELS ORPHELINS (dans Label table MAIS PAS dans les notes) ===')
const orphanLabels = []
allLabels.forEach(label => {
let found = false
labelsInNotes.forEach(noteLabel => {
if (noteLabel.toLowerCase() === label.name.toLowerCase()) {
found = true
}
})
if (!found) {
orphanLabels.push(label)
}
})
console.log(`Total orphans: ${orphanLabels.length}`)
orphanLabels.forEach(l => {
console.log(` - ${l.name} (userId: ${l.userId})`)
})
console.log('\n=== LABELS MANQUANTS (dans notes MAIS PAS dans Label table) ===')
const missingLabels = []
const existingLabelNames = new Set()
allLabels.forEach(l => existingLabelNames.add(l.name.toLowerCase()))
labelsInNotes.forEach(noteLabel => {
if (!existingLabelNames.has(noteLabel.toLowerCase())) {
missingLabels.push(noteLabel)
}
})
console.log(`Total missing: ${missingLabels.length}`)
missingLabels.forEach(l => console.log(` - ${l}`))
} catch (error) {
console.error('Error:', error)
} finally {
await prisma.$disconnect()
}
}
checkLabels()

View File

@@ -1,11 +0,0 @@
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function main() {
const users = await prisma.user.findMany({
select: { email: true, name: true }
});
console.log('Registered users:', JSON.stringify(users, null, 2));
}
main().catch(console.error).finally(() => prisma.$disconnect());

View File

@@ -1,12 +0,0 @@
import 'dotenv/config'
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function main() {
const users = await prisma.user.findMany()
console.log(JSON.stringify(users, null, 2))
}
main()
.catch(e => console.error(e))
.finally(async () => await prisma.$disconnect())

View File

@@ -1,34 +0,0 @@
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function fixOrder() {
try {
// Get all notes sorted by creation date
const notes = await prisma.note.findMany({
orderBy: [
{ isPinned: 'desc' },
{ createdAt: 'asc' }
]
})
console.log(`Found ${notes.length} notes`)
// Update order values
for (let i = 0; i < notes.length; i++) {
await prisma.note.update({
where: { id: notes[i].id },
data: { order: i }
})
console.log(`Updated note ${notes[i].id} - order: ${i}`)
}
console.log('✅ Order values fixed!')
} catch (error) {
console.error('Error:', error)
} finally {
await prisma.$disconnect()
}
}
fixOrder()

View File

@@ -0,0 +1,35 @@
const { PrismaClient } = require('../prisma/client-generated');
const prisma = new PrismaClient();
async function promoteAdmin() {
const email = process.argv[2];
try {
let user;
if (email) {
user = await prisma.user.findUnique({ where: { email } });
} else {
console.log("Aucun email fourni, promotion du premier utilisateur trouvé...");
user = await prisma.user.findFirst();
}
if (!user) {
console.error("Aucun utilisateur trouvé.");
return;
}
await prisma.user.update({
where: { id: user.id },
data: { role: 'ADMIN' }
});
console.log(`Succès : L'utilisateur ${user.email} (${user.name}) est maintenant ADMIN.`);
} catch (e) {
console.error("Erreur :", e);
} finally {
await prisma.$disconnect();
}
}
promoteAdmin();