@hpcc-js/codemirror 2.53.0 → 2.54.0

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,8 +1,8 @@
1
1
  import { Palette, HTMLWidget } from '@hpcc-js/common';
2
2
 
3
3
  var PKG_NAME = "@hpcc-js/codemirror";
4
- var PKG_VERSION = "2.53.0";
5
- var BUILD_VERSION = "2.94.0";
4
+ var PKG_VERSION = "2.54.0";
5
+ var BUILD_VERSION = "2.95.0";
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -94,7 +94,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
94
94
  var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
95
95
  var phantom = /PhantomJS/.test(userAgent);
96
96
 
97
- var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
97
+ var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
98
98
  var android = /Android/.test(userAgent);
99
99
  // This is woefully incomplete. Suggestions for alternative methods welcome.
100
100
  var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
@@ -266,7 +266,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
266
266
  }
267
267
 
268
268
  // Number of pixels added to scroller and sizer to hide scrollbar
269
- var scrollerGap = 30;
269
+ var scrollerGap = 50;
270
270
 
271
271
  // Returned or thrown by various protocols to signal 'I'm not
272
272
  // handling this'.
@@ -547,14 +547,15 @@ var codemirror = createCommonjsModule(function (module, exports) {
547
547
  for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
548
548
  order.push(new BidiSpan(0, start, i$7));
549
549
  } else {
550
- var pos = i$7, at = order.length;
550
+ var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
551
551
  for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
552
552
  for (var j$2 = pos; j$2 < i$7;) {
553
553
  if (countsAsNum.test(types[j$2])) {
554
- if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
554
+ if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; }
555
555
  var nstart = j$2;
556
556
  for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
557
557
  order.splice(at, 0, new BidiSpan(2, nstart, j$2));
558
+ at += isRTL;
558
559
  pos = j$2;
559
560
  } else { ++j$2; }
560
561
  }
@@ -1262,7 +1263,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
1262
1263
  var prop = lineClass[1] ? "bgClass" : "textClass";
1263
1264
  if (output[prop] == null)
1264
1265
  { output[prop] = lineClass[2]; }
1265
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
1266
+ else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop]))
1266
1267
  { output[prop] += " " + lineClass[2]; }
1267
1268
  } }
1268
1269
  return type
@@ -1372,6 +1373,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
1372
1373
  if (span.marker == marker) { return span }
1373
1374
  } }
1374
1375
  }
1376
+
1375
1377
  // Remove a span from an array, returning undefined if no spans are
1376
1378
  // left (we don't store arrays for lines without spans).
1377
1379
  function removeMarkedSpan(spans, span) {
@@ -1380,9 +1382,16 @@ var codemirror = createCommonjsModule(function (module, exports) {
1380
1382
  { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
1381
1383
  return r
1382
1384
  }
1385
+
1383
1386
  // Add a span to a line.
1384
- function addMarkedSpan(line, span) {
1385
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
1387
+ function addMarkedSpan(line, span, op) {
1388
+ var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet));
1389
+ if (inThisOp && inThisOp.has(line.markedSpans)) {
1390
+ line.markedSpans.push(span);
1391
+ } else {
1392
+ line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
1393
+ if (inThisOp) { inThisOp.add(line.markedSpans); }
1394
+ }
1386
1395
  span.marker.attachLine(line);
1387
1396
  }
1388
1397
 
@@ -1902,7 +1911,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
1902
1911
  }
1903
1912
  }
1904
1913
  builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
1905
- if (style || startStyle || endStyle || mustWrap || css) {
1914
+ if (style || startStyle || endStyle || mustWrap || css || attributes) {
1906
1915
  var fullStyle = style || "";
1907
1916
  if (startStyle) { fullStyle += startStyle; }
1908
1917
  if (endStyle) { fullStyle += endStyle; }
@@ -2247,6 +2256,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
2247
2256
  if (cm.options.lineNumbers || markers) {
2248
2257
  var wrap$1 = ensureLineWrapped(lineView);
2249
2258
  var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
2259
+ gutterWrap.setAttribute("aria-hidden", "true");
2250
2260
  cm.display.input.setUneditable(gutterWrap);
2251
2261
  wrap$1.insertBefore(gutterWrap, lineView.text);
2252
2262
  if (lineView.line.gutterClass)
@@ -2403,12 +2413,14 @@ var codemirror = createCommonjsModule(function (module, exports) {
2403
2413
  function mapFromLineView(lineView, line, lineN) {
2404
2414
  if (lineView.line == line)
2405
2415
  { return {map: lineView.measure.map, cache: lineView.measure.cache} }
2406
- for (var i = 0; i < lineView.rest.length; i++)
2407
- { if (lineView.rest[i] == line)
2408
- { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
2409
- for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
2410
- { if (lineNo(lineView.rest[i$1]) > lineN)
2411
- { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
2416
+ if (lineView.rest) {
2417
+ for (var i = 0; i < lineView.rest.length; i++)
2418
+ { if (lineView.rest[i] == line)
2419
+ { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
2420
+ for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
2421
+ { if (lineNo(lineView.rest[i$1]) > lineN)
2422
+ { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
2423
+ }
2412
2424
  }
2413
2425
 
2414
2426
  // Render a line into the hidden node display.externalMeasured. Used
@@ -3021,7 +3033,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3021
3033
  var x, y, space = display.lineSpace.getBoundingClientRect();
3022
3034
  // Fails unpredictably on IE[67] when mouse is dragged around quickly.
3023
3035
  try { x = e.clientX - space.left; y = e.clientY - space.top; }
3024
- catch (e) { return null }
3036
+ catch (e$1) { return null }
3025
3037
  var coords = coordsChar(cm, x, y), line;
3026
3038
  if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
3027
3039
  var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
@@ -3202,13 +3214,19 @@ var codemirror = createCommonjsModule(function (module, exports) {
3202
3214
  var curFragment = result.cursors = document.createDocumentFragment();
3203
3215
  var selFragment = result.selection = document.createDocumentFragment();
3204
3216
 
3217
+ var customCursor = cm.options.$customCursor;
3218
+ if (customCursor) { primary = true; }
3205
3219
  for (var i = 0; i < doc.sel.ranges.length; i++) {
3206
3220
  if (!primary && i == doc.sel.primIndex) { continue }
3207
3221
  var range = doc.sel.ranges[i];
3208
3222
  if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
3209
3223
  var collapsed = range.empty();
3210
- if (collapsed || cm.options.showCursorWhenSelecting)
3211
- { drawSelectionCursor(cm, range.head, curFragment); }
3224
+ if (customCursor) {
3225
+ var head = customCursor(cm, range);
3226
+ if (head) { drawSelectionCursor(cm, head, curFragment); }
3227
+ } else if (collapsed || cm.options.showCursorWhenSelecting) {
3228
+ drawSelectionCursor(cm, range.head, curFragment);
3229
+ }
3212
3230
  if (!collapsed)
3213
3231
  { drawSelectionRange(cm, range, selFragment); }
3214
3232
  }
@@ -3224,6 +3242,12 @@ var codemirror = createCommonjsModule(function (module, exports) {
3224
3242
  cursor.style.top = pos.top + "px";
3225
3243
  cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
3226
3244
 
3245
+ if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) {
3246
+ var charPos = charCoords(cm, head, "div", null, null);
3247
+ var width = charPos.right - charPos.left;
3248
+ cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px";
3249
+ }
3250
+
3227
3251
  if (pos.other) {
3228
3252
  // Secondary cursor, shown when on a 'jump' in bi-directional text
3229
3253
  var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
@@ -3337,26 +3361,31 @@ var codemirror = createCommonjsModule(function (module, exports) {
3337
3361
  var on = true;
3338
3362
  display.cursorDiv.style.visibility = "";
3339
3363
  if (cm.options.cursorBlinkRate > 0)
3340
- { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
3341
- cm.options.cursorBlinkRate); }
3364
+ { display.blinker = setInterval(function () {
3365
+ if (!cm.hasFocus()) { onBlur(cm); }
3366
+ display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
3367
+ }, cm.options.cursorBlinkRate); }
3342
3368
  else if (cm.options.cursorBlinkRate < 0)
3343
3369
  { display.cursorDiv.style.visibility = "hidden"; }
3344
3370
  }
3345
3371
 
3346
3372
  function ensureFocus(cm) {
3347
- if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
3373
+ if (!cm.hasFocus()) {
3374
+ cm.display.input.focus();
3375
+ if (!cm.state.focused) { onFocus(cm); }
3376
+ }
3348
3377
  }
3349
3378
 
3350
3379
  function delayBlurEvent(cm) {
3351
3380
  cm.state.delayingBlurEvent = true;
3352
3381
  setTimeout(function () { if (cm.state.delayingBlurEvent) {
3353
3382
  cm.state.delayingBlurEvent = false;
3354
- onBlur(cm);
3383
+ if (cm.state.focused) { onBlur(cm); }
3355
3384
  } }, 100);
3356
3385
  }
3357
3386
 
3358
3387
  function onFocus(cm, e) {
3359
- if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
3388
+ if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; }
3360
3389
 
3361
3390
  if (cm.options.readOnly == "nocursor") { return }
3362
3391
  if (!cm.state.focused) {
@@ -3391,10 +3420,14 @@ var codemirror = createCommonjsModule(function (module, exports) {
3391
3420
  function updateHeightsInViewport(cm) {
3392
3421
  var display = cm.display;
3393
3422
  var prevBottom = display.lineDiv.offsetTop;
3423
+ var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top);
3424
+ var oldHeight = display.lineDiv.getBoundingClientRect().top;
3425
+ var mustScroll = 0;
3394
3426
  for (var i = 0; i < display.view.length; i++) {
3395
3427
  var cur = display.view[i], wrapping = cm.options.lineWrapping;
3396
3428
  var height = (void 0), width = 0;
3397
3429
  if (cur.hidden) { continue }
3430
+ oldHeight += cur.line.height;
3398
3431
  if (ie && ie_version < 8) {
3399
3432
  var bot = cur.node.offsetTop + cur.node.offsetHeight;
3400
3433
  height = bot - prevBottom;
@@ -3409,6 +3442,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3409
3442
  }
3410
3443
  var diff = cur.line.height - height;
3411
3444
  if (diff > .005 || diff < -.005) {
3445
+ if (oldHeight < viewTop) { mustScroll -= diff; }
3412
3446
  updateLineHeight(cur.line, height);
3413
3447
  updateWidgetHeight(cur.line);
3414
3448
  if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
@@ -3423,6 +3457,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3423
3457
  }
3424
3458
  }
3425
3459
  }
3460
+ if (Math.abs(mustScroll) > 2) { display.scroller.scrollTop += mustScroll; }
3426
3461
  }
3427
3462
 
3428
3463
  // Read and store the height of line widgets associated with the
@@ -3486,8 +3521,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
3486
3521
  // Set pos and end to the cursor positions around the character pos sticks to
3487
3522
  // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
3488
3523
  // If pos == Pos(_, 0, "before"), pos and end are unchanged
3489
- pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
3490
3524
  end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
3525
+ pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
3491
3526
  }
3492
3527
  for (var limit = 0; limit < 5; limit++) {
3493
3528
  var changed = false;
@@ -3538,14 +3573,15 @@ var codemirror = createCommonjsModule(function (module, exports) {
3538
3573
  if (newTop != screentop) { result.scrollTop = newTop; }
3539
3574
  }
3540
3575
 
3541
- var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
3542
- var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
3576
+ var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth;
3577
+ var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace;
3578
+ var screenw = displayWidth(cm) - display.gutters.offsetWidth;
3543
3579
  var tooWide = rect.right - rect.left > screenw;
3544
3580
  if (tooWide) { rect.right = rect.left + screenw; }
3545
3581
  if (rect.left < 10)
3546
3582
  { result.scrollLeft = 0; }
3547
3583
  else if (rect.left < screenleft)
3548
- { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
3584
+ { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); }
3549
3585
  else if (rect.right > screenw + screenleft - 3)
3550
3586
  { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
3551
3587
  return result
@@ -3612,7 +3648,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3612
3648
  }
3613
3649
 
3614
3650
  function setScrollTop(cm, val, forceScroll) {
3615
- val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
3651
+ val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val));
3616
3652
  if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
3617
3653
  cm.doc.scrollTop = val;
3618
3654
  cm.display.scrollbars.setScrollTop(val);
@@ -3622,7 +3658,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3622
3658
  // Sync scroller and scrollbar, ensure the gutter elements are
3623
3659
  // aligned.
3624
3660
  function setScrollLeft(cm, val, isScroller, forceScroll) {
3625
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
3661
+ val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth));
3626
3662
  if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
3627
3663
  cm.doc.scrollLeft = val;
3628
3664
  alignHorizontally(cm);
@@ -3682,6 +3718,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
3682
3718
  this.vert.firstChild.style.height =
3683
3719
  Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
3684
3720
  } else {
3721
+ this.vert.scrollTop = 0;
3685
3722
  this.vert.style.display = "";
3686
3723
  this.vert.firstChild.style.height = "0";
3687
3724
  }
@@ -3837,7 +3874,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
3837
3874
  scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
3838
3875
  scrollToPos: null, // Used to scroll to a specific position
3839
3876
  focus: false,
3840
- id: ++nextOpId // Unique ID
3877
+ id: ++nextOpId, // Unique ID
3878
+ markArrays: null // Used by addMarkedSpan
3841
3879
  };
3842
3880
  pushOperation(cm.curOp);
3843
3881
  }
@@ -4111,7 +4149,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
4111
4149
  function restoreSelection(snapshot) {
4112
4150
  if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
4113
4151
  snapshot.activeElt.focus();
4114
- if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4152
+ if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
4153
+ snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4115
4154
  var sel = window.getSelection(), range = document.createRange();
4116
4155
  range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
4117
4156
  range.collapse(false);
@@ -4209,6 +4248,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
4209
4248
  update.visible = visibleLines(cm.display, cm.doc, viewport);
4210
4249
  if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
4211
4250
  { break }
4251
+ } else if (first) {
4252
+ update.visible = visibleLines(cm.display, cm.doc, viewport);
4212
4253
  }
4213
4254
  if (!updateDisplayIfNeeded(cm, update)) { break }
4214
4255
  updateHeightsInViewport(cm);
@@ -4287,6 +4328,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
4287
4328
  function updateGutterSpace(display) {
4288
4329
  var width = display.gutters.offsetWidth;
4289
4330
  display.sizer.style.marginLeft = width + "px";
4331
+ // Send an event to consumers responding to changes in gutter width.
4332
+ signalLater(display, "gutterChanged", display);
4290
4333
  }
4291
4334
 
4292
4335
  function setDocumentHeight(cm, measure) {
@@ -4426,6 +4469,10 @@ var codemirror = createCommonjsModule(function (module, exports) {
4426
4469
  // The element in which the editor lives.
4427
4470
  d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
4428
4471
 
4472
+ // This attribute is respected by automatic translation systems such as Google Translate,
4473
+ // and may also be respected by tools used by human translators.
4474
+ d.wrapper.setAttribute('translate', 'no');
4475
+
4429
4476
  // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
4430
4477
  if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
4431
4478
  if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
@@ -4523,6 +4570,12 @@ var codemirror = createCommonjsModule(function (module, exports) {
4523
4570
 
4524
4571
  function onScrollWheel(cm, e) {
4525
4572
  var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
4573
+ var pixelsPerUnit = wheelPixelsPerUnit;
4574
+ if (e.deltaMode === 0) {
4575
+ dx = e.deltaX;
4576
+ dy = e.deltaY;
4577
+ pixelsPerUnit = 1;
4578
+ }
4526
4579
 
4527
4580
  var display = cm.display, scroll = display.scroller;
4528
4581
  // Quit if there's nothing to scroll here
@@ -4551,10 +4604,10 @@ var codemirror = createCommonjsModule(function (module, exports) {
4551
4604
  // estimated pixels/delta value, we just handle horizontal
4552
4605
  // scrolling entirely here. It'll be slightly off from native, but
4553
4606
  // better than glitching out.
4554
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
4607
+ if (dx && !gecko && !presto && pixelsPerUnit != null) {
4555
4608
  if (dy && canScrollY)
4556
- { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
4557
- setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
4609
+ { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit)); }
4610
+ setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit));
4558
4611
  // Only prevent default scrolling if vertical scrolling is
4559
4612
  // actually possible. Otherwise, it causes vertical scroll
4560
4613
  // jitter on OSX trackpads when deltaX is small and deltaY
@@ -4567,15 +4620,15 @@ var codemirror = createCommonjsModule(function (module, exports) {
4567
4620
 
4568
4621
  // 'Project' the visible viewport to cover the area that is being
4569
4622
  // scrolled into view (if we know enough to estimate it).
4570
- if (dy && wheelPixelsPerUnit != null) {
4571
- var pixels = dy * wheelPixelsPerUnit;
4623
+ if (dy && pixelsPerUnit != null) {
4624
+ var pixels = dy * pixelsPerUnit;
4572
4625
  var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
4573
4626
  if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
4574
4627
  else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
4575
4628
  updateDisplaySimple(cm, {top: top, bottom: bot});
4576
4629
  }
4577
4630
 
4578
- if (wheelSamples < 20) {
4631
+ if (wheelSamples < 20 && e.deltaMode !== 0) {
4579
4632
  if (display.wheelStartX == null) {
4580
4633
  display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
4581
4634
  display.wheelDX = dx; display.wheelDY = dy;
@@ -4834,6 +4887,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
4834
4887
  estimateLineHeights(cm);
4835
4888
  loadMode(cm);
4836
4889
  setDirectionClass(cm);
4890
+ cm.options.direction = doc.direction;
4837
4891
  if (!cm.options.lineWrapping) { findMaxLine(cm); }
4838
4892
  cm.options.mode = doc.modeOption;
4839
4893
  regChange(cm);
@@ -4850,19 +4904,19 @@ var codemirror = createCommonjsModule(function (module, exports) {
4850
4904
  });
4851
4905
  }
4852
4906
 
4853
- function History(startGen) {
4907
+ function History(prev) {
4854
4908
  // Arrays of change events and selections. Doing something adds an
4855
4909
  // event to done and clears undo. Undoing moves events from done
4856
4910
  // to undone, redoing moves them in the other direction.
4857
4911
  this.done = []; this.undone = [];
4858
- this.undoDepth = Infinity;
4912
+ this.undoDepth = prev ? prev.undoDepth : Infinity;
4859
4913
  // Used to track when changes can be merged into a single undo
4860
4914
  // event
4861
4915
  this.lastModTime = this.lastSelTime = 0;
4862
4916
  this.lastOp = this.lastSelOp = null;
4863
4917
  this.lastOrigin = this.lastSelOrigin = null;
4864
4918
  // Used by the isClean() method
4865
- this.generation = this.maxGeneration = startGen || 1;
4919
+ this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1;
4866
4920
  }
4867
4921
 
4868
4922
  // Create a history change event from an updateDoc-style change
@@ -5167,7 +5221,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
5167
5221
  (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
5168
5222
  setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
5169
5223
 
5170
- if (!(options && options.scroll === false) && doc.cm)
5224
+ if (!(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor")
5171
5225
  { ensureCursorVisible(doc.cm); }
5172
5226
  }
5173
5227
 
@@ -5824,7 +5878,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
5824
5878
  changeLine(doc, handle, "widget", function (line) {
5825
5879
  var widgets = line.widgets || (line.widgets = []);
5826
5880
  if (widget.insertAt == null) { widgets.push(widget); }
5827
- else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
5881
+ else { widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget); }
5828
5882
  widget.line = line;
5829
5883
  if (cm && !lineIsHidden(doc, line)) {
5830
5884
  var aboveVisible = heightAtLine(line) < doc.scrollTop;
@@ -6010,7 +6064,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6010
6064
  if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
6011
6065
  addMarkedSpan(line, new MarkedSpan(marker,
6012
6066
  curLine == from.line ? from.ch : null,
6013
- curLine == to.line ? to.ch : null));
6067
+ curLine == to.line ? to.ch : null), doc.cm && doc.cm.curOp);
6014
6068
  ++curLine;
6015
6069
  });
6016
6070
  // lineIsHidden depends on the presence of the spans, so needs a second pass
@@ -6182,6 +6236,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6182
6236
  getRange: function(from, to, lineSep) {
6183
6237
  var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
6184
6238
  if (lineSep === false) { return lines }
6239
+ if (lineSep === '') { return lines.join('') }
6185
6240
  return lines.join(lineSep || this.lineSeparator())
6186
6241
  },
6187
6242
 
@@ -6233,7 +6288,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6233
6288
  var out = [];
6234
6289
  for (var i = 0; i < ranges.length; i++)
6235
6290
  { out[i] = new Range(clipPos(this, ranges[i].anchor),
6236
- clipPos(this, ranges[i].head)); }
6291
+ clipPos(this, ranges[i].head || ranges[i].anchor)); }
6237
6292
  if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
6238
6293
  setSelection(this, normalizeSelection(this.cm, out, primary), options);
6239
6294
  }),
@@ -6293,7 +6348,12 @@ var codemirror = createCommonjsModule(function (module, exports) {
6293
6348
  for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
6294
6349
  return {undo: done, redo: undone}
6295
6350
  },
6296
- clearHistory: function() {this.history = new History(this.history.maxGeneration);},
6351
+ clearHistory: function() {
6352
+ var this$1 = this;
6353
+
6354
+ this.history = new History(this.history);
6355
+ linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true);
6356
+ },
6297
6357
 
6298
6358
  markClean: function() {
6299
6359
  this.cleanGeneration = this.changeGeneration(true);
@@ -6312,7 +6372,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6312
6372
  undone: copyHistoryArray(this.history.undone)}
6313
6373
  },
6314
6374
  setHistory: function(histData) {
6315
- var hist = this.history = new History(this.history.maxGeneration);
6375
+ var hist = this.history = new History(this.history);
6316
6376
  hist.done = copyHistoryArray(histData.done.slice(0), null, true);
6317
6377
  hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
6318
6378
  },
@@ -6544,28 +6604,39 @@ var codemirror = createCommonjsModule(function (module, exports) {
6544
6604
  // and insert it.
6545
6605
  if (files && files.length && window.FileReader && window.File) {
6546
6606
  var n = files.length, text = Array(n), read = 0;
6547
- var loadFile = function (file, i) {
6548
- if (cm.options.allowDropFileTypes &&
6549
- indexOf(cm.options.allowDropFileTypes, file.type) == -1)
6550
- { return }
6551
-
6552
- var reader = new FileReader;
6553
- reader.onload = operation(cm, function () {
6554
- var content = reader.result;
6555
- if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
6556
- text[i] = content;
6557
- if (++read == n) {
6607
+ var markAsReadAndPasteIfAllFilesAreRead = function () {
6608
+ if (++read == n) {
6609
+ operation(cm, function () {
6558
6610
  pos = clipPos(cm.doc, pos);
6559
6611
  var change = {from: pos, to: pos,
6560
- text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
6612
+ text: cm.doc.splitLines(
6613
+ text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())),
6561
6614
  origin: "paste"};
6562
6615
  makeChange(cm.doc, change);
6563
- setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
6616
+ setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change))));
6617
+ })();
6618
+ }
6619
+ };
6620
+ var readTextFromFile = function (file, i) {
6621
+ if (cm.options.allowDropFileTypes &&
6622
+ indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
6623
+ markAsReadAndPasteIfAllFilesAreRead();
6624
+ return
6625
+ }
6626
+ var reader = new FileReader;
6627
+ reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); };
6628
+ reader.onload = function () {
6629
+ var content = reader.result;
6630
+ if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
6631
+ markAsReadAndPasteIfAllFilesAreRead();
6632
+ return
6564
6633
  }
6565
- });
6634
+ text[i] = content;
6635
+ markAsReadAndPasteIfAllFilesAreRead();
6636
+ };
6566
6637
  reader.readAsText(file);
6567
6638
  };
6568
- for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
6639
+ for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); }
6569
6640
  } else { // Normal drop
6570
6641
  // Don't do a replace if the drop happened inside of the selected text.
6571
6642
  if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
@@ -6587,7 +6658,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6587
6658
  cm.display.input.focus();
6588
6659
  }
6589
6660
  }
6590
- catch(e){}
6661
+ catch(e$1){}
6591
6662
  }
6592
6663
  }
6593
6664
 
@@ -6683,7 +6754,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6683
6754
  46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
6684
6755
  106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
6685
6756
  173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
6686
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
6757
+ 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
6687
6758
  63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
6688
6759
  };
6689
6760
 
@@ -6720,10 +6791,9 @@ var codemirror = createCommonjsModule(function (module, exports) {
6720
6791
  // Very basic readline/emacs-style bindings, which are standard on Mac.
6721
6792
  keyMap.emacsy = {
6722
6793
  "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
6723
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
6724
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
6725
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
6726
- "Ctrl-O": "openLine"
6794
+ "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp",
6795
+ "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine",
6796
+ "Ctrl-T": "transposeChars", "Ctrl-O": "openLine"
6727
6797
  };
6728
6798
  keyMap.macDefault = {
6729
6799
  "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
@@ -6818,7 +6888,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6818
6888
  var base = name;
6819
6889
  if (event.altKey && base != "Alt") { name = "Alt-" + name; }
6820
6890
  if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
6821
- if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
6891
+ if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") { name = "Cmd-" + name; }
6822
6892
  if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
6823
6893
  return name
6824
6894
  }
@@ -6875,6 +6945,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
6875
6945
 
6876
6946
  function endOfLine(visually, cm, lineObj, lineNo, dir) {
6877
6947
  if (visually) {
6948
+ if (cm.doc.direction == "rtl") { dir = -dir; }
6878
6949
  var order = getOrder(lineObj, cm.doc.direction);
6879
6950
  if (order) {
6880
6951
  var part = dir < 0 ? lst(order) : order[0];
@@ -7043,7 +7114,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7043
7114
  goGroupRight: function (cm) { return cm.moveH(1, "group"); },
7044
7115
  goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
7045
7116
  goWordRight: function (cm) { return cm.moveH(1, "word"); },
7046
- delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
7117
+ delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); },
7047
7118
  delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
7048
7119
  delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
7049
7120
  delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
@@ -7129,7 +7200,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7129
7200
  var line = getLine(cm.doc, start.line);
7130
7201
  var order = getOrder(line, cm.doc.direction);
7131
7202
  if (!order || order[0].level == 0) {
7132
- var firstNonWS = Math.max(0, line.text.search(/\S/));
7203
+ var firstNonWS = Math.max(start.ch, line.text.search(/\S/));
7133
7204
  var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
7134
7205
  return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
7135
7206
  }
@@ -7232,6 +7303,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7232
7303
  var lastStoppedKey = null;
7233
7304
  function onKeyDown(e) {
7234
7305
  var cm = this;
7306
+ if (e.target && e.target != cm.display.input.getField()) { return }
7235
7307
  cm.curOp.focus = activeElt();
7236
7308
  if (signalDOMEvent(cm, e)) { return }
7237
7309
  // IE does strange things with escape.
@@ -7275,6 +7347,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7275
7347
 
7276
7348
  function onKeyPress(e) {
7277
7349
  var cm = this;
7350
+ if (e.target && e.target != cm.display.input.getField()) { return }
7278
7351
  if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
7279
7352
  var keyCode = e.keyCode, charCode = e.charCode;
7280
7353
  if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
@@ -7414,6 +7487,10 @@ var codemirror = createCommonjsModule(function (module, exports) {
7414
7487
  var dragEnd = operation(cm, function (e) {
7415
7488
  if (webkit) { display.scroller.draggable = false; }
7416
7489
  cm.state.draggingText = false;
7490
+ if (cm.state.delayingBlurEvent) {
7491
+ if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; }
7492
+ else { delayBlurEvent(cm); }
7493
+ }
7417
7494
  off(display.wrapper.ownerDocument, "mouseup", dragEnd);
7418
7495
  off(display.wrapper.ownerDocument, "mousemove", mouseMove);
7419
7496
  off(display.scroller, "dragstart", dragStart);
@@ -7423,8 +7500,8 @@ var codemirror = createCommonjsModule(function (module, exports) {
7423
7500
  if (!behavior.addNew)
7424
7501
  { extendSelection(cm.doc, pos, null, null, behavior.extend); }
7425
7502
  // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
7426
- if (webkit || ie && ie_version == 9)
7427
- { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
7503
+ if ((webkit && !safari) || ie && ie_version == 9)
7504
+ { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); }
7428
7505
  else
7429
7506
  { display.input.focus(); }
7430
7507
  }
@@ -7437,15 +7514,15 @@ var codemirror = createCommonjsModule(function (module, exports) {
7437
7514
  if (webkit) { display.scroller.draggable = true; }
7438
7515
  cm.state.draggingText = dragEnd;
7439
7516
  dragEnd.copy = !behavior.moveOnDrag;
7440
- // IE's approach to draggable
7441
- if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
7442
7517
  on(display.wrapper.ownerDocument, "mouseup", dragEnd);
7443
7518
  on(display.wrapper.ownerDocument, "mousemove", mouseMove);
7444
7519
  on(display.scroller, "dragstart", dragStart);
7445
7520
  on(display.scroller, "drop", dragEnd);
7446
7521
 
7447
- delayBlurEvent(cm);
7522
+ cm.state.delayingBlurEvent = true;
7448
7523
  setTimeout(function () { return display.input.focus(); }, 20);
7524
+ // IE's approach to draggable
7525
+ if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
7449
7526
  }
7450
7527
 
7451
7528
  function rangeForUnit(cm, pos, unit) {
@@ -7458,6 +7535,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7458
7535
 
7459
7536
  // Normal selection, as opposed to text dragging.
7460
7537
  function leftButtonSelect(cm, event, start, behavior) {
7538
+ if (ie) { delayBlurEvent(cm); }
7461
7539
  var display = cm.display, doc = cm.doc;
7462
7540
  e_preventDefault(event);
7463
7541
 
@@ -7636,7 +7714,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7636
7714
  mY = e.touches[0].clientY;
7637
7715
  } else {
7638
7716
  try { mX = e.clientX; mY = e.clientY; }
7639
- catch(e) { return false }
7717
+ catch(e$1) { return false }
7640
7718
  }
7641
7719
  if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
7642
7720
  if (prevent) { e_preventDefault(e); }
@@ -7736,7 +7814,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
7736
7814
  for (var i = newBreaks.length - 1; i >= 0; i--)
7737
7815
  { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
7738
7816
  });
7739
- option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7817
+ option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7740
7818
  cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
7741
7819
  if (old != Init) { cm.refresh(); }
7742
7820
  });
@@ -7800,6 +7878,12 @@ var codemirror = createCommonjsModule(function (module, exports) {
7800
7878
  }
7801
7879
  cm.display.input.readOnlyChanged(val);
7802
7880
  });
7881
+
7882
+ option("screenReaderLabel", null, function (cm, val) {
7883
+ val = (val === '') ? null : val;
7884
+ cm.display.input.screenReaderLabelChanged(val);
7885
+ });
7886
+
7803
7887
  option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
7804
7888
  option("dragDrop", true, dragDropChanged);
7805
7889
  option("allowDropFileTypes", null);
@@ -7910,7 +7994,9 @@ var codemirror = createCommonjsModule(function (module, exports) {
7910
7994
  attachDoc(this, doc);
7911
7995
 
7912
7996
  if ((options.autofocus && !mobile) || this.hasFocus())
7913
- { setTimeout(bind(onFocus, this), 20); }
7997
+ { setTimeout(function () {
7998
+ if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); }
7999
+ }, 20); }
7914
8000
  else
7915
8001
  { onBlur(this); }
7916
8002
 
@@ -7952,6 +8038,9 @@ var codemirror = createCommonjsModule(function (module, exports) {
7952
8038
  // which point we can't mess with it anymore. Context menu is
7953
8039
  // handled in onMouseDown for these browsers.
7954
8040
  on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); });
8041
+ on(d.input.getField(), "contextmenu", function (e) {
8042
+ if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); }
8043
+ });
7955
8044
 
7956
8045
  // Used to suppress mouse event handling when a touch happens
7957
8046
  var touchFinished, prevTouch = {end: 0};
@@ -8147,7 +8236,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8147
8236
  { from = Pos(from.line, from.ch - deleted); }
8148
8237
  else if (cm.state.overwrite && !paste) // Handle overwrite
8149
8238
  { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
8150
- else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
8239
+ else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n"))
8151
8240
  { from = to = Pos(from.line, 0); }
8152
8241
  }
8153
8242
  var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
@@ -8216,7 +8305,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8216
8305
  }
8217
8306
 
8218
8307
  function hiddenTextarea() {
8219
- var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
8308
+ var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none");
8220
8309
  var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
8221
8310
  // The textarea is kept positioned near the cursor to prevent the
8222
8311
  // fact that it'll be scrolled into view on input from scrolling
@@ -8628,7 +8717,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8628
8717
  clearCaches(this);
8629
8718
  scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
8630
8719
  updateGutterSpace(this.display);
8631
- if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
8720
+ if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping)
8632
8721
  { estimateLineHeights(this); }
8633
8722
  signal(this, "refresh", this);
8634
8723
  }),
@@ -8670,34 +8759,43 @@ var codemirror = createCommonjsModule(function (module, exports) {
8670
8759
  }
8671
8760
 
8672
8761
  // Used for horizontal relative motion. Dir is -1 or 1 (left or
8673
- // right), unit can be "char", "column" (like char, but doesn't
8674
- // cross line boundaries), "word" (across next word), or "group" (to
8675
- // the start of next group of word or non-word-non-whitespace
8676
- // chars). The visually param controls whether, in right-to-left
8677
- // text, direction 1 means to move towards the next index in the
8678
- // string, or towards the character to the right of the current
8679
- // position. The resulting position will have a hitSide=true
8680
- // property if it reached the end of the document.
8762
+ // right), unit can be "codepoint", "char", "column" (like char, but
8763
+ // doesn't cross line boundaries), "word" (across next word), or
8764
+ // "group" (to the start of next group of word or
8765
+ // non-word-non-whitespace chars). The visually param controls
8766
+ // whether, in right-to-left text, direction 1 means to move towards
8767
+ // the next index in the string, or towards the character to the right
8768
+ // of the current position. The resulting position will have a
8769
+ // hitSide=true property if it reached the end of the document.
8681
8770
  function findPosH(doc, pos, dir, unit, visually) {
8682
8771
  var oldPos = pos;
8683
8772
  var origDir = dir;
8684
8773
  var lineObj = getLine(doc, pos.line);
8774
+ var lineDir = visually && doc.direction == "rtl" ? -dir : dir;
8685
8775
  function findNextLine() {
8686
- var l = pos.line + dir;
8776
+ var l = pos.line + lineDir;
8687
8777
  if (l < doc.first || l >= doc.first + doc.size) { return false }
8688
8778
  pos = new Pos(l, pos.ch, pos.sticky);
8689
8779
  return lineObj = getLine(doc, l)
8690
8780
  }
8691
8781
  function moveOnce(boundToLine) {
8692
8782
  var next;
8693
- if (visually) {
8783
+ if (unit == "codepoint") {
8784
+ var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1));
8785
+ if (isNaN(ch)) {
8786
+ next = null;
8787
+ } else {
8788
+ var astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF;
8789
+ next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir);
8790
+ }
8791
+ } else if (visually) {
8694
8792
  next = moveVisually(doc.cm, lineObj, pos, dir);
8695
8793
  } else {
8696
8794
  next = moveLogically(lineObj, pos, dir);
8697
8795
  }
8698
8796
  if (next == null) {
8699
8797
  if (!boundToLine && findNextLine())
8700
- { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
8798
+ { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); }
8701
8799
  else
8702
8800
  { return false }
8703
8801
  } else {
@@ -8706,7 +8804,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8706
8804
  return true
8707
8805
  }
8708
8806
 
8709
- if (unit == "char") {
8807
+ if (unit == "char" || unit == "codepoint") {
8710
8808
  moveOnce();
8711
8809
  } else if (unit == "column") {
8712
8810
  moveOnce(true);
@@ -8774,10 +8872,19 @@ var codemirror = createCommonjsModule(function (module, exports) {
8774
8872
 
8775
8873
  var input = this, cm = input.cm;
8776
8874
  var div = input.div = display.lineDiv;
8875
+ div.contentEditable = true;
8777
8876
  disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
8778
8877
 
8878
+ function belongsToInput(e) {
8879
+ for (var t = e.target; t; t = t.parentNode) {
8880
+ if (t == div) { return true }
8881
+ if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break }
8882
+ }
8883
+ return false
8884
+ }
8885
+
8779
8886
  on(div, "paste", function (e) {
8780
- if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
8887
+ if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
8781
8888
  // IE doesn't fire input events, so we schedule a read for the pasted content in this way
8782
8889
  if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
8783
8890
  });
@@ -8802,7 +8909,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8802
8909
  });
8803
8910
 
8804
8911
  function onCopyCut(e) {
8805
- if (signalDOMEvent(cm, e)) { return }
8912
+ if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return }
8806
8913
  if (cm.somethingSelected()) {
8807
8914
  setLastCopied({lineWise: false, text: cm.getSelections()});
8808
8915
  if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
@@ -8832,7 +8939,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8832
8939
  var kludge = hiddenTextarea(), te = kludge.firstChild;
8833
8940
  cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8834
8941
  te.value = lastCopied.text.join("\n");
8835
- var hadFocus = document.activeElement;
8942
+ var hadFocus = activeElt();
8836
8943
  selectInput(te);
8837
8944
  setTimeout(function () {
8838
8945
  cm.display.lineSpace.removeChild(kludge);
@@ -8844,9 +8951,18 @@ var codemirror = createCommonjsModule(function (module, exports) {
8844
8951
  on(div, "cut", onCopyCut);
8845
8952
  };
8846
8953
 
8954
+ ContentEditableInput.prototype.screenReaderLabelChanged = function (label) {
8955
+ // Label for screenreaders, accessibility
8956
+ if(label) {
8957
+ this.div.setAttribute('aria-label', label);
8958
+ } else {
8959
+ this.div.removeAttribute('aria-label');
8960
+ }
8961
+ };
8962
+
8847
8963
  ContentEditableInput.prototype.prepareSelection = function () {
8848
8964
  var result = prepareSelection(this.cm, false);
8849
- result.focus = this.cm.state.focused;
8965
+ result.focus = activeElt() == this.div;
8850
8966
  return result
8851
8967
  };
8852
8968
 
@@ -8942,7 +9058,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
8942
9058
 
8943
9059
  ContentEditableInput.prototype.focus = function () {
8944
9060
  if (this.cm.options.readOnly != "nocursor") {
8945
- if (!this.selectionInEditor())
9061
+ if (!this.selectionInEditor() || activeElt() != this.div)
8946
9062
  { this.showSelection(this.prepareSelection(), true); }
8947
9063
  this.div.focus();
8948
9064
  }
@@ -8953,9 +9069,11 @@ var codemirror = createCommonjsModule(function (module, exports) {
8953
9069
  ContentEditableInput.prototype.supportsTouch = function () { return true };
8954
9070
 
8955
9071
  ContentEditableInput.prototype.receivedFocus = function () {
9072
+ var this$1 = this;
9073
+
8956
9074
  var input = this;
8957
9075
  if (this.selectionInEditor())
8958
- { this.pollSelection(); }
9076
+ { setTimeout(function () { return this$1.pollSelection(); }, 20); }
8959
9077
  else
8960
9078
  { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
8961
9079
 
@@ -9384,6 +9502,15 @@ var codemirror = createCommonjsModule(function (module, exports) {
9384
9502
  this.textarea = this.wrapper.firstChild;
9385
9503
  };
9386
9504
 
9505
+ TextareaInput.prototype.screenReaderLabelChanged = function (label) {
9506
+ // Label for screenreaders, accessibility
9507
+ if(label) {
9508
+ this.textarea.setAttribute('aria-label', label);
9509
+ } else {
9510
+ this.textarea.removeAttribute('aria-label');
9511
+ }
9512
+ };
9513
+
9387
9514
  TextareaInput.prototype.prepareSelection = function () {
9388
9515
  // Redraw the selection and/or cursor
9389
9516
  var cm = this.cm, display = cm.display, doc = cm.doc;
@@ -9624,6 +9751,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
9624
9751
  TextareaInput.prototype.readOnlyChanged = function (val) {
9625
9752
  if (!val) { this.reset(); }
9626
9753
  this.textarea.disabled = val == "nocursor";
9754
+ this.textarea.readOnly = !!val;
9627
9755
  };
9628
9756
 
9629
9757
  TextareaInput.prototype.setUneditable = function () {};
@@ -9774,7 +9902,7 @@ var codemirror = createCommonjsModule(function (module, exports) {
9774
9902
 
9775
9903
  addLegacyProps(CodeMirror);
9776
9904
 
9777
- CodeMirror.version = "5.50.2";
9905
+ CodeMirror.version = "5.65.0";
9778
9906
 
9779
9907
  return CodeMirror;
9780
9908
 
@@ -9807,7 +9935,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
9807
9935
  valueKeywords = parserConfig.valueKeywords || {},
9808
9936
  allowNested = parserConfig.allowNested,
9809
9937
  lineComment = parserConfig.lineComment,
9810
- supportsAtComponent = parserConfig.supportsAtComponent === true;
9938
+ supportsAtComponent = parserConfig.supportsAtComponent === true,
9939
+ highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;
9811
9940
 
9812
9941
  var type, override;
9813
9942
  function ret(style, tp) { type = tp; return style; }
@@ -9855,8 +9984,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
9855
9984
  return ret("qualifier", "qualifier");
9856
9985
  } else if (/[:;{}\[\]\(\)]/.test(ch)) {
9857
9986
  return ret(null, ch);
9858
- } else if (stream.match(/[\w-.]+(?=\()/)) {
9859
- if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
9987
+ } else if (stream.match(/^[\w-.]+(?=\()/)) {
9988
+ if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) {
9860
9989
  state.tokenize = tokenParenthesized;
9861
9990
  }
9862
9991
  return ret("variable callee", "variable");
@@ -9885,7 +10014,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
9885
10014
 
9886
10015
  function tokenParenthesized(stream, state) {
9887
10016
  stream.next(); // Must be '('
9888
- if (!stream.match(/\s*[\"\')]/, false))
10017
+ if (!stream.match(/^\s*[\"\')]/, false))
9889
10018
  state.tokenize = tokenString(")");
9890
10019
  else
9891
10020
  state.tokenize = null;
@@ -9975,7 +10104,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
9975
10104
  override = "property";
9976
10105
  return "maybeprop";
9977
10106
  } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
9978
- override = "string-2";
10107
+ override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
9979
10108
  return "maybeprop";
9980
10109
  } else if (allowNested) {
9981
10110
  override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
@@ -10069,7 +10198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10069
10198
  else if (propertyKeywords.hasOwnProperty(word))
10070
10199
  override = "property";
10071
10200
  else if (nonStandardPropertyKeywords.hasOwnProperty(word))
10072
- override = "string-2";
10201
+ override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
10073
10202
  else if (valueKeywords.hasOwnProperty(word))
10074
10203
  override = "atom";
10075
10204
  else if (colorKeywords.hasOwnProperty(word))
@@ -10220,117 +10349,151 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10220
10349
  "monochrome", "min-monochrome", "max-monochrome", "resolution",
10221
10350
  "min-resolution", "max-resolution", "scan", "grid", "orientation",
10222
10351
  "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
10223
- "pointer", "any-pointer", "hover", "any-hover"
10352
+ "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme",
10353
+ "dynamic-range", "video-dynamic-range"
10224
10354
  ], mediaFeatures = keySet(mediaFeatures_);
10225
10355
 
10226
10356
  var mediaValueKeywords_ = [
10227
10357
  "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
10228
- "interlace", "progressive"
10358
+ "interlace", "progressive",
10359
+ "dark", "light",
10360
+ "standard", "high"
10229
10361
  ], mediaValueKeywords = keySet(mediaValueKeywords_);
10230
10362
 
10231
10363
  var propertyKeywords_ = [
10232
10364
  "align-content", "align-items", "align-self", "alignment-adjust",
10233
- "alignment-baseline", "anchor-point", "animation", "animation-delay",
10365
+ "alignment-baseline", "all", "anchor-point", "animation", "animation-delay",
10234
10366
  "animation-direction", "animation-duration", "animation-fill-mode",
10235
10367
  "animation-iteration-count", "animation-name", "animation-play-state",
10236
- "animation-timing-function", "appearance", "azimuth", "backface-visibility",
10237
- "background", "background-attachment", "background-blend-mode", "background-clip",
10238
- "background-color", "background-image", "background-origin", "background-position",
10239
- "background-repeat", "background-size", "baseline-shift", "binding",
10240
- "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
10241
- "bookmark-target", "border", "border-bottom", "border-bottom-color",
10242
- "border-bottom-left-radius", "border-bottom-right-radius",
10243
- "border-bottom-style", "border-bottom-width", "border-collapse",
10244
- "border-color", "border-image", "border-image-outset",
10368
+ "animation-timing-function", "appearance", "azimuth", "backdrop-filter",
10369
+ "backface-visibility", "background", "background-attachment",
10370
+ "background-blend-mode", "background-clip", "background-color",
10371
+ "background-image", "background-origin", "background-position",
10372
+ "background-position-x", "background-position-y", "background-repeat",
10373
+ "background-size", "baseline-shift", "binding", "bleed", "block-size",
10374
+ "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target",
10375
+ "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius",
10376
+ "border-bottom-right-radius", "border-bottom-style", "border-bottom-width",
10377
+ "border-collapse", "border-color", "border-image", "border-image-outset",
10245
10378
  "border-image-repeat", "border-image-slice", "border-image-source",
10246
- "border-image-width", "border-left", "border-left-color",
10247
- "border-left-style", "border-left-width", "border-radius", "border-right",
10248
- "border-right-color", "border-right-style", "border-right-width",
10249
- "border-spacing", "border-style", "border-top", "border-top-color",
10250
- "border-top-left-radius", "border-top-right-radius", "border-top-style",
10251
- "border-top-width", "border-width", "bottom", "box-decoration-break",
10252
- "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
10253
- "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
10254
- "column-fill", "column-gap", "column-rule", "column-rule-color",
10255
- "column-rule-style", "column-rule-width", "column-span", "column-width",
10256
- "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
10257
- "cue-after", "cue-before", "cursor", "direction", "display",
10258
- "dominant-baseline", "drop-initial-after-adjust",
10259
- "drop-initial-after-align", "drop-initial-before-adjust",
10260
- "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
10261
- "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
10262
- "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
10263
- "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
10264
- "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
10265
- "font-stretch", "font-style", "font-synthesis", "font-variant",
10266
- "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
10267
- "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
10268
- "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
10269
- "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
10270
- "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
10271
- "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
10272
- "grid-template-rows", "hanging-punctuation", "height", "hyphens",
10273
- "icon", "image-orientation", "image-rendering", "image-resolution",
10274
- "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
10275
- "line-break", "line-height", "line-stacking", "line-stacking-ruby",
10379
+ "border-image-width", "border-left", "border-left-color", "border-left-style",
10380
+ "border-left-width", "border-radius", "border-right", "border-right-color",
10381
+ "border-right-style", "border-right-width", "border-spacing", "border-style",
10382
+ "border-top", "border-top-color", "border-top-left-radius",
10383
+ "border-top-right-radius", "border-top-style", "border-top-width",
10384
+ "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing",
10385
+ "break-after", "break-before", "break-inside", "caption-side", "caret-color",
10386
+ "clear", "clip", "color", "color-profile", "column-count", "column-fill",
10387
+ "column-gap", "column-rule", "column-rule-color", "column-rule-style",
10388
+ "column-rule-width", "column-span", "column-width", "columns", "contain",
10389
+ "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after",
10390
+ "cue-before", "cursor", "direction", "display", "dominant-baseline",
10391
+ "drop-initial-after-adjust", "drop-initial-after-align",
10392
+ "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size",
10393
+ "drop-initial-value", "elevation", "empty-cells", "fit", "fit-content", "fit-position",
10394
+ "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow",
10395
+ "flex-shrink", "flex-wrap", "float", "float-offset", "flow-from", "flow-into",
10396
+ "font", "font-family", "font-feature-settings", "font-kerning",
10397
+ "font-language-override", "font-optical-sizing", "font-size",
10398
+ "font-size-adjust", "font-stretch", "font-style", "font-synthesis",
10399
+ "font-variant", "font-variant-alternates", "font-variant-caps",
10400
+ "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric",
10401
+ "font-variant-position", "font-variation-settings", "font-weight", "gap",
10402
+ "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows",
10403
+ "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start",
10404
+ "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "grid-row-start",
10405
+ "grid-template", "grid-template-areas", "grid-template-columns",
10406
+ "grid-template-rows", "hanging-punctuation", "height", "hyphens", "icon",
10407
+ "image-orientation", "image-rendering", "image-resolution", "inline-box-align",
10408
+ "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline",
10409
+ "inset-inline-end", "inset-inline-start", "isolation", "justify-content",
10410
+ "justify-items", "justify-self", "left", "letter-spacing", "line-break",
10411
+ "line-height", "line-height-step", "line-stacking", "line-stacking-ruby",
10276
10412
  "line-stacking-shift", "line-stacking-strategy", "list-style",
10277
10413
  "list-style-image", "list-style-position", "list-style-type", "margin",
10278
- "margin-bottom", "margin-left", "margin-right", "margin-top",
10279
- "marks", "marquee-direction", "marquee-loop",
10280
- "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
10281
- "max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
10282
- "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
10283
- "opacity", "order", "orphans", "outline",
10284
- "outline-color", "outline-offset", "outline-style", "outline-width",
10285
- "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
10286
- "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
10287
- "page", "page-break-after", "page-break-before", "page-break-inside",
10288
- "page-policy", "pause", "pause-after", "pause-before", "perspective",
10289
- "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
10290
- "presentation-level", "punctuation-trim", "quotes", "region-break-after",
10291
- "region-break-before", "region-break-inside", "region-fragment",
10292
- "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
10293
- "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
10294
- "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
10295
- "shape-outside", "size", "speak", "speak-as", "speak-header",
10296
- "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
10297
- "tab-size", "table-layout", "target", "target-name", "target-new",
10298
- "target-position", "text-align", "text-align-last", "text-decoration",
10414
+ "margin-bottom", "margin-left", "margin-right", "margin-top", "marks",
10415
+ "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed",
10416
+ "marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode",
10417
+ "mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type",
10418
+ "max-block-size", "max-height", "max-inline-size",
10419
+ "max-width", "min-block-size", "min-height", "min-inline-size", "min-width",
10420
+ "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right",
10421
+ "nav-up", "object-fit", "object-position", "offset", "offset-anchor",
10422
+ "offset-distance", "offset-path", "offset-position", "offset-rotate",
10423
+ "opacity", "order", "orphans", "outline", "outline-color", "outline-offset",
10424
+ "outline-style", "outline-width", "overflow", "overflow-style",
10425
+ "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom",
10426
+ "padding-left", "padding-right", "padding-top", "page", "page-break-after",
10427
+ "page-break-before", "page-break-inside", "page-policy", "pause",
10428
+ "pause-after", "pause-before", "perspective", "perspective-origin", "pitch",
10429
+ "pitch-range", "place-content", "place-items", "place-self", "play-during",
10430
+ "position", "presentation-level", "punctuation-trim", "quotes",
10431
+ "region-break-after", "region-break-before", "region-break-inside",
10432
+ "region-fragment", "rendering-intent", "resize", "rest", "rest-after",
10433
+ "rest-before", "richness", "right", "rotate", "rotation", "rotation-point",
10434
+ "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span",
10435
+ "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block",
10436
+ "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom",
10437
+ "scroll-margin-inline", "scroll-margin-inline-end",
10438
+ "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right",
10439
+ "scroll-margin-top", "scroll-padding", "scroll-padding-block",
10440
+ "scroll-padding-block-end", "scroll-padding-block-start",
10441
+ "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end",
10442
+ "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right",
10443
+ "scroll-padding-top", "scroll-snap-align", "scroll-snap-type",
10444
+ "shape-image-threshold", "shape-inside", "shape-margin", "shape-outside",
10445
+ "size", "speak", "speak-as", "speak-header", "speak-numeral",
10446
+ "speak-punctuation", "speech-rate", "stress", "string-set", "tab-size",
10447
+ "table-layout", "target", "target-name", "target-new", "target-position",
10448
+ "text-align", "text-align-last", "text-combine-upright", "text-decoration",
10299
10449
  "text-decoration-color", "text-decoration-line", "text-decoration-skip",
10300
- "text-decoration-style", "text-emphasis", "text-emphasis-color",
10301
- "text-emphasis-position", "text-emphasis-style", "text-height",
10302
- "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
10303
- "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
10304
- "text-wrap", "top", "transform", "transform-origin", "transform-style",
10305
- "transition", "transition-delay", "transition-duration",
10306
- "transition-property", "transition-timing-function", "unicode-bidi",
10307
- "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
10308
- "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
10309
- "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
10310
- "word-spacing", "word-wrap", "z-index",
10450
+ "text-decoration-skip-ink", "text-decoration-style", "text-emphasis",
10451
+ "text-emphasis-color", "text-emphasis-position", "text-emphasis-style",
10452
+ "text-height", "text-indent", "text-justify", "text-orientation",
10453
+ "text-outline", "text-overflow", "text-rendering", "text-shadow",
10454
+ "text-size-adjust", "text-space-collapse", "text-transform",
10455
+ "text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin",
10456
+ "transform-style", "transition", "transition-delay", "transition-duration",
10457
+ "transition-property", "transition-timing-function", "translate",
10458
+ "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance",
10459
+ "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate",
10460
+ "voice-stress", "voice-volume", "volume", "white-space", "widows", "width",
10461
+ "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index",
10311
10462
  // SVG-specific
10312
10463
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
10313
10464
  "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
10314
10465
  "color-interpolation", "color-interpolation-filters",
10315
10466
  "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
10316
- "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
10467
+ "marker", "marker-end", "marker-mid", "marker-start", "paint-order", "shape-rendering", "stroke",
10317
10468
  "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
10318
10469
  "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
10319
10470
  "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
10320
- "glyph-orientation-vertical", "text-anchor", "writing-mode"
10471
+ "glyph-orientation-vertical", "text-anchor", "writing-mode",
10321
10472
  ], propertyKeywords = keySet(propertyKeywords_);
10322
10473
 
10323
10474
  var nonStandardPropertyKeywords_ = [
10475
+ "accent-color", "aspect-ratio", "border-block", "border-block-color", "border-block-end",
10476
+ "border-block-end-color", "border-block-end-style", "border-block-end-width",
10477
+ "border-block-start", "border-block-start-color", "border-block-start-style",
10478
+ "border-block-start-width", "border-block-style", "border-block-width",
10479
+ "border-inline", "border-inline-color", "border-inline-end",
10480
+ "border-inline-end-color", "border-inline-end-style",
10481
+ "border-inline-end-width", "border-inline-start", "border-inline-start-color",
10482
+ "border-inline-start-style", "border-inline-start-width",
10483
+ "border-inline-style", "border-inline-width", "content-visibility", "margin-block",
10484
+ "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end",
10485
+ "margin-inline-start", "overflow-anchor", "overscroll-behavior", "padding-block", "padding-block-end",
10486
+ "padding-block-start", "padding-inline", "padding-inline-end",
10487
+ "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color",
10324
10488
  "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
10325
10489
  "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
10326
- "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
10327
- "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
10328
- "searchfield-results-decoration", "zoom"
10490
+ "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration",
10491
+ "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom"
10329
10492
  ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
10330
10493
 
10331
10494
  var fontProperties_ = [
10332
- "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
10333
- "font-stretch", "font-weight", "font-style"
10495
+ "font-display", "font-family", "src", "unicode-range", "font-variant",
10496
+ "font-feature-settings", "font-stretch", "font-weight", "font-style"
10334
10497
  ], fontProperties = keySet(fontProperties_);
10335
10498
 
10336
10499
  var counterDescriptors_ = [
@@ -10343,16 +10506,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10343
10506
  "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
10344
10507
  "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
10345
10508
  "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
10346
- "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
10509
+ "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen",
10347
10510
  "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
10348
- "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
10349
- "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
10511
+ "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet",
10512
+ "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick",
10350
10513
  "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
10351
10514
  "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
10352
10515
  "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
10353
10516
  "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
10354
- "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
10355
- "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
10517
+ "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
10518
+ "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
10356
10519
  "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
10357
10520
  "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
10358
10521
  "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
@@ -10362,7 +10525,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10362
10525
  "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
10363
10526
  "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
10364
10527
  "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
10365
- "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
10528
+ "slateblue", "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan",
10366
10529
  "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
10367
10530
  "whitesmoke", "yellow", "yellowgreen"
10368
10531
  ], colorKeywords = keySet(colorKeywords_);
@@ -10372,22 +10535,22 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10372
10535
  "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
10373
10536
  "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
10374
10537
  "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
10375
- "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
10376
- "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
10377
- "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
10538
+ "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary",
10539
+ "bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box",
10540
+ "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "button-bevel",
10378
10541
  "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
10379
10542
  "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
10380
10543
  "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
10381
10544
  "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
10382
10545
  "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
10383
10546
  "compact", "condensed", "contain", "content", "contents",
10384
- "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
10385
- "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
10547
+ "content-box", "context-menu", "continuous", "contrast", "copy", "counter", "counters", "cover", "crop",
10548
+ "cross", "crosshair", "cubic-bezier", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
10386
10549
  "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
10387
10550
  "destination-in", "destination-out", "destination-over", "devanagari", "difference",
10388
10551
  "disc", "discard", "disclosure-closed", "disclosure-open", "document",
10389
10552
  "dot-dash", "dot-dot-dash",
10390
- "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
10553
+ "dotted", "double", "down", "drop-shadow", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
10391
10554
  "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
10392
10555
  "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
10393
10556
  "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
@@ -10396,11 +10559,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10396
10559
  "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
10397
10560
  "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
10398
10561
  "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
10399
- "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
10400
- "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
10562
+ "extra-expanded", "fantasy", "fast", "fill", "fill-box", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
10563
+ "forwards", "from", "geometricPrecision", "georgian", "grayscale", "graytext", "grid", "groove",
10401
10564
  "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
10402
10565
  "help", "hidden", "hide", "higher", "highlight", "highlighttext",
10403
- "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
10566
+ "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "hue-rotate", "icon", "ignore",
10404
10567
  "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
10405
10568
  "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
10406
10569
  "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
@@ -10411,7 +10574,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10411
10574
  "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
10412
10575
  "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
10413
10576
  "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
10414
- "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
10577
+ "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d",
10415
10578
  "media-controls-background", "media-current-time-display",
10416
10579
  "media-fullscreen-button", "media-mute-button", "media-play-button",
10417
10580
  "media-return-to-realtime-button", "media-rewind-button",
@@ -10420,13 +10583,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10420
10583
  "media-volume-slider-container", "media-volume-sliderthumb", "medium",
10421
10584
  "menu", "menulist", "menulist-button", "menulist-text",
10422
10585
  "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
10423
- "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
10586
+ "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize",
10424
10587
  "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
10425
10588
  "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
10426
10589
  "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
10427
10590
  "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
10428
10591
  "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
10429
- "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
10592
+ "painted", "page", "paused", "persian", "perspective", "pinch-zoom", "plus-darker", "plus-lighter",
10430
10593
  "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
10431
10594
  "progress", "push-button", "radial-gradient", "radio", "read-only",
10432
10595
  "read-write", "read-write-plaintext-only", "rectangle", "region",
@@ -10434,18 +10597,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10434
10597
  "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
10435
10598
  "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
10436
10599
  "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
10437
- "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
10600
+ "s-resize", "sans-serif", "saturate", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
10438
10601
  "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
10439
10602
  "searchfield-cancel-button", "searchfield-decoration",
10440
10603
  "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
10441
- "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
10604
+ "semi-condensed", "semi-expanded", "separate", "sepia", "serif", "show", "sidama",
10442
10605
  "simp-chinese-formal", "simp-chinese-informal", "single",
10443
10606
  "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
10444
10607
  "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
10445
10608
  "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
10446
10609
  "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
10447
- "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
10448
- "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
10610
+ "square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub",
10611
+ "subpixel-antialiased", "svg_masks", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
10449
10612
  "table-caption", "table-cell", "table-column", "table-column-group",
10450
10613
  "table-footer-group", "table-header-group", "table-row", "table-row-group",
10451
10614
  "tamil",
@@ -10455,10 +10618,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10455
10618
  "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
10456
10619
  "trad-chinese-formal", "trad-chinese-informal", "transform",
10457
10620
  "translate", "translate3d", "translateX", "translateY", "translateZ",
10458
- "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
10621
+ "transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up",
10459
10622
  "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
10460
10623
  "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
10461
- "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
10624
+ "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", "visiblePainted",
10462
10625
  "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
10463
10626
  "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
10464
10627
  "xx-large", "xx-small"
@@ -10526,7 +10689,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
10526
10689
  }
10527
10690
  },
10528
10691
  ":": function(stream) {
10529
- if (stream.match(/\s*\{/, false))
10692
+ if (stream.match(/^\s*\{/, false))
10530
10693
  return [null, null]
10531
10694
  return false;
10532
10695
  },
@@ -10996,9 +11159,13 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
10996
11159
  };
10997
11160
  }
10998
11161
 
11162
+ function lower(tagName) {
11163
+ return tagName && tagName.toLowerCase();
11164
+ }
11165
+
10999
11166
  function Context(state, tagName, startOfLine) {
11000
11167
  this.prev = state.context;
11001
- this.tagName = tagName;
11168
+ this.tagName = tagName || "";
11002
11169
  this.indent = state.indented;
11003
11170
  this.startOfLine = startOfLine;
11004
11171
  if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
@@ -11014,8 +11181,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11014
11181
  return;
11015
11182
  }
11016
11183
  parentTagName = state.context.tagName;
11017
- if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
11018
- !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
11184
+ if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) ||
11185
+ !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) {
11019
11186
  return;
11020
11187
  }
11021
11188
  popContext(state);
@@ -11049,7 +11216,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11049
11216
  if (type == "word") {
11050
11217
  var tagName = stream.current();
11051
11218
  if (state.context && state.context.tagName != tagName &&
11052
- config.implicitlyClosed.hasOwnProperty(state.context.tagName))
11219
+ config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName)))
11053
11220
  popContext(state);
11054
11221
  if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
11055
11222
  setStyle = "tag";
@@ -11088,7 +11255,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11088
11255
  var tagName = state.tagName, tagStart = state.tagStart;
11089
11256
  state.tagName = state.tagStart = null;
11090
11257
  if (type == "selfcloseTag" ||
11091
- config.autoSelfClosers.hasOwnProperty(tagName)) {
11258
+ config.autoSelfClosers.hasOwnProperty(lower(tagName))) {
11092
11259
  maybePopContext(state, tagName);
11093
11260
  } else {
11094
11261
  maybePopContext(state, tagName);
@@ -11168,7 +11335,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11168
11335
  if (context.tagName == tagAfter[2]) {
11169
11336
  context = context.prev;
11170
11337
  break;
11171
- } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
11338
+ } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) {
11172
11339
  context = context.prev;
11173
11340
  } else {
11174
11341
  break;
@@ -11176,8 +11343,8 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11176
11343
  }
11177
11344
  } else if (tagAfter) { // Opening tag spotted
11178
11345
  while (context) {
11179
- var grabbers = config.contextGrabbers[context.tagName];
11180
- if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
11346
+ var grabbers = config.contextGrabbers[lower(context.tagName)];
11347
+ if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2])))
11181
11348
  context = context.prev;
11182
11349
  else
11183
11350
  break;
@@ -11208,7 +11375,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
11208
11375
  xmlCurrentContext: function(state) {
11209
11376
  var context = [];
11210
11377
  for (var cx = state.context; cx; cx = cx.prev)
11211
- if (cx.tagName) context.push(cx.tagName);
11378
+ context.push(cx.tagName);
11212
11379
  return context.reverse()
11213
11380
  }
11214
11381
  };
@@ -11238,12 +11405,12 @@ var meta = createCommonjsModule(function (module, exports) {
11238
11405
  {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
11239
11406
  {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
11240
11407
  {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
11241
- {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
11408
+ {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy", "cbl"]},
11242
11409
  {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]},
11243
11410
  {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
11244
11411
  {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
11245
11412
  {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
11246
- {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
11413
+ {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/},
11247
11414
  {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
11248
11415
  {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
11249
11416
  {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
@@ -11263,7 +11430,7 @@ var meta = createCommonjsModule(function (module, exports) {
11263
11430
  {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
11264
11431
  {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
11265
11432
  {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
11266
- {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
11433
+ {name: "Embedded JavaScript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
11267
11434
  {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
11268
11435
  {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
11269
11436
  {name: "Esper", mime: "text/x-esper", mode: "sql"},
@@ -11274,7 +11441,7 @@ var meta = createCommonjsModule(function (module, exports) {
11274
11441
  {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
11275
11442
  {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
11276
11443
  {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
11277
- {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
11444
+ {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i},
11278
11445
  {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
11279
11446
  {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
11280
11447
  {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
@@ -11295,7 +11462,7 @@ var meta = createCommonjsModule(function (module, exports) {
11295
11462
  {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
11296
11463
  {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
11297
11464
  {name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]},
11298
- {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
11465
+ {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"], alias: ["jl"]},
11299
11466
  {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
11300
11467
  {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
11301
11468
  {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
@@ -11363,7 +11530,7 @@ var meta = createCommonjsModule(function (module, exports) {
11363
11530
  {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
11364
11531
  {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
11365
11532
  {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
11366
- {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
11533
+ {name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
11367
11534
  {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
11368
11535
  {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
11369
11536
  {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
@@ -11388,7 +11555,8 @@ var meta = createCommonjsModule(function (module, exports) {
11388
11555
  {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
11389
11556
  {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
11390
11557
  {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
11391
- {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
11558
+ {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]},
11559
+ {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]},
11392
11560
  ];
11393
11561
  // Ensure all modes have a mime property for backwards compatibility
11394
11562
  for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
@@ -11484,6 +11652,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
11484
11652
  if (modeCfg.fencedCodeBlockHighlighting === undefined)
11485
11653
  modeCfg.fencedCodeBlockHighlighting = true;
11486
11654
 
11655
+ if (modeCfg.fencedCodeBlockDefaultMode === undefined)
11656
+ modeCfg.fencedCodeBlockDefaultMode = 'text/plain';
11657
+
11487
11658
  if (modeCfg.xml === undefined)
11488
11659
  modeCfg.xml = true;
11489
11660
 
@@ -11523,9 +11694,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
11523
11694
  , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/
11524
11695
  , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE
11525
11696
  , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
11526
- , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
11697
+ , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/
11527
11698
  , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/
11528
- , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/
11699
+ , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/
11529
11700
  , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition
11530
11701
  , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/
11531
11702
  , expandedTab = " "; // CommonMark specifies tab as 4 spaces
@@ -11656,7 +11827,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
11656
11827
 
11657
11828
  // Add this list item's content's indentation to the stack
11658
11829
  state.listStack.push(state.indentation);
11659
- // Reset inline styles which shouldn't propagate aross list items
11830
+ // Reset inline styles which shouldn't propagate across list items
11660
11831
  state.em = false;
11661
11832
  state.strong = false;
11662
11833
  state.code = false;
@@ -11672,7 +11843,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
11672
11843
  state.quote = 0;
11673
11844
  state.fencedEndRE = new RegExp(match[1] + "+ *$");
11674
11845
  // try switching mode
11675
- state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]);
11846
+ state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode );
11676
11847
  if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
11677
11848
  state.f = state.block = local;
11678
11849
  if (modeCfg.highlightFormatting) state.formatting = "code-block";
@@ -12045,7 +12216,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
12045
12216
  return getType(state);
12046
12217
  }
12047
12218
  } else if (ch === ' ') {
12048
- if (stream.match(/^~~/, true)) { // Probably surrounded by space
12219
+ if (stream.match('~~', true)) { // Probably surrounded by space
12049
12220
  if (stream.peek() === ' ') { // Surrounded by spaces, ignore
12050
12221
  return getType(state);
12051
12222
  } else { // Not surrounded by spaces, back up pointer
@@ -12144,7 +12315,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
12144
12315
  }
12145
12316
 
12146
12317
  function footnoteLinkInside(stream, state) {
12147
- if (stream.match(/^\]:/, true)) {
12318
+ if (stream.match(']:', true)) {
12148
12319
  state.f = state.inline = footnoteUrl;
12149
12320
  if (modeCfg.highlightFormatting) state.formatting = "link";
12150
12321
  var returnType = getType(state);
@@ -12168,7 +12339,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
12168
12339
  if (stream.peek() === undefined) { // End of line, set flag to check next line
12169
12340
  state.linkTitle = true;
12170
12341
  } else { // More content on line, check if link title
12171
- stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
12342
+ stream.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, true);
12172
12343
  }
12173
12344
  state.f = state.inline = inlineNormal;
12174
12345
  return tokenTypes.linkHref + " url";
@@ -12545,6 +12716,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12545
12716
  var statementIndent = parserConfig.statementIndent;
12546
12717
  var jsonldMode = parserConfig.jsonld;
12547
12718
  var jsonMode = parserConfig.json || jsonldMode;
12719
+ var trackScope = parserConfig.trackScope !== false;
12548
12720
  var isTS = parserConfig.typescript;
12549
12721
  var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
12550
12722
 
@@ -12627,21 +12799,25 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12627
12799
  } else if (ch == "`") {
12628
12800
  state.tokenize = tokenQuasi;
12629
12801
  return tokenQuasi(stream, state);
12630
- } else if (ch == "#") {
12802
+ } else if (ch == "#" && stream.peek() == "!") {
12631
12803
  stream.skipToEnd();
12632
- return ret("error", "error");
12633
- } else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) {
12804
+ return ret("meta", "meta");
12805
+ } else if (ch == "#" && stream.eatWhile(wordRE)) {
12806
+ return ret("variable", "property")
12807
+ } else if (ch == "<" && stream.match("!--") ||
12808
+ (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
12634
12809
  stream.skipToEnd();
12635
12810
  return ret("comment", "comment")
12636
12811
  } else if (isOperatorChar.test(ch)) {
12637
12812
  if (ch != ">" || !state.lexical || state.lexical.type != ">") {
12638
12813
  if (stream.eat("=")) {
12639
12814
  if (ch == "!" || ch == "=") stream.eat("=");
12640
- } else if (/[<>*+\-]/.test(ch)) {
12815
+ } else if (/[<>*+\-|&?]/.test(ch)) {
12641
12816
  stream.eat(ch);
12642
12817
  if (ch == ">") stream.eat(ch);
12643
12818
  }
12644
12819
  }
12820
+ if (ch == "?" && stream.eat(".")) return ret(".")
12645
12821
  return ret("operator", "operator", stream.current());
12646
12822
  } else if (wordRE.test(ch)) {
12647
12823
  stream.eatWhile(wordRE);
@@ -12651,7 +12827,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12651
12827
  var kw = keywords[word];
12652
12828
  return ret(kw.type, kw.style, word)
12653
12829
  }
12654
- if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
12830
+ if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
12655
12831
  return ret("async", "keyword", word)
12656
12832
  }
12657
12833
  return ret("variable", "variable", word)
@@ -12743,7 +12919,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12743
12919
 
12744
12920
  // Parser
12745
12921
 
12746
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
12922
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
12923
+ "regexp": true, "this": true, "import": true, "jsonld-keyword": true};
12747
12924
 
12748
12925
  function JSLexical(indented, column, type, align, prev, info) {
12749
12926
  this.indented = indented;
@@ -12755,6 +12932,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12755
12932
  }
12756
12933
 
12757
12934
  function inScope(state, varname) {
12935
+ if (!trackScope) return false
12758
12936
  for (var v = state.localVars; v; v = v.next)
12759
12937
  if (v.name == varname) return true;
12760
12938
  for (var cx = state.context; cx; cx = cx.prev) {
@@ -12801,6 +12979,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12801
12979
  function register(varname) {
12802
12980
  var state = cx.state;
12803
12981
  cx.marked = "def";
12982
+ if (!trackScope) return
12804
12983
  if (state.context) {
12805
12984
  if (state.lexical.info == "var" && state.context && state.context.block) {
12806
12985
  // FIXME function decls are also not block scoped
@@ -12899,7 +13078,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12899
13078
  return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
12900
13079
  }
12901
13080
  if (type == "function") return cont(functiondef);
12902
- if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
13081
+ if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
12903
13082
  if (type == "class" || (isTS && value == "interface")) {
12904
13083
  cx.marked = "keyword";
12905
13084
  return cont(pushlex("form", type == "class" ? type : value), className, poplex)
@@ -12945,7 +13124,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12945
13124
  }
12946
13125
  function parenExpr(type) {
12947
13126
  if (type != "(") return pass()
12948
- return cont(pushlex(")"), expression, expect(")"), poplex)
13127
+ return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
12949
13128
  }
12950
13129
  function expressionInner(type, value, noComma) {
12951
13130
  if (cx.state.fatArrowAt == cx.stream.start) {
@@ -12965,7 +13144,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12965
13144
  if (type == "{") return contCommasep(objprop, "}", null, maybeop);
12966
13145
  if (type == "quasi") return pass(quasi, maybeop);
12967
13146
  if (type == "new") return cont(maybeTarget(noComma));
12968
- if (type == "import") return cont(expression);
12969
13147
  return cont();
12970
13148
  }
12971
13149
  function maybeexpression(type) {
@@ -12974,7 +13152,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12974
13152
  }
12975
13153
 
12976
13154
  function maybeoperatorComma(type, value) {
12977
- if (type == ",") return cont(expression);
13155
+ if (type == ",") return cont(maybeexpression);
12978
13156
  return maybeoperatorNoComma(type, value, false);
12979
13157
  }
12980
13158
  function maybeoperatorNoComma(type, value, noComma) {
@@ -12983,7 +13161,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12983
13161
  if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
12984
13162
  if (type == "operator") {
12985
13163
  if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
12986
- if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
13164
+ if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
12987
13165
  return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
12988
13166
  if (value == "?") return cont(expression, expect(":"), expr);
12989
13167
  return cont(expr);
@@ -13003,7 +13181,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13003
13181
  function quasi(type, value) {
13004
13182
  if (type != "quasi") return pass();
13005
13183
  if (value.slice(value.length - 2) != "${") return cont(quasi);
13006
- return cont(expression, continueQuasi);
13184
+ return cont(maybeexpression, continueQuasi);
13007
13185
  }
13008
13186
  function continueQuasi(type) {
13009
13187
  if (type == "}") {
@@ -13129,7 +13307,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13129
13307
  }
13130
13308
  }
13131
13309
  function typeexpr(type, value) {
13132
- if (value == "keyof" || value == "typeof" || value == "infer") {
13310
+ if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
13133
13311
  cx.marked = "keyword";
13134
13312
  return cont(value == "typeof" ? expressionNoComma : typeexpr)
13135
13313
  }
@@ -13140,13 +13318,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13140
13318
  if (value == "|" || value == "&") return cont(typeexpr)
13141
13319
  if (type == "string" || type == "number" || type == "atom") return cont(afterType);
13142
13320
  if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
13143
- if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
13321
+ if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
13144
13322
  if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
13145
13323
  if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
13324
+ if (type == "quasi") { return pass(quasiType, afterType); }
13146
13325
  }
13147
13326
  function maybeReturnType(type) {
13148
13327
  if (type == "=>") return cont(typeexpr)
13149
13328
  }
13329
+ function typeprops(type) {
13330
+ if (type.match(/[\}\)\]]/)) return cont()
13331
+ if (type == "," || type == ";") return cont(typeprops)
13332
+ return pass(typeprop, typeprops)
13333
+ }
13150
13334
  function typeprop(type, value) {
13151
13335
  if (type == "variable" || cx.style == "keyword") {
13152
13336
  cx.marked = "property";
@@ -13159,6 +13343,20 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13159
13343
  return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
13160
13344
  } else if (type == "(") {
13161
13345
  return pass(functiondecl, typeprop)
13346
+ } else if (!type.match(/[;\}\)\],]/)) {
13347
+ return cont()
13348
+ }
13349
+ }
13350
+ function quasiType(type, value) {
13351
+ if (type != "quasi") return pass();
13352
+ if (value.slice(value.length - 2) != "${") return cont(quasiType);
13353
+ return cont(typeexpr, continueQuasiType);
13354
+ }
13355
+ function continueQuasiType(type) {
13356
+ if (type == "}") {
13357
+ cx.marked = "string-2";
13358
+ cx.state.tokenize = tokenQuasi;
13359
+ return cont(quasiType);
13162
13360
  }
13163
13361
  }
13164
13362
  function typearg(type, value) {
@@ -13285,11 +13483,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13285
13483
  }
13286
13484
  if (type == "variable" || cx.style == "keyword") {
13287
13485
  cx.marked = "property";
13288
- return cont(isTS ? classfield : functiondef, classBody);
13486
+ return cont(classfield, classBody);
13289
13487
  }
13290
- if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody);
13488
+ if (type == "number" || type == "string") return cont(classfield, classBody);
13291
13489
  if (type == "[")
13292
- return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
13490
+ return cont(expression, maybetype, expect("]"), classfield, classBody)
13293
13491
  if (value == "*") {
13294
13492
  cx.marked = "keyword";
13295
13493
  return cont(classBody);
@@ -13300,6 +13498,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13300
13498
  if (value == "@") return cont(expression, classBody)
13301
13499
  }
13302
13500
  function classfield(type, value) {
13501
+ if (value == "!") return cont(classfield)
13303
13502
  if (value == "?") return cont(classfield)
13304
13503
  if (type == ":") return cont(typeexpr, maybeAssign)
13305
13504
  if (value == "=") return cont(expressionNoComma)
@@ -13319,6 +13518,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13319
13518
  function afterImport(type) {
13320
13519
  if (type == "string") return cont();
13321
13520
  if (type == "(") return pass(expression);
13521
+ if (type == ".") return pass(maybeoperatorComma);
13322
13522
  return pass(importSpec, maybeMoreImports, maybeFrom);
13323
13523
  }
13324
13524
  function importSpec(type, value) {
@@ -13392,14 +13592,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13392
13592
  },
13393
13593
 
13394
13594
  indent: function(state, textAfter) {
13395
- if (state.tokenize == tokenComment) return CodeMirror.Pass;
13595
+ if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
13396
13596
  if (state.tokenize != tokenBase) return 0;
13397
13597
  var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
13398
13598
  // Kludge to prevent 'maybelse' from blocking lexical scope pops
13399
13599
  if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
13400
13600
  var c = state.cc[i];
13401
13601
  if (c == poplex) lexical = lexical.prev;
13402
- else if (c != maybeelse) break;
13602
+ else if (c != maybeelse && c != popcontext) break;
13403
13603
  }
13404
13604
  while ((lexical.type == "stat" || lexical.type == "form") &&
13405
13605
  (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
@@ -13436,8 +13636,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13436
13636
  expressionAllowed: expressionAllowed,
13437
13637
 
13438
13638
  skipExpression: function(state) {
13439
- var top = state.cc[state.cc.length - 1];
13440
- if (top == expression || top == expressionNoComma) state.cc.pop();
13639
+ parseJS(state, "atom", "atom", "true", new CodeMirror.StringStream("", 2, null));
13441
13640
  }
13442
13641
  };
13443
13642
  });
@@ -13449,9 +13648,10 @@ CodeMirror.defineMIME("text/ecmascript", "javascript");
13449
13648
  CodeMirror.defineMIME("application/javascript", "javascript");
13450
13649
  CodeMirror.defineMIME("application/x-javascript", "javascript");
13451
13650
  CodeMirror.defineMIME("application/ecmascript", "javascript");
13452
- CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
13453
- CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
13454
- CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
13651
+ CodeMirror.defineMIME("application/json", { name: "javascript", json: true });
13652
+ CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true });
13653
+ CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true });
13654
+ CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true });
13455
13655
  CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
13456
13656
  CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
13457
13657
 
@@ -13529,7 +13729,8 @@ var htmlmixed = createCommonjsModule(function (module, exports) {
13529
13729
  name: "xml",
13530
13730
  htmlMode: true,
13531
13731
  multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
13532
- multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
13732
+ multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
13733
+ allowMissingTagName: parserConfig.allowMissingTagName,
13533
13734
  });
13534
13735
 
13535
13736
  var tags = {};
@@ -14584,7 +14785,7 @@ function styleInject(css, ref) {
14584
14785
  }
14585
14786
  }
14586
14787
 
14587
- var css_248z = ".CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,.5)}.cm-animate-fat-cursor,.cm-fat-cursor-mark{-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:none}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:\"\"}span.CodeMirror-selectedtext{background:none}";
14788
+ var css_248z = ".CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor .CodeMirror-line::selection,.cm-fat-cursor .CodeMirror-line>span::selection,.cm-fat-cursor .CodeMirror-line>span>span::selection{background:transparent}.cm-fat-cursor .CodeMirror-line::-moz-selection,.cm-fat-cursor .CodeMirror-line>span::-moz-selection,.cm-fat-cursor .CodeMirror-line>span>span::-moz-selection{background:transparent}.cm-fat-cursor{caret-color:transparent}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;height:100%;outline:none;position:relative}.CodeMirror-sizer{position:relative;border-right:50px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none;outline:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-50px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:none}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:\"\"}span.CodeMirror-selectedtext{background:none}";
14588
14789
  styleInject(css_248z);
14589
14790
 
14590
14791
  var braceFold = createCommonjsModule(function (module, exports) {
@@ -14597,9 +14798,9 @@ var braceFold = createCommonjsModule(function (module, exports) {
14597
14798
 
14598
14799
  CodeMirror.registerHelper("fold", "brace", function(cm, start) {
14599
14800
  var line = start.line, lineText = cm.getLine(line);
14600
- var tokenType;
14601
14801
 
14602
14802
  function findOpening(openCh) {
14803
+ var tokenType;
14603
14804
  for (var at = start.ch, pass = 0;;) {
14604
14805
  var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
14605
14806
  if (found == -1) {
@@ -14610,37 +14811,42 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) {
14610
14811
  }
14611
14812
  if (pass == 1 && found < start.ch) break;
14612
14813
  tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
14613
- if (!/^(comment|string)/.test(tokenType)) return found + 1;
14814
+ if (!/^(comment|string)/.test(tokenType)) return {ch: found + 1, tokenType: tokenType};
14614
14815
  at = found - 1;
14615
14816
  }
14616
14817
  }
14617
14818
 
14618
- var startToken = "{", endToken = "}", startCh = findOpening("{");
14619
- if (startCh == null) {
14620
- startToken = "[", endToken = "]";
14621
- startCh = findOpening("[");
14622
- }
14623
-
14624
- if (startCh == null) return;
14625
- var count = 1, lastLine = cm.lastLine(), end, endCh;
14626
- outer: for (var i = line; i <= lastLine; ++i) {
14627
- var text = cm.getLine(i), pos = i == line ? startCh : 0;
14628
- for (;;) {
14629
- var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
14630
- if (nextOpen < 0) nextOpen = text.length;
14631
- if (nextClose < 0) nextClose = text.length;
14632
- pos = Math.min(nextOpen, nextClose);
14633
- if (pos == text.length) break;
14634
- if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
14635
- if (pos == nextOpen) ++count;
14636
- else if (!--count) { end = i; endCh = pos; break outer; }
14819
+ function findRange(startToken, endToken, found) {
14820
+ var count = 1, lastLine = cm.lastLine(), end, startCh = found.ch, endCh;
14821
+ outer: for (var i = line; i <= lastLine; ++i) {
14822
+ var text = cm.getLine(i), pos = i == line ? startCh : 0;
14823
+ for (;;) {
14824
+ var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
14825
+ if (nextOpen < 0) nextOpen = text.length;
14826
+ if (nextClose < 0) nextClose = text.length;
14827
+ pos = Math.min(nextOpen, nextClose);
14828
+ if (pos == text.length) break;
14829
+ if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == found.tokenType) {
14830
+ if (pos == nextOpen) ++count;
14831
+ else if (!--count) { end = i; endCh = pos; break outer; }
14832
+ }
14833
+ ++pos;
14637
14834
  }
14638
- ++pos;
14639
14835
  }
14836
+
14837
+ if (end == null || line == end) return null
14838
+ return {from: CodeMirror.Pos(line, startCh),
14839
+ to: CodeMirror.Pos(end, endCh)};
14840
+ }
14841
+
14842
+ var startBrace = findOpening("{"), startBracket = findOpening("[");
14843
+ if (startBrace && (!startBracket || startBracket.ch > startBrace.ch)) {
14844
+ return findRange("{", "}", startBrace) || (startBracket && findRange("[", "]", startBracket))
14845
+ } else if (startBracket) {
14846
+ return findRange("[", "]", startBracket) || (startBrace && findRange("{", "}", startBrace))
14847
+ } else {
14848
+ return null
14640
14849
  }
14641
- if (end == null || line == end) return;
14642
- return {from: CodeMirror.Pos(line, startCh),
14643
- to: CodeMirror.Pos(end, endCh)};
14644
14850
  });
14645
14851
 
14646
14852
  CodeMirror.registerHelper("fold", "import", function(cm, start) {
@@ -14766,9 +14972,11 @@ var foldcode = createCommonjsModule(function (module, exports) {
14766
14972
  function getRange(allowFolded) {
14767
14973
  var range = finder(cm, pos);
14768
14974
  if (!range || range.to.line - range.from.line < minSize) return null;
14975
+ if (force === "fold") return range;
14976
+
14769
14977
  var marks = cm.findMarksAt(range.from);
14770
14978
  for (var i = 0; i < marks.length; ++i) {
14771
- if (marks[i].__isFold && force !== "fold") {
14979
+ if (marks[i].__isFold) {
14772
14980
  if (!allowFolded) return null;
14773
14981
  range.cleared = true;
14774
14982
  marks[i].clear();
@@ -14841,18 +15049,18 @@ var foldcode = createCommonjsModule(function (module, exports) {
14841
15049
  cm.foldCode(cm.getCursor(), null, "fold");
14842
15050
  };
14843
15051
  CodeMirror.commands.unfold = function(cm) {
14844
- cm.foldCode(cm.getCursor(), null, "unfold");
15052
+ cm.foldCode(cm.getCursor(), { scanUp: false }, "unfold");
14845
15053
  };
14846
15054
  CodeMirror.commands.foldAll = function(cm) {
14847
15055
  cm.operation(function() {
14848
15056
  for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
14849
- cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
15057
+ cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "fold");
14850
15058
  });
14851
15059
  };
14852
15060
  CodeMirror.commands.unfoldAll = function(cm) {
14853
15061
  cm.operation(function() {
14854
15062
  for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
14855
- cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
15063
+ cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "unfold");
14856
15064
  });
14857
15065
  };
14858
15066
 
@@ -15367,7 +15575,9 @@ var dialog = createCommonjsModule(function (module, exports) {
15367
15575
  if (e.keyCode == 13) callback(inp.value, e);
15368
15576
  });
15369
15577
 
15370
- if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
15578
+ if (options.closeOnBlur !== false) CodeMirror.on(dialog, "focusout", function (evt) {
15579
+ if (evt.relatedTarget !== null) close();
15580
+ });
15371
15581
  } else if (button = dialog.getElementsByTagName("button")[0]) {
15372
15582
  CodeMirror.on(button, "click", function() {
15373
15583
  close();
@@ -15456,8 +15666,11 @@ var jumpToLine = createCommonjsModule(function (module, exports) {
15456
15666
  mod(codemirror, dialog);
15457
15667
  })(function(CodeMirror) {
15458
15668
 
15669
+ // default search panel location
15670
+ CodeMirror.defineOption("search", {bottom: false});
15671
+
15459
15672
  function dialog(cm, text, shortText, deflt, f) {
15460
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
15673
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom});
15461
15674
  else f(prompt(shortText, deflt));
15462
15675
  }
15463
15676
 
@@ -15692,6 +15905,7 @@ var searchcursor = createCommonjsModule(function (module, exports) {
15692
15905
 
15693
15906
  function SearchCursor(doc, query, pos, options) {
15694
15907
  this.atOccurrence = false;
15908
+ this.afterEmptyMatch = false;
15695
15909
  this.doc = doc;
15696
15910
  pos = pos ? doc.clipPos(pos) : Pos(0, 0);
15697
15911
  this.pos = {from: pos, to: pos};
@@ -15727,21 +15941,29 @@ var searchcursor = createCommonjsModule(function (module, exports) {
15727
15941
  findPrevious: function() {return this.find(true)},
15728
15942
 
15729
15943
  find: function(reverse) {
15730
- var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to));
15731
-
15732
- // Implements weird auto-growing behavior on null-matches for
15733
- // backwards-compatiblity with the vim code (unfortunately)
15734
- while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
15944
+ var head = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
15945
+ if (this.afterEmptyMatch && this.atOccurrence) {
15946
+ // do not return the same 0 width match twice
15947
+ head = Pos(head.line, head.ch);
15735
15948
  if (reverse) {
15736
- if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1);
15737
- else if (result.from.line == this.doc.firstLine()) result = null;
15738
- else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)));
15949
+ head.ch--;
15950
+ if (head.ch < 0) {
15951
+ head.line--;
15952
+ head.ch = (this.doc.getLine(head.line) || "").length;
15953
+ }
15739
15954
  } else {
15740
- if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1);
15741
- else if (result.to.line == this.doc.lastLine()) result = null;
15742
- else result = this.matches(reverse, Pos(result.to.line + 1, 0));
15955
+ head.ch++;
15956
+ if (head.ch > (this.doc.getLine(head.line) || "").length) {
15957
+ head.ch = 0;
15958
+ head.line++;
15959
+ }
15960
+ }
15961
+ if (CodeMirror.cmpPos(head, this.doc.clipPos(head)) != 0) {
15962
+ return this.atOccurrence = false
15743
15963
  }
15744
15964
  }
15965
+ var result = this.matches(reverse, head);
15966
+ this.afterEmptyMatch = result && CodeMirror.cmpPos(result.from, result.to) == 0;
15745
15967
 
15746
15968
  if (result) {
15747
15969
  this.pos = result;
@@ -15802,6 +16024,9 @@ var search = createCommonjsModule(function (module, exports) {
15802
16024
  mod(codemirror, searchcursor, dialog);
15803
16025
  })(function(CodeMirror) {
15804
16026
 
16027
+ // default search panel location
16028
+ CodeMirror.defineOption("search", {bottom: false});
16029
+
15805
16030
  function searchOverlay(query, caseInsensitive) {
15806
16031
  if (typeof query == "string")
15807
16032
  query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
@@ -15846,12 +16071,13 @@ var search = createCommonjsModule(function (module, exports) {
15846
16071
  selectValueOnOpen: true,
15847
16072
  closeOnEnter: false,
15848
16073
  onClose: function() { clearSearch(cm); },
15849
- onKeyDown: onKeyDown
16074
+ onKeyDown: onKeyDown,
16075
+ bottom: cm.options.search.bottom
15850
16076
  });
15851
16077
  }
15852
16078
 
15853
16079
  function dialog(cm, text, shortText, deflt, f) {
15854
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
16080
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom});
15855
16081
  else f(prompt(shortText, deflt));
15856
16082
  }
15857
16083
 
@@ -15968,18 +16194,43 @@ var search = createCommonjsModule(function (module, exports) {
15968
16194
  if (state.annotate) { state.annotate.clear(); state.annotate = null; }
15969
16195
  });}
15970
16196
 
16197
+ function el(tag, attrs) {
16198
+ var element = tag ? document.createElement(tag) : document.createDocumentFragment();
16199
+ for (var key in attrs) {
16200
+ element[key] = attrs[key];
16201
+ }
16202
+ for (var i = 2; i < arguments.length; i++) {
16203
+ var child = arguments[i];
16204
+ element.appendChild(typeof child == "string" ? document.createTextNode(child) : child);
16205
+ }
16206
+ return element;
16207
+ }
15971
16208
 
15972
16209
  function getQueryDialog(cm) {
15973
- return '<span class="CodeMirror-search-label">' + cm.phrase("Search:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
16210
+ return el("", null,
16211
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ",
16212
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16213
+ el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16214
+ cm.phrase("(Use /re/ syntax for regexp search)")));
15974
16215
  }
15975
16216
  function getReplaceQueryDialog(cm) {
15976
- return ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
16217
+ return el("", null, " ",
16218
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16219
+ el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16220
+ cm.phrase("(Use /re/ syntax for regexp search)")));
15977
16221
  }
15978
16222
  function getReplacementQueryDialog(cm) {
15979
- return '<span class="CodeMirror-search-label">' + cm.phrase("With:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
16223
+ return el("", null,
16224
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("With:")), " ",
16225
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}));
15980
16226
  }
15981
16227
  function getDoReplaceConfirm(cm) {
15982
- return '<span class="CodeMirror-search-label">' + cm.phrase("Replace?") + '</span> <button>' + cm.phrase("Yes") + '</button> <button>' + cm.phrase("No") + '</button> <button>' + cm.phrase("All") + '</button> <button>' + cm.phrase("Stop") + '</button> ';
16228
+ return el("", null,
16229
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("Replace?")), " ",
16230
+ el("button", {}, cm.phrase("Yes")), " ",
16231
+ el("button", {}, cm.phrase("No")), " ",
16232
+ el("button", {}, cm.phrase("All")), " ",
16233
+ el("button", {}, cm.phrase("Stop")));
15983
16234
  }
15984
16235
 
15985
16236
  function replaceAll(cm, query, text) {
@@ -15996,8 +16247,11 @@ var search = createCommonjsModule(function (module, exports) {
15996
16247
  function replace(cm, all) {
15997
16248
  if (cm.getOption("readOnly")) return;
15998
16249
  var query = cm.getSelection() || getSearchState(cm).lastQuery;
15999
- var dialogText = '<span class="CodeMirror-search-label">' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + '</span>';
16000
- dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) {
16250
+ var dialogText = all ? cm.phrase("Replace all:") : cm.phrase("Replace:");
16251
+ var fragment = el("", null,
16252
+ el("span", {className: "CodeMirror-search-label"}, dialogText),
16253
+ getReplaceQueryDialog(cm));
16254
+ dialog(cm, fragment, dialogText, query, function(query) {
16001
16255
  if (!query) return;
16002
16256
  query = parseQuery(query);
16003
16257
  dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {