wordpress-mobile / WordPress-Editor-iOS

⛔️ [DEPRECATED] A reusable iOS rich text editor component.
GNU General Public License v2.0
1.06k stars 210 forks source link

Added hardware keyboard shortcuts for iPad #820

Closed frosty closed 8 years ago

frosty commented 8 years ago

Fixes #806. I've added keyboard shortcuts for iPads using hardware keyboards.

I've used shortcut keys they either: match system defaults (bold / underline), match other third party apps (bullet and ordered list shortcuts match iA Writer), or I've tried to pick something that makes sense where I couldn't find any precedent. Here's the initial selection that I've added:

keyboard-shortcuts

To test: Try to use each of the shortcuts listed above (you can hold down Command in the app to view the shortcuts). Test with text selected and without.

Also, please let me know if you think any of the shortcut keys should be changed to something else!

Needs Review: @SergioEstevao Thanks!

SergioEstevao commented 8 years ago

@frosty Do you mind adding these shortcuts to the legacy editor also?

frosty commented 8 years ago

@SergioEstevao I've managed to add support to the legacy editor. I had to add a UITextView subclass, and I've explained the reason for that in its documentation comments.

SergioEstevao commented 8 years ago

@frosty I tested it a bit more on the device and found the following issues:

frosty commented 8 years ago

Thanks for the comments, @SergioEstevao – sorry for the delay in replying!

on the visual editor, when you use a shortcut, the corresponding icon on the toolbar should be activated

This is working for me – can you confirm that it's definitely not for you? I can record a GIF / video if necessary.

on the visual editor, the shortcuts don't work on the HTML mode

I've taken a look at this and it seems to be the same issue as with the legacy editor: HTML uses a UITextView, which suffers from the same iOS 9 bug. I'm just thinking about the best way to approach fixing this in both places (alongside working on other stuff), and I'll try and get something pushed up soon!

frosty commented 8 years ago

@SergioEstevao I've been looking into highlighting the toolbar buttons, and the problem only affects the Bold and Italic buttons. It's the same iOS 9 bug, where our custom methods for these shortcuts aren't called. The issue is that we seem to have no way of knowing then the user's pressed the keyboard shortcut. I've even hooked up the editor to Safari's inspector, and no javascript events get fired when you press Cmd+B/ Cmd+I.

It's up to you whether you want to proceed without these two buttons getting highlighted as soon as you press the shortcut? They do highlight once you start pressing other keys, and as you noted the B / I icons on the top of the keyboard get highlighted too. I think the benefit of having the shortcuts in the first place outweighs these few issues.

SergioEstevao commented 8 years ago

Ok, let's proceed with this anyway I think it will be good for our users with keyboards, even if they are few of them. :shipit:

frosty commented 8 years ago

Thanks @SergioEstevao!