Skip to content

[2.x] Continue lists when pressing Enter in the Markdown editor#4778

Open
linkrobins wants to merge 1 commit into
flarum:2.xfrom
linkrobins:fix/ordered-list-continuation
Open

[2.x] Continue lists when pressing Enter in the Markdown editor#4778
linkrobins wants to merge 1 commit into
flarum:2.xfrom
linkrobins:fix/ordered-list-continuation

Conversation

@linkrobins

Copy link
Copy Markdown
Contributor

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 a 1./2./3. list by typing, which is what #4232 reports.

This adds list continuation to the editor's existing keyHandlers extender (the same place the bold/italic shortcuts live, so core stays generic). On a plain Enter inside a list item it now:

  • continues ordered lists, incrementing the number — 1. a2. 3. (also handles the 1) delimiter and 9 → 10);
  • continues unordered lists, repeating the bullet (-, *, +);
  • ends the list when Enter is pressed on an empty item;
  • preserves leading indentation;
  • ignores Ctrl/Cmd/Shift/Alt+Enter (submit / soft newline) and IME composition, and only acts on a collapsed selection.

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 — the continueList handler and its registration. The dist changes are the rebuilt bundle.
  • Whether keyHandlers on BasicEditorDriver is the right home for this vs. core. I kept it in the markdown extension since list markers are Markdown syntax.

Confirmed

  • Frontend changes: tested in the latest Firefox and Chrome.
  • Translations added for any user-facing text — N/A (no new strings).
  • Backend changes — N/A.

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.

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
@linkrobins linkrobins requested a review from a team as a code owner June 22, 2026 22:13
@linkrobins linkrobins changed the title Continue lists when pressing Enter in the Markdown editor [2.x] Continue lists when pressing Enter in the Markdown editor Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numbered List Not Working in Editor

1 participant