0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

increment ordered list numbering

This commit is contained in:
Gazook89
2021-09-28 16:09:00 -05:00
parent 63c59a223a
commit 40a75b9b27

View File

@@ -112,12 +112,16 @@ const CodeEditor = createClass({
const newSelection = this.codeMirror.getSelection();
const regex = /^\d+\.\s|^-\s/gm;
console.log(regex);
if(newSelection.match(regex) != null){ // if selection IS A LIST
this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around');
} else { // if selection IS NOT A LIST
listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around') :
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '1. '), 'around');
listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, `- `), 'around') :
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, (()=>{
let n = 1;
return ()=>{
return `${n++}. `;
};
})()), 'around');
}
},