CodeMirror 5.62.2

This commit is contained in:
tophf 2021-07-21 15:32:01 +03:00
parent 33ff2c8373
commit 7a0ac57b06
8 changed files with 73 additions and 38 deletions

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "1.5.19", "version": "1.5.19",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"codemirror": "5.62.0", "codemirror": "5.62.2",
"db-to-cloud": "^0.6.0", "db-to-cloud": "^0.6.0",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"less-bundle": "github:openstyles/less-bundle#v0.1.0", "less-bundle": "github:openstyles/less-bundle#v0.1.0",
@ -2361,9 +2361,9 @@
} }
}, },
"node_modules/codemirror": { "node_modules/codemirror": {
"version": "5.62.0", "version": "5.62.2",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.0.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.2.tgz",
"integrity": "sha512-Xnl3304iCc8nyVZuRkzDVVwc794uc9QNX0UcPGeNic1fbzkSrO4l4GVXho9tRNKBgPYZXgocUqXyfIv3BILhCQ==" "integrity": "sha512-tVFMUa4J3Q8JUd1KL9yQzQB0/BJt7ZYZujZmTPgo/54Lpuq3ez4C8x/ATUY/wv7b7X3AUq8o3Xd+2C5ZrCGWHw=="
}, },
"node_modules/collection-visit": { "node_modules/collection-visit": {
"version": "1.0.0", "version": "1.0.0",
@ -13933,9 +13933,9 @@
} }
}, },
"codemirror": { "codemirror": {
"version": "5.62.0", "version": "5.62.2",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.0.tgz", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.2.tgz",
"integrity": "sha512-Xnl3304iCc8nyVZuRkzDVVwc794uc9QNX0UcPGeNic1fbzkSrO4l4GVXho9tRNKBgPYZXgocUqXyfIv3BILhCQ==" "integrity": "sha512-tVFMUa4J3Q8JUd1KL9yQzQB0/BJt7ZYZujZmTPgo/54Lpuq3ez4C8x/ATUY/wv7b7X3AUq8o3Xd+2C5ZrCGWHw=="
}, },
"collection-visit": { "collection-visit": {
"version": "1.0.0", "version": "1.0.0",

View File

@ -6,7 +6,7 @@
"repository": "openstyles/stylus", "repository": "openstyles/stylus",
"author": "Stylus Team", "author": "Stylus Team",
"dependencies": { "dependencies": {
"codemirror": "5.62.0", "codemirror": "5.62.2",
"db-to-cloud": "^0.6.0", "db-to-cloud": "^0.6.0",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"less-bundle": "github:openstyles/less-bundle#v0.1.0", "less-bundle": "github:openstyles/less-bundle#v0.1.0",

View File

@ -1,4 +1,4 @@
## codemirror v5.62.0 ## codemirror v5.62.2
Following files are copied from npm (node_modules): Following files are copied from npm (node_modules):

View File

@ -24,9 +24,11 @@
function getRange(allowFolded) { function getRange(allowFolded) {
var range = finder(cm, pos); var range = finder(cm, pos);
if (!range || range.to.line - range.from.line < minSize) return null; if (!range || range.to.line - range.from.line < minSize) return null;
if (force === "fold") return range;
var marks = cm.findMarksAt(range.from); var marks = cm.findMarksAt(range.from);
for (var i = 0; i < marks.length; ++i) { for (var i = 0; i < marks.length; ++i) {
if (marks[i].__isFold && force !== "fold") { if (marks[i].__isFold) {
if (!allowFolded) return null; if (!allowFolded) return null;
range.cleared = true; range.cleared = true;
marks[i].clear(); marks[i].clear();
@ -99,18 +101,18 @@
cm.foldCode(cm.getCursor(), null, "fold"); cm.foldCode(cm.getCursor(), null, "fold");
}; };
CodeMirror.commands.unfold = function(cm) { CodeMirror.commands.unfold = function(cm) {
cm.foldCode(cm.getCursor(), null, "unfold"); cm.foldCode(cm.getCursor(), { scanUp: false }, "unfold");
}; };
CodeMirror.commands.foldAll = function(cm) { CodeMirror.commands.foldAll = function(cm) {
cm.operation(function() { cm.operation(function() {
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "fold");
}); });
}; };
CodeMirror.commands.unfoldAll = function(cm) { CodeMirror.commands.unfoldAll = function(cm) {
cm.operation(function() { cm.operation(function() {
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold"); cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "unfold");
}); });
}; };

View File

@ -224,6 +224,7 @@
} }
function Widget(completion, data) { function Widget(completion, data) {
this.id = "cm-complete-" + Math.floor(Math.random(1e6))
this.completion = completion; this.completion = completion;
this.data = data; this.data = data;
this.picked = false; this.picked = false;
@ -232,6 +233,9 @@
var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow;
var hints = this.hints = ownerDocument.createElement("ul"); var hints = this.hints = ownerDocument.createElement("ul");
hints.setAttribute("role", "listbox")
hints.setAttribute("aria-expanded", "true")
hints.id = this.id
var theme = completion.cm.options.theme; var theme = completion.cm.options.theme;
hints.className = "CodeMirror-hints " + theme; hints.className = "CodeMirror-hints " + theme;
this.selectedHint = data.selectedHint || 0; this.selectedHint = data.selectedHint || 0;
@ -242,6 +246,9 @@
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
if (cur.className != null) className = cur.className + " " + className; if (cur.className != null) className = cur.className + " " + className;
elt.className = className; elt.className = className;
if (i == this.selectedHint) elt.setAttribute("aria-selected", "true")
elt.id = this.id + "-" + i
elt.setAttribute("role", "option")
if (cur.render) cur.render(elt, data, cur); if (cur.render) cur.render(elt, data, cur);
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
elt.hintId = i; elt.hintId = i;
@ -267,6 +274,9 @@
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
container.appendChild(hints); container.appendChild(hints);
cm.getInputField().setAttribute("aria-autocomplete", "list")
cm.getInputField().setAttribute("aria-owns", this.id)
cm.getInputField().setAttribute("aria-activedescendant", this.id + "-" + this.selectedHint)
var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect(); var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect();
var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false; var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false;
@ -364,6 +374,9 @@
this.completion.widget = null; this.completion.widget = null;
if (this.hints.parentNode) this.hints.parentNode.removeChild(this.hints); if (this.hints.parentNode) this.hints.parentNode.removeChild(this.hints);
this.completion.cm.removeKeyMap(this.keyMap); this.completion.cm.removeKeyMap(this.keyMap);
var input = this.completion.cm.getInputField()
input.removeAttribute("aria-activedescendant")
input.removeAttribute("aria-owns")
var cm = this.completion.cm; var cm = this.completion.cm;
if (this.completion.options.closeOnUnfocus) { if (this.completion.options.closeOnUnfocus) {
@ -391,9 +404,14 @@
i = avoidWrap ? 0 : this.data.list.length - 1; i = avoidWrap ? 0 : this.data.list.length - 1;
if (this.selectedHint == i) return; if (this.selectedHint == i) return;
var node = this.hints.childNodes[this.selectedHint]; var node = this.hints.childNodes[this.selectedHint];
if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, ""); if (node) {
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
node.removeAttribute("aria-selected")
}
node = this.hints.childNodes[this.selectedHint = i]; node = this.hints.childNodes[this.selectedHint = i];
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
node.setAttribute("aria-selected", "true")
this.completion.cm.getInputField().setAttribute("aria-activedescendant", node.id)
this.scrollToActive() this.scrollToActive()
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
}, },

View File

@ -59,25 +59,42 @@
CodeMirror.on(node, "mouseout", hide); CodeMirror.on(node, "mouseout", hide);
} }
function LintState(cm, options, hasGutter) { function LintState(cm, conf, hasGutter) {
this.marked = []; this.marked = [];
this.options = options; if (conf instanceof Function) conf = {getAnnotations: conf};
if (!conf || conf === true) conf = {};
this.options = {};
this.linterOptions = conf.options || {};
for (var prop in defaults) this.options[prop] = defaults[prop];
for (var prop in conf) {
if (defaults.hasOwnProperty(prop)) {
if (conf[prop] != null) this.options[prop] = conf[prop];
} else if (!conf.options) {
this.linterOptions[prop] = conf[prop];
}
}
this.timeout = null; this.timeout = null;
this.hasGutter = hasGutter; this.hasGutter = hasGutter;
this.onMouseOver = function(e) { onMouseOver(cm, e); }; this.onMouseOver = function(e) { onMouseOver(cm, e); };
this.waitingFor = 0 this.waitingFor = 0
} }
function parseOptions(_cm, options) { var defaults = {
if (options instanceof Function) return {getAnnotations: options}; highlightLines: false,
if (!options || options === true) options = {}; tooltips: true,
return options; delay: 500,
lintOnChange: true,
getAnnotations: null,
async: false,
selfContain: null,
formatAnnotation: null,
onUpdateLinting: null
} }
function clearMarks(cm) { function clearMarks(cm) {
var state = cm.state.lint; var state = cm.state.lint;
if (state.hasGutter) cm.clearGutter(GUTTER_ID); if (state.hasGutter) cm.clearGutter(GUTTER_ID);
if (isHighlightErrorLinesEnabled(state)) clearErrorLines(cm); if (state.options.highlightLines) clearErrorLines(cm);
for (var i = 0; i < state.marked.length; ++i) for (var i = 0; i < state.marked.length; ++i)
state.marked[i].clear(); state.marked[i].clear();
state.marked.length = 0; state.marked.length = 0;
@ -90,10 +107,6 @@
}) })
} }
function isHighlightErrorLinesEnabled(state) {
return state.options.highlightLines;
}
function makeMarker(cm, labels, severity, multiple, tooltips) { function makeMarker(cm, labels, severity, multiple, tooltips) {
var marker = document.createElement("div"), inner = marker; var marker = document.createElement("div"), inner = marker;
marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity; marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity;
@ -136,7 +149,7 @@
return tip; return tip;
} }
function lintAsync(cm, getAnnotations, passOptions) { function lintAsync(cm, getAnnotations) {
var state = cm.state.lint var state = cm.state.lint
var id = ++state.waitingFor var id = ++state.waitingFor
function abort() { function abort() {
@ -149,7 +162,7 @@
if (state.waitingFor != id) return if (state.waitingFor != id) return
if (arg2 && annotations instanceof CodeMirror) annotations = arg2 if (arg2 && annotations instanceof CodeMirror) annotations = arg2
cm.operation(function() {updateLinting(cm, annotations)}) cm.operation(function() {updateLinting(cm, annotations)})
}, passOptions, cm); }, state.linterOptions, cm);
} }
function startLinting(cm) { function startLinting(cm) {
@ -160,13 +173,12 @@
* Passing rules in `options` property prevents JSHint (and other linters) from complaining * Passing rules in `options` property prevents JSHint (and other linters) from complaining
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc. * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
*/ */
var passOptions = options.options || options;
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
if (!getAnnotations) return; if (!getAnnotations) return;
if (options.async || getAnnotations.async) { if (options.async || getAnnotations.async) {
lintAsync(cm, getAnnotations, passOptions) lintAsync(cm, getAnnotations)
} else { } else {
var annotations = getAnnotations(cm.getValue(), passOptions, cm); var annotations = getAnnotations(cm.getValue(), state.linterOptions, cm);
if (!annotations) return; if (!annotations) return;
if (annotations.then) annotations.then(function(issues) { if (annotations.then) annotations.then(function(issues) {
cm.operation(function() {updateLinting(cm, issues)}) cm.operation(function() {updateLinting(cm, issues)})
@ -211,9 +223,9 @@
// use original annotations[line] to show multiple messages // use original annotations[line] to show multiple messages
if (state.hasGutter) if (state.hasGutter)
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1, cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
state.options.tooltips)); options.tooltips));
if (isHighlightErrorLinesEnabled(state)) if (options.highlightLines)
cm.addLineClass(line, "wrap", LINT_LINE_ID + maxSeverity); cm.addLineClass(line, "wrap", LINT_LINE_ID + maxSeverity);
} }
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
@ -223,7 +235,7 @@
var state = cm.state.lint; var state = cm.state.lint;
if (!state) return; if (!state) return;
clearTimeout(state.timeout); clearTimeout(state.timeout);
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay);
} }
function popupTooltips(cm, annotations, e) { function popupTooltips(cm, annotations, e) {
@ -263,8 +275,8 @@
if (val) { if (val) {
var gutters = cm.getOption("gutters"), hasLintGutter = false; var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); var state = cm.state.lint = new LintState(cm, val, hasLintGutter);
if (state.options.lintOnChange !== false) if (state.options.lintOnChange)
cm.on("change", onChange); cm.on("change", onChange);
if (state.options.tooltips != false && state.options.tooltips != "gutter") if (state.options.tooltips != false && state.options.tooltips != "gutter")
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);

View File

@ -420,6 +420,9 @@
var numbers = makeKeyRange(48, 10); var numbers = makeKeyRange(48, 10);
var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']);
var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '_', '/']); var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '_', '/']);
var upperCaseChars;
try { upperCaseChars = new RegExp("^[\\p{Lu}]$", "u"); }
catch (_) { upperCaseChars = /^[A-Z]$/; }
function isLine(cm, line) { function isLine(cm, line) {
return line >= cm.firstLine() && line <= cm.lastLine(); return line >= cm.firstLine() && line <= cm.lastLine();
@ -434,7 +437,7 @@
return numberRegex.test(k); return numberRegex.test(k);
} }
function isUpperCase(k) { function isUpperCase(k) {
return (/^[A-Z]$/).test(k); return upperCaseChars.test(k);
} }
function isWhiteSpaceString(k) { function isWhiteSpaceString(k) {
return (/^\s*$/).test(k); return (/^\s*$/).test(k);
@ -658,7 +661,7 @@
this.latestRegister = registerName; this.latestRegister = registerName;
if (cm.openDialog) { if (cm.openDialog) {
this.onRecordingDone = cm.openDialog( this.onRecordingDone = cm.openDialog(
'(recording)['+registerName+']', null, {bottom:true}); document.createTextNode('(recording)['+registerName+']'), null, {bottom:true});
} }
this.isRecording = true; this.isRecording = true;
} }

View File

@ -9807,7 +9807,7 @@
addLegacyProps(CodeMirror); addLegacyProps(CodeMirror);
CodeMirror.version = "5.62.0"; CodeMirror.version = "5.62.2";
return CodeMirror; return CodeMirror;