forgejo/web_src/js/features/comp
Danko Aleksejevs 221ca0c404 Implement tab indentation and list continuation in the new editor (#3848, #3849) (#4072)
This overrides handling of Tab and Enter keys in the ComboMarkdownEditor, so that:

* 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.

Since Tab "capture" can interfere with keyboard navigation, it's only done if there was any previous input in the textarea or if it was selected with a pointer. Additionally, presing Esc will make the textarea lose focus, resuming tab navigation. This seems adequate to me, but I might be wrong.

Had to use the "deprecated" execCommand method, since anything else I tried messes up the undo history. There's a fallback for when (if?) it's actually removed.

Only tested in desktop Firefox and Chrome so far.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4072
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Beowulf <beowulf@noreply.codeberg.org>
Co-authored-by: Danko Aleksejevs <danko@very.lv>
Co-committed-by: Danko Aleksejevs <danko@very.lv>
2024-06-15 13:40:31 +00:00
..
ComboMarkdownEditor.js Implement tab indentation and list continuation in the new editor (#3848, #3849) (#4072) 2024-06-15 13:40:31 +00:00
ConfirmModal.js Change green buttons to primary color (#27099) 2023-09-18 22:05:31 +00:00
EasyMDEToolbarActions.js s/Gitea/Forgejo in various log messages and comments 2024-04-21 21:26:15 +05:00
LabelEdit.js replace jquery-minicolors with coloris (#30055) 2024-04-07 11:02:33 +02:00
Paste.js Support pasting URLs over markdown text (#29566) 2024-03-11 23:36:59 +07:00
QuickSubmit.js Remove jQuery from the "quick submit" handler (#29200) 2024-02-17 23:24:31 +01:00
ReactionSelector.js Remove jQuery class from the reaction selector (#30138) 2024-03-30 07:17:31 +01:00
SearchUserBox.js Refactor all .length === 0 patterns in JS (#30045) 2024-03-30 07:17:30 +01:00
TextExpander.js
WebHookEditor.js Fix various loading states, remove .loading class (#29920) 2024-03-26 19:04:26 +01:00