When users select text and use CTRL/CMD + B, add the corresponding bold markdown formatting around the word:
**some bold text**
When users select text and use CTRL/CMD + I, add the corresponding italics markdown formatting around the word:
*some italics text*
If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.
New contributors please see our Developer's Guide.
I am giving this a shot.
When pressed again, should it undo bold/italic if selected text already has the markdown for it? or should it simply keep adding markdown on repeated hotkey presses?
@jp0707 github comments has this feature. They undo the bold/italic, and it's a good experience.
Implemented this for CreatePost and CreateComment components : https://github.com/jp0707/mattermost-webapp/commit/10c81fbf273e66aa1f4a79b3d94f62093d6f35d9
Now working on tests and docs.
@jp0707 @mkozakov @mattermod Is there any way to make this feature optional? The reason is that Ctrl-B is backspace within most text fields on a Mac. This breaks the former behavior which was compatibility with emacs-style keybindings (Ctrl-A, Ctrl-H, and the like all still work).
@jp0707 @mkozakov @mattermod Is there any way to make this feature optional? The reason is that Ctrl-B is backspace within most text fields on a Mac. This breaks the former behavior which was compatibility with emacs-style keybindings (Ctrl-A, Ctrl-H, and the like all still work).
on mac this feature would be triggered by CMD key not control
on mac this feature would be triggered by CMD key not control
I just tested it and it appears to be triggered by both CMD-B and CTRL-B. Compare to what CTRL-B does in most other textareas on a Mac. It is equivalent to left arrow, namely going back one character without deleting it.
Desired behavior: disable this for CTRL-B, keep it for CMD-B.
Thanks for the reports! That looks like an oversight with this feature since we have other shortcuts that properly respect cmd/ctrl depending on the OS. I filed a ticket to look into this further.
My bad for missing this. I think we can fix this using Utils.isMac()
. I can fix this if no one else is working on it yet. The only thing I'll need some help with is writing tests. Is there an example of test that simulates mac/non-mac environment?
If you'd like to work on it, that would be great. I didn't think about it when reviewing your PR, but there's a Utils.cmdOrCtrlPressed()
that should handle that automatically based on OS.
For testing, we'd usually just force Utils.isMac
to return true, but that doesn't really work when the key doesn't really exist outside Mac as far as I know. There are some E2E tests around that, but I think they need to be run on a Mac to work. Given we use cmdOrCtrlPressed
for other things, I think we can trust that at least as long as it works fine elsewhere.
This mac bug is fixed in https://github.com/mattermost/mattermost-webapp/pull/7125