-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Editable: Fix splitting inline Editables using shift+enter #1299
Conversation
So, enter behaves as it does now, shift+enter splits is right away? |
I think I like this! Nice 👍 👍 |
@iseulde yes, that's the idea. |
70f9010
to
583e187
Compare
Testing |
@youknowriad I changed it slightly so |
@iseulde nice, thanks |
blocks/editable/index.js
Outdated
@@ -206,6 +206,14 @@ export default class Editable extends wp.element.Component { | |||
event.preventDefault(); | |||
event.stopImmediatePropagation(); | |||
} | |||
|
|||
if ( event.keyCode === ENTER && event.shiftKey && this.props.inline ) { |
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.
Can we include some more inline documentation describing what these various inline conditions are achieving? Seems like they'll be difficult to revisit in the future otherwise.
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.
Adding some.
There's another change that this PR is introducing: when you split with just enter, and merge the blocks back, there's a line break left over, whereas before it would merge without any line breaks and the caret at the place they are merged. |
8b78b58
to
fed0607
Compare
@iseulde Merging back without empty lines should be fixed now. |
blocks/editable/index.js
Outdated
@@ -207,6 +207,8 @@ export default class Editable extends wp.element.Component { | |||
event.stopImmediatePropagation(); | |||
} | |||
|
|||
// If we click shift+Enter on inline Editables, we should avoid creating `p` tags |
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.
It would also split two contenteditables into two, e.g. a heading will suddenly become two headings.
Works well in various browsers. |
closes #1243 #1254
In this PR, I'm proposing to split a text block if we hit shift+enter.
The current
shift+enter
behaviour is broken (see #1243 and #1254)