diff --git a/tinymce-per-block/src/index.js b/tinymce-per-block/src/index.js index b84fe2b689e1d..25e8f59b12c7e 100644 --- a/tinymce-per-block/src/index.js +++ b/tinymce-per-block/src/index.js @@ -27,15 +27,17 @@ class App extends Component { const type = forceType ? forceType : this.state.activeRenderer; switch ( type ) { case 'block': + const html = serializers.block.serialize( + nextContent.map( block => { + const blockDefinition = getBlock( block.blockType ); + return blockDefinition.serialize( block ); + } ) + ); this.setState( { content: { block: nextContent, - html: serializers.block.serialize( - nextContent.map( block => { - const blockDefinition = getBlock( block.blockType ); - return blockDefinition.serialize( block ); - } ) - ) + raw: html, + html } } ); return; @@ -50,16 +52,17 @@ class App extends Component { return parsedBlock ? parsedBlock : getBlock( 'text' ).parse( rawBlock ); } ) .map( block => Object.assign( { uid: uniqueId() }, block ) ), - html: nextContent + html: nextContent, + raw: nextContent } } ); return; } } - toggleRenderer = () => { + selectRenderer = ( renderer ) => () => { this.setState( { - activeRenderer: this.state.activeRenderer === 'block' ? 'html' : 'block' + activeRenderer: renderer } ); } @@ -72,7 +75,11 @@ class App extends Component { const Renderer = renderers[ activeRenderer ]; return (