1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 10:46:32 +00:00

Linting fixes

This commit is contained in:
Jannick Hemelhof
2018-02-26 16:43:13 +01:00
parent 1f1e545538
commit 012908e32d

View File

@@ -1,46 +1,52 @@
(function (mod) { (function (mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports === 'object' && typeof module === 'object') { // Common JS
mod(require("../codemirror/lib/codemirror")); mod(require('../codemirror/lib/codemirror'))
else if (typeof define == "function" && define.amd) // AMD } else if (typeof define === 'function' && define.amd) { // AMD
define(["../codemirror/lib/codemirror"], mod); define(['../codemirror/lib/codemirror'], mod)
else // Plain browser env } else { // Plain browser env
mod(CodeMirror); mod(CodeMirror)
}
})(function (CodeMirror) { })(function (CodeMirror) {
"use strict"; 'use strict'
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/
emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, var emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/
unorderedListRE = /[*+-]\s/; var unorderedListRE = /[*+-]\s/
CodeMirror.commands.boostNewLineAndIndentContinueMarkdownList = function (cm) { CodeMirror.commands.boostNewLineAndIndentContinueMarkdownList = function (cm) {
if (cm.getOption("disableInput")) return CodeMirror.Pass; if (cm.getOption('disableInput')) return CodeMirror.Pass
var ranges = cm.listSelections(), replacements = []; var ranges = cm.listSelections()
var replacements = []
for (var i = 0; i < ranges.length; i++) { for (var i = 0; i < ranges.length; i++) {
var pos = ranges[i].head; var pos = ranges[i].head
var eolState = cm.getStateAfter(pos.line); var eolState = cm.getStateAfter(pos.line)
var inList = eolState.list !== false; var inList = eolState.list !== false
var inQuote = eolState.quote !== 0; var inQuote = eolState.quote !== 0
var line = cm.getLine(pos.line), match = listRE.exec(line); var line = cm.getLine(pos.line)
var match = listRE.exec(line)
if (!ranges[i].empty() || (!inList && !inQuote) || !match || pos.ch < match[2].length - 1) { if (!ranges[i].empty() || (!inList && !inQuote) || !match || pos.ch < match[2].length - 1) {
cm.execCommand("newlineAndIndent"); cm.execCommand('newlineAndIndent')
return; return
} }
if (emptyListRE.test(line)) { if (emptyListRE.test(line)) {
if (!/>\s*$/.test(line)) cm.replaceRange("", { if (!/>\s*$/.test(line)) {
cm.replaceRange('', {
line: pos.line, ch: 0 line: pos.line, ch: 0
}, { }, {
line: pos.line, ch: pos.ch + 1 line: pos.line, ch: pos.ch + 1
}); })
replacements[i] = "\n"; }
replacements[i] = '\n'
} else { } else {
var indent = match[1], after = match[5]; var indent = match[1]
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0 var after = match[5]
? match[2].replace("x", " ") var bullet = unorderedListRE.test(match[2]) || match[2].indexOf('>') >= 0
: (parseInt(match[3], 10) + 1) + match[4]; ? match[2].replace('x', ' ')
replacements[i] = "\n" + indent + bullet + after; : (parseInt(match[3], 10) + 1) + match[4]
replacements[i] = '\n' + indent + bullet + after
} }
} }
cm.replaceSelections(replacements); cm.replaceSelections(replacements)
}; }
}); })