mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
This commit is contained in:
parent
69a4a895d4
commit
6272a2eb4f
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user