mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
Add bold/italic shortcuts, reposition renderer warning
This commit is contained in:
committed by
Scott Tolksdorf
parent
911d1d4f9c
commit
aafac16af2
@@ -30,7 +30,7 @@
|
|||||||
.ppr_msg{
|
.ppr_msg{
|
||||||
position : absolute;
|
position : absolute;
|
||||||
left : 0px;
|
left : 0px;
|
||||||
bottom : 0;
|
top : 0; // This obscures the horizonal scrollbar (when shown) when it's on the bottom
|
||||||
z-index : 1000;
|
z-index : 1000;
|
||||||
padding : 8px 10px;
|
padding : 8px 10px;
|
||||||
background-color : #333;
|
background-color : #333;
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ const CodeEditor = createClass({
|
|||||||
value : this.props.value,
|
value : this.props.value,
|
||||||
lineNumbers : true,
|
lineNumbers : true,
|
||||||
lineWrapping : this.props.wrap,
|
lineWrapping : this.props.wrap,
|
||||||
mode : this.props.language
|
mode : this.props.language,
|
||||||
|
extraKeys : {
|
||||||
|
'Ctrl-B' : this.makeBold,
|
||||||
|
'Ctrl-I' : this.makeItalic
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.codeMirror.on('change', this.handleChange);
|
this.codeMirror.on('change', this.handleChange);
|
||||||
@@ -38,6 +42,16 @@ const CodeEditor = createClass({
|
|||||||
this.updateSize();
|
this.updateSize();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeBold : function() {
|
||||||
|
const selection = this.codeMirror.getSelection();
|
||||||
|
this.codeMirror.replaceSelection(`**${selection}**`, 'around');
|
||||||
|
},
|
||||||
|
|
||||||
|
makeItalic : function() {
|
||||||
|
const selection = this.codeMirror.getSelection();
|
||||||
|
this.codeMirror.replaceSelection(`*${selection}*`, 'around');
|
||||||
|
},
|
||||||
|
|
||||||
componentWillReceiveProps : function(nextProps){
|
componentWillReceiveProps : function(nextProps){
|
||||||
if(this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
|
if(this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
|
||||||
this.codeMirror.setValue(nextProps.value);
|
this.codeMirror.setValue(nextProps.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user