1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-09-15 18:56:59 +00:00

Remove tab key handling in markdown editor, add toolbar buttons instead, re #4072 #4142 (#4263)

We haven't decided much (to my knowledge), and I've been using the main branch in production (as one does) and found out even I myself rely on Tab sometimes working to move focus and have been caught off guard by it indenting lines instead.

So this removes Tab handling and instead adds two new buttons to the toolbar. The indentation logic is unchanged (other than now focusing the textarea during button handling, to ensure execCommand works, and thus undo history is preserved).

I'm not sure which terminology to use in tooltips. Could also add keyboard shortcuts for the whole toolbar eventually, but as is this is hopefully an better solution to the problems I previously created than un-merging the whole thing :)

<img width="414" alt="Screenshot with two new buttons" src="/attachments/b7af3aa4-a195-48d1-be0a-1559f25dce8e">

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4263
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Danko Aleksejevs <danko@very.lv>
Co-committed-by: Danko Aleksejevs <danko@very.lv>
This commit is contained in:
Danko Aleksejevs 2024-06-30 13:03:32 +00:00 committed by Earl Warren
parent 7b80ac476f
commit 36b6444f34
6 changed files with 38 additions and 49 deletions

View file

@ -1,7 +1,5 @@
Added handling of Tab and Enter keys to the new Markdown editor, in line with what standalone text editors usually do. This is mostly focused on quickly writing and rearranging lists.
- Pressing Tab prepending 4 spaces to the line under cursor, or all the lines in the selection.
- Pressing Shift+Tab removes up to 4 spaces.
- Pressing Enter repeats any indentation and a "repeatable" prefix (list or blockquote) from the current line.
- To avoid interfering with keyboard navigation, the Tab presses are only handled once there has been some other interaction with the element after focusing.
- Pressing Escape removes focus from the editor and resumes default Tab navigation.
- Added Enter key handling to the new Markdown editor ([#4072](https://codeberg.org/forgejo/forgejo/pulls/4072)):
- Pressing Enter while in a list, quote or code block will copy the prefix to the new line.
- Ordered list index will be increased for the new line, and task list "checkbox" will be unchecked.
- Added indent/unindent function for a line or selection.
- Currently available as toolbar buttons ([#4263](https://codeberg.org/forgejo/forgejo/pulls/4263))