1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Code style fixes

This commit is contained in:
kostaldavid8
2017-02-15 23:30:56 +01:00
parent e68d535fa2
commit 77eb19af40

View File

@@ -57,32 +57,43 @@ export default class CodeEditor extends React.Component {
inputStyle: 'textarea',
extraKeys: {
Tab: function (cm) {
let cursor = cm.getCursor()
let line = cm.getLine(cursor.line)
const cursor = cm.getCursor()
const line = cm.getLine(cursor.line)
if (cm.somethingSelected()) cm.indentSelection('add')
else {
let tabs = cm.getOption('indentWithTabs')
const tabs = cm.getOption('indentWithTabs')
if (line.trimLeft() === '- ' || line.trimLeft() === '* ') {
cm.execCommand('goLineStart')
if (tabs) cm.execCommand('insertTab'); else cm.execCommand('insertSoftTab')
if (tabs) {
cm.execCommand('insertTab')
} else {
cm.execCommand('insertSoftTab')
}
cm.execCommand('goLineEnd')
} else {
if (tabs) cm.execCommand('insertTab'); else cm.execCommand('insertSoftTab')
if (tabs) {
cm.execCommand('insertTab')
} else {
cm.execCommand('insertSoftTab')
}
}
}
},
'Cmd-T': function (cm) {
// Do nothing
},
Enter: function (cm) {
let cursor = cm.getCursor()
let line = cm.getLine(cursor.line)
let dash = line.trim().startsWith('- ')
if ((line.trim().startsWith('- ') || line.trim().startsWith('* '))) {
Enter: (cm) => {
const cursor = cm.getCursor()
const line = cm.getLine(cursor.line)
const dash = line.trim().startsWith('- ')
if (line.trim().startsWith('- ') || line.trim().startsWith('* ')) {
cm.execCommand('newlineAndIndent')
let range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length}
console.log(range)
if (dash) cm.replaceRange('- ', range); else cm.replaceRange('* ', range)
const range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length}
if (dash) {
cm.replaceRange('- ', range)
} else {
cm.replaceRange('* ', range)
}
} else {
cm.execCommand('newlineAndIndent')
}