@hpcc-js/codemirror 2.60.13 → 2.61.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.js CHANGED
@@ -5,8 +5,8 @@
5
5
  })(this, (function (exports, common) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/codemirror";
8
- var PKG_VERSION = "2.60.13";
9
- var BUILD_VERSION = "2.104.32";
8
+ var PKG_VERSION = "2.61.1";
9
+ var BUILD_VERSION = "2.104.35";
10
10
 
11
11
  /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -173,13 +173,14 @@
173
173
  } while (child = child.parentNode)
174
174
  }
175
175
 
176
- function activeElt(doc) {
176
+ function activeElt(rootNode) {
177
177
  // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
178
178
  // IE < 10 will throw when accessed while the page is loading or in an iframe.
179
179
  // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
180
+ var doc = rootNode.ownerDocument || rootNode;
180
181
  var activeElement;
181
182
  try {
182
- activeElement = doc.activeElement;
183
+ activeElement = rootNode.activeElement;
183
184
  } catch(e) {
184
185
  activeElement = doc.body || null;
185
186
  }
@@ -207,6 +208,15 @@
207
208
 
208
209
  function doc(cm) { return cm.display.wrapper.ownerDocument }
209
210
 
211
+ function root(cm) {
212
+ return rootNode(cm.display.wrapper)
213
+ }
214
+
215
+ function rootNode(element) {
216
+ // Detect modern browsers (2017+).
217
+ return element.getRootNode ? element.getRootNode() : element.ownerDocument
218
+ }
219
+
210
220
  function win(cm) { return doc(cm).defaultView }
211
221
 
212
222
  function bind(f) {
@@ -3961,7 +3971,7 @@
3961
3971
  cm.display.maxLineChanged = false;
3962
3972
  }
3963
3973
 
3964
- var takeFocus = op.focus && op.focus == activeElt(doc(cm));
3974
+ var takeFocus = op.focus && op.focus == activeElt(root(cm));
3965
3975
  if (op.preparedSelection)
3966
3976
  { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
3967
3977
  if (op.updatedDisplay || op.startHeight != cm.doc.height)
@@ -4138,7 +4148,7 @@
4138
4148
 
4139
4149
  function selectionSnapshot(cm) {
4140
4150
  if (cm.hasFocus()) { return null }
4141
- var active = activeElt(doc(cm));
4151
+ var active = activeElt(root(cm));
4142
4152
  if (!active || !contains(cm.display.lineDiv, active)) { return null }
4143
4153
  var result = {activeElt: active};
4144
4154
  if (window.getSelection) {
@@ -4154,7 +4164,7 @@
4154
4164
  }
4155
4165
 
4156
4166
  function restoreSelection(snapshot) {
4157
- if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
4167
+ if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return }
4158
4168
  snapshot.activeElt.focus();
4159
4169
  if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
4160
4170
  snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
@@ -7325,7 +7335,7 @@
7325
7335
  function onKeyDown(e) {
7326
7336
  var cm = this;
7327
7337
  if (e.target && e.target != cm.display.input.getField()) { return }
7328
- cm.curOp.focus = activeElt(doc(cm));
7338
+ cm.curOp.focus = activeElt(root(cm));
7329
7339
  if (signalDOMEvent(cm, e)) { return }
7330
7340
  // IE does strange things with escape.
7331
7341
  if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
@@ -7487,7 +7497,7 @@
7487
7497
 
7488
7498
  function leftButtonDown(cm, pos, repeat, event) {
7489
7499
  if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
7490
- else { cm.curOp.focus = activeElt(doc(cm)); }
7500
+ else { cm.curOp.focus = activeElt(root(cm)); }
7491
7501
 
7492
7502
  var behavior = configureMouse(cm, repeat, event);
7493
7503
 
@@ -7557,19 +7567,19 @@
7557
7567
  // Normal selection, as opposed to text dragging.
7558
7568
  function leftButtonSelect(cm, event, start, behavior) {
7559
7569
  if (ie) { delayBlurEvent(cm); }
7560
- var display = cm.display, doc$1 = cm.doc;
7570
+ var display = cm.display, doc = cm.doc;
7561
7571
  e_preventDefault(event);
7562
7572
 
7563
- var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
7573
+ var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
7564
7574
  if (behavior.addNew && !behavior.extend) {
7565
- ourIndex = doc$1.sel.contains(start);
7575
+ ourIndex = doc.sel.contains(start);
7566
7576
  if (ourIndex > -1)
7567
7577
  { ourRange = ranges[ourIndex]; }
7568
7578
  else
7569
7579
  { ourRange = new Range(start, start); }
7570
7580
  } else {
7571
- ourRange = doc$1.sel.primary();
7572
- ourIndex = doc$1.sel.primIndex;
7581
+ ourRange = doc.sel.primary();
7582
+ ourIndex = doc.sel.primIndex;
7573
7583
  }
7574
7584
 
7575
7585
  if (behavior.unit == "rectangle") {
@@ -7586,18 +7596,18 @@
7586
7596
 
7587
7597
  if (!behavior.addNew) {
7588
7598
  ourIndex = 0;
7589
- setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
7590
- startSel = doc$1.sel;
7599
+ setSelection(doc, new Selection([ourRange], 0), sel_mouse);
7600
+ startSel = doc.sel;
7591
7601
  } else if (ourIndex == -1) {
7592
7602
  ourIndex = ranges.length;
7593
- setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
7603
+ setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
7594
7604
  {scroll: false, origin: "*mouse"});
7595
7605
  } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
7596
- setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
7606
+ setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
7597
7607
  {scroll: false, origin: "*mouse"});
7598
- startSel = doc$1.sel;
7608
+ startSel = doc.sel;
7599
7609
  } else {
7600
- replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
7610
+ replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
7601
7611
  }
7602
7612
 
7603
7613
  var lastPos = start;
@@ -7607,19 +7617,19 @@
7607
7617
 
7608
7618
  if (behavior.unit == "rectangle") {
7609
7619
  var ranges = [], tabSize = cm.options.tabSize;
7610
- var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
7611
- var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
7620
+ var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
7621
+ var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
7612
7622
  var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
7613
7623
  for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
7614
7624
  line <= end; line++) {
7615
- var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
7625
+ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
7616
7626
  if (left == right)
7617
7627
  { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
7618
7628
  else if (text.length > leftPos)
7619
7629
  { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
7620
7630
  }
7621
7631
  if (!ranges.length) { ranges.push(new Range(start, start)); }
7622
- setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7632
+ setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7623
7633
  {origin: "*mouse", scroll: false});
7624
7634
  cm.scrollIntoView(pos);
7625
7635
  } else {
@@ -7634,8 +7644,8 @@
7634
7644
  anchor = maxPos(oldRange.to(), range.head);
7635
7645
  }
7636
7646
  var ranges$1 = startSel.ranges.slice(0);
7637
- ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
7638
- setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7647
+ ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
7648
+ setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7639
7649
  }
7640
7650
  }
7641
7651
 
@@ -7651,9 +7661,9 @@
7651
7661
  var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
7652
7662
  if (!cur) { return }
7653
7663
  if (cmp(cur, lastPos) != 0) {
7654
- cm.curOp.focus = activeElt(doc(cm));
7664
+ cm.curOp.focus = activeElt(root(cm));
7655
7665
  extendTo(cur);
7656
- var visible = visibleLines(display, doc$1);
7666
+ var visible = visibleLines(display, doc);
7657
7667
  if (cur.line >= visible.to || cur.line < visible.from)
7658
7668
  { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
7659
7669
  } else {
@@ -7678,7 +7688,7 @@
7678
7688
  }
7679
7689
  off(display.wrapper.ownerDocument, "mousemove", move);
7680
7690
  off(display.wrapper.ownerDocument, "mouseup", up);
7681
- doc$1.history.lastSelOrigin = null;
7691
+ doc.history.lastSelOrigin = null;
7682
7692
  }
7683
7693
 
7684
7694
  var move = operation(cm, function (e) {
@@ -8678,7 +8688,7 @@
8678
8688
 
8679
8689
  signal(this, "overwriteToggle", this, this.state.overwrite);
8680
8690
  },
8681
- hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
8691
+ hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) },
8682
8692
  isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
8683
8693
 
8684
8694
  scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
@@ -8960,7 +8970,7 @@
8960
8970
  disableBrowserMagic(te);
8961
8971
  cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8962
8972
  te.value = lastCopied.text.join("\n");
8963
- var hadFocus = activeElt(div.ownerDocument);
8973
+ var hadFocus = activeElt(rootNode(div));
8964
8974
  selectInput(te);
8965
8975
  setTimeout(function () {
8966
8976
  cm.display.lineSpace.removeChild(kludge);
@@ -8983,7 +8993,7 @@
8983
8993
 
8984
8994
  ContentEditableInput.prototype.prepareSelection = function () {
8985
8995
  var result = prepareSelection(this.cm, false);
8986
- result.focus = activeElt(this.div.ownerDocument) == this.div;
8996
+ result.focus = activeElt(rootNode(this.div)) == this.div;
8987
8997
  return result
8988
8998
  };
8989
8999
 
@@ -9079,7 +9089,7 @@
9079
9089
 
9080
9090
  ContentEditableInput.prototype.focus = function () {
9081
9091
  if (this.cm.options.readOnly != "nocursor") {
9082
- if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
9092
+ if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div)
9083
9093
  { this.showSelection(this.prepareSelection(), true); }
9084
9094
  this.div.focus();
9085
9095
  }
@@ -9587,7 +9597,7 @@
9587
9597
  TextareaInput.prototype.supportsTouch = function () { return false };
9588
9598
 
9589
9599
  TextareaInput.prototype.focus = function () {
9590
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
9600
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) {
9591
9601
  try { this.textarea.focus(); }
9592
9602
  catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
9593
9603
  }
@@ -9794,7 +9804,7 @@
9794
9804
  // Set autofocus to true if this textarea is focused, or if it has
9795
9805
  // autofocus and no other element is focused.
9796
9806
  if (options.autofocus == null) {
9797
- var hasFocus = activeElt(textarea.ownerDocument);
9807
+ var hasFocus = activeElt(rootNode(textarea));
9798
9808
  options.autofocus = hasFocus == textarea ||
9799
9809
  textarea.getAttribute("autofocus") != null && hasFocus == document.body;
9800
9810
  }
@@ -9928,7 +9938,7 @@
9928
9938
 
9929
9939
  addLegacyProps(CodeMirror);
9930
9940
 
9931
- CodeMirror.version = "5.65.15";
9941
+ CodeMirror.version = "5.65.16";
9932
9942
 
9933
9943
  return CodeMirror;
9934
9944
 
@@ -16395,6 +16405,7 @@
16395
16405
  var _this = _super !== null && _super.apply(this, arguments) || this;
16396
16406
  _this._markedText = [];
16397
16407
  _this._initialText = "";
16408
+ _this._options = new Map();
16398
16409
  return _this;
16399
16410
  }
16400
16411
  Editor.prototype.options = function () {
@@ -16405,6 +16416,19 @@
16405
16416
  tabSize: 2
16406
16417
  };
16407
16418
  };
16419
+ Editor.prototype.option = function (option, value) {
16420
+ if (this._codemirror) {
16421
+ if (arguments.length < 2) {
16422
+ return this._codemirror.getOption(option);
16423
+ }
16424
+ this._codemirror.setOption(option, value);
16425
+ return this;
16426
+ }
16427
+ if (arguments.length < 2) {
16428
+ return this._options.get(option);
16429
+ }
16430
+ this._options.set(option, value);
16431
+ };
16408
16432
  Editor.prototype.guttersOption = function () {
16409
16433
  var gutters = ["CodeMirror-linenumbers"];
16410
16434
  if (this.gutterMarkerWidth() > 0) {
@@ -16526,6 +16550,9 @@
16526
16550
  this._codemirror.on("changes", function (cm, changes) {
16527
16551
  _this.changes(changes);
16528
16552
  });
16553
+ this._options.forEach(function (value, key) {
16554
+ _this._codemirror.setOption(key, value);
16555
+ });
16529
16556
  this.text(this._initialText);
16530
16557
  };
16531
16558
  Editor.prototype.update = function (domNode, Element) {
@@ -16538,6 +16565,9 @@
16538
16565
  // Events ---
16539
16566
  Editor.prototype.changes = function (changes) {
16540
16567
  };
16568
+ /**
16569
+ * @deprecated Replaced with `option`
16570
+ */
16541
16571
  Editor.prototype.setOption = function (option, value) {
16542
16572
  this._codemirror.setOption(option, value);
16543
16573
  };