@codemirror/view 6.2.0 → 6.2.3
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/CHANGELOG.md +28 -0
- package/dist/index.cjs +232 -215
- package/dist/index.d.ts +6 -1
- package/dist/index.js +232 -215
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ function getSelection(root) {
|
|
|
18
18
|
function contains(dom, node) {
|
|
19
19
|
return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
|
|
20
20
|
}
|
|
21
|
-
function deepActiveElement() {
|
|
22
|
-
let elt =
|
|
21
|
+
function deepActiveElement(doc) {
|
|
22
|
+
let elt = doc.activeElement;
|
|
23
23
|
while (elt && elt.shadowRoot)
|
|
24
24
|
elt = elt.shadowRoot.activeElement;
|
|
25
25
|
return elt;
|
|
@@ -304,7 +304,7 @@ class ContentView {
|
|
|
304
304
|
constructor() {
|
|
305
305
|
this.parent = null;
|
|
306
306
|
this.dom = null;
|
|
307
|
-
this.dirty = 2 /* Node */;
|
|
307
|
+
this.dirty = 2 /* Dirty.Node */;
|
|
308
308
|
}
|
|
309
309
|
get editorView() {
|
|
310
310
|
if (!this.parent)
|
|
@@ -335,7 +335,7 @@ class ContentView {
|
|
|
335
335
|
// given position.
|
|
336
336
|
coordsAt(_pos, _side) { return null; }
|
|
337
337
|
sync(track) {
|
|
338
|
-
if (this.dirty & 2 /* Node */) {
|
|
338
|
+
if (this.dirty & 2 /* Dirty.Node */) {
|
|
339
339
|
let parent = this.dom;
|
|
340
340
|
let prev = null, next;
|
|
341
341
|
for (let child of this.children) {
|
|
@@ -346,7 +346,7 @@ class ContentView {
|
|
|
346
346
|
child.reuseDOM(next);
|
|
347
347
|
}
|
|
348
348
|
child.sync(track);
|
|
349
|
-
child.dirty = 0 /* Not */;
|
|
349
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
350
350
|
}
|
|
351
351
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
352
352
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -366,11 +366,11 @@ class ContentView {
|
|
|
366
366
|
while (next)
|
|
367
367
|
next = rm$1(next);
|
|
368
368
|
}
|
|
369
|
-
else if (this.dirty & 1 /* Child */) {
|
|
369
|
+
else if (this.dirty & 1 /* Dirty.Child */) {
|
|
370
370
|
for (let child of this.children)
|
|
371
371
|
if (child.dirty) {
|
|
372
372
|
child.sync(track);
|
|
373
|
-
child.dirty = 0 /* Not */;
|
|
373
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -435,16 +435,16 @@ class ContentView {
|
|
|
435
435
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
436
436
|
}
|
|
437
437
|
markDirty(andParent = false) {
|
|
438
|
-
this.dirty |= 2 /* Node */;
|
|
438
|
+
this.dirty |= 2 /* Dirty.Node */;
|
|
439
439
|
this.markParentsDirty(andParent);
|
|
440
440
|
}
|
|
441
441
|
markParentsDirty(childList) {
|
|
442
442
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
443
443
|
if (childList)
|
|
444
|
-
parent.dirty |= 2 /* Node */;
|
|
445
|
-
if (parent.dirty & 1 /* Child */)
|
|
444
|
+
parent.dirty |= 2 /* Dirty.Node */;
|
|
445
|
+
if (parent.dirty & 1 /* Dirty.Child */)
|
|
446
446
|
return;
|
|
447
|
-
parent.dirty |= 1 /* Child */;
|
|
447
|
+
parent.dirty |= 1 /* Dirty.Child */;
|
|
448
448
|
childList = false;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
@@ -720,13 +720,13 @@ class MarkView extends ContentView {
|
|
|
720
720
|
reuseDOM(node) {
|
|
721
721
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
722
722
|
this.setDOM(node);
|
|
723
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
723
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
724
724
|
}
|
|
725
725
|
}
|
|
726
726
|
sync(track) {
|
|
727
727
|
if (!this.dom)
|
|
728
728
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
729
|
-
else if (this.dirty & 4 /* Attrs */)
|
|
729
|
+
else if (this.dirty & 4 /* Dirty.Attrs */)
|
|
730
730
|
this.setAttrs(this.dom);
|
|
731
731
|
super.sync(track);
|
|
732
732
|
}
|
|
@@ -758,7 +758,7 @@ class MarkView extends ContentView {
|
|
|
758
758
|
return new MarkView(this.mark, result, length);
|
|
759
759
|
}
|
|
760
760
|
domAtPos(pos) {
|
|
761
|
-
return inlineDOMAtPos(this
|
|
761
|
+
return inlineDOMAtPos(this, pos);
|
|
762
762
|
}
|
|
763
763
|
coordsAt(pos, side) {
|
|
764
764
|
return coordsInChildren(this, pos, side);
|
|
@@ -909,11 +909,14 @@ class CompositionView extends WidgetView {
|
|
|
909
909
|
// offset.
|
|
910
910
|
function scanCompositionTree(pos, side, view, text, enterView, fromText) {
|
|
911
911
|
if (view instanceof MarkView) {
|
|
912
|
-
for (let child
|
|
913
|
-
let
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
912
|
+
for (let child = view.dom.firstChild; child; child = child.nextSibling) {
|
|
913
|
+
let desc = ContentView.get(child);
|
|
914
|
+
if (!desc)
|
|
915
|
+
return fromText(pos, side);
|
|
916
|
+
let hasComp = contains(child, text);
|
|
917
|
+
let len = desc.length + (hasComp ? text.nodeValue.length : 0);
|
|
918
|
+
if (pos < len || pos == len && desc.getSide() <= 0)
|
|
919
|
+
return hasComp ? scanCompositionTree(pos, side, desc, text, enterView, fromText) : enterView(desc, pos, side);
|
|
917
920
|
pos -= len;
|
|
918
921
|
}
|
|
919
922
|
return enterView(view, view.length, -1);
|
|
@@ -1003,8 +1006,8 @@ function inlineSiblingRect(view, side) {
|
|
|
1003
1006
|
}
|
|
1004
1007
|
return undefined;
|
|
1005
1008
|
}
|
|
1006
|
-
function inlineDOMAtPos(
|
|
1007
|
-
let i = 0;
|
|
1009
|
+
function inlineDOMAtPos(parent, pos) {
|
|
1010
|
+
let dom = parent.dom, { children } = parent, i = 0;
|
|
1008
1011
|
for (let off = 0; i < children.length; i++) {
|
|
1009
1012
|
let child = children[i], end = off + child.length;
|
|
1010
1013
|
if (end == off && child.getSide() <= 0)
|
|
@@ -1015,10 +1018,16 @@ function inlineDOMAtPos(dom, children, pos) {
|
|
|
1015
1018
|
break;
|
|
1016
1019
|
off = end;
|
|
1017
1020
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1021
|
+
// if (i) return DOMPos.after(children[i - 1].dom!)
|
|
1022
|
+
for (let j = i; j > 0; j--) {
|
|
1023
|
+
let prev = children[j - 1];
|
|
1024
|
+
if (prev.dom.parentNode == dom)
|
|
1025
|
+
return prev.domAtPos(prev.length);
|
|
1026
|
+
}
|
|
1027
|
+
for (let j = i; j < children.length; j++) {
|
|
1028
|
+
let next = children[j];
|
|
1029
|
+
if (next.dom.parentNode == dom)
|
|
1030
|
+
return next.domAtPos(0);
|
|
1022
1031
|
}
|
|
1023
1032
|
return new DOMPos(dom, 0);
|
|
1024
1033
|
}
|
|
@@ -1226,7 +1235,7 @@ class Decoration extends RangeValue {
|
|
|
1226
1235
|
*/
|
|
1227
1236
|
static widget(spec) {
|
|
1228
1237
|
let side = spec.side || 0, block = !!spec.block;
|
|
1229
|
-
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1238
|
+
side += block ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */) : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
|
|
1230
1239
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1231
1240
|
}
|
|
1232
1241
|
/**
|
|
@@ -1236,13 +1245,13 @@ class Decoration extends RangeValue {
|
|
|
1236
1245
|
static replace(spec) {
|
|
1237
1246
|
let block = !!spec.block, startSide, endSide;
|
|
1238
1247
|
if (spec.isBlockGap) {
|
|
1239
|
-
startSide = -500000000 /* GapStart */;
|
|
1240
|
-
endSide = 400000000 /* GapEnd */;
|
|
1248
|
+
startSide = -500000000 /* Side.GapStart */;
|
|
1249
|
+
endSide = 400000000 /* Side.GapEnd */;
|
|
1241
1250
|
}
|
|
1242
1251
|
else {
|
|
1243
1252
|
let { start, end } = getInclusive(spec, block);
|
|
1244
|
-
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1245
|
-
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1253
|
+
startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
|
|
1254
|
+
endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
|
|
1246
1255
|
}
|
|
1247
1256
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1248
1257
|
}
|
|
@@ -1273,7 +1282,7 @@ Decoration.none = RangeSet.empty;
|
|
|
1273
1282
|
class MarkDecoration extends Decoration {
|
|
1274
1283
|
constructor(spec) {
|
|
1275
1284
|
let { start, end } = getInclusive(spec);
|
|
1276
|
-
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1285
|
+
super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
|
|
1277
1286
|
this.tagName = spec.tagName || "span";
|
|
1278
1287
|
this.class = spec.class || "";
|
|
1279
1288
|
this.attrs = spec.attributes || null;
|
|
@@ -1294,7 +1303,7 @@ class MarkDecoration extends Decoration {
|
|
|
1294
1303
|
MarkDecoration.prototype.point = false;
|
|
1295
1304
|
class LineDecoration extends Decoration {
|
|
1296
1305
|
constructor(spec) {
|
|
1297
|
-
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1306
|
+
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1298
1307
|
}
|
|
1299
1308
|
eq(other) {
|
|
1300
1309
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1426,12 +1435,12 @@ class LineView extends ContentView {
|
|
|
1426
1435
|
this.attrs = combineAttrs({ class: cls }, this.attrs || {});
|
|
1427
1436
|
}
|
|
1428
1437
|
domAtPos(pos) {
|
|
1429
|
-
return inlineDOMAtPos(this
|
|
1438
|
+
return inlineDOMAtPos(this, pos);
|
|
1430
1439
|
}
|
|
1431
1440
|
reuseDOM(node) {
|
|
1432
1441
|
if (node.nodeName == "DIV") {
|
|
1433
1442
|
this.setDOM(node);
|
|
1434
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1443
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
1435
1444
|
}
|
|
1436
1445
|
}
|
|
1437
1446
|
sync(track) {
|
|
@@ -1441,7 +1450,7 @@ class LineView extends ContentView {
|
|
|
1441
1450
|
this.dom.className = "cm-line";
|
|
1442
1451
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1443
1452
|
}
|
|
1444
|
-
else if (this.dirty & 4 /* Attrs */) {
|
|
1453
|
+
else if (this.dirty & 4 /* Dirty.Attrs */) {
|
|
1445
1454
|
clearAttributes(this.dom);
|
|
1446
1455
|
this.dom.className = "cm-line";
|
|
1447
1456
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1571,7 +1580,7 @@ class ContentBuilder {
|
|
|
1571
1580
|
this.content = [];
|
|
1572
1581
|
this.curLine = null;
|
|
1573
1582
|
this.breakAtStart = 0;
|
|
1574
|
-
this.pendingBuffer = 0 /* No */;
|
|
1583
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1575
1584
|
// Set to false directly after a widget that covers the position after it
|
|
1576
1585
|
this.atCursorPos = true;
|
|
1577
1586
|
this.openStart = -1;
|
|
@@ -1597,7 +1606,7 @@ class ContentBuilder {
|
|
|
1597
1606
|
flushBuffer(active) {
|
|
1598
1607
|
if (this.pendingBuffer) {
|
|
1599
1608
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1600
|
-
this.pendingBuffer = 0 /* No */;
|
|
1609
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1601
1610
|
}
|
|
1602
1611
|
}
|
|
1603
1612
|
addBlockWidget(view) {
|
|
@@ -1609,7 +1618,7 @@ class ContentBuilder {
|
|
|
1609
1618
|
if (!openEnd)
|
|
1610
1619
|
this.flushBuffer([]);
|
|
1611
1620
|
else
|
|
1612
|
-
this.pendingBuffer = 0 /* No */;
|
|
1621
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1613
1622
|
if (!this.posCovered())
|
|
1614
1623
|
this.getLine();
|
|
1615
1624
|
}
|
|
@@ -1637,7 +1646,7 @@ class ContentBuilder {
|
|
|
1637
1646
|
this.textOff = 0;
|
|
1638
1647
|
}
|
|
1639
1648
|
}
|
|
1640
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1649
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
|
|
1641
1650
|
this.flushBuffer(active.slice(0, openStart));
|
|
1642
1651
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1643
1652
|
this.atCursorPos = true;
|
|
@@ -1672,8 +1681,8 @@ class ContentBuilder {
|
|
|
1672
1681
|
let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
|
|
1673
1682
|
let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
|
|
1674
1683
|
let line = this.getLine();
|
|
1675
|
-
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
|
|
1676
|
-
this.pendingBuffer = 0 /* No */;
|
|
1684
|
+
if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore)
|
|
1685
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1677
1686
|
this.flushBuffer(active);
|
|
1678
1687
|
if (cursorBefore) {
|
|
1679
1688
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1681,7 +1690,7 @@ class ContentBuilder {
|
|
|
1681
1690
|
}
|
|
1682
1691
|
line.append(wrapMarks(view, active), openStart);
|
|
1683
1692
|
this.atCursorPos = cursorAfter;
|
|
1684
|
-
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1693
|
+
this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
|
|
1685
1694
|
}
|
|
1686
1695
|
}
|
|
1687
1696
|
else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
|
|
@@ -1974,7 +1983,7 @@ class ViewUpdate {
|
|
|
1974
1983
|
let focus = view.hasFocus;
|
|
1975
1984
|
if (focus != view.inputState.notifiedFocused) {
|
|
1976
1985
|
view.inputState.notifiedFocused = focus;
|
|
1977
|
-
this.flags |= 1 /* Focus */;
|
|
1986
|
+
this.flags |= 1 /* UpdateFlag.Focus */;
|
|
1978
1987
|
}
|
|
1979
1988
|
}
|
|
1980
1989
|
/**
|
|
@@ -1989,27 +1998,27 @@ class ViewUpdate {
|
|
|
1989
1998
|
update.
|
|
1990
1999
|
*/
|
|
1991
2000
|
get viewportChanged() {
|
|
1992
|
-
return (this.flags & 4 /* Viewport */) > 0;
|
|
2001
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
1993
2002
|
}
|
|
1994
2003
|
/**
|
|
1995
2004
|
Indicates whether the height of a block element in the editor
|
|
1996
2005
|
changed in this update.
|
|
1997
2006
|
*/
|
|
1998
2007
|
get heightChanged() {
|
|
1999
|
-
return (this.flags & 2 /* Height */) > 0;
|
|
2008
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2000
2009
|
}
|
|
2001
2010
|
/**
|
|
2002
2011
|
Returns true when the document was modified or the size of the
|
|
2003
2012
|
editor, or elements within the editor, changed.
|
|
2004
2013
|
*/
|
|
2005
2014
|
get geometryChanged() {
|
|
2006
|
-
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2015
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2007
2016
|
}
|
|
2008
2017
|
/**
|
|
2009
2018
|
True when this update indicates a focus change.
|
|
2010
2019
|
*/
|
|
2011
2020
|
get focusChanged() {
|
|
2012
|
-
return (this.flags & 1 /* Focus */) > 0;
|
|
2021
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2013
2022
|
}
|
|
2014
2023
|
/**
|
|
2015
2024
|
Whether the document changed in this update.
|
|
@@ -2067,13 +2076,14 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2067
2076
|
}
|
|
2068
2077
|
function charType(ch) {
|
|
2069
2078
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2070
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2079
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2071
2080
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2072
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2073
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2074
|
-
ch
|
|
2081
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2082
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :
|
|
2083
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :
|
|
2084
|
+
ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;
|
|
2075
2085
|
}
|
|
2076
|
-
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
|
2086
|
+
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2077
2087
|
/**
|
|
2078
2088
|
Represents a contiguous range of text that has a single direction
|
|
2079
2089
|
(as in left-to-right or right-to-left).
|
|
@@ -2136,8 +2146,8 @@ class BidiSpan {
|
|
|
2136
2146
|
// Reused array of character types
|
|
2137
2147
|
const types = [];
|
|
2138
2148
|
function computeOrder(line, direction) {
|
|
2139
|
-
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2140
|
-
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2149
|
+
let len = line.length, outerType = direction == LTR ? 1 /* T.L */ : 2 /* T.R */, oppositeType = direction == LTR ? 2 /* T.R */ : 1 /* T.L */;
|
|
2150
|
+
if (!line || outerType == 1 /* T.L */ && !BidiRE.test(line))
|
|
2141
2151
|
return trivialOrder(len);
|
|
2142
2152
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2143
2153
|
// change the type of the NSM to the type of the previous
|
|
@@ -2151,12 +2161,12 @@ function computeOrder(line, direction) {
|
|
|
2151
2161
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2152
2162
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2153
2163
|
let type = charType(line.charCodeAt(i));
|
|
2154
|
-
if (type == 512 /* NSM */)
|
|
2164
|
+
if (type == 512 /* T.NSM */)
|
|
2155
2165
|
type = prev;
|
|
2156
|
-
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2157
|
-
type = 16 /* AN */;
|
|
2158
|
-
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2159
|
-
if (type & 7 /* Strong */)
|
|
2166
|
+
else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
|
|
2167
|
+
type = 16 /* T.AN */;
|
|
2168
|
+
types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
|
|
2169
|
+
if (type & 7 /* T.Strong */)
|
|
2160
2170
|
prevStrong = type;
|
|
2161
2171
|
prev = type;
|
|
2162
2172
|
}
|
|
@@ -2170,26 +2180,26 @@ function computeOrder(line, direction) {
|
|
|
2170
2180
|
// (Left after this: L, R, EN+AN, NI)
|
|
2171
2181
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2172
2182
|
let type = types[i];
|
|
2173
|
-
if (type == 128 /* CS */) {
|
|
2174
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2183
|
+
if (type == 128 /* T.CS */) {
|
|
2184
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
|
|
2175
2185
|
type = types[i] = prev;
|
|
2176
2186
|
else
|
|
2177
|
-
types[i] = 256 /* NI */;
|
|
2187
|
+
types[i] = 256 /* T.NI */;
|
|
2178
2188
|
}
|
|
2179
|
-
else if (type == 64 /* ET */) {
|
|
2189
|
+
else if (type == 64 /* T.ET */) {
|
|
2180
2190
|
let end = i + 1;
|
|
2181
|
-
while (end < len && types[end] == 64 /* ET */)
|
|
2191
|
+
while (end < len && types[end] == 64 /* T.ET */)
|
|
2182
2192
|
end++;
|
|
2183
|
-
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2193
|
+
let replace = (i && prev == 8 /* T.EN */) || (end < len && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;
|
|
2184
2194
|
for (let j = i; j < end; j++)
|
|
2185
2195
|
types[j] = replace;
|
|
2186
2196
|
i = end - 1;
|
|
2187
2197
|
}
|
|
2188
|
-
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2189
|
-
types[i] = 1 /* L */;
|
|
2198
|
+
else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
|
|
2199
|
+
types[i] = 1 /* T.L */;
|
|
2190
2200
|
}
|
|
2191
2201
|
prev = type;
|
|
2192
|
-
if (type & 7 /* Strong */)
|
|
2202
|
+
if (type & 7 /* T.Strong */)
|
|
2193
2203
|
prevStrong = type;
|
|
2194
2204
|
}
|
|
2195
2205
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2204,9 +2214,9 @@ function computeOrder(line, direction) {
|
|
|
2204
2214
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2205
2215
|
if (BracketStack[sJ + 1] == -br) {
|
|
2206
2216
|
let flags = BracketStack[sJ + 2];
|
|
2207
|
-
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2208
|
-
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2209
|
-
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2217
|
+
let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
|
|
2218
|
+
!(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
|
|
2219
|
+
(flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
|
|
2210
2220
|
if (type)
|
|
2211
2221
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2212
2222
|
sI = sJ;
|
|
@@ -2214,7 +2224,7 @@ function computeOrder(line, direction) {
|
|
|
2214
2224
|
}
|
|
2215
2225
|
}
|
|
2216
2226
|
}
|
|
2217
|
-
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2227
|
+
else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
|
|
2218
2228
|
break;
|
|
2219
2229
|
}
|
|
2220
2230
|
else {
|
|
@@ -2223,20 +2233,20 @@ function computeOrder(line, direction) {
|
|
|
2223
2233
|
BracketStack[sI++] = context;
|
|
2224
2234
|
}
|
|
2225
2235
|
}
|
|
2226
|
-
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2236
|
+
else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
|
|
2227
2237
|
let embed = type == outerType;
|
|
2228
|
-
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2238
|
+
context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
|
|
2229
2239
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2230
2240
|
let cur = BracketStack[sJ + 2];
|
|
2231
|
-
if (cur & 2 /* EmbedInside */)
|
|
2241
|
+
if (cur & 2 /* Bracketed.EmbedInside */)
|
|
2232
2242
|
break;
|
|
2233
2243
|
if (embed) {
|
|
2234
|
-
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2244
|
+
BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
|
|
2235
2245
|
}
|
|
2236
2246
|
else {
|
|
2237
|
-
if (cur & 4 /* OppositeInside */)
|
|
2247
|
+
if (cur & 4 /* Bracketed.OppositeInside */)
|
|
2238
2248
|
break;
|
|
2239
|
-
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2249
|
+
BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
|
|
2240
2250
|
}
|
|
2241
2251
|
}
|
|
2242
2252
|
}
|
|
@@ -2249,13 +2259,13 @@ function computeOrder(line, direction) {
|
|
|
2249
2259
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2250
2260
|
// (Left after this: L, R, EN+AN)
|
|
2251
2261
|
for (let i = 0; i < len; i++) {
|
|
2252
|
-
if (types[i] == 256 /* NI */) {
|
|
2262
|
+
if (types[i] == 256 /* T.NI */) {
|
|
2253
2263
|
let end = i + 1;
|
|
2254
|
-
while (end < len && types[end] == 256 /* NI */)
|
|
2264
|
+
while (end < len && types[end] == 256 /* T.NI */)
|
|
2255
2265
|
end++;
|
|
2256
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2257
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2258
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2266
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* T.L */;
|
|
2267
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* T.L */;
|
|
2268
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
|
|
2259
2269
|
for (let j = i; j < end; j++)
|
|
2260
2270
|
types[j] = replace;
|
|
2261
2271
|
i = end - 1;
|
|
@@ -2267,15 +2277,15 @@ function computeOrder(line, direction) {
|
|
|
2267
2277
|
// explicit embedding into account, we can build up the order on
|
|
2268
2278
|
// the fly, without following the level-based algorithm.
|
|
2269
2279
|
let order = [];
|
|
2270
|
-
if (outerType == 1 /* L */) {
|
|
2280
|
+
if (outerType == 1 /* T.L */) {
|
|
2271
2281
|
for (let i = 0; i < len;) {
|
|
2272
|
-
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2273
|
-
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2282
|
+
let start = i, rtl = types[i++] != 1 /* T.L */;
|
|
2283
|
+
while (i < len && rtl == (types[i] != 1 /* T.L */))
|
|
2274
2284
|
i++;
|
|
2275
2285
|
if (rtl) {
|
|
2276
2286
|
for (let j = i; j > start;) {
|
|
2277
|
-
let end = j, l = types[--j] != 2 /* R */;
|
|
2278
|
-
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2287
|
+
let end = j, l = types[--j] != 2 /* T.R */;
|
|
2288
|
+
while (j > start && l == (types[j - 1] != 2 /* T.R */))
|
|
2279
2289
|
j--;
|
|
2280
2290
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2281
2291
|
}
|
|
@@ -2287,8 +2297,8 @@ function computeOrder(line, direction) {
|
|
|
2287
2297
|
}
|
|
2288
2298
|
else {
|
|
2289
2299
|
for (let i = 0; i < len;) {
|
|
2290
|
-
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2291
|
-
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2300
|
+
let start = i, rtl = types[i++] == 2 /* T.R */;
|
|
2301
|
+
while (i < len && rtl == (types[i] == 2 /* T.R */))
|
|
2292
2302
|
i++;
|
|
2293
2303
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2294
2304
|
}
|
|
@@ -2509,7 +2519,7 @@ class DocView extends ContentView {
|
|
|
2509
2519
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2510
2520
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2511
2521
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2512
|
-
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2522
|
+
if (this.dirty == 0 /* Dirty.Not */ && changedRanges.length == 0) {
|
|
2513
2523
|
return false;
|
|
2514
2524
|
}
|
|
2515
2525
|
else {
|
|
@@ -2538,7 +2548,7 @@ class DocView extends ContentView {
|
|
|
2538
2548
|
// to detect that situation.
|
|
2539
2549
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2540
2550
|
this.sync(track);
|
|
2541
|
-
this.dirty = 0 /* Not */;
|
|
2551
|
+
this.dirty = 0 /* Dirty.Not */;
|
|
2542
2552
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2543
2553
|
this.forceSelection = true;
|
|
2544
2554
|
this.dom.style.height = "";
|
|
@@ -2567,8 +2577,7 @@ class DocView extends ContentView {
|
|
|
2567
2577
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2568
2578
|
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2569
2579
|
this.view.observer.readSelectionRange();
|
|
2570
|
-
if (!(fromPointer || this.mayControlSelection())
|
|
2571
|
-
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
2580
|
+
if (!(fromPointer || this.mayControlSelection()))
|
|
2572
2581
|
return;
|
|
2573
2582
|
let force = this.forceSelection;
|
|
2574
2583
|
this.forceSelection = false;
|
|
@@ -2605,10 +2614,10 @@ class DocView extends ContentView {
|
|
|
2605
2614
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2606
2615
|
if (browser.gecko) {
|
|
2607
2616
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2608
|
-
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2609
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2617
|
+
if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
|
|
2618
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);
|
|
2610
2619
|
if (text)
|
|
2611
|
-
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2620
|
+
anchor = new DOMPos(text, nextTo == 1 /* NextTo.Before */ ? 0 : text.nodeValue.length);
|
|
2612
2621
|
}
|
|
2613
2622
|
}
|
|
2614
2623
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -2940,8 +2949,8 @@ function nearbyTextNode(node, offset, side) {
|
|
|
2940
2949
|
function nextToUneditable(node, offset) {
|
|
2941
2950
|
if (node.nodeType != 1)
|
|
2942
2951
|
return 0;
|
|
2943
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
2944
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
2952
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
|
|
2953
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
|
|
2945
2954
|
}
|
|
2946
2955
|
class DecorationComparator$1 {
|
|
2947
2956
|
constructor() {
|
|
@@ -3296,7 +3305,7 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3296
3305
|
for (let set of atoms) {
|
|
3297
3306
|
set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
|
|
3298
3307
|
if (pos.from > from && pos.from < to) {
|
|
3299
|
-
pos = oldPos.
|
|
3308
|
+
pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
|
|
3300
3309
|
moved = true;
|
|
3301
3310
|
}
|
|
3302
3311
|
});
|
|
@@ -3338,7 +3347,6 @@ class InputState {
|
|
|
3338
3347
|
// composition)
|
|
3339
3348
|
this.compositionFirstChange = null;
|
|
3340
3349
|
this.compositionEndedAt = 0;
|
|
3341
|
-
this.rapidCompositionStart = false;
|
|
3342
3350
|
this.mouseSelection = null;
|
|
3343
3351
|
for (let type in handlers) {
|
|
3344
3352
|
let handler = handlers[type];
|
|
@@ -3452,9 +3460,10 @@ class InputState {
|
|
|
3452
3460
|
// applyDOMChange, notify key handlers of it and reset to
|
|
3453
3461
|
// the state they produce.
|
|
3454
3462
|
let pending;
|
|
3455
|
-
if (browser.ios &&
|
|
3456
|
-
|
|
3457
|
-
|
|
3463
|
+
if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&
|
|
3464
|
+
((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||
|
|
3465
|
+
EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
|
|
3466
|
+
this.pendingIOSKey = pending || event;
|
|
3458
3467
|
setTimeout(() => this.flushIOSKey(view), 250);
|
|
3459
3468
|
return true;
|
|
3460
3469
|
}
|
|
@@ -3485,8 +3494,7 @@ class InputState {
|
|
|
3485
3494
|
return false;
|
|
3486
3495
|
}
|
|
3487
3496
|
mustFlushObserver(event) {
|
|
3488
|
-
return
|
|
3489
|
-
event.type == "compositionend" && !browser.ios;
|
|
3497
|
+
return event.type == "keydown" && event.keyCode != 229;
|
|
3490
3498
|
}
|
|
3491
3499
|
startMouseSelection(mouseSelection) {
|
|
3492
3500
|
if (this.mouseSelection)
|
|
@@ -3509,6 +3517,7 @@ const PendingKeys = [
|
|
|
3509
3517
|
{ key: "Enter", keyCode: 13, inputType: "insertParagraph" },
|
|
3510
3518
|
{ key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
|
|
3511
3519
|
];
|
|
3520
|
+
const EmacsyPendingKeys = "dthko";
|
|
3512
3521
|
// Key codes for modifier keys
|
|
3513
3522
|
const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
|
|
3514
3523
|
class MouseSelection {
|
|
@@ -3753,8 +3762,7 @@ function basicMouseSelection(view, event) {
|
|
|
3753
3762
|
return {
|
|
3754
3763
|
update(update) {
|
|
3755
3764
|
if (update.docChanged) {
|
|
3756
|
-
|
|
3757
|
-
start.pos = update.changes.mapPos(start.pos);
|
|
3765
|
+
start.pos = update.changes.mapPos(start.pos);
|
|
3758
3766
|
startSel = startSel.map(update.changes);
|
|
3759
3767
|
lastEvent = null;
|
|
3760
3768
|
}
|
|
@@ -3767,8 +3775,6 @@ function basicMouseSelection(view, event) {
|
|
|
3767
3775
|
cur = last = queryPos(view, event);
|
|
3768
3776
|
lastEvent = event;
|
|
3769
3777
|
}
|
|
3770
|
-
if (!cur || !start)
|
|
3771
|
-
return startSel;
|
|
3772
3778
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3773
3779
|
if (start.pos != cur.pos && !extend) {
|
|
3774
3780
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -3940,36 +3946,24 @@ handlers.blur = view => {
|
|
|
3940
3946
|
view.observer.clearSelectionRange();
|
|
3941
3947
|
updateForFocusChange(view);
|
|
3942
3948
|
};
|
|
3943
|
-
function forceClearComposition(view, rapid) {
|
|
3944
|
-
if (view.docView.compositionDeco.size) {
|
|
3945
|
-
view.inputState.rapidCompositionStart = rapid;
|
|
3946
|
-
try {
|
|
3947
|
-
view.update([]);
|
|
3948
|
-
}
|
|
3949
|
-
finally {
|
|
3950
|
-
view.inputState.rapidCompositionStart = false;
|
|
3951
|
-
}
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3954
3949
|
handlers.compositionstart = handlers.compositionupdate = view => {
|
|
3955
3950
|
if (view.inputState.compositionFirstChange == null)
|
|
3956
3951
|
view.inputState.compositionFirstChange = true;
|
|
3957
3952
|
if (view.inputState.composing < 0) {
|
|
3958
3953
|
// FIXME possibly set a timeout to clear it again on Android
|
|
3959
3954
|
view.inputState.composing = 0;
|
|
3960
|
-
if (view.docView.compositionDeco.size) {
|
|
3961
|
-
view.observer.flush();
|
|
3962
|
-
forceClearComposition(view, true);
|
|
3963
|
-
}
|
|
3964
3955
|
}
|
|
3965
3956
|
};
|
|
3966
3957
|
handlers.compositionend = view => {
|
|
3967
3958
|
view.inputState.composing = -1;
|
|
3968
3959
|
view.inputState.compositionEndedAt = Date.now();
|
|
3969
3960
|
view.inputState.compositionFirstChange = null;
|
|
3961
|
+
if (browser.chrome && browser.android)
|
|
3962
|
+
view.observer.flushSoon();
|
|
3970
3963
|
setTimeout(() => {
|
|
3971
|
-
if
|
|
3972
|
-
|
|
3964
|
+
// Force the composition state to be cleared if it hasn't already been
|
|
3965
|
+
if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
|
|
3966
|
+
view.update([]);
|
|
3973
3967
|
}, 50);
|
|
3974
3968
|
};
|
|
3975
3969
|
handlers.contextmenu = view => {
|
|
@@ -4139,13 +4133,13 @@ const Epsilon = 1e-3;
|
|
|
4139
4133
|
class HeightMap {
|
|
4140
4134
|
constructor(length, // The number of characters covered
|
|
4141
4135
|
height, // Height of this part of the document
|
|
4142
|
-
flags = 2 /* Outdated */) {
|
|
4136
|
+
flags = 2 /* Flag.Outdated */) {
|
|
4143
4137
|
this.length = length;
|
|
4144
4138
|
this.height = height;
|
|
4145
4139
|
this.flags = flags;
|
|
4146
4140
|
}
|
|
4147
|
-
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4148
|
-
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4141
|
+
get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
|
|
4142
|
+
set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
|
|
4149
4143
|
setHeight(oracle, height) {
|
|
4150
4144
|
if (this.height != height) {
|
|
4151
4145
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4272,7 +4266,7 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4272
4266
|
}
|
|
4273
4267
|
replace(_from, _to, nodes) {
|
|
4274
4268
|
let node = nodes[0];
|
|
4275
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4269
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
|
|
4276
4270
|
Math.abs(this.length - node.length) < 10) {
|
|
4277
4271
|
if (node instanceof HeightMapGap)
|
|
4278
4272
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4398,12 +4392,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4398
4392
|
}
|
|
4399
4393
|
class HeightMapBranch extends HeightMap {
|
|
4400
4394
|
constructor(left, brk, right) {
|
|
4401
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4395
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
|
|
4402
4396
|
this.left = left;
|
|
4403
4397
|
this.right = right;
|
|
4404
4398
|
this.size = left.size + right.size;
|
|
4405
4399
|
}
|
|
4406
|
-
get break() { return this.flags & 1 /* Break */; }
|
|
4400
|
+
get break() { return this.flags & 1 /* Flag.Break */; }
|
|
4407
4401
|
blockAt(height, doc, top, offset) {
|
|
4408
4402
|
let mid = top + this.left.height;
|
|
4409
4403
|
return height < mid ? this.left.blockAt(height, doc, top, offset)
|
|
@@ -4587,7 +4581,7 @@ class NodeBuilder {
|
|
|
4587
4581
|
blankContent(from, to) {
|
|
4588
4582
|
let gap = new HeightMapGap(to - from);
|
|
4589
4583
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4590
|
-
gap.flags |= 4 /* SingleLine */;
|
|
4584
|
+
gap.flags |= 4 /* Flag.SingleLine */;
|
|
4591
4585
|
return gap;
|
|
4592
4586
|
}
|
|
4593
4587
|
ensureLine() {
|
|
@@ -4785,7 +4779,7 @@ class ViewState {
|
|
|
4785
4779
|
}
|
|
4786
4780
|
}
|
|
4787
4781
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
4788
|
-
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
4782
|
+
this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
|
|
4789
4783
|
new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
|
|
4790
4784
|
}
|
|
4791
4785
|
updateViewportLines() {
|
|
@@ -4803,18 +4797,18 @@ class ViewState {
|
|
|
4803
4797
|
let prevHeight = this.heightMap.height;
|
|
4804
4798
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
4805
4799
|
if (this.heightMap.height != prevHeight)
|
|
4806
|
-
update.flags |= 2 /* Height */;
|
|
4800
|
+
update.flags |= 2 /* UpdateFlag.Height */;
|
|
4807
4801
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
4808
4802
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
4809
4803
|
!this.viewportIsAppropriate(viewport))
|
|
4810
4804
|
viewport = this.getViewport(0, scrollTarget);
|
|
4811
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
4805
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||
|
|
4812
4806
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
4813
4807
|
this.viewport = viewport;
|
|
4814
4808
|
this.updateForViewport();
|
|
4815
4809
|
if (updateLines)
|
|
4816
4810
|
this.updateViewportLines();
|
|
4817
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4811
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4818
4812
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
4819
4813
|
update.flags |= this.computeVisibleRanges();
|
|
4820
4814
|
if (scrollTarget)
|
|
@@ -4838,13 +4832,13 @@ class ViewState {
|
|
|
4838
4832
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4839
4833
|
this.paddingTop = paddingTop;
|
|
4840
4834
|
this.paddingBottom = paddingBottom;
|
|
4841
|
-
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4835
|
+
result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
|
|
4842
4836
|
}
|
|
4843
4837
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4844
4838
|
if (oracle.lineWrapping)
|
|
4845
4839
|
measureContent = true;
|
|
4846
4840
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4847
|
-
result |= 8 /* Geometry */;
|
|
4841
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4848
4842
|
}
|
|
4849
4843
|
// Pixel viewport
|
|
4850
4844
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
@@ -4862,7 +4856,7 @@ class ViewState {
|
|
|
4862
4856
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
4863
4857
|
this.contentDOMWidth = contentWidth;
|
|
4864
4858
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
4865
|
-
result |= 8 /* Geometry */;
|
|
4859
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4866
4860
|
}
|
|
4867
4861
|
if (measureContent) {
|
|
4868
4862
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -4873,7 +4867,7 @@ class ViewState {
|
|
|
4873
4867
|
refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
|
|
4874
4868
|
if (refresh) {
|
|
4875
4869
|
view.docView.minWidth = 0;
|
|
4876
|
-
result |= 8 /* Geometry */;
|
|
4870
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4877
4871
|
}
|
|
4878
4872
|
}
|
|
4879
4873
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -4886,16 +4880,16 @@ class ViewState {
|
|
|
4886
4880
|
this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
4887
4881
|
}
|
|
4888
4882
|
if (oracle.heightChanged)
|
|
4889
|
-
result |= 2 /* Height */;
|
|
4883
|
+
result |= 2 /* UpdateFlag.Height */;
|
|
4890
4884
|
}
|
|
4891
4885
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
4892
4886
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
|
|
4893
4887
|
if (viewportChange)
|
|
4894
4888
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
4895
4889
|
this.updateForViewport();
|
|
4896
|
-
if ((result & 2 /* Height */) || viewportChange)
|
|
4890
|
+
if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
|
|
4897
4891
|
this.updateViewportLines();
|
|
4898
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4892
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4899
4893
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
|
|
4900
4894
|
result |= this.computeVisibleRanges();
|
|
4901
4895
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -4914,9 +4908,9 @@ class ViewState {
|
|
|
4914
4908
|
// This will divide VP.Margin between the top and the
|
|
4915
4909
|
// bottom, depending on the bias (the change in viewport position
|
|
4916
4910
|
// since the last update). It'll hold a number between 0 and 1
|
|
4917
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
4911
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
|
|
4918
4912
|
let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
|
|
4919
|
-
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType.ByHeight, doc, 0, 0).to);
|
|
4913
|
+
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).to);
|
|
4920
4914
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
4921
4915
|
if (scrollTarget) {
|
|
4922
4916
|
let { head } = scrollTarget.range;
|
|
@@ -4929,7 +4923,7 @@ class ViewState {
|
|
|
4929
4923
|
topPos = block.top;
|
|
4930
4924
|
else
|
|
4931
4925
|
topPos = block.bottom - viewHeight;
|
|
4932
|
-
viewport = new Viewport(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType.ByHeight, doc, 0, 0).to);
|
|
4926
|
+
viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).to);
|
|
4933
4927
|
}
|
|
4934
4928
|
}
|
|
4935
4929
|
return viewport;
|
|
@@ -4946,10 +4940,10 @@ class ViewState {
|
|
|
4946
4940
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4947
4941
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4948
4942
|
let { visibleTop, visibleBottom } = this;
|
|
4949
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
4943
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4950
4944
|
(to == this.state.doc.length ||
|
|
4951
|
-
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
4952
|
-
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
4945
|
+
bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4946
|
+
(top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
|
|
4953
4947
|
}
|
|
4954
4948
|
mapLineGaps(gaps, changes) {
|
|
4955
4949
|
if (!gaps.length || changes.empty)
|
|
@@ -4973,20 +4967,20 @@ class ViewState {
|
|
|
4973
4967
|
if (this.defaultTextDirection != Direction.LTR)
|
|
4974
4968
|
return gaps;
|
|
4975
4969
|
for (let line of this.viewportLines) {
|
|
4976
|
-
if (line.length < 4000 /* DoubleMargin */)
|
|
4970
|
+
if (line.length < 4000 /* LG.DoubleMargin */)
|
|
4977
4971
|
continue;
|
|
4978
4972
|
let structure = lineStructure(line.from, line.to, this.stateDeco);
|
|
4979
|
-
if (structure.total < 4000 /* DoubleMargin */)
|
|
4973
|
+
if (structure.total < 4000 /* LG.DoubleMargin */)
|
|
4980
4974
|
continue;
|
|
4981
4975
|
let viewFrom, viewTo;
|
|
4982
4976
|
if (this.heightOracle.lineWrapping) {
|
|
4983
|
-
let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4977
|
+
let marginHeight = (2000 /* LG.Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4984
4978
|
viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
|
|
4985
4979
|
viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
|
|
4986
4980
|
}
|
|
4987
4981
|
else {
|
|
4988
4982
|
let totalWidth = structure.total * this.heightOracle.charWidth;
|
|
4989
|
-
let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
|
|
4983
|
+
let marginWidth = 2000 /* LG.Margin */ * this.heightOracle.charWidth;
|
|
4990
4984
|
viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
|
|
4991
4985
|
viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
|
|
4992
4986
|
}
|
|
@@ -4998,13 +4992,13 @@ class ViewState {
|
|
|
4998
4992
|
let sel = this.state.selection.main;
|
|
4999
4993
|
// Make sure the gaps don't cover a selection end
|
|
5000
4994
|
if (sel.from >= line.from && sel.from <= line.to)
|
|
5001
|
-
cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
|
|
4995
|
+
cutRange(outside, sel.from - 10 /* LG.SelectionMargin */, sel.from + 10 /* LG.SelectionMargin */);
|
|
5002
4996
|
if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
|
|
5003
|
-
cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
|
|
4997
|
+
cutRange(outside, sel.to - 10 /* LG.SelectionMargin */, sel.to + 10 /* LG.SelectionMargin */);
|
|
5004
4998
|
for (let { from, to } of outside)
|
|
5005
|
-
if (to - from > 1000 /* HalfMargin */) {
|
|
4999
|
+
if (to - from > 1000 /* LG.HalfMargin */) {
|
|
5006
5000
|
gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
|
|
5007
|
-
Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
|
|
5001
|
+
Math.abs(gap.from - from) < 1000 /* LG.HalfMargin */ && Math.abs(gap.to - to) < 1000 /* LG.HalfMargin */) ||
|
|
5008
5002
|
new LineGap(from, to, this.gapSize(line, from, to, structure)));
|
|
5009
5003
|
}
|
|
5010
5004
|
}
|
|
@@ -5037,7 +5031,7 @@ class ViewState {
|
|
|
5037
5031
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5038
5032
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5039
5033
|
this.visibleRanges = ranges;
|
|
5040
|
-
return changed ? 4 /* Viewport */ : 0;
|
|
5034
|
+
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
5041
5035
|
}
|
|
5042
5036
|
lineBlockAt(pos) {
|
|
5043
5037
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5143,7 +5137,7 @@ class BigScaler {
|
|
|
5143
5137
|
vpHeight += bottom - top;
|
|
5144
5138
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5145
5139
|
});
|
|
5146
|
-
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5140
|
+
this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5147
5141
|
for (let obj of this.viewports) {
|
|
5148
5142
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5149
5143
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5446,6 +5440,7 @@ class DOMObserver {
|
|
|
5446
5440
|
this.resizeTimeout = -1;
|
|
5447
5441
|
this.queue = [];
|
|
5448
5442
|
this.delayedAndroidKey = null;
|
|
5443
|
+
this.lastChange = 0;
|
|
5449
5444
|
this.scrollTargets = [];
|
|
5450
5445
|
this.intersection = null;
|
|
5451
5446
|
this.resize = null;
|
|
@@ -5492,8 +5487,7 @@ class DOMObserver {
|
|
|
5492
5487
|
});
|
|
5493
5488
|
this.resize.observe(view.scrollDOM);
|
|
5494
5489
|
}
|
|
5495
|
-
this.win = view.
|
|
5496
|
-
this.addWindowListeners(this.win);
|
|
5490
|
+
this.addWindowListeners(this.win = view.win);
|
|
5497
5491
|
this.start();
|
|
5498
5492
|
if (typeof IntersectionObserver == "function") {
|
|
5499
5493
|
this.intersection = new IntersectionObserver(entries => {
|
|
@@ -5543,14 +5537,18 @@ class DOMObserver {
|
|
|
5543
5537
|
}
|
|
5544
5538
|
}
|
|
5545
5539
|
onSelectionChange(event) {
|
|
5540
|
+
let wasChanged = this.selectionChanged;
|
|
5546
5541
|
if (!this.readSelectionRange() || this.delayedAndroidKey)
|
|
5547
5542
|
return;
|
|
5548
5543
|
let { view } = this, sel = this.selectionRange;
|
|
5549
5544
|
if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))
|
|
5550
5545
|
return;
|
|
5551
5546
|
let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
|
|
5552
|
-
if (context && context.ignoreEvent(event))
|
|
5547
|
+
if (context && context.ignoreEvent(event)) {
|
|
5548
|
+
if (!wasChanged)
|
|
5549
|
+
this.selectionChanged = false;
|
|
5553
5550
|
return;
|
|
5551
|
+
}
|
|
5554
5552
|
// Deletions on IE11 fire their events in the wrong order, giving
|
|
5555
5553
|
// us a selection change event before the DOM changes are
|
|
5556
5554
|
// reported.
|
|
@@ -5567,7 +5565,8 @@ class DOMObserver {
|
|
|
5567
5565
|
let { view } = this;
|
|
5568
5566
|
// The Selection object is broken in shadow roots in Safari. See
|
|
5569
5567
|
// https://github.com/codemirror/dev/issues/414
|
|
5570
|
-
let range = browser.safari && view.root.nodeType == 11 &&
|
|
5568
|
+
let range = browser.safari && view.root.nodeType == 11 &&
|
|
5569
|
+
deepActiveElement(this.dom.ownerDocument) == this.dom &&
|
|
5571
5570
|
safariSelectionRangeHack(this.view) || getSelection(view.root);
|
|
5572
5571
|
if (!range || this.selectionRange.eq(range))
|
|
5573
5572
|
return false;
|
|
@@ -5667,26 +5666,34 @@ class DOMObserver {
|
|
|
5667
5666
|
// detected (via beforeinput or keydown), and then tries to flush
|
|
5668
5667
|
// them or, if that has no effect, dispatches the given key.
|
|
5669
5668
|
delayAndroidKey(key, keyCode) {
|
|
5669
|
+
var _a;
|
|
5670
5670
|
if (!this.delayedAndroidKey)
|
|
5671
|
-
requestAnimationFrame(() => {
|
|
5671
|
+
this.view.win.requestAnimationFrame(() => {
|
|
5672
5672
|
let key = this.delayedAndroidKey;
|
|
5673
5673
|
this.delayedAndroidKey = null;
|
|
5674
5674
|
this.delayedFlush = -1;
|
|
5675
|
-
if (!this.flush())
|
|
5675
|
+
if (!this.flush() && key.force)
|
|
5676
5676
|
dispatchKey(this.dom, key.key, key.keyCode);
|
|
5677
5677
|
});
|
|
5678
5678
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5679
5679
|
// Enter always takes precedence.
|
|
5680
5680
|
if (!this.delayedAndroidKey || key == "Enter")
|
|
5681
|
-
this.delayedAndroidKey = {
|
|
5681
|
+
this.delayedAndroidKey = {
|
|
5682
|
+
key, keyCode,
|
|
5683
|
+
// Only run the key handler when no changes are detected if
|
|
5684
|
+
// this isn't coming right after another change, in which case
|
|
5685
|
+
// it is probably part of a weird chain of updates, and should
|
|
5686
|
+
// be ignored if it returns the DOM to its previous state.
|
|
5687
|
+
force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
|
|
5688
|
+
};
|
|
5682
5689
|
}
|
|
5683
5690
|
flushSoon() {
|
|
5684
5691
|
if (this.delayedFlush < 0)
|
|
5685
|
-
this.delayedFlush =
|
|
5692
|
+
this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
|
|
5686
5693
|
}
|
|
5687
5694
|
forceFlush() {
|
|
5688
5695
|
if (this.delayedFlush >= 0) {
|
|
5689
|
-
|
|
5696
|
+
this.view.win.cancelAnimationFrame(this.delayedFlush);
|
|
5690
5697
|
this.delayedFlush = -1;
|
|
5691
5698
|
}
|
|
5692
5699
|
this.flush();
|
|
@@ -5720,13 +5727,15 @@ class DOMObserver {
|
|
|
5720
5727
|
// managing those will make sure processRecords is called and the
|
|
5721
5728
|
// view is resynchronized after
|
|
5722
5729
|
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
|
|
5723
|
-
return;
|
|
5730
|
+
return false;
|
|
5724
5731
|
if (readSelection)
|
|
5725
5732
|
this.readSelectionRange();
|
|
5726
5733
|
let { from, to, typeOver } = this.processRecords();
|
|
5727
5734
|
let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
|
|
5728
5735
|
if (from < 0 && !newSel)
|
|
5729
|
-
return;
|
|
5736
|
+
return false;
|
|
5737
|
+
if (from > -1)
|
|
5738
|
+
this.lastChange = Date.now();
|
|
5730
5739
|
this.view.inputState.lastFocusTime = 0;
|
|
5731
5740
|
this.selectionChanged = false;
|
|
5732
5741
|
let startState = this.view.state;
|
|
@@ -5742,7 +5751,7 @@ class DOMObserver {
|
|
|
5742
5751
|
return null;
|
|
5743
5752
|
cView.markDirty(rec.type == "attributes");
|
|
5744
5753
|
if (rec.type == "attributes")
|
|
5745
|
-
cView.dirty |= 4 /* Attrs */;
|
|
5754
|
+
cView.dirty |= 4 /* Dirty.Attrs */;
|
|
5746
5755
|
if (rec.type == "childList") {
|
|
5747
5756
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
5748
5757
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -5812,7 +5821,7 @@ function safariSelectionRangeHack(view) {
|
|
|
5812
5821
|
found = event.getTargetRanges()[0];
|
|
5813
5822
|
}
|
|
5814
5823
|
view.contentDOM.addEventListener("beforeinput", read, true);
|
|
5815
|
-
|
|
5824
|
+
view.dom.ownerDocument.execCommand("indent");
|
|
5816
5825
|
view.contentDOM.removeEventListener("beforeinput", read, true);
|
|
5817
5826
|
if (!found)
|
|
5818
5827
|
return null;
|
|
@@ -6069,7 +6078,7 @@ class EditorView {
|
|
|
6069
6078
|
/**
|
|
6070
6079
|
@internal
|
|
6071
6080
|
*/
|
|
6072
|
-
this.updateState = 2 /* Updating */;
|
|
6081
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6073
6082
|
/**
|
|
6074
6083
|
@internal
|
|
6075
6084
|
*/
|
|
@@ -6108,7 +6117,7 @@ class EditorView {
|
|
|
6108
6117
|
this.docView = new DocView(this);
|
|
6109
6118
|
this.mountStyles();
|
|
6110
6119
|
this.updateAttrs();
|
|
6111
|
-
this.updateState = 0 /* Idle */;
|
|
6120
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6112
6121
|
this.requestMeasure();
|
|
6113
6122
|
if (config.parent)
|
|
6114
6123
|
config.parent.appendChild(this.dom);
|
|
@@ -6156,6 +6165,10 @@ class EditorView {
|
|
|
6156
6165
|
The document or shadow root that the view lives in.
|
|
6157
6166
|
*/
|
|
6158
6167
|
get root() { return this._root; }
|
|
6168
|
+
/**
|
|
6169
|
+
@internal
|
|
6170
|
+
*/
|
|
6171
|
+
get win() { return this.dom.ownerDocument.defaultView; }
|
|
6159
6172
|
dispatch(...input) {
|
|
6160
6173
|
this._dispatch(input.length == 1 && input[0] instanceof Transaction ? input[0]
|
|
6161
6174
|
: this.state.update(...input));
|
|
@@ -6169,7 +6182,7 @@ class EditorView {
|
|
|
6169
6182
|
as a primitive.
|
|
6170
6183
|
*/
|
|
6171
6184
|
update(transactions) {
|
|
6172
|
-
if (this.updateState != 0 /* Idle */)
|
|
6185
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6173
6186
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6174
6187
|
let redrawn = false, attrsChanged = false, update;
|
|
6175
6188
|
let state = this.state;
|
|
@@ -6189,7 +6202,7 @@ class EditorView {
|
|
|
6189
6202
|
update = ViewUpdate.create(this, state, transactions);
|
|
6190
6203
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6191
6204
|
try {
|
|
6192
|
-
this.updateState = 2 /* Updating */;
|
|
6205
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6193
6206
|
for (let tr of transactions) {
|
|
6194
6207
|
if (scrollTarget)
|
|
6195
6208
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6215,7 +6228,7 @@ class EditorView {
|
|
|
6215
6228
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6216
6229
|
}
|
|
6217
6230
|
finally {
|
|
6218
|
-
this.updateState = 0 /* Idle */;
|
|
6231
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6219
6232
|
}
|
|
6220
6233
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6221
6234
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6233,13 +6246,13 @@ class EditorView {
|
|
|
6233
6246
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6234
6247
|
*/
|
|
6235
6248
|
setState(newState) {
|
|
6236
|
-
if (this.updateState != 0 /* Idle */)
|
|
6249
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6237
6250
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6238
6251
|
if (this.destroyed) {
|
|
6239
6252
|
this.viewState.state = newState;
|
|
6240
6253
|
return;
|
|
6241
6254
|
}
|
|
6242
|
-
this.updateState = 2 /* Updating */;
|
|
6255
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6243
6256
|
let hadFocus = this.hasFocus;
|
|
6244
6257
|
try {
|
|
6245
6258
|
for (let plugin of this.plugins)
|
|
@@ -6256,7 +6269,7 @@ class EditorView {
|
|
|
6256
6269
|
this.bidiCache = [];
|
|
6257
6270
|
}
|
|
6258
6271
|
finally {
|
|
6259
|
-
this.updateState = 0 /* Idle */;
|
|
6272
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6260
6273
|
}
|
|
6261
6274
|
if (hadFocus)
|
|
6262
6275
|
this.focus();
|
|
@@ -6307,7 +6320,7 @@ class EditorView {
|
|
|
6307
6320
|
let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;
|
|
6308
6321
|
try {
|
|
6309
6322
|
for (let i = 0;; i++) {
|
|
6310
|
-
this.updateState = 1 /* Measuring */;
|
|
6323
|
+
this.updateState = 1 /* UpdateState.Measuring */;
|
|
6311
6324
|
let oldViewport = this.viewport;
|
|
6312
6325
|
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6313
6326
|
let changed = this.viewState.measure(this);
|
|
@@ -6321,7 +6334,7 @@ class EditorView {
|
|
|
6321
6334
|
}
|
|
6322
6335
|
let measuring = [];
|
|
6323
6336
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6324
|
-
if (!(changed & 4 /* Viewport */))
|
|
6337
|
+
if (!(changed & 4 /* UpdateFlag.Viewport */))
|
|
6325
6338
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6326
6339
|
let measured = measuring.map(m => {
|
|
6327
6340
|
try {
|
|
@@ -6338,7 +6351,7 @@ class EditorView {
|
|
|
6338
6351
|
updated = update;
|
|
6339
6352
|
else
|
|
6340
6353
|
updated.flags |= changed;
|
|
6341
|
-
this.updateState = 2 /* Updating */;
|
|
6354
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6342
6355
|
if (!update.empty) {
|
|
6343
6356
|
this.updatePlugins(update);
|
|
6344
6357
|
this.inputState.update(update);
|
|
@@ -6376,7 +6389,7 @@ class EditorView {
|
|
|
6376
6389
|
}
|
|
6377
6390
|
}
|
|
6378
6391
|
finally {
|
|
6379
|
-
this.updateState = 0 /* Idle */;
|
|
6392
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6380
6393
|
this.measureScheduled = -1;
|
|
6381
6394
|
}
|
|
6382
6395
|
if (updated && !updated.empty)
|
|
@@ -6435,9 +6448,9 @@ class EditorView {
|
|
|
6435
6448
|
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6436
6449
|
}
|
|
6437
6450
|
readMeasured() {
|
|
6438
|
-
if (this.updateState == 2 /* Updating */)
|
|
6451
|
+
if (this.updateState == 2 /* UpdateState.Updating */)
|
|
6439
6452
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6440
|
-
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6453
|
+
if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
|
|
6441
6454
|
this.measure(false);
|
|
6442
6455
|
}
|
|
6443
6456
|
/**
|
|
@@ -6450,7 +6463,7 @@ class EditorView {
|
|
|
6450
6463
|
*/
|
|
6451
6464
|
requestMeasure(request) {
|
|
6452
6465
|
if (this.measureScheduled < 0)
|
|
6453
|
-
this.measureScheduled = requestAnimationFrame(() => this.measure());
|
|
6466
|
+
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6454
6467
|
if (request) {
|
|
6455
6468
|
if (request.key != null)
|
|
6456
6469
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
@@ -6695,7 +6708,7 @@ class EditorView {
|
|
|
6695
6708
|
// or closing, which leads us to ignore selection changes from the
|
|
6696
6709
|
// context menu because it looks like the editor isn't focused.
|
|
6697
6710
|
// This kludges around that.
|
|
6698
|
-
return (
|
|
6711
|
+
return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
|
|
6699
6712
|
this.root.activeElement == this.contentDOM;
|
|
6700
6713
|
}
|
|
6701
6714
|
/**
|
|
@@ -6880,6 +6893,11 @@ the editor's vertical layout structure. The ones provided as
|
|
|
6880
6893
|
functions are called _after_ the new viewport has been computed,
|
|
6881
6894
|
and thus **must not** introduce block widgets or replacing
|
|
6882
6895
|
decorations that cover line breaks.
|
|
6896
|
+
|
|
6897
|
+
If you want decorated ranges to behave like atomic units for
|
|
6898
|
+
cursor motion and deletion purposes, also provide the range set
|
|
6899
|
+
containing the decorations to
|
|
6900
|
+
[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
|
|
6883
6901
|
*/
|
|
6884
6902
|
EditorView.decorations = decorations;
|
|
6885
6903
|
/**
|
|
@@ -7110,7 +7128,7 @@ function runHandlers(map, event, view, scope) {
|
|
|
7110
7128
|
}
|
|
7111
7129
|
return false;
|
|
7112
7130
|
};
|
|
7113
|
-
let scopeObj = map[scope], baseName;
|
|
7131
|
+
let scopeObj = map[scope], baseName, shiftName;
|
|
7114
7132
|
if (scopeObj) {
|
|
7115
7133
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
7116
7134
|
return true;
|
|
@@ -7118,8 +7136,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
7118
7136
|
(baseName = base[event.keyCode]) && baseName != name) {
|
|
7119
7137
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
7120
7138
|
return true;
|
|
7121
|
-
else if (event.shiftKey && shift[event.keyCode] != baseName &&
|
|
7122
|
-
runFor(scopeObj[prefix + modifiers(
|
|
7139
|
+
else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&
|
|
7140
|
+
runFor(scopeObj[prefix + modifiers(shiftName, event, false)]))
|
|
7123
7141
|
return true;
|
|
7124
7142
|
}
|
|
7125
7143
|
else if (isChar && event.shiftKey) {
|
|
@@ -7320,7 +7338,7 @@ function measureRange(view, range) {
|
|
|
7320
7338
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7321
7339
|
}
|
|
7322
7340
|
function piece(left, top, right, bottom) {
|
|
7323
|
-
return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
|
|
7341
|
+
return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
|
|
7324
7342
|
}
|
|
7325
7343
|
function pieces({ top, bottom, horizontal }) {
|
|
7326
7344
|
let pieces = [];
|
|
@@ -8017,7 +8035,6 @@ const tooltipConfig = /*@__PURE__*/Facet.define({
|
|
|
8017
8035
|
});
|
|
8018
8036
|
const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
8019
8037
|
constructor(view) {
|
|
8020
|
-
var _a;
|
|
8021
8038
|
this.view = view;
|
|
8022
8039
|
this.inView = true;
|
|
8023
8040
|
this.lastTransaction = 0;
|
|
@@ -8035,7 +8052,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8035
8052
|
this.measureSoon();
|
|
8036
8053
|
}, { threshold: [1] }) : null;
|
|
8037
8054
|
this.observeIntersection();
|
|
8038
|
-
|
|
8055
|
+
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
8039
8056
|
this.maybeMeasure();
|
|
8040
8057
|
}
|
|
8041
8058
|
createContainer() {
|
|
@@ -8108,11 +8125,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8108
8125
|
return tooltipView;
|
|
8109
8126
|
}
|
|
8110
8127
|
destroy() {
|
|
8111
|
-
var _a
|
|
8112
|
-
|
|
8128
|
+
var _a;
|
|
8129
|
+
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
8113
8130
|
for (let { dom } of this.manager.tooltipViews)
|
|
8114
8131
|
dom.remove();
|
|
8115
|
-
(
|
|
8132
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
8116
8133
|
clearTimeout(this.measureTimeout);
|
|
8117
8134
|
}
|
|
8118
8135
|
readMeasure() {
|
|
@@ -8143,12 +8160,12 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8143
8160
|
continue;
|
|
8144
8161
|
}
|
|
8145
8162
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8146
|
-
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8163
|
+
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
8147
8164
|
let width = size.right - size.left, height = size.bottom - size.top;
|
|
8148
8165
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
|
|
8149
8166
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8150
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8151
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8167
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
8168
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
8152
8169
|
let above = !!tooltip.above;
|
|
8153
8170
|
if (!tooltip.strictSide && (above
|
|
8154
8171
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8170,7 +8187,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8170
8187
|
dom.style.left = left + "px";
|
|
8171
8188
|
}
|
|
8172
8189
|
if (arrow)
|
|
8173
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8190
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */)}px`;
|
|
8174
8191
|
if (tView.overlap !== true)
|
|
8175
8192
|
others.push({ left, top, right, bottom: top + height });
|
|
8176
8193
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8212,8 +8229,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8212
8229
|
color: "white"
|
|
8213
8230
|
},
|
|
8214
8231
|
".cm-tooltip-arrow": {
|
|
8215
|
-
height: `${7 /* Size */}px`,
|
|
8216
|
-
width: `${7 /* Size */ * 2}px`,
|
|
8232
|
+
height: `${7 /* Arrow.Size */}px`,
|
|
8233
|
+
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
8217
8234
|
position: "absolute",
|
|
8218
8235
|
zIndex: -1,
|
|
8219
8236
|
overflow: "hidden",
|
|
@@ -8222,26 +8239,26 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8222
8239
|
position: "absolute",
|
|
8223
8240
|
width: 0,
|
|
8224
8241
|
height: 0,
|
|
8225
|
-
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8226
|
-
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8242
|
+
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8243
|
+
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8227
8244
|
},
|
|
8228
8245
|
".cm-tooltip-above &": {
|
|
8229
|
-
bottom: `-${7 /* Size */}px`,
|
|
8246
|
+
bottom: `-${7 /* Arrow.Size */}px`,
|
|
8230
8247
|
"&:before": {
|
|
8231
|
-
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8248
|
+
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8232
8249
|
},
|
|
8233
8250
|
"&:after": {
|
|
8234
|
-
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8251
|
+
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8235
8252
|
bottom: "1px"
|
|
8236
8253
|
}
|
|
8237
8254
|
},
|
|
8238
8255
|
".cm-tooltip-below &": {
|
|
8239
|
-
top: `-${7 /* Size */}px`,
|
|
8256
|
+
top: `-${7 /* Arrow.Size */}px`,
|
|
8240
8257
|
"&:before": {
|
|
8241
|
-
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8258
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8242
8259
|
},
|
|
8243
8260
|
"&:after": {
|
|
8244
|
-
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8261
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8245
8262
|
top: "1px"
|
|
8246
8263
|
}
|
|
8247
8264
|
},
|
|
@@ -8386,7 +8403,7 @@ class HoverPlugin {
|
|
|
8386
8403
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
8387
8404
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
8388
8405
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
8389
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
8406
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* Hover.MaxDist */))) {
|
|
8390
8407
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
8391
8408
|
this.pending = null;
|
|
8392
8409
|
}
|
|
@@ -8468,7 +8485,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
8468
8485
|
});
|
|
8469
8486
|
return [
|
|
8470
8487
|
hoverState,
|
|
8471
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
8488
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
8472
8489
|
showHoverTooltipHost
|
|
8473
8490
|
];
|
|
8474
8491
|
}
|