Conversation
|
Oh, these could actually use something in the tooltip! |
|
I don't know if that lost commit makes sense. Can always remove it, or @jasmussen, feel free to edit. :) |
| { | ||
| icon: 'editor-bold', | ||
| title: __( 'Bold' ), | ||
| title: __( 'Bold — ⌘B' ), |
There was a problem hiding this comment.
Should we use ${ __( 'Bold') } — ⌘B instead? As we are not expecting keyboard shortcuts to be changed during translation, this way translations for 'Bold' get reused.
There was a problem hiding this comment.
Good point, though I'm not sure dash and order should not be translatable. Maybe we can just omit the shortcut itself from the translation.
There was a problem hiding this comment.
Should we use ${ __( 'Bold') } — ⌘B instead?
Alas, this wouldn't work for RTL languages like Hebrew and Arabic.
There was a problem hiding this comment.
I think it would be safe to use something like ${ __( 'Bold' ) } ${ __( '-' ) } ⌘B. This way translations are reused and we address the point raised by @iseulde.
Regarding the RTL point, It's a nice question, honestly, I don't know if in RTL normally the shortcuts appear inverted, but in LTR, if the shortcuts appeared like "⌘B — Bold" it would be ok so maybe in RTL both ways are also "ok". To be safe be on the safe side we can use the original version, I don't have a strong opinion here.
|
This is working really well for me. Except for access+c for code, I can't get that to work for some reason. Mac/chrome. I love that you added the keyboard shortcuts to the tooltips, starting work on #2980: However can we make it look like this instead? If not, then we should replace the — with a couple of spaces (like Is this doable? If not, then probably good to keep the shortcuts still, then we can look at improving the look in a separate PR. |
|
@jasmussen Updating the PR, but now wondering what colour you have in mind? :) |
|
@jasmussen I added it as a separate attribute on the toolbar/iconbutton/tooltip, so it can be styled all the same. Let me know if this is what you have in mind, and feel free to change to styles of course. :) Thank you! |
|
Ah, I missed your comment now, I'm so slow. |
|
Updated. :) |
I can't reproduce. Are you sure it's the right combination? I also found myself trying cmd+x before, which is cut. :D |
|
This looks amazing to me. @jorgefilipecosta does this particular layout fix issues with RTL?
I think the reason it's not working is that I have that keyboard shortcut assigned to the magnifier in OSX. If it works for another Mac user then 👍 👍 from me :D |
6fff91c to
ca593c5
Compare
|
Rebased. What's left here? |
Took it for a quick spin. Experience wise, this feels solid to me. I don't know if we need any more code reviewing. I would be happy to get this merged in sooner rather than later. If it needs a code review, @youknowriad can you take a look? Looks good to me. |
| { | ||
| icon: 'editor-bold', | ||
| title: __( 'Bold' ), | ||
| shortcut: '⌘B', |
There was a problem hiding this comment.
I'm concerned about the hard-coding of the modifier key as ⌘, which is meaningless to non-macOS users. IMO, this is a blocker.
There's precedent of cross-platform handling:
gutenberg/edit-post/keyboard-shortcuts.js
Lines 1 to 2 in ca593c5
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { primaryShortcut, primaryAltShortcut } from 'utils/keycodes'; |
There was a problem hiding this comment.
What's primaryAlt? So primary but not really? So secondary? 🤔
There was a problem hiding this comment.
Oops, it should totally be secondary.
utils/keycodes.js
Outdated
| * | ||
| * @return {string} The keyboard shortcut. | ||
| */ | ||
| export function metaShortcut( character, _isMacOS = isMacOS ) { |
There was a problem hiding this comment.
What will this be used for?
There was a problem hiding this comment.
If we want keyboard shortcuts using Ctrl+Q on Mac, though admittedly I don't see any yet. It'd be Windows+Q on Windows… should I just remove it?
There was a problem hiding this comment.
Yeah, I think across the whole application, we should only ever implement two combinations: primary and access.
utils/keycodes.js
Outdated
| * | ||
| * @return {string} The keyboard shortcut. | ||
| */ | ||
| export function primaryAccessShortcut( character, _isMacOS = isMacOS ) { |
There was a problem hiding this comment.
Could we drop this combination in favour of the standard access combination that is now called accessShortcut ?
There was a problem hiding this comment.
That'll change an existing keyboard shortcut: https://github.com/WordPress/gutenberg/blob/add/editable-shortcuts/edit-post/keyboard-shortcuts.js#L8
Which I presume has many modifiers as it isn't common. But we could call it tertiary. I am now realising I made a terrible API by surfacing its underlying implementation.
There was a problem hiding this comment.
I think we should change it be an access shortcut. It was just a random combination that didn't clash with anything.
There was a problem hiding this comment.
See #3755 (comment) for history on that.
No particular reason for that combination, it should be revised.
There was a problem hiding this comment.
There was a problem hiding this comment.
Would be nice to have a combo that is the same on all OS though. :)
There was a problem hiding this comment.
Ancient history: https://core.trac.wordpress.org/ticket/29558
There was a problem hiding this comment.
Oddly enough the Mu doesn't appear outside of Gutenberg. If I type Ctrl+Alt+M into this text field it seems like an invisible unicode character is inserted instead.
Looks like Cmd+Alt on Mac will work, though Cmd+Alt+M is also the shortcut to enable responsive design mode in Firefox so that's a bit annoying. 😆
Maybe this needs to stay a three-character combo, just to be safe?
There was a problem hiding this comment.
If there's one clash in that namespace, there's likely to be more. Would be nice to find a maximum two-modifier namespace that can be used in WordPress.
I wonder if we can adopt one of https://en.wikipedia.org/wiki/Access_key...
Curiously enough it list Ctrl+Alt as reserved on Firefox on Mac for accesskey, so I wonder why it decided to use that.
I'm fine with just picking one non primary combination in this PR and revise it later.
There was a problem hiding this comment.
Also if we change it at all, we can't use access in TinyMCE: https://github.com/tinymce/tinymce/blob/90a829b4ed7655d91f07df15056a805fa43d49f9/src/plugins/help/main/ts/data/KeyboardShortcuts.ts#L14
| { | ||
| icon: 'editor-strikethrough', | ||
| title: __( 'Strikethrough' ), | ||
| shortcut: primaryAltShortcut( 'D' ), |
There was a problem hiding this comment.
This should be accessShortcut, right? https://github.com/WordPress/gutenberg/pull/4411/files#diff-766381e792acf9d4c2505f3aeddcca7eR181
There was a problem hiding this comment.
Arg, yes, thanks, I think all these code names have confused my brain. Sorry! 😓
There was a problem hiding this comment.
Yeah, that's why I think two is enough for now. :) #4411 (comment)
11fbe65 to
e6e1e7b
Compare
e5a48d1 to
c62cd5f
Compare
|
I kept the codes as they were before but added the keycode/shortcut text functions that work across platforms. I tested the key combos here and they worked in Windows/Mac/Linux, Edge/Firefox/Chrome/Safari. It would be nice to simplify the shortcuts but I don't think there are simpler ones we can use that won't cause an error somewhere. 😢 So I think this is ready to go 😄 |
utils/keycodes.js
Outdated
| const isMac = _isMacOS(); | ||
|
|
||
| const alt = isMac ? '⌥' : 'Alt'; | ||
| const meta = isMac ? '⌃' : '⊞'; |
There was a problem hiding this comment.
Just to note: I know this is a common way to display shortcuts on the Mac, but my built-in keyboard doesn't have any of these symbols, so this always confuses me. 🙈
There was a problem hiding this comment.
There was a problem hiding this comment.
I don't mind keeping the command symbol since it's still on the keyboard (and I know that one), the rest I'm not so sure. I don't know how people make sense of the shortcuts shown on the Mac menus... :)
When I see ⌥ or ⌃ I just make a guess until I get what I want hahaha.
So... it's up to you. I just wanted to make a note here it may not make sense to some people.
There was a problem hiding this comment.
Not sure if someone will try to press the caret key. :D
There was a problem hiding this comment.
Yeah I was about to file an issue and ask people what they think, but I say we eschew Mac conventions here for usability. I'll keep the command glyph but change the rest to text. 👍
|
|
||
| export const ALT = 'alt'; | ||
| export const CTRL = 'ctrl'; | ||
| export const PRIMARY = 'mod'; |
There was a problem hiding this comment.
Minor: should this become 'primary'? Not that it matters. :)
There was a problem hiding this comment.
So I noticed "mod" was actually used as the key code in https://github.com/WordPress/gutenberg/pull/4411/files#diff-cb4a97a77964e94dc29c6d9caf74f9ccL6... I figured it was good to internally keep it as "mod".
|
@tofumatt I can't approve my own PR (Github doesn't let me), but it looks good to me! |
|
💥💥💥💥💥 |
| } | ||
|
|
||
| this.setState( { | ||
| isAddingLink: !! nextProps.formats.link && nextProps.formats.link.isAdding, |
There was a problem hiding this comment.
This change is causing issues to the format toolbar. When the modal is renrendered (it can happen when you move the mouse over a block), it disappears if you just clicked the link button.
That's because isAddingLink is a state value controlled from within this component without changing the formats on the RichText component.
|
|
||
| export const F10 = 121; | ||
|
|
||
| export const ALT = 'alt'; |
There was a problem hiding this comment.
Every other key exported in this module is its key code, yet for this and other modifiers we export a string? Even though Alt has a code (18)?
There was a problem hiding this comment.
I believe it's used to pass to mousetrap and tinymce which wouldn't accept the codes?
There was a problem hiding this comment.
Oops, I should have at least left a comment. I honestly forget at this point; it could have just been terrible newbie-ness. 😅
There was a problem hiding this comment.
These are a public API of @wordpress/keycodes, which describes exports as:
Contains keycodes constants for keyboard keys like DOWN, UP, ENTER, etc.
https://www.npmjs.com/package/@wordpress/keycodes
Yet...
import * as keycodes from '@wordpress/keycodes';
keycodes.DOWN // 40 ✅
keycodes.UP // 38 ✅
keycodes.ENTER // 13 ✅
keycodes.ALT // 'alt' 😱 |
I'm having trouble finding documentation on what all the new keycodes are for Gutenberg. I know how to add a code tag, but how do I actually make a code block? I can make a heading just by using markdown. Same with bolding stuff or making an ul or ol but not sure how to get the code block? |
|
@jcklpe A Code block can be added either using the inserter, or by key sequence using three tick (`) characters, then Enter. Inline code fragments can be made by typing "`", the code fragment, then a closing "`". My understanding is that a user guide should become available shortly in the Gutenberg Handbook. |
|
@aduth Awesome! I tried doing ``` like on github but duh, should have tried just one. Thanks! |
|
You should be able to insert a code block by typing |







Description
See #71.
This PR adds the remaining shortcuts for editable:
access+dfor strikethrough (<del>tag).access+cfor code.access+aandmeta+kto add a link.access+sto remove a link.accessmeansctrl+alton Mac andshift+alton Windows.metameanscmdon Mac andctrlon Windows.How Has This Been Tested?
access+dand the text should be struck through. Press it again and the formatting should be removed.access+xand the text should be code. Press it again and the formatting should be removed.access+aand the pop up to add a link should appear focussed.meta+kand the pop up to add a link should appear focussed.access+safter putting the caret on a link. The link should be removed.Checklist: