Repository navigation
RichText: add non breaking space shortcut on Windows - #43150
Conversation
|
Size Change: +173 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
| } | ||
|
|
||
| // Shift + Ctrl + Space shortcut is built in on the Mac. | ||
| if ( isAppleOS() ) { |
There was a problem hiding this comment.
Does it hurt to override the default?
There was a problem hiding this comment.
I deleted it, but I don't have a Mac, could you test it?
|
|
||
| return ( | ||
| <RichTextShortcut | ||
| type="primaryShift" |
There was a problem hiding this comment.
Btw, the original issue had a typo. It should be Shift+Alt+Space. But apparently Alt+Space also works so we could simplify it to just Alt+Space?
There was a problem hiding this comment.
As shown in this source, Alt+Space is often used to access the menu of the program itself.
For example, in Chrome, it would appear as follows (this was also the case in FireFox and Edge):
Shift+Alt+Space also showed the same behavior.
If we override this shortcut, we will not be able to access the browser menu unless we remove focus from RichText.
I recommend Ctrl+Shift+Space, which is a continuation of the Microsoft Word shortcut.
There was a problem hiding this comment.
Shift+Alt+Space has the same behaviour? I think it's fine to override the Shift combination then.
I think we should stick to an Alt combination because Alt indicates an alternative for the current key/character. I think this is the same for Windows? Alt combinations input different characters, whereas Ctrl is more for commands/controls.
There was a problem hiding this comment.
I think we should stick to an Alt combination because Alt indicates an alternative for the current key/character. I think this is the same for Windows? Alt combinations input different characters, whereas Ctrl is more for commands/controls.
Yes, that is correct.
But unfortunately, Alt+Space (Alt+Shift+Space) didn't respond to triggering RichtextShortcut, and the browser menu opens.
From my research here, it appears that Alt + Space is not a browser shortcut, but is implemented at the OS level.
Alt + Spacebar | Open the shortcut menu for the active window.
Then, possible patterns and possibilities are as follows.
- ✅
Ctrl + Shift + Space: Confirmed to work correctly - ✅
Ctrl + Space: Confirmed to work correctly - ❗
Shift + Space: Switch character width between full-width and half-width. (OS shortcut) - ❗
Ctrl + Space: Turn the Chinese input method editor (IME) on or off. (OS shortcut)
| "@wordpress/html-entities": "file:packages/html-entities", | ||
| "@wordpress/i18n": "file:packages/i18n", | ||
| "@wordpress/icons": "file:packages/icons", | ||
| "@wordpress/keycodes": "file:packages/keycodes", |
|
Ignore this message. Testing if this subscribes me in the mentioned notifications. @ellatrix |
| ), | ||
| }, | ||
| { | ||
| keyCombination: { modifier: 'primaryShift', character: 'SPACE' }, |
There was a problem hiding this comment.
Can we use a literal space here as you did below for the rich text shortcut?
There was a problem hiding this comment.
Ah, this is for displaying the shortcut? Sorry it wasn't clear from the code.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @rezeau, @pierrefrance, @burnuser, @zackkatz. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| name, | ||
| title, | ||
| tagName: 'span', | ||
| className: 'nbsp', |
There was a problem hiding this comment.
This could cause existing span tags with this class to be wrongly processed as this format. I wonder if we could set the tagName to nbsp to work around the rules. 🤔
There was a problem hiding this comment.
Even if I changed the tagName to nbsp, it worked fine! Does tagName not have to be an element that is allowed as HTML?
There was a problem hiding this comment.
Not if we're not going to use it 😄
Unlinked contributors: rezeau, pierrefrance, burnuser, zackkatz. Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: yankiara <yankiara@git.wordpress.org> Co-authored-by: tybor <tybor@git.wordpress.org> Co-authored-by: fr-laurentn <peexy@git.wordpress.org> Co-authored-by: TonyGravagno <starbuck@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: benjaminpwarren <benjpw@git.wordpress.org>


Fix: #18523
What?
This PR adds non-breaking space shortcut (Ctrl + Shift Space) for Windows.
Why?
As seen in the source here, this shortcut is well known in Word and its compatibility software and should be introduced in Gutenberg as well.
How?
I added a format type (
core/non-breaking-space) and appliedRichTextShortcutin it. This shortcut is built-in on Mac and valid only on Windows.However, this shortcut is not for formatting. It might not be necessary to add a format type, but
RichTextShortcutis used in only format types or blocks, and I couldn't find a way to implement it directly into RichText.At the same time, I added it to the keyboard shortcut modal. I think this should be no problem to display without limiting the OS.
Testing Instructions
Press
Ctrl+Shift+Spacein rich text.This behavior follows the behavior of Microsoft Word.
Screenshots or screencast
bdad4fc264ebf129bf30d4e8f42f849e.mp4