From 28d1d681a6b09524cf5bdb6f6b316e949559f323 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 8 Feb 2019 13:38:26 +0300 Subject: [PATCH 1/2] [Mobile]Remove unnecessary tags from post title (#13763) * Add extra rootTagsToEliminate prop * Fix lint issues * Revert unnecessary prop --- .../src/components/post-title/index.native.js | 1 + .../src/components/rich-text/index.native.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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 ); + 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, '' ); } From e0b39c6ce434f7ed71100198ede2abd7661a1847 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 8 Feb 2019 15:19:21 +0300 Subject: [PATCH 2/2] Add code comment for the workaround fix --- packages/editor/src/components/rich-text/index.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/editor/src/components/rich-text/index.native.js b/packages/editor/src/components/rich-text/index.native.js index b238af2702eb26..ac1f8593d73c91 100644 --- a/packages/editor/src/components/rich-text/index.native.js +++ b/packages/editor/src/components/rich-text/index.native.js @@ -171,6 +171,7 @@ export class RichText extends Component { removeRootTagsProduceByAztec( html ) { 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 );