@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.cjs
CHANGED
|
@@ -22,8 +22,8 @@ function getSelection(root) {
|
|
|
22
22
|
function contains(dom, node) {
|
|
23
23
|
return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
|
|
24
24
|
}
|
|
25
|
-
function deepActiveElement() {
|
|
26
|
-
let elt =
|
|
25
|
+
function deepActiveElement(doc) {
|
|
26
|
+
let elt = doc.activeElement;
|
|
27
27
|
while (elt && elt.shadowRoot)
|
|
28
28
|
elt = elt.shadowRoot.activeElement;
|
|
29
29
|
return elt;
|
|
@@ -308,7 +308,7 @@ class ContentView {
|
|
|
308
308
|
constructor() {
|
|
309
309
|
this.parent = null;
|
|
310
310
|
this.dom = null;
|
|
311
|
-
this.dirty = 2 /* Node */;
|
|
311
|
+
this.dirty = 2 /* Dirty.Node */;
|
|
312
312
|
}
|
|
313
313
|
get editorView() {
|
|
314
314
|
if (!this.parent)
|
|
@@ -339,7 +339,7 @@ class ContentView {
|
|
|
339
339
|
// given position.
|
|
340
340
|
coordsAt(_pos, _side) { return null; }
|
|
341
341
|
sync(track) {
|
|
342
|
-
if (this.dirty & 2 /* Node */) {
|
|
342
|
+
if (this.dirty & 2 /* Dirty.Node */) {
|
|
343
343
|
let parent = this.dom;
|
|
344
344
|
let prev = null, next;
|
|
345
345
|
for (let child of this.children) {
|
|
@@ -350,7 +350,7 @@ class ContentView {
|
|
|
350
350
|
child.reuseDOM(next);
|
|
351
351
|
}
|
|
352
352
|
child.sync(track);
|
|
353
|
-
child.dirty = 0 /* Not */;
|
|
353
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
354
354
|
}
|
|
355
355
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
356
356
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -370,11 +370,11 @@ class ContentView {
|
|
|
370
370
|
while (next)
|
|
371
371
|
next = rm$1(next);
|
|
372
372
|
}
|
|
373
|
-
else if (this.dirty & 1 /* Child */) {
|
|
373
|
+
else if (this.dirty & 1 /* Dirty.Child */) {
|
|
374
374
|
for (let child of this.children)
|
|
375
375
|
if (child.dirty) {
|
|
376
376
|
child.sync(track);
|
|
377
|
-
child.dirty = 0 /* Not */;
|
|
377
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -439,16 +439,16 @@ class ContentView {
|
|
|
439
439
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
440
440
|
}
|
|
441
441
|
markDirty(andParent = false) {
|
|
442
|
-
this.dirty |= 2 /* Node */;
|
|
442
|
+
this.dirty |= 2 /* Dirty.Node */;
|
|
443
443
|
this.markParentsDirty(andParent);
|
|
444
444
|
}
|
|
445
445
|
markParentsDirty(childList) {
|
|
446
446
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
447
447
|
if (childList)
|
|
448
|
-
parent.dirty |= 2 /* Node */;
|
|
449
|
-
if (parent.dirty & 1 /* Child */)
|
|
448
|
+
parent.dirty |= 2 /* Dirty.Node */;
|
|
449
|
+
if (parent.dirty & 1 /* Dirty.Child */)
|
|
450
450
|
return;
|
|
451
|
-
parent.dirty |= 1 /* Child */;
|
|
451
|
+
parent.dirty |= 1 /* Dirty.Child */;
|
|
452
452
|
childList = false;
|
|
453
453
|
}
|
|
454
454
|
}
|
|
@@ -724,13 +724,13 @@ class MarkView extends ContentView {
|
|
|
724
724
|
reuseDOM(node) {
|
|
725
725
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
726
726
|
this.setDOM(node);
|
|
727
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
727
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
730
|
sync(track) {
|
|
731
731
|
if (!this.dom)
|
|
732
732
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
733
|
-
else if (this.dirty & 4 /* Attrs */)
|
|
733
|
+
else if (this.dirty & 4 /* Dirty.Attrs */)
|
|
734
734
|
this.setAttrs(this.dom);
|
|
735
735
|
super.sync(track);
|
|
736
736
|
}
|
|
@@ -762,7 +762,7 @@ class MarkView extends ContentView {
|
|
|
762
762
|
return new MarkView(this.mark, result, length);
|
|
763
763
|
}
|
|
764
764
|
domAtPos(pos) {
|
|
765
|
-
return inlineDOMAtPos(this
|
|
765
|
+
return inlineDOMAtPos(this, pos);
|
|
766
766
|
}
|
|
767
767
|
coordsAt(pos, side) {
|
|
768
768
|
return coordsInChildren(this, pos, side);
|
|
@@ -913,11 +913,14 @@ class CompositionView extends WidgetView {
|
|
|
913
913
|
// offset.
|
|
914
914
|
function scanCompositionTree(pos, side, view, text, enterView, fromText) {
|
|
915
915
|
if (view instanceof MarkView) {
|
|
916
|
-
for (let child
|
|
917
|
-
let
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
916
|
+
for (let child = view.dom.firstChild; child; child = child.nextSibling) {
|
|
917
|
+
let desc = ContentView.get(child);
|
|
918
|
+
if (!desc)
|
|
919
|
+
return fromText(pos, side);
|
|
920
|
+
let hasComp = contains(child, text);
|
|
921
|
+
let len = desc.length + (hasComp ? text.nodeValue.length : 0);
|
|
922
|
+
if (pos < len || pos == len && desc.getSide() <= 0)
|
|
923
|
+
return hasComp ? scanCompositionTree(pos, side, desc, text, enterView, fromText) : enterView(desc, pos, side);
|
|
921
924
|
pos -= len;
|
|
922
925
|
}
|
|
923
926
|
return enterView(view, view.length, -1);
|
|
@@ -1007,8 +1010,8 @@ function inlineSiblingRect(view, side) {
|
|
|
1007
1010
|
}
|
|
1008
1011
|
return undefined;
|
|
1009
1012
|
}
|
|
1010
|
-
function inlineDOMAtPos(
|
|
1011
|
-
let i = 0;
|
|
1013
|
+
function inlineDOMAtPos(parent, pos) {
|
|
1014
|
+
let dom = parent.dom, { children } = parent, i = 0;
|
|
1012
1015
|
for (let off = 0; i < children.length; i++) {
|
|
1013
1016
|
let child = children[i], end = off + child.length;
|
|
1014
1017
|
if (end == off && child.getSide() <= 0)
|
|
@@ -1019,10 +1022,16 @@ function inlineDOMAtPos(dom, children, pos) {
|
|
|
1019
1022
|
break;
|
|
1020
1023
|
off = end;
|
|
1021
1024
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1025
|
+
// if (i) return DOMPos.after(children[i - 1].dom!)
|
|
1026
|
+
for (let j = i; j > 0; j--) {
|
|
1027
|
+
let prev = children[j - 1];
|
|
1028
|
+
if (prev.dom.parentNode == dom)
|
|
1029
|
+
return prev.domAtPos(prev.length);
|
|
1030
|
+
}
|
|
1031
|
+
for (let j = i; j < children.length; j++) {
|
|
1032
|
+
let next = children[j];
|
|
1033
|
+
if (next.dom.parentNode == dom)
|
|
1034
|
+
return next.domAtPos(0);
|
|
1026
1035
|
}
|
|
1027
1036
|
return new DOMPos(dom, 0);
|
|
1028
1037
|
}
|
|
@@ -1231,7 +1240,7 @@ class Decoration extends state.RangeValue {
|
|
|
1231
1240
|
*/
|
|
1232
1241
|
static widget(spec) {
|
|
1233
1242
|
let side = spec.side || 0, block = !!spec.block;
|
|
1234
|
-
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1243
|
+
side += block ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */) : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
|
|
1235
1244
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1236
1245
|
}
|
|
1237
1246
|
/**
|
|
@@ -1241,13 +1250,13 @@ class Decoration extends state.RangeValue {
|
|
|
1241
1250
|
static replace(spec) {
|
|
1242
1251
|
let block = !!spec.block, startSide, endSide;
|
|
1243
1252
|
if (spec.isBlockGap) {
|
|
1244
|
-
startSide = -500000000 /* GapStart */;
|
|
1245
|
-
endSide = 400000000 /* GapEnd */;
|
|
1253
|
+
startSide = -500000000 /* Side.GapStart */;
|
|
1254
|
+
endSide = 400000000 /* Side.GapEnd */;
|
|
1246
1255
|
}
|
|
1247
1256
|
else {
|
|
1248
1257
|
let { start, end } = getInclusive(spec, block);
|
|
1249
|
-
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1250
|
-
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1258
|
+
startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
|
|
1259
|
+
endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
|
|
1251
1260
|
}
|
|
1252
1261
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1253
1262
|
}
|
|
@@ -1278,7 +1287,7 @@ Decoration.none = state.RangeSet.empty;
|
|
|
1278
1287
|
class MarkDecoration extends Decoration {
|
|
1279
1288
|
constructor(spec) {
|
|
1280
1289
|
let { start, end } = getInclusive(spec);
|
|
1281
|
-
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1290
|
+
super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
|
|
1282
1291
|
this.tagName = spec.tagName || "span";
|
|
1283
1292
|
this.class = spec.class || "";
|
|
1284
1293
|
this.attrs = spec.attributes || null;
|
|
@@ -1299,7 +1308,7 @@ class MarkDecoration extends Decoration {
|
|
|
1299
1308
|
MarkDecoration.prototype.point = false;
|
|
1300
1309
|
class LineDecoration extends Decoration {
|
|
1301
1310
|
constructor(spec) {
|
|
1302
|
-
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1311
|
+
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1303
1312
|
}
|
|
1304
1313
|
eq(other) {
|
|
1305
1314
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1431,12 +1440,12 @@ class LineView extends ContentView {
|
|
|
1431
1440
|
this.attrs = combineAttrs({ class: cls }, this.attrs || {});
|
|
1432
1441
|
}
|
|
1433
1442
|
domAtPos(pos) {
|
|
1434
|
-
return inlineDOMAtPos(this
|
|
1443
|
+
return inlineDOMAtPos(this, pos);
|
|
1435
1444
|
}
|
|
1436
1445
|
reuseDOM(node) {
|
|
1437
1446
|
if (node.nodeName == "DIV") {
|
|
1438
1447
|
this.setDOM(node);
|
|
1439
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1448
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
1440
1449
|
}
|
|
1441
1450
|
}
|
|
1442
1451
|
sync(track) {
|
|
@@ -1446,7 +1455,7 @@ class LineView extends ContentView {
|
|
|
1446
1455
|
this.dom.className = "cm-line";
|
|
1447
1456
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1448
1457
|
}
|
|
1449
|
-
else if (this.dirty & 4 /* Attrs */) {
|
|
1458
|
+
else if (this.dirty & 4 /* Dirty.Attrs */) {
|
|
1450
1459
|
clearAttributes(this.dom);
|
|
1451
1460
|
this.dom.className = "cm-line";
|
|
1452
1461
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1576,7 +1585,7 @@ class ContentBuilder {
|
|
|
1576
1585
|
this.content = [];
|
|
1577
1586
|
this.curLine = null;
|
|
1578
1587
|
this.breakAtStart = 0;
|
|
1579
|
-
this.pendingBuffer = 0 /* No */;
|
|
1588
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1580
1589
|
// Set to false directly after a widget that covers the position after it
|
|
1581
1590
|
this.atCursorPos = true;
|
|
1582
1591
|
this.openStart = -1;
|
|
@@ -1602,7 +1611,7 @@ class ContentBuilder {
|
|
|
1602
1611
|
flushBuffer(active) {
|
|
1603
1612
|
if (this.pendingBuffer) {
|
|
1604
1613
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1605
|
-
this.pendingBuffer = 0 /* No */;
|
|
1614
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1606
1615
|
}
|
|
1607
1616
|
}
|
|
1608
1617
|
addBlockWidget(view) {
|
|
@@ -1614,7 +1623,7 @@ class ContentBuilder {
|
|
|
1614
1623
|
if (!openEnd)
|
|
1615
1624
|
this.flushBuffer([]);
|
|
1616
1625
|
else
|
|
1617
|
-
this.pendingBuffer = 0 /* No */;
|
|
1626
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1618
1627
|
if (!this.posCovered())
|
|
1619
1628
|
this.getLine();
|
|
1620
1629
|
}
|
|
@@ -1642,7 +1651,7 @@ class ContentBuilder {
|
|
|
1642
1651
|
this.textOff = 0;
|
|
1643
1652
|
}
|
|
1644
1653
|
}
|
|
1645
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1654
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
|
|
1646
1655
|
this.flushBuffer(active.slice(0, openStart));
|
|
1647
1656
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1648
1657
|
this.atCursorPos = true;
|
|
@@ -1677,8 +1686,8 @@ class ContentBuilder {
|
|
|
1677
1686
|
let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
|
|
1678
1687
|
let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
|
|
1679
1688
|
let line = this.getLine();
|
|
1680
|
-
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
|
|
1681
|
-
this.pendingBuffer = 0 /* No */;
|
|
1689
|
+
if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore)
|
|
1690
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1682
1691
|
this.flushBuffer(active);
|
|
1683
1692
|
if (cursorBefore) {
|
|
1684
1693
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1686,7 +1695,7 @@ class ContentBuilder {
|
|
|
1686
1695
|
}
|
|
1687
1696
|
line.append(wrapMarks(view, active), openStart);
|
|
1688
1697
|
this.atCursorPos = cursorAfter;
|
|
1689
|
-
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1698
|
+
this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
|
|
1690
1699
|
}
|
|
1691
1700
|
}
|
|
1692
1701
|
else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
|
|
@@ -1979,7 +1988,7 @@ class ViewUpdate {
|
|
|
1979
1988
|
let focus = view.hasFocus;
|
|
1980
1989
|
if (focus != view.inputState.notifiedFocused) {
|
|
1981
1990
|
view.inputState.notifiedFocused = focus;
|
|
1982
|
-
this.flags |= 1 /* Focus */;
|
|
1991
|
+
this.flags |= 1 /* UpdateFlag.Focus */;
|
|
1983
1992
|
}
|
|
1984
1993
|
}
|
|
1985
1994
|
/**
|
|
@@ -1994,27 +2003,27 @@ class ViewUpdate {
|
|
|
1994
2003
|
update.
|
|
1995
2004
|
*/
|
|
1996
2005
|
get viewportChanged() {
|
|
1997
|
-
return (this.flags & 4 /* Viewport */) > 0;
|
|
2006
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
1998
2007
|
}
|
|
1999
2008
|
/**
|
|
2000
2009
|
Indicates whether the height of a block element in the editor
|
|
2001
2010
|
changed in this update.
|
|
2002
2011
|
*/
|
|
2003
2012
|
get heightChanged() {
|
|
2004
|
-
return (this.flags & 2 /* Height */) > 0;
|
|
2013
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2005
2014
|
}
|
|
2006
2015
|
/**
|
|
2007
2016
|
Returns true when the document was modified or the size of the
|
|
2008
2017
|
editor, or elements within the editor, changed.
|
|
2009
2018
|
*/
|
|
2010
2019
|
get geometryChanged() {
|
|
2011
|
-
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2020
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2012
2021
|
}
|
|
2013
2022
|
/**
|
|
2014
2023
|
True when this update indicates a focus change.
|
|
2015
2024
|
*/
|
|
2016
2025
|
get focusChanged() {
|
|
2017
|
-
return (this.flags & 1 /* Focus */) > 0;
|
|
2026
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2018
2027
|
}
|
|
2019
2028
|
/**
|
|
2020
2029
|
Whether the document changed in this update.
|
|
@@ -2073,13 +2082,14 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2073
2082
|
}
|
|
2074
2083
|
function charType(ch) {
|
|
2075
2084
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2076
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2085
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2077
2086
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2078
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2079
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2080
|
-
ch
|
|
2087
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2088
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :
|
|
2089
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :
|
|
2090
|
+
ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;
|
|
2081
2091
|
}
|
|
2082
|
-
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
|
2092
|
+
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2083
2093
|
/**
|
|
2084
2094
|
Represents a contiguous range of text that has a single direction
|
|
2085
2095
|
(as in left-to-right or right-to-left).
|
|
@@ -2142,8 +2152,8 @@ class BidiSpan {
|
|
|
2142
2152
|
// Reused array of character types
|
|
2143
2153
|
const types = [];
|
|
2144
2154
|
function computeOrder(line, direction) {
|
|
2145
|
-
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2146
|
-
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2155
|
+
let len = line.length, outerType = direction == LTR ? 1 /* T.L */ : 2 /* T.R */, oppositeType = direction == LTR ? 2 /* T.R */ : 1 /* T.L */;
|
|
2156
|
+
if (!line || outerType == 1 /* T.L */ && !BidiRE.test(line))
|
|
2147
2157
|
return trivialOrder(len);
|
|
2148
2158
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2149
2159
|
// change the type of the NSM to the type of the previous
|
|
@@ -2157,12 +2167,12 @@ function computeOrder(line, direction) {
|
|
|
2157
2167
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2158
2168
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2159
2169
|
let type = charType(line.charCodeAt(i));
|
|
2160
|
-
if (type == 512 /* NSM */)
|
|
2170
|
+
if (type == 512 /* T.NSM */)
|
|
2161
2171
|
type = prev;
|
|
2162
|
-
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2163
|
-
type = 16 /* AN */;
|
|
2164
|
-
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2165
|
-
if (type & 7 /* Strong */)
|
|
2172
|
+
else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
|
|
2173
|
+
type = 16 /* T.AN */;
|
|
2174
|
+
types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
|
|
2175
|
+
if (type & 7 /* T.Strong */)
|
|
2166
2176
|
prevStrong = type;
|
|
2167
2177
|
prev = type;
|
|
2168
2178
|
}
|
|
@@ -2176,26 +2186,26 @@ function computeOrder(line, direction) {
|
|
|
2176
2186
|
// (Left after this: L, R, EN+AN, NI)
|
|
2177
2187
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2178
2188
|
let type = types[i];
|
|
2179
|
-
if (type == 128 /* CS */) {
|
|
2180
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2189
|
+
if (type == 128 /* T.CS */) {
|
|
2190
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
|
|
2181
2191
|
type = types[i] = prev;
|
|
2182
2192
|
else
|
|
2183
|
-
types[i] = 256 /* NI */;
|
|
2193
|
+
types[i] = 256 /* T.NI */;
|
|
2184
2194
|
}
|
|
2185
|
-
else if (type == 64 /* ET */) {
|
|
2195
|
+
else if (type == 64 /* T.ET */) {
|
|
2186
2196
|
let end = i + 1;
|
|
2187
|
-
while (end < len && types[end] == 64 /* ET */)
|
|
2197
|
+
while (end < len && types[end] == 64 /* T.ET */)
|
|
2188
2198
|
end++;
|
|
2189
|
-
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2199
|
+
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 */;
|
|
2190
2200
|
for (let j = i; j < end; j++)
|
|
2191
2201
|
types[j] = replace;
|
|
2192
2202
|
i = end - 1;
|
|
2193
2203
|
}
|
|
2194
|
-
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2195
|
-
types[i] = 1 /* L */;
|
|
2204
|
+
else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
|
|
2205
|
+
types[i] = 1 /* T.L */;
|
|
2196
2206
|
}
|
|
2197
2207
|
prev = type;
|
|
2198
|
-
if (type & 7 /* Strong */)
|
|
2208
|
+
if (type & 7 /* T.Strong */)
|
|
2199
2209
|
prevStrong = type;
|
|
2200
2210
|
}
|
|
2201
2211
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2210,9 +2220,9 @@ function computeOrder(line, direction) {
|
|
|
2210
2220
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2211
2221
|
if (BracketStack[sJ + 1] == -br) {
|
|
2212
2222
|
let flags = BracketStack[sJ + 2];
|
|
2213
|
-
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2214
|
-
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2215
|
-
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2223
|
+
let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
|
|
2224
|
+
!(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
|
|
2225
|
+
(flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
|
|
2216
2226
|
if (type)
|
|
2217
2227
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2218
2228
|
sI = sJ;
|
|
@@ -2220,7 +2230,7 @@ function computeOrder(line, direction) {
|
|
|
2220
2230
|
}
|
|
2221
2231
|
}
|
|
2222
2232
|
}
|
|
2223
|
-
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2233
|
+
else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
|
|
2224
2234
|
break;
|
|
2225
2235
|
}
|
|
2226
2236
|
else {
|
|
@@ -2229,20 +2239,20 @@ function computeOrder(line, direction) {
|
|
|
2229
2239
|
BracketStack[sI++] = context;
|
|
2230
2240
|
}
|
|
2231
2241
|
}
|
|
2232
|
-
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2242
|
+
else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
|
|
2233
2243
|
let embed = type == outerType;
|
|
2234
|
-
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2244
|
+
context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
|
|
2235
2245
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2236
2246
|
let cur = BracketStack[sJ + 2];
|
|
2237
|
-
if (cur & 2 /* EmbedInside */)
|
|
2247
|
+
if (cur & 2 /* Bracketed.EmbedInside */)
|
|
2238
2248
|
break;
|
|
2239
2249
|
if (embed) {
|
|
2240
|
-
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2250
|
+
BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
|
|
2241
2251
|
}
|
|
2242
2252
|
else {
|
|
2243
|
-
if (cur & 4 /* OppositeInside */)
|
|
2253
|
+
if (cur & 4 /* Bracketed.OppositeInside */)
|
|
2244
2254
|
break;
|
|
2245
|
-
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2255
|
+
BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
|
|
2246
2256
|
}
|
|
2247
2257
|
}
|
|
2248
2258
|
}
|
|
@@ -2255,13 +2265,13 @@ function computeOrder(line, direction) {
|
|
|
2255
2265
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2256
2266
|
// (Left after this: L, R, EN+AN)
|
|
2257
2267
|
for (let i = 0; i < len; i++) {
|
|
2258
|
-
if (types[i] == 256 /* NI */) {
|
|
2268
|
+
if (types[i] == 256 /* T.NI */) {
|
|
2259
2269
|
let end = i + 1;
|
|
2260
|
-
while (end < len && types[end] == 256 /* NI */)
|
|
2270
|
+
while (end < len && types[end] == 256 /* T.NI */)
|
|
2261
2271
|
end++;
|
|
2262
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2263
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2264
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2272
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* T.L */;
|
|
2273
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* T.L */;
|
|
2274
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
|
|
2265
2275
|
for (let j = i; j < end; j++)
|
|
2266
2276
|
types[j] = replace;
|
|
2267
2277
|
i = end - 1;
|
|
@@ -2273,15 +2283,15 @@ function computeOrder(line, direction) {
|
|
|
2273
2283
|
// explicit embedding into account, we can build up the order on
|
|
2274
2284
|
// the fly, without following the level-based algorithm.
|
|
2275
2285
|
let order = [];
|
|
2276
|
-
if (outerType == 1 /* L */) {
|
|
2286
|
+
if (outerType == 1 /* T.L */) {
|
|
2277
2287
|
for (let i = 0; i < len;) {
|
|
2278
|
-
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2279
|
-
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2288
|
+
let start = i, rtl = types[i++] != 1 /* T.L */;
|
|
2289
|
+
while (i < len && rtl == (types[i] != 1 /* T.L */))
|
|
2280
2290
|
i++;
|
|
2281
2291
|
if (rtl) {
|
|
2282
2292
|
for (let j = i; j > start;) {
|
|
2283
|
-
let end = j, l = types[--j] != 2 /* R */;
|
|
2284
|
-
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2293
|
+
let end = j, l = types[--j] != 2 /* T.R */;
|
|
2294
|
+
while (j > start && l == (types[j - 1] != 2 /* T.R */))
|
|
2285
2295
|
j--;
|
|
2286
2296
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2287
2297
|
}
|
|
@@ -2293,8 +2303,8 @@ function computeOrder(line, direction) {
|
|
|
2293
2303
|
}
|
|
2294
2304
|
else {
|
|
2295
2305
|
for (let i = 0; i < len;) {
|
|
2296
|
-
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2297
|
-
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2306
|
+
let start = i, rtl = types[i++] == 2 /* T.R */;
|
|
2307
|
+
while (i < len && rtl == (types[i] == 2 /* T.R */))
|
|
2298
2308
|
i++;
|
|
2299
2309
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2300
2310
|
}
|
|
@@ -2515,7 +2525,7 @@ class DocView extends ContentView {
|
|
|
2515
2525
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2516
2526
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2517
2527
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2518
|
-
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2528
|
+
if (this.dirty == 0 /* Dirty.Not */ && changedRanges.length == 0) {
|
|
2519
2529
|
return false;
|
|
2520
2530
|
}
|
|
2521
2531
|
else {
|
|
@@ -2544,7 +2554,7 @@ class DocView extends ContentView {
|
|
|
2544
2554
|
// to detect that situation.
|
|
2545
2555
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2546
2556
|
this.sync(track);
|
|
2547
|
-
this.dirty = 0 /* Not */;
|
|
2557
|
+
this.dirty = 0 /* Dirty.Not */;
|
|
2548
2558
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2549
2559
|
this.forceSelection = true;
|
|
2550
2560
|
this.dom.style.height = "";
|
|
@@ -2573,8 +2583,7 @@ class DocView extends ContentView {
|
|
|
2573
2583
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2574
2584
|
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2575
2585
|
this.view.observer.readSelectionRange();
|
|
2576
|
-
if (!(fromPointer || this.mayControlSelection())
|
|
2577
|
-
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
2586
|
+
if (!(fromPointer || this.mayControlSelection()))
|
|
2578
2587
|
return;
|
|
2579
2588
|
let force = this.forceSelection;
|
|
2580
2589
|
this.forceSelection = false;
|
|
@@ -2611,10 +2620,10 @@ class DocView extends ContentView {
|
|
|
2611
2620
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2612
2621
|
if (browser.gecko) {
|
|
2613
2622
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2614
|
-
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2615
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2623
|
+
if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
|
|
2624
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);
|
|
2616
2625
|
if (text)
|
|
2617
|
-
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2626
|
+
anchor = new DOMPos(text, nextTo == 1 /* NextTo.Before */ ? 0 : text.nodeValue.length);
|
|
2618
2627
|
}
|
|
2619
2628
|
}
|
|
2620
2629
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -2946,8 +2955,8 @@ function nearbyTextNode(node, offset, side) {
|
|
|
2946
2955
|
function nextToUneditable(node, offset) {
|
|
2947
2956
|
if (node.nodeType != 1)
|
|
2948
2957
|
return 0;
|
|
2949
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
2950
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
2958
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
|
|
2959
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
|
|
2951
2960
|
}
|
|
2952
2961
|
class DecorationComparator$1 {
|
|
2953
2962
|
constructor() {
|
|
@@ -3302,7 +3311,7 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3302
3311
|
for (let set of atoms) {
|
|
3303
3312
|
set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
|
|
3304
3313
|
if (pos.from > from && pos.from < to) {
|
|
3305
|
-
pos = oldPos.
|
|
3314
|
+
pos = oldPos.head > pos.from ? state.EditorSelection.cursor(from, 1) : state.EditorSelection.cursor(to, -1);
|
|
3306
3315
|
moved = true;
|
|
3307
3316
|
}
|
|
3308
3317
|
});
|
|
@@ -3344,7 +3353,6 @@ class InputState {
|
|
|
3344
3353
|
// composition)
|
|
3345
3354
|
this.compositionFirstChange = null;
|
|
3346
3355
|
this.compositionEndedAt = 0;
|
|
3347
|
-
this.rapidCompositionStart = false;
|
|
3348
3356
|
this.mouseSelection = null;
|
|
3349
3357
|
for (let type in handlers) {
|
|
3350
3358
|
let handler = handlers[type];
|
|
@@ -3458,9 +3466,10 @@ class InputState {
|
|
|
3458
3466
|
// applyDOMChange, notify key handlers of it and reset to
|
|
3459
3467
|
// the state they produce.
|
|
3460
3468
|
let pending;
|
|
3461
|
-
if (browser.ios &&
|
|
3462
|
-
|
|
3463
|
-
|
|
3469
|
+
if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&
|
|
3470
|
+
((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||
|
|
3471
|
+
EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
|
|
3472
|
+
this.pendingIOSKey = pending || event;
|
|
3464
3473
|
setTimeout(() => this.flushIOSKey(view), 250);
|
|
3465
3474
|
return true;
|
|
3466
3475
|
}
|
|
@@ -3491,8 +3500,7 @@ class InputState {
|
|
|
3491
3500
|
return false;
|
|
3492
3501
|
}
|
|
3493
3502
|
mustFlushObserver(event) {
|
|
3494
|
-
return
|
|
3495
|
-
event.type == "compositionend" && !browser.ios;
|
|
3503
|
+
return event.type == "keydown" && event.keyCode != 229;
|
|
3496
3504
|
}
|
|
3497
3505
|
startMouseSelection(mouseSelection) {
|
|
3498
3506
|
if (this.mouseSelection)
|
|
@@ -3515,6 +3523,7 @@ const PendingKeys = [
|
|
|
3515
3523
|
{ key: "Enter", keyCode: 13, inputType: "insertParagraph" },
|
|
3516
3524
|
{ key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
|
|
3517
3525
|
];
|
|
3526
|
+
const EmacsyPendingKeys = "dthko";
|
|
3518
3527
|
// Key codes for modifier keys
|
|
3519
3528
|
const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
|
|
3520
3529
|
class MouseSelection {
|
|
@@ -3759,8 +3768,7 @@ function basicMouseSelection(view, event) {
|
|
|
3759
3768
|
return {
|
|
3760
3769
|
update(update) {
|
|
3761
3770
|
if (update.docChanged) {
|
|
3762
|
-
|
|
3763
|
-
start.pos = update.changes.mapPos(start.pos);
|
|
3771
|
+
start.pos = update.changes.mapPos(start.pos);
|
|
3764
3772
|
startSel = startSel.map(update.changes);
|
|
3765
3773
|
lastEvent = null;
|
|
3766
3774
|
}
|
|
@@ -3773,8 +3781,6 @@ function basicMouseSelection(view, event) {
|
|
|
3773
3781
|
cur = last = queryPos(view, event);
|
|
3774
3782
|
lastEvent = event;
|
|
3775
3783
|
}
|
|
3776
|
-
if (!cur || !start)
|
|
3777
|
-
return startSel;
|
|
3778
3784
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3779
3785
|
if (start.pos != cur.pos && !extend) {
|
|
3780
3786
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -3946,36 +3952,24 @@ handlers.blur = view => {
|
|
|
3946
3952
|
view.observer.clearSelectionRange();
|
|
3947
3953
|
updateForFocusChange(view);
|
|
3948
3954
|
};
|
|
3949
|
-
function forceClearComposition(view, rapid) {
|
|
3950
|
-
if (view.docView.compositionDeco.size) {
|
|
3951
|
-
view.inputState.rapidCompositionStart = rapid;
|
|
3952
|
-
try {
|
|
3953
|
-
view.update([]);
|
|
3954
|
-
}
|
|
3955
|
-
finally {
|
|
3956
|
-
view.inputState.rapidCompositionStart = false;
|
|
3957
|
-
}
|
|
3958
|
-
}
|
|
3959
|
-
}
|
|
3960
3955
|
handlers.compositionstart = handlers.compositionupdate = view => {
|
|
3961
3956
|
if (view.inputState.compositionFirstChange == null)
|
|
3962
3957
|
view.inputState.compositionFirstChange = true;
|
|
3963
3958
|
if (view.inputState.composing < 0) {
|
|
3964
3959
|
// FIXME possibly set a timeout to clear it again on Android
|
|
3965
3960
|
view.inputState.composing = 0;
|
|
3966
|
-
if (view.docView.compositionDeco.size) {
|
|
3967
|
-
view.observer.flush();
|
|
3968
|
-
forceClearComposition(view, true);
|
|
3969
|
-
}
|
|
3970
3961
|
}
|
|
3971
3962
|
};
|
|
3972
3963
|
handlers.compositionend = view => {
|
|
3973
3964
|
view.inputState.composing = -1;
|
|
3974
3965
|
view.inputState.compositionEndedAt = Date.now();
|
|
3975
3966
|
view.inputState.compositionFirstChange = null;
|
|
3967
|
+
if (browser.chrome && browser.android)
|
|
3968
|
+
view.observer.flushSoon();
|
|
3976
3969
|
setTimeout(() => {
|
|
3977
|
-
if
|
|
3978
|
-
|
|
3970
|
+
// Force the composition state to be cleared if it hasn't already been
|
|
3971
|
+
if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
|
|
3972
|
+
view.update([]);
|
|
3979
3973
|
}, 50);
|
|
3980
3974
|
};
|
|
3981
3975
|
handlers.contextmenu = view => {
|
|
@@ -4146,13 +4140,13 @@ const Epsilon = 1e-3;
|
|
|
4146
4140
|
class HeightMap {
|
|
4147
4141
|
constructor(length, // The number of characters covered
|
|
4148
4142
|
height, // Height of this part of the document
|
|
4149
|
-
flags = 2 /* Outdated */) {
|
|
4143
|
+
flags = 2 /* Flag.Outdated */) {
|
|
4150
4144
|
this.length = length;
|
|
4151
4145
|
this.height = height;
|
|
4152
4146
|
this.flags = flags;
|
|
4153
4147
|
}
|
|
4154
|
-
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4155
|
-
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4148
|
+
get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
|
|
4149
|
+
set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
|
|
4156
4150
|
setHeight(oracle, height) {
|
|
4157
4151
|
if (this.height != height) {
|
|
4158
4152
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4279,7 +4273,7 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4279
4273
|
}
|
|
4280
4274
|
replace(_from, _to, nodes) {
|
|
4281
4275
|
let node = nodes[0];
|
|
4282
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4276
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
|
|
4283
4277
|
Math.abs(this.length - node.length) < 10) {
|
|
4284
4278
|
if (node instanceof HeightMapGap)
|
|
4285
4279
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4405,12 +4399,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4405
4399
|
}
|
|
4406
4400
|
class HeightMapBranch extends HeightMap {
|
|
4407
4401
|
constructor(left, brk, right) {
|
|
4408
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4402
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
|
|
4409
4403
|
this.left = left;
|
|
4410
4404
|
this.right = right;
|
|
4411
4405
|
this.size = left.size + right.size;
|
|
4412
4406
|
}
|
|
4413
|
-
get break() { return this.flags & 1 /* Break */; }
|
|
4407
|
+
get break() { return this.flags & 1 /* Flag.Break */; }
|
|
4414
4408
|
blockAt(height, doc, top, offset) {
|
|
4415
4409
|
let mid = top + this.left.height;
|
|
4416
4410
|
return height < mid ? this.left.blockAt(height, doc, top, offset)
|
|
@@ -4594,7 +4588,7 @@ class NodeBuilder {
|
|
|
4594
4588
|
blankContent(from, to) {
|
|
4595
4589
|
let gap = new HeightMapGap(to - from);
|
|
4596
4590
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4597
|
-
gap.flags |= 4 /* SingleLine */;
|
|
4591
|
+
gap.flags |= 4 /* Flag.SingleLine */;
|
|
4598
4592
|
return gap;
|
|
4599
4593
|
}
|
|
4600
4594
|
ensureLine() {
|
|
@@ -4792,7 +4786,7 @@ class ViewState {
|
|
|
4792
4786
|
}
|
|
4793
4787
|
}
|
|
4794
4788
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
4795
|
-
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
4789
|
+
this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
|
|
4796
4790
|
new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
|
|
4797
4791
|
}
|
|
4798
4792
|
updateViewportLines() {
|
|
@@ -4810,18 +4804,18 @@ class ViewState {
|
|
|
4810
4804
|
let prevHeight = this.heightMap.height;
|
|
4811
4805
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
4812
4806
|
if (this.heightMap.height != prevHeight)
|
|
4813
|
-
update.flags |= 2 /* Height */;
|
|
4807
|
+
update.flags |= 2 /* UpdateFlag.Height */;
|
|
4814
4808
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
4815
4809
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
4816
4810
|
!this.viewportIsAppropriate(viewport))
|
|
4817
4811
|
viewport = this.getViewport(0, scrollTarget);
|
|
4818
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
4812
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||
|
|
4819
4813
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
4820
4814
|
this.viewport = viewport;
|
|
4821
4815
|
this.updateForViewport();
|
|
4822
4816
|
if (updateLines)
|
|
4823
4817
|
this.updateViewportLines();
|
|
4824
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4818
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4825
4819
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
4826
4820
|
update.flags |= this.computeVisibleRanges();
|
|
4827
4821
|
if (scrollTarget)
|
|
@@ -4845,13 +4839,13 @@ class ViewState {
|
|
|
4845
4839
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4846
4840
|
this.paddingTop = paddingTop;
|
|
4847
4841
|
this.paddingBottom = paddingBottom;
|
|
4848
|
-
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4842
|
+
result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
|
|
4849
4843
|
}
|
|
4850
4844
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4851
4845
|
if (oracle.lineWrapping)
|
|
4852
4846
|
measureContent = true;
|
|
4853
4847
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4854
|
-
result |= 8 /* Geometry */;
|
|
4848
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4855
4849
|
}
|
|
4856
4850
|
// Pixel viewport
|
|
4857
4851
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
@@ -4869,7 +4863,7 @@ class ViewState {
|
|
|
4869
4863
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
4870
4864
|
this.contentDOMWidth = contentWidth;
|
|
4871
4865
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
4872
|
-
result |= 8 /* Geometry */;
|
|
4866
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4873
4867
|
}
|
|
4874
4868
|
if (measureContent) {
|
|
4875
4869
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -4880,7 +4874,7 @@ class ViewState {
|
|
|
4880
4874
|
refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
|
|
4881
4875
|
if (refresh) {
|
|
4882
4876
|
view.docView.minWidth = 0;
|
|
4883
|
-
result |= 8 /* Geometry */;
|
|
4877
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4884
4878
|
}
|
|
4885
4879
|
}
|
|
4886
4880
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -4893,16 +4887,16 @@ class ViewState {
|
|
|
4893
4887
|
this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
4894
4888
|
}
|
|
4895
4889
|
if (oracle.heightChanged)
|
|
4896
|
-
result |= 2 /* Height */;
|
|
4890
|
+
result |= 2 /* UpdateFlag.Height */;
|
|
4897
4891
|
}
|
|
4898
4892
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
4899
4893
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
|
|
4900
4894
|
if (viewportChange)
|
|
4901
4895
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
4902
4896
|
this.updateForViewport();
|
|
4903
|
-
if ((result & 2 /* Height */) || viewportChange)
|
|
4897
|
+
if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
|
|
4904
4898
|
this.updateViewportLines();
|
|
4905
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4899
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4906
4900
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
|
|
4907
4901
|
result |= this.computeVisibleRanges();
|
|
4908
4902
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -4921,9 +4915,9 @@ class ViewState {
|
|
|
4921
4915
|
// This will divide VP.Margin between the top and the
|
|
4922
4916
|
// bottom, depending on the bias (the change in viewport position
|
|
4923
4917
|
// since the last update). It'll hold a number between 0 and 1
|
|
4924
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
4918
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
|
|
4925
4919
|
let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
|
|
4926
|
-
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);
|
|
4920
|
+
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);
|
|
4927
4921
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
4928
4922
|
if (scrollTarget) {
|
|
4929
4923
|
let { head } = scrollTarget.range;
|
|
@@ -4936,7 +4930,7 @@ class ViewState {
|
|
|
4936
4930
|
topPos = block.top;
|
|
4937
4931
|
else
|
|
4938
4932
|
topPos = block.bottom - viewHeight;
|
|
4939
|
-
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);
|
|
4933
|
+
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);
|
|
4940
4934
|
}
|
|
4941
4935
|
}
|
|
4942
4936
|
return viewport;
|
|
@@ -4953,10 +4947,10 @@ class ViewState {
|
|
|
4953
4947
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4954
4948
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4955
4949
|
let { visibleTop, visibleBottom } = this;
|
|
4956
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
4950
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4957
4951
|
(to == this.state.doc.length ||
|
|
4958
|
-
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
4959
|
-
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
4952
|
+
bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4953
|
+
(top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
|
|
4960
4954
|
}
|
|
4961
4955
|
mapLineGaps(gaps, changes) {
|
|
4962
4956
|
if (!gaps.length || changes.empty)
|
|
@@ -4980,20 +4974,20 @@ class ViewState {
|
|
|
4980
4974
|
if (this.defaultTextDirection != exports.Direction.LTR)
|
|
4981
4975
|
return gaps;
|
|
4982
4976
|
for (let line of this.viewportLines) {
|
|
4983
|
-
if (line.length < 4000 /* DoubleMargin */)
|
|
4977
|
+
if (line.length < 4000 /* LG.DoubleMargin */)
|
|
4984
4978
|
continue;
|
|
4985
4979
|
let structure = lineStructure(line.from, line.to, this.stateDeco);
|
|
4986
|
-
if (structure.total < 4000 /* DoubleMargin */)
|
|
4980
|
+
if (structure.total < 4000 /* LG.DoubleMargin */)
|
|
4987
4981
|
continue;
|
|
4988
4982
|
let viewFrom, viewTo;
|
|
4989
4983
|
if (this.heightOracle.lineWrapping) {
|
|
4990
|
-
let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4984
|
+
let marginHeight = (2000 /* LG.Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4991
4985
|
viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
|
|
4992
4986
|
viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
|
|
4993
4987
|
}
|
|
4994
4988
|
else {
|
|
4995
4989
|
let totalWidth = structure.total * this.heightOracle.charWidth;
|
|
4996
|
-
let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
|
|
4990
|
+
let marginWidth = 2000 /* LG.Margin */ * this.heightOracle.charWidth;
|
|
4997
4991
|
viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
|
|
4998
4992
|
viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
|
|
4999
4993
|
}
|
|
@@ -5005,13 +4999,13 @@ class ViewState {
|
|
|
5005
4999
|
let sel = this.state.selection.main;
|
|
5006
5000
|
// Make sure the gaps don't cover a selection end
|
|
5007
5001
|
if (sel.from >= line.from && sel.from <= line.to)
|
|
5008
|
-
cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
|
|
5002
|
+
cutRange(outside, sel.from - 10 /* LG.SelectionMargin */, sel.from + 10 /* LG.SelectionMargin */);
|
|
5009
5003
|
if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
|
|
5010
|
-
cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
|
|
5004
|
+
cutRange(outside, sel.to - 10 /* LG.SelectionMargin */, sel.to + 10 /* LG.SelectionMargin */);
|
|
5011
5005
|
for (let { from, to } of outside)
|
|
5012
|
-
if (to - from > 1000 /* HalfMargin */) {
|
|
5006
|
+
if (to - from > 1000 /* LG.HalfMargin */) {
|
|
5013
5007
|
gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
|
|
5014
|
-
Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
|
|
5008
|
+
Math.abs(gap.from - from) < 1000 /* LG.HalfMargin */ && Math.abs(gap.to - to) < 1000 /* LG.HalfMargin */) ||
|
|
5015
5009
|
new LineGap(from, to, this.gapSize(line, from, to, structure)));
|
|
5016
5010
|
}
|
|
5017
5011
|
}
|
|
@@ -5044,7 +5038,7 @@ class ViewState {
|
|
|
5044
5038
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5045
5039
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5046
5040
|
this.visibleRanges = ranges;
|
|
5047
|
-
return changed ? 4 /* Viewport */ : 0;
|
|
5041
|
+
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
5048
5042
|
}
|
|
5049
5043
|
lineBlockAt(pos) {
|
|
5050
5044
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5150,7 +5144,7 @@ class BigScaler {
|
|
|
5150
5144
|
vpHeight += bottom - top;
|
|
5151
5145
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5152
5146
|
});
|
|
5153
|
-
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5147
|
+
this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5154
5148
|
for (let obj of this.viewports) {
|
|
5155
5149
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5156
5150
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5453,6 +5447,7 @@ class DOMObserver {
|
|
|
5453
5447
|
this.resizeTimeout = -1;
|
|
5454
5448
|
this.queue = [];
|
|
5455
5449
|
this.delayedAndroidKey = null;
|
|
5450
|
+
this.lastChange = 0;
|
|
5456
5451
|
this.scrollTargets = [];
|
|
5457
5452
|
this.intersection = null;
|
|
5458
5453
|
this.resize = null;
|
|
@@ -5499,8 +5494,7 @@ class DOMObserver {
|
|
|
5499
5494
|
});
|
|
5500
5495
|
this.resize.observe(view.scrollDOM);
|
|
5501
5496
|
}
|
|
5502
|
-
this.win = view.
|
|
5503
|
-
this.addWindowListeners(this.win);
|
|
5497
|
+
this.addWindowListeners(this.win = view.win);
|
|
5504
5498
|
this.start();
|
|
5505
5499
|
if (typeof IntersectionObserver == "function") {
|
|
5506
5500
|
this.intersection = new IntersectionObserver(entries => {
|
|
@@ -5550,14 +5544,18 @@ class DOMObserver {
|
|
|
5550
5544
|
}
|
|
5551
5545
|
}
|
|
5552
5546
|
onSelectionChange(event) {
|
|
5547
|
+
let wasChanged = this.selectionChanged;
|
|
5553
5548
|
if (!this.readSelectionRange() || this.delayedAndroidKey)
|
|
5554
5549
|
return;
|
|
5555
5550
|
let { view } = this, sel = this.selectionRange;
|
|
5556
5551
|
if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))
|
|
5557
5552
|
return;
|
|
5558
5553
|
let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
|
|
5559
|
-
if (context && context.ignoreEvent(event))
|
|
5554
|
+
if (context && context.ignoreEvent(event)) {
|
|
5555
|
+
if (!wasChanged)
|
|
5556
|
+
this.selectionChanged = false;
|
|
5560
5557
|
return;
|
|
5558
|
+
}
|
|
5561
5559
|
// Deletions on IE11 fire their events in the wrong order, giving
|
|
5562
5560
|
// us a selection change event before the DOM changes are
|
|
5563
5561
|
// reported.
|
|
@@ -5574,7 +5572,8 @@ class DOMObserver {
|
|
|
5574
5572
|
let { view } = this;
|
|
5575
5573
|
// The Selection object is broken in shadow roots in Safari. See
|
|
5576
5574
|
// https://github.com/codemirror/dev/issues/414
|
|
5577
|
-
let range = browser.safari && view.root.nodeType == 11 &&
|
|
5575
|
+
let range = browser.safari && view.root.nodeType == 11 &&
|
|
5576
|
+
deepActiveElement(this.dom.ownerDocument) == this.dom &&
|
|
5578
5577
|
safariSelectionRangeHack(this.view) || getSelection(view.root);
|
|
5579
5578
|
if (!range || this.selectionRange.eq(range))
|
|
5580
5579
|
return false;
|
|
@@ -5674,26 +5673,34 @@ class DOMObserver {
|
|
|
5674
5673
|
// detected (via beforeinput or keydown), and then tries to flush
|
|
5675
5674
|
// them or, if that has no effect, dispatches the given key.
|
|
5676
5675
|
delayAndroidKey(key, keyCode) {
|
|
5676
|
+
var _a;
|
|
5677
5677
|
if (!this.delayedAndroidKey)
|
|
5678
|
-
requestAnimationFrame(() => {
|
|
5678
|
+
this.view.win.requestAnimationFrame(() => {
|
|
5679
5679
|
let key = this.delayedAndroidKey;
|
|
5680
5680
|
this.delayedAndroidKey = null;
|
|
5681
5681
|
this.delayedFlush = -1;
|
|
5682
|
-
if (!this.flush())
|
|
5682
|
+
if (!this.flush() && key.force)
|
|
5683
5683
|
dispatchKey(this.dom, key.key, key.keyCode);
|
|
5684
5684
|
});
|
|
5685
5685
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5686
5686
|
// Enter always takes precedence.
|
|
5687
5687
|
if (!this.delayedAndroidKey || key == "Enter")
|
|
5688
|
-
this.delayedAndroidKey = {
|
|
5688
|
+
this.delayedAndroidKey = {
|
|
5689
|
+
key, keyCode,
|
|
5690
|
+
// Only run the key handler when no changes are detected if
|
|
5691
|
+
// this isn't coming right after another change, in which case
|
|
5692
|
+
// it is probably part of a weird chain of updates, and should
|
|
5693
|
+
// be ignored if it returns the DOM to its previous state.
|
|
5694
|
+
force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
|
|
5695
|
+
};
|
|
5689
5696
|
}
|
|
5690
5697
|
flushSoon() {
|
|
5691
5698
|
if (this.delayedFlush < 0)
|
|
5692
|
-
this.delayedFlush =
|
|
5699
|
+
this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
|
|
5693
5700
|
}
|
|
5694
5701
|
forceFlush() {
|
|
5695
5702
|
if (this.delayedFlush >= 0) {
|
|
5696
|
-
|
|
5703
|
+
this.view.win.cancelAnimationFrame(this.delayedFlush);
|
|
5697
5704
|
this.delayedFlush = -1;
|
|
5698
5705
|
}
|
|
5699
5706
|
this.flush();
|
|
@@ -5727,13 +5734,15 @@ class DOMObserver {
|
|
|
5727
5734
|
// managing those will make sure processRecords is called and the
|
|
5728
5735
|
// view is resynchronized after
|
|
5729
5736
|
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
|
|
5730
|
-
return;
|
|
5737
|
+
return false;
|
|
5731
5738
|
if (readSelection)
|
|
5732
5739
|
this.readSelectionRange();
|
|
5733
5740
|
let { from, to, typeOver } = this.processRecords();
|
|
5734
5741
|
let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
|
|
5735
5742
|
if (from < 0 && !newSel)
|
|
5736
|
-
return;
|
|
5743
|
+
return false;
|
|
5744
|
+
if (from > -1)
|
|
5745
|
+
this.lastChange = Date.now();
|
|
5737
5746
|
this.view.inputState.lastFocusTime = 0;
|
|
5738
5747
|
this.selectionChanged = false;
|
|
5739
5748
|
let startState = this.view.state;
|
|
@@ -5749,7 +5758,7 @@ class DOMObserver {
|
|
|
5749
5758
|
return null;
|
|
5750
5759
|
cView.markDirty(rec.type == "attributes");
|
|
5751
5760
|
if (rec.type == "attributes")
|
|
5752
|
-
cView.dirty |= 4 /* Attrs */;
|
|
5761
|
+
cView.dirty |= 4 /* Dirty.Attrs */;
|
|
5753
5762
|
if (rec.type == "childList") {
|
|
5754
5763
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
5755
5764
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -5819,7 +5828,7 @@ function safariSelectionRangeHack(view) {
|
|
|
5819
5828
|
found = event.getTargetRanges()[0];
|
|
5820
5829
|
}
|
|
5821
5830
|
view.contentDOM.addEventListener("beforeinput", read, true);
|
|
5822
|
-
|
|
5831
|
+
view.dom.ownerDocument.execCommand("indent");
|
|
5823
5832
|
view.contentDOM.removeEventListener("beforeinput", read, true);
|
|
5824
5833
|
if (!found)
|
|
5825
5834
|
return null;
|
|
@@ -6076,7 +6085,7 @@ class EditorView {
|
|
|
6076
6085
|
/**
|
|
6077
6086
|
@internal
|
|
6078
6087
|
*/
|
|
6079
|
-
this.updateState = 2 /* Updating */;
|
|
6088
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6080
6089
|
/**
|
|
6081
6090
|
@internal
|
|
6082
6091
|
*/
|
|
@@ -6115,7 +6124,7 @@ class EditorView {
|
|
|
6115
6124
|
this.docView = new DocView(this);
|
|
6116
6125
|
this.mountStyles();
|
|
6117
6126
|
this.updateAttrs();
|
|
6118
|
-
this.updateState = 0 /* Idle */;
|
|
6127
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6119
6128
|
this.requestMeasure();
|
|
6120
6129
|
if (config.parent)
|
|
6121
6130
|
config.parent.appendChild(this.dom);
|
|
@@ -6163,6 +6172,10 @@ class EditorView {
|
|
|
6163
6172
|
The document or shadow root that the view lives in.
|
|
6164
6173
|
*/
|
|
6165
6174
|
get root() { return this._root; }
|
|
6175
|
+
/**
|
|
6176
|
+
@internal
|
|
6177
|
+
*/
|
|
6178
|
+
get win() { return this.dom.ownerDocument.defaultView; }
|
|
6166
6179
|
dispatch(...input) {
|
|
6167
6180
|
this._dispatch(input.length == 1 && input[0] instanceof state.Transaction ? input[0]
|
|
6168
6181
|
: this.state.update(...input));
|
|
@@ -6176,7 +6189,7 @@ class EditorView {
|
|
|
6176
6189
|
as a primitive.
|
|
6177
6190
|
*/
|
|
6178
6191
|
update(transactions) {
|
|
6179
|
-
if (this.updateState != 0 /* Idle */)
|
|
6192
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6180
6193
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6181
6194
|
let redrawn = false, attrsChanged = false, update;
|
|
6182
6195
|
let state$1 = this.state;
|
|
@@ -6196,7 +6209,7 @@ class EditorView {
|
|
|
6196
6209
|
update = ViewUpdate.create(this, state$1, transactions);
|
|
6197
6210
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6198
6211
|
try {
|
|
6199
|
-
this.updateState = 2 /* Updating */;
|
|
6212
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6200
6213
|
for (let tr of transactions) {
|
|
6201
6214
|
if (scrollTarget)
|
|
6202
6215
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6222,7 +6235,7 @@ class EditorView {
|
|
|
6222
6235
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6223
6236
|
}
|
|
6224
6237
|
finally {
|
|
6225
|
-
this.updateState = 0 /* Idle */;
|
|
6238
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6226
6239
|
}
|
|
6227
6240
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6228
6241
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6240,13 +6253,13 @@ class EditorView {
|
|
|
6240
6253
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6241
6254
|
*/
|
|
6242
6255
|
setState(newState) {
|
|
6243
|
-
if (this.updateState != 0 /* Idle */)
|
|
6256
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6244
6257
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6245
6258
|
if (this.destroyed) {
|
|
6246
6259
|
this.viewState.state = newState;
|
|
6247
6260
|
return;
|
|
6248
6261
|
}
|
|
6249
|
-
this.updateState = 2 /* Updating */;
|
|
6262
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6250
6263
|
let hadFocus = this.hasFocus;
|
|
6251
6264
|
try {
|
|
6252
6265
|
for (let plugin of this.plugins)
|
|
@@ -6263,7 +6276,7 @@ class EditorView {
|
|
|
6263
6276
|
this.bidiCache = [];
|
|
6264
6277
|
}
|
|
6265
6278
|
finally {
|
|
6266
|
-
this.updateState = 0 /* Idle */;
|
|
6279
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6267
6280
|
}
|
|
6268
6281
|
if (hadFocus)
|
|
6269
6282
|
this.focus();
|
|
@@ -6314,7 +6327,7 @@ class EditorView {
|
|
|
6314
6327
|
let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;
|
|
6315
6328
|
try {
|
|
6316
6329
|
for (let i = 0;; i++) {
|
|
6317
|
-
this.updateState = 1 /* Measuring */;
|
|
6330
|
+
this.updateState = 1 /* UpdateState.Measuring */;
|
|
6318
6331
|
let oldViewport = this.viewport;
|
|
6319
6332
|
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6320
6333
|
let changed = this.viewState.measure(this);
|
|
@@ -6328,7 +6341,7 @@ class EditorView {
|
|
|
6328
6341
|
}
|
|
6329
6342
|
let measuring = [];
|
|
6330
6343
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6331
|
-
if (!(changed & 4 /* Viewport */))
|
|
6344
|
+
if (!(changed & 4 /* UpdateFlag.Viewport */))
|
|
6332
6345
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6333
6346
|
let measured = measuring.map(m => {
|
|
6334
6347
|
try {
|
|
@@ -6345,7 +6358,7 @@ class EditorView {
|
|
|
6345
6358
|
updated = update;
|
|
6346
6359
|
else
|
|
6347
6360
|
updated.flags |= changed;
|
|
6348
|
-
this.updateState = 2 /* Updating */;
|
|
6361
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6349
6362
|
if (!update.empty) {
|
|
6350
6363
|
this.updatePlugins(update);
|
|
6351
6364
|
this.inputState.update(update);
|
|
@@ -6383,7 +6396,7 @@ class EditorView {
|
|
|
6383
6396
|
}
|
|
6384
6397
|
}
|
|
6385
6398
|
finally {
|
|
6386
|
-
this.updateState = 0 /* Idle */;
|
|
6399
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6387
6400
|
this.measureScheduled = -1;
|
|
6388
6401
|
}
|
|
6389
6402
|
if (updated && !updated.empty)
|
|
@@ -6442,9 +6455,9 @@ class EditorView {
|
|
|
6442
6455
|
styleMod.StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6443
6456
|
}
|
|
6444
6457
|
readMeasured() {
|
|
6445
|
-
if (this.updateState == 2 /* Updating */)
|
|
6458
|
+
if (this.updateState == 2 /* UpdateState.Updating */)
|
|
6446
6459
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6447
|
-
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6460
|
+
if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
|
|
6448
6461
|
this.measure(false);
|
|
6449
6462
|
}
|
|
6450
6463
|
/**
|
|
@@ -6457,7 +6470,7 @@ class EditorView {
|
|
|
6457
6470
|
*/
|
|
6458
6471
|
requestMeasure(request) {
|
|
6459
6472
|
if (this.measureScheduled < 0)
|
|
6460
|
-
this.measureScheduled = requestAnimationFrame(() => this.measure());
|
|
6473
|
+
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6461
6474
|
if (request) {
|
|
6462
6475
|
if (request.key != null)
|
|
6463
6476
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
@@ -6702,7 +6715,7 @@ class EditorView {
|
|
|
6702
6715
|
// or closing, which leads us to ignore selection changes from the
|
|
6703
6716
|
// context menu because it looks like the editor isn't focused.
|
|
6704
6717
|
// This kludges around that.
|
|
6705
|
-
return (
|
|
6718
|
+
return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
|
|
6706
6719
|
this.root.activeElement == this.contentDOM;
|
|
6707
6720
|
}
|
|
6708
6721
|
/**
|
|
@@ -6887,6 +6900,11 @@ the editor's vertical layout structure. The ones provided as
|
|
|
6887
6900
|
functions are called _after_ the new viewport has been computed,
|
|
6888
6901
|
and thus **must not** introduce block widgets or replacing
|
|
6889
6902
|
decorations that cover line breaks.
|
|
6903
|
+
|
|
6904
|
+
If you want decorated ranges to behave like atomic units for
|
|
6905
|
+
cursor motion and deletion purposes, also provide the range set
|
|
6906
|
+
containing the decorations to
|
|
6907
|
+
[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
|
|
6890
6908
|
*/
|
|
6891
6909
|
EditorView.decorations = decorations;
|
|
6892
6910
|
/**
|
|
@@ -7117,7 +7135,7 @@ function runHandlers(map, event, view, scope) {
|
|
|
7117
7135
|
}
|
|
7118
7136
|
return false;
|
|
7119
7137
|
};
|
|
7120
|
-
let scopeObj = map[scope], baseName;
|
|
7138
|
+
let scopeObj = map[scope], baseName, shiftName;
|
|
7121
7139
|
if (scopeObj) {
|
|
7122
7140
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
7123
7141
|
return true;
|
|
@@ -7125,8 +7143,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
7125
7143
|
(baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
|
|
7126
7144
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
7127
7145
|
return true;
|
|
7128
|
-
else if (event.shiftKey && w3cKeyname.shift[event.keyCode] != baseName &&
|
|
7129
|
-
runFor(scopeObj[prefix + modifiers(
|
|
7146
|
+
else if (event.shiftKey && (shiftName = w3cKeyname.shift[event.keyCode]) != name && shiftName != baseName &&
|
|
7147
|
+
runFor(scopeObj[prefix + modifiers(shiftName, event, false)]))
|
|
7130
7148
|
return true;
|
|
7131
7149
|
}
|
|
7132
7150
|
else if (isChar && event.shiftKey) {
|
|
@@ -7327,7 +7345,7 @@ function measureRange(view, range) {
|
|
|
7327
7345
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7328
7346
|
}
|
|
7329
7347
|
function piece(left, top, right, bottom) {
|
|
7330
|
-
return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
|
|
7348
|
+
return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
|
|
7331
7349
|
}
|
|
7332
7350
|
function pieces({ top, bottom, horizontal }) {
|
|
7333
7351
|
let pieces = [];
|
|
@@ -8024,7 +8042,6 @@ const tooltipConfig = state.Facet.define({
|
|
|
8024
8042
|
});
|
|
8025
8043
|
const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
8026
8044
|
constructor(view) {
|
|
8027
|
-
var _a;
|
|
8028
8045
|
this.view = view;
|
|
8029
8046
|
this.inView = true;
|
|
8030
8047
|
this.lastTransaction = 0;
|
|
@@ -8042,7 +8059,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8042
8059
|
this.measureSoon();
|
|
8043
8060
|
}, { threshold: [1] }) : null;
|
|
8044
8061
|
this.observeIntersection();
|
|
8045
|
-
|
|
8062
|
+
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
8046
8063
|
this.maybeMeasure();
|
|
8047
8064
|
}
|
|
8048
8065
|
createContainer() {
|
|
@@ -8115,11 +8132,11 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8115
8132
|
return tooltipView;
|
|
8116
8133
|
}
|
|
8117
8134
|
destroy() {
|
|
8118
|
-
var _a
|
|
8119
|
-
|
|
8135
|
+
var _a;
|
|
8136
|
+
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
8120
8137
|
for (let { dom } of this.manager.tooltipViews)
|
|
8121
8138
|
dom.remove();
|
|
8122
|
-
(
|
|
8139
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
8123
8140
|
clearTimeout(this.measureTimeout);
|
|
8124
8141
|
}
|
|
8125
8142
|
readMeasure() {
|
|
@@ -8150,12 +8167,12 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8150
8167
|
continue;
|
|
8151
8168
|
}
|
|
8152
8169
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8153
|
-
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8170
|
+
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
8154
8171
|
let width = size.right - size.left, height = size.bottom - size.top;
|
|
8155
8172
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == exports.Direction.LTR;
|
|
8156
8173
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8157
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8158
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8174
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
8175
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
8159
8176
|
let above = !!tooltip.above;
|
|
8160
8177
|
if (!tooltip.strictSide && (above
|
|
8161
8178
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8177,7 +8194,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8177
8194
|
dom.style.left = left + "px";
|
|
8178
8195
|
}
|
|
8179
8196
|
if (arrow)
|
|
8180
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8197
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */)}px`;
|
|
8181
8198
|
if (tView.overlap !== true)
|
|
8182
8199
|
others.push({ left, top, right, bottom: top + height });
|
|
8183
8200
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8219,8 +8236,8 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8219
8236
|
color: "white"
|
|
8220
8237
|
},
|
|
8221
8238
|
".cm-tooltip-arrow": {
|
|
8222
|
-
height: `${7 /* Size */}px`,
|
|
8223
|
-
width: `${7 /* Size */ * 2}px`,
|
|
8239
|
+
height: `${7 /* Arrow.Size */}px`,
|
|
8240
|
+
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
8224
8241
|
position: "absolute",
|
|
8225
8242
|
zIndex: -1,
|
|
8226
8243
|
overflow: "hidden",
|
|
@@ -8229,26 +8246,26 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8229
8246
|
position: "absolute",
|
|
8230
8247
|
width: 0,
|
|
8231
8248
|
height: 0,
|
|
8232
|
-
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8233
|
-
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8249
|
+
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8250
|
+
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8234
8251
|
},
|
|
8235
8252
|
".cm-tooltip-above &": {
|
|
8236
|
-
bottom: `-${7 /* Size */}px`,
|
|
8253
|
+
bottom: `-${7 /* Arrow.Size */}px`,
|
|
8237
8254
|
"&:before": {
|
|
8238
|
-
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8255
|
+
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8239
8256
|
},
|
|
8240
8257
|
"&:after": {
|
|
8241
|
-
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8258
|
+
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8242
8259
|
bottom: "1px"
|
|
8243
8260
|
}
|
|
8244
8261
|
},
|
|
8245
8262
|
".cm-tooltip-below &": {
|
|
8246
|
-
top: `-${7 /* Size */}px`,
|
|
8263
|
+
top: `-${7 /* Arrow.Size */}px`,
|
|
8247
8264
|
"&:before": {
|
|
8248
|
-
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8265
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8249
8266
|
},
|
|
8250
8267
|
"&:after": {
|
|
8251
|
-
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8268
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8252
8269
|
top: "1px"
|
|
8253
8270
|
}
|
|
8254
8271
|
},
|
|
@@ -8393,7 +8410,7 @@ class HoverPlugin {
|
|
|
8393
8410
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
8394
8411
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
8395
8412
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
8396
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
8413
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* Hover.MaxDist */))) {
|
|
8397
8414
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
8398
8415
|
this.pending = null;
|
|
8399
8416
|
}
|
|
@@ -8475,7 +8492,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
8475
8492
|
});
|
|
8476
8493
|
return [
|
|
8477
8494
|
hoverState,
|
|
8478
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
8495
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
8479
8496
|
showHoverTooltipHost
|
|
8480
8497
|
];
|
|
8481
8498
|
}
|