Phase 1: NoteEditor Split (64KB → 9 focused components) - components/note-editor/: types.ts, context, toolbar, title-block, content-area, metadata-section, full-page, dialog compositions - Maintains backwards compatibility via re-export from note-editor.tsx Phase 2: Context Consolidation (5 → 3 contexts) - NotebooksContext absorbs LabelContext (labels CRUD) - EditorUIContext merges HomeViewContext + NotebookDragContext - Removed: LabelContext, home-view-context, notebook-drag-context Phase 3: React Query Infrastructure - Added QueryProvider with @tanstack/react-query - lib/query-keys.ts: centralized query key definitions - lib/query-hooks.ts: useNotes, useNotebooksQuery, useLabelsQuery - lib/use-refresh.ts: hybrid invalidateQueries + triggerRefresh helper - NotebooksContext: invalidateQueries on mutations (with triggerRefresh fallback) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
'use client'
|
|
|
|
import { LanguageProvider, useLanguage } from '@/lib/i18n/LanguageProvider'
|
|
import { NotebooksProvider } from '@/context/notebooks-context'
|
|
import { EditorUIProvider } from '@/context/editor-ui-context'
|
|
import { NoteRefreshProvider } from '@/context/NoteRefreshContext'
|
|
import { QueryProvider } from '@/components/query-provider'
|
|
import type { ReactNode } from 'react'
|
|
import type { Translations } from '@/lib/i18n/load-translations'
|
|
|
|
const RTL_LANGUAGES = ['ar', 'fa']
|
|
|
|
/** Sets `dir` on its own DOM node from React state — immune to third-party JS overwriting documentElement.dir. */
|
|
function DirWrapper({ children }: { children: ReactNode }) {
|
|
const { language } = useLanguage()
|
|
const dir = RTL_LANGUAGES.includes(language) ? 'rtl' : 'ltr'
|
|
return <div dir={dir} className="contents">{children}</div>
|
|
}
|
|
|
|
interface ProvidersWrapperProps {
|
|
children: ReactNode
|
|
initialLanguage?: string
|
|
initialTranslations?: Translations
|
|
}
|
|
|
|
export function ProvidersWrapper({ children, initialLanguage = 'en', initialTranslations }: ProvidersWrapperProps) {
|
|
return (
|
|
<QueryProvider>
|
|
<NoteRefreshProvider>
|
|
<NotebooksProvider>
|
|
<EditorUIProvider>
|
|
<LanguageProvider initialLanguage={initialLanguage as any} initialTranslations={initialTranslations}>
|
|
<DirWrapper>
|
|
{children}
|
|
</DirWrapper>
|
|
</LanguageProvider>
|
|
</EditorUIProvider>
|
|
</NotebooksProvider>
|
|
</NoteRefreshProvider>
|
|
</QueryProvider>
|
|
)
|
|
}
|