Skip to content
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

Paste: detect single line and treat as inline text #10614

Merged
merged 1 commit into from
Oct 16, 2018

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Oct 15, 2018

Description

Fixes #6555.

If the pasted content results in one block, and the plain text version has no line breaks, then paste as inline text if mode is set to AUTO.

This PR is block agnostic compared to #5354, because it checks the original plain text.

How has this been tested?

See #6555 and #5354.

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.

@ellatrix ellatrix self-assigned this Oct 15, 2018
@ellatrix ellatrix requested review from mcsf, mtias and a team October 15, 2018 11:57
Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. :)


// If we're allowed to return inline content and there is only one block
// and the original plain text content does not have any line breaks, then
// treat it as inline paste.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a good set of conditions to have in general, even regardless of the very specific issue this is targeting. I'm racking my brains for any unintended consequences this may have.

expect( console ).toHaveLogged();
} );

it( 'should parse Markdown with HTML', () => {
const filtered = rawHandler( {
HTML: '',
plainText: '# Some <em>heading</em>',
plainText: '# Some <em>heading</em>\n\nA paragraph.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this test changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this specific test tests Markdown parsing, which together with this PR would only result into a heading if there's multiple lines paste.

@ellatrix ellatrix merged commit e07bc3e into master Oct 16, 2018
@ellatrix ellatrix deleted the try/single-line-paste branch October 16, 2018 09:15
@mtias
Copy link
Member

mtias commented Oct 16, 2018

This is a great small change, thanks.

@mtias mtias added this to the 4.1 - UI freeze milestone Oct 18, 2018
@paaljoachim
Copy link
Contributor

Please add the ability (sometime down the road...:) to select between bullets and other kinds of icons. For instance numbers, stars etc. Thanks.

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

Successfully merging this pull request may close these issues.

Paste: Single-line pastes should conform to current block
4 participants