diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index c793cb4d0a1135..f9534487cfdaa2 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -48,6 +48,7 @@ class PostTitle extends Component { return ( ', 'gim' ); - const closingTagRegexp = RegExp( '$', 'gim' ); + let result = this.removeRootTag( this.props.tagName, html ); + // Temporary workaround for https://github.com/WordPress/gutenberg/pull/13763 + if ( this.props.rootTagsToEliminate ) { + this.props.rootTagsToEliminate.forEach( ( element ) => { + result = this.removeRootTag( element, result ); + } ); + } + return result; + } + + removeRootTag( tag, html ) { + const openingTagRegexp = RegExp( '^<' + tag + '>', 'gim' ); + const closingTagRegexp = RegExp( '$', 'gim' ); return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' ); }