0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Custom function to use spaces for indent

This commit is contained in:
Trevor Buckner
2023-05-20 01:24:36 -04:00
parent 95376db055
commit 57eea5c69f

View File

@@ -97,11 +97,13 @@ const CodeEditor = createClass({
this.codeMirror = CodeMirror(this.refs.editor, {
lineNumbers : true,
lineWrapping : this.props.wrap,
indentWithTabs : true,
indentWithTabs : false,
tabSize : 2,
historyEventDelay : 250,
scrollPastEnd : true,
extraKeys : {
'Tab' : this.indent,
'Shift-Tab' : this.dedent,
'Ctrl-B' : this.makeBold,
'Cmd-B' : this.makeBold,
'Ctrl-I' : this.makeItalic,
@@ -171,6 +173,19 @@ const CodeEditor = createClass({
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) {
const selection = this.codeMirror.getSelection();
const header = Array(number).fill('#').join('');