Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure no div elements get in the content of quotes. #16072

Merged
merged 2 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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