@hpcc-js/codemirror 2.59.5 → 2.60.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es6.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Palette, HTMLWidget } from '@hpcc-js/common';
2
2
 
3
3
  var PKG_NAME = "@hpcc-js/codemirror";
4
- var PKG_VERSION = "2.59.5";
5
- var BUILD_VERSION = "2.103.2";
4
+ var PKG_VERSION = "2.60.1";
5
+ var BUILD_VERSION = "2.104.2";
6
6
 
7
- /*! *****************************************************************************
7
+ /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
9
9
 
10
10
  Permission to use, copy, modify, and/or distribute this software for any
@@ -54,9 +54,9 @@ var codemirror = {exports: {}};
54
54
 
55
55
  (function (module, exports) {
56
56
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
57
- // Distributed under an MIT license: https://codemirror.net/LICENSE
57
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
58
58
 
59
- // This is CodeMirror (https://codemirror.net), a code editor
59
+ // This is CodeMirror (https://codemirror.net/5), a code editor
60
60
  // implemented in JavaScript on top of the browser's DOM.
61
61
  //
62
62
  // You can find some technical background for some of the code below
@@ -78,7 +78,8 @@ var codemirror = {exports: {}};
78
78
  var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
79
79
  var webkit = !edge && /WebKit\//.test(userAgent);
80
80
  var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
81
- var chrome = !edge && /Chrome\//.test(userAgent);
81
+ var chrome = !edge && /Chrome\/(\d+)/.exec(userAgent);
82
+ var chrome_version = chrome && +chrome[1];
82
83
  var presto = /Opera\//.test(userAgent);
83
84
  var safari = /Apple Computer/.test(navigator.vendor);
84
85
  var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
@@ -163,15 +164,15 @@ var codemirror = {exports: {}};
163
164
  } while (child = child.parentNode)
164
165
  }
165
166
 
166
- function activeElt() {
167
+ function activeElt(doc) {
167
168
  // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
168
169
  // IE < 10 will throw when accessed while the page is loading or in an iframe.
169
170
  // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
170
171
  var activeElement;
171
172
  try {
172
- activeElement = document.activeElement;
173
+ activeElement = doc.activeElement;
173
174
  } catch(e) {
174
- activeElement = document.body || null;
175
+ activeElement = doc.body || null;
175
176
  }
176
177
  while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
177
178
  { activeElement = activeElement.shadowRoot.activeElement; }
@@ -195,6 +196,10 @@ var codemirror = {exports: {}};
195
196
  else if (ie) // Suppress mysterious IE10 errors
196
197
  { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
197
198
 
199
+ function doc(cm) { return cm.display.wrapper.ownerDocument }
200
+
201
+ function win(cm) { return doc(cm).defaultView }
202
+
198
203
  function bind(f) {
199
204
  var args = Array.prototype.slice.call(arguments, 1);
200
205
  return function(){return f.apply(null, args)}
@@ -1376,7 +1381,7 @@ var codemirror = {exports: {}};
1376
1381
  // Add a span to a line.
1377
1382
  function addMarkedSpan(line, span, op) {
1378
1383
  var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet));
1379
- if (inThisOp && inThisOp.has(line.markedSpans)) {
1384
+ if (inThisOp && line.markedSpans && inThisOp.has(line.markedSpans)) {
1380
1385
  line.markedSpans.push(span);
1381
1386
  } else {
1382
1387
  line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
@@ -2624,16 +2629,16 @@ var codemirror = {exports: {}};
2624
2629
  cm.display.lineNumChars = null;
2625
2630
  }
2626
2631
 
2627
- function pageScrollX() {
2632
+ function pageScrollX(doc) {
2628
2633
  // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
2629
2634
  // which causes page_Offset and bounding client rects to use
2630
2635
  // different reference viewports and invalidate our calculations.
2631
- if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
2632
- return window.pageXOffset || (document.documentElement || document.body).scrollLeft
2636
+ if (chrome && android) { return -(doc.body.getBoundingClientRect().left - parseInt(getComputedStyle(doc.body).marginLeft)) }
2637
+ return doc.defaultView.pageXOffset || (doc.documentElement || doc.body).scrollLeft
2633
2638
  }
2634
- function pageScrollY() {
2635
- if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
2636
- return window.pageYOffset || (document.documentElement || document.body).scrollTop
2639
+ function pageScrollY(doc) {
2640
+ if (chrome && android) { return -(doc.body.getBoundingClientRect().top - parseInt(getComputedStyle(doc.body).marginTop)) }
2641
+ return doc.defaultView.pageYOffset || (doc.documentElement || doc.body).scrollTop
2637
2642
  }
2638
2643
 
2639
2644
  function widgetTopHeight(lineObj) {
@@ -2661,8 +2666,8 @@ var codemirror = {exports: {}};
2661
2666
  else { yOff -= cm.display.viewOffset; }
2662
2667
  if (context == "page" || context == "window") {
2663
2668
  var lOff = cm.display.lineSpace.getBoundingClientRect();
2664
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
2665
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
2669
+ yOff += lOff.top + (context == "window" ? 0 : pageScrollY(doc(cm)));
2670
+ var xOff = lOff.left + (context == "window" ? 0 : pageScrollX(doc(cm)));
2666
2671
  rect.left += xOff; rect.right += xOff;
2667
2672
  }
2668
2673
  rect.top += yOff; rect.bottom += yOff;
@@ -2676,8 +2681,8 @@ var codemirror = {exports: {}};
2676
2681
  var left = coords.left, top = coords.top;
2677
2682
  // First move into "page" coordinate system
2678
2683
  if (context == "page") {
2679
- left -= pageScrollX();
2680
- top -= pageScrollY();
2684
+ left -= pageScrollX(doc(cm));
2685
+ top -= pageScrollY(doc(cm));
2681
2686
  } else if (context == "local" || !context) {
2682
2687
  var localBox = cm.display.sizer.getBoundingClientRect();
2683
2688
  left += localBox.left;
@@ -3493,8 +3498,9 @@ var codemirror = {exports: {}};
3493
3498
  if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
3494
3499
 
3495
3500
  var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
3501
+ var doc = display.wrapper.ownerDocument;
3496
3502
  if (rect.top + box.top < 0) { doScroll = true; }
3497
- else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
3503
+ else if (rect.bottom + box.top > (doc.defaultView.innerHeight || doc.documentElement.clientHeight)) { doScroll = false; }
3498
3504
  if (doScroll != null && !phantom) {
3499
3505
  var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
3500
3506
  cm.display.lineSpace.appendChild(scrollNode);
@@ -3748,13 +3754,13 @@ var codemirror = {exports: {}};
3748
3754
  NativeScrollbars.prototype.zeroWidthHack = function () {
3749
3755
  var w = mac && !mac_geMountainLion ? "12px" : "18px";
3750
3756
  this.horiz.style.height = this.vert.style.width = w;
3751
- this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
3757
+ this.horiz.style.visibility = this.vert.style.visibility = "hidden";
3752
3758
  this.disableHoriz = new Delayed;
3753
3759
  this.disableVert = new Delayed;
3754
3760
  };
3755
3761
 
3756
3762
  NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
3757
- bar.style.pointerEvents = "auto";
3763
+ bar.style.visibility = "";
3758
3764
  function maybeDisable() {
3759
3765
  // To find out whether the scrollbar is still visible, we
3760
3766
  // check whether the element under the pixel in the bottom
@@ -3765,7 +3771,7 @@ var codemirror = {exports: {}};
3765
3771
  var box = bar.getBoundingClientRect();
3766
3772
  var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
3767
3773
  : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
3768
- if (elt != bar) { bar.style.pointerEvents = "none"; }
3774
+ if (elt != bar) { bar.style.visibility = "hidden"; }
3769
3775
  else { delay.set(1000, maybeDisable); }
3770
3776
  }
3771
3777
  delay.set(1000, maybeDisable);
@@ -3946,7 +3952,7 @@ var codemirror = {exports: {}};
3946
3952
  cm.display.maxLineChanged = false;
3947
3953
  }
3948
3954
 
3949
- var takeFocus = op.focus && op.focus == activeElt();
3955
+ var takeFocus = op.focus && op.focus == activeElt(doc(cm));
3950
3956
  if (op.preparedSelection)
3951
3957
  { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
3952
3958
  if (op.updatedDisplay || op.startHeight != cm.doc.height)
@@ -4123,11 +4129,11 @@ var codemirror = {exports: {}};
4123
4129
 
4124
4130
  function selectionSnapshot(cm) {
4125
4131
  if (cm.hasFocus()) { return null }
4126
- var active = activeElt();
4132
+ var active = activeElt(doc(cm));
4127
4133
  if (!active || !contains(cm.display.lineDiv, active)) { return null }
4128
4134
  var result = {activeElt: active};
4129
4135
  if (window.getSelection) {
4130
- var sel = window.getSelection();
4136
+ var sel = win(cm).getSelection();
4131
4137
  if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
4132
4138
  result.anchorNode = sel.anchorNode;
4133
4139
  result.anchorOffset = sel.anchorOffset;
@@ -4139,11 +4145,12 @@ var codemirror = {exports: {}};
4139
4145
  }
4140
4146
 
4141
4147
  function restoreSelection(snapshot) {
4142
- if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
4148
+ if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
4143
4149
  snapshot.activeElt.focus();
4144
4150
  if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
4145
4151
  snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4146
- var sel = window.getSelection(), range = document.createRange();
4152
+ var doc = snapshot.activeElt.ownerDocument;
4153
+ var sel = doc.defaultView.getSelection(), range = doc.createRange();
4147
4154
  range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
4148
4155
  range.collapse(false);
4149
4156
  sel.removeAllRanges();
@@ -4561,6 +4568,17 @@ var codemirror = {exports: {}};
4561
4568
  }
4562
4569
 
4563
4570
  function onScrollWheel(cm, e) {
4571
+ // On Chrome 102, viewport updates somehow stop wheel-based
4572
+ // scrolling. Turning off pointer events during the scroll seems
4573
+ // to avoid the issue.
4574
+ if (chrome && chrome_version == 102) {
4575
+ if (cm.display.chromeScrollHack == null) { cm.display.sizer.style.pointerEvents = "none"; }
4576
+ else { clearTimeout(cm.display.chromeScrollHack); }
4577
+ cm.display.chromeScrollHack = setTimeout(function () {
4578
+ cm.display.chromeScrollHack = null;
4579
+ cm.display.sizer.style.pointerEvents = "";
4580
+ }, 100);
4581
+ }
4564
4582
  var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
4565
4583
  var pixelsPerUnit = wheelPixelsPerUnit;
4566
4584
  if (e.deltaMode === 0) {
@@ -5244,7 +5262,7 @@ var codemirror = {exports: {}};
5244
5262
  var range = sel.ranges[i];
5245
5263
  var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
5246
5264
  var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
5247
- var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
5265
+ var newHead = range.head == range.anchor ? newAnchor : skipAtomic(doc, range.head, old && old.head, bias, mayClear);
5248
5266
  if (out || newAnchor != range.anchor || newHead != range.head) {
5249
5267
  if (!out) { out = sel.ranges.slice(0, i); }
5250
5268
  out[i] = new Range(newAnchor, newHead);
@@ -7296,7 +7314,7 @@ var codemirror = {exports: {}};
7296
7314
  function onKeyDown(e) {
7297
7315
  var cm = this;
7298
7316
  if (e.target && e.target != cm.display.input.getField()) { return }
7299
- cm.curOp.focus = activeElt();
7317
+ cm.curOp.focus = activeElt(doc(cm));
7300
7318
  if (signalDOMEvent(cm, e)) { return }
7301
7319
  // IE does strange things with escape.
7302
7320
  if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
@@ -7403,7 +7421,7 @@ var codemirror = {exports: {}};
7403
7421
  }
7404
7422
  if (clickInGutter(cm, e)) { return }
7405
7423
  var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
7406
- window.focus();
7424
+ win(cm).focus();
7407
7425
 
7408
7426
  // #3261: make sure, that we're not starting a second selection
7409
7427
  if (button == 1 && cm.state.selectingText)
@@ -7458,7 +7476,7 @@ var codemirror = {exports: {}};
7458
7476
 
7459
7477
  function leftButtonDown(cm, pos, repeat, event) {
7460
7478
  if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
7461
- else { cm.curOp.focus = activeElt(); }
7479
+ else { cm.curOp.focus = activeElt(doc(cm)); }
7462
7480
 
7463
7481
  var behavior = configureMouse(cm, repeat, event);
7464
7482
 
@@ -7528,19 +7546,19 @@ var codemirror = {exports: {}};
7528
7546
  // Normal selection, as opposed to text dragging.
7529
7547
  function leftButtonSelect(cm, event, start, behavior) {
7530
7548
  if (ie) { delayBlurEvent(cm); }
7531
- var display = cm.display, doc = cm.doc;
7549
+ var display = cm.display, doc$1 = cm.doc;
7532
7550
  e_preventDefault(event);
7533
7551
 
7534
- var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
7552
+ var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
7535
7553
  if (behavior.addNew && !behavior.extend) {
7536
- ourIndex = doc.sel.contains(start);
7554
+ ourIndex = doc$1.sel.contains(start);
7537
7555
  if (ourIndex > -1)
7538
7556
  { ourRange = ranges[ourIndex]; }
7539
7557
  else
7540
7558
  { ourRange = new Range(start, start); }
7541
7559
  } else {
7542
- ourRange = doc.sel.primary();
7543
- ourIndex = doc.sel.primIndex;
7560
+ ourRange = doc$1.sel.primary();
7561
+ ourIndex = doc$1.sel.primIndex;
7544
7562
  }
7545
7563
 
7546
7564
  if (behavior.unit == "rectangle") {
@@ -7557,18 +7575,18 @@ var codemirror = {exports: {}};
7557
7575
 
7558
7576
  if (!behavior.addNew) {
7559
7577
  ourIndex = 0;
7560
- setSelection(doc, new Selection([ourRange], 0), sel_mouse);
7561
- startSel = doc.sel;
7578
+ setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
7579
+ startSel = doc$1.sel;
7562
7580
  } else if (ourIndex == -1) {
7563
7581
  ourIndex = ranges.length;
7564
- setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
7582
+ setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
7565
7583
  {scroll: false, origin: "*mouse"});
7566
7584
  } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
7567
- setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
7585
+ setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
7568
7586
  {scroll: false, origin: "*mouse"});
7569
- startSel = doc.sel;
7587
+ startSel = doc$1.sel;
7570
7588
  } else {
7571
- replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
7589
+ replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
7572
7590
  }
7573
7591
 
7574
7592
  var lastPos = start;
@@ -7578,19 +7596,19 @@ var codemirror = {exports: {}};
7578
7596
 
7579
7597
  if (behavior.unit == "rectangle") {
7580
7598
  var ranges = [], tabSize = cm.options.tabSize;
7581
- var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
7582
- var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
7599
+ var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
7600
+ var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
7583
7601
  var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
7584
7602
  for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
7585
7603
  line <= end; line++) {
7586
- var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
7604
+ var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
7587
7605
  if (left == right)
7588
7606
  { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
7589
7607
  else if (text.length > leftPos)
7590
7608
  { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
7591
7609
  }
7592
7610
  if (!ranges.length) { ranges.push(new Range(start, start)); }
7593
- setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7611
+ setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7594
7612
  {origin: "*mouse", scroll: false});
7595
7613
  cm.scrollIntoView(pos);
7596
7614
  } else {
@@ -7605,8 +7623,8 @@ var codemirror = {exports: {}};
7605
7623
  anchor = maxPos(oldRange.to(), range.head);
7606
7624
  }
7607
7625
  var ranges$1 = startSel.ranges.slice(0);
7608
- ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
7609
- setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7626
+ ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
7627
+ setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7610
7628
  }
7611
7629
  }
7612
7630
 
@@ -7622,9 +7640,9 @@ var codemirror = {exports: {}};
7622
7640
  var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
7623
7641
  if (!cur) { return }
7624
7642
  if (cmp(cur, lastPos) != 0) {
7625
- cm.curOp.focus = activeElt();
7643
+ cm.curOp.focus = activeElt(doc(cm));
7626
7644
  extendTo(cur);
7627
- var visible = visibleLines(display, doc);
7645
+ var visible = visibleLines(display, doc$1);
7628
7646
  if (cur.line >= visible.to || cur.line < visible.from)
7629
7647
  { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
7630
7648
  } else {
@@ -7649,7 +7667,7 @@ var codemirror = {exports: {}};
7649
7667
  }
7650
7668
  off(display.wrapper.ownerDocument, "mousemove", move);
7651
7669
  off(display.wrapper.ownerDocument, "mouseup", up);
7652
- doc.history.lastSelOrigin = null;
7670
+ doc$1.history.lastSelOrigin = null;
7653
7671
  }
7654
7672
 
7655
7673
  var move = operation(cm, function (e) {
@@ -8249,7 +8267,7 @@ var codemirror = {exports: {}};
8249
8267
  var pasted = e.clipboardData && e.clipboardData.getData("Text");
8250
8268
  if (pasted) {
8251
8269
  e.preventDefault();
8252
- if (!cm.isReadOnly() && !cm.options.disableInput)
8270
+ if (!cm.isReadOnly() && !cm.options.disableInput && cm.hasFocus())
8253
8271
  { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
8254
8272
  return true
8255
8273
  }
@@ -8326,7 +8344,7 @@ var codemirror = {exports: {}};
8326
8344
 
8327
8345
  CodeMirror.prototype = {
8328
8346
  constructor: CodeMirror,
8329
- focus: function(){window.focus(); this.display.input.focus();},
8347
+ focus: function(){win(this).focus(); this.display.input.focus();},
8330
8348
 
8331
8349
  setOption: function(option, value) {
8332
8350
  var options = this.options, old = options[option];
@@ -8650,7 +8668,7 @@ var codemirror = {exports: {}};
8650
8668
 
8651
8669
  signal(this, "overwriteToggle", this, this.state.overwrite);
8652
8670
  },
8653
- hasFocus: function() { return this.display.input.getField() == activeElt() },
8671
+ hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
8654
8672
  isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
8655
8673
 
8656
8674
  scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
@@ -8831,7 +8849,7 @@ var codemirror = {exports: {}};
8831
8849
  function findPosV(cm, pos, dir, unit) {
8832
8850
  var doc = cm.doc, x = pos.left, y;
8833
8851
  if (unit == "page") {
8834
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
8852
+ var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc(cm).documentElement.clientHeight);
8835
8853
  var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
8836
8854
  y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
8837
8855
 
@@ -8931,7 +8949,7 @@ var codemirror = {exports: {}};
8931
8949
  var kludge = hiddenTextarea(), te = kludge.firstChild;
8932
8950
  cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8933
8951
  te.value = lastCopied.text.join("\n");
8934
- var hadFocus = activeElt();
8952
+ var hadFocus = activeElt(div.ownerDocument);
8935
8953
  selectInput(te);
8936
8954
  setTimeout(function () {
8937
8955
  cm.display.lineSpace.removeChild(kludge);
@@ -8954,7 +8972,7 @@ var codemirror = {exports: {}};
8954
8972
 
8955
8973
  ContentEditableInput.prototype.prepareSelection = function () {
8956
8974
  var result = prepareSelection(this.cm, false);
8957
- result.focus = activeElt() == this.div;
8975
+ result.focus = activeElt(this.div.ownerDocument) == this.div;
8958
8976
  return result
8959
8977
  };
8960
8978
 
@@ -9050,7 +9068,7 @@ var codemirror = {exports: {}};
9050
9068
 
9051
9069
  ContentEditableInput.prototype.focus = function () {
9052
9070
  if (this.cm.options.readOnly != "nocursor") {
9053
- if (!this.selectionInEditor() || activeElt() != this.div)
9071
+ if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
9054
9072
  { this.showSelection(this.prepareSelection(), true); }
9055
9073
  this.div.focus();
9056
9074
  }
@@ -9553,7 +9571,7 @@ var codemirror = {exports: {}};
9553
9571
  TextareaInput.prototype.supportsTouch = function () { return false };
9554
9572
 
9555
9573
  TextareaInput.prototype.focus = function () {
9556
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
9574
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
9557
9575
  try { this.textarea.focus(); }
9558
9576
  catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
9559
9577
  }
@@ -9676,9 +9694,9 @@ var codemirror = {exports: {}};
9676
9694
  input.wrapper.style.cssText = "position: static";
9677
9695
  te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
9678
9696
  var oldScrollY;
9679
- if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
9697
+ if (webkit) { oldScrollY = te.ownerDocument.defaultView.scrollY; } // Work around Chrome issue (#2712)
9680
9698
  display.input.focus();
9681
- if (webkit) { window.scrollTo(null, oldScrollY); }
9699
+ if (webkit) { te.ownerDocument.defaultView.scrollTo(null, oldScrollY); }
9682
9700
  display.input.reset();
9683
9701
  // Adds "Select all" to context menu in FF
9684
9702
  if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
@@ -9760,7 +9778,7 @@ var codemirror = {exports: {}};
9760
9778
  // Set autofocus to true if this textarea is focused, or if it has
9761
9779
  // autofocus and no other element is focused.
9762
9780
  if (options.autofocus == null) {
9763
- var hasFocus = activeElt();
9781
+ var hasFocus = activeElt(textarea.ownerDocument);
9764
9782
  options.autofocus = hasFocus == textarea ||
9765
9783
  textarea.getAttribute("autofocus") != null && hasFocus == document.body;
9766
9784
  }
@@ -9894,7 +9912,7 @@ var codemirror = {exports: {}};
9894
9912
 
9895
9913
  addLegacyProps(CodeMirror);
9896
9914
 
9897
- CodeMirror.version = "5.65.2";
9915
+ CodeMirror.version = "5.65.7";
9898
9916
 
9899
9917
  return CodeMirror;
9900
9918
 
@@ -9905,7 +9923,7 @@ var CodeMirror = codemirror.exports;
9905
9923
 
9906
9924
  (function (module, exports) {
9907
9925
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
9908
- // Distributed under an MIT license: https://codemirror.net/LICENSE
9926
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
9909
9927
 
9910
9928
  (function(mod) {
9911
9929
  mod(codemirror.exports);
@@ -10128,7 +10146,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10128
10146
  if (type == "}" || type == "{") return popAndPass(type, stream, state);
10129
10147
  if (type == "(") return pushContext(state, stream, "parens");
10130
10148
 
10131
- if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
10149
+ if (type == "hash" && !/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(stream.current())) {
10132
10150
  override += " error";
10133
10151
  } else if (type == "word") {
10134
10152
  wordAsValue(stream);
@@ -10531,7 +10549,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10531
10549
  "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
10532
10550
  "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary",
10533
10551
  "bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box",
10534
- "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "button-bevel",
10552
+ "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button",
10535
10553
  "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
10536
10554
  "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
10537
10555
  "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
@@ -10569,14 +10587,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10569
10587
  "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
10570
10588
  "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
10571
10589
  "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d",
10572
- "media-controls-background", "media-current-time-display",
10573
- "media-fullscreen-button", "media-mute-button", "media-play-button",
10574
- "media-return-to-realtime-button", "media-rewind-button",
10575
- "media-seek-back-button", "media-seek-forward-button", "media-slider",
10576
- "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
10577
- "media-volume-slider-container", "media-volume-sliderthumb", "medium",
10578
- "menu", "menulist", "menulist-button", "menulist-text",
10579
- "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
10590
+ "media-play-button", "media-slider", "media-sliderthumb",
10591
+ "media-volume-slider", "media-volume-sliderthumb", "medium",
10592
+ "menu", "menulist", "menulist-button",
10593
+ "menutext", "message-box", "middle", "min-intrinsic",
10580
10594
  "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize",
10581
10595
  "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
10582
10596
  "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
@@ -10768,7 +10782,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10768
10782
 
10769
10783
  (function (module, exports) {
10770
10784
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
10771
- // Distributed under an MIT license: https://codemirror.net/LICENSE
10785
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
10772
10786
 
10773
10787
  (function(mod) {
10774
10788
  mod(codemirror.exports);
@@ -10975,7 +10989,7 @@ var xml = {exports: {}};
10975
10989
 
10976
10990
  (function (module, exports) {
10977
10991
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
10978
- // Distributed under an MIT license: https://codemirror.net/LICENSE
10992
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
10979
10993
 
10980
10994
  (function(mod) {
10981
10995
  mod(codemirror.exports);
@@ -11391,7 +11405,7 @@ var meta = {exports: {}};
11391
11405
 
11392
11406
  (function (module, exports) {
11393
11407
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
11394
- // Distributed under an MIT license: https://codemirror.net/LICENSE
11408
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
11395
11409
 
11396
11410
  (function(mod) {
11397
11411
  mod(codemirror.exports);
@@ -11609,7 +11623,7 @@ var meta = {exports: {}};
11609
11623
 
11610
11624
  (function (module, exports) {
11611
11625
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
11612
- // Distributed under an MIT license: https://codemirror.net/LICENSE
11626
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
11613
11627
 
11614
11628
  (function(mod) {
11615
11629
  mod(codemirror.exports, xml.exports, meta.exports);
@@ -12494,7 +12508,7 @@ var overlay = {exports: {}};
12494
12508
 
12495
12509
  (function (module, exports) {
12496
12510
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12497
- // Distributed under an MIT license: https://codemirror.net/LICENSE
12511
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
12498
12512
 
12499
12513
  // Utility function that allows modes to be combined. The mode given
12500
12514
  // as the base argument takes care of most of the normal mode
@@ -12581,7 +12595,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
12581
12595
 
12582
12596
  (function (module, exports) {
12583
12597
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12584
- // Distributed under an MIT license: https://codemirror.net/LICENSE
12598
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
12585
12599
 
12586
12600
  (function(mod) {
12587
12601
  mod(codemirror.exports, markdown.exports, overlay.exports);
@@ -12709,7 +12723,7 @@ var javascript = {exports: {}};
12709
12723
 
12710
12724
  (function (module, exports) {
12711
12725
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12712
- // Distributed under an MIT license: https://codemirror.net/LICENSE
12726
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
12713
12727
 
12714
12728
  (function(mod) {
12715
12729
  mod(codemirror.exports);
@@ -13665,7 +13679,7 @@ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript
13665
13679
 
13666
13680
  (function (module, exports) {
13667
13681
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
13668
- // Distributed under an MIT license: https://codemirror.net/LICENSE
13682
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
13669
13683
 
13670
13684
  (function(mod) {
13671
13685
  mod(codemirror.exports, xml.exports, javascript.exports, css.exports);
@@ -14795,7 +14809,7 @@ styleInject$1(css_248z$2);
14795
14809
 
14796
14810
  (function (module, exports) {
14797
14811
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
14798
- // Distributed under an MIT license: https://codemirror.net/LICENSE
14812
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
14799
14813
 
14800
14814
  (function(mod) {
14801
14815
  mod(codemirror.exports);
@@ -14911,7 +14925,7 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
14911
14925
 
14912
14926
  (function (module, exports) {
14913
14927
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
14914
- // Distributed under an MIT license: https://codemirror.net/LICENSE
14928
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
14915
14929
 
14916
14930
  (function(mod) {
14917
14931
  mod(codemirror.exports);
@@ -14969,7 +14983,7 @@ var foldcode = {exports: {}};
14969
14983
 
14970
14984
  (function (module, exports) {
14971
14985
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
14972
- // Distributed under an MIT license: https://codemirror.net/LICENSE
14986
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
14973
14987
 
14974
14988
  (function(mod) {
14975
14989
  mod(codemirror.exports);
@@ -15125,7 +15139,7 @@ var foldcode = {exports: {}};
15125
15139
 
15126
15140
  (function (module, exports) {
15127
15141
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15128
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15142
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15129
15143
 
15130
15144
  (function(mod) {
15131
15145
  mod(codemirror.exports, foldcode.exports);
@@ -15285,7 +15299,7 @@ var foldcode = {exports: {}};
15285
15299
 
15286
15300
  (function (module, exports) {
15287
15301
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15288
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15302
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15289
15303
 
15290
15304
  (function(mod) {
15291
15305
  mod(codemirror.exports);
@@ -15329,7 +15343,7 @@ CodeMirror.registerHelper("fold", "indent", function(cm, start) {
15329
15343
 
15330
15344
  (function (module, exports) {
15331
15345
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15332
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15346
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15333
15347
 
15334
15348
  (function(mod) {
15335
15349
  mod(codemirror.exports);
@@ -15515,7 +15529,7 @@ var dialog = {exports: {}};
15515
15529
 
15516
15530
  (function (module, exports) {
15517
15531
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15518
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15532
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15519
15533
 
15520
15534
  // Open simple dialogs on top of an editor. Relies on dialog.css.
15521
15535
 
@@ -15676,7 +15690,7 @@ var dialog = {exports: {}};
15676
15690
 
15677
15691
  (function (module, exports) {
15678
15692
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15679
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15693
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15680
15694
 
15681
15695
  // Defines jumpToLine command. Uses dialog.js if present.
15682
15696
 
@@ -15728,7 +15742,7 @@ var searchcursor = {exports: {}};
15728
15742
 
15729
15743
  (function (module, exports) {
15730
15744
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
15731
- // Distributed under an MIT license: https://codemirror.net/LICENSE
15745
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
15732
15746
 
15733
15747
  (function(mod) {
15734
15748
  mod(codemirror.exports);
@@ -16030,7 +16044,7 @@ var searchcursor = {exports: {}};
16030
16044
 
16031
16045
  (function (module, exports) {
16032
16046
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
16033
- // Distributed under an MIT license: https://codemirror.net/LICENSE
16047
+ // Distributed under an MIT license: https://codemirror.net/5/LICENSE
16034
16048
 
16035
16049
  // Define search commands. Depends on dialog.js or another
16036
16050
  // implementation of the openDialog method.
@@ -16227,16 +16241,19 @@ var searchcursor = {exports: {}};
16227
16241
  }
16228
16242
 
16229
16243
  function getQueryDialog(cm) {
16230
- return el("", null,
16231
- el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ",
16232
- el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16233
- el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16244
+ var label = el("label", {className: "CodeMirror-search-label"},
16245
+ cm.phrase("Search:"),
16246
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field",
16247
+ id: "CodeMirror-search-field"}));
16248
+ label.setAttribute("for","CodeMirror-search-field");
16249
+ return el("", null, label, " ",
16250
+ el("span", {style: "color: #666", className: "CodeMirror-search-hint"},
16234
16251
  cm.phrase("(Use /re/ syntax for regexp search)")));
16235
16252
  }
16236
16253
  function getReplaceQueryDialog(cm) {
16237
16254
  return el("", null, " ",
16238
16255
  el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16239
- el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16256
+ el("span", {style: "color: #666", className: "CodeMirror-search-hint"},
16240
16257
  cm.phrase("(Use /re/ syntax for regexp search)")));
16241
16258
  }
16242
16259
  function getReplacementQueryDialog(cm) {