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

Text Block: When splitting a text block, avoid empty paragraphs at the begining of the created block #553

Merged
merged 2 commits into from
Apr 28, 2017

Conversation

youknowriad
Copy link
Contributor

closes #543

Testing instructions

When putting the cursor in an empty line of a text block and splitting this text block, the empty line should be dropped from the created block.

@youknowriad youknowriad added [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended labels Apr 28, 2017
@youknowriad youknowriad self-assigned this Apr 28, 2017
@youknowriad youknowriad requested a review from mtias April 28, 2017 14:06
@@ -170,13 +170,17 @@ export default class Editable extends wp.element.Component {
return;
}
const before = getHtml( beforeNodes.slice( 0, beforeNodes.length - 1 ) );
const after = getHtml( childNodes.slice( splitIndex ).reduce( ( memo, node ) => {
Copy link
Member

Choose a reason for hiding this comment

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

A comment explaining the why could be useful for the future.

@youknowriad youknowriad force-pushed the fix/empty-paragraph-when-splitting branch from 0ffc5d7 to 4d64739 Compare April 28, 2017 14:14
@mtias
Copy link
Member

mtias commented Apr 28, 2017

Mmm, this is now creating two empty paragraphs on second enter and not splitting :)

@youknowriad
Copy link
Contributor Author

@mtias Yeah sorry, small typo fixed in 17bf307

@mtias
Copy link
Member

mtias commented Apr 28, 2017

Nice, looks good to me. 🚢

@youknowriad youknowriad merged commit 92be486 into master Apr 28, 2017
@youknowriad youknowriad deleted the fix/empty-paragraph-when-splitting branch April 28, 2017 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing double enter between two paragraphs of a text block
2 participants