@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.js
CHANGED
|
@@ -105,7 +105,7 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
107
|
if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
|
|
108
|
-
cur = cur.parentNode;
|
|
108
|
+
cur = cur.assignedSlot || cur.parentNode;
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
111
111
|
let rect = cur.getBoundingClientRect();
|
|
@@ -156,24 +156,28 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
156
156
|
win.scrollBy(moveX, moveY);
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
+
let movedX = 0, movedY = 0;
|
|
159
160
|
if (moveY) {
|
|
160
161
|
let start = cur.scrollTop;
|
|
161
162
|
cur.scrollTop += moveY;
|
|
162
|
-
|
|
163
|
+
movedY = cur.scrollTop - start;
|
|
163
164
|
}
|
|
164
165
|
if (moveX) {
|
|
165
166
|
let start = cur.scrollLeft;
|
|
166
167
|
cur.scrollLeft += moveX;
|
|
167
|
-
|
|
168
|
+
movedX = cur.scrollLeft - start;
|
|
168
169
|
}
|
|
169
|
-
rect = { left: rect.left -
|
|
170
|
-
right: rect.right -
|
|
170
|
+
rect = { left: rect.left - movedX, top: rect.top - movedY,
|
|
171
|
+
right: rect.right - movedX, bottom: rect.bottom - movedY };
|
|
172
|
+
if (movedX && Math.abs(movedX - moveX) < 1)
|
|
173
|
+
x = "nearest";
|
|
174
|
+
if (movedY && Math.abs(movedY - moveY) < 1)
|
|
175
|
+
y = "nearest";
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
178
|
if (top)
|
|
174
179
|
break;
|
|
175
180
|
cur = cur.assignedSlot || cur.parentNode;
|
|
176
|
-
x = y = "nearest";
|
|
177
181
|
}
|
|
178
182
|
else if (cur.nodeType == 11) { // A shadow root
|
|
179
183
|
cur = cur.host;
|
|
@@ -304,7 +308,7 @@ class ContentView {
|
|
|
304
308
|
constructor() {
|
|
305
309
|
this.parent = null;
|
|
306
310
|
this.dom = null;
|
|
307
|
-
this.dirty = 2 /* Node */;
|
|
311
|
+
this.dirty = 2 /* Dirty.Node */;
|
|
308
312
|
}
|
|
309
313
|
get editorView() {
|
|
310
314
|
if (!this.parent)
|
|
@@ -335,7 +339,7 @@ class ContentView {
|
|
|
335
339
|
// given position.
|
|
336
340
|
coordsAt(_pos, _side) { return null; }
|
|
337
341
|
sync(track) {
|
|
338
|
-
if (this.dirty & 2 /* Node */) {
|
|
342
|
+
if (this.dirty & 2 /* Dirty.Node */) {
|
|
339
343
|
let parent = this.dom;
|
|
340
344
|
let prev = null, next;
|
|
341
345
|
for (let child of this.children) {
|
|
@@ -346,7 +350,7 @@ class ContentView {
|
|
|
346
350
|
child.reuseDOM(next);
|
|
347
351
|
}
|
|
348
352
|
child.sync(track);
|
|
349
|
-
child.dirty = 0 /* Not */;
|
|
353
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
350
354
|
}
|
|
351
355
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
352
356
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -366,11 +370,11 @@ class ContentView {
|
|
|
366
370
|
while (next)
|
|
367
371
|
next = rm$1(next);
|
|
368
372
|
}
|
|
369
|
-
else if (this.dirty & 1 /* Child */) {
|
|
373
|
+
else if (this.dirty & 1 /* Dirty.Child */) {
|
|
370
374
|
for (let child of this.children)
|
|
371
375
|
if (child.dirty) {
|
|
372
376
|
child.sync(track);
|
|
373
|
-
child.dirty = 0 /* Not */;
|
|
377
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
374
378
|
}
|
|
375
379
|
}
|
|
376
380
|
}
|
|
@@ -435,16 +439,16 @@ class ContentView {
|
|
|
435
439
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
436
440
|
}
|
|
437
441
|
markDirty(andParent = false) {
|
|
438
|
-
this.dirty |= 2 /* Node */;
|
|
442
|
+
this.dirty |= 2 /* Dirty.Node */;
|
|
439
443
|
this.markParentsDirty(andParent);
|
|
440
444
|
}
|
|
441
445
|
markParentsDirty(childList) {
|
|
442
446
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
443
447
|
if (childList)
|
|
444
|
-
parent.dirty |= 2 /* Node */;
|
|
445
|
-
if (parent.dirty & 1 /* Child */)
|
|
448
|
+
parent.dirty |= 2 /* Dirty.Node */;
|
|
449
|
+
if (parent.dirty & 1 /* Dirty.Child */)
|
|
446
450
|
return;
|
|
447
|
-
parent.dirty |= 1 /* Child */;
|
|
451
|
+
parent.dirty |= 1 /* Dirty.Child */;
|
|
448
452
|
childList = false;
|
|
449
453
|
}
|
|
450
454
|
}
|
|
@@ -720,13 +724,13 @@ class MarkView extends ContentView {
|
|
|
720
724
|
reuseDOM(node) {
|
|
721
725
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
722
726
|
this.setDOM(node);
|
|
723
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
727
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
724
728
|
}
|
|
725
729
|
}
|
|
726
730
|
sync(track) {
|
|
727
731
|
if (!this.dom)
|
|
728
732
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
729
|
-
else if (this.dirty & 4 /* Attrs */)
|
|
733
|
+
else if (this.dirty & 4 /* Dirty.Attrs */)
|
|
730
734
|
this.setAttrs(this.dom);
|
|
731
735
|
super.sync(track);
|
|
732
736
|
}
|
|
@@ -1235,7 +1239,7 @@ class Decoration extends RangeValue {
|
|
|
1235
1239
|
*/
|
|
1236
1240
|
static widget(spec) {
|
|
1237
1241
|
let side = spec.side || 0, block = !!spec.block;
|
|
1238
|
-
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1242
|
+
side += block ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */) : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
|
|
1239
1243
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1240
1244
|
}
|
|
1241
1245
|
/**
|
|
@@ -1245,13 +1249,13 @@ class Decoration extends RangeValue {
|
|
|
1245
1249
|
static replace(spec) {
|
|
1246
1250
|
let block = !!spec.block, startSide, endSide;
|
|
1247
1251
|
if (spec.isBlockGap) {
|
|
1248
|
-
startSide = -500000000 /* GapStart */;
|
|
1249
|
-
endSide = 400000000 /* GapEnd */;
|
|
1252
|
+
startSide = -500000000 /* Side.GapStart */;
|
|
1253
|
+
endSide = 400000000 /* Side.GapEnd */;
|
|
1250
1254
|
}
|
|
1251
1255
|
else {
|
|
1252
1256
|
let { start, end } = getInclusive(spec, block);
|
|
1253
|
-
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1254
|
-
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1257
|
+
startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
|
|
1258
|
+
endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
|
|
1255
1259
|
}
|
|
1256
1260
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1257
1261
|
}
|
|
@@ -1282,7 +1286,7 @@ Decoration.none = RangeSet.empty;
|
|
|
1282
1286
|
class MarkDecoration extends Decoration {
|
|
1283
1287
|
constructor(spec) {
|
|
1284
1288
|
let { start, end } = getInclusive(spec);
|
|
1285
|
-
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1289
|
+
super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
|
|
1286
1290
|
this.tagName = spec.tagName || "span";
|
|
1287
1291
|
this.class = spec.class || "";
|
|
1288
1292
|
this.attrs = spec.attributes || null;
|
|
@@ -1303,7 +1307,7 @@ class MarkDecoration extends Decoration {
|
|
|
1303
1307
|
MarkDecoration.prototype.point = false;
|
|
1304
1308
|
class LineDecoration extends Decoration {
|
|
1305
1309
|
constructor(spec) {
|
|
1306
|
-
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1310
|
+
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1307
1311
|
}
|
|
1308
1312
|
eq(other) {
|
|
1309
1313
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1440,7 +1444,7 @@ class LineView extends ContentView {
|
|
|
1440
1444
|
reuseDOM(node) {
|
|
1441
1445
|
if (node.nodeName == "DIV") {
|
|
1442
1446
|
this.setDOM(node);
|
|
1443
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1447
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
1444
1448
|
}
|
|
1445
1449
|
}
|
|
1446
1450
|
sync(track) {
|
|
@@ -1450,7 +1454,7 @@ class LineView extends ContentView {
|
|
|
1450
1454
|
this.dom.className = "cm-line";
|
|
1451
1455
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1452
1456
|
}
|
|
1453
|
-
else if (this.dirty & 4 /* Attrs */) {
|
|
1457
|
+
else if (this.dirty & 4 /* Dirty.Attrs */) {
|
|
1454
1458
|
clearAttributes(this.dom);
|
|
1455
1459
|
this.dom.className = "cm-line";
|
|
1456
1460
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1580,7 +1584,7 @@ class ContentBuilder {
|
|
|
1580
1584
|
this.content = [];
|
|
1581
1585
|
this.curLine = null;
|
|
1582
1586
|
this.breakAtStart = 0;
|
|
1583
|
-
this.pendingBuffer = 0 /* No */;
|
|
1587
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1584
1588
|
// Set to false directly after a widget that covers the position after it
|
|
1585
1589
|
this.atCursorPos = true;
|
|
1586
1590
|
this.openStart = -1;
|
|
@@ -1606,7 +1610,7 @@ class ContentBuilder {
|
|
|
1606
1610
|
flushBuffer(active) {
|
|
1607
1611
|
if (this.pendingBuffer) {
|
|
1608
1612
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1609
|
-
this.pendingBuffer = 0 /* No */;
|
|
1613
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1610
1614
|
}
|
|
1611
1615
|
}
|
|
1612
1616
|
addBlockWidget(view) {
|
|
@@ -1618,7 +1622,7 @@ class ContentBuilder {
|
|
|
1618
1622
|
if (!openEnd)
|
|
1619
1623
|
this.flushBuffer([]);
|
|
1620
1624
|
else
|
|
1621
|
-
this.pendingBuffer = 0 /* No */;
|
|
1625
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1622
1626
|
if (!this.posCovered())
|
|
1623
1627
|
this.getLine();
|
|
1624
1628
|
}
|
|
@@ -1646,7 +1650,7 @@ class ContentBuilder {
|
|
|
1646
1650
|
this.textOff = 0;
|
|
1647
1651
|
}
|
|
1648
1652
|
}
|
|
1649
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1653
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
|
|
1650
1654
|
this.flushBuffer(active.slice(0, openStart));
|
|
1651
1655
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1652
1656
|
this.atCursorPos = true;
|
|
@@ -1681,8 +1685,8 @@ class ContentBuilder {
|
|
|
1681
1685
|
let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
|
|
1682
1686
|
let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
|
|
1683
1687
|
let line = this.getLine();
|
|
1684
|
-
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
|
|
1685
|
-
this.pendingBuffer = 0 /* No */;
|
|
1688
|
+
if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore)
|
|
1689
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1686
1690
|
this.flushBuffer(active);
|
|
1687
1691
|
if (cursorBefore) {
|
|
1688
1692
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1690,7 +1694,7 @@ class ContentBuilder {
|
|
|
1690
1694
|
}
|
|
1691
1695
|
line.append(wrapMarks(view, active), openStart);
|
|
1692
1696
|
this.atCursorPos = cursorAfter;
|
|
1693
|
-
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1697
|
+
this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
|
|
1694
1698
|
}
|
|
1695
1699
|
}
|
|
1696
1700
|
else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
|
|
@@ -1983,7 +1987,7 @@ class ViewUpdate {
|
|
|
1983
1987
|
let focus = view.hasFocus;
|
|
1984
1988
|
if (focus != view.inputState.notifiedFocused) {
|
|
1985
1989
|
view.inputState.notifiedFocused = focus;
|
|
1986
|
-
this.flags |= 1 /* Focus */;
|
|
1990
|
+
this.flags |= 1 /* UpdateFlag.Focus */;
|
|
1987
1991
|
}
|
|
1988
1992
|
}
|
|
1989
1993
|
/**
|
|
@@ -1998,27 +2002,27 @@ class ViewUpdate {
|
|
|
1998
2002
|
update.
|
|
1999
2003
|
*/
|
|
2000
2004
|
get viewportChanged() {
|
|
2001
|
-
return (this.flags & 4 /* Viewport */) > 0;
|
|
2005
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
2002
2006
|
}
|
|
2003
2007
|
/**
|
|
2004
2008
|
Indicates whether the height of a block element in the editor
|
|
2005
2009
|
changed in this update.
|
|
2006
2010
|
*/
|
|
2007
2011
|
get heightChanged() {
|
|
2008
|
-
return (this.flags & 2 /* Height */) > 0;
|
|
2012
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2009
2013
|
}
|
|
2010
2014
|
/**
|
|
2011
2015
|
Returns true when the document was modified or the size of the
|
|
2012
2016
|
editor, or elements within the editor, changed.
|
|
2013
2017
|
*/
|
|
2014
2018
|
get geometryChanged() {
|
|
2015
|
-
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2019
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2016
2020
|
}
|
|
2017
2021
|
/**
|
|
2018
2022
|
True when this update indicates a focus change.
|
|
2019
2023
|
*/
|
|
2020
2024
|
get focusChanged() {
|
|
2021
|
-
return (this.flags & 1 /* Focus */) > 0;
|
|
2025
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2022
2026
|
}
|
|
2023
2027
|
/**
|
|
2024
2028
|
Whether the document changed in this update.
|
|
@@ -2076,12 +2080,12 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2076
2080
|
}
|
|
2077
2081
|
function charType(ch) {
|
|
2078
2082
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2079
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2083
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2080
2084
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2081
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2082
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2083
|
-
0xfb50 <= ch && ch <= 0xfdff ? 4 /* AL */ :
|
|
2084
|
-
ch == 0x200c ? 256 /* NI */ : 1 /* L */;
|
|
2085
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2086
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :
|
|
2087
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :
|
|
2088
|
+
ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;
|
|
2085
2089
|
}
|
|
2086
2090
|
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2087
2091
|
/**
|
|
@@ -2146,8 +2150,8 @@ class BidiSpan {
|
|
|
2146
2150
|
// Reused array of character types
|
|
2147
2151
|
const types = [];
|
|
2148
2152
|
function computeOrder(line, direction) {
|
|
2149
|
-
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2150
|
-
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2153
|
+
let len = line.length, outerType = direction == LTR ? 1 /* T.L */ : 2 /* T.R */, oppositeType = direction == LTR ? 2 /* T.R */ : 1 /* T.L */;
|
|
2154
|
+
if (!line || outerType == 1 /* T.L */ && !BidiRE.test(line))
|
|
2151
2155
|
return trivialOrder(len);
|
|
2152
2156
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2153
2157
|
// change the type of the NSM to the type of the previous
|
|
@@ -2161,12 +2165,12 @@ function computeOrder(line, direction) {
|
|
|
2161
2165
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2162
2166
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2163
2167
|
let type = charType(line.charCodeAt(i));
|
|
2164
|
-
if (type == 512 /* NSM */)
|
|
2168
|
+
if (type == 512 /* T.NSM */)
|
|
2165
2169
|
type = prev;
|
|
2166
|
-
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2167
|
-
type = 16 /* AN */;
|
|
2168
|
-
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2169
|
-
if (type & 7 /* Strong */)
|
|
2170
|
+
else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
|
|
2171
|
+
type = 16 /* T.AN */;
|
|
2172
|
+
types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
|
|
2173
|
+
if (type & 7 /* T.Strong */)
|
|
2170
2174
|
prevStrong = type;
|
|
2171
2175
|
prev = type;
|
|
2172
2176
|
}
|
|
@@ -2180,26 +2184,26 @@ function computeOrder(line, direction) {
|
|
|
2180
2184
|
// (Left after this: L, R, EN+AN, NI)
|
|
2181
2185
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2182
2186
|
let type = types[i];
|
|
2183
|
-
if (type == 128 /* CS */) {
|
|
2184
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2187
|
+
if (type == 128 /* T.CS */) {
|
|
2188
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
|
|
2185
2189
|
type = types[i] = prev;
|
|
2186
2190
|
else
|
|
2187
|
-
types[i] = 256 /* NI */;
|
|
2191
|
+
types[i] = 256 /* T.NI */;
|
|
2188
2192
|
}
|
|
2189
|
-
else if (type == 64 /* ET */) {
|
|
2193
|
+
else if (type == 64 /* T.ET */) {
|
|
2190
2194
|
let end = i + 1;
|
|
2191
|
-
while (end < len && types[end] == 64 /* ET */)
|
|
2195
|
+
while (end < len && types[end] == 64 /* T.ET */)
|
|
2192
2196
|
end++;
|
|
2193
|
-
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2197
|
+
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 */;
|
|
2194
2198
|
for (let j = i; j < end; j++)
|
|
2195
2199
|
types[j] = replace;
|
|
2196
2200
|
i = end - 1;
|
|
2197
2201
|
}
|
|
2198
|
-
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2199
|
-
types[i] = 1 /* L */;
|
|
2202
|
+
else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
|
|
2203
|
+
types[i] = 1 /* T.L */;
|
|
2200
2204
|
}
|
|
2201
2205
|
prev = type;
|
|
2202
|
-
if (type & 7 /* Strong */)
|
|
2206
|
+
if (type & 7 /* T.Strong */)
|
|
2203
2207
|
prevStrong = type;
|
|
2204
2208
|
}
|
|
2205
2209
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2214,9 +2218,9 @@ function computeOrder(line, direction) {
|
|
|
2214
2218
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2215
2219
|
if (BracketStack[sJ + 1] == -br) {
|
|
2216
2220
|
let flags = BracketStack[sJ + 2];
|
|
2217
|
-
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2218
|
-
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2219
|
-
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2221
|
+
let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
|
|
2222
|
+
!(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
|
|
2223
|
+
(flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
|
|
2220
2224
|
if (type)
|
|
2221
2225
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2222
2226
|
sI = sJ;
|
|
@@ -2224,7 +2228,7 @@ function computeOrder(line, direction) {
|
|
|
2224
2228
|
}
|
|
2225
2229
|
}
|
|
2226
2230
|
}
|
|
2227
|
-
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2231
|
+
else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
|
|
2228
2232
|
break;
|
|
2229
2233
|
}
|
|
2230
2234
|
else {
|
|
@@ -2233,20 +2237,20 @@ function computeOrder(line, direction) {
|
|
|
2233
2237
|
BracketStack[sI++] = context;
|
|
2234
2238
|
}
|
|
2235
2239
|
}
|
|
2236
|
-
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2240
|
+
else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
|
|
2237
2241
|
let embed = type == outerType;
|
|
2238
|
-
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2242
|
+
context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
|
|
2239
2243
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2240
2244
|
let cur = BracketStack[sJ + 2];
|
|
2241
|
-
if (cur & 2 /* EmbedInside */)
|
|
2245
|
+
if (cur & 2 /* Bracketed.EmbedInside */)
|
|
2242
2246
|
break;
|
|
2243
2247
|
if (embed) {
|
|
2244
|
-
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2248
|
+
BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
|
|
2245
2249
|
}
|
|
2246
2250
|
else {
|
|
2247
|
-
if (cur & 4 /* OppositeInside */)
|
|
2251
|
+
if (cur & 4 /* Bracketed.OppositeInside */)
|
|
2248
2252
|
break;
|
|
2249
|
-
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2253
|
+
BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
|
|
2250
2254
|
}
|
|
2251
2255
|
}
|
|
2252
2256
|
}
|
|
@@ -2259,13 +2263,13 @@ function computeOrder(line, direction) {
|
|
|
2259
2263
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2260
2264
|
// (Left after this: L, R, EN+AN)
|
|
2261
2265
|
for (let i = 0; i < len; i++) {
|
|
2262
|
-
if (types[i] == 256 /* NI */) {
|
|
2266
|
+
if (types[i] == 256 /* T.NI */) {
|
|
2263
2267
|
let end = i + 1;
|
|
2264
|
-
while (end < len && types[end] == 256 /* NI */)
|
|
2268
|
+
while (end < len && types[end] == 256 /* T.NI */)
|
|
2265
2269
|
end++;
|
|
2266
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2267
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2268
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2270
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* T.L */;
|
|
2271
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* T.L */;
|
|
2272
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
|
|
2269
2273
|
for (let j = i; j < end; j++)
|
|
2270
2274
|
types[j] = replace;
|
|
2271
2275
|
i = end - 1;
|
|
@@ -2277,15 +2281,15 @@ function computeOrder(line, direction) {
|
|
|
2277
2281
|
// explicit embedding into account, we can build up the order on
|
|
2278
2282
|
// the fly, without following the level-based algorithm.
|
|
2279
2283
|
let order = [];
|
|
2280
|
-
if (outerType == 1 /* L */) {
|
|
2284
|
+
if (outerType == 1 /* T.L */) {
|
|
2281
2285
|
for (let i = 0; i < len;) {
|
|
2282
|
-
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2283
|
-
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2286
|
+
let start = i, rtl = types[i++] != 1 /* T.L */;
|
|
2287
|
+
while (i < len && rtl == (types[i] != 1 /* T.L */))
|
|
2284
2288
|
i++;
|
|
2285
2289
|
if (rtl) {
|
|
2286
2290
|
for (let j = i; j > start;) {
|
|
2287
|
-
let end = j, l = types[--j] != 2 /* R */;
|
|
2288
|
-
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2291
|
+
let end = j, l = types[--j] != 2 /* T.R */;
|
|
2292
|
+
while (j > start && l == (types[j - 1] != 2 /* T.R */))
|
|
2289
2293
|
j--;
|
|
2290
2294
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2291
2295
|
}
|
|
@@ -2297,8 +2301,8 @@ function computeOrder(line, direction) {
|
|
|
2297
2301
|
}
|
|
2298
2302
|
else {
|
|
2299
2303
|
for (let i = 0; i < len;) {
|
|
2300
|
-
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2301
|
-
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2304
|
+
let start = i, rtl = types[i++] == 2 /* T.R */;
|
|
2305
|
+
while (i < len && rtl == (types[i] == 2 /* T.R */))
|
|
2302
2306
|
i++;
|
|
2303
2307
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2304
2308
|
}
|
|
@@ -2519,7 +2523,7 @@ class DocView extends ContentView {
|
|
|
2519
2523
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2520
2524
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2521
2525
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2522
|
-
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2526
|
+
if (this.dirty == 0 /* Dirty.Not */ && changedRanges.length == 0) {
|
|
2523
2527
|
return false;
|
|
2524
2528
|
}
|
|
2525
2529
|
else {
|
|
@@ -2548,7 +2552,7 @@ class DocView extends ContentView {
|
|
|
2548
2552
|
// to detect that situation.
|
|
2549
2553
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2550
2554
|
this.sync(track);
|
|
2551
|
-
this.dirty = 0 /* Not */;
|
|
2555
|
+
this.dirty = 0 /* Dirty.Not */;
|
|
2552
2556
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2553
2557
|
this.forceSelection = true;
|
|
2554
2558
|
this.dom.style.height = "";
|
|
@@ -2577,8 +2581,7 @@ class DocView extends ContentView {
|
|
|
2577
2581
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2578
2582
|
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2579
2583
|
this.view.observer.readSelectionRange();
|
|
2580
|
-
if (!(fromPointer || this.mayControlSelection())
|
|
2581
|
-
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
2584
|
+
if (!(fromPointer || this.mayControlSelection()))
|
|
2582
2585
|
return;
|
|
2583
2586
|
let force = this.forceSelection;
|
|
2584
2587
|
this.forceSelection = false;
|
|
@@ -2615,10 +2618,10 @@ class DocView extends ContentView {
|
|
|
2615
2618
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2616
2619
|
if (browser.gecko) {
|
|
2617
2620
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2618
|
-
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2619
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2621
|
+
if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
|
|
2622
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);
|
|
2620
2623
|
if (text)
|
|
2621
|
-
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2624
|
+
anchor = new DOMPos(text, nextTo == 1 /* NextTo.Before */ ? 0 : text.nodeValue.length);
|
|
2622
2625
|
}
|
|
2623
2626
|
}
|
|
2624
2627
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -2950,8 +2953,8 @@ function nearbyTextNode(node, offset, side) {
|
|
|
2950
2953
|
function nextToUneditable(node, offset) {
|
|
2951
2954
|
if (node.nodeType != 1)
|
|
2952
2955
|
return 0;
|
|
2953
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
2954
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
2956
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
|
|
2957
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
|
|
2955
2958
|
}
|
|
2956
2959
|
class DecorationComparator$1 {
|
|
2957
2960
|
constructor() {
|
|
@@ -3306,7 +3309,7 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3306
3309
|
for (let set of atoms) {
|
|
3307
3310
|
set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
|
|
3308
3311
|
if (pos.from > from && pos.from < to) {
|
|
3309
|
-
pos = oldPos.
|
|
3312
|
+
pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
|
|
3310
3313
|
moved = true;
|
|
3311
3314
|
}
|
|
3312
3315
|
});
|
|
@@ -3348,7 +3351,6 @@ class InputState {
|
|
|
3348
3351
|
// composition)
|
|
3349
3352
|
this.compositionFirstChange = null;
|
|
3350
3353
|
this.compositionEndedAt = 0;
|
|
3351
|
-
this.rapidCompositionStart = false;
|
|
3352
3354
|
this.mouseSelection = null;
|
|
3353
3355
|
for (let type in handlers) {
|
|
3354
3356
|
let handler = handlers[type];
|
|
@@ -3496,8 +3498,7 @@ class InputState {
|
|
|
3496
3498
|
return false;
|
|
3497
3499
|
}
|
|
3498
3500
|
mustFlushObserver(event) {
|
|
3499
|
-
return
|
|
3500
|
-
event.type == "compositionend" && !browser.ios;
|
|
3501
|
+
return event.type == "keydown" && event.keyCode != 229;
|
|
3501
3502
|
}
|
|
3502
3503
|
startMouseSelection(mouseSelection) {
|
|
3503
3504
|
if (this.mouseSelection)
|
|
@@ -3765,8 +3766,7 @@ function basicMouseSelection(view, event) {
|
|
|
3765
3766
|
return {
|
|
3766
3767
|
update(update) {
|
|
3767
3768
|
if (update.docChanged) {
|
|
3768
|
-
|
|
3769
|
-
start.pos = update.changes.mapPos(start.pos);
|
|
3769
|
+
start.pos = update.changes.mapPos(start.pos);
|
|
3770
3770
|
startSel = startSel.map(update.changes);
|
|
3771
3771
|
lastEvent = null;
|
|
3772
3772
|
}
|
|
@@ -3779,8 +3779,6 @@ function basicMouseSelection(view, event) {
|
|
|
3779
3779
|
cur = last = queryPos(view, event);
|
|
3780
3780
|
lastEvent = event;
|
|
3781
3781
|
}
|
|
3782
|
-
if (!cur || !start)
|
|
3783
|
-
return startSel;
|
|
3784
3782
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3785
3783
|
if (start.pos != cur.pos && !extend) {
|
|
3786
3784
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -3952,36 +3950,24 @@ handlers.blur = view => {
|
|
|
3952
3950
|
view.observer.clearSelectionRange();
|
|
3953
3951
|
updateForFocusChange(view);
|
|
3954
3952
|
};
|
|
3955
|
-
function forceClearComposition(view, rapid) {
|
|
3956
|
-
if (view.docView.compositionDeco.size) {
|
|
3957
|
-
view.inputState.rapidCompositionStart = rapid;
|
|
3958
|
-
try {
|
|
3959
|
-
view.update([]);
|
|
3960
|
-
}
|
|
3961
|
-
finally {
|
|
3962
|
-
view.inputState.rapidCompositionStart = false;
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
3953
|
handlers.compositionstart = handlers.compositionupdate = view => {
|
|
3967
3954
|
if (view.inputState.compositionFirstChange == null)
|
|
3968
3955
|
view.inputState.compositionFirstChange = true;
|
|
3969
3956
|
if (view.inputState.composing < 0) {
|
|
3970
3957
|
// FIXME possibly set a timeout to clear it again on Android
|
|
3971
3958
|
view.inputState.composing = 0;
|
|
3972
|
-
if (view.docView.compositionDeco.size) {
|
|
3973
|
-
view.observer.flush();
|
|
3974
|
-
forceClearComposition(view, true);
|
|
3975
|
-
}
|
|
3976
3959
|
}
|
|
3977
3960
|
};
|
|
3978
3961
|
handlers.compositionend = view => {
|
|
3979
3962
|
view.inputState.composing = -1;
|
|
3980
3963
|
view.inputState.compositionEndedAt = Date.now();
|
|
3981
3964
|
view.inputState.compositionFirstChange = null;
|
|
3965
|
+
if (browser.chrome && browser.android)
|
|
3966
|
+
view.observer.flushSoon();
|
|
3982
3967
|
setTimeout(() => {
|
|
3983
|
-
if
|
|
3984
|
-
|
|
3968
|
+
// Force the composition state to be cleared if it hasn't already been
|
|
3969
|
+
if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
|
|
3970
|
+
view.update([]);
|
|
3985
3971
|
}, 50);
|
|
3986
3972
|
};
|
|
3987
3973
|
handlers.contextmenu = view => {
|
|
@@ -4151,13 +4137,13 @@ const Epsilon = 1e-3;
|
|
|
4151
4137
|
class HeightMap {
|
|
4152
4138
|
constructor(length, // The number of characters covered
|
|
4153
4139
|
height, // Height of this part of the document
|
|
4154
|
-
flags = 2 /* Outdated */) {
|
|
4140
|
+
flags = 2 /* Flag.Outdated */) {
|
|
4155
4141
|
this.length = length;
|
|
4156
4142
|
this.height = height;
|
|
4157
4143
|
this.flags = flags;
|
|
4158
4144
|
}
|
|
4159
|
-
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4160
|
-
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4145
|
+
get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
|
|
4146
|
+
set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
|
|
4161
4147
|
setHeight(oracle, height) {
|
|
4162
4148
|
if (this.height != height) {
|
|
4163
4149
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4284,7 +4270,7 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4284
4270
|
}
|
|
4285
4271
|
replace(_from, _to, nodes) {
|
|
4286
4272
|
let node = nodes[0];
|
|
4287
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4273
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
|
|
4288
4274
|
Math.abs(this.length - node.length) < 10) {
|
|
4289
4275
|
if (node instanceof HeightMapGap)
|
|
4290
4276
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4410,12 +4396,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4410
4396
|
}
|
|
4411
4397
|
class HeightMapBranch extends HeightMap {
|
|
4412
4398
|
constructor(left, brk, right) {
|
|
4413
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4399
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
|
|
4414
4400
|
this.left = left;
|
|
4415
4401
|
this.right = right;
|
|
4416
4402
|
this.size = left.size + right.size;
|
|
4417
4403
|
}
|
|
4418
|
-
get break() { return this.flags & 1 /* Break */; }
|
|
4404
|
+
get break() { return this.flags & 1 /* Flag.Break */; }
|
|
4419
4405
|
blockAt(height, doc, top, offset) {
|
|
4420
4406
|
let mid = top + this.left.height;
|
|
4421
4407
|
return height < mid ? this.left.blockAt(height, doc, top, offset)
|
|
@@ -4599,7 +4585,7 @@ class NodeBuilder {
|
|
|
4599
4585
|
blankContent(from, to) {
|
|
4600
4586
|
let gap = new HeightMapGap(to - from);
|
|
4601
4587
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4602
|
-
gap.flags |= 4 /* SingleLine */;
|
|
4588
|
+
gap.flags |= 4 /* Flag.SingleLine */;
|
|
4603
4589
|
return gap;
|
|
4604
4590
|
}
|
|
4605
4591
|
ensureLine() {
|
|
@@ -4670,10 +4656,10 @@ class DecorationComparator {
|
|
|
4670
4656
|
|
|
4671
4657
|
function visiblePixelRange(dom, paddingTop) {
|
|
4672
4658
|
let rect = dom.getBoundingClientRect();
|
|
4673
|
-
let
|
|
4674
|
-
let
|
|
4675
|
-
let
|
|
4676
|
-
for (let parent = dom.parentNode; parent && parent != body;) {
|
|
4659
|
+
let doc = dom.ownerDocument, win = doc.defaultView;
|
|
4660
|
+
let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
|
|
4661
|
+
let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
|
|
4662
|
+
for (let parent = dom.parentNode; parent && parent != doc.body;) {
|
|
4677
4663
|
if (parent.nodeType == 1) {
|
|
4678
4664
|
let elt = parent;
|
|
4679
4665
|
let style = window.getComputedStyle(elt);
|
|
@@ -4797,7 +4783,7 @@ class ViewState {
|
|
|
4797
4783
|
}
|
|
4798
4784
|
}
|
|
4799
4785
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
4800
|
-
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
4786
|
+
this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
|
|
4801
4787
|
new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
|
|
4802
4788
|
}
|
|
4803
4789
|
updateViewportLines() {
|
|
@@ -4815,18 +4801,18 @@ class ViewState {
|
|
|
4815
4801
|
let prevHeight = this.heightMap.height;
|
|
4816
4802
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
4817
4803
|
if (this.heightMap.height != prevHeight)
|
|
4818
|
-
update.flags |= 2 /* Height */;
|
|
4804
|
+
update.flags |= 2 /* UpdateFlag.Height */;
|
|
4819
4805
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
4820
4806
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
4821
4807
|
!this.viewportIsAppropriate(viewport))
|
|
4822
4808
|
viewport = this.getViewport(0, scrollTarget);
|
|
4823
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
4809
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||
|
|
4824
4810
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
4825
4811
|
this.viewport = viewport;
|
|
4826
4812
|
this.updateForViewport();
|
|
4827
4813
|
if (updateLines)
|
|
4828
4814
|
this.updateViewportLines();
|
|
4829
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4815
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4830
4816
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
4831
4817
|
update.flags |= this.computeVisibleRanges();
|
|
4832
4818
|
if (scrollTarget)
|
|
@@ -4850,13 +4836,13 @@ class ViewState {
|
|
|
4850
4836
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4851
4837
|
this.paddingTop = paddingTop;
|
|
4852
4838
|
this.paddingBottom = paddingBottom;
|
|
4853
|
-
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4839
|
+
result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
|
|
4854
4840
|
}
|
|
4855
4841
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4856
4842
|
if (oracle.lineWrapping)
|
|
4857
4843
|
measureContent = true;
|
|
4858
4844
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4859
|
-
result |= 8 /* Geometry */;
|
|
4845
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4860
4846
|
}
|
|
4861
4847
|
// Pixel viewport
|
|
4862
4848
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
@@ -4868,13 +4854,13 @@ class ViewState {
|
|
|
4868
4854
|
if (inView)
|
|
4869
4855
|
measureContent = true;
|
|
4870
4856
|
}
|
|
4871
|
-
if (!this.inView)
|
|
4857
|
+
if (!this.inView && !this.scrollTarget)
|
|
4872
4858
|
return 0;
|
|
4873
4859
|
let contentWidth = dom.clientWidth;
|
|
4874
4860
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
4875
4861
|
this.contentDOMWidth = contentWidth;
|
|
4876
4862
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
4877
|
-
result |= 8 /* Geometry */;
|
|
4863
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4878
4864
|
}
|
|
4879
4865
|
if (measureContent) {
|
|
4880
4866
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -4885,7 +4871,7 @@ class ViewState {
|
|
|
4885
4871
|
refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
|
|
4886
4872
|
if (refresh) {
|
|
4887
4873
|
view.docView.minWidth = 0;
|
|
4888
|
-
result |= 8 /* Geometry */;
|
|
4874
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4889
4875
|
}
|
|
4890
4876
|
}
|
|
4891
4877
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -4898,16 +4884,16 @@ class ViewState {
|
|
|
4898
4884
|
this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
4899
4885
|
}
|
|
4900
4886
|
if (oracle.heightChanged)
|
|
4901
|
-
result |= 2 /* Height */;
|
|
4887
|
+
result |= 2 /* UpdateFlag.Height */;
|
|
4902
4888
|
}
|
|
4903
4889
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
4904
4890
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
|
|
4905
4891
|
if (viewportChange)
|
|
4906
4892
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
4907
4893
|
this.updateForViewport();
|
|
4908
|
-
if ((result & 2 /* Height */) || viewportChange)
|
|
4894
|
+
if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
|
|
4909
4895
|
this.updateViewportLines();
|
|
4910
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4896
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4911
4897
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
|
|
4912
4898
|
result |= this.computeVisibleRanges();
|
|
4913
4899
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -4926,9 +4912,9 @@ class ViewState {
|
|
|
4926
4912
|
// This will divide VP.Margin between the top and the
|
|
4927
4913
|
// bottom, depending on the bias (the change in viewport position
|
|
4928
4914
|
// since the last update). It'll hold a number between 0 and 1
|
|
4929
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
4915
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
|
|
4930
4916
|
let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
|
|
4931
|
-
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);
|
|
4917
|
+
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);
|
|
4932
4918
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
4933
4919
|
if (scrollTarget) {
|
|
4934
4920
|
let { head } = scrollTarget.range;
|
|
@@ -4941,7 +4927,7 @@ class ViewState {
|
|
|
4941
4927
|
topPos = block.top;
|
|
4942
4928
|
else
|
|
4943
4929
|
topPos = block.bottom - viewHeight;
|
|
4944
|
-
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);
|
|
4930
|
+
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);
|
|
4945
4931
|
}
|
|
4946
4932
|
}
|
|
4947
4933
|
return viewport;
|
|
@@ -4958,10 +4944,10 @@ class ViewState {
|
|
|
4958
4944
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4959
4945
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4960
4946
|
let { visibleTop, visibleBottom } = this;
|
|
4961
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
4947
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4962
4948
|
(to == this.state.doc.length ||
|
|
4963
|
-
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
4964
|
-
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
4949
|
+
bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4950
|
+
(top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
|
|
4965
4951
|
}
|
|
4966
4952
|
mapLineGaps(gaps, changes) {
|
|
4967
4953
|
if (!gaps.length || changes.empty)
|
|
@@ -4985,20 +4971,20 @@ class ViewState {
|
|
|
4985
4971
|
if (this.defaultTextDirection != Direction.LTR)
|
|
4986
4972
|
return gaps;
|
|
4987
4973
|
for (let line of this.viewportLines) {
|
|
4988
|
-
if (line.length < 4000 /* DoubleMargin */)
|
|
4974
|
+
if (line.length < 4000 /* LG.DoubleMargin */)
|
|
4989
4975
|
continue;
|
|
4990
4976
|
let structure = lineStructure(line.from, line.to, this.stateDeco);
|
|
4991
|
-
if (structure.total < 4000 /* DoubleMargin */)
|
|
4977
|
+
if (structure.total < 4000 /* LG.DoubleMargin */)
|
|
4992
4978
|
continue;
|
|
4993
4979
|
let viewFrom, viewTo;
|
|
4994
4980
|
if (this.heightOracle.lineWrapping) {
|
|
4995
|
-
let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4981
|
+
let marginHeight = (2000 /* LG.Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4996
4982
|
viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
|
|
4997
4983
|
viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
|
|
4998
4984
|
}
|
|
4999
4985
|
else {
|
|
5000
4986
|
let totalWidth = structure.total * this.heightOracle.charWidth;
|
|
5001
|
-
let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
|
|
4987
|
+
let marginWidth = 2000 /* LG.Margin */ * this.heightOracle.charWidth;
|
|
5002
4988
|
viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
|
|
5003
4989
|
viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
|
|
5004
4990
|
}
|
|
@@ -5010,13 +4996,13 @@ class ViewState {
|
|
|
5010
4996
|
let sel = this.state.selection.main;
|
|
5011
4997
|
// Make sure the gaps don't cover a selection end
|
|
5012
4998
|
if (sel.from >= line.from && sel.from <= line.to)
|
|
5013
|
-
cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
|
|
4999
|
+
cutRange(outside, sel.from - 10 /* LG.SelectionMargin */, sel.from + 10 /* LG.SelectionMargin */);
|
|
5014
5000
|
if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
|
|
5015
|
-
cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
|
|
5001
|
+
cutRange(outside, sel.to - 10 /* LG.SelectionMargin */, sel.to + 10 /* LG.SelectionMargin */);
|
|
5016
5002
|
for (let { from, to } of outside)
|
|
5017
|
-
if (to - from > 1000 /* HalfMargin */) {
|
|
5003
|
+
if (to - from > 1000 /* LG.HalfMargin */) {
|
|
5018
5004
|
gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
|
|
5019
|
-
Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
|
|
5005
|
+
Math.abs(gap.from - from) < 1000 /* LG.HalfMargin */ && Math.abs(gap.to - to) < 1000 /* LG.HalfMargin */) ||
|
|
5020
5006
|
new LineGap(from, to, this.gapSize(line, from, to, structure)));
|
|
5021
5007
|
}
|
|
5022
5008
|
}
|
|
@@ -5049,7 +5035,7 @@ class ViewState {
|
|
|
5049
5035
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5050
5036
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5051
5037
|
this.visibleRanges = ranges;
|
|
5052
|
-
return changed ? 4 /* Viewport */ : 0;
|
|
5038
|
+
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
5053
5039
|
}
|
|
5054
5040
|
lineBlockAt(pos) {
|
|
5055
5041
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5155,7 +5141,7 @@ class BigScaler {
|
|
|
5155
5141
|
vpHeight += bottom - top;
|
|
5156
5142
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5157
5143
|
});
|
|
5158
|
-
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5144
|
+
this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5159
5145
|
for (let obj of this.viewports) {
|
|
5160
5146
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5161
5147
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5312,8 +5298,8 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5312
5298
|
"&.cm-focused .cm-cursor": {
|
|
5313
5299
|
display: "block"
|
|
5314
5300
|
},
|
|
5315
|
-
"&light .cm-activeLine": { backgroundColor: "#
|
|
5316
|
-
"&dark .cm-activeLine": { backgroundColor: "#
|
|
5301
|
+
"&light .cm-activeLine": { backgroundColor: "#cceeff44" },
|
|
5302
|
+
"&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
|
|
5317
5303
|
"&light .cm-specialChar": { color: "red" },
|
|
5318
5304
|
"&dark .cm-specialChar": { color: "#f78" },
|
|
5319
5305
|
".cm-gutters": {
|
|
@@ -5458,6 +5444,7 @@ class DOMObserver {
|
|
|
5458
5444
|
this.resizeTimeout = -1;
|
|
5459
5445
|
this.queue = [];
|
|
5460
5446
|
this.delayedAndroidKey = null;
|
|
5447
|
+
this.lastChange = 0;
|
|
5461
5448
|
this.scrollTargets = [];
|
|
5462
5449
|
this.intersection = null;
|
|
5463
5450
|
this.resize = null;
|
|
@@ -5504,8 +5491,7 @@ class DOMObserver {
|
|
|
5504
5491
|
});
|
|
5505
5492
|
this.resize.observe(view.scrollDOM);
|
|
5506
5493
|
}
|
|
5507
|
-
this.win = view.
|
|
5508
|
-
this.addWindowListeners(this.win);
|
|
5494
|
+
this.addWindowListeners(this.win = view.win);
|
|
5509
5495
|
this.start();
|
|
5510
5496
|
if (typeof IntersectionObserver == "function") {
|
|
5511
5497
|
this.intersection = new IntersectionObserver(entries => {
|
|
@@ -5684,26 +5670,34 @@ class DOMObserver {
|
|
|
5684
5670
|
// detected (via beforeinput or keydown), and then tries to flush
|
|
5685
5671
|
// them or, if that has no effect, dispatches the given key.
|
|
5686
5672
|
delayAndroidKey(key, keyCode) {
|
|
5673
|
+
var _a;
|
|
5687
5674
|
if (!this.delayedAndroidKey)
|
|
5688
|
-
requestAnimationFrame(() => {
|
|
5675
|
+
this.view.win.requestAnimationFrame(() => {
|
|
5689
5676
|
let key = this.delayedAndroidKey;
|
|
5690
5677
|
this.delayedAndroidKey = null;
|
|
5691
5678
|
this.delayedFlush = -1;
|
|
5692
|
-
if (!this.flush())
|
|
5679
|
+
if (!this.flush() && key.force)
|
|
5693
5680
|
dispatchKey(this.dom, key.key, key.keyCode);
|
|
5694
5681
|
});
|
|
5695
5682
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5696
5683
|
// Enter always takes precedence.
|
|
5697
5684
|
if (!this.delayedAndroidKey || key == "Enter")
|
|
5698
|
-
this.delayedAndroidKey = {
|
|
5685
|
+
this.delayedAndroidKey = {
|
|
5686
|
+
key, keyCode,
|
|
5687
|
+
// Only run the key handler when no changes are detected if
|
|
5688
|
+
// this isn't coming right after another change, in which case
|
|
5689
|
+
// it is probably part of a weird chain of updates, and should
|
|
5690
|
+
// be ignored if it returns the DOM to its previous state.
|
|
5691
|
+
force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
|
|
5692
|
+
};
|
|
5699
5693
|
}
|
|
5700
5694
|
flushSoon() {
|
|
5701
5695
|
if (this.delayedFlush < 0)
|
|
5702
|
-
this.delayedFlush =
|
|
5696
|
+
this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
|
|
5703
5697
|
}
|
|
5704
5698
|
forceFlush() {
|
|
5705
5699
|
if (this.delayedFlush >= 0) {
|
|
5706
|
-
|
|
5700
|
+
this.view.win.cancelAnimationFrame(this.delayedFlush);
|
|
5707
5701
|
this.delayedFlush = -1;
|
|
5708
5702
|
}
|
|
5709
5703
|
this.flush();
|
|
@@ -5737,13 +5731,15 @@ class DOMObserver {
|
|
|
5737
5731
|
// managing those will make sure processRecords is called and the
|
|
5738
5732
|
// view is resynchronized after
|
|
5739
5733
|
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
|
|
5740
|
-
return;
|
|
5734
|
+
return false;
|
|
5741
5735
|
if (readSelection)
|
|
5742
5736
|
this.readSelectionRange();
|
|
5743
5737
|
let { from, to, typeOver } = this.processRecords();
|
|
5744
5738
|
let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
|
|
5745
5739
|
if (from < 0 && !newSel)
|
|
5746
|
-
return;
|
|
5740
|
+
return false;
|
|
5741
|
+
if (from > -1)
|
|
5742
|
+
this.lastChange = Date.now();
|
|
5747
5743
|
this.view.inputState.lastFocusTime = 0;
|
|
5748
5744
|
this.selectionChanged = false;
|
|
5749
5745
|
let startState = this.view.state;
|
|
@@ -5759,7 +5755,7 @@ class DOMObserver {
|
|
|
5759
5755
|
return null;
|
|
5760
5756
|
cView.markDirty(rec.type == "attributes");
|
|
5761
5757
|
if (rec.type == "attributes")
|
|
5762
|
-
cView.dirty |= 4 /* Attrs */;
|
|
5758
|
+
cView.dirty |= 4 /* Dirty.Attrs */;
|
|
5763
5759
|
if (rec.type == "childList") {
|
|
5764
5760
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
5765
5761
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -6086,7 +6082,7 @@ class EditorView {
|
|
|
6086
6082
|
/**
|
|
6087
6083
|
@internal
|
|
6088
6084
|
*/
|
|
6089
|
-
this.updateState = 2 /* Updating */;
|
|
6085
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6090
6086
|
/**
|
|
6091
6087
|
@internal
|
|
6092
6088
|
*/
|
|
@@ -6125,7 +6121,7 @@ class EditorView {
|
|
|
6125
6121
|
this.docView = new DocView(this);
|
|
6126
6122
|
this.mountStyles();
|
|
6127
6123
|
this.updateAttrs();
|
|
6128
|
-
this.updateState = 0 /* Idle */;
|
|
6124
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6129
6125
|
this.requestMeasure();
|
|
6130
6126
|
if (config.parent)
|
|
6131
6127
|
config.parent.appendChild(this.dom);
|
|
@@ -6173,6 +6169,10 @@ class EditorView {
|
|
|
6173
6169
|
The document or shadow root that the view lives in.
|
|
6174
6170
|
*/
|
|
6175
6171
|
get root() { return this._root; }
|
|
6172
|
+
/**
|
|
6173
|
+
@internal
|
|
6174
|
+
*/
|
|
6175
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6176
6176
|
dispatch(...input) {
|
|
6177
6177
|
this._dispatch(input.length == 1 && input[0] instanceof Transaction ? input[0]
|
|
6178
6178
|
: this.state.update(...input));
|
|
@@ -6186,7 +6186,7 @@ class EditorView {
|
|
|
6186
6186
|
as a primitive.
|
|
6187
6187
|
*/
|
|
6188
6188
|
update(transactions) {
|
|
6189
|
-
if (this.updateState != 0 /* Idle */)
|
|
6189
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6190
6190
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6191
6191
|
let redrawn = false, attrsChanged = false, update;
|
|
6192
6192
|
let state = this.state;
|
|
@@ -6206,7 +6206,7 @@ class EditorView {
|
|
|
6206
6206
|
update = ViewUpdate.create(this, state, transactions);
|
|
6207
6207
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6208
6208
|
try {
|
|
6209
|
-
this.updateState = 2 /* Updating */;
|
|
6209
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6210
6210
|
for (let tr of transactions) {
|
|
6211
6211
|
if (scrollTarget)
|
|
6212
6212
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6232,7 +6232,7 @@ class EditorView {
|
|
|
6232
6232
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6233
6233
|
}
|
|
6234
6234
|
finally {
|
|
6235
|
-
this.updateState = 0 /* Idle */;
|
|
6235
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6236
6236
|
}
|
|
6237
6237
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6238
6238
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6250,13 +6250,13 @@ class EditorView {
|
|
|
6250
6250
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6251
6251
|
*/
|
|
6252
6252
|
setState(newState) {
|
|
6253
|
-
if (this.updateState != 0 /* Idle */)
|
|
6253
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6254
6254
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6255
6255
|
if (this.destroyed) {
|
|
6256
6256
|
this.viewState.state = newState;
|
|
6257
6257
|
return;
|
|
6258
6258
|
}
|
|
6259
|
-
this.updateState = 2 /* Updating */;
|
|
6259
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6260
6260
|
let hadFocus = this.hasFocus;
|
|
6261
6261
|
try {
|
|
6262
6262
|
for (let plugin of this.plugins)
|
|
@@ -6273,7 +6273,7 @@ class EditorView {
|
|
|
6273
6273
|
this.bidiCache = [];
|
|
6274
6274
|
}
|
|
6275
6275
|
finally {
|
|
6276
|
-
this.updateState = 0 /* Idle */;
|
|
6276
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6277
6277
|
}
|
|
6278
6278
|
if (hadFocus)
|
|
6279
6279
|
this.focus();
|
|
@@ -6324,7 +6324,7 @@ class EditorView {
|
|
|
6324
6324
|
let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;
|
|
6325
6325
|
try {
|
|
6326
6326
|
for (let i = 0;; i++) {
|
|
6327
|
-
this.updateState = 1 /* Measuring */;
|
|
6327
|
+
this.updateState = 1 /* UpdateState.Measuring */;
|
|
6328
6328
|
let oldViewport = this.viewport;
|
|
6329
6329
|
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6330
6330
|
let changed = this.viewState.measure(this);
|
|
@@ -6338,7 +6338,7 @@ class EditorView {
|
|
|
6338
6338
|
}
|
|
6339
6339
|
let measuring = [];
|
|
6340
6340
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6341
|
-
if (!(changed & 4 /* Viewport */))
|
|
6341
|
+
if (!(changed & 4 /* UpdateFlag.Viewport */))
|
|
6342
6342
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6343
6343
|
let measured = measuring.map(m => {
|
|
6344
6344
|
try {
|
|
@@ -6355,7 +6355,7 @@ class EditorView {
|
|
|
6355
6355
|
updated = update;
|
|
6356
6356
|
else
|
|
6357
6357
|
updated.flags |= changed;
|
|
6358
|
-
this.updateState = 2 /* Updating */;
|
|
6358
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6359
6359
|
if (!update.empty) {
|
|
6360
6360
|
this.updatePlugins(update);
|
|
6361
6361
|
this.inputState.update(update);
|
|
@@ -6393,7 +6393,7 @@ class EditorView {
|
|
|
6393
6393
|
}
|
|
6394
6394
|
}
|
|
6395
6395
|
finally {
|
|
6396
|
-
this.updateState = 0 /* Idle */;
|
|
6396
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6397
6397
|
this.measureScheduled = -1;
|
|
6398
6398
|
}
|
|
6399
6399
|
if (updated && !updated.empty)
|
|
@@ -6452,9 +6452,9 @@ class EditorView {
|
|
|
6452
6452
|
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6453
6453
|
}
|
|
6454
6454
|
readMeasured() {
|
|
6455
|
-
if (this.updateState == 2 /* Updating */)
|
|
6455
|
+
if (this.updateState == 2 /* UpdateState.Updating */)
|
|
6456
6456
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6457
|
-
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6457
|
+
if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
|
|
6458
6458
|
this.measure(false);
|
|
6459
6459
|
}
|
|
6460
6460
|
/**
|
|
@@ -6467,7 +6467,7 @@ class EditorView {
|
|
|
6467
6467
|
*/
|
|
6468
6468
|
requestMeasure(request) {
|
|
6469
6469
|
if (this.measureScheduled < 0)
|
|
6470
|
-
this.measureScheduled = requestAnimationFrame(() => this.measure());
|
|
6470
|
+
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6471
6471
|
if (request) {
|
|
6472
6472
|
if (request.key != null)
|
|
6473
6473
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
@@ -7342,7 +7342,7 @@ function measureRange(view, range) {
|
|
|
7342
7342
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7343
7343
|
}
|
|
7344
7344
|
function piece(left, top, right, bottom) {
|
|
7345
|
-
return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
|
|
7345
|
+
return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
|
|
7346
7346
|
}
|
|
7347
7347
|
function pieces({ top, bottom, horizontal }) {
|
|
7348
7348
|
let pieces = [];
|
|
@@ -7536,9 +7536,15 @@ class MatchDecorator {
|
|
|
7536
7536
|
if (decorate) {
|
|
7537
7537
|
this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);
|
|
7538
7538
|
}
|
|
7539
|
+
else if (typeof decoration == "function") {
|
|
7540
|
+
this.addMatch = (match, view, from, add) => {
|
|
7541
|
+
let deco = decoration(match, view, from);
|
|
7542
|
+
if (deco)
|
|
7543
|
+
add(from, from + match[0].length, deco);
|
|
7544
|
+
};
|
|
7545
|
+
}
|
|
7539
7546
|
else if (decoration) {
|
|
7540
|
-
|
|
7541
|
-
this.addMatch = (match, view, from, add) => add(from, from + match[0].length, getDeco(match, view, from));
|
|
7547
|
+
this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);
|
|
7542
7548
|
}
|
|
7543
7549
|
else {
|
|
7544
7550
|
throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
|
|
@@ -7805,8 +7811,6 @@ const activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
7805
7811
|
getDeco(view) {
|
|
7806
7812
|
let lastLineStart = -1, deco = [];
|
|
7807
7813
|
for (let r of view.state.selection.ranges) {
|
|
7808
|
-
if (!r.empty)
|
|
7809
|
-
return Decoration.none;
|
|
7810
7814
|
let line = view.lineBlockAt(r.head);
|
|
7811
7815
|
if (line.from > lastLineStart) {
|
|
7812
7816
|
deco.push(lineDeco.range(line.from));
|
|
@@ -8024,8 +8028,9 @@ Creates an extension that configures tooltip behavior.
|
|
|
8024
8028
|
function tooltips(config = {}) {
|
|
8025
8029
|
return tooltipConfig.of(config);
|
|
8026
8030
|
}
|
|
8027
|
-
function windowSpace() {
|
|
8028
|
-
|
|
8031
|
+
function windowSpace(view) {
|
|
8032
|
+
let { win } = view;
|
|
8033
|
+
return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
|
|
8029
8034
|
}
|
|
8030
8035
|
const tooltipConfig = /*@__PURE__*/Facet.define({
|
|
8031
8036
|
combine: values => {
|
|
@@ -8039,7 +8044,6 @@ const tooltipConfig = /*@__PURE__*/Facet.define({
|
|
|
8039
8044
|
});
|
|
8040
8045
|
const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
8041
8046
|
constructor(view) {
|
|
8042
|
-
var _a;
|
|
8043
8047
|
this.view = view;
|
|
8044
8048
|
this.inView = true;
|
|
8045
8049
|
this.lastTransaction = 0;
|
|
@@ -8057,7 +8061,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8057
8061
|
this.measureSoon();
|
|
8058
8062
|
}, { threshold: [1] }) : null;
|
|
8059
8063
|
this.observeIntersection();
|
|
8060
|
-
|
|
8064
|
+
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
8061
8065
|
this.maybeMeasure();
|
|
8062
8066
|
}
|
|
8063
8067
|
createContainer() {
|
|
@@ -8130,11 +8134,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8130
8134
|
return tooltipView;
|
|
8131
8135
|
}
|
|
8132
8136
|
destroy() {
|
|
8133
|
-
var _a
|
|
8134
|
-
|
|
8137
|
+
var _a;
|
|
8138
|
+
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
8135
8139
|
for (let { dom } of this.manager.tooltipViews)
|
|
8136
8140
|
dom.remove();
|
|
8137
|
-
(
|
|
8141
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
8138
8142
|
clearTimeout(this.measureTimeout);
|
|
8139
8143
|
}
|
|
8140
8144
|
readMeasure() {
|
|
@@ -8165,12 +8169,12 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8165
8169
|
continue;
|
|
8166
8170
|
}
|
|
8167
8171
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8168
|
-
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8172
|
+
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
8169
8173
|
let width = size.right - size.left, height = size.bottom - size.top;
|
|
8170
8174
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
|
|
8171
8175
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8172
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8173
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8176
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
8177
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
8174
8178
|
let above = !!tooltip.above;
|
|
8175
8179
|
if (!tooltip.strictSide && (above
|
|
8176
8180
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8192,7 +8196,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8192
8196
|
dom.style.left = left + "px";
|
|
8193
8197
|
}
|
|
8194
8198
|
if (arrow)
|
|
8195
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8199
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */)}px`;
|
|
8196
8200
|
if (tView.overlap !== true)
|
|
8197
8201
|
others.push({ left, top, right, bottom: top + height });
|
|
8198
8202
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8234,8 +8238,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8234
8238
|
color: "white"
|
|
8235
8239
|
},
|
|
8236
8240
|
".cm-tooltip-arrow": {
|
|
8237
|
-
height: `${7 /* Size */}px`,
|
|
8238
|
-
width: `${7 /* Size */ * 2}px`,
|
|
8241
|
+
height: `${7 /* Arrow.Size */}px`,
|
|
8242
|
+
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
8239
8243
|
position: "absolute",
|
|
8240
8244
|
zIndex: -1,
|
|
8241
8245
|
overflow: "hidden",
|
|
@@ -8244,26 +8248,26 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8244
8248
|
position: "absolute",
|
|
8245
8249
|
width: 0,
|
|
8246
8250
|
height: 0,
|
|
8247
|
-
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8248
|
-
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8251
|
+
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8252
|
+
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8249
8253
|
},
|
|
8250
8254
|
".cm-tooltip-above &": {
|
|
8251
|
-
bottom: `-${7 /* Size */}px`,
|
|
8255
|
+
bottom: `-${7 /* Arrow.Size */}px`,
|
|
8252
8256
|
"&:before": {
|
|
8253
|
-
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8257
|
+
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8254
8258
|
},
|
|
8255
8259
|
"&:after": {
|
|
8256
|
-
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8260
|
+
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8257
8261
|
bottom: "1px"
|
|
8258
8262
|
}
|
|
8259
8263
|
},
|
|
8260
8264
|
".cm-tooltip-below &": {
|
|
8261
|
-
top: `-${7 /* Size */}px`,
|
|
8265
|
+
top: `-${7 /* Arrow.Size */}px`,
|
|
8262
8266
|
"&:before": {
|
|
8263
|
-
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8267
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8264
8268
|
},
|
|
8265
8269
|
"&:after": {
|
|
8266
|
-
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8270
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8267
8271
|
top: "1px"
|
|
8268
8272
|
}
|
|
8269
8273
|
},
|
|
@@ -8408,7 +8412,7 @@ class HoverPlugin {
|
|
|
8408
8412
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
8409
8413
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
8410
8414
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
8411
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
8415
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* Hover.MaxDist */))) {
|
|
8412
8416
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
8413
8417
|
this.pending = null;
|
|
8414
8418
|
}
|
|
@@ -8490,7 +8494,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
8490
8494
|
});
|
|
8491
8495
|
return [
|
|
8492
8496
|
hoverState,
|
|
8493
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
8497
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
8494
8498
|
showHoverTooltipHost
|
|
8495
8499
|
];
|
|
8496
8500
|
}
|
|
@@ -9121,14 +9125,13 @@ const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {
|
|
|
9121
9125
|
};
|
|
9122
9126
|
const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute(["selection"], state => {
|
|
9123
9127
|
let marks = [], last = -1;
|
|
9124
|
-
for (let range of state.selection.ranges)
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
marks.push(activeLineGutterMarker.range(linePos));
|
|
9130
|
-
}
|
|
9128
|
+
for (let range of state.selection.ranges) {
|
|
9129
|
+
let linePos = state.doc.lineAt(range.head).from;
|
|
9130
|
+
if (linePos > last) {
|
|
9131
|
+
last = linePos;
|
|
9132
|
+
marks.push(activeLineGutterMarker.range(linePos));
|
|
9131
9133
|
}
|
|
9134
|
+
}
|
|
9132
9135
|
return RangeSet.of(marks);
|
|
9133
9136
|
});
|
|
9134
9137
|
/**
|