0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 15:42:39 +00:00

Merge pull request #1078 from RKuerten/update-b-i

Updated makeBold and makeItalic functions
This commit is contained in:
Trevor Buckner
2020-10-28 22:26:49 -04:00
committed by GitHub

View File

@@ -46,11 +46,19 @@ const CodeEditor = createClass({
makeBold : function() { makeBold : function() {
const selection = this.codeMirror.getSelection(); const selection = this.codeMirror.getSelection();
this.codeMirror.replaceSelection(`**${selection}**`, 'around'); this.codeMirror.replaceSelection(`**${selection}**`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
}
}, },
makeItalic : function() { makeItalic : function() {
const selection = this.codeMirror.getSelection(); const selection = this.codeMirror.getSelection();
this.codeMirror.replaceSelection(`*${selection}*`, 'around'); this.codeMirror.replaceSelection(`*${selection}*`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
}
}, },
componentWillReceiveProps : function(nextProps){ componentWillReceiveProps : function(nextProps){