mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-11 19:52:41 +00:00
increment ordered list numbering
This commit is contained in:
@@ -112,12 +112,16 @@ const CodeEditor = createClass({
|
|||||||
const newSelection = this.codeMirror.getSelection();
|
const newSelection = this.codeMirror.getSelection();
|
||||||
|
|
||||||
const regex = /^\d+\.\s|^-\s/gm;
|
const regex = /^\d+\.\s|^-\s/gm;
|
||||||
console.log(regex);
|
|
||||||
if(newSelection.match(regex) != null){ // if selection IS A LIST
|
if(newSelection.match(regex) != null){ // if selection IS A LIST
|
||||||
this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around');
|
this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around');
|
||||||
} else { // if selection IS NOT A LIST
|
} else { // if selection IS NOT A LIST
|
||||||
listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around') :
|
listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, `- `), 'around') :
|
||||||
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '1. '), 'around');
|
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, (()=>{
|
||||||
|
let n = 1;
|
||||||
|
return ()=>{
|
||||||
|
return `${n++}. `;
|
||||||
|
};
|
||||||
|
})()), 'around');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user