continuation for ordered lists

This commit is contained in:
Gamosoft 2026-04-13 17:12:04 +02:00
parent 52129a8868
commit f137ff9562
3 changed files with 14 additions and 3 deletions

View File

@ -33,7 +33,7 @@
- **Visual tree view** - Expandable/collapsible navigation - **Visual tree view** - Expandable/collapsible navigation
- **Hide system folders** - Toggle to hide `_attachments`, `_templates` and other underscore-prefixed folders from sidebar - **Hide system folders** - Toggle to hide `_attachments`, `_templates` and other underscore-prefixed folders from sidebar
- **Tab inserts tab** - Toggle to make Tab key insert a tab character in the editor instead of changing focus - **Tab inserts tab** - Toggle to make Tab key insert a tab character in the editor instead of changing focus
- **List & quote continuation (Enter)** - At the end of a line, Enter continues blockquotes (`>`), bullets (`-` / `*` / `+`), and task lists (`- [ ]` / `- [x]`); pressing Enter again on an empty continued line exits the list or quote. Disabled inside fenced code blocks and when using Shift+Enter (plain newline) - **List & quote continuation (Enter)** - At the end of a line, Enter continues blockquotes (`>`), bullets (`-` / `*` / `+`), ordered lists (`1.` / `1)`), and task lists (`- [ ]` / `- [x]`); pressing Enter again on an empty continued line exits the list or quote. Disabled inside fenced code blocks and when using Shift+Enter (plain newline)
### Export & Print ### Export & Print
- **HTML Export** - Download notes as standalone HTML files with all styling, images, diagrams, and math embedded - **HTML Export** - Download notes as standalone HTML files with all styling, images, diagrams, and math embedded

View File

@ -859,7 +859,7 @@ function noteApp() {
}, },
/** /**
* Enter: continue blockquote / bullet / task list; second Enter on empty item exits (see editor-markdown-continue.js). * Enter: continue blockquote / bullet / ordered list / task list; second Enter on empty item exits (see editor-markdown-continue.js).
*/ */
handleEditorEnterKey(event) { handleEditorEnterKey(event) {
if (typeof EditorMarkdownContinue === 'undefined') return; if (typeof EditorMarkdownContinue === 'undefined') return;

View File

@ -1,5 +1,5 @@
/** /**
* Markdown editor helpers: Enter continues blockquotes, bullets, and task lists. * Markdown editor helpers: Enter continues blockquotes, bullets, ordered lists, and task lists.
* Plain functions only; no DOM. Used by app.js handleEditorEnterKey. * Plain functions only; no DOM. Used by app.js handleEditorEnterKey.
*/ */
(function (global) { (function (global) {
@ -70,6 +70,17 @@
return { continuePrefix: quoteFull + inner + marker, isEmpty }; return { continuePrefix: quoteFull + inner + marker, isEmpty };
} }
const orderedMatch = rest.match(/^(\s*)(\d+)([.)])\s+(.*)$/);
if (orderedMatch) {
const inner = orderedMatch[1];
const num = parseInt(orderedMatch[2], 10);
const sep = orderedMatch[3];
const cont = orderedMatch[4];
const marker = (num + 1) + sep + ' ';
const isEmpty = cont.trim() === '';
return { continuePrefix: quoteFull + inner + marker, isEmpty };
}
if (quoteFull) { if (quoteFull) {
const isEmpty = rest.trim() === ''; const isEmpty = rest.trim() === '';
return { continuePrefix: quoteFull, isEmpty }; return { continuePrefix: quoteFull, isEmpty };