Skip to content

Commit

Permalink
fix: add paragraph as child of td in case is text
Browse files Browse the repository at this point in the history
  • Loading branch information
frgarciames committed Nov 14, 2024
1 parent ee4632c commit f8f3de8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,17 @@ describe('deserializeMdIndentList', () => {
children: [
{
type: 'td',
children: [{ text: 'Left columns' }],
children: [{
type: 'p',
children: [{ text: 'Left columns' }],
}],
},
{
type: 'td',
children: [{ text: 'Right columns' }],
children: [{
type: 'p',
children: [{ text: 'Right columns' }],
}],
},
],
},
Expand All @@ -584,11 +590,17 @@ describe('deserializeMdIndentList', () => {
children: [
{
type: 'td',
children: [{ text: 'left foo' }],
children: [{
type: 'p',
children: [{ text: 'left foo' }],
}],
},
{
type: 'td',
children: [{ text: 'right foo' }],
children: [{
type: 'p',
children: [{ text: 'right foo' }],
}],
},
],
},
Expand All @@ -597,11 +609,17 @@ describe('deserializeMdIndentList', () => {
children: [
{
type: 'td',
children: [{ text: 'left bar' }],
children: [{
type: 'p',
children: [{ text: 'left bar' }],
}],
},
{
type: 'td',
children: [{ text: 'right bar' }],
children: [{
type: 'p',
children: [{ text: 'right bar' }],
}],
},
],
},
Expand All @@ -610,11 +628,17 @@ describe('deserializeMdIndentList', () => {
children: [
{
type: 'td',
children: [{ text: 'left baz' }],
children: [{
type: 'p',
children: [{ text: 'left baz' }],
}],
},
{
type: 'td',
children: [{ text: 'right baz' }],
children: [{
type: 'p',
children: [{ text: 'right baz' }],
}],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const remarkDefaultElementRules: RemarkElementRules = {
transform: (node, options) => {
const children = node.children?.length
? node.children.flatMap((paragraph) =>
remarkTransformElementChildren(paragraph, options)
)
remarkTransformElementChildren(paragraph, options)
)
: [{ text: '' }];

// Flatten nested blockquotes (e.g. >>>)
Expand Down Expand Up @@ -182,8 +182,16 @@ export const remarkDefaultElementRules: RemarkElementRules = {
children:
row.children?.map((cell) => {
return {
children: remarkTransformElementChildren(cell, options),
type: options.editor.getType({ key: 'td' }),
children: remarkTransformElementChildren(cell, options).map(child => {
if (!child.type) {
return {
type: options.editor.getType({ key: 'p' }),
children: [child]
}
}
return child
}),
};
}) || [],
type: options.editor.getType({ key: 'tr' }),
Expand Down

0 comments on commit f8f3de8

Please sign in to comment.