diff --git a/packages/rich-text/src/test/__snapshots__/to-dom.js.snap b/packages/rich-text/src/test/__snapshots__/to-dom.js.snap index 0b3d69d139c95..ce980dcd7589b 100644 --- a/packages/rich-text/src/test/__snapshots__/to-dom.js.snap +++ b/packages/rich-text/src/test/__snapshots__/to-dom.js.snap @@ -301,6 +301,22 @@ exports[`recordToDom should handle selection before br 1`] = ` `; +exports[`recordToDom should ignore formats at line separator 1`] = ` + +

+ + one + +

+

+ + two + + +

+ +`; + exports[`recordToDom should ignore line breaks to format HTML 1`] = ` diff --git a/packages/rich-text/src/test/create.js b/packages/rich-text/src/test/create.js index f4bbbad889b22..79d11f23134f5 100644 --- a/packages/rich-text/src/test/create.js +++ b/packages/rich-text/src/test/create.js @@ -32,6 +32,10 @@ describe( 'create', () => { createRange, record, } ) => { + if ( html === undefined ) { + return; + } + it( description, () => { const element = createElement( document, html ); const range = createRange( element ); diff --git a/packages/rich-text/src/test/helpers/index.js b/packages/rich-text/src/test/helpers/index.js index cb8ad42d9997b..a220d4ac70561 100644 --- a/packages/rich-text/src/test/helpers/index.js +++ b/packages/rich-text/src/test/helpers/index.js @@ -530,6 +530,16 @@ export const spec = [ text: '', }, }, + { + description: 'should ignore formats at line separator', + multilineTag: 'p', + startPath: [], + endPath: [], + record: { + formats: [ [ em ], [ em ], [ em ], [ em ], [ em ], [ em ], [ em ] ], + text: 'one\u2028two', + }, + }, { description: 'should remove br with settings', settings: { diff --git a/packages/rich-text/src/to-tree.js b/packages/rich-text/src/to-tree.js index 893b331c44a37..fa8810b8e17ea 100644 --- a/packages/rich-text/src/to-tree.js +++ b/packages/rich-text/src/to-tree.js @@ -45,7 +45,7 @@ function fromFormat( { type, attributes, object } ) { export function toTree( { value, multilineTag, - multilineWrapperTags, + multilineWrapperTags = [], createEmpty, append, getLastChild,