[2.x] Continue lists when pressing Enter in the Markdown editor#4778
Open
linkrobins wants to merge 1 commit into
Open
[2.x] Continue lists when pressing Enter in the Markdown editor#4778linkrobins wants to merge 1 commit into
linkrobins wants to merge 1 commit into
Conversation
Pressing Enter inside a list item now inserts the next list marker instead of a plain newline: ordered lists increment the number (1. -> 2. -> 3.) and unordered lists repeat the bullet. Pressing Enter on an empty item ends the list. Leading indentation is preserved, and the handler ignores modifier combinations (Ctrl/Cmd/Shift/Alt+Enter) and IME composition. Previously the only way to add a numbered item was to re-click the toolbar button, which always produced "1.", so multi-item numbered lists were effectively impossible. Fixes flarum#4232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4232
Changes proposed in this pull request
The Markdown editor never continued lists when pressing Enter — it just inserted a plain newline. So the only way to add a numbered item was to re-click the toolbar button, which always emits
1.for the current line. The result was that you couldn't build a1./2./3.list by typing, which is what #4232 reports.This adds list continuation to the editor's existing
keyHandlersextender (the same place the bold/italic shortcuts live, so core stays generic). On a plain Enter inside a list item it now:1. a→2.→3.(also handles the1)delimiter and 9 → 10);-,*,+);This mirrors the list-continuation behaviour people expect from GitHub's editor and most Markdown editors.
Reviewers should focus on
extensions/markdown/js/src/common/index.tsx— thecontinueListhandler and its registration. Thedistchanges are the rebuilt bundle.keyHandlersonBasicEditorDriveris the right home for this vs. core. I kept it in the markdown extension since list markers are Markdown syntax.Confirmed
Testing
Verified manually in a 2.0.0-rc.4 forum (with the rich-text editor disabled so the Markdown textarea editor is active): typing a numbered list and pressing Enter now produces
1.,2.,3.; unordered lists repeat the bullet; and pressing Enter on an empty item ends the list.