mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
finish UL creation/removal function
This commit is contained in:
@@ -104,17 +104,18 @@ const CodeEditor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
makeUnOrderedList : function() {
|
makeUnOrderedList : function() {
|
||||||
const isList = /^-\s/gm;
|
|
||||||
const selectionStart = this.codeMirror.getCursor('from');
|
const selectionStart = this.codeMirror.getCursor('from');
|
||||||
const selectionEnd = this.codeMirror.getCursor('to');
|
const selectionEnd = this.codeMirror.getCursor('to');
|
||||||
const selection = this.codeMirror.setSelection(
|
this.codeMirror.setSelection(
|
||||||
{ line: selectionStart.line, ch: 0 },
|
{ line: selectionStart.line, ch: 0 },
|
||||||
{ line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length });
|
{ line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }
|
||||||
console.log(selectionStart, selectionEnd, selection);
|
);
|
||||||
if(isList.test(this.codeMirror.getSelection()) == true){
|
const isUL = /^-\s/gm;
|
||||||
console.log('is list');
|
const newSelection = this.codeMirror.getSelection();
|
||||||
|
if(newSelection.match(isUL) == null){
|
||||||
|
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around');
|
||||||
} else {
|
} else {
|
||||||
console.log('is not a list');
|
this.codeMirror.replaceSelection(newSelection.replace(isUL, ''), 'around');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user