@codemirror/view 6.2.2 → 6.2.4
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 +18 -0
- package/dist/index.cjs +219 -216
- package/dist/index.d.ts +2 -2
- package/dist/index.js +219 -216
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -109,7 +109,7 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
|
|
112
|
-
cur = cur.parentNode;
|
|
112
|
+
cur = cur.assignedSlot || cur.parentNode;
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
115
|
let rect = cur.getBoundingClientRect();
|
|
@@ -160,24 +160,28 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
160
160
|
win.scrollBy(moveX, moveY);
|
|
161
161
|
}
|
|
162
162
|
else {
|
|
163
|
+
let movedX = 0, movedY = 0;
|
|
163
164
|
if (moveY) {
|
|
164
165
|
let start = cur.scrollTop;
|
|
165
166
|
cur.scrollTop += moveY;
|
|
166
|
-
|
|
167
|
+
movedY = cur.scrollTop - start;
|
|
167
168
|
}
|
|
168
169
|
if (moveX) {
|
|
169
170
|
let start = cur.scrollLeft;
|
|
170
171
|
cur.scrollLeft += moveX;
|
|
171
|
-
|
|
172
|
+
movedX = cur.scrollLeft - start;
|
|
172
173
|
}
|
|
173
|
-
rect = { left: rect.left -
|
|
174
|
-
right: rect.right -
|
|
174
|
+
rect = { left: rect.left - movedX, top: rect.top - movedY,
|
|
175
|
+
right: rect.right - movedX, bottom: rect.bottom - movedY };
|
|
176
|
+
if (movedX && Math.abs(movedX - moveX) < 1)
|
|
177
|
+
x = "nearest";
|
|
178
|
+
if (movedY && Math.abs(movedY - moveY) < 1)
|
|
179
|
+
y = "nearest";
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
182
|
if (top)
|
|
178
183
|
break;
|
|
179
184
|
cur = cur.assignedSlot || cur.parentNode;
|
|
180
|
-
x = y = "nearest";
|
|
181
185
|
}
|
|
182
186
|
else if (cur.nodeType == 11) { // A shadow root
|
|
183
187
|
cur = cur.host;
|
|
@@ -308,7 +312,7 @@ class ContentView {
|
|
|
308
312
|
constructor() {
|
|
309
313
|
this.parent = null;
|
|
310
314
|
this.dom = null;
|
|
311
|
-
this.dirty = 2 /* Node */;
|
|
315
|
+
this.dirty = 2 /* Dirty.Node */;
|
|
312
316
|
}
|
|
313
317
|
get editorView() {
|
|
314
318
|
if (!this.parent)
|
|
@@ -339,7 +343,7 @@ class ContentView {
|
|
|
339
343
|
// given position.
|
|
340
344
|
coordsAt(_pos, _side) { return null; }
|
|
341
345
|
sync(track) {
|
|
342
|
-
if (this.dirty & 2 /* Node */) {
|
|
346
|
+
if (this.dirty & 2 /* Dirty.Node */) {
|
|
343
347
|
let parent = this.dom;
|
|
344
348
|
let prev = null, next;
|
|
345
349
|
for (let child of this.children) {
|
|
@@ -350,7 +354,7 @@ class ContentView {
|
|
|
350
354
|
child.reuseDOM(next);
|
|
351
355
|
}
|
|
352
356
|
child.sync(track);
|
|
353
|
-
child.dirty = 0 /* Not */;
|
|
357
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
354
358
|
}
|
|
355
359
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
356
360
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -370,11 +374,11 @@ class ContentView {
|
|
|
370
374
|
while (next)
|
|
371
375
|
next = rm$1(next);
|
|
372
376
|
}
|
|
373
|
-
else if (this.dirty & 1 /* Child */) {
|
|
377
|
+
else if (this.dirty & 1 /* Dirty.Child */) {
|
|
374
378
|
for (let child of this.children)
|
|
375
379
|
if (child.dirty) {
|
|
376
380
|
child.sync(track);
|
|
377
|
-
child.dirty = 0 /* Not */;
|
|
381
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
378
382
|
}
|
|
379
383
|
}
|
|
380
384
|
}
|
|
@@ -439,16 +443,16 @@ class ContentView {
|
|
|
439
443
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
440
444
|
}
|
|
441
445
|
markDirty(andParent = false) {
|
|
442
|
-
this.dirty |= 2 /* Node */;
|
|
446
|
+
this.dirty |= 2 /* Dirty.Node */;
|
|
443
447
|
this.markParentsDirty(andParent);
|
|
444
448
|
}
|
|
445
449
|
markParentsDirty(childList) {
|
|
446
450
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
447
451
|
if (childList)
|
|
448
|
-
parent.dirty |= 2 /* Node */;
|
|
449
|
-
if (parent.dirty & 1 /* Child */)
|
|
452
|
+
parent.dirty |= 2 /* Dirty.Node */;
|
|
453
|
+
if (parent.dirty & 1 /* Dirty.Child */)
|
|
450
454
|
return;
|
|
451
|
-
parent.dirty |= 1 /* Child */;
|
|
455
|
+
parent.dirty |= 1 /* Dirty.Child */;
|
|
452
456
|
childList = false;
|
|
453
457
|
}
|
|
454
458
|
}
|
|
@@ -724,13 +728,13 @@ class MarkView extends ContentView {
|
|
|
724
728
|
reuseDOM(node) {
|
|
725
729
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
726
730
|
this.setDOM(node);
|
|
727
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
731
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
728
732
|
}
|
|
729
733
|
}
|
|
730
734
|
sync(track) {
|
|
731
735
|
if (!this.dom)
|
|
732
736
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
733
|
-
else if (this.dirty & 4 /* Attrs */)
|
|
737
|
+
else if (this.dirty & 4 /* Dirty.Attrs */)
|
|
734
738
|
this.setAttrs(this.dom);
|
|
735
739
|
super.sync(track);
|
|
736
740
|
}
|
|
@@ -1240,7 +1244,7 @@ class Decoration extends state.RangeValue {
|
|
|
1240
1244
|
*/
|
|
1241
1245
|
static widget(spec) {
|
|
1242
1246
|
let side = spec.side || 0, block = !!spec.block;
|
|
1243
|
-
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1247
|
+
side += block ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */) : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
|
|
1244
1248
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1245
1249
|
}
|
|
1246
1250
|
/**
|
|
@@ -1250,13 +1254,13 @@ class Decoration extends state.RangeValue {
|
|
|
1250
1254
|
static replace(spec) {
|
|
1251
1255
|
let block = !!spec.block, startSide, endSide;
|
|
1252
1256
|
if (spec.isBlockGap) {
|
|
1253
|
-
startSide = -500000000 /* GapStart */;
|
|
1254
|
-
endSide = 400000000 /* GapEnd */;
|
|
1257
|
+
startSide = -500000000 /* Side.GapStart */;
|
|
1258
|
+
endSide = 400000000 /* Side.GapEnd */;
|
|
1255
1259
|
}
|
|
1256
1260
|
else {
|
|
1257
1261
|
let { start, end } = getInclusive(spec, block);
|
|
1258
|
-
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1259
|
-
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1262
|
+
startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
|
|
1263
|
+
endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
|
|
1260
1264
|
}
|
|
1261
1265
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1262
1266
|
}
|
|
@@ -1287,7 +1291,7 @@ Decoration.none = state.RangeSet.empty;
|
|
|
1287
1291
|
class MarkDecoration extends Decoration {
|
|
1288
1292
|
constructor(spec) {
|
|
1289
1293
|
let { start, end } = getInclusive(spec);
|
|
1290
|
-
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1294
|
+
super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
|
|
1291
1295
|
this.tagName = spec.tagName || "span";
|
|
1292
1296
|
this.class = spec.class || "";
|
|
1293
1297
|
this.attrs = spec.attributes || null;
|
|
@@ -1308,7 +1312,7 @@ class MarkDecoration extends Decoration {
|
|
|
1308
1312
|
MarkDecoration.prototype.point = false;
|
|
1309
1313
|
class LineDecoration extends Decoration {
|
|
1310
1314
|
constructor(spec) {
|
|
1311
|
-
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1315
|
+
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1312
1316
|
}
|
|
1313
1317
|
eq(other) {
|
|
1314
1318
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1445,7 +1449,7 @@ class LineView extends ContentView {
|
|
|
1445
1449
|
reuseDOM(node) {
|
|
1446
1450
|
if (node.nodeName == "DIV") {
|
|
1447
1451
|
this.setDOM(node);
|
|
1448
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1452
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
1449
1453
|
}
|
|
1450
1454
|
}
|
|
1451
1455
|
sync(track) {
|
|
@@ -1455,7 +1459,7 @@ class LineView extends ContentView {
|
|
|
1455
1459
|
this.dom.className = "cm-line";
|
|
1456
1460
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1457
1461
|
}
|
|
1458
|
-
else if (this.dirty & 4 /* Attrs */) {
|
|
1462
|
+
else if (this.dirty & 4 /* Dirty.Attrs */) {
|
|
1459
1463
|
clearAttributes(this.dom);
|
|
1460
1464
|
this.dom.className = "cm-line";
|
|
1461
1465
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1585,7 +1589,7 @@ class ContentBuilder {
|
|
|
1585
1589
|
this.content = [];
|
|
1586
1590
|
this.curLine = null;
|
|
1587
1591
|
this.breakAtStart = 0;
|
|
1588
|
-
this.pendingBuffer = 0 /* No */;
|
|
1592
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1589
1593
|
// Set to false directly after a widget that covers the position after it
|
|
1590
1594
|
this.atCursorPos = true;
|
|
1591
1595
|
this.openStart = -1;
|
|
@@ -1611,7 +1615,7 @@ class ContentBuilder {
|
|
|
1611
1615
|
flushBuffer(active) {
|
|
1612
1616
|
if (this.pendingBuffer) {
|
|
1613
1617
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1614
|
-
this.pendingBuffer = 0 /* No */;
|
|
1618
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1615
1619
|
}
|
|
1616
1620
|
}
|
|
1617
1621
|
addBlockWidget(view) {
|
|
@@ -1623,7 +1627,7 @@ class ContentBuilder {
|
|
|
1623
1627
|
if (!openEnd)
|
|
1624
1628
|
this.flushBuffer([]);
|
|
1625
1629
|
else
|
|
1626
|
-
this.pendingBuffer = 0 /* No */;
|
|
1630
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1627
1631
|
if (!this.posCovered())
|
|
1628
1632
|
this.getLine();
|
|
1629
1633
|
}
|
|
@@ -1651,7 +1655,7 @@ class ContentBuilder {
|
|
|
1651
1655
|
this.textOff = 0;
|
|
1652
1656
|
}
|
|
1653
1657
|
}
|
|
1654
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1658
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
|
|
1655
1659
|
this.flushBuffer(active.slice(0, openStart));
|
|
1656
1660
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1657
1661
|
this.atCursorPos = true;
|
|
@@ -1686,8 +1690,8 @@ class ContentBuilder {
|
|
|
1686
1690
|
let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
|
|
1687
1691
|
let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
|
|
1688
1692
|
let line = this.getLine();
|
|
1689
|
-
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
|
|
1690
|
-
this.pendingBuffer = 0 /* No */;
|
|
1693
|
+
if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore)
|
|
1694
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1691
1695
|
this.flushBuffer(active);
|
|
1692
1696
|
if (cursorBefore) {
|
|
1693
1697
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1695,7 +1699,7 @@ class ContentBuilder {
|
|
|
1695
1699
|
}
|
|
1696
1700
|
line.append(wrapMarks(view, active), openStart);
|
|
1697
1701
|
this.atCursorPos = cursorAfter;
|
|
1698
|
-
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1702
|
+
this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
|
|
1699
1703
|
}
|
|
1700
1704
|
}
|
|
1701
1705
|
else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
|
|
@@ -1988,7 +1992,7 @@ class ViewUpdate {
|
|
|
1988
1992
|
let focus = view.hasFocus;
|
|
1989
1993
|
if (focus != view.inputState.notifiedFocused) {
|
|
1990
1994
|
view.inputState.notifiedFocused = focus;
|
|
1991
|
-
this.flags |= 1 /* Focus */;
|
|
1995
|
+
this.flags |= 1 /* UpdateFlag.Focus */;
|
|
1992
1996
|
}
|
|
1993
1997
|
}
|
|
1994
1998
|
/**
|
|
@@ -2003,27 +2007,27 @@ class ViewUpdate {
|
|
|
2003
2007
|
update.
|
|
2004
2008
|
*/
|
|
2005
2009
|
get viewportChanged() {
|
|
2006
|
-
return (this.flags & 4 /* Viewport */) > 0;
|
|
2010
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
2007
2011
|
}
|
|
2008
2012
|
/**
|
|
2009
2013
|
Indicates whether the height of a block element in the editor
|
|
2010
2014
|
changed in this update.
|
|
2011
2015
|
*/
|
|
2012
2016
|
get heightChanged() {
|
|
2013
|
-
return (this.flags & 2 /* Height */) > 0;
|
|
2017
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2014
2018
|
}
|
|
2015
2019
|
/**
|
|
2016
2020
|
Returns true when the document was modified or the size of the
|
|
2017
2021
|
editor, or elements within the editor, changed.
|
|
2018
2022
|
*/
|
|
2019
2023
|
get geometryChanged() {
|
|
2020
|
-
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2024
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2021
2025
|
}
|
|
2022
2026
|
/**
|
|
2023
2027
|
True when this update indicates a focus change.
|
|
2024
2028
|
*/
|
|
2025
2029
|
get focusChanged() {
|
|
2026
|
-
return (this.flags & 1 /* Focus */) > 0;
|
|
2030
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2027
2031
|
}
|
|
2028
2032
|
/**
|
|
2029
2033
|
Whether the document changed in this update.
|
|
@@ -2082,12 +2086,12 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2082
2086
|
}
|
|
2083
2087
|
function charType(ch) {
|
|
2084
2088
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2085
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2089
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2086
2090
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2087
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2088
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2089
|
-
0xfb50 <= ch && ch <= 0xfdff ? 4 /* AL */ :
|
|
2090
|
-
ch == 0x200c ? 256 /* NI */ : 1 /* L */;
|
|
2091
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2092
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :
|
|
2093
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :
|
|
2094
|
+
ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;
|
|
2091
2095
|
}
|
|
2092
2096
|
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2093
2097
|
/**
|
|
@@ -2152,8 +2156,8 @@ class BidiSpan {
|
|
|
2152
2156
|
// Reused array of character types
|
|
2153
2157
|
const types = [];
|
|
2154
2158
|
function computeOrder(line, direction) {
|
|
2155
|
-
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2156
|
-
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2159
|
+
let len = line.length, outerType = direction == LTR ? 1 /* T.L */ : 2 /* T.R */, oppositeType = direction == LTR ? 2 /* T.R */ : 1 /* T.L */;
|
|
2160
|
+
if (!line || outerType == 1 /* T.L */ && !BidiRE.test(line))
|
|
2157
2161
|
return trivialOrder(len);
|
|
2158
2162
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2159
2163
|
// change the type of the NSM to the type of the previous
|
|
@@ -2167,12 +2171,12 @@ function computeOrder(line, direction) {
|
|
|
2167
2171
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2168
2172
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2169
2173
|
let type = charType(line.charCodeAt(i));
|
|
2170
|
-
if (type == 512 /* NSM */)
|
|
2174
|
+
if (type == 512 /* T.NSM */)
|
|
2171
2175
|
type = prev;
|
|
2172
|
-
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2173
|
-
type = 16 /* AN */;
|
|
2174
|
-
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2175
|
-
if (type & 7 /* Strong */)
|
|
2176
|
+
else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
|
|
2177
|
+
type = 16 /* T.AN */;
|
|
2178
|
+
types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
|
|
2179
|
+
if (type & 7 /* T.Strong */)
|
|
2176
2180
|
prevStrong = type;
|
|
2177
2181
|
prev = type;
|
|
2178
2182
|
}
|
|
@@ -2186,26 +2190,26 @@ function computeOrder(line, direction) {
|
|
|
2186
2190
|
// (Left after this: L, R, EN+AN, NI)
|
|
2187
2191
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2188
2192
|
let type = types[i];
|
|
2189
|
-
if (type == 128 /* CS */) {
|
|
2190
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2193
|
+
if (type == 128 /* T.CS */) {
|
|
2194
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
|
|
2191
2195
|
type = types[i] = prev;
|
|
2192
2196
|
else
|
|
2193
|
-
types[i] = 256 /* NI */;
|
|
2197
|
+
types[i] = 256 /* T.NI */;
|
|
2194
2198
|
}
|
|
2195
|
-
else if (type == 64 /* ET */) {
|
|
2199
|
+
else if (type == 64 /* T.ET */) {
|
|
2196
2200
|
let end = i + 1;
|
|
2197
|
-
while (end < len && types[end] == 64 /* ET */)
|
|
2201
|
+
while (end < len && types[end] == 64 /* T.ET */)
|
|
2198
2202
|
end++;
|
|
2199
|
-
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2203
|
+
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 */;
|
|
2200
2204
|
for (let j = i; j < end; j++)
|
|
2201
2205
|
types[j] = replace;
|
|
2202
2206
|
i = end - 1;
|
|
2203
2207
|
}
|
|
2204
|
-
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2205
|
-
types[i] = 1 /* L */;
|
|
2208
|
+
else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
|
|
2209
|
+
types[i] = 1 /* T.L */;
|
|
2206
2210
|
}
|
|
2207
2211
|
prev = type;
|
|
2208
|
-
if (type & 7 /* Strong */)
|
|
2212
|
+
if (type & 7 /* T.Strong */)
|
|
2209
2213
|
prevStrong = type;
|
|
2210
2214
|
}
|
|
2211
2215
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2220,9 +2224,9 @@ function computeOrder(line, direction) {
|
|
|
2220
2224
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2221
2225
|
if (BracketStack[sJ + 1] == -br) {
|
|
2222
2226
|
let flags = BracketStack[sJ + 2];
|
|
2223
|
-
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2224
|
-
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2225
|
-
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2227
|
+
let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
|
|
2228
|
+
!(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
|
|
2229
|
+
(flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
|
|
2226
2230
|
if (type)
|
|
2227
2231
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2228
2232
|
sI = sJ;
|
|
@@ -2230,7 +2234,7 @@ function computeOrder(line, direction) {
|
|
|
2230
2234
|
}
|
|
2231
2235
|
}
|
|
2232
2236
|
}
|
|
2233
|
-
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2237
|
+
else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
|
|
2234
2238
|
break;
|
|
2235
2239
|
}
|
|
2236
2240
|
else {
|
|
@@ -2239,20 +2243,20 @@ function computeOrder(line, direction) {
|
|
|
2239
2243
|
BracketStack[sI++] = context;
|
|
2240
2244
|
}
|
|
2241
2245
|
}
|
|
2242
|
-
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2246
|
+
else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
|
|
2243
2247
|
let embed = type == outerType;
|
|
2244
|
-
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2248
|
+
context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
|
|
2245
2249
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2246
2250
|
let cur = BracketStack[sJ + 2];
|
|
2247
|
-
if (cur & 2 /* EmbedInside */)
|
|
2251
|
+
if (cur & 2 /* Bracketed.EmbedInside */)
|
|
2248
2252
|
break;
|
|
2249
2253
|
if (embed) {
|
|
2250
|
-
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2254
|
+
BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
|
|
2251
2255
|
}
|
|
2252
2256
|
else {
|
|
2253
|
-
if (cur & 4 /* OppositeInside */)
|
|
2257
|
+
if (cur & 4 /* Bracketed.OppositeInside */)
|
|
2254
2258
|
break;
|
|
2255
|
-
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2259
|
+
BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
|
|
2256
2260
|
}
|
|
2257
2261
|
}
|
|
2258
2262
|
}
|
|
@@ -2265,13 +2269,13 @@ function computeOrder(line, direction) {
|
|
|
2265
2269
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2266
2270
|
// (Left after this: L, R, EN+AN)
|
|
2267
2271
|
for (let i = 0; i < len; i++) {
|
|
2268
|
-
if (types[i] == 256 /* NI */) {
|
|
2272
|
+
if (types[i] == 256 /* T.NI */) {
|
|
2269
2273
|
let end = i + 1;
|
|
2270
|
-
while (end < len && types[end] == 256 /* NI */)
|
|
2274
|
+
while (end < len && types[end] == 256 /* T.NI */)
|
|
2271
2275
|
end++;
|
|
2272
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2273
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2274
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2276
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* T.L */;
|
|
2277
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* T.L */;
|
|
2278
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
|
|
2275
2279
|
for (let j = i; j < end; j++)
|
|
2276
2280
|
types[j] = replace;
|
|
2277
2281
|
i = end - 1;
|
|
@@ -2283,15 +2287,15 @@ function computeOrder(line, direction) {
|
|
|
2283
2287
|
// explicit embedding into account, we can build up the order on
|
|
2284
2288
|
// the fly, without following the level-based algorithm.
|
|
2285
2289
|
let order = [];
|
|
2286
|
-
if (outerType == 1 /* L */) {
|
|
2290
|
+
if (outerType == 1 /* T.L */) {
|
|
2287
2291
|
for (let i = 0; i < len;) {
|
|
2288
|
-
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2289
|
-
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2292
|
+
let start = i, rtl = types[i++] != 1 /* T.L */;
|
|
2293
|
+
while (i < len && rtl == (types[i] != 1 /* T.L */))
|
|
2290
2294
|
i++;
|
|
2291
2295
|
if (rtl) {
|
|
2292
2296
|
for (let j = i; j > start;) {
|
|
2293
|
-
let end = j, l = types[--j] != 2 /* R */;
|
|
2294
|
-
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2297
|
+
let end = j, l = types[--j] != 2 /* T.R */;
|
|
2298
|
+
while (j > start && l == (types[j - 1] != 2 /* T.R */))
|
|
2295
2299
|
j--;
|
|
2296
2300
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2297
2301
|
}
|
|
@@ -2303,8 +2307,8 @@ function computeOrder(line, direction) {
|
|
|
2303
2307
|
}
|
|
2304
2308
|
else {
|
|
2305
2309
|
for (let i = 0; i < len;) {
|
|
2306
|
-
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2307
|
-
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2310
|
+
let start = i, rtl = types[i++] == 2 /* T.R */;
|
|
2311
|
+
while (i < len && rtl == (types[i] == 2 /* T.R */))
|
|
2308
2312
|
i++;
|
|
2309
2313
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2310
2314
|
}
|
|
@@ -2525,7 +2529,7 @@ class DocView extends ContentView {
|
|
|
2525
2529
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2526
2530
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2527
2531
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2528
|
-
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2532
|
+
if (this.dirty == 0 /* Dirty.Not */ && changedRanges.length == 0) {
|
|
2529
2533
|
return false;
|
|
2530
2534
|
}
|
|
2531
2535
|
else {
|
|
@@ -2554,7 +2558,7 @@ class DocView extends ContentView {
|
|
|
2554
2558
|
// to detect that situation.
|
|
2555
2559
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2556
2560
|
this.sync(track);
|
|
2557
|
-
this.dirty = 0 /* Not */;
|
|
2561
|
+
this.dirty = 0 /* Dirty.Not */;
|
|
2558
2562
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2559
2563
|
this.forceSelection = true;
|
|
2560
2564
|
this.dom.style.height = "";
|
|
@@ -2583,8 +2587,7 @@ class DocView extends ContentView {
|
|
|
2583
2587
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2584
2588
|
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2585
2589
|
this.view.observer.readSelectionRange();
|
|
2586
|
-
if (!(fromPointer || this.mayControlSelection())
|
|
2587
|
-
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
2590
|
+
if (!(fromPointer || this.mayControlSelection()))
|
|
2588
2591
|
return;
|
|
2589
2592
|
let force = this.forceSelection;
|
|
2590
2593
|
this.forceSelection = false;
|
|
@@ -2621,10 +2624,10 @@ class DocView extends ContentView {
|
|
|
2621
2624
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2622
2625
|
if (browser.gecko) {
|
|
2623
2626
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2624
|
-
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2625
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2627
|
+
if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
|
|
2628
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);
|
|
2626
2629
|
if (text)
|
|
2627
|
-
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2630
|
+
anchor = new DOMPos(text, nextTo == 1 /* NextTo.Before */ ? 0 : text.nodeValue.length);
|
|
2628
2631
|
}
|
|
2629
2632
|
}
|
|
2630
2633
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -2956,8 +2959,8 @@ function nearbyTextNode(node, offset, side) {
|
|
|
2956
2959
|
function nextToUneditable(node, offset) {
|
|
2957
2960
|
if (node.nodeType != 1)
|
|
2958
2961
|
return 0;
|
|
2959
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
2960
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
2962
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
|
|
2963
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
|
|
2961
2964
|
}
|
|
2962
2965
|
class DecorationComparator$1 {
|
|
2963
2966
|
constructor() {
|
|
@@ -3312,7 +3315,7 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3312
3315
|
for (let set of atoms) {
|
|
3313
3316
|
set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
|
|
3314
3317
|
if (pos.from > from && pos.from < to) {
|
|
3315
|
-
pos = oldPos.
|
|
3318
|
+
pos = oldPos.head > pos.from ? state.EditorSelection.cursor(from, 1) : state.EditorSelection.cursor(to, -1);
|
|
3316
3319
|
moved = true;
|
|
3317
3320
|
}
|
|
3318
3321
|
});
|
|
@@ -3354,7 +3357,6 @@ class InputState {
|
|
|
3354
3357
|
// composition)
|
|
3355
3358
|
this.compositionFirstChange = null;
|
|
3356
3359
|
this.compositionEndedAt = 0;
|
|
3357
|
-
this.rapidCompositionStart = false;
|
|
3358
3360
|
this.mouseSelection = null;
|
|
3359
3361
|
for (let type in handlers) {
|
|
3360
3362
|
let handler = handlers[type];
|
|
@@ -3502,8 +3504,7 @@ class InputState {
|
|
|
3502
3504
|
return false;
|
|
3503
3505
|
}
|
|
3504
3506
|
mustFlushObserver(event) {
|
|
3505
|
-
return
|
|
3506
|
-
event.type == "compositionend" && !browser.ios;
|
|
3507
|
+
return event.type == "keydown" && event.keyCode != 229;
|
|
3507
3508
|
}
|
|
3508
3509
|
startMouseSelection(mouseSelection) {
|
|
3509
3510
|
if (this.mouseSelection)
|
|
@@ -3771,8 +3772,7 @@ function basicMouseSelection(view, event) {
|
|
|
3771
3772
|
return {
|
|
3772
3773
|
update(update) {
|
|
3773
3774
|
if (update.docChanged) {
|
|
3774
|
-
|
|
3775
|
-
start.pos = update.changes.mapPos(start.pos);
|
|
3775
|
+
start.pos = update.changes.mapPos(start.pos);
|
|
3776
3776
|
startSel = startSel.map(update.changes);
|
|
3777
3777
|
lastEvent = null;
|
|
3778
3778
|
}
|
|
@@ -3785,8 +3785,6 @@ function basicMouseSelection(view, event) {
|
|
|
3785
3785
|
cur = last = queryPos(view, event);
|
|
3786
3786
|
lastEvent = event;
|
|
3787
3787
|
}
|
|
3788
|
-
if (!cur || !start)
|
|
3789
|
-
return startSel;
|
|
3790
3788
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3791
3789
|
if (start.pos != cur.pos && !extend) {
|
|
3792
3790
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -3958,36 +3956,24 @@ handlers.blur = view => {
|
|
|
3958
3956
|
view.observer.clearSelectionRange();
|
|
3959
3957
|
updateForFocusChange(view);
|
|
3960
3958
|
};
|
|
3961
|
-
function forceClearComposition(view, rapid) {
|
|
3962
|
-
if (view.docView.compositionDeco.size) {
|
|
3963
|
-
view.inputState.rapidCompositionStart = rapid;
|
|
3964
|
-
try {
|
|
3965
|
-
view.update([]);
|
|
3966
|
-
}
|
|
3967
|
-
finally {
|
|
3968
|
-
view.inputState.rapidCompositionStart = false;
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
}
|
|
3972
3959
|
handlers.compositionstart = handlers.compositionupdate = view => {
|
|
3973
3960
|
if (view.inputState.compositionFirstChange == null)
|
|
3974
3961
|
view.inputState.compositionFirstChange = true;
|
|
3975
3962
|
if (view.inputState.composing < 0) {
|
|
3976
3963
|
// FIXME possibly set a timeout to clear it again on Android
|
|
3977
3964
|
view.inputState.composing = 0;
|
|
3978
|
-
if (view.docView.compositionDeco.size) {
|
|
3979
|
-
view.observer.flush();
|
|
3980
|
-
forceClearComposition(view, true);
|
|
3981
|
-
}
|
|
3982
3965
|
}
|
|
3983
3966
|
};
|
|
3984
3967
|
handlers.compositionend = view => {
|
|
3985
3968
|
view.inputState.composing = -1;
|
|
3986
3969
|
view.inputState.compositionEndedAt = Date.now();
|
|
3987
3970
|
view.inputState.compositionFirstChange = null;
|
|
3971
|
+
if (browser.chrome && browser.android)
|
|
3972
|
+
view.observer.flushSoon();
|
|
3988
3973
|
setTimeout(() => {
|
|
3989
|
-
if
|
|
3990
|
-
|
|
3974
|
+
// Force the composition state to be cleared if it hasn't already been
|
|
3975
|
+
if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
|
|
3976
|
+
view.update([]);
|
|
3991
3977
|
}, 50);
|
|
3992
3978
|
};
|
|
3993
3979
|
handlers.contextmenu = view => {
|
|
@@ -4158,13 +4144,13 @@ const Epsilon = 1e-3;
|
|
|
4158
4144
|
class HeightMap {
|
|
4159
4145
|
constructor(length, // The number of characters covered
|
|
4160
4146
|
height, // Height of this part of the document
|
|
4161
|
-
flags = 2 /* Outdated */) {
|
|
4147
|
+
flags = 2 /* Flag.Outdated */) {
|
|
4162
4148
|
this.length = length;
|
|
4163
4149
|
this.height = height;
|
|
4164
4150
|
this.flags = flags;
|
|
4165
4151
|
}
|
|
4166
|
-
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4167
|
-
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4152
|
+
get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
|
|
4153
|
+
set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
|
|
4168
4154
|
setHeight(oracle, height) {
|
|
4169
4155
|
if (this.height != height) {
|
|
4170
4156
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4291,7 +4277,7 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4291
4277
|
}
|
|
4292
4278
|
replace(_from, _to, nodes) {
|
|
4293
4279
|
let node = nodes[0];
|
|
4294
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4280
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
|
|
4295
4281
|
Math.abs(this.length - node.length) < 10) {
|
|
4296
4282
|
if (node instanceof HeightMapGap)
|
|
4297
4283
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4417,12 +4403,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4417
4403
|
}
|
|
4418
4404
|
class HeightMapBranch extends HeightMap {
|
|
4419
4405
|
constructor(left, brk, right) {
|
|
4420
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4406
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
|
|
4421
4407
|
this.left = left;
|
|
4422
4408
|
this.right = right;
|
|
4423
4409
|
this.size = left.size + right.size;
|
|
4424
4410
|
}
|
|
4425
|
-
get break() { return this.flags & 1 /* Break */; }
|
|
4411
|
+
get break() { return this.flags & 1 /* Flag.Break */; }
|
|
4426
4412
|
blockAt(height, doc, top, offset) {
|
|
4427
4413
|
let mid = top + this.left.height;
|
|
4428
4414
|
return height < mid ? this.left.blockAt(height, doc, top, offset)
|
|
@@ -4606,7 +4592,7 @@ class NodeBuilder {
|
|
|
4606
4592
|
blankContent(from, to) {
|
|
4607
4593
|
let gap = new HeightMapGap(to - from);
|
|
4608
4594
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4609
|
-
gap.flags |= 4 /* SingleLine */;
|
|
4595
|
+
gap.flags |= 4 /* Flag.SingleLine */;
|
|
4610
4596
|
return gap;
|
|
4611
4597
|
}
|
|
4612
4598
|
ensureLine() {
|
|
@@ -4677,10 +4663,10 @@ class DecorationComparator {
|
|
|
4677
4663
|
|
|
4678
4664
|
function visiblePixelRange(dom, paddingTop) {
|
|
4679
4665
|
let rect = dom.getBoundingClientRect();
|
|
4680
|
-
let
|
|
4681
|
-
let
|
|
4682
|
-
let
|
|
4683
|
-
for (let parent = dom.parentNode; parent && parent != body;) {
|
|
4666
|
+
let doc = dom.ownerDocument, win = doc.defaultView;
|
|
4667
|
+
let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
|
|
4668
|
+
let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
|
|
4669
|
+
for (let parent = dom.parentNode; parent && parent != doc.body;) {
|
|
4684
4670
|
if (parent.nodeType == 1) {
|
|
4685
4671
|
let elt = parent;
|
|
4686
4672
|
let style = window.getComputedStyle(elt);
|
|
@@ -4804,7 +4790,7 @@ class ViewState {
|
|
|
4804
4790
|
}
|
|
4805
4791
|
}
|
|
4806
4792
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
4807
|
-
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
4793
|
+
this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
|
|
4808
4794
|
new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
|
|
4809
4795
|
}
|
|
4810
4796
|
updateViewportLines() {
|
|
@@ -4822,18 +4808,18 @@ class ViewState {
|
|
|
4822
4808
|
let prevHeight = this.heightMap.height;
|
|
4823
4809
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
4824
4810
|
if (this.heightMap.height != prevHeight)
|
|
4825
|
-
update.flags |= 2 /* Height */;
|
|
4811
|
+
update.flags |= 2 /* UpdateFlag.Height */;
|
|
4826
4812
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
4827
4813
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
4828
4814
|
!this.viewportIsAppropriate(viewport))
|
|
4829
4815
|
viewport = this.getViewport(0, scrollTarget);
|
|
4830
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
4816
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||
|
|
4831
4817
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
4832
4818
|
this.viewport = viewport;
|
|
4833
4819
|
this.updateForViewport();
|
|
4834
4820
|
if (updateLines)
|
|
4835
4821
|
this.updateViewportLines();
|
|
4836
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4822
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4837
4823
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
4838
4824
|
update.flags |= this.computeVisibleRanges();
|
|
4839
4825
|
if (scrollTarget)
|
|
@@ -4857,13 +4843,13 @@ class ViewState {
|
|
|
4857
4843
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4858
4844
|
this.paddingTop = paddingTop;
|
|
4859
4845
|
this.paddingBottom = paddingBottom;
|
|
4860
|
-
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4846
|
+
result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
|
|
4861
4847
|
}
|
|
4862
4848
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4863
4849
|
if (oracle.lineWrapping)
|
|
4864
4850
|
measureContent = true;
|
|
4865
4851
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4866
|
-
result |= 8 /* Geometry */;
|
|
4852
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4867
4853
|
}
|
|
4868
4854
|
// Pixel viewport
|
|
4869
4855
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
@@ -4875,13 +4861,13 @@ class ViewState {
|
|
|
4875
4861
|
if (inView)
|
|
4876
4862
|
measureContent = true;
|
|
4877
4863
|
}
|
|
4878
|
-
if (!this.inView)
|
|
4864
|
+
if (!this.inView && !this.scrollTarget)
|
|
4879
4865
|
return 0;
|
|
4880
4866
|
let contentWidth = dom.clientWidth;
|
|
4881
4867
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
4882
4868
|
this.contentDOMWidth = contentWidth;
|
|
4883
4869
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
4884
|
-
result |= 8 /* Geometry */;
|
|
4870
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4885
4871
|
}
|
|
4886
4872
|
if (measureContent) {
|
|
4887
4873
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -4892,7 +4878,7 @@ class ViewState {
|
|
|
4892
4878
|
refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
|
|
4893
4879
|
if (refresh) {
|
|
4894
4880
|
view.docView.minWidth = 0;
|
|
4895
|
-
result |= 8 /* Geometry */;
|
|
4881
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4896
4882
|
}
|
|
4897
4883
|
}
|
|
4898
4884
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -4905,16 +4891,16 @@ class ViewState {
|
|
|
4905
4891
|
this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
4906
4892
|
}
|
|
4907
4893
|
if (oracle.heightChanged)
|
|
4908
|
-
result |= 2 /* Height */;
|
|
4894
|
+
result |= 2 /* UpdateFlag.Height */;
|
|
4909
4895
|
}
|
|
4910
4896
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
4911
4897
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
|
|
4912
4898
|
if (viewportChange)
|
|
4913
4899
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
4914
4900
|
this.updateForViewport();
|
|
4915
|
-
if ((result & 2 /* Height */) || viewportChange)
|
|
4901
|
+
if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
|
|
4916
4902
|
this.updateViewportLines();
|
|
4917
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4903
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4918
4904
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
|
|
4919
4905
|
result |= this.computeVisibleRanges();
|
|
4920
4906
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -4933,9 +4919,9 @@ class ViewState {
|
|
|
4933
4919
|
// This will divide VP.Margin between the top and the
|
|
4934
4920
|
// bottom, depending on the bias (the change in viewport position
|
|
4935
4921
|
// since the last update). It'll hold a number between 0 and 1
|
|
4936
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
4922
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
|
|
4937
4923
|
let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
|
|
4938
|
-
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);
|
|
4924
|
+
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);
|
|
4939
4925
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
4940
4926
|
if (scrollTarget) {
|
|
4941
4927
|
let { head } = scrollTarget.range;
|
|
@@ -4948,7 +4934,7 @@ class ViewState {
|
|
|
4948
4934
|
topPos = block.top;
|
|
4949
4935
|
else
|
|
4950
4936
|
topPos = block.bottom - viewHeight;
|
|
4951
|
-
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);
|
|
4937
|
+
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);
|
|
4952
4938
|
}
|
|
4953
4939
|
}
|
|
4954
4940
|
return viewport;
|
|
@@ -4965,10 +4951,10 @@ class ViewState {
|
|
|
4965
4951
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4966
4952
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4967
4953
|
let { visibleTop, visibleBottom } = this;
|
|
4968
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
4954
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4969
4955
|
(to == this.state.doc.length ||
|
|
4970
|
-
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
4971
|
-
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
4956
|
+
bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4957
|
+
(top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
|
|
4972
4958
|
}
|
|
4973
4959
|
mapLineGaps(gaps, changes) {
|
|
4974
4960
|
if (!gaps.length || changes.empty)
|
|
@@ -4992,20 +4978,20 @@ class ViewState {
|
|
|
4992
4978
|
if (this.defaultTextDirection != exports.Direction.LTR)
|
|
4993
4979
|
return gaps;
|
|
4994
4980
|
for (let line of this.viewportLines) {
|
|
4995
|
-
if (line.length < 4000 /* DoubleMargin */)
|
|
4981
|
+
if (line.length < 4000 /* LG.DoubleMargin */)
|
|
4996
4982
|
continue;
|
|
4997
4983
|
let structure = lineStructure(line.from, line.to, this.stateDeco);
|
|
4998
|
-
if (structure.total < 4000 /* DoubleMargin */)
|
|
4984
|
+
if (structure.total < 4000 /* LG.DoubleMargin */)
|
|
4999
4985
|
continue;
|
|
5000
4986
|
let viewFrom, viewTo;
|
|
5001
4987
|
if (this.heightOracle.lineWrapping) {
|
|
5002
|
-
let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4988
|
+
let marginHeight = (2000 /* LG.Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
5003
4989
|
viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
|
|
5004
4990
|
viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
|
|
5005
4991
|
}
|
|
5006
4992
|
else {
|
|
5007
4993
|
let totalWidth = structure.total * this.heightOracle.charWidth;
|
|
5008
|
-
let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
|
|
4994
|
+
let marginWidth = 2000 /* LG.Margin */ * this.heightOracle.charWidth;
|
|
5009
4995
|
viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
|
|
5010
4996
|
viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
|
|
5011
4997
|
}
|
|
@@ -5017,13 +5003,13 @@ class ViewState {
|
|
|
5017
5003
|
let sel = this.state.selection.main;
|
|
5018
5004
|
// Make sure the gaps don't cover a selection end
|
|
5019
5005
|
if (sel.from >= line.from && sel.from <= line.to)
|
|
5020
|
-
cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
|
|
5006
|
+
cutRange(outside, sel.from - 10 /* LG.SelectionMargin */, sel.from + 10 /* LG.SelectionMargin */);
|
|
5021
5007
|
if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
|
|
5022
|
-
cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
|
|
5008
|
+
cutRange(outside, sel.to - 10 /* LG.SelectionMargin */, sel.to + 10 /* LG.SelectionMargin */);
|
|
5023
5009
|
for (let { from, to } of outside)
|
|
5024
|
-
if (to - from > 1000 /* HalfMargin */) {
|
|
5010
|
+
if (to - from > 1000 /* LG.HalfMargin */) {
|
|
5025
5011
|
gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
|
|
5026
|
-
Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
|
|
5012
|
+
Math.abs(gap.from - from) < 1000 /* LG.HalfMargin */ && Math.abs(gap.to - to) < 1000 /* LG.HalfMargin */) ||
|
|
5027
5013
|
new LineGap(from, to, this.gapSize(line, from, to, structure)));
|
|
5028
5014
|
}
|
|
5029
5015
|
}
|
|
@@ -5056,7 +5042,7 @@ class ViewState {
|
|
|
5056
5042
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5057
5043
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5058
5044
|
this.visibleRanges = ranges;
|
|
5059
|
-
return changed ? 4 /* Viewport */ : 0;
|
|
5045
|
+
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
5060
5046
|
}
|
|
5061
5047
|
lineBlockAt(pos) {
|
|
5062
5048
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5162,7 +5148,7 @@ class BigScaler {
|
|
|
5162
5148
|
vpHeight += bottom - top;
|
|
5163
5149
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5164
5150
|
});
|
|
5165
|
-
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5151
|
+
this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5166
5152
|
for (let obj of this.viewports) {
|
|
5167
5153
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5168
5154
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5319,8 +5305,8 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
|
5319
5305
|
"&.cm-focused .cm-cursor": {
|
|
5320
5306
|
display: "block"
|
|
5321
5307
|
},
|
|
5322
|
-
"&light .cm-activeLine": { backgroundColor: "#
|
|
5323
|
-
"&dark .cm-activeLine": { backgroundColor: "#
|
|
5308
|
+
"&light .cm-activeLine": { backgroundColor: "#cceeff44" },
|
|
5309
|
+
"&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
|
|
5324
5310
|
"&light .cm-specialChar": { color: "red" },
|
|
5325
5311
|
"&dark .cm-specialChar": { color: "#f78" },
|
|
5326
5312
|
".cm-gutters": {
|
|
@@ -5465,6 +5451,7 @@ class DOMObserver {
|
|
|
5465
5451
|
this.resizeTimeout = -1;
|
|
5466
5452
|
this.queue = [];
|
|
5467
5453
|
this.delayedAndroidKey = null;
|
|
5454
|
+
this.lastChange = 0;
|
|
5468
5455
|
this.scrollTargets = [];
|
|
5469
5456
|
this.intersection = null;
|
|
5470
5457
|
this.resize = null;
|
|
@@ -5511,8 +5498,7 @@ class DOMObserver {
|
|
|
5511
5498
|
});
|
|
5512
5499
|
this.resize.observe(view.scrollDOM);
|
|
5513
5500
|
}
|
|
5514
|
-
this.win = view.
|
|
5515
|
-
this.addWindowListeners(this.win);
|
|
5501
|
+
this.addWindowListeners(this.win = view.win);
|
|
5516
5502
|
this.start();
|
|
5517
5503
|
if (typeof IntersectionObserver == "function") {
|
|
5518
5504
|
this.intersection = new IntersectionObserver(entries => {
|
|
@@ -5691,26 +5677,34 @@ class DOMObserver {
|
|
|
5691
5677
|
// detected (via beforeinput or keydown), and then tries to flush
|
|
5692
5678
|
// them or, if that has no effect, dispatches the given key.
|
|
5693
5679
|
delayAndroidKey(key, keyCode) {
|
|
5680
|
+
var _a;
|
|
5694
5681
|
if (!this.delayedAndroidKey)
|
|
5695
|
-
requestAnimationFrame(() => {
|
|
5682
|
+
this.view.win.requestAnimationFrame(() => {
|
|
5696
5683
|
let key = this.delayedAndroidKey;
|
|
5697
5684
|
this.delayedAndroidKey = null;
|
|
5698
5685
|
this.delayedFlush = -1;
|
|
5699
|
-
if (!this.flush())
|
|
5686
|
+
if (!this.flush() && key.force)
|
|
5700
5687
|
dispatchKey(this.dom, key.key, key.keyCode);
|
|
5701
5688
|
});
|
|
5702
5689
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5703
5690
|
// Enter always takes precedence.
|
|
5704
5691
|
if (!this.delayedAndroidKey || key == "Enter")
|
|
5705
|
-
this.delayedAndroidKey = {
|
|
5692
|
+
this.delayedAndroidKey = {
|
|
5693
|
+
key, keyCode,
|
|
5694
|
+
// Only run the key handler when no changes are detected if
|
|
5695
|
+
// this isn't coming right after another change, in which case
|
|
5696
|
+
// it is probably part of a weird chain of updates, and should
|
|
5697
|
+
// be ignored if it returns the DOM to its previous state.
|
|
5698
|
+
force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
|
|
5699
|
+
};
|
|
5706
5700
|
}
|
|
5707
5701
|
flushSoon() {
|
|
5708
5702
|
if (this.delayedFlush < 0)
|
|
5709
|
-
this.delayedFlush =
|
|
5703
|
+
this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
|
|
5710
5704
|
}
|
|
5711
5705
|
forceFlush() {
|
|
5712
5706
|
if (this.delayedFlush >= 0) {
|
|
5713
|
-
|
|
5707
|
+
this.view.win.cancelAnimationFrame(this.delayedFlush);
|
|
5714
5708
|
this.delayedFlush = -1;
|
|
5715
5709
|
}
|
|
5716
5710
|
this.flush();
|
|
@@ -5744,13 +5738,15 @@ class DOMObserver {
|
|
|
5744
5738
|
// managing those will make sure processRecords is called and the
|
|
5745
5739
|
// view is resynchronized after
|
|
5746
5740
|
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
|
|
5747
|
-
return;
|
|
5741
|
+
return false;
|
|
5748
5742
|
if (readSelection)
|
|
5749
5743
|
this.readSelectionRange();
|
|
5750
5744
|
let { from, to, typeOver } = this.processRecords();
|
|
5751
5745
|
let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
|
|
5752
5746
|
if (from < 0 && !newSel)
|
|
5753
|
-
return;
|
|
5747
|
+
return false;
|
|
5748
|
+
if (from > -1)
|
|
5749
|
+
this.lastChange = Date.now();
|
|
5754
5750
|
this.view.inputState.lastFocusTime = 0;
|
|
5755
5751
|
this.selectionChanged = false;
|
|
5756
5752
|
let startState = this.view.state;
|
|
@@ -5766,7 +5762,7 @@ class DOMObserver {
|
|
|
5766
5762
|
return null;
|
|
5767
5763
|
cView.markDirty(rec.type == "attributes");
|
|
5768
5764
|
if (rec.type == "attributes")
|
|
5769
|
-
cView.dirty |= 4 /* Attrs */;
|
|
5765
|
+
cView.dirty |= 4 /* Dirty.Attrs */;
|
|
5770
5766
|
if (rec.type == "childList") {
|
|
5771
5767
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
5772
5768
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -6093,7 +6089,7 @@ class EditorView {
|
|
|
6093
6089
|
/**
|
|
6094
6090
|
@internal
|
|
6095
6091
|
*/
|
|
6096
|
-
this.updateState = 2 /* Updating */;
|
|
6092
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6097
6093
|
/**
|
|
6098
6094
|
@internal
|
|
6099
6095
|
*/
|
|
@@ -6132,7 +6128,7 @@ class EditorView {
|
|
|
6132
6128
|
this.docView = new DocView(this);
|
|
6133
6129
|
this.mountStyles();
|
|
6134
6130
|
this.updateAttrs();
|
|
6135
|
-
this.updateState = 0 /* Idle */;
|
|
6131
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6136
6132
|
this.requestMeasure();
|
|
6137
6133
|
if (config.parent)
|
|
6138
6134
|
config.parent.appendChild(this.dom);
|
|
@@ -6180,6 +6176,10 @@ class EditorView {
|
|
|
6180
6176
|
The document or shadow root that the view lives in.
|
|
6181
6177
|
*/
|
|
6182
6178
|
get root() { return this._root; }
|
|
6179
|
+
/**
|
|
6180
|
+
@internal
|
|
6181
|
+
*/
|
|
6182
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6183
6183
|
dispatch(...input) {
|
|
6184
6184
|
this._dispatch(input.length == 1 && input[0] instanceof state.Transaction ? input[0]
|
|
6185
6185
|
: this.state.update(...input));
|
|
@@ -6193,7 +6193,7 @@ class EditorView {
|
|
|
6193
6193
|
as a primitive.
|
|
6194
6194
|
*/
|
|
6195
6195
|
update(transactions) {
|
|
6196
|
-
if (this.updateState != 0 /* Idle */)
|
|
6196
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6197
6197
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6198
6198
|
let redrawn = false, attrsChanged = false, update;
|
|
6199
6199
|
let state$1 = this.state;
|
|
@@ -6213,7 +6213,7 @@ class EditorView {
|
|
|
6213
6213
|
update = ViewUpdate.create(this, state$1, transactions);
|
|
6214
6214
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6215
6215
|
try {
|
|
6216
|
-
this.updateState = 2 /* Updating */;
|
|
6216
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6217
6217
|
for (let tr of transactions) {
|
|
6218
6218
|
if (scrollTarget)
|
|
6219
6219
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6239,7 +6239,7 @@ class EditorView {
|
|
|
6239
6239
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6240
6240
|
}
|
|
6241
6241
|
finally {
|
|
6242
|
-
this.updateState = 0 /* Idle */;
|
|
6242
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6243
6243
|
}
|
|
6244
6244
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6245
6245
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6257,13 +6257,13 @@ class EditorView {
|
|
|
6257
6257
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6258
6258
|
*/
|
|
6259
6259
|
setState(newState) {
|
|
6260
|
-
if (this.updateState != 0 /* Idle */)
|
|
6260
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6261
6261
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6262
6262
|
if (this.destroyed) {
|
|
6263
6263
|
this.viewState.state = newState;
|
|
6264
6264
|
return;
|
|
6265
6265
|
}
|
|
6266
|
-
this.updateState = 2 /* Updating */;
|
|
6266
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6267
6267
|
let hadFocus = this.hasFocus;
|
|
6268
6268
|
try {
|
|
6269
6269
|
for (let plugin of this.plugins)
|
|
@@ -6280,7 +6280,7 @@ class EditorView {
|
|
|
6280
6280
|
this.bidiCache = [];
|
|
6281
6281
|
}
|
|
6282
6282
|
finally {
|
|
6283
|
-
this.updateState = 0 /* Idle */;
|
|
6283
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6284
6284
|
}
|
|
6285
6285
|
if (hadFocus)
|
|
6286
6286
|
this.focus();
|
|
@@ -6331,7 +6331,7 @@ class EditorView {
|
|
|
6331
6331
|
let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;
|
|
6332
6332
|
try {
|
|
6333
6333
|
for (let i = 0;; i++) {
|
|
6334
|
-
this.updateState = 1 /* Measuring */;
|
|
6334
|
+
this.updateState = 1 /* UpdateState.Measuring */;
|
|
6335
6335
|
let oldViewport = this.viewport;
|
|
6336
6336
|
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6337
6337
|
let changed = this.viewState.measure(this);
|
|
@@ -6345,7 +6345,7 @@ class EditorView {
|
|
|
6345
6345
|
}
|
|
6346
6346
|
let measuring = [];
|
|
6347
6347
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6348
|
-
if (!(changed & 4 /* Viewport */))
|
|
6348
|
+
if (!(changed & 4 /* UpdateFlag.Viewport */))
|
|
6349
6349
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6350
6350
|
let measured = measuring.map(m => {
|
|
6351
6351
|
try {
|
|
@@ -6362,7 +6362,7 @@ class EditorView {
|
|
|
6362
6362
|
updated = update;
|
|
6363
6363
|
else
|
|
6364
6364
|
updated.flags |= changed;
|
|
6365
|
-
this.updateState = 2 /* Updating */;
|
|
6365
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6366
6366
|
if (!update.empty) {
|
|
6367
6367
|
this.updatePlugins(update);
|
|
6368
6368
|
this.inputState.update(update);
|
|
@@ -6400,7 +6400,7 @@ class EditorView {
|
|
|
6400
6400
|
}
|
|
6401
6401
|
}
|
|
6402
6402
|
finally {
|
|
6403
|
-
this.updateState = 0 /* Idle */;
|
|
6403
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6404
6404
|
this.measureScheduled = -1;
|
|
6405
6405
|
}
|
|
6406
6406
|
if (updated && !updated.empty)
|
|
@@ -6459,9 +6459,9 @@ class EditorView {
|
|
|
6459
6459
|
styleMod.StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6460
6460
|
}
|
|
6461
6461
|
readMeasured() {
|
|
6462
|
-
if (this.updateState == 2 /* Updating */)
|
|
6462
|
+
if (this.updateState == 2 /* UpdateState.Updating */)
|
|
6463
6463
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6464
|
-
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6464
|
+
if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
|
|
6465
6465
|
this.measure(false);
|
|
6466
6466
|
}
|
|
6467
6467
|
/**
|
|
@@ -6474,7 +6474,7 @@ class EditorView {
|
|
|
6474
6474
|
*/
|
|
6475
6475
|
requestMeasure(request) {
|
|
6476
6476
|
if (this.measureScheduled < 0)
|
|
6477
|
-
this.measureScheduled = requestAnimationFrame(() => this.measure());
|
|
6477
|
+
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6478
6478
|
if (request) {
|
|
6479
6479
|
if (request.key != null)
|
|
6480
6480
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
@@ -7349,7 +7349,7 @@ function measureRange(view, range) {
|
|
|
7349
7349
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7350
7350
|
}
|
|
7351
7351
|
function piece(left, top, right, bottom) {
|
|
7352
|
-
return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
|
|
7352
|
+
return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
|
|
7353
7353
|
}
|
|
7354
7354
|
function pieces({ top, bottom, horizontal }) {
|
|
7355
7355
|
let pieces = [];
|
|
@@ -7543,9 +7543,15 @@ class MatchDecorator {
|
|
|
7543
7543
|
if (decorate) {
|
|
7544
7544
|
this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);
|
|
7545
7545
|
}
|
|
7546
|
+
else if (typeof decoration == "function") {
|
|
7547
|
+
this.addMatch = (match, view, from, add) => {
|
|
7548
|
+
let deco = decoration(match, view, from);
|
|
7549
|
+
if (deco)
|
|
7550
|
+
add(from, from + match[0].length, deco);
|
|
7551
|
+
};
|
|
7552
|
+
}
|
|
7546
7553
|
else if (decoration) {
|
|
7547
|
-
|
|
7548
|
-
this.addMatch = (match, view, from, add) => add(from, from + match[0].length, getDeco(match, view, from));
|
|
7554
|
+
this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);
|
|
7549
7555
|
}
|
|
7550
7556
|
else {
|
|
7551
7557
|
throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
|
|
@@ -7812,8 +7818,6 @@ const activeLineHighlighter = ViewPlugin.fromClass(class {
|
|
|
7812
7818
|
getDeco(view) {
|
|
7813
7819
|
let lastLineStart = -1, deco = [];
|
|
7814
7820
|
for (let r of view.state.selection.ranges) {
|
|
7815
|
-
if (!r.empty)
|
|
7816
|
-
return Decoration.none;
|
|
7817
7821
|
let line = view.lineBlockAt(r.head);
|
|
7818
7822
|
if (line.from > lastLineStart) {
|
|
7819
7823
|
deco.push(lineDeco.range(line.from));
|
|
@@ -8031,8 +8035,9 @@ Creates an extension that configures tooltip behavior.
|
|
|
8031
8035
|
function tooltips(config = {}) {
|
|
8032
8036
|
return tooltipConfig.of(config);
|
|
8033
8037
|
}
|
|
8034
|
-
function windowSpace() {
|
|
8035
|
-
|
|
8038
|
+
function windowSpace(view) {
|
|
8039
|
+
let { win } = view;
|
|
8040
|
+
return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
|
|
8036
8041
|
}
|
|
8037
8042
|
const tooltipConfig = state.Facet.define({
|
|
8038
8043
|
combine: values => {
|
|
@@ -8046,7 +8051,6 @@ const tooltipConfig = state.Facet.define({
|
|
|
8046
8051
|
});
|
|
8047
8052
|
const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
8048
8053
|
constructor(view) {
|
|
8049
|
-
var _a;
|
|
8050
8054
|
this.view = view;
|
|
8051
8055
|
this.inView = true;
|
|
8052
8056
|
this.lastTransaction = 0;
|
|
@@ -8064,7 +8068,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8064
8068
|
this.measureSoon();
|
|
8065
8069
|
}, { threshold: [1] }) : null;
|
|
8066
8070
|
this.observeIntersection();
|
|
8067
|
-
|
|
8071
|
+
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
8068
8072
|
this.maybeMeasure();
|
|
8069
8073
|
}
|
|
8070
8074
|
createContainer() {
|
|
@@ -8137,11 +8141,11 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8137
8141
|
return tooltipView;
|
|
8138
8142
|
}
|
|
8139
8143
|
destroy() {
|
|
8140
|
-
var _a
|
|
8141
|
-
|
|
8144
|
+
var _a;
|
|
8145
|
+
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
8142
8146
|
for (let { dom } of this.manager.tooltipViews)
|
|
8143
8147
|
dom.remove();
|
|
8144
|
-
(
|
|
8148
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
8145
8149
|
clearTimeout(this.measureTimeout);
|
|
8146
8150
|
}
|
|
8147
8151
|
readMeasure() {
|
|
@@ -8172,12 +8176,12 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8172
8176
|
continue;
|
|
8173
8177
|
}
|
|
8174
8178
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8175
|
-
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8179
|
+
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
8176
8180
|
let width = size.right - size.left, height = size.bottom - size.top;
|
|
8177
8181
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == exports.Direction.LTR;
|
|
8178
8182
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8179
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8180
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8183
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
8184
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
8181
8185
|
let above = !!tooltip.above;
|
|
8182
8186
|
if (!tooltip.strictSide && (above
|
|
8183
8187
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8199,7 +8203,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8199
8203
|
dom.style.left = left + "px";
|
|
8200
8204
|
}
|
|
8201
8205
|
if (arrow)
|
|
8202
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8206
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */)}px`;
|
|
8203
8207
|
if (tView.overlap !== true)
|
|
8204
8208
|
others.push({ left, top, right, bottom: top + height });
|
|
8205
8209
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8241,8 +8245,8 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8241
8245
|
color: "white"
|
|
8242
8246
|
},
|
|
8243
8247
|
".cm-tooltip-arrow": {
|
|
8244
|
-
height: `${7 /* Size */}px`,
|
|
8245
|
-
width: `${7 /* Size */ * 2}px`,
|
|
8248
|
+
height: `${7 /* Arrow.Size */}px`,
|
|
8249
|
+
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
8246
8250
|
position: "absolute",
|
|
8247
8251
|
zIndex: -1,
|
|
8248
8252
|
overflow: "hidden",
|
|
@@ -8251,26 +8255,26 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8251
8255
|
position: "absolute",
|
|
8252
8256
|
width: 0,
|
|
8253
8257
|
height: 0,
|
|
8254
|
-
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8255
|
-
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8258
|
+
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8259
|
+
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8256
8260
|
},
|
|
8257
8261
|
".cm-tooltip-above &": {
|
|
8258
|
-
bottom: `-${7 /* Size */}px`,
|
|
8262
|
+
bottom: `-${7 /* Arrow.Size */}px`,
|
|
8259
8263
|
"&:before": {
|
|
8260
|
-
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8264
|
+
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8261
8265
|
},
|
|
8262
8266
|
"&:after": {
|
|
8263
|
-
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8267
|
+
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8264
8268
|
bottom: "1px"
|
|
8265
8269
|
}
|
|
8266
8270
|
},
|
|
8267
8271
|
".cm-tooltip-below &": {
|
|
8268
|
-
top: `-${7 /* Size */}px`,
|
|
8272
|
+
top: `-${7 /* Arrow.Size */}px`,
|
|
8269
8273
|
"&:before": {
|
|
8270
|
-
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8274
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8271
8275
|
},
|
|
8272
8276
|
"&:after": {
|
|
8273
|
-
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8277
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8274
8278
|
top: "1px"
|
|
8275
8279
|
}
|
|
8276
8280
|
},
|
|
@@ -8415,7 +8419,7 @@ class HoverPlugin {
|
|
|
8415
8419
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
8416
8420
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
8417
8421
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
8418
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
8422
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* Hover.MaxDist */))) {
|
|
8419
8423
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
8420
8424
|
this.pending = null;
|
|
8421
8425
|
}
|
|
@@ -8497,7 +8501,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
8497
8501
|
});
|
|
8498
8502
|
return [
|
|
8499
8503
|
hoverState,
|
|
8500
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
8504
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
8501
8505
|
showHoverTooltipHost
|
|
8502
8506
|
];
|
|
8503
8507
|
}
|
|
@@ -9128,14 +9132,13 @@ const activeLineGutterMarker = new class extends GutterMarker {
|
|
|
9128
9132
|
};
|
|
9129
9133
|
const activeLineGutterHighlighter = gutterLineClass.compute(["selection"], state$1 => {
|
|
9130
9134
|
let marks = [], last = -1;
|
|
9131
|
-
for (let range of state$1.selection.ranges)
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
marks.push(activeLineGutterMarker.range(linePos));
|
|
9137
|
-
}
|
|
9135
|
+
for (let range of state$1.selection.ranges) {
|
|
9136
|
+
let linePos = state$1.doc.lineAt(range.head).from;
|
|
9137
|
+
if (linePos > last) {
|
|
9138
|
+
last = linePos;
|
|
9139
|
+
marks.push(activeLineGutterMarker.range(linePos));
|
|
9138
9140
|
}
|
|
9141
|
+
}
|
|
9139
9142
|
return state.RangeSet.of(marks);
|
|
9140
9143
|
});
|
|
9141
9144
|
/**
|