mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-12 12:39:52 +08:00
- lib/utils.ts: remove convertToLegalXml and replaceNodes; the streaming preview now goes through wrapCellsInModel, autoFixXml and replacePageModel like the final commit path does - lib/utils.ts: extractDiagramXML reuses extractSvgEmbeddedXml, pageElement and decompressPageContent instead of hand-written SVG parsing and pako inflation - lib/use-file-processor.tsx: messages parameter is required, drop the English default texts only tests used - hooks/use-dictionary.ts, lib/i18n/utils.ts: drop duplicate default exports nobody imported - tests updated accordingly
28 lines
674 B
TypeScript
28 lines
674 B
TypeScript
"use client"
|
|
|
|
import React, { createContext, useContext } from "react"
|
|
import type { Dictionary } from "@/lib/i18n/dictionaries"
|
|
|
|
const DictionaryContext = createContext<Dictionary | null>(null)
|
|
|
|
export function DictionaryProvider({
|
|
children,
|
|
dictionary,
|
|
}: React.PropsWithChildren<{ dictionary: Dictionary }>) {
|
|
return React.createElement(
|
|
DictionaryContext.Provider,
|
|
{ value: dictionary },
|
|
children,
|
|
)
|
|
}
|
|
|
|
export function useDictionary() {
|
|
const dict = useContext(DictionaryContext)
|
|
if (!dict) {
|
|
throw new Error(
|
|
"useDictionary must be used within a DictionaryProvider",
|
|
)
|
|
}
|
|
return dict
|
|
}
|