Skip to content

Commit

Permalink
Make sure no div elements get in the content of quotes. (#16072)
Browse files Browse the repository at this point in the history
* Make sure no div elements get in the content.

* Remove tags in content.
  • Loading branch information
SergioEstevao authored Jun 10, 2019
1 parent 4d08cc5 commit e9e3565
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ export class RichText extends Component {
result = this.removeRootTag( element, result );
} );
}

if ( this.props.tagsToEliminate ) {
this.props.tagsToEliminate.forEach( ( element ) => {
result = this.removeTag( element, result );
} );
}
return result;
}

Expand All @@ -307,6 +313,11 @@ export class RichText extends Component {
const closingTagRegexp = RegExp( '</' + tag + '>$', 'gim' );
return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' );
}
removeTag( tag, html ) {
const openingTagRegexp = RegExp( '<' + tag + '>', 'gim' );
const closingTagRegexp = RegExp( '</' + tag + '>', 'gim' );
return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' );
}

/*
* Handles any case where the content of the AztecRN instance has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const BlockQuotation = ( props ) => {
if ( child && child.props.identifier === 'citation' ) {
return cloneElement( child, { style: styles.wpBlockQuoteCitation } );
}
if ( child && child.props.identifier === 'value' ) {
return cloneElement( child, { tagsToEliminate: [ 'div' ] } );
}
return child;
} );
return (
Expand Down

0 comments on commit e9e3565

Please sign in to comment.