Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4485 from tinacms/nested-object-mdx-issue
- Loading branch information
Showing
19 changed files
with
452 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@tinacms/mdx": patch | ||
tinacms: patch | ||
--- | ||
|
||
Fix issue where rich-text nested inside JSX objects wasn't being parsed/stringified properly. |
Large diffs are not rendered by default.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/field.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { RichTextField } from '@tinacms/schema-tools' | ||
|
||
export const field: RichTextField = { | ||
name: 'body', | ||
type: 'rich-text', | ||
parser: { type: 'mdx' }, | ||
templates: [ | ||
{ | ||
name: 'Table', | ||
fields: [ | ||
{ | ||
name: 'rows', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'columns', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'content', | ||
type: 'object', | ||
fields: [{ name: 'description', type: 'rich-text' }], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/in.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Hello | ||
|
||
<Table rows={[ | ||
{ | ||
columns: [ | ||
{ | ||
content: { | ||
description: "# Hello" | ||
} | ||
} | ||
] | ||
} | ||
]} /> |
13 changes: 13 additions & 0 deletions
13
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { it, expect } from 'vitest' | ||
import { parseMDX } from '../../../parse' | ||
import { stringifyMDX } from '../../../stringify' | ||
import { field } from './field' | ||
import input from './in.md?raw' | ||
import * as util from '../util' | ||
|
||
it('matches input', () => { | ||
const tree = parseMDX(input, field, (v) => v) | ||
expect(util.print(tree)).toMatchFile(util.nodePath(__dirname)) | ||
const string = stringifyMDX(tree, field, (v) => v) | ||
expect(string).toMatchFile(util.mdPath(__dirname)) | ||
}) |
50 changes: 50 additions & 0 deletions
50
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/node.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "p", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "mdxJsxFlowElement", | ||
"name": "Table", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "" | ||
} | ||
], | ||
"props": { | ||
"rows": [ | ||
{ | ||
"columns": [ | ||
{ | ||
"content": { | ||
"description": { | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "h1", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/out.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hello | ||
|
||
<Table rows={[{ columns: [{ content: { description: "# Hello\n" } }] }]} /> |
33 changes: 33 additions & 0 deletions
33
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-3/field.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { RichTextField } from '@tinacms/schema-tools' | ||
|
||
export const field: RichTextField = { | ||
name: 'body', | ||
type: 'rich-text', | ||
parser: { type: 'mdx' }, | ||
templates: [ | ||
{ | ||
name: 'Table', | ||
fields: [ | ||
{ | ||
name: 'rows', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'columns', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'content', | ||
type: 'rich-text', | ||
templates: [{ name: 'World', fields: [] }], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-3/in.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Hello | ||
|
||
<Table rows={[ | ||
{ | ||
columns: [ | ||
{ | ||
content: "# Hello <World />" | ||
} | ||
] | ||
} | ||
]} /> |
13 changes: 13 additions & 0 deletions
13
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-3/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { it, expect } from 'vitest' | ||
import { parseMDX } from '../../../parse' | ||
import { stringifyMDX } from '../../../stringify' | ||
import { field } from './field' | ||
import input from './in.md?raw' | ||
import * as util from '../util' | ||
|
||
it('matches input', () => { | ||
const tree = parseMDX(input, field, (v) => v) | ||
expect(util.print(tree)).toMatchFile(util.nodePath(__dirname)) | ||
const string = stringifyMDX(tree, field, (v) => v) | ||
expect(string).toMatchFile(util.mdPath(__dirname)) | ||
}) |
59 changes: 59 additions & 0 deletions
59
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-3/node.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "p", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "mdxJsxFlowElement", | ||
"name": "Table", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "" | ||
} | ||
], | ||
"props": { | ||
"rows": [ | ||
{ | ||
"columns": [ | ||
{ | ||
"content": { | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "h1", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello " | ||
}, | ||
{ | ||
"type": "mdxJsxTextElement", | ||
"name": "World", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "" | ||
} | ||
], | ||
"props": {} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects-3/out.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hello | ||
|
||
<Table rows={[{ columns: [{ content: "# Hello <World />\n" }] }]} /> |
32 changes: 32 additions & 0 deletions
32
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects/field.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { RichTextField } from '@tinacms/schema-tools' | ||
|
||
export const field: RichTextField = { | ||
name: 'body', | ||
type: 'rich-text', | ||
parser: { type: 'mdx' }, | ||
templates: [ | ||
{ | ||
name: 'Table', | ||
fields: [ | ||
{ | ||
name: 'rows', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'columns', | ||
type: 'object', | ||
list: true, | ||
fields: [ | ||
{ | ||
name: 'content', | ||
type: 'rich-text', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects/in.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Hello | ||
|
||
<Table rows={[ | ||
{ | ||
columns: [ | ||
{ | ||
content: "# Hello" | ||
} | ||
] | ||
} | ||
]} /> |
13 changes: 13 additions & 0 deletions
13
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { it, expect } from 'vitest' | ||
import { parseMDX } from '../../../parse' | ||
import { stringifyMDX } from '../../../stringify' | ||
import { field } from './field' | ||
import input from './in.md?raw' | ||
import * as util from '../util' | ||
|
||
it('matches input', () => { | ||
const tree = parseMDX(input, field, (v) => v) | ||
expect(util.print(tree)).toMatchFile(util.nodePath(__dirname)) | ||
const string = stringifyMDX(tree, field, (v) => v) | ||
expect(string).toMatchFile(util.mdPath(__dirname)) | ||
}) |
48 changes: 48 additions & 0 deletions
48
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects/node.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "p", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "mdxJsxFlowElement", | ||
"name": "Table", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "" | ||
} | ||
], | ||
"props": { | ||
"rows": [ | ||
{ | ||
"columns": [ | ||
{ | ||
"content": { | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "h1", | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"text": "Hello" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/@tinacms/mdx/src/next/tests/mdx-basic-nested-objects/out.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hello | ||
|
||
<Table rows={[{ columns: [{ content: "# Hello\n" }] }]} /> |
Oops, something went wrong.