Skip to content

Commit

Permalink
feat(plugin): deep merge source lexical block values into translation (
Browse files Browse the repository at this point in the history
…#221)

* feat(plugin): deep merge source lexical block values into translation

* style(plugin): cleanup

* test(lexicaleditorwithmultipleblocks): test nested fields lex blocks
  • Loading branch information
thompsonsj authored Oct 29, 2024
1 parent 25919b4 commit 8354f56
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 78 deletions.
28 changes: 21 additions & 7 deletions dev/src/lib/collections/fields/lexicalEditorWithBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,29 @@ export const lexicalEditorWithBlocks: RichTextField = {
imageAltText: "CTA",
fields: [
{
name: "text",
type: "text",
},
{
name: "href",
type: "text",
name: "link",
type: "group",
fields: [
{
name: "text",
type: "text",
},
{
name: "href",
type: "text",
},
{
name: "type",
type: "select",
options: [
"internal",
"external",
]
}
]
},
{
name: "type",
name: "style",
type: "select",
options: [
"primary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,6 @@ describe('Lexical editor with multiple blocks', () => {
},
{
"fields": {
"blockName": "",
"blockType": "highlight",
"color": "yellow",
"content": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export const fixture = {
"id": "65d67d2591c92e447e7472f7",
"blockName": "",
"blockType": "cta",
"text": "Download payload-crowdin-sync on npm!",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"type": "primary"
"link": {
"text": "Download payload-crowdin-sync on npm!",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"type": "external",
},
"select": "primary"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ describe('Lexical editor with multiple blocks', () => {
{
"blockName": "",
"blockType": "cta",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"id": "65d67d2591c92e447e7472f7",
"text": "Download payload-crowdin-sync on npm!",
"type": "primary",
"link": {
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"text": "Download payload-crowdin-sync on npm!",
"type": "external",
},
"select": "primary",
},
{
"blockName": "",
Expand Down Expand Up @@ -172,10 +175,13 @@ describe('Lexical editor with multiple blocks', () => {
"fields": {
"blockName": "",
"blockType": "cta",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"id": "65d67d2591c92e447e7472f7",
"text": "Download payload-crowdin-sync on npm!",
"type": "primary",
"link": {
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"text": "Download payload-crowdin-sync on npm!",
"type": "external",
},
"select": "primary",
},
"format": "",
"type": "block",
Expand Down Expand Up @@ -448,10 +454,13 @@ describe('Lexical editor with multiple blocks', () => {
"fields": {
"blockName": "",
"blockType": "cta",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"id": "65d67d2591c92e447e7472f7",
"text": "Download payload-crowdin-sync on npm!",
"type": "primary",
"link": {
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"text": "Download payload-crowdin-sync on npm!",
"type": "external",
},
"select": "primary",
},
"format": "",
"type": "block",
Expand Down Expand Up @@ -1020,8 +1029,10 @@ describe('Lexical editor with multiple blocks', () => {
blocks: {
'65d67d2591c92e447e7472f7': {
cta: {
text: 'Téléchargez payload-crowdin-sync sur npm!',
href: 'https://www.npmjs.com/package/payload-crowdin-sync',
link: {
text: 'Téléchargez payload-crowdin-sync sur npm!',
href: 'https://www.npmjs.com/package/payload-crowdin-sync',
},
},
},
'65d67d8191c92e447e7472f8': {
Expand Down Expand Up @@ -1184,12 +1195,13 @@ describe('Lexical editor with multiple blocks', () => {
},
{
"fields": {
"blockName": "",
"blockType": "cta",
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"id": "65d67d2591c92e447e7472f7",
"text": "Téléchargez payload-crowdin-sync sur npm!",
"type": "primary",
"link": {
"href": "https://www.npmjs.com/package/payload-crowdin-sync",
"text": "Téléchargez payload-crowdin-sync sur npm!",
"type": "external",
},
},
"format": "",
"type": "block",
Expand Down Expand Up @@ -1265,7 +1277,6 @@ describe('Lexical editor with multiple blocks', () => {
},
{
"fields": {
"blockName": "",
"blockType": "highlight",
"color": "green",
"content": {
Expand Down Expand Up @@ -1309,7 +1320,6 @@ describe('Lexical editor with multiple blocks', () => {
},
{
"fields": {
"blockName": "",
"blockType": "imageText",
"id": "65d67e2291c92e447e7472f9",
"image": "65d67e6a7fb7e9426b3f9f5f",
Expand Down
86 changes: 65 additions & 21 deletions dev/src/lib/tests/plugin/getLocalizedFields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,29 @@ describe('payload-crowdin-sync: getLexicalBlockFields', () => {
{
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
},
{
"name": "type",
"options": [
"internal",
"external",
],
"type": "select",
},
],
"name": "link",
"type": "group",
},
{
"name": "type",
"name": "style",
"options": [
"primary",
"secondary",
Expand Down Expand Up @@ -476,6 +490,8 @@ describe('payload-crowdin-sync: getLexicalBlockFields', () => {
"slug": "imageText",
},
],
"name": "blocks",
"type": "blocks",
}
`);
});
Expand Down Expand Up @@ -1813,15 +1829,29 @@ describe('payload-crowdin-sync: getLocalizedFields', () => {
{
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
},
{
"name": "type",
"options": [
"internal",
"external",
],
"type": "select",
},
],
"name": "link",
"type": "group",
},
{
"name": "type",
"name": "style",
"options": [
"primary",
"secondary",
Expand Down Expand Up @@ -4635,15 +4665,29 @@ describe('payload-crowdin-sync: getLocalizedFields', () => {
{
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
"fields": [
{
"name": "text",
"type": "text",
},
{
"name": "href",
"type": "text",
},
{
"name": "type",
"options": [
"internal",
"external",
],
"type": "select",
},
],
"name": "link",
"type": "group",
},
{
"name": "type",
"name": "style",
"options": [
"primary",
"secondary",
Expand Down
Loading

0 comments on commit 8354f56

Please sign in to comment.