Skip to content

Commit

Permalink
TinyMCE per block: Fix the paragraph generated markup (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Mar 3, 2017
1 parent 529ee55 commit 83800da
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tinymce-per-block/src/blocks/paragraph-block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ registerBlock( 'paragraph', {
return {
blockType: 'paragraph',
align: rawBlock.attrs.align || 'no-align',
content: serialize( rawBlock.children ),
content: serialize( rawBlock.children[ 0 ].children ),
};
},
serialize: ( block ) => {
const children = parse( block.content );
const rawHtml = serialize( children );
let children = parse( block.content );
// Should probably be handled in the form
children = children.length === 1 && children[ 0 ].name === 'p' ? children[ 0 ].children : children;
const rawHtml = `<p style="text-align: ${ block.align };">${ serialize( children ) }</p>`;

return {
type: 'WP_Block',
Expand All @@ -40,7 +42,7 @@ registerBlock( 'paragraph', {
startText: '<!-- wp:paragraph -->',
endText: '<!-- /wp -->',
rawContent: '<!-- wp:paragraph -->' + rawHtml + '<!-- /wp -->',
children
children: parse( rawHtml )
};
}
} );

0 comments on commit 83800da

Please sign in to comment.