Skip to content

Commit 33ba472

Browse files
committed
Fix phpmyadmin#14555 - JavaScript error when auto completion is open (upgrade CodeMirror to 5.60.0)
Closes: codemirror/codemirror5#6174 Fixes: phpmyadmin#14555
1 parent e5704fc commit 33ba472

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

js/vendor/codemirror/addon/hint/show-hint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
close: function() {
361361
if (this.completion.widget != this) return;
362362
this.completion.widget = null;
363-
this.hints.parentNode.removeChild(this.hints);
363+
if (this.hints.parentNode) this.hints.parentNode.removeChild(this.hints);
364364
this.completion.cm.removeKeyMap(this.keyMap);
365365

366366
var cm = this.completion.cm;

js/vendor/codemirror/lib/codemirror.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020

2121
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
22-
background-color: transparent; /* The little square between H and V scrollbars */
22+
background-color: white; /* The little square between H and V scrollbars */
2323
}
2424

2525
/* GUTTER */

js/vendor/codemirror/lib/codemirror.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,19 +4798,19 @@
47984798
});
47994799
}
48004800

4801-
function History(startGen) {
4801+
function History(prev) {
48024802
// Arrays of change events and selections. Doing something adds an
48034803
// event to done and clears undo. Undoing moves events from done
48044804
// to undone, redoing moves them in the other direction.
48054805
this.done = []; this.undone = [];
4806-
this.undoDepth = Infinity;
4806+
this.undoDepth = prev ? prev.undoDepth : Infinity;
48074807
// Used to track when changes can be merged into a single undo
48084808
// event
48094809
this.lastModTime = this.lastSelTime = 0;
48104810
this.lastOp = this.lastSelOp = null;
48114811
this.lastOrigin = this.lastSelOrigin = null;
48124812
// Used by the isClean() method
4813-
this.generation = this.maxGeneration = startGen || 1;
4813+
this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1;
48144814
}
48154815

48164816
// Create a history change event from an updateDoc-style change
@@ -6181,7 +6181,7 @@
61816181
var out = [];
61826182
for (var i = 0; i < ranges.length; i++)
61836183
{ out[i] = new Range(clipPos(this, ranges[i].anchor),
6184-
clipPos(this, ranges[i].head)); }
6184+
clipPos(this, ranges[i].head || ranges[i].anchor)); }
61856185
if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
61866186
setSelection(this, normalizeSelection(this.cm, out, primary), options);
61876187
}),
@@ -6244,7 +6244,7 @@
62446244
clearHistory: function() {
62456245
var this$1 = this;
62466246

6247-
this.history = new History(this.history.maxGeneration);
6247+
this.history = new History(this.history);
62486248
linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true);
62496249
},
62506250

@@ -6265,7 +6265,7 @@
62656265
undone: copyHistoryArray(this.history.undone)}
62666266
},
62676267
setHistory: function(histData) {
6268-
var hist = this.history = new History(this.history.maxGeneration);
6268+
var hist = this.history = new History(this.history);
62696269
hist.done = copyHistoryArray(histData.done.slice(0), null, true);
62706270
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
62716271
},
@@ -7708,7 +7708,7 @@
77087708
for (var i = newBreaks.length - 1; i >= 0; i--)
77097709
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
77107710
});
7711-
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7711+
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
77127712
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
77137713
if (old != Init) { cm.refresh(); }
77147714
});
@@ -8766,6 +8766,7 @@
87668766

87678767
var input = this, cm = input.cm;
87688768
var div = input.div = display.lineDiv;
8769+
div.contentEditable = true;
87698770
disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
87708771

87718772
function belongsToInput(e) {
@@ -9793,7 +9794,7 @@
97939794

97949795
addLegacyProps(CodeMirror);
97959796

9796-
CodeMirror.version = "5.59.2";
9797+
CodeMirror.version = "5.60.0";
97979798

97989799
return CodeMirror;
97999800

js/vendor/codemirror/mode/javascript/javascript.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
218218

219219
// Parser
220220

221-
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
221+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
222+
"regexp": true, "this": true, "import": true, "jsonld-keyword": true};
222223

223224
function JSLexical(indented, column, type, align, prev, info) {
224225
this.indented = indented;
@@ -441,7 +442,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
441442
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
442443
if (type == "quasi") return pass(quasi, maybeop);
443444
if (type == "new") return cont(maybeTarget(noComma));
444-
if (type == "import") return cont(expression);
445445
return cont();
446446
}
447447
function maybeexpression(type) {
@@ -605,7 +605,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
605605
}
606606
}
607607
function typeexpr(type, value) {
608-
if (value == "keyof" || value == "typeof" || value == "infer") {
608+
if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
609609
cx.marked = "keyword"
610610
return cont(value == "typeof" ? expressionNoComma : typeexpr)
611611
}
@@ -802,6 +802,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
802802
function afterImport(type) {
803803
if (type == "string") return cont();
804804
if (type == "(") return pass(expression);
805+
if (type == ".") return pass(maybeoperatorComma);
805806
return pass(importSpec, maybeMoreImports, maybeFrom);
806807
}
807808
function importSpec(type, value) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@babel/preset-env": "^7.12.11",
1616
"blueimp-md5": "^2.18.0",
1717
"bootstrap": "4.5.3",
18-
"codemirror": "5.59.2",
18+
"codemirror": "5.60.0",
1919
"jquery": "3.5.1",
2020
"jquery-debounce-throttle": "^1.0.6-rc.0",
2121
"jquery-fullscreen-plugin": "^1.1.5",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@
12561256
terminal-link "^2.0.0"
12571257
v8-to-istanbul "^7.0.0"
12581258
optionalDependencies:
1259-
node-notifier "^8.0.1"
1259+
node-notifier "^8.0.0"
12601260

12611261
"@jest/source-map@^26.6.2":
12621262
version "26.6.2"
@@ -2192,10 +2192,10 @@ co@^4.6.0:
21922192
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
21932193
integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=
21942194

2195-
codemirror@5.59.2:
2196-
version "5.59.2"
2197-
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.%3Cspan%20class="x x-first x-last">59.2.tgz#ee674d3a4a8d241af38d52afc482625ba7393922"
2198-
integrity sha512-/D5PcsKyzthtSy2NNKCyJi3b+htRkoKv3idswR/tR6UAvMNKA7SrmyZy6fOONJxSRs1JlUWEDAbxqfdArbK8iA==
2195+
codemirror@5.60.0:
2196+
version "5.60.0"
2197+
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.%3Cspan%20class="x x-first x-last">60.0.tgz#00a8cfd287d5d8737ceb73987f04aee2fe5860da"
2198+
integrity sha512-AEL7LhFOlxPlCL8IdTcJDblJm8yrAGib7I+DErJPdZd4l6imx8IMgKK3RblVgBQqz3TZJR4oknQ03bz+uNjBYA==
21992199

22002200
collect-v8-coverage@^1.0.0:
22012201
version "1.0.1"

0 commit comments

Comments
 (0)