mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
Reduce duplicate code
This commit is contained in:
@@ -45,23 +45,19 @@ const CodeEditor = createClass({
|
|||||||
|
|
||||||
makeBold : function() {
|
makeBold : function() {
|
||||||
const selection = this.codeMirror.getSelection();
|
const selection = this.codeMirror.getSelection();
|
||||||
|
this.codeMirror.replaceSelection(`**${selection}**`, 'around');
|
||||||
if(selection.length === 0){
|
if(selection.length === 0){
|
||||||
this.codeMirror.replaceSelection(`**${selection}**`, 'around');
|
|
||||||
const cursor = this.codeMirror.getCursor();
|
const cursor = this.codeMirror.getCursor();
|
||||||
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
|
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
|
||||||
} else {
|
|
||||||
this.codeMirror.replaceSelection(`**${selection}**`, 'around');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
makeItalic : function() {
|
makeItalic : function() {
|
||||||
const selection = this.codeMirror.getSelection();
|
const selection = this.codeMirror.getSelection();
|
||||||
|
this.codeMirror.replaceSelection(`*${selection}*`, 'around');
|
||||||
if(selection.length === 0){
|
if(selection.length === 0){
|
||||||
this.codeMirror.replaceSelection(`*${selection}*`, 'around');
|
|
||||||
const cursor = this.codeMirror.getCursor();
|
const cursor = this.codeMirror.getCursor();
|
||||||
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
|
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
|
||||||
} else {
|
|
||||||
this.codeMirror.replaceSelection(`*${selection}*`, 'around');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user