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

finish UL creation/removal function

This commit is contained in:
Gazook89
2021-09-28 11:19:02 -05:00
parent 41609f90ea
commit 6717692187

View File

@@ -104,17 +104,18 @@ const CodeEditor = createClass({
},
makeUnOrderedList : function() {
const isList = /^-\s/gm;
const selectionStart = this.codeMirror.getCursor('from');
const selectionEnd = this.codeMirror.getCursor('to');
const selection = this.codeMirror.setSelection(
this.codeMirror.setSelection(
{ line: selectionStart.line, ch: 0 },
{ line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length });
console.log(selectionStart, selectionEnd, selection);
if(isList.test(this.codeMirror.getSelection()) == true){
console.log('is list');
{ line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }
);
const isUL = /^-\s/gm;
const newSelection = this.codeMirror.getSelection();
if(newSelection.match(isUL) == null){
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around');
} else {
console.log('is not a list');
this.codeMirror.replaceSelection(newSelection.replace(isUL, ''), 'around');
}
},