@@ -205,7 +205,7 @@ export class RichText extends Component {
205
205
206
206
valueToFormat ( value ) {
207
207
// Remove the outer root tags.
208
- return this . removeRootTagsProduceByAztec (
208
+ return this . removeRootTagsProducedByAztec (
209
209
toHTMLString ( {
210
210
value,
211
211
multilineTag : this . multilineTag ,
@@ -272,30 +272,27 @@ export class RichText extends Component {
272
272
* Cleans up any root tags produced by aztec.
273
273
* TODO: This should be removed on a later version when aztec doesn't return the top tag of the text being edited
274
274
*/
275
- removeRootTagsProduceByAztec ( html ) {
275
+ removeRootTagsProducedByAztec ( html ) {
276
276
let result = this . removeRootTag ( this . props . tagName , html ) ;
277
- // Temporary workaround for https://github.com/WordPress/gutenberg/pull/13763
278
- if ( this . props . rootTagsToEliminate ) {
279
- this . props . rootTagsToEliminate . forEach ( ( element ) => {
280
- result = this . removeRootTag ( element , result ) ;
281
- } ) ;
282
- }
283
277
284
278
if ( this . props . tagsToEliminate ) {
285
279
this . props . tagsToEliminate . forEach ( ( element ) => {
286
280
result = this . removeTag ( element , result ) ;
287
281
} ) ;
288
282
}
283
+
289
284
return result ;
290
285
}
291
286
292
287
removeRootTag ( tag , html ) {
293
288
const openingTagRegexp = RegExp ( '^<' + tag + '[^>]*>' , 'gim' ) ;
294
289
const closingTagRegexp = RegExp ( '</' + tag + '>$' , 'gim' ) ;
290
+
295
291
return html
296
292
. replace ( openingTagRegexp , '' )
297
293
. replace ( closingTagRegexp , '' ) ;
298
294
}
295
+
299
296
removeTag ( tag , html ) {
300
297
const openingTagRegexp = RegExp ( '<' + tag + '>' , 'gim' ) ;
301
298
const closingTagRegexp = RegExp ( '</' + tag + '>' , 'gim' ) ;
@@ -312,7 +309,7 @@ export class RichText extends Component {
312
309
return ;
313
310
}
314
311
315
- const contentWithoutRootTag = this . removeRootTagsProduceByAztec (
312
+ const contentWithoutRootTag = this . removeRootTagsProducedByAztec (
316
313
unescapeSpaces ( event . nativeEvent . text )
317
314
) ;
318
315
// On iOS, onChange can be triggered after selection changes, even though there are no content changes.
@@ -327,7 +324,7 @@ export class RichText extends Component {
327
324
}
328
325
329
326
onTextUpdate ( event ) {
330
- const contentWithoutRootTag = this . removeRootTagsProduceByAztec (
327
+ const contentWithoutRootTag = this . removeRootTagsProducedByAztec (
331
328
unescapeSpaces ( event . nativeEvent . text )
332
329
) ;
333
330
let formattedContent = contentWithoutRootTag ;
@@ -652,7 +649,7 @@ export class RichText extends Component {
652
649
const realEnd = Math . max ( start , end ) ;
653
650
654
651
// Check and dicsard stray event, where the text and selection is equal to the ones already cached.
655
- const contentWithoutRootTag = this . removeRootTagsProduceByAztec (
652
+ const contentWithoutRootTag = this . removeRootTagsProducedByAztec (
656
653
unescapeSpaces ( event . nativeEvent . text )
657
654
) ;
658
655
if (
0 commit comments