- Toolbar: remove text labels from all icon buttons (AI, Save, Preview, Convert) all buttons now icon-only with title tooltip for accessibility - Toolbar: reposition PanelRight (info panel toggle) to far right after three-dot menu - Versioning: decouple getNoteHistory/restoreNoteVersion from global userAISettings.noteHistory now checks note.historyEnabled directly — unblocks manual per-note history - Versioning: add 'Sauvegarder cette version' button in Versions tab of info panel calls commitNoteHistory with visual feedback (spinner → success state) - note-document-info-panel: import commitNoteHistory, add isSavingVersion state - notes.ts: fix double guard that silently blocked all history operations
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { applyDocumentTheme, normalizeThemeId } from '@/lib/apply-document-theme'
|
|
|
|
interface ThemeInitializerProps {
|
|
theme?: string
|
|
fontSize?: string
|
|
fontFamily?: string
|
|
}
|
|
|
|
export function ThemeInitializer({ theme, fontSize, fontFamily }: ThemeInitializerProps) {
|
|
useEffect(() => {
|
|
const applyFontSize = (s?: string) => {
|
|
const size = s || 'medium'
|
|
|
|
const fontSizeMap: Record<string, string> = {
|
|
small: '14px',
|
|
medium: '16px',
|
|
large: '18px',
|
|
'extra-large': '20px',
|
|
}
|
|
|
|
const fontSizeFactorMap: Record<string, number> = {
|
|
small: 0.95,
|
|
medium: 1.0,
|
|
large: 1.1,
|
|
'extra-large': 1.25,
|
|
}
|
|
|
|
const root = document.documentElement
|
|
root.style.setProperty('--user-font-size', fontSizeMap[size] || '16px')
|
|
root.style.setProperty('--user-font-size-factor', (fontSizeFactorMap[size] || 1).toString())
|
|
}
|
|
|
|
const localTheme = localStorage.getItem('theme-preference')
|
|
const effectiveTheme = localTheme || theme || 'light'
|
|
|
|
applyDocumentTheme(effectiveTheme)
|
|
|
|
if (!localTheme && theme) {
|
|
localStorage.setItem('theme-preference', normalizeThemeId(theme))
|
|
}
|
|
|
|
applyFontSize(fontSize)
|
|
|
|
const localFontFamily = localStorage.getItem('font-family')
|
|
const effectiveFontFamily = localFontFamily || fontFamily || 'inter'
|
|
const root = document.documentElement
|
|
root.classList.remove('font-system', 'font-playfair', 'font-jetbrains')
|
|
if (effectiveFontFamily === 'system') root.classList.add('font-system')
|
|
if (effectiveFontFamily === 'playfair') root.classList.add('font-playfair')
|
|
if (effectiveFontFamily === 'jetbrains') root.classList.add('font-jetbrains')
|
|
if (!localFontFamily && fontFamily) {
|
|
localStorage.setItem('font-family', fontFamily)
|
|
}
|
|
}, [theme, fontSize, fontFamily])
|
|
|
|
return null
|
|
}
|