feat(14.2.1-03): add markdown and multilingual cabana fields
Lift locale maps before ProjectWritableFields so a Journal-shaped save can persist the default host scalar and non-default locales through TranslationWriter without dropping nested JSON. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
24
admin/src/components/form/mlLocale.ts
Normal file
24
admin/src/components/form/mlLocale.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/** Window event that keeps every ML control on one active locale. */
|
||||
export const ML_LOCALE_CHANGE = 'summer:ml-locale'
|
||||
|
||||
/** Broadcast the locale the administrator selected on any ML control. */
|
||||
export function broadcastMLLocale(locale: string): void {
|
||||
if (typeof window === 'undefined' || locale === '') {
|
||||
return
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent(ML_LOCALE_CHANGE, { detail: locale }))
|
||||
}
|
||||
|
||||
/** Locale → text map as it is sent on save: only string values. */
|
||||
export function localeRecord(value: unknown): Record<string, string> {
|
||||
const out: Record<string, string> = {}
|
||||
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
||||
return out
|
||||
}
|
||||
for (const [locale, text] of Object.entries(value as Record<string, unknown>)) {
|
||||
if (typeof text === 'string') {
|
||||
out[locale] = text
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user