Skip to content

Commit e9e3565

Browse files
Make sure no div elements get in the content of quotes. (#16072)
* Make sure no div elements get in the content. * Remove tags in content.
1 parent 4d08cc5 commit e9e3565

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/block-editor/src/components/rich-text/index.native.js

+11
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ export class RichText extends Component {
299299
result = this.removeRootTag( element, result );
300300
} );
301301
}
302+
303+
if ( this.props.tagsToEliminate ) {
304+
this.props.tagsToEliminate.forEach( ( element ) => {
305+
result = this.removeTag( element, result );
306+
} );
307+
}
302308
return result;
303309
}
304310

@@ -307,6 +313,11 @@ export class RichText extends Component {
307313
const closingTagRegexp = RegExp( '</' + tag + '>$', 'gim' );
308314
return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' );
309315
}
316+
removeTag( tag, html ) {
317+
const openingTagRegexp = RegExp( '<' + tag + '>', 'gim' );
318+
const closingTagRegexp = RegExp( '</' + tag + '>', 'gim' );
319+
return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' );
320+
}
310321

311322
/*
312323
* Handles any case where the content of the AztecRN instance has changed

packages/components/src/primitives/block-quotation/index.native.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export const BlockQuotation = ( props ) => {
1616
if ( child && child.props.identifier === 'citation' ) {
1717
return cloneElement( child, { style: styles.wpBlockQuoteCitation } );
1818
}
19+
if ( child && child.props.identifier === 'value' ) {
20+
return cloneElement( child, { tagsToEliminate: [ 'div' ] } );
21+
}
1922
return child;
2023
} );
2124
return (

0 commit comments

Comments
 (0)