From afb679feff21706df85765467baba98ae39450a7 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 29 Feb 2024 18:32:26 +0200 Subject: [PATCH 1/2] Rich text: fix typing into empty flex element --- packages/rich-text/src/create.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/rich-text/src/create.js b/packages/rich-text/src/create.js index fce6d5a55b2027..0eaec892b155d9 100644 --- a/packages/rich-text/src/create.js +++ b/packages/rich-text/src/create.js @@ -472,11 +472,9 @@ function createFromElement( { element, range, isEditableTree } ) { if ( isEditableTree && - // Ignore any placeholders. - ( node.getAttribute( 'data-rich-text-placeholder' ) || - // Ignore any line breaks that are not inserted by us. - ( tagName === 'br' && - ! node.getAttribute( 'data-rich-text-line-break' ) ) ) + // Ignore any line breaks that are not inserted by us. + tagName === 'br' && + ! node.getAttribute( 'data-rich-text-line-break' ) ) { accumulateSelection( accumulator, node, range, createEmptyValue() ); continue; @@ -541,7 +539,9 @@ function createFromElement( { element, range, isEditableTree } ) { accumulateSelection( accumulator, node, range, value ); - if ( ! format ) { + // Ignore any placeholders, but keep their content since the browser + // might insert text inside them. + if ( ! format || node.getAttribute( 'data-rich-text-placeholder' ) ) { mergePair( accumulator, value ); } else if ( value.text.length === 0 ) { if ( format.attributes ) { From 39a93fd6c91bfec514732954987e43cbed444541 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 29 Feb 2024 18:35:47 +0200 Subject: [PATCH 2/2] Adjust comment --- packages/rich-text/src/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rich-text/src/create.js b/packages/rich-text/src/create.js index 0eaec892b155d9..3629ff8c60a749 100644 --- a/packages/rich-text/src/create.js +++ b/packages/rich-text/src/create.js @@ -540,7 +540,7 @@ function createFromElement( { element, range, isEditableTree } ) { accumulateSelection( accumulator, node, range, value ); // Ignore any placeholders, but keep their content since the browser - // might insert text inside them. + // might insert text inside them when the editable element is flex. if ( ! format || node.getAttribute( 'data-rich-text-placeholder' ) ) { mergePair( accumulator, value ); } else if ( value.text.length === 0 ) {