-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Keep styling after spliting a block #14464
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
Conversation
|
@Jackie6 Thanks for taking this on! I really appreciate you jumping in and contributing. 🎉 I didn't even think about what should happen if the word or paragraph is broken in the middle. Great exploration. Your PR looks fantastic with one exception: when I hit |
|
@mapk Hi Mark! Thanks for your comments! Anyway, I can make another commit to fix the issue if needed. That is not hard. |
|
@Jackie6 I hear what you're saying. When the block retains some of the content (it splits) I'm fine with it keeping the styling, but when it's void of content, let's remove the styling as well. The reason I'm pushing for this is that I've seen people use this method to move a block down b/c they want a fresh block above it. Thanks so much for your time on this! |
db42494 to
c6b7185
Compare
|
This is working really well. There's just one last thing before merging it. When moving the paragraph down by pressing The first keyboard press is @Jackie6 can you make this last change? Just keep the styling when moving the paragraph back up to the original position. Is this possible? |
|
Hi @mapk Thanks for your ideas. I have modified the code to keep styling after pressing delete |
|
Oops, looks like we might have gotten some merge commits pollute the diff. Any chance you might be able to rebase this against the latest master @Jackie6? |
9eff729 to
430fd88
Compare
|
Hi @dmsnell I have rebased my code. Is this what you expect? |
|
much better @Jackie6 ! thanks |
mapk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested everything from a functional/design perspective and it works as expected. It's great! LGTM
|
Hi @aduth , thanks for your review, it is really helpful. You are right,
But I don't think the correct wat to apply the attributes of blockB into blockA is to check the mergeblocks method in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Yes, some of it overlaps with #14765. |
|
Hi @aduth @ellatrix I have reviewed the changed files in #14765 and #14464. I think Ella's pr is better since it fixed more issues. I do not have the permission and make a commit on Ella's pr. But I would advise Ella to change
to onSplit={ ( value ) => createBlock( name, value.length ? { ...attributes, content: value } : { content: value } ) }also change gutenberg/packages/block-library/src/paragraph/index.js Lines 147 to 151 in 3ceec4d
to merge( attributes, attributesToMerge ) {
return {
backgroundColor: attributes.content.length === 0 ? attributesToMerge.backgroundColor : attributes.backgroundColor,
textColor: attributes.content.length === 0 ? attributesToMerge.textColor : attributes.textColor,
fontSize: attributes.content.length === 0 ? attributesToMerge.fontSize : attributes.fontSize,
content: ( attributes.content || '' ) + ( attributesToMerge.content || '' ),
};
},Then, the issue #13740 will also be fixed and this pr can be closed. |
|
Ok, I actually took it over in e740fcf. Seemed like a trivial fix. :) |

Description
Fix #13740
How has this been tested?
Screenshots
Types of changes
Update the
splitBlockfunction such that it will make the styling of the new block same as the current one.Checklist: