Skip to content

Commit

Permalink
Rich text: fix typing into empty flex element (#59473)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mgrmjp <miikkamakela@git.wordpress.org>
  • Loading branch information
8 people authored Mar 1, 2024
1 parent 44b5cd5 commit 1979209
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 when the editable element is flex.
if ( ! format || node.getAttribute( 'data-rich-text-placeholder' ) ) {
mergePair( accumulator, value );
} else if ( value.text.length === 0 ) {
if ( format.attributes ) {
Expand Down

0 comments on commit 1979209

Please sign in to comment.