1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-12 17:26:17 +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) { }
"use strict"; })(function (CodeMirror) {
'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()
for (var i = 0; i < ranges.length; i++) { var replacements = []
var pos = ranges[i].head; for (var i = 0; i < ranges.length; i++) {
var eolState = cm.getStateAfter(pos.line); var pos = ranges[i].head
var inList = eolState.list !== false; var eolState = cm.getStateAfter(pos.line)
var inQuote = eolState.quote !== 0; var inList = eolState.list !== false
var line = cm.getLine(pos.line), match = listRE.exec(line); var inQuote = eolState.quote !== 0
if (!ranges[i].empty() || (!inList && !inQuote) || !match || pos.ch < match[2].length - 1) { var line = cm.getLine(pos.line)
cm.execCommand("newlineAndIndent"); var match = listRE.exec(line)
return; if (!ranges[i].empty() || (!inList && !inQuote) || !match || pos.ch < match[2].length - 1) {
} cm.execCommand('newlineAndIndent')
if (emptyListRE.test(line)) { return
if (!/>\s*$/.test(line)) cm.replaceRange("", { }
line: pos.line, ch: 0 if (emptyListRE.test(line)) {
}, { if (!/>\s*$/.test(line)) {
line: pos.line, ch: pos.ch + 1 cm.replaceRange('', {
}); line: pos.line, ch: 0
replacements[i] = "\n"; }, {
} else { line: pos.line, ch: pos.ch + 1
var indent = match[1], after = match[5]; })
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
? match[2].replace("x", " ")
: (parseInt(match[3], 10) + 1) + match[4];
replacements[i] = "\n" + indent + bullet + after;
}
} }
replacements[i] = '\n'
} else {
var indent = match[1]
var after = match[5]
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf('>') >= 0
? match[2].replace('x', ' ')
: (parseInt(match[3], 10) + 1) + match[4]
replacements[i] = '\n' + indent + bullet + after
}
}
cm.replaceSelections(replacements); cm.replaceSelections(replacements)
}; }
}); })