diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.ts b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.ts index 395e2f92e9..81f6815b90 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.ts +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.ts @@ -1,3 +1,5 @@ +import markdownUtils from '@joplin/lib/markdownUtils'; + // Helper functions that use the cursor export default function useCursorUtils(CodeMirror: any) { @@ -78,6 +80,8 @@ export default function useCursorUtils(CodeMirror: any) { for (let i = 0; i < selectedStrings.length; i++) { const selected = selectedStrings[i]; + let num = markdownUtils.olLineNumber(string1); + const lines = selected.split(/\r?\n/); // Save the newline character to restore it later const newLines = selected.match(/\r?\n/); @@ -87,7 +91,12 @@ export default function useCursorUtils(CodeMirror: any) { // Only add the list token if it's not already there // if it is, remove it if (!line.startsWith(string1)) { - lines[j] = string1 + line; + if (num) { + lines[j] = `${num.toString()}. ${line}`; + num++; + } else { + lines[j] = string1 + line; + } } else { lines[j] = line.substr(string1.length, line.length - string1.length); }