@hpcc-js/codemirror 2.50.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.js CHANGED
@@ -5,8 +5,8 @@
5
5
  }(this, (function (exports, common) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/codemirror";
8
- var PKG_VERSION = "2.50.0";
9
- var BUILD_VERSION = "2.87.0";
8
+ var PKG_VERSION = "2.54.0";
9
+ var BUILD_VERSION = "2.95.0";
10
10
 
11
11
  /*! *****************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -98,7 +98,7 @@
98
98
  var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
99
99
  var phantom = /PhantomJS/.test(userAgent);
100
100
 
101
- var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
101
+ var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
102
102
  var android = /Android/.test(userAgent);
103
103
  // This is woefully incomplete. Suggestions for alternative methods welcome.
104
104
  var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
@@ -270,7 +270,7 @@
270
270
  }
271
271
 
272
272
  // Number of pixels added to scroller and sizer to hide scrollbar
273
- var scrollerGap = 30;
273
+ var scrollerGap = 50;
274
274
 
275
275
  // Returned or thrown by various protocols to signal 'I'm not
276
276
  // handling this'.
@@ -551,14 +551,15 @@
551
551
  for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
552
552
  order.push(new BidiSpan(0, start, i$7));
553
553
  } else {
554
- var pos = i$7, at = order.length;
554
+ var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
555
555
  for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
556
556
  for (var j$2 = pos; j$2 < i$7;) {
557
557
  if (countsAsNum.test(types[j$2])) {
558
- if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
558
+ if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; }
559
559
  var nstart = j$2;
560
560
  for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
561
561
  order.splice(at, 0, new BidiSpan(2, nstart, j$2));
562
+ at += isRTL;
562
563
  pos = j$2;
563
564
  } else { ++j$2; }
564
565
  }
@@ -1266,7 +1267,7 @@
1266
1267
  var prop = lineClass[1] ? "bgClass" : "textClass";
1267
1268
  if (output[prop] == null)
1268
1269
  { output[prop] = lineClass[2]; }
1269
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
1270
+ else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop]))
1270
1271
  { output[prop] += " " + lineClass[2]; }
1271
1272
  } }
1272
1273
  return type
@@ -1376,6 +1377,7 @@
1376
1377
  if (span.marker == marker) { return span }
1377
1378
  } }
1378
1379
  }
1380
+
1379
1381
  // Remove a span from an array, returning undefined if no spans are
1380
1382
  // left (we don't store arrays for lines without spans).
1381
1383
  function removeMarkedSpan(spans, span) {
@@ -1384,9 +1386,16 @@
1384
1386
  { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
1385
1387
  return r
1386
1388
  }
1389
+
1387
1390
  // Add a span to a line.
1388
- function addMarkedSpan(line, span) {
1389
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
1391
+ function addMarkedSpan(line, span, op) {
1392
+ var inThisOp = op && window.WeakSet && (op.markedSpans || (op.markedSpans = new WeakSet));
1393
+ if (inThisOp && inThisOp.has(line.markedSpans)) {
1394
+ line.markedSpans.push(span);
1395
+ } else {
1396
+ line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
1397
+ if (inThisOp) { inThisOp.add(line.markedSpans); }
1398
+ }
1390
1399
  span.marker.attachLine(line);
1391
1400
  }
1392
1401
 
@@ -1906,7 +1915,7 @@
1906
1915
  }
1907
1916
  }
1908
1917
  builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
1909
- if (style || startStyle || endStyle || mustWrap || css) {
1918
+ if (style || startStyle || endStyle || mustWrap || css || attributes) {
1910
1919
  var fullStyle = style || "";
1911
1920
  if (startStyle) { fullStyle += startStyle; }
1912
1921
  if (endStyle) { fullStyle += endStyle; }
@@ -2251,6 +2260,7 @@
2251
2260
  if (cm.options.lineNumbers || markers) {
2252
2261
  var wrap$1 = ensureLineWrapped(lineView);
2253
2262
  var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
2263
+ gutterWrap.setAttribute("aria-hidden", "true");
2254
2264
  cm.display.input.setUneditable(gutterWrap);
2255
2265
  wrap$1.insertBefore(gutterWrap, lineView.text);
2256
2266
  if (lineView.line.gutterClass)
@@ -2407,12 +2417,14 @@
2407
2417
  function mapFromLineView(lineView, line, lineN) {
2408
2418
  if (lineView.line == line)
2409
2419
  { return {map: lineView.measure.map, cache: lineView.measure.cache} }
2410
- for (var i = 0; i < lineView.rest.length; i++)
2411
- { if (lineView.rest[i] == line)
2412
- { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
2413
- for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
2414
- { if (lineNo(lineView.rest[i$1]) > lineN)
2415
- { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
2420
+ if (lineView.rest) {
2421
+ for (var i = 0; i < lineView.rest.length; i++)
2422
+ { if (lineView.rest[i] == line)
2423
+ { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
2424
+ for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
2425
+ { if (lineNo(lineView.rest[i$1]) > lineN)
2426
+ { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
2427
+ }
2416
2428
  }
2417
2429
 
2418
2430
  // Render a line into the hidden node display.externalMeasured. Used
@@ -3025,7 +3037,7 @@
3025
3037
  var x, y, space = display.lineSpace.getBoundingClientRect();
3026
3038
  // Fails unpredictably on IE[67] when mouse is dragged around quickly.
3027
3039
  try { x = e.clientX - space.left; y = e.clientY - space.top; }
3028
- catch (e) { return null }
3040
+ catch (e$1) { return null }
3029
3041
  var coords = coordsChar(cm, x, y), line;
3030
3042
  if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
3031
3043
  var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
@@ -3206,13 +3218,19 @@
3206
3218
  var curFragment = result.cursors = document.createDocumentFragment();
3207
3219
  var selFragment = result.selection = document.createDocumentFragment();
3208
3220
 
3221
+ var customCursor = cm.options.$customCursor;
3222
+ if (customCursor) { primary = true; }
3209
3223
  for (var i = 0; i < doc.sel.ranges.length; i++) {
3210
3224
  if (!primary && i == doc.sel.primIndex) { continue }
3211
3225
  var range = doc.sel.ranges[i];
3212
3226
  if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
3213
3227
  var collapsed = range.empty();
3214
- if (collapsed || cm.options.showCursorWhenSelecting)
3215
- { drawSelectionCursor(cm, range.head, curFragment); }
3228
+ if (customCursor) {
3229
+ var head = customCursor(cm, range);
3230
+ if (head) { drawSelectionCursor(cm, head, curFragment); }
3231
+ } else if (collapsed || cm.options.showCursorWhenSelecting) {
3232
+ drawSelectionCursor(cm, range.head, curFragment);
3233
+ }
3216
3234
  if (!collapsed)
3217
3235
  { drawSelectionRange(cm, range, selFragment); }
3218
3236
  }
@@ -3228,6 +3246,12 @@
3228
3246
  cursor.style.top = pos.top + "px";
3229
3247
  cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
3230
3248
 
3249
+ if (/\bcm-fat-cursor\b/.test(cm.getWrapperElement().className)) {
3250
+ var charPos = charCoords(cm, head, "div", null, null);
3251
+ var width = charPos.right - charPos.left;
3252
+ cursor.style.width = (width > 0 ? width : cm.defaultCharWidth()) + "px";
3253
+ }
3254
+
3231
3255
  if (pos.other) {
3232
3256
  // Secondary cursor, shown when on a 'jump' in bi-directional text
3233
3257
  var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
@@ -3341,26 +3365,31 @@
3341
3365
  var on = true;
3342
3366
  display.cursorDiv.style.visibility = "";
3343
3367
  if (cm.options.cursorBlinkRate > 0)
3344
- { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
3345
- cm.options.cursorBlinkRate); }
3368
+ { display.blinker = setInterval(function () {
3369
+ if (!cm.hasFocus()) { onBlur(cm); }
3370
+ display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
3371
+ }, cm.options.cursorBlinkRate); }
3346
3372
  else if (cm.options.cursorBlinkRate < 0)
3347
3373
  { display.cursorDiv.style.visibility = "hidden"; }
3348
3374
  }
3349
3375
 
3350
3376
  function ensureFocus(cm) {
3351
- if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
3377
+ if (!cm.hasFocus()) {
3378
+ cm.display.input.focus();
3379
+ if (!cm.state.focused) { onFocus(cm); }
3380
+ }
3352
3381
  }
3353
3382
 
3354
3383
  function delayBlurEvent(cm) {
3355
3384
  cm.state.delayingBlurEvent = true;
3356
3385
  setTimeout(function () { if (cm.state.delayingBlurEvent) {
3357
3386
  cm.state.delayingBlurEvent = false;
3358
- onBlur(cm);
3387
+ if (cm.state.focused) { onBlur(cm); }
3359
3388
  } }, 100);
3360
3389
  }
3361
3390
 
3362
3391
  function onFocus(cm, e) {
3363
- if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
3392
+ if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; }
3364
3393
 
3365
3394
  if (cm.options.readOnly == "nocursor") { return }
3366
3395
  if (!cm.state.focused) {
@@ -3395,10 +3424,14 @@
3395
3424
  function updateHeightsInViewport(cm) {
3396
3425
  var display = cm.display;
3397
3426
  var prevBottom = display.lineDiv.offsetTop;
3427
+ var viewTop = Math.max(0, display.scroller.getBoundingClientRect().top);
3428
+ var oldHeight = display.lineDiv.getBoundingClientRect().top;
3429
+ var mustScroll = 0;
3398
3430
  for (var i = 0; i < display.view.length; i++) {
3399
3431
  var cur = display.view[i], wrapping = cm.options.lineWrapping;
3400
3432
  var height = (void 0), width = 0;
3401
3433
  if (cur.hidden) { continue }
3434
+ oldHeight += cur.line.height;
3402
3435
  if (ie && ie_version < 8) {
3403
3436
  var bot = cur.node.offsetTop + cur.node.offsetHeight;
3404
3437
  height = bot - prevBottom;
@@ -3413,6 +3446,7 @@
3413
3446
  }
3414
3447
  var diff = cur.line.height - height;
3415
3448
  if (diff > .005 || diff < -.005) {
3449
+ if (oldHeight < viewTop) { mustScroll -= diff; }
3416
3450
  updateLineHeight(cur.line, height);
3417
3451
  updateWidgetHeight(cur.line);
3418
3452
  if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
@@ -3427,6 +3461,7 @@
3427
3461
  }
3428
3462
  }
3429
3463
  }
3464
+ if (Math.abs(mustScroll) > 2) { display.scroller.scrollTop += mustScroll; }
3430
3465
  }
3431
3466
 
3432
3467
  // Read and store the height of line widgets associated with the
@@ -3490,8 +3525,8 @@
3490
3525
  // Set pos and end to the cursor positions around the character pos sticks to
3491
3526
  // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
3492
3527
  // If pos == Pos(_, 0, "before"), pos and end are unchanged
3493
- pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
3494
3528
  end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
3529
+ pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
3495
3530
  }
3496
3531
  for (var limit = 0; limit < 5; limit++) {
3497
3532
  var changed = false;
@@ -3542,14 +3577,15 @@
3542
3577
  if (newTop != screentop) { result.scrollTop = newTop; }
3543
3578
  }
3544
3579
 
3545
- var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
3546
- var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
3580
+ var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth;
3581
+ var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace;
3582
+ var screenw = displayWidth(cm) - display.gutters.offsetWidth;
3547
3583
  var tooWide = rect.right - rect.left > screenw;
3548
3584
  if (tooWide) { rect.right = rect.left + screenw; }
3549
3585
  if (rect.left < 10)
3550
3586
  { result.scrollLeft = 0; }
3551
3587
  else if (rect.left < screenleft)
3552
- { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
3588
+ { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); }
3553
3589
  else if (rect.right > screenw + screenleft - 3)
3554
3590
  { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
3555
3591
  return result
@@ -3616,7 +3652,7 @@
3616
3652
  }
3617
3653
 
3618
3654
  function setScrollTop(cm, val, forceScroll) {
3619
- val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
3655
+ val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val));
3620
3656
  if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
3621
3657
  cm.doc.scrollTop = val;
3622
3658
  cm.display.scrollbars.setScrollTop(val);
@@ -3626,7 +3662,7 @@
3626
3662
  // Sync scroller and scrollbar, ensure the gutter elements are
3627
3663
  // aligned.
3628
3664
  function setScrollLeft(cm, val, isScroller, forceScroll) {
3629
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
3665
+ val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth));
3630
3666
  if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
3631
3667
  cm.doc.scrollLeft = val;
3632
3668
  alignHorizontally(cm);
@@ -3686,6 +3722,7 @@
3686
3722
  this.vert.firstChild.style.height =
3687
3723
  Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
3688
3724
  } else {
3725
+ this.vert.scrollTop = 0;
3689
3726
  this.vert.style.display = "";
3690
3727
  this.vert.firstChild.style.height = "0";
3691
3728
  }
@@ -3841,7 +3878,8 @@
3841
3878
  scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
3842
3879
  scrollToPos: null, // Used to scroll to a specific position
3843
3880
  focus: false,
3844
- id: ++nextOpId // Unique ID
3881
+ id: ++nextOpId, // Unique ID
3882
+ markArrays: null // Used by addMarkedSpan
3845
3883
  };
3846
3884
  pushOperation(cm.curOp);
3847
3885
  }
@@ -4115,7 +4153,8 @@
4115
4153
  function restoreSelection(snapshot) {
4116
4154
  if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
4117
4155
  snapshot.activeElt.focus();
4118
- if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4156
+ if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
4157
+ snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
4119
4158
  var sel = window.getSelection(), range = document.createRange();
4120
4159
  range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
4121
4160
  range.collapse(false);
@@ -4213,6 +4252,8 @@
4213
4252
  update.visible = visibleLines(cm.display, cm.doc, viewport);
4214
4253
  if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
4215
4254
  { break }
4255
+ } else if (first) {
4256
+ update.visible = visibleLines(cm.display, cm.doc, viewport);
4216
4257
  }
4217
4258
  if (!updateDisplayIfNeeded(cm, update)) { break }
4218
4259
  updateHeightsInViewport(cm);
@@ -4291,6 +4332,8 @@
4291
4332
  function updateGutterSpace(display) {
4292
4333
  var width = display.gutters.offsetWidth;
4293
4334
  display.sizer.style.marginLeft = width + "px";
4335
+ // Send an event to consumers responding to changes in gutter width.
4336
+ signalLater(display, "gutterChanged", display);
4294
4337
  }
4295
4338
 
4296
4339
  function setDocumentHeight(cm, measure) {
@@ -4430,6 +4473,10 @@
4430
4473
  // The element in which the editor lives.
4431
4474
  d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
4432
4475
 
4476
+ // This attribute is respected by automatic translation systems such as Google Translate,
4477
+ // and may also be respected by tools used by human translators.
4478
+ d.wrapper.setAttribute('translate', 'no');
4479
+
4433
4480
  // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
4434
4481
  if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
4435
4482
  if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
@@ -4527,6 +4574,12 @@
4527
4574
 
4528
4575
  function onScrollWheel(cm, e) {
4529
4576
  var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
4577
+ var pixelsPerUnit = wheelPixelsPerUnit;
4578
+ if (e.deltaMode === 0) {
4579
+ dx = e.deltaX;
4580
+ dy = e.deltaY;
4581
+ pixelsPerUnit = 1;
4582
+ }
4530
4583
 
4531
4584
  var display = cm.display, scroll = display.scroller;
4532
4585
  // Quit if there's nothing to scroll here
@@ -4555,10 +4608,10 @@
4555
4608
  // estimated pixels/delta value, we just handle horizontal
4556
4609
  // scrolling entirely here. It'll be slightly off from native, but
4557
4610
  // better than glitching out.
4558
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
4611
+ if (dx && !gecko && !presto && pixelsPerUnit != null) {
4559
4612
  if (dy && canScrollY)
4560
- { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
4561
- setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
4613
+ { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * pixelsPerUnit)); }
4614
+ setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * pixelsPerUnit));
4562
4615
  // Only prevent default scrolling if vertical scrolling is
4563
4616
  // actually possible. Otherwise, it causes vertical scroll
4564
4617
  // jitter on OSX trackpads when deltaX is small and deltaY
@@ -4571,15 +4624,15 @@
4571
4624
 
4572
4625
  // 'Project' the visible viewport to cover the area that is being
4573
4626
  // scrolled into view (if we know enough to estimate it).
4574
- if (dy && wheelPixelsPerUnit != null) {
4575
- var pixels = dy * wheelPixelsPerUnit;
4627
+ if (dy && pixelsPerUnit != null) {
4628
+ var pixels = dy * pixelsPerUnit;
4576
4629
  var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
4577
4630
  if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
4578
4631
  else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
4579
4632
  updateDisplaySimple(cm, {top: top, bottom: bot});
4580
4633
  }
4581
4634
 
4582
- if (wheelSamples < 20) {
4635
+ if (wheelSamples < 20 && e.deltaMode !== 0) {
4583
4636
  if (display.wheelStartX == null) {
4584
4637
  display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
4585
4638
  display.wheelDX = dx; display.wheelDY = dy;
@@ -4838,6 +4891,7 @@
4838
4891
  estimateLineHeights(cm);
4839
4892
  loadMode(cm);
4840
4893
  setDirectionClass(cm);
4894
+ cm.options.direction = doc.direction;
4841
4895
  if (!cm.options.lineWrapping) { findMaxLine(cm); }
4842
4896
  cm.options.mode = doc.modeOption;
4843
4897
  regChange(cm);
@@ -4854,19 +4908,19 @@
4854
4908
  });
4855
4909
  }
4856
4910
 
4857
- function History(startGen) {
4911
+ function History(prev) {
4858
4912
  // Arrays of change events and selections. Doing something adds an
4859
4913
  // event to done and clears undo. Undoing moves events from done
4860
4914
  // to undone, redoing moves them in the other direction.
4861
4915
  this.done = []; this.undone = [];
4862
- this.undoDepth = Infinity;
4916
+ this.undoDepth = prev ? prev.undoDepth : Infinity;
4863
4917
  // Used to track when changes can be merged into a single undo
4864
4918
  // event
4865
4919
  this.lastModTime = this.lastSelTime = 0;
4866
4920
  this.lastOp = this.lastSelOp = null;
4867
4921
  this.lastOrigin = this.lastSelOrigin = null;
4868
4922
  // Used by the isClean() method
4869
- this.generation = this.maxGeneration = startGen || 1;
4923
+ this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1;
4870
4924
  }
4871
4925
 
4872
4926
  // Create a history change event from an updateDoc-style change
@@ -5171,7 +5225,7 @@
5171
5225
  (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
5172
5226
  setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
5173
5227
 
5174
- if (!(options && options.scroll === false) && doc.cm)
5228
+ if (!(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor")
5175
5229
  { ensureCursorVisible(doc.cm); }
5176
5230
  }
5177
5231
 
@@ -5828,7 +5882,7 @@
5828
5882
  changeLine(doc, handle, "widget", function (line) {
5829
5883
  var widgets = line.widgets || (line.widgets = []);
5830
5884
  if (widget.insertAt == null) { widgets.push(widget); }
5831
- else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
5885
+ else { widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget); }
5832
5886
  widget.line = line;
5833
5887
  if (cm && !lineIsHidden(doc, line)) {
5834
5888
  var aboveVisible = heightAtLine(line) < doc.scrollTop;
@@ -6014,7 +6068,7 @@
6014
6068
  if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
6015
6069
  addMarkedSpan(line, new MarkedSpan(marker,
6016
6070
  curLine == from.line ? from.ch : null,
6017
- curLine == to.line ? to.ch : null));
6071
+ curLine == to.line ? to.ch : null), doc.cm && doc.cm.curOp);
6018
6072
  ++curLine;
6019
6073
  });
6020
6074
  // lineIsHidden depends on the presence of the spans, so needs a second pass
@@ -6186,6 +6240,7 @@
6186
6240
  getRange: function(from, to, lineSep) {
6187
6241
  var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
6188
6242
  if (lineSep === false) { return lines }
6243
+ if (lineSep === '') { return lines.join('') }
6189
6244
  return lines.join(lineSep || this.lineSeparator())
6190
6245
  },
6191
6246
 
@@ -6237,7 +6292,7 @@
6237
6292
  var out = [];
6238
6293
  for (var i = 0; i < ranges.length; i++)
6239
6294
  { out[i] = new Range(clipPos(this, ranges[i].anchor),
6240
- clipPos(this, ranges[i].head)); }
6295
+ clipPos(this, ranges[i].head || ranges[i].anchor)); }
6241
6296
  if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
6242
6297
  setSelection(this, normalizeSelection(this.cm, out, primary), options);
6243
6298
  }),
@@ -6297,7 +6352,12 @@
6297
6352
  for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
6298
6353
  return {undo: done, redo: undone}
6299
6354
  },
6300
- clearHistory: function() {this.history = new History(this.history.maxGeneration);},
6355
+ clearHistory: function() {
6356
+ var this$1 = this;
6357
+
6358
+ this.history = new History(this.history);
6359
+ linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true);
6360
+ },
6301
6361
 
6302
6362
  markClean: function() {
6303
6363
  this.cleanGeneration = this.changeGeneration(true);
@@ -6316,7 +6376,7 @@
6316
6376
  undone: copyHistoryArray(this.history.undone)}
6317
6377
  },
6318
6378
  setHistory: function(histData) {
6319
- var hist = this.history = new History(this.history.maxGeneration);
6379
+ var hist = this.history = new History(this.history);
6320
6380
  hist.done = copyHistoryArray(histData.done.slice(0), null, true);
6321
6381
  hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
6322
6382
  },
@@ -6548,28 +6608,39 @@
6548
6608
  // and insert it.
6549
6609
  if (files && files.length && window.FileReader && window.File) {
6550
6610
  var n = files.length, text = Array(n), read = 0;
6551
- var loadFile = function (file, i) {
6552
- if (cm.options.allowDropFileTypes &&
6553
- indexOf(cm.options.allowDropFileTypes, file.type) == -1)
6554
- { return }
6555
-
6556
- var reader = new FileReader;
6557
- reader.onload = operation(cm, function () {
6558
- var content = reader.result;
6559
- if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
6560
- text[i] = content;
6561
- if (++read == n) {
6611
+ var markAsReadAndPasteIfAllFilesAreRead = function () {
6612
+ if (++read == n) {
6613
+ operation(cm, function () {
6562
6614
  pos = clipPos(cm.doc, pos);
6563
6615
  var change = {from: pos, to: pos,
6564
- text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
6616
+ text: cm.doc.splitLines(
6617
+ text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())),
6565
6618
  origin: "paste"};
6566
6619
  makeChange(cm.doc, change);
6567
- setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
6620
+ setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change))));
6621
+ })();
6622
+ }
6623
+ };
6624
+ var readTextFromFile = function (file, i) {
6625
+ if (cm.options.allowDropFileTypes &&
6626
+ indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
6627
+ markAsReadAndPasteIfAllFilesAreRead();
6628
+ return
6629
+ }
6630
+ var reader = new FileReader;
6631
+ reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); };
6632
+ reader.onload = function () {
6633
+ var content = reader.result;
6634
+ if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
6635
+ markAsReadAndPasteIfAllFilesAreRead();
6636
+ return
6568
6637
  }
6569
- });
6638
+ text[i] = content;
6639
+ markAsReadAndPasteIfAllFilesAreRead();
6640
+ };
6570
6641
  reader.readAsText(file);
6571
6642
  };
6572
- for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
6643
+ for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); }
6573
6644
  } else { // Normal drop
6574
6645
  // Don't do a replace if the drop happened inside of the selected text.
6575
6646
  if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
@@ -6591,7 +6662,7 @@
6591
6662
  cm.display.input.focus();
6592
6663
  }
6593
6664
  }
6594
- catch(e){}
6665
+ catch(e$1){}
6595
6666
  }
6596
6667
  }
6597
6668
 
@@ -6687,7 +6758,7 @@
6687
6758
  46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
6688
6759
  106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
6689
6760
  173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
6690
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
6761
+ 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
6691
6762
  63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
6692
6763
  };
6693
6764
 
@@ -6724,10 +6795,9 @@
6724
6795
  // Very basic readline/emacs-style bindings, which are standard on Mac.
6725
6796
  keyMap.emacsy = {
6726
6797
  "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
6727
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
6728
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
6729
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
6730
- "Ctrl-O": "openLine"
6798
+ "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp",
6799
+ "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine",
6800
+ "Ctrl-T": "transposeChars", "Ctrl-O": "openLine"
6731
6801
  };
6732
6802
  keyMap.macDefault = {
6733
6803
  "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
@@ -6822,7 +6892,7 @@
6822
6892
  var base = name;
6823
6893
  if (event.altKey && base != "Alt") { name = "Alt-" + name; }
6824
6894
  if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
6825
- if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
6895
+ if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") { name = "Cmd-" + name; }
6826
6896
  if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
6827
6897
  return name
6828
6898
  }
@@ -6879,6 +6949,7 @@
6879
6949
 
6880
6950
  function endOfLine(visually, cm, lineObj, lineNo, dir) {
6881
6951
  if (visually) {
6952
+ if (cm.doc.direction == "rtl") { dir = -dir; }
6882
6953
  var order = getOrder(lineObj, cm.doc.direction);
6883
6954
  if (order) {
6884
6955
  var part = dir < 0 ? lst(order) : order[0];
@@ -7047,7 +7118,7 @@
7047
7118
  goGroupRight: function (cm) { return cm.moveH(1, "group"); },
7048
7119
  goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
7049
7120
  goWordRight: function (cm) { return cm.moveH(1, "word"); },
7050
- delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
7121
+ delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); },
7051
7122
  delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
7052
7123
  delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
7053
7124
  delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
@@ -7133,7 +7204,7 @@
7133
7204
  var line = getLine(cm.doc, start.line);
7134
7205
  var order = getOrder(line, cm.doc.direction);
7135
7206
  if (!order || order[0].level == 0) {
7136
- var firstNonWS = Math.max(0, line.text.search(/\S/));
7207
+ var firstNonWS = Math.max(start.ch, line.text.search(/\S/));
7137
7208
  var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
7138
7209
  return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
7139
7210
  }
@@ -7236,6 +7307,7 @@
7236
7307
  var lastStoppedKey = null;
7237
7308
  function onKeyDown(e) {
7238
7309
  var cm = this;
7310
+ if (e.target && e.target != cm.display.input.getField()) { return }
7239
7311
  cm.curOp.focus = activeElt();
7240
7312
  if (signalDOMEvent(cm, e)) { return }
7241
7313
  // IE does strange things with escape.
@@ -7279,6 +7351,7 @@
7279
7351
 
7280
7352
  function onKeyPress(e) {
7281
7353
  var cm = this;
7354
+ if (e.target && e.target != cm.display.input.getField()) { return }
7282
7355
  if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
7283
7356
  var keyCode = e.keyCode, charCode = e.charCode;
7284
7357
  if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
@@ -7418,6 +7491,10 @@
7418
7491
  var dragEnd = operation(cm, function (e) {
7419
7492
  if (webkit) { display.scroller.draggable = false; }
7420
7493
  cm.state.draggingText = false;
7494
+ if (cm.state.delayingBlurEvent) {
7495
+ if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; }
7496
+ else { delayBlurEvent(cm); }
7497
+ }
7421
7498
  off(display.wrapper.ownerDocument, "mouseup", dragEnd);
7422
7499
  off(display.wrapper.ownerDocument, "mousemove", mouseMove);
7423
7500
  off(display.scroller, "dragstart", dragStart);
@@ -7427,8 +7504,8 @@
7427
7504
  if (!behavior.addNew)
7428
7505
  { extendSelection(cm.doc, pos, null, null, behavior.extend); }
7429
7506
  // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
7430
- if (webkit || ie && ie_version == 9)
7431
- { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
7507
+ if ((webkit && !safari) || ie && ie_version == 9)
7508
+ { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); }
7432
7509
  else
7433
7510
  { display.input.focus(); }
7434
7511
  }
@@ -7441,15 +7518,15 @@
7441
7518
  if (webkit) { display.scroller.draggable = true; }
7442
7519
  cm.state.draggingText = dragEnd;
7443
7520
  dragEnd.copy = !behavior.moveOnDrag;
7444
- // IE's approach to draggable
7445
- if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
7446
7521
  on(display.wrapper.ownerDocument, "mouseup", dragEnd);
7447
7522
  on(display.wrapper.ownerDocument, "mousemove", mouseMove);
7448
7523
  on(display.scroller, "dragstart", dragStart);
7449
7524
  on(display.scroller, "drop", dragEnd);
7450
7525
 
7451
- delayBlurEvent(cm);
7526
+ cm.state.delayingBlurEvent = true;
7452
7527
  setTimeout(function () { return display.input.focus(); }, 20);
7528
+ // IE's approach to draggable
7529
+ if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
7453
7530
  }
7454
7531
 
7455
7532
  function rangeForUnit(cm, pos, unit) {
@@ -7462,6 +7539,7 @@
7462
7539
 
7463
7540
  // Normal selection, as opposed to text dragging.
7464
7541
  function leftButtonSelect(cm, event, start, behavior) {
7542
+ if (ie) { delayBlurEvent(cm); }
7465
7543
  var display = cm.display, doc = cm.doc;
7466
7544
  e_preventDefault(event);
7467
7545
 
@@ -7640,7 +7718,7 @@
7640
7718
  mY = e.touches[0].clientY;
7641
7719
  } else {
7642
7720
  try { mX = e.clientX; mY = e.clientY; }
7643
- catch(e) { return false }
7721
+ catch(e$1) { return false }
7644
7722
  }
7645
7723
  if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
7646
7724
  if (prevent) { e_preventDefault(e); }
@@ -7740,7 +7818,7 @@
7740
7818
  for (var i = newBreaks.length - 1; i >= 0; i--)
7741
7819
  { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
7742
7820
  });
7743
- option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7821
+ option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
7744
7822
  cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
7745
7823
  if (old != Init) { cm.refresh(); }
7746
7824
  });
@@ -7804,6 +7882,12 @@
7804
7882
  }
7805
7883
  cm.display.input.readOnlyChanged(val);
7806
7884
  });
7885
+
7886
+ option("screenReaderLabel", null, function (cm, val) {
7887
+ val = (val === '') ? null : val;
7888
+ cm.display.input.screenReaderLabelChanged(val);
7889
+ });
7890
+
7807
7891
  option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
7808
7892
  option("dragDrop", true, dragDropChanged);
7809
7893
  option("allowDropFileTypes", null);
@@ -7914,7 +7998,9 @@
7914
7998
  attachDoc(this, doc);
7915
7999
 
7916
8000
  if ((options.autofocus && !mobile) || this.hasFocus())
7917
- { setTimeout(bind(onFocus, this), 20); }
8001
+ { setTimeout(function () {
8002
+ if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); }
8003
+ }, 20); }
7918
8004
  else
7919
8005
  { onBlur(this); }
7920
8006
 
@@ -7956,6 +8042,9 @@
7956
8042
  // which point we can't mess with it anymore. Context menu is
7957
8043
  // handled in onMouseDown for these browsers.
7958
8044
  on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); });
8045
+ on(d.input.getField(), "contextmenu", function (e) {
8046
+ if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); }
8047
+ });
7959
8048
 
7960
8049
  // Used to suppress mouse event handling when a touch happens
7961
8050
  var touchFinished, prevTouch = {end: 0};
@@ -8151,7 +8240,7 @@
8151
8240
  { from = Pos(from.line, from.ch - deleted); }
8152
8241
  else if (cm.state.overwrite && !paste) // Handle overwrite
8153
8242
  { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
8154
- else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
8243
+ else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n"))
8155
8244
  { from = to = Pos(from.line, 0); }
8156
8245
  }
8157
8246
  var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
@@ -8220,7 +8309,7 @@
8220
8309
  }
8221
8310
 
8222
8311
  function hiddenTextarea() {
8223
- var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
8312
+ var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; min-height: 1em; outline: none");
8224
8313
  var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
8225
8314
  // The textarea is kept positioned near the cursor to prevent the
8226
8315
  // fact that it'll be scrolled into view on input from scrolling
@@ -8632,7 +8721,7 @@
8632
8721
  clearCaches(this);
8633
8722
  scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
8634
8723
  updateGutterSpace(this.display);
8635
- if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
8724
+ if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping)
8636
8725
  { estimateLineHeights(this); }
8637
8726
  signal(this, "refresh", this);
8638
8727
  }),
@@ -8674,34 +8763,43 @@
8674
8763
  }
8675
8764
 
8676
8765
  // Used for horizontal relative motion. Dir is -1 or 1 (left or
8677
- // right), unit can be "char", "column" (like char, but doesn't
8678
- // cross line boundaries), "word" (across next word), or "group" (to
8679
- // the start of next group of word or non-word-non-whitespace
8680
- // chars). The visually param controls whether, in right-to-left
8681
- // text, direction 1 means to move towards the next index in the
8682
- // string, or towards the character to the right of the current
8683
- // position. The resulting position will have a hitSide=true
8684
- // property if it reached the end of the document.
8766
+ // right), unit can be "codepoint", "char", "column" (like char, but
8767
+ // doesn't cross line boundaries), "word" (across next word), or
8768
+ // "group" (to the start of next group of word or
8769
+ // non-word-non-whitespace chars). The visually param controls
8770
+ // whether, in right-to-left text, direction 1 means to move towards
8771
+ // the next index in the string, or towards the character to the right
8772
+ // of the current position. The resulting position will have a
8773
+ // hitSide=true property if it reached the end of the document.
8685
8774
  function findPosH(doc, pos, dir, unit, visually) {
8686
8775
  var oldPos = pos;
8687
8776
  var origDir = dir;
8688
8777
  var lineObj = getLine(doc, pos.line);
8778
+ var lineDir = visually && doc.direction == "rtl" ? -dir : dir;
8689
8779
  function findNextLine() {
8690
- var l = pos.line + dir;
8780
+ var l = pos.line + lineDir;
8691
8781
  if (l < doc.first || l >= doc.first + doc.size) { return false }
8692
8782
  pos = new Pos(l, pos.ch, pos.sticky);
8693
8783
  return lineObj = getLine(doc, l)
8694
8784
  }
8695
8785
  function moveOnce(boundToLine) {
8696
8786
  var next;
8697
- if (visually) {
8787
+ if (unit == "codepoint") {
8788
+ var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1));
8789
+ if (isNaN(ch)) {
8790
+ next = null;
8791
+ } else {
8792
+ var astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF;
8793
+ next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir);
8794
+ }
8795
+ } else if (visually) {
8698
8796
  next = moveVisually(doc.cm, lineObj, pos, dir);
8699
8797
  } else {
8700
8798
  next = moveLogically(lineObj, pos, dir);
8701
8799
  }
8702
8800
  if (next == null) {
8703
8801
  if (!boundToLine && findNextLine())
8704
- { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
8802
+ { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); }
8705
8803
  else
8706
8804
  { return false }
8707
8805
  } else {
@@ -8710,7 +8808,7 @@
8710
8808
  return true
8711
8809
  }
8712
8810
 
8713
- if (unit == "char") {
8811
+ if (unit == "char" || unit == "codepoint") {
8714
8812
  moveOnce();
8715
8813
  } else if (unit == "column") {
8716
8814
  moveOnce(true);
@@ -8778,10 +8876,19 @@
8778
8876
 
8779
8877
  var input = this, cm = input.cm;
8780
8878
  var div = input.div = display.lineDiv;
8879
+ div.contentEditable = true;
8781
8880
  disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
8782
8881
 
8882
+ function belongsToInput(e) {
8883
+ for (var t = e.target; t; t = t.parentNode) {
8884
+ if (t == div) { return true }
8885
+ if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break }
8886
+ }
8887
+ return false
8888
+ }
8889
+
8783
8890
  on(div, "paste", function (e) {
8784
- if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
8891
+ if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
8785
8892
  // IE doesn't fire input events, so we schedule a read for the pasted content in this way
8786
8893
  if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
8787
8894
  });
@@ -8806,7 +8913,7 @@
8806
8913
  });
8807
8914
 
8808
8915
  function onCopyCut(e) {
8809
- if (signalDOMEvent(cm, e)) { return }
8916
+ if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return }
8810
8917
  if (cm.somethingSelected()) {
8811
8918
  setLastCopied({lineWise: false, text: cm.getSelections()});
8812
8919
  if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
@@ -8836,7 +8943,7 @@
8836
8943
  var kludge = hiddenTextarea(), te = kludge.firstChild;
8837
8944
  cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8838
8945
  te.value = lastCopied.text.join("\n");
8839
- var hadFocus = document.activeElement;
8946
+ var hadFocus = activeElt();
8840
8947
  selectInput(te);
8841
8948
  setTimeout(function () {
8842
8949
  cm.display.lineSpace.removeChild(kludge);
@@ -8848,9 +8955,18 @@
8848
8955
  on(div, "cut", onCopyCut);
8849
8956
  };
8850
8957
 
8958
+ ContentEditableInput.prototype.screenReaderLabelChanged = function (label) {
8959
+ // Label for screenreaders, accessibility
8960
+ if(label) {
8961
+ this.div.setAttribute('aria-label', label);
8962
+ } else {
8963
+ this.div.removeAttribute('aria-label');
8964
+ }
8965
+ };
8966
+
8851
8967
  ContentEditableInput.prototype.prepareSelection = function () {
8852
8968
  var result = prepareSelection(this.cm, false);
8853
- result.focus = this.cm.state.focused;
8969
+ result.focus = activeElt() == this.div;
8854
8970
  return result
8855
8971
  };
8856
8972
 
@@ -8946,7 +9062,7 @@
8946
9062
 
8947
9063
  ContentEditableInput.prototype.focus = function () {
8948
9064
  if (this.cm.options.readOnly != "nocursor") {
8949
- if (!this.selectionInEditor())
9065
+ if (!this.selectionInEditor() || activeElt() != this.div)
8950
9066
  { this.showSelection(this.prepareSelection(), true); }
8951
9067
  this.div.focus();
8952
9068
  }
@@ -8957,9 +9073,11 @@
8957
9073
  ContentEditableInput.prototype.supportsTouch = function () { return true };
8958
9074
 
8959
9075
  ContentEditableInput.prototype.receivedFocus = function () {
9076
+ var this$1 = this;
9077
+
8960
9078
  var input = this;
8961
9079
  if (this.selectionInEditor())
8962
- { this.pollSelection(); }
9080
+ { setTimeout(function () { return this$1.pollSelection(); }, 20); }
8963
9081
  else
8964
9082
  { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
8965
9083
 
@@ -9388,6 +9506,15 @@
9388
9506
  this.textarea = this.wrapper.firstChild;
9389
9507
  };
9390
9508
 
9509
+ TextareaInput.prototype.screenReaderLabelChanged = function (label) {
9510
+ // Label for screenreaders, accessibility
9511
+ if(label) {
9512
+ this.textarea.setAttribute('aria-label', label);
9513
+ } else {
9514
+ this.textarea.removeAttribute('aria-label');
9515
+ }
9516
+ };
9517
+
9391
9518
  TextareaInput.prototype.prepareSelection = function () {
9392
9519
  // Redraw the selection and/or cursor
9393
9520
  var cm = this.cm, display = cm.display, doc = cm.doc;
@@ -9628,6 +9755,7 @@
9628
9755
  TextareaInput.prototype.readOnlyChanged = function (val) {
9629
9756
  if (!val) { this.reset(); }
9630
9757
  this.textarea.disabled = val == "nocursor";
9758
+ this.textarea.readOnly = !!val;
9631
9759
  };
9632
9760
 
9633
9761
  TextareaInput.prototype.setUneditable = function () {};
@@ -9778,7 +9906,7 @@
9778
9906
 
9779
9907
  addLegacyProps(CodeMirror);
9780
9908
 
9781
- CodeMirror.version = "5.50.2";
9909
+ CodeMirror.version = "5.65.0";
9782
9910
 
9783
9911
  return CodeMirror;
9784
9912
 
@@ -9811,7 +9939,8 @@
9811
9939
  valueKeywords = parserConfig.valueKeywords || {},
9812
9940
  allowNested = parserConfig.allowNested,
9813
9941
  lineComment = parserConfig.lineComment,
9814
- supportsAtComponent = parserConfig.supportsAtComponent === true;
9942
+ supportsAtComponent = parserConfig.supportsAtComponent === true,
9943
+ highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;
9815
9944
 
9816
9945
  var type, override;
9817
9946
  function ret(style, tp) { type = tp; return style; }
@@ -9859,8 +9988,8 @@
9859
9988
  return ret("qualifier", "qualifier");
9860
9989
  } else if (/[:;{}\[\]\(\)]/.test(ch)) {
9861
9990
  return ret(null, ch);
9862
- } else if (stream.match(/[\w-.]+(?=\()/)) {
9863
- if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
9991
+ } else if (stream.match(/^[\w-.]+(?=\()/)) {
9992
+ if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) {
9864
9993
  state.tokenize = tokenParenthesized;
9865
9994
  }
9866
9995
  return ret("variable callee", "variable");
@@ -9889,7 +10018,7 @@
9889
10018
 
9890
10019
  function tokenParenthesized(stream, state) {
9891
10020
  stream.next(); // Must be '('
9892
- if (!stream.match(/\s*[\"\')]/, false))
10021
+ if (!stream.match(/^\s*[\"\')]/, false))
9893
10022
  state.tokenize = tokenString(")");
9894
10023
  else
9895
10024
  state.tokenize = null;
@@ -9979,7 +10108,7 @@
9979
10108
  override = "property";
9980
10109
  return "maybeprop";
9981
10110
  } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
9982
- override = "string-2";
10111
+ override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
9983
10112
  return "maybeprop";
9984
10113
  } else if (allowNested) {
9985
10114
  override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
@@ -10073,7 +10202,7 @@
10073
10202
  else if (propertyKeywords.hasOwnProperty(word))
10074
10203
  override = "property";
10075
10204
  else if (nonStandardPropertyKeywords.hasOwnProperty(word))
10076
- override = "string-2";
10205
+ override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
10077
10206
  else if (valueKeywords.hasOwnProperty(word))
10078
10207
  override = "atom";
10079
10208
  else if (colorKeywords.hasOwnProperty(word))
@@ -10224,117 +10353,151 @@
10224
10353
  "monochrome", "min-monochrome", "max-monochrome", "resolution",
10225
10354
  "min-resolution", "max-resolution", "scan", "grid", "orientation",
10226
10355
  "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
10227
- "pointer", "any-pointer", "hover", "any-hover"
10356
+ "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme",
10357
+ "dynamic-range", "video-dynamic-range"
10228
10358
  ], mediaFeatures = keySet(mediaFeatures_);
10229
10359
 
10230
10360
  var mediaValueKeywords_ = [
10231
10361
  "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
10232
- "interlace", "progressive"
10362
+ "interlace", "progressive",
10363
+ "dark", "light",
10364
+ "standard", "high"
10233
10365
  ], mediaValueKeywords = keySet(mediaValueKeywords_);
10234
10366
 
10235
10367
  var propertyKeywords_ = [
10236
10368
  "align-content", "align-items", "align-self", "alignment-adjust",
10237
- "alignment-baseline", "anchor-point", "animation", "animation-delay",
10369
+ "alignment-baseline", "all", "anchor-point", "animation", "animation-delay",
10238
10370
  "animation-direction", "animation-duration", "animation-fill-mode",
10239
10371
  "animation-iteration-count", "animation-name", "animation-play-state",
10240
- "animation-timing-function", "appearance", "azimuth", "backface-visibility",
10241
- "background", "background-attachment", "background-blend-mode", "background-clip",
10242
- "background-color", "background-image", "background-origin", "background-position",
10243
- "background-repeat", "background-size", "baseline-shift", "binding",
10244
- "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
10245
- "bookmark-target", "border", "border-bottom", "border-bottom-color",
10246
- "border-bottom-left-radius", "border-bottom-right-radius",
10247
- "border-bottom-style", "border-bottom-width", "border-collapse",
10248
- "border-color", "border-image", "border-image-outset",
10372
+ "animation-timing-function", "appearance", "azimuth", "backdrop-filter",
10373
+ "backface-visibility", "background", "background-attachment",
10374
+ "background-blend-mode", "background-clip", "background-color",
10375
+ "background-image", "background-origin", "background-position",
10376
+ "background-position-x", "background-position-y", "background-repeat",
10377
+ "background-size", "baseline-shift", "binding", "bleed", "block-size",
10378
+ "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target",
10379
+ "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius",
10380
+ "border-bottom-right-radius", "border-bottom-style", "border-bottom-width",
10381
+ "border-collapse", "border-color", "border-image", "border-image-outset",
10249
10382
  "border-image-repeat", "border-image-slice", "border-image-source",
10250
- "border-image-width", "border-left", "border-left-color",
10251
- "border-left-style", "border-left-width", "border-radius", "border-right",
10252
- "border-right-color", "border-right-style", "border-right-width",
10253
- "border-spacing", "border-style", "border-top", "border-top-color",
10254
- "border-top-left-radius", "border-top-right-radius", "border-top-style",
10255
- "border-top-width", "border-width", "bottom", "box-decoration-break",
10256
- "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
10257
- "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
10258
- "column-fill", "column-gap", "column-rule", "column-rule-color",
10259
- "column-rule-style", "column-rule-width", "column-span", "column-width",
10260
- "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
10261
- "cue-after", "cue-before", "cursor", "direction", "display",
10262
- "dominant-baseline", "drop-initial-after-adjust",
10263
- "drop-initial-after-align", "drop-initial-before-adjust",
10264
- "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
10265
- "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
10266
- "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
10267
- "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
10268
- "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
10269
- "font-stretch", "font-style", "font-synthesis", "font-variant",
10270
- "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
10271
- "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
10272
- "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
10273
- "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
10274
- "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
10275
- "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
10276
- "grid-template-rows", "hanging-punctuation", "height", "hyphens",
10277
- "icon", "image-orientation", "image-rendering", "image-resolution",
10278
- "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
10279
- "line-break", "line-height", "line-stacking", "line-stacking-ruby",
10383
+ "border-image-width", "border-left", "border-left-color", "border-left-style",
10384
+ "border-left-width", "border-radius", "border-right", "border-right-color",
10385
+ "border-right-style", "border-right-width", "border-spacing", "border-style",
10386
+ "border-top", "border-top-color", "border-top-left-radius",
10387
+ "border-top-right-radius", "border-top-style", "border-top-width",
10388
+ "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing",
10389
+ "break-after", "break-before", "break-inside", "caption-side", "caret-color",
10390
+ "clear", "clip", "color", "color-profile", "column-count", "column-fill",
10391
+ "column-gap", "column-rule", "column-rule-color", "column-rule-style",
10392
+ "column-rule-width", "column-span", "column-width", "columns", "contain",
10393
+ "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after",
10394
+ "cue-before", "cursor", "direction", "display", "dominant-baseline",
10395
+ "drop-initial-after-adjust", "drop-initial-after-align",
10396
+ "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size",
10397
+ "drop-initial-value", "elevation", "empty-cells", "fit", "fit-content", "fit-position",
10398
+ "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow",
10399
+ "flex-shrink", "flex-wrap", "float", "float-offset", "flow-from", "flow-into",
10400
+ "font", "font-family", "font-feature-settings", "font-kerning",
10401
+ "font-language-override", "font-optical-sizing", "font-size",
10402
+ "font-size-adjust", "font-stretch", "font-style", "font-synthesis",
10403
+ "font-variant", "font-variant-alternates", "font-variant-caps",
10404
+ "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric",
10405
+ "font-variant-position", "font-variation-settings", "font-weight", "gap",
10406
+ "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows",
10407
+ "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start",
10408
+ "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "grid-row-start",
10409
+ "grid-template", "grid-template-areas", "grid-template-columns",
10410
+ "grid-template-rows", "hanging-punctuation", "height", "hyphens", "icon",
10411
+ "image-orientation", "image-rendering", "image-resolution", "inline-box-align",
10412
+ "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline",
10413
+ "inset-inline-end", "inset-inline-start", "isolation", "justify-content",
10414
+ "justify-items", "justify-self", "left", "letter-spacing", "line-break",
10415
+ "line-height", "line-height-step", "line-stacking", "line-stacking-ruby",
10280
10416
  "line-stacking-shift", "line-stacking-strategy", "list-style",
10281
10417
  "list-style-image", "list-style-position", "list-style-type", "margin",
10282
- "margin-bottom", "margin-left", "margin-right", "margin-top",
10283
- "marks", "marquee-direction", "marquee-loop",
10284
- "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
10285
- "max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
10286
- "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
10287
- "opacity", "order", "orphans", "outline",
10288
- "outline-color", "outline-offset", "outline-style", "outline-width",
10289
- "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
10290
- "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
10291
- "page", "page-break-after", "page-break-before", "page-break-inside",
10292
- "page-policy", "pause", "pause-after", "pause-before", "perspective",
10293
- "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
10294
- "presentation-level", "punctuation-trim", "quotes", "region-break-after",
10295
- "region-break-before", "region-break-inside", "region-fragment",
10296
- "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
10297
- "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
10298
- "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
10299
- "shape-outside", "size", "speak", "speak-as", "speak-header",
10300
- "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
10301
- "tab-size", "table-layout", "target", "target-name", "target-new",
10302
- "target-position", "text-align", "text-align-last", "text-decoration",
10418
+ "margin-bottom", "margin-left", "margin-right", "margin-top", "marks",
10419
+ "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed",
10420
+ "marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode",
10421
+ "mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type",
10422
+ "max-block-size", "max-height", "max-inline-size",
10423
+ "max-width", "min-block-size", "min-height", "min-inline-size", "min-width",
10424
+ "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right",
10425
+ "nav-up", "object-fit", "object-position", "offset", "offset-anchor",
10426
+ "offset-distance", "offset-path", "offset-position", "offset-rotate",
10427
+ "opacity", "order", "orphans", "outline", "outline-color", "outline-offset",
10428
+ "outline-style", "outline-width", "overflow", "overflow-style",
10429
+ "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom",
10430
+ "padding-left", "padding-right", "padding-top", "page", "page-break-after",
10431
+ "page-break-before", "page-break-inside", "page-policy", "pause",
10432
+ "pause-after", "pause-before", "perspective", "perspective-origin", "pitch",
10433
+ "pitch-range", "place-content", "place-items", "place-self", "play-during",
10434
+ "position", "presentation-level", "punctuation-trim", "quotes",
10435
+ "region-break-after", "region-break-before", "region-break-inside",
10436
+ "region-fragment", "rendering-intent", "resize", "rest", "rest-after",
10437
+ "rest-before", "richness", "right", "rotate", "rotation", "rotation-point",
10438
+ "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span",
10439
+ "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block",
10440
+ "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom",
10441
+ "scroll-margin-inline", "scroll-margin-inline-end",
10442
+ "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right",
10443
+ "scroll-margin-top", "scroll-padding", "scroll-padding-block",
10444
+ "scroll-padding-block-end", "scroll-padding-block-start",
10445
+ "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end",
10446
+ "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right",
10447
+ "scroll-padding-top", "scroll-snap-align", "scroll-snap-type",
10448
+ "shape-image-threshold", "shape-inside", "shape-margin", "shape-outside",
10449
+ "size", "speak", "speak-as", "speak-header", "speak-numeral",
10450
+ "speak-punctuation", "speech-rate", "stress", "string-set", "tab-size",
10451
+ "table-layout", "target", "target-name", "target-new", "target-position",
10452
+ "text-align", "text-align-last", "text-combine-upright", "text-decoration",
10303
10453
  "text-decoration-color", "text-decoration-line", "text-decoration-skip",
10304
- "text-decoration-style", "text-emphasis", "text-emphasis-color",
10305
- "text-emphasis-position", "text-emphasis-style", "text-height",
10306
- "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
10307
- "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
10308
- "text-wrap", "top", "transform", "transform-origin", "transform-style",
10309
- "transition", "transition-delay", "transition-duration",
10310
- "transition-property", "transition-timing-function", "unicode-bidi",
10311
- "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
10312
- "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
10313
- "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
10314
- "word-spacing", "word-wrap", "z-index",
10454
+ "text-decoration-skip-ink", "text-decoration-style", "text-emphasis",
10455
+ "text-emphasis-color", "text-emphasis-position", "text-emphasis-style",
10456
+ "text-height", "text-indent", "text-justify", "text-orientation",
10457
+ "text-outline", "text-overflow", "text-rendering", "text-shadow",
10458
+ "text-size-adjust", "text-space-collapse", "text-transform",
10459
+ "text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin",
10460
+ "transform-style", "transition", "transition-delay", "transition-duration",
10461
+ "transition-property", "transition-timing-function", "translate",
10462
+ "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance",
10463
+ "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate",
10464
+ "voice-stress", "voice-volume", "volume", "white-space", "widows", "width",
10465
+ "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index",
10315
10466
  // SVG-specific
10316
10467
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
10317
10468
  "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
10318
10469
  "color-interpolation", "color-interpolation-filters",
10319
10470
  "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
10320
- "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
10471
+ "marker", "marker-end", "marker-mid", "marker-start", "paint-order", "shape-rendering", "stroke",
10321
10472
  "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
10322
10473
  "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
10323
10474
  "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
10324
- "glyph-orientation-vertical", "text-anchor", "writing-mode"
10475
+ "glyph-orientation-vertical", "text-anchor", "writing-mode",
10325
10476
  ], propertyKeywords = keySet(propertyKeywords_);
10326
10477
 
10327
10478
  var nonStandardPropertyKeywords_ = [
10479
+ "accent-color", "aspect-ratio", "border-block", "border-block-color", "border-block-end",
10480
+ "border-block-end-color", "border-block-end-style", "border-block-end-width",
10481
+ "border-block-start", "border-block-start-color", "border-block-start-style",
10482
+ "border-block-start-width", "border-block-style", "border-block-width",
10483
+ "border-inline", "border-inline-color", "border-inline-end",
10484
+ "border-inline-end-color", "border-inline-end-style",
10485
+ "border-inline-end-width", "border-inline-start", "border-inline-start-color",
10486
+ "border-inline-start-style", "border-inline-start-width",
10487
+ "border-inline-style", "border-inline-width", "content-visibility", "margin-block",
10488
+ "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end",
10489
+ "margin-inline-start", "overflow-anchor", "overscroll-behavior", "padding-block", "padding-block-end",
10490
+ "padding-block-start", "padding-inline", "padding-inline-end",
10491
+ "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color",
10328
10492
  "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
10329
10493
  "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
10330
- "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
10331
- "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
10332
- "searchfield-results-decoration", "zoom"
10494
+ "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration",
10495
+ "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom"
10333
10496
  ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
10334
10497
 
10335
10498
  var fontProperties_ = [
10336
- "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
10337
- "font-stretch", "font-weight", "font-style"
10499
+ "font-display", "font-family", "src", "unicode-range", "font-variant",
10500
+ "font-feature-settings", "font-stretch", "font-weight", "font-style"
10338
10501
  ], fontProperties = keySet(fontProperties_);
10339
10502
 
10340
10503
  var counterDescriptors_ = [
@@ -10347,16 +10510,16 @@
10347
10510
  "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
10348
10511
  "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
10349
10512
  "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
10350
- "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
10513
+ "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen",
10351
10514
  "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
10352
- "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
10353
- "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
10515
+ "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet",
10516
+ "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick",
10354
10517
  "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
10355
10518
  "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
10356
10519
  "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
10357
10520
  "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
10358
- "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
10359
- "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
10521
+ "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
10522
+ "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
10360
10523
  "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
10361
10524
  "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
10362
10525
  "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
@@ -10366,7 +10529,7 @@
10366
10529
  "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
10367
10530
  "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
10368
10531
  "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
10369
- "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
10532
+ "slateblue", "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan",
10370
10533
  "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
10371
10534
  "whitesmoke", "yellow", "yellowgreen"
10372
10535
  ], colorKeywords = keySet(colorKeywords_);
@@ -10376,22 +10539,22 @@
10376
10539
  "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
10377
10540
  "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
10378
10541
  "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
10379
- "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
10380
- "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
10381
- "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
10542
+ "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary",
10543
+ "bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box",
10544
+ "both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", "button-bevel",
10382
10545
  "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
10383
10546
  "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
10384
10547
  "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
10385
10548
  "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
10386
10549
  "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
10387
10550
  "compact", "condensed", "contain", "content", "contents",
10388
- "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
10389
- "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
10551
+ "content-box", "context-menu", "continuous", "contrast", "copy", "counter", "counters", "cover", "crop",
10552
+ "cross", "crosshair", "cubic-bezier", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
10390
10553
  "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
10391
10554
  "destination-in", "destination-out", "destination-over", "devanagari", "difference",
10392
10555
  "disc", "discard", "disclosure-closed", "disclosure-open", "document",
10393
10556
  "dot-dash", "dot-dot-dash",
10394
- "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
10557
+ "dotted", "double", "down", "drop-shadow", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
10395
10558
  "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
10396
10559
  "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
10397
10560
  "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
@@ -10400,11 +10563,11 @@
10400
10563
  "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
10401
10564
  "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
10402
10565
  "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
10403
- "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
10404
- "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
10566
+ "extra-expanded", "fantasy", "fast", "fill", "fill-box", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
10567
+ "forwards", "from", "geometricPrecision", "georgian", "grayscale", "graytext", "grid", "groove",
10405
10568
  "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
10406
10569
  "help", "hidden", "hide", "higher", "highlight", "highlighttext",
10407
- "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
10570
+ "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "hue-rotate", "icon", "ignore",
10408
10571
  "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
10409
10572
  "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
10410
10573
  "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
@@ -10415,7 +10578,7 @@
10415
10578
  "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
10416
10579
  "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
10417
10580
  "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
10418
- "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
10581
+ "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d",
10419
10582
  "media-controls-background", "media-current-time-display",
10420
10583
  "media-fullscreen-button", "media-mute-button", "media-play-button",
10421
10584
  "media-return-to-realtime-button", "media-rewind-button",
@@ -10424,13 +10587,13 @@
10424
10587
  "media-volume-slider-container", "media-volume-sliderthumb", "medium",
10425
10588
  "menu", "menulist", "menulist-button", "menulist-text",
10426
10589
  "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
10427
- "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
10590
+ "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize",
10428
10591
  "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
10429
10592
  "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
10430
10593
  "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
10431
10594
  "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
10432
10595
  "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
10433
- "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
10596
+ "painted", "page", "paused", "persian", "perspective", "pinch-zoom", "plus-darker", "plus-lighter",
10434
10597
  "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
10435
10598
  "progress", "push-button", "radial-gradient", "radio", "read-only",
10436
10599
  "read-write", "read-write-plaintext-only", "rectangle", "region",
@@ -10438,18 +10601,18 @@
10438
10601
  "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
10439
10602
  "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
10440
10603
  "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
10441
- "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
10604
+ "s-resize", "sans-serif", "saturate", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
10442
10605
  "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
10443
10606
  "searchfield-cancel-button", "searchfield-decoration",
10444
10607
  "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
10445
- "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
10608
+ "semi-condensed", "semi-expanded", "separate", "sepia", "serif", "show", "sidama",
10446
10609
  "simp-chinese-formal", "simp-chinese-informal", "single",
10447
10610
  "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
10448
10611
  "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
10449
10612
  "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
10450
10613
  "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
10451
- "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
10452
- "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
10614
+ "square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub",
10615
+ "subpixel-antialiased", "svg_masks", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
10453
10616
  "table-caption", "table-cell", "table-column", "table-column-group",
10454
10617
  "table-footer-group", "table-header-group", "table-row", "table-row-group",
10455
10618
  "tamil",
@@ -10459,10 +10622,10 @@
10459
10622
  "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
10460
10623
  "trad-chinese-formal", "trad-chinese-informal", "transform",
10461
10624
  "translate", "translate3d", "translateX", "translateY", "translateZ",
10462
- "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
10625
+ "transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up",
10463
10626
  "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
10464
10627
  "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
10465
- "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
10628
+ "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", "visiblePainted",
10466
10629
  "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
10467
10630
  "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
10468
10631
  "xx-large", "xx-small"
@@ -10530,7 +10693,7 @@
10530
10693
  }
10531
10694
  },
10532
10695
  ":": function(stream) {
10533
- if (stream.match(/\s*\{/, false))
10696
+ if (stream.match(/^\s*\{/, false))
10534
10697
  return [null, null]
10535
10698
  return false;
10536
10699
  },
@@ -11000,9 +11163,13 @@
11000
11163
  };
11001
11164
  }
11002
11165
 
11166
+ function lower(tagName) {
11167
+ return tagName && tagName.toLowerCase();
11168
+ }
11169
+
11003
11170
  function Context(state, tagName, startOfLine) {
11004
11171
  this.prev = state.context;
11005
- this.tagName = tagName;
11172
+ this.tagName = tagName || "";
11006
11173
  this.indent = state.indented;
11007
11174
  this.startOfLine = startOfLine;
11008
11175
  if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
@@ -11018,8 +11185,8 @@
11018
11185
  return;
11019
11186
  }
11020
11187
  parentTagName = state.context.tagName;
11021
- if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
11022
- !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
11188
+ if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) ||
11189
+ !config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) {
11023
11190
  return;
11024
11191
  }
11025
11192
  popContext(state);
@@ -11053,7 +11220,7 @@
11053
11220
  if (type == "word") {
11054
11221
  var tagName = stream.current();
11055
11222
  if (state.context && state.context.tagName != tagName &&
11056
- config.implicitlyClosed.hasOwnProperty(state.context.tagName))
11223
+ config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName)))
11057
11224
  popContext(state);
11058
11225
  if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
11059
11226
  setStyle = "tag";
@@ -11092,7 +11259,7 @@
11092
11259
  var tagName = state.tagName, tagStart = state.tagStart;
11093
11260
  state.tagName = state.tagStart = null;
11094
11261
  if (type == "selfcloseTag" ||
11095
- config.autoSelfClosers.hasOwnProperty(tagName)) {
11262
+ config.autoSelfClosers.hasOwnProperty(lower(tagName))) {
11096
11263
  maybePopContext(state, tagName);
11097
11264
  } else {
11098
11265
  maybePopContext(state, tagName);
@@ -11172,7 +11339,7 @@
11172
11339
  if (context.tagName == tagAfter[2]) {
11173
11340
  context = context.prev;
11174
11341
  break;
11175
- } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
11342
+ } else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) {
11176
11343
  context = context.prev;
11177
11344
  } else {
11178
11345
  break;
@@ -11180,8 +11347,8 @@
11180
11347
  }
11181
11348
  } else if (tagAfter) { // Opening tag spotted
11182
11349
  while (context) {
11183
- var grabbers = config.contextGrabbers[context.tagName];
11184
- if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
11350
+ var grabbers = config.contextGrabbers[lower(context.tagName)];
11351
+ if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2])))
11185
11352
  context = context.prev;
11186
11353
  else
11187
11354
  break;
@@ -11212,7 +11379,7 @@
11212
11379
  xmlCurrentContext: function(state) {
11213
11380
  var context = [];
11214
11381
  for (var cx = state.context; cx; cx = cx.prev)
11215
- if (cx.tagName) context.push(cx.tagName);
11382
+ context.push(cx.tagName);
11216
11383
  return context.reverse()
11217
11384
  }
11218
11385
  };
@@ -11242,12 +11409,12 @@
11242
11409
  {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
11243
11410
  {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
11244
11411
  {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
11245
- {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
11412
+ {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy", "cbl"]},
11246
11413
  {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]},
11247
11414
  {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
11248
11415
  {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
11249
11416
  {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
11250
- {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
11417
+ {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/},
11251
11418
  {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
11252
11419
  {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
11253
11420
  {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
@@ -11267,7 +11434,7 @@
11267
11434
  {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
11268
11435
  {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
11269
11436
  {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
11270
- {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
11437
+ {name: "Embedded JavaScript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
11271
11438
  {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
11272
11439
  {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
11273
11440
  {name: "Esper", mime: "text/x-esper", mode: "sql"},
@@ -11278,7 +11445,7 @@
11278
11445
  {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
11279
11446
  {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
11280
11447
  {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
11281
- {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
11448
+ {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i},
11282
11449
  {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
11283
11450
  {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
11284
11451
  {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
@@ -11299,7 +11466,7 @@
11299
11466
  {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
11300
11467
  {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
11301
11468
  {name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]},
11302
- {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
11469
+ {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"], alias: ["jl"]},
11303
11470
  {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
11304
11471
  {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
11305
11472
  {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
@@ -11367,7 +11534,7 @@
11367
11534
  {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
11368
11535
  {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
11369
11536
  {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
11370
- {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
11537
+ {name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
11371
11538
  {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
11372
11539
  {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
11373
11540
  {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
@@ -11392,7 +11559,8 @@
11392
11559
  {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
11393
11560
  {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
11394
11561
  {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
11395
- {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
11562
+ {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]},
11563
+ {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]},
11396
11564
  ];
11397
11565
  // Ensure all modes have a mime property for backwards compatibility
11398
11566
  for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
@@ -11488,6 +11656,9 @@
11488
11656
  if (modeCfg.fencedCodeBlockHighlighting === undefined)
11489
11657
  modeCfg.fencedCodeBlockHighlighting = true;
11490
11658
 
11659
+ if (modeCfg.fencedCodeBlockDefaultMode === undefined)
11660
+ modeCfg.fencedCodeBlockDefaultMode = 'text/plain';
11661
+
11491
11662
  if (modeCfg.xml === undefined)
11492
11663
  modeCfg.xml = true;
11493
11664
 
@@ -11527,9 +11698,9 @@
11527
11698
  , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/
11528
11699
  , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE
11529
11700
  , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
11530
- , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
11701
+ , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/
11531
11702
  , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/
11532
- , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/
11703
+ , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/
11533
11704
  , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition
11534
11705
  , 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]/
11535
11706
  , expandedTab = " "; // CommonMark specifies tab as 4 spaces
@@ -11660,7 +11831,7 @@
11660
11831
 
11661
11832
  // Add this list item's content's indentation to the stack
11662
11833
  state.listStack.push(state.indentation);
11663
- // Reset inline styles which shouldn't propagate aross list items
11834
+ // Reset inline styles which shouldn't propagate across list items
11664
11835
  state.em = false;
11665
11836
  state.strong = false;
11666
11837
  state.code = false;
@@ -11676,7 +11847,7 @@
11676
11847
  state.quote = 0;
11677
11848
  state.fencedEndRE = new RegExp(match[1] + "+ *$");
11678
11849
  // try switching mode
11679
- state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]);
11850
+ state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode );
11680
11851
  if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
11681
11852
  state.f = state.block = local;
11682
11853
  if (modeCfg.highlightFormatting) state.formatting = "code-block";
@@ -12049,7 +12220,7 @@
12049
12220
  return getType(state);
12050
12221
  }
12051
12222
  } else if (ch === ' ') {
12052
- if (stream.match(/^~~/, true)) { // Probably surrounded by space
12223
+ if (stream.match('~~', true)) { // Probably surrounded by space
12053
12224
  if (stream.peek() === ' ') { // Surrounded by spaces, ignore
12054
12225
  return getType(state);
12055
12226
  } else { // Not surrounded by spaces, back up pointer
@@ -12148,7 +12319,7 @@
12148
12319
  }
12149
12320
 
12150
12321
  function footnoteLinkInside(stream, state) {
12151
- if (stream.match(/^\]:/, true)) {
12322
+ if (stream.match(']:', true)) {
12152
12323
  state.f = state.inline = footnoteUrl;
12153
12324
  if (modeCfg.highlightFormatting) state.formatting = "link";
12154
12325
  var returnType = getType(state);
@@ -12172,7 +12343,7 @@
12172
12343
  if (stream.peek() === undefined) { // End of line, set flag to check next line
12173
12344
  state.linkTitle = true;
12174
12345
  } else { // More content on line, check if link title
12175
- stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
12346
+ stream.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, true);
12176
12347
  }
12177
12348
  state.f = state.inline = inlineNormal;
12178
12349
  return tokenTypes.linkHref + " url";
@@ -12549,6 +12720,7 @@
12549
12720
  var statementIndent = parserConfig.statementIndent;
12550
12721
  var jsonldMode = parserConfig.jsonld;
12551
12722
  var jsonMode = parserConfig.json || jsonldMode;
12723
+ var trackScope = parserConfig.trackScope !== false;
12552
12724
  var isTS = parserConfig.typescript;
12553
12725
  var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
12554
12726
 
@@ -12631,21 +12803,25 @@
12631
12803
  } else if (ch == "`") {
12632
12804
  state.tokenize = tokenQuasi;
12633
12805
  return tokenQuasi(stream, state);
12634
- } else if (ch == "#") {
12806
+ } else if (ch == "#" && stream.peek() == "!") {
12635
12807
  stream.skipToEnd();
12636
- return ret("error", "error");
12637
- } else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) {
12808
+ return ret("meta", "meta");
12809
+ } else if (ch == "#" && stream.eatWhile(wordRE)) {
12810
+ return ret("variable", "property")
12811
+ } else if (ch == "<" && stream.match("!--") ||
12812
+ (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
12638
12813
  stream.skipToEnd();
12639
12814
  return ret("comment", "comment")
12640
12815
  } else if (isOperatorChar.test(ch)) {
12641
12816
  if (ch != ">" || !state.lexical || state.lexical.type != ">") {
12642
12817
  if (stream.eat("=")) {
12643
12818
  if (ch == "!" || ch == "=") stream.eat("=");
12644
- } else if (/[<>*+\-]/.test(ch)) {
12819
+ } else if (/[<>*+\-|&?]/.test(ch)) {
12645
12820
  stream.eat(ch);
12646
12821
  if (ch == ">") stream.eat(ch);
12647
12822
  }
12648
12823
  }
12824
+ if (ch == "?" && stream.eat(".")) return ret(".")
12649
12825
  return ret("operator", "operator", stream.current());
12650
12826
  } else if (wordRE.test(ch)) {
12651
12827
  stream.eatWhile(wordRE);
@@ -12655,7 +12831,7 @@
12655
12831
  var kw = keywords[word];
12656
12832
  return ret(kw.type, kw.style, word)
12657
12833
  }
12658
- if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
12834
+ if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
12659
12835
  return ret("async", "keyword", word)
12660
12836
  }
12661
12837
  return ret("variable", "variable", word)
@@ -12747,7 +12923,8 @@
12747
12923
 
12748
12924
  // Parser
12749
12925
 
12750
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
12926
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
12927
+ "regexp": true, "this": true, "import": true, "jsonld-keyword": true};
12751
12928
 
12752
12929
  function JSLexical(indented, column, type, align, prev, info) {
12753
12930
  this.indented = indented;
@@ -12759,6 +12936,7 @@
12759
12936
  }
12760
12937
 
12761
12938
  function inScope(state, varname) {
12939
+ if (!trackScope) return false
12762
12940
  for (var v = state.localVars; v; v = v.next)
12763
12941
  if (v.name == varname) return true;
12764
12942
  for (var cx = state.context; cx; cx = cx.prev) {
@@ -12805,6 +12983,7 @@
12805
12983
  function register(varname) {
12806
12984
  var state = cx.state;
12807
12985
  cx.marked = "def";
12986
+ if (!trackScope) return
12808
12987
  if (state.context) {
12809
12988
  if (state.lexical.info == "var" && state.context && state.context.block) {
12810
12989
  // FIXME function decls are also not block scoped
@@ -12903,7 +13082,7 @@
12903
13082
  return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
12904
13083
  }
12905
13084
  if (type == "function") return cont(functiondef);
12906
- if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
13085
+ if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
12907
13086
  if (type == "class" || (isTS && value == "interface")) {
12908
13087
  cx.marked = "keyword";
12909
13088
  return cont(pushlex("form", type == "class" ? type : value), className, poplex)
@@ -12949,7 +13128,7 @@
12949
13128
  }
12950
13129
  function parenExpr(type) {
12951
13130
  if (type != "(") return pass()
12952
- return cont(pushlex(")"), expression, expect(")"), poplex)
13131
+ return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
12953
13132
  }
12954
13133
  function expressionInner(type, value, noComma) {
12955
13134
  if (cx.state.fatArrowAt == cx.stream.start) {
@@ -12969,7 +13148,6 @@
12969
13148
  if (type == "{") return contCommasep(objprop, "}", null, maybeop);
12970
13149
  if (type == "quasi") return pass(quasi, maybeop);
12971
13150
  if (type == "new") return cont(maybeTarget(noComma));
12972
- if (type == "import") return cont(expression);
12973
13151
  return cont();
12974
13152
  }
12975
13153
  function maybeexpression(type) {
@@ -12978,7 +13156,7 @@
12978
13156
  }
12979
13157
 
12980
13158
  function maybeoperatorComma(type, value) {
12981
- if (type == ",") return cont(expression);
13159
+ if (type == ",") return cont(maybeexpression);
12982
13160
  return maybeoperatorNoComma(type, value, false);
12983
13161
  }
12984
13162
  function maybeoperatorNoComma(type, value, noComma) {
@@ -12987,7 +13165,7 @@
12987
13165
  if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
12988
13166
  if (type == "operator") {
12989
13167
  if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
12990
- if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
13168
+ if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
12991
13169
  return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
12992
13170
  if (value == "?") return cont(expression, expect(":"), expr);
12993
13171
  return cont(expr);
@@ -13007,7 +13185,7 @@
13007
13185
  function quasi(type, value) {
13008
13186
  if (type != "quasi") return pass();
13009
13187
  if (value.slice(value.length - 2) != "${") return cont(quasi);
13010
- return cont(expression, continueQuasi);
13188
+ return cont(maybeexpression, continueQuasi);
13011
13189
  }
13012
13190
  function continueQuasi(type) {
13013
13191
  if (type == "}") {
@@ -13133,7 +13311,7 @@
13133
13311
  }
13134
13312
  }
13135
13313
  function typeexpr(type, value) {
13136
- if (value == "keyof" || value == "typeof" || value == "infer") {
13314
+ if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
13137
13315
  cx.marked = "keyword";
13138
13316
  return cont(value == "typeof" ? expressionNoComma : typeexpr)
13139
13317
  }
@@ -13144,13 +13322,19 @@
13144
13322
  if (value == "|" || value == "&") return cont(typeexpr)
13145
13323
  if (type == "string" || type == "number" || type == "atom") return cont(afterType);
13146
13324
  if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
13147
- if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
13325
+ if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
13148
13326
  if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
13149
13327
  if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
13328
+ if (type == "quasi") { return pass(quasiType, afterType); }
13150
13329
  }
13151
13330
  function maybeReturnType(type) {
13152
13331
  if (type == "=>") return cont(typeexpr)
13153
13332
  }
13333
+ function typeprops(type) {
13334
+ if (type.match(/[\}\)\]]/)) return cont()
13335
+ if (type == "," || type == ";") return cont(typeprops)
13336
+ return pass(typeprop, typeprops)
13337
+ }
13154
13338
  function typeprop(type, value) {
13155
13339
  if (type == "variable" || cx.style == "keyword") {
13156
13340
  cx.marked = "property";
@@ -13163,6 +13347,20 @@
13163
13347
  return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
13164
13348
  } else if (type == "(") {
13165
13349
  return pass(functiondecl, typeprop)
13350
+ } else if (!type.match(/[;\}\)\],]/)) {
13351
+ return cont()
13352
+ }
13353
+ }
13354
+ function quasiType(type, value) {
13355
+ if (type != "quasi") return pass();
13356
+ if (value.slice(value.length - 2) != "${") return cont(quasiType);
13357
+ return cont(typeexpr, continueQuasiType);
13358
+ }
13359
+ function continueQuasiType(type) {
13360
+ if (type == "}") {
13361
+ cx.marked = "string-2";
13362
+ cx.state.tokenize = tokenQuasi;
13363
+ return cont(quasiType);
13166
13364
  }
13167
13365
  }
13168
13366
  function typearg(type, value) {
@@ -13289,11 +13487,11 @@
13289
13487
  }
13290
13488
  if (type == "variable" || cx.style == "keyword") {
13291
13489
  cx.marked = "property";
13292
- return cont(isTS ? classfield : functiondef, classBody);
13490
+ return cont(classfield, classBody);
13293
13491
  }
13294
- if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody);
13492
+ if (type == "number" || type == "string") return cont(classfield, classBody);
13295
13493
  if (type == "[")
13296
- return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
13494
+ return cont(expression, maybetype, expect("]"), classfield, classBody)
13297
13495
  if (value == "*") {
13298
13496
  cx.marked = "keyword";
13299
13497
  return cont(classBody);
@@ -13304,6 +13502,7 @@
13304
13502
  if (value == "@") return cont(expression, classBody)
13305
13503
  }
13306
13504
  function classfield(type, value) {
13505
+ if (value == "!") return cont(classfield)
13307
13506
  if (value == "?") return cont(classfield)
13308
13507
  if (type == ":") return cont(typeexpr, maybeAssign)
13309
13508
  if (value == "=") return cont(expressionNoComma)
@@ -13323,6 +13522,7 @@
13323
13522
  function afterImport(type) {
13324
13523
  if (type == "string") return cont();
13325
13524
  if (type == "(") return pass(expression);
13525
+ if (type == ".") return pass(maybeoperatorComma);
13326
13526
  return pass(importSpec, maybeMoreImports, maybeFrom);
13327
13527
  }
13328
13528
  function importSpec(type, value) {
@@ -13396,14 +13596,14 @@
13396
13596
  },
13397
13597
 
13398
13598
  indent: function(state, textAfter) {
13399
- if (state.tokenize == tokenComment) return CodeMirror.Pass;
13599
+ if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
13400
13600
  if (state.tokenize != tokenBase) return 0;
13401
13601
  var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
13402
13602
  // Kludge to prevent 'maybelse' from blocking lexical scope pops
13403
13603
  if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
13404
13604
  var c = state.cc[i];
13405
13605
  if (c == poplex) lexical = lexical.prev;
13406
- else if (c != maybeelse) break;
13606
+ else if (c != maybeelse && c != popcontext) break;
13407
13607
  }
13408
13608
  while ((lexical.type == "stat" || lexical.type == "form") &&
13409
13609
  (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
@@ -13440,8 +13640,7 @@
13440
13640
  expressionAllowed: expressionAllowed,
13441
13641
 
13442
13642
  skipExpression: function(state) {
13443
- var top = state.cc[state.cc.length - 1];
13444
- if (top == expression || top == expressionNoComma) state.cc.pop();
13643
+ parseJS(state, "atom", "atom", "true", new CodeMirror.StringStream("", 2, null));
13445
13644
  }
13446
13645
  };
13447
13646
  });
@@ -13453,9 +13652,10 @@
13453
13652
  CodeMirror.defineMIME("application/javascript", "javascript");
13454
13653
  CodeMirror.defineMIME("application/x-javascript", "javascript");
13455
13654
  CodeMirror.defineMIME("application/ecmascript", "javascript");
13456
- CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
13457
- CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
13458
- CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
13655
+ CodeMirror.defineMIME("application/json", { name: "javascript", json: true });
13656
+ CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true });
13657
+ CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true });
13658
+ CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true });
13459
13659
  CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
13460
13660
  CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
13461
13661
 
@@ -13533,7 +13733,8 @@
13533
13733
  name: "xml",
13534
13734
  htmlMode: true,
13535
13735
  multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
13536
- multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
13736
+ multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
13737
+ allowMissingTagName: parserConfig.allowMissingTagName,
13537
13738
  });
13538
13739
 
13539
13740
  var tags = {};
@@ -14588,7 +14789,7 @@
14588
14789
  }
14589
14790
  }
14590
14791
 
14591
- 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}";
14792
+ 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}";
14592
14793
  styleInject(css_248z);
14593
14794
 
14594
14795
  var braceFold = createCommonjsModule(function (module, exports) {
@@ -14601,9 +14802,9 @@
14601
14802
 
14602
14803
  CodeMirror.registerHelper("fold", "brace", function(cm, start) {
14603
14804
  var line = start.line, lineText = cm.getLine(line);
14604
- var tokenType;
14605
14805
 
14606
14806
  function findOpening(openCh) {
14807
+ var tokenType;
14607
14808
  for (var at = start.ch, pass = 0;;) {
14608
14809
  var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
14609
14810
  if (found == -1) {
@@ -14614,37 +14815,42 @@
14614
14815
  }
14615
14816
  if (pass == 1 && found < start.ch) break;
14616
14817
  tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
14617
- if (!/^(comment|string)/.test(tokenType)) return found + 1;
14818
+ if (!/^(comment|string)/.test(tokenType)) return {ch: found + 1, tokenType: tokenType};
14618
14819
  at = found - 1;
14619
14820
  }
14620
14821
  }
14621
14822
 
14622
- var startToken = "{", endToken = "}", startCh = findOpening("{");
14623
- if (startCh == null) {
14624
- startToken = "[", endToken = "]";
14625
- startCh = findOpening("[");
14626
- }
14627
-
14628
- if (startCh == null) return;
14629
- var count = 1, lastLine = cm.lastLine(), end, endCh;
14630
- outer: for (var i = line; i <= lastLine; ++i) {
14631
- var text = cm.getLine(i), pos = i == line ? startCh : 0;
14632
- for (;;) {
14633
- var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
14634
- if (nextOpen < 0) nextOpen = text.length;
14635
- if (nextClose < 0) nextClose = text.length;
14636
- pos = Math.min(nextOpen, nextClose);
14637
- if (pos == text.length) break;
14638
- if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
14639
- if (pos == nextOpen) ++count;
14640
- else if (!--count) { end = i; endCh = pos; break outer; }
14823
+ function findRange(startToken, endToken, found) {
14824
+ var count = 1, lastLine = cm.lastLine(), end, startCh = found.ch, endCh;
14825
+ outer: for (var i = line; i <= lastLine; ++i) {
14826
+ var text = cm.getLine(i), pos = i == line ? startCh : 0;
14827
+ for (;;) {
14828
+ var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
14829
+ if (nextOpen < 0) nextOpen = text.length;
14830
+ if (nextClose < 0) nextClose = text.length;
14831
+ pos = Math.min(nextOpen, nextClose);
14832
+ if (pos == text.length) break;
14833
+ if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == found.tokenType) {
14834
+ if (pos == nextOpen) ++count;
14835
+ else if (!--count) { end = i; endCh = pos; break outer; }
14836
+ }
14837
+ ++pos;
14641
14838
  }
14642
- ++pos;
14643
14839
  }
14840
+
14841
+ if (end == null || line == end) return null
14842
+ return {from: CodeMirror.Pos(line, startCh),
14843
+ to: CodeMirror.Pos(end, endCh)};
14844
+ }
14845
+
14846
+ var startBrace = findOpening("{"), startBracket = findOpening("[");
14847
+ if (startBrace && (!startBracket || startBracket.ch > startBrace.ch)) {
14848
+ return findRange("{", "}", startBrace) || (startBracket && findRange("[", "]", startBracket))
14849
+ } else if (startBracket) {
14850
+ return findRange("[", "]", startBracket) || (startBrace && findRange("{", "}", startBrace))
14851
+ } else {
14852
+ return null
14644
14853
  }
14645
- if (end == null || line == end) return;
14646
- return {from: CodeMirror.Pos(line, startCh),
14647
- to: CodeMirror.Pos(end, endCh)};
14648
14854
  });
14649
14855
 
14650
14856
  CodeMirror.registerHelper("fold", "import", function(cm, start) {
@@ -14770,9 +14976,11 @@
14770
14976
  function getRange(allowFolded) {
14771
14977
  var range = finder(cm, pos);
14772
14978
  if (!range || range.to.line - range.from.line < minSize) return null;
14979
+ if (force === "fold") return range;
14980
+
14773
14981
  var marks = cm.findMarksAt(range.from);
14774
14982
  for (var i = 0; i < marks.length; ++i) {
14775
- if (marks[i].__isFold && force !== "fold") {
14983
+ if (marks[i].__isFold) {
14776
14984
  if (!allowFolded) return null;
14777
14985
  range.cleared = true;
14778
14986
  marks[i].clear();
@@ -14845,18 +15053,18 @@
14845
15053
  cm.foldCode(cm.getCursor(), null, "fold");
14846
15054
  };
14847
15055
  CodeMirror.commands.unfold = function(cm) {
14848
- cm.foldCode(cm.getCursor(), null, "unfold");
15056
+ cm.foldCode(cm.getCursor(), { scanUp: false }, "unfold");
14849
15057
  };
14850
15058
  CodeMirror.commands.foldAll = function(cm) {
14851
15059
  cm.operation(function() {
14852
15060
  for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
14853
- cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
15061
+ cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "fold");
14854
15062
  });
14855
15063
  };
14856
15064
  CodeMirror.commands.unfoldAll = function(cm) {
14857
15065
  cm.operation(function() {
14858
15066
  for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
14859
- cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
15067
+ cm.foldCode(CodeMirror.Pos(i, 0), { scanUp: false }, "unfold");
14860
15068
  });
14861
15069
  };
14862
15070
 
@@ -15371,7 +15579,9 @@
15371
15579
  if (e.keyCode == 13) callback(inp.value, e);
15372
15580
  });
15373
15581
 
15374
- if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
15582
+ if (options.closeOnBlur !== false) CodeMirror.on(dialog, "focusout", function (evt) {
15583
+ if (evt.relatedTarget !== null) close();
15584
+ });
15375
15585
  } else if (button = dialog.getElementsByTagName("button")[0]) {
15376
15586
  CodeMirror.on(button, "click", function() {
15377
15587
  close();
@@ -15460,8 +15670,11 @@
15460
15670
  mod(codemirror, dialog);
15461
15671
  })(function(CodeMirror) {
15462
15672
 
15673
+ // default search panel location
15674
+ CodeMirror.defineOption("search", {bottom: false});
15675
+
15463
15676
  function dialog(cm, text, shortText, deflt, f) {
15464
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
15677
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom});
15465
15678
  else f(prompt(shortText, deflt));
15466
15679
  }
15467
15680
 
@@ -15696,6 +15909,7 @@
15696
15909
 
15697
15910
  function SearchCursor(doc, query, pos, options) {
15698
15911
  this.atOccurrence = false;
15912
+ this.afterEmptyMatch = false;
15699
15913
  this.doc = doc;
15700
15914
  pos = pos ? doc.clipPos(pos) : Pos(0, 0);
15701
15915
  this.pos = {from: pos, to: pos};
@@ -15731,21 +15945,29 @@
15731
15945
  findPrevious: function() {return this.find(true)},
15732
15946
 
15733
15947
  find: function(reverse) {
15734
- var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to));
15735
-
15736
- // Implements weird auto-growing behavior on null-matches for
15737
- // backwards-compatiblity with the vim code (unfortunately)
15738
- while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
15948
+ var head = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
15949
+ if (this.afterEmptyMatch && this.atOccurrence) {
15950
+ // do not return the same 0 width match twice
15951
+ head = Pos(head.line, head.ch);
15739
15952
  if (reverse) {
15740
- if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1);
15741
- else if (result.from.line == this.doc.firstLine()) result = null;
15742
- else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)));
15953
+ head.ch--;
15954
+ if (head.ch < 0) {
15955
+ head.line--;
15956
+ head.ch = (this.doc.getLine(head.line) || "").length;
15957
+ }
15743
15958
  } else {
15744
- if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1);
15745
- else if (result.to.line == this.doc.lastLine()) result = null;
15746
- else result = this.matches(reverse, Pos(result.to.line + 1, 0));
15959
+ head.ch++;
15960
+ if (head.ch > (this.doc.getLine(head.line) || "").length) {
15961
+ head.ch = 0;
15962
+ head.line++;
15963
+ }
15964
+ }
15965
+ if (CodeMirror.cmpPos(head, this.doc.clipPos(head)) != 0) {
15966
+ return this.atOccurrence = false
15747
15967
  }
15748
15968
  }
15969
+ var result = this.matches(reverse, head);
15970
+ this.afterEmptyMatch = result && CodeMirror.cmpPos(result.from, result.to) == 0;
15749
15971
 
15750
15972
  if (result) {
15751
15973
  this.pos = result;
@@ -15806,6 +16028,9 @@
15806
16028
  mod(codemirror, searchcursor, dialog);
15807
16029
  })(function(CodeMirror) {
15808
16030
 
16031
+ // default search panel location
16032
+ CodeMirror.defineOption("search", {bottom: false});
16033
+
15809
16034
  function searchOverlay(query, caseInsensitive) {
15810
16035
  if (typeof query == "string")
15811
16036
  query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
@@ -15850,12 +16075,13 @@
15850
16075
  selectValueOnOpen: true,
15851
16076
  closeOnEnter: false,
15852
16077
  onClose: function() { clearSearch(cm); },
15853
- onKeyDown: onKeyDown
16078
+ onKeyDown: onKeyDown,
16079
+ bottom: cm.options.search.bottom
15854
16080
  });
15855
16081
  }
15856
16082
 
15857
16083
  function dialog(cm, text, shortText, deflt, f) {
15858
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
16084
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom});
15859
16085
  else f(prompt(shortText, deflt));
15860
16086
  }
15861
16087
 
@@ -15972,18 +16198,43 @@
15972
16198
  if (state.annotate) { state.annotate.clear(); state.annotate = null; }
15973
16199
  });}
15974
16200
 
16201
+ function el(tag, attrs) {
16202
+ var element = tag ? document.createElement(tag) : document.createDocumentFragment();
16203
+ for (var key in attrs) {
16204
+ element[key] = attrs[key];
16205
+ }
16206
+ for (var i = 2; i < arguments.length; i++) {
16207
+ var child = arguments[i];
16208
+ element.appendChild(typeof child == "string" ? document.createTextNode(child) : child);
16209
+ }
16210
+ return element;
16211
+ }
15975
16212
 
15976
16213
  function getQueryDialog(cm) {
15977
- 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>';
16214
+ return el("", null,
16215
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ",
16216
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16217
+ el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16218
+ cm.phrase("(Use /re/ syntax for regexp search)")));
15978
16219
  }
15979
16220
  function getReplaceQueryDialog(cm) {
15980
- 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>';
16221
+ return el("", null, " ",
16222
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ",
16223
+ el("span", {style: "color: #888", className: "CodeMirror-search-hint"},
16224
+ cm.phrase("(Use /re/ syntax for regexp search)")));
15981
16225
  }
15982
16226
  function getReplacementQueryDialog(cm) {
15983
- return '<span class="CodeMirror-search-label">' + cm.phrase("With:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
16227
+ return el("", null,
16228
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("With:")), " ",
16229
+ el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}));
15984
16230
  }
15985
16231
  function getDoReplaceConfirm(cm) {
15986
- 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> ';
16232
+ return el("", null,
16233
+ el("span", {className: "CodeMirror-search-label"}, cm.phrase("Replace?")), " ",
16234
+ el("button", {}, cm.phrase("Yes")), " ",
16235
+ el("button", {}, cm.phrase("No")), " ",
16236
+ el("button", {}, cm.phrase("All")), " ",
16237
+ el("button", {}, cm.phrase("Stop")));
15987
16238
  }
15988
16239
 
15989
16240
  function replaceAll(cm, query, text) {
@@ -16000,8 +16251,11 @@
16000
16251
  function replace(cm, all) {
16001
16252
  if (cm.getOption("readOnly")) return;
16002
16253
  var query = cm.getSelection() || getSearchState(cm).lastQuery;
16003
- var dialogText = '<span class="CodeMirror-search-label">' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + '</span>';
16004
- dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) {
16254
+ var dialogText = all ? cm.phrase("Replace all:") : cm.phrase("Replace:");
16255
+ var fragment = el("", null,
16256
+ el("span", {className: "CodeMirror-search-label"}, dialogText),
16257
+ getReplaceQueryDialog(cm));
16258
+ dialog(cm, fragment, dialogText, query, function(query) {
16005
16259
  if (!query) return;
16006
16260
  query = parseQuery(query);
16007
16261
  dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {