mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-01 17:22:42 +00:00
Merge pull request #2839 from naturalcrit/ChangeTabToSpaces
Custom function to use spaces for indent
This commit is contained in:
@@ -97,11 +97,14 @@ const CodeEditor = createClass({
|
|||||||
this.codeMirror = CodeMirror(this.refs.editor, {
|
this.codeMirror = CodeMirror(this.refs.editor, {
|
||||||
lineNumbers : true,
|
lineNumbers : true,
|
||||||
lineWrapping : this.props.wrap,
|
lineWrapping : this.props.wrap,
|
||||||
indentWithTabs : true,
|
indentWithTabs : false,
|
||||||
tabSize : 2,
|
tabSize : 2,
|
||||||
|
smartIndent : false,
|
||||||
historyEventDelay : 250,
|
historyEventDelay : 250,
|
||||||
scrollPastEnd : true,
|
scrollPastEnd : true,
|
||||||
extraKeys : {
|
extraKeys : {
|
||||||
|
'Tab' : this.indent,
|
||||||
|
'Shift-Tab' : this.dedent,
|
||||||
'Ctrl-B' : this.makeBold,
|
'Ctrl-B' : this.makeBold,
|
||||||
'Cmd-B' : this.makeBold,
|
'Cmd-B' : this.makeBold,
|
||||||
'Ctrl-I' : this.makeItalic,
|
'Ctrl-I' : this.makeItalic,
|
||||||
@@ -171,6 +174,19 @@ const CodeEditor = createClass({
|
|||||||
this.updateSize();
|
this.updateSize();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
indent : function () {
|
||||||
|
const cm = this.codeMirror;
|
||||||
|
if (cm.somethingSelected()) {
|
||||||
|
cm.execCommand('indentMore');
|
||||||
|
} else {
|
||||||
|
cm.execCommand('insertSoftTab');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
dedent : function () {
|
||||||
|
this.codeMirror.execCommand('indentLess');
|
||||||
|
},
|
||||||
|
|
||||||
makeHeader : function (number) {
|
makeHeader : function (number) {
|
||||||
const selection = this.codeMirror.getSelection();
|
const selection = this.codeMirror.getSelection();
|
||||||
const header = Array(number).fill('#').join('');
|
const header = Array(number).fill('#').join('');
|
||||||
|
|||||||
Reference in New Issue
Block a user