mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-12 20:49:53 +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
13 lines
350 B
TypeScript
13 lines
350 B
TypeScript
export function formatMessage(
|
|
template: string | undefined,
|
|
vars?: Record<string, string | number | undefined>,
|
|
): string {
|
|
if (!template) return ""
|
|
if (!vars) return template
|
|
|
|
return template.replace(/\{(\w+)\}/g, (match, name) => {
|
|
const val = vars[name]
|
|
return val === undefined ? match : String(val)
|
|
})
|
|
}
|