framework icon indicating copy to clipboard operation
framework copied to clipboard

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

Open karl-bullock opened this issue 5 months ago • 0 comments

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. a → 2. → 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

  • [x] Frontend changes: tested in the latest Firefox and Chrome.
  • [x] Translations added for any user-facing text — N/A (no new strings).
  • [x] 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.

karl-bullock avatar Jun 22 '26 22:06 karl-bullock