Skip to content

Commit 54224c3

Browse files
authored
perf(richtext-lexical): do not return i18n from editor adapter (#14228)
This PR deprecates the `i18n` property returned from the editor adapter. Instead, we now merge `i18n` directly into the `config`, since the config is already available in the richtext adapter provider. This simplifies the logic (only one line of code) and eliminates the need to manually read and merge i18n from the adapter. Benefits: - **Simpler implementation**: Merging i18n into the config is straightforward - **Reduced memory usage**: Each editor no longer maintains its own i18n object - only a single, merged `config.i18n` is kept. - **Improved developer experience**: The sanitized field config is now smaller and easier to inspect. Console logging the config no longer floods the output with hundreds of translation lines. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211668727538425
1 parent 0dc782c commit 54224c3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/payload/src/admin/RichText.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ type RichTextAdapterBase<
235235
siblingDoc: JsonObject
236236
}) => void
237237
hooks?: RichTextHooks
238+
/**
239+
* @deprecated - manually merge i18n translations into the config.i18n.translations object within the adapter provider instead.
240+
* This property will be removed in v4.
241+
*/
238242
i18n?: Partial<GenericLanguages>
239243
outputSchema?: (args: {
240244
collectionIDFieldTypes: { [key: string]: 'number' | 'string' }

packages/richtext-lexical/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
beforeChangeTraverseFields,
88
beforeValidateTraverseFields,
99
checkDependencies,
10+
deepMergeSimple,
1011
withNullableJSONSchemaType,
1112
} from 'payload'
1213

@@ -93,6 +94,8 @@ export function lexicalEditor(args?: LexicalEditorProps): LexicalRichTextAdapter
9394
featureI18n[lang].lexical.general = i18n[lang]
9495
}
9596

97+
config.i18n.translations = deepMergeSimple(config.i18n.translations, featureI18n)
98+
9699
return {
97100
CellComponent: {
98101
path: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell',
@@ -783,7 +786,6 @@ export function lexicalEditor(args?: LexicalEditorProps): LexicalRichTextAdapter
783786
},
784787
],
785788
},
786-
i18n: featureI18n,
787789
outputSchema: ({
788790
collectionIDFieldTypes,
789791
config,

0 commit comments

Comments
 (0)