New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line break insertion #10297

Merged
merged 5 commits into from Oct 4, 2018

Conversation

Projects
None yet
2 participants
@iseulde
Member

iseulde commented Oct 3, 2018

Description

Fixes an issue where inserting like breaks would throw an error. This either happens when pressing shift+enter in a rich text field that can be split, like a paragraph, or when pressing enter in a rich text field that cannot be split, like a caption.

  1. It replaces the TinyMCE command to insert a line break with rich text value helpers.
  2. "to dom" functionality is update to handle selection on br elements.
  3. "create" tests are now reused for "to dom", to ensure the other way around has enough coverage.
  4. A few e2e tests are added.

How has this been tested?

Press enter in e.g. a caption. A line break should be added.

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@iseulde iseulde changed the title from Fix line line break insertion to Fix line break insertion Oct 3, 2018

@iseulde iseulde added this to the 4.0 milestone Oct 3, 2018

@iseulde iseulde requested a review from WordPress/gutenberg-core Oct 3, 2018

@iseulde iseulde referenced this pull request Oct 4, 2018

Open

Fix buggy behaviour on fast enter to split blocks #10328

0 of 4 tasks complete

@iseulde iseulde self-assigned this Oct 4, 2018

@mcsf

mcsf approved these changes Oct 4, 2018

Raised some questions, but aside from those it looks good to me.

Just noting that I get deprecation notices in Image, though:

screenshot 2018-10-04 at 11 57 34

Show outdated Hide outdated test/e2e/specs/writing-flow.test.js Outdated
if ( this.props.onSplit && isEmptyLine( record ) ) {
this.props.onSplit( ...split( record ).map( this.valueToFormat ) );
} else {
this.onChange( insert( record, '\u2028' ) );

This comment has been minimized.

@mcsf

mcsf Oct 4, 2018

Contributor

Why Unicode 2028 instead of a plain (ASCII-level) line break?

@mcsf

mcsf Oct 4, 2018

Contributor

Why Unicode 2028 instead of a plain (ASCII-level) line break?

This comment has been minimized.

@iseulde

iseulde Oct 4, 2018

Member

Because we're using that to delimit lines in multiline values. We could probably benefit from a helper or a constant...

@iseulde

iseulde Oct 4, 2018

Member

Because we're using that to delimit lines in multiline values. We could probably benefit from a helper or a constant...

This comment has been minimized.

@iseulde

iseulde Oct 4, 2018

Member

And \n are used for single line breaks which convert to <br> elements.

@iseulde

iseulde Oct 4, 2018

Member

And \n are used for single line breaks which convert to <br> elements.

This comment has been minimized.

@mcsf

mcsf Oct 4, 2018

Contributor

That's fair, but let's add a comment for it.

@mcsf

mcsf Oct 4, 2018

Contributor

That's fair, but let's add a comment for it.

This comment has been minimized.

@mcsf

mcsf Oct 4, 2018

Contributor

Comment then 🚢 🚢 !

@mcsf

mcsf Oct 4, 2018

Contributor

Comment then 🚢 🚢 !

@iseulde

This comment has been minimized.

Show comment
Hide comment
@iseulde

iseulde Oct 4, 2018

Member

Just noting that I get deprecation notices in Image, though:

Yes, noticed this with Jorge the other day, will fix separately.

Member

iseulde commented Oct 4, 2018

Just noting that I get deprecation notices in Image, though:

Yes, noticed this with Jorge the other day, will fix separately.

@iseulde iseulde merged commit fb135fb into master Oct 4, 2018

2 checks passed

codecov/project 49.25% (+0.03%) compared to 557dccc
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@iseulde iseulde deleted the fix/rich-text-br branch Oct 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment