CodeMirror 5.59.0 + bump deps

This commit is contained in:
tophf 2020-12-22 01:17:19 +03:00
parent 1e614fa2bc
commit 06823bd5b4
10 changed files with 8013 additions and 5613 deletions

13485
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
"repository": "openstyles/stylus", "repository": "openstyles/stylus",
"author": "Stylus Team", "author": "Stylus Team",
"dependencies": { "dependencies": {
"codemirror": "^5.58.3", "codemirror": "^5.59.0",
"db-to-cloud": "^0.4.5", "db-to-cloud": "^0.4.5",
"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",
@ -20,13 +20,13 @@
"devDependencies": { "devDependencies": {
"archiver": "^4.0.1", "archiver": "^4.0.1",
"endent": "^1.4.0", "endent": "^1.4.0",
"eslint": "^7.1.0", "eslint": "^7.16.0",
"fs-extra": "^9.0.0", "fs-extra": "^9.0.0",
"make-fetch-happen": "^8.0.7", "make-fetch-happen": "^8.0.7",
"shx": "^0.3.2", "shx": "^0.3.2",
"sync-version": "^1.0.1", "sync-version": "^1.0.1",
"tiny-glob": "^0.2.6", "tiny-glob": "^0.2.6",
"web-ext": "^4.2.0", "web-ext": "^5.4.1",
"webext-tx-fix": "^0.3.3" "webext-tx-fix": "^0.3.3"
}, },
"scripts": { "scripts": {

View File

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

View File

@ -117,25 +117,25 @@
}); });
} }
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { function clearHighlighted(cm) {
function clear(cm) {
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted = null; cm.state.matchBrackets.currentlyHighlighted = null;
} }
} }
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) { if (old && old != CodeMirror.Init) {
cm.off("cursorActivity", doMatchBrackets); cm.off("cursorActivity", doMatchBrackets);
cm.off("focus", doMatchBrackets) cm.off("focus", doMatchBrackets)
cm.off("blur", clear) cm.off("blur", clearHighlighted)
clear(cm); clearHighlighted(cm);
} }
if (val) { if (val) {
cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.state.matchBrackets = typeof val == "object" ? val : {};
cm.on("cursorActivity", doMatchBrackets); cm.on("cursorActivity", doMatchBrackets);
cm.on("focus", doMatchBrackets) cm.on("focus", doMatchBrackets)
cm.on("blur", clear) cm.on("blur", clearHighlighted)
} }
}); });

View File

@ -1,6 +1,8 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: DOMRect
(function(mod) { (function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror")); mod(require("../../lib/codemirror"));
@ -94,8 +96,10 @@
completion.to || data.to, "complete"); completion.to || data.to, "complete");
CodeMirror.signal(data, "pick", completion); CodeMirror.signal(data, "pick", completion);
self.cm.scrollIntoView(); self.cm.scrollIntoView();
}) });
if (this.options.closeOnPick) {
this.close(); this.close();
}
}, },
cursorActivity: function() { cursorActivity: function() {
@ -113,7 +117,9 @@
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
pos.ch < identStart.ch || this.cm.somethingSelected() || pos.ch < identStart.ch || this.cm.somethingSelected() ||
(!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
if (this.options.closeOnCursorActivity) {
this.close(); this.close();
}
} else { } else {
var self = this; var self = this;
this.debounce = requestAnimationFrame(function() {self.update();}); this.debounce = requestAnimationFrame(function() {self.update();});
@ -259,10 +265,15 @@
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);
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
var scrolls = hints.scrollHeight > hints.clientHeight + 1
var startScroll = cm.getScrollInfo();
var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect();
var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false;
// Compute in the timeout to avoid reflow on init
var startScroll;
setTimeout(function() { startScroll = cm.getScrollInfo(); });
var overlapY = box.bottom - winH;
if (overlapY > 0) { if (overlapY > 0) {
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
if (curTop - height > 0) { // Fits above cursor if (curTop - height > 0) { // Fits above cursor
@ -332,7 +343,12 @@
CodeMirror.on(hints, "mousedown", function() { CodeMirror.on(hints, "mousedown", function() {
setTimeout(function(){cm.focus();}, 20); setTimeout(function(){cm.focus();}, 20);
}); });
this.scrollToActive()
// The first hint doesn't need to be scrolled to on init
var selectedHintRange = this.getSelectedHintRange();
if (selectedHintRange.from !== 0 || selectedHintRange.to !== 0) {
this.scrollToActive();
}
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
return true; return true;
@ -379,9 +395,9 @@
}, },
scrollToActive: function() { scrollToActive: function() {
var margin = this.completion.options.scrollMargin || 0; var selectedHintRange = this.getSelectedHintRange();
var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)]; var node1 = this.hints.childNodes[selectedHintRange.from];
var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)]; var node2 = this.hints.childNodes[selectedHintRange.to];
var firstNode = this.hints.firstChild; var firstNode = this.hints.firstChild;
if (node1.offsetTop < this.hints.scrollTop) if (node1.offsetTop < this.hints.scrollTop)
this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop;
@ -391,6 +407,14 @@
screenAmount: function() { screenAmount: function() {
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
},
getSelectedHintRange: function() {
var margin = this.completion.options.scrollMargin || 0;
return {
from: Math.max(0, this.selectedHint - margin),
to: Math.min(this.data.list.length - 1, this.selectedHint + margin),
};
} }
}; };
@ -468,11 +492,15 @@
completeSingle: true, completeSingle: true,
alignWithWord: true, alignWithWord: true,
closeCharacters: /[\s()\[\]{};:>,]/, closeCharacters: /[\s()\[\]{};:>,]/,
closeOnCursorActivity: true,
closeOnPick: true,
closeOnUnfocus: true, closeOnUnfocus: true,
completeOnSingleClick: true, completeOnSingleClick: true,
container: null, container: null,
customKeys: null, customKeys: null,
extraKeys: null extraKeys: null,
paddingForScrollbar: true,
moveOnOverlap: true,
}; };
CodeMirror.defineOption("hintOptions", null); CodeMirror.defineOption("hintOptions", null);

View File

@ -170,6 +170,10 @@
var anns = annotations[line]; var anns = annotations[line];
if (!anns) continue; if (!anns) continue;
// filter out duplicate messages
var message = [];
anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) });
var maxSeverity = null; var maxSeverity = null;
var tipLabel = state.hasGutter && document.createDocumentFragment(); var tipLabel = state.hasGutter && document.createDocumentFragment();
@ -187,9 +191,9 @@
__annotation: ann __annotation: ann
})); }));
} }
// use original annotations[line] to show multiple messages
if (state.hasGutter) if (state.hasGutter)
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
state.options.tooltips)); state.options.tooltips));
} }
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);

View File

@ -19,7 +19,7 @@
} }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */ background-color: transparent; /* The little square between H and V scrollbars */
} }
/* GUTTER */ /* GUTTER */

View File

@ -32,7 +32,7 @@
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent); var phantom = /PhantomJS/.test(userAgent);
var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
var android = /Android/.test(userAgent); var android = /Android/.test(userAgent);
// This is woefully incomplete. Suggestions for alternative methods welcome. // This is woefully incomplete. Suggestions for alternative methods welcome.
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
@ -9790,7 +9790,7 @@
addLegacyProps(CodeMirror); addLegacyProps(CodeMirror);
CodeMirror.version = "5.58.3"; CodeMirror.version = "5.59.0";
return CodeMirror; return CodeMirror;

View File

@ -616,13 +616,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (value == "|" || value == "&") return cont(typeexpr) if (value == "|" || value == "&") return cont(typeexpr)
if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "string" || type == "number" || type == "atom") return cont(afterType);
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
} }
function maybeReturnType(type) { function maybeReturnType(type) {
if (type == "=>") return cont(typeexpr) if (type == "=>") return cont(typeexpr)
} }
function typeprops(type) {
if (type == "}") return cont()
if (type == "," || type == ";") return cont(typeprops)
return pass(typeprop, typeprops)
}
function typeprop(type, value) { function typeprop(type, value) {
if (type == "variable" || cx.style == "keyword") { if (type == "variable" || cx.style == "keyword") {
cx.marked = "property" cx.marked = "property"

View File

@ -99,7 +99,7 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
.cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; } .cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; }
.cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; }
.cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; } .cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-light .CodeMirror-line > span::-moz-selection, .cm-s-light .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; }
/* Editor styling */ /* Editor styling */