mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Changes to pass tests and lint code
This commit is contained in:
@@ -215,7 +215,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.editor = CodeMirror(this.refs.root, {
|
this.editor = CodeMirror(this.refs.root, {
|
||||||
rulers: buildCMRulers(rulers, enableRulers),
|
rulers: buildCMRulers(rulers, enableRulers),
|
||||||
value: this.props.value,
|
value: this.props.value,
|
||||||
linesHighlighted:this.props.linesHighlighted,
|
linesHighlighted: this.props.linesHighlighted,
|
||||||
lineNumbers: this.props.displayLineNumbers,
|
lineNumbers: this.props.displayLineNumbers,
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
theme: this.props.theme,
|
theme: this.props.theme,
|
||||||
@@ -242,7 +242,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.editor.on('focus', this.focusHandler)
|
this.editor.on('focus', this.focusHandler)
|
||||||
this.editor.on('blur', this.blurHandler)
|
this.editor.on('blur', this.blurHandler)
|
||||||
this.editor.on('change', this.changeHandler)
|
this.editor.on('change', this.changeHandler)
|
||||||
this.editor.on("gutterClick",this.highlightHandler)
|
this.editor.on('gutterClick', this.highlightHandler)
|
||||||
this.editor.on('paste', this.pasteHandler)
|
this.editor.on('paste', this.pasteHandler)
|
||||||
this.editor.on('contextmenu', this.contextMenuHandler)
|
this.editor.on('contextmenu', this.contextMenuHandler)
|
||||||
eventEmitter.on('top:search', this.searchHandler)
|
eventEmitter.on('top:search', this.searchHandler)
|
||||||
@@ -518,13 +518,13 @@ export default class CodeEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleHighlight (editor, changeObject) {
|
handleHighlight (editor, changeObject) {
|
||||||
let lines =editor.options.linesHighlighted
|
const lines = editor.options.linesHighlighted
|
||||||
if(!lines.includes(changeObject)){
|
if (!lines.includes(changeObject)) {
|
||||||
lines.push(changeObject)
|
lines.push(changeObject)
|
||||||
editor.addLineClass(changeObject,'text',"CodeMirror-activeline-background")
|
editor.addLineClass(changeObject, 'text', 'CodeMirror-activeline-background')
|
||||||
}else{
|
} else {
|
||||||
lines.splice(lines.indexOf(changeObject),1)
|
lines.splice(lines.indexOf(changeObject), 1)
|
||||||
editor.removeLineClass(changeObject,'text',"CodeMirror-activeline-background")
|
editor.removeLineClass(changeObject, 'text', 'CodeMirror-activeline-background')
|
||||||
}
|
}
|
||||||
if (this.props.onChange) {
|
if (this.props.onChange) {
|
||||||
this.props.onChange(editor)
|
this.props.onChange(editor)
|
||||||
@@ -566,7 +566,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
this.editor.setCursor(cursor)
|
this.editor.setCursor(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
restartHighlighting(){
|
restartHighlighting () {
|
||||||
this.editor.options.linesHighlighted = this.props.linesHighlighted
|
this.editor.options.linesHighlighted = this.props.linesHighlighted
|
||||||
this.initialHighlighting()
|
this.initialHighlighting()
|
||||||
}
|
}
|
||||||
@@ -708,11 +708,11 @@ export default class CodeEditor extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
initialHighlighting(){
|
initialHighlighting () {
|
||||||
var count = this.editor.lineCount(), i
|
const count = this.editor.lineCount()
|
||||||
for (i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
if(this.editor.options.linesHighlighted.includes(i)){
|
if (this.editor.options.linesHighlighted.includes(i)) {
|
||||||
this.editor.addLineClass(i,'text',"CodeMirror-activeline-background")
|
this.editor.addLineClass(i, 'text', 'CodeMirror-activeline-background')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export function createSnippetNote (storage, folder, dispatch, location, params,
|
|||||||
name: '',
|
name: '',
|
||||||
mode: config.editor.snippetDefaultLanguage || 'text',
|
mode: config.editor.snippetDefaultLanguage || 'text',
|
||||||
content: '',
|
content: '',
|
||||||
linesHighlighted:[],
|
linesHighlighted: []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
return (e) => {
|
return (e) => {
|
||||||
const snippets = this.state.note.snippets.slice()
|
const snippets = this.state.note.snippets.slice()
|
||||||
snippets[index].content = this.refs['code-' + index].value
|
snippets[index].content = this.refs['code-' + index].value
|
||||||
snippets[index].linesHighlighted=e.options.linesHighlighted
|
snippets[index].linesHighlighted = e.options.linesHighlighted
|
||||||
|
|
||||||
this.setState(state => ({note: Object.assign(state.note, {snippets: snippets})}))
|
this.setState(state => ({note: Object.assign(state.note, {snippets: snippets})}))
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
@@ -605,7 +605,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
name: '',
|
name: '',
|
||||||
mode: config.editor.snippetDefaultLanguage || 'text',
|
mode: config.editor.snippetDefaultLanguage || 'text',
|
||||||
content: '',
|
content: '',
|
||||||
linesHighlighted:[]
|
linesHighlighted: []
|
||||||
}])
|
}])
|
||||||
const snippetIndex = note.snippets.length - 1
|
const snippetIndex = note.snippets.length - 1
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function validateInput (input) {
|
|||||||
name: '',
|
name: '',
|
||||||
mode: 'text',
|
mode: 'text',
|
||||||
content: '',
|
content: '',
|
||||||
linesHighlighted:[],
|
linesHighlighted: []
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ function validateInput (input) {
|
|||||||
name: '',
|
name: '',
|
||||||
mode: 'text',
|
mode: 'text',
|
||||||
content: '',
|
content: '',
|
||||||
linesHighlighted:[],
|
linesHighlighted: []
|
||||||
}]
|
}]
|
||||||
} else {
|
} else {
|
||||||
validatedInput.snippets = input.snippets
|
validatedInput.snippets = input.snippets
|
||||||
@@ -98,7 +98,7 @@ function updateNote (storageKey, noteKey, input) {
|
|||||||
name: '',
|
name: '',
|
||||||
mode: 'text',
|
mode: 'text',
|
||||||
content: '',
|
content: '',
|
||||||
linesHighlighted:[],
|
linesHighlighted: []
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function updateSnippet (snippet, snippetFile) {
|
|||||||
currentSnippet.name === snippet.name &&
|
currentSnippet.name === snippet.name &&
|
||||||
currentSnippet.prefix === snippet.prefix &&
|
currentSnippet.prefix === snippet.prefix &&
|
||||||
currentSnippet.content === snippet.content &&
|
currentSnippet.content === snippet.content &&
|
||||||
currentSnippet.linesHighlighted===snippet.linesHighlighted
|
currentSnippet.linesHighlighted === snippet.linesHighlighted
|
||||||
) {
|
) {
|
||||||
// if everything is the same then don't write to disk
|
// if everything is the same then don't write to disk
|
||||||
resolve(snippets)
|
resolve(snippets)
|
||||||
|
|||||||
Reference in New Issue
Block a user