thompsonsj / payload-crowdin-sync

Upload and sync localized fields from the default locale to Crowdin.
7 stars 6 forks source link

fix(lexical): support lexical editor configs in nested fields #150

Closed thompsonsj closed 10 months ago

thompsonsj commented 10 months ago

Support the conversion of nested Lexical rich text field content to HTML. The plugin could only retrieve a Lexical editor config for top-level fields before this change.

TODO: support HTML conversion back to Lexical when retrieving translations.

Changed approach mid pull request

https://github.com/thompsonsj/payload-crowdin-sync/commit/781876492b4964110518dbab98af287d941a81b4 changed the return value of buildCrowdinHtmlObject to include the field config.

After getting to the point where the config needs to be included when translations are returned from Crowdin, I realised this isn't ideal. Although it passes a field definition when creating the source translation (field configs are available at that tine), when receiving a translation, it's necessary to search for the config - this field config is not available.

As a result, we may as well search for the config based on name in both approaches. This keeps the data structure simpler.