@codemirror/view 6.2.2 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +185 -190
- package/dist/index.d.ts +1 -1
- package/dist/index.js +185 -190
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -304,7 +304,7 @@ class ContentView {
|
|
|
304
304
|
constructor() {
|
|
305
305
|
this.parent = null;
|
|
306
306
|
this.dom = null;
|
|
307
|
-
this.dirty = 2 /* Node */;
|
|
307
|
+
this.dirty = 2 /* Dirty.Node */;
|
|
308
308
|
}
|
|
309
309
|
get editorView() {
|
|
310
310
|
if (!this.parent)
|
|
@@ -335,7 +335,7 @@ class ContentView {
|
|
|
335
335
|
// given position.
|
|
336
336
|
coordsAt(_pos, _side) { return null; }
|
|
337
337
|
sync(track) {
|
|
338
|
-
if (this.dirty & 2 /* Node */) {
|
|
338
|
+
if (this.dirty & 2 /* Dirty.Node */) {
|
|
339
339
|
let parent = this.dom;
|
|
340
340
|
let prev = null, next;
|
|
341
341
|
for (let child of this.children) {
|
|
@@ -346,7 +346,7 @@ class ContentView {
|
|
|
346
346
|
child.reuseDOM(next);
|
|
347
347
|
}
|
|
348
348
|
child.sync(track);
|
|
349
|
-
child.dirty = 0 /* Not */;
|
|
349
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
350
350
|
}
|
|
351
351
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
352
352
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -366,11 +366,11 @@ class ContentView {
|
|
|
366
366
|
while (next)
|
|
367
367
|
next = rm$1(next);
|
|
368
368
|
}
|
|
369
|
-
else if (this.dirty & 1 /* Child */) {
|
|
369
|
+
else if (this.dirty & 1 /* Dirty.Child */) {
|
|
370
370
|
for (let child of this.children)
|
|
371
371
|
if (child.dirty) {
|
|
372
372
|
child.sync(track);
|
|
373
|
-
child.dirty = 0 /* Not */;
|
|
373
|
+
child.dirty = 0 /* Dirty.Not */;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -435,16 +435,16 @@ class ContentView {
|
|
|
435
435
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
436
436
|
}
|
|
437
437
|
markDirty(andParent = false) {
|
|
438
|
-
this.dirty |= 2 /* Node */;
|
|
438
|
+
this.dirty |= 2 /* Dirty.Node */;
|
|
439
439
|
this.markParentsDirty(andParent);
|
|
440
440
|
}
|
|
441
441
|
markParentsDirty(childList) {
|
|
442
442
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
443
443
|
if (childList)
|
|
444
|
-
parent.dirty |= 2 /* Node */;
|
|
445
|
-
if (parent.dirty & 1 /* Child */)
|
|
444
|
+
parent.dirty |= 2 /* Dirty.Node */;
|
|
445
|
+
if (parent.dirty & 1 /* Dirty.Child */)
|
|
446
446
|
return;
|
|
447
|
-
parent.dirty |= 1 /* Child */;
|
|
447
|
+
parent.dirty |= 1 /* Dirty.Child */;
|
|
448
448
|
childList = false;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
@@ -720,13 +720,13 @@ class MarkView extends ContentView {
|
|
|
720
720
|
reuseDOM(node) {
|
|
721
721
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
722
722
|
this.setDOM(node);
|
|
723
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
723
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
724
724
|
}
|
|
725
725
|
}
|
|
726
726
|
sync(track) {
|
|
727
727
|
if (!this.dom)
|
|
728
728
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
729
|
-
else if (this.dirty & 4 /* Attrs */)
|
|
729
|
+
else if (this.dirty & 4 /* Dirty.Attrs */)
|
|
730
730
|
this.setAttrs(this.dom);
|
|
731
731
|
super.sync(track);
|
|
732
732
|
}
|
|
@@ -1235,7 +1235,7 @@ class Decoration extends RangeValue {
|
|
|
1235
1235
|
*/
|
|
1236
1236
|
static widget(spec) {
|
|
1237
1237
|
let side = spec.side || 0, block = !!spec.block;
|
|
1238
|
-
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1238
|
+
side += block ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */) : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
|
|
1239
1239
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
@@ -1245,13 +1245,13 @@ class Decoration extends RangeValue {
|
|
|
1245
1245
|
static replace(spec) {
|
|
1246
1246
|
let block = !!spec.block, startSide, endSide;
|
|
1247
1247
|
if (spec.isBlockGap) {
|
|
1248
|
-
startSide = -500000000 /* GapStart */;
|
|
1249
|
-
endSide = 400000000 /* GapEnd */;
|
|
1248
|
+
startSide = -500000000 /* Side.GapStart */;
|
|
1249
|
+
endSide = 400000000 /* Side.GapEnd */;
|
|
1250
1250
|
}
|
|
1251
1251
|
else {
|
|
1252
1252
|
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;
|
|
1253
|
+
startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
|
|
1254
|
+
endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
|
|
1255
1255
|
}
|
|
1256
1256
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1257
1257
|
}
|
|
@@ -1282,7 +1282,7 @@ Decoration.none = RangeSet.empty;
|
|
|
1282
1282
|
class MarkDecoration extends Decoration {
|
|
1283
1283
|
constructor(spec) {
|
|
1284
1284
|
let { start, end } = getInclusive(spec);
|
|
1285
|
-
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1285
|
+
super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
|
|
1286
1286
|
this.tagName = spec.tagName || "span";
|
|
1287
1287
|
this.class = spec.class || "";
|
|
1288
1288
|
this.attrs = spec.attributes || null;
|
|
@@ -1303,7 +1303,7 @@ class MarkDecoration extends Decoration {
|
|
|
1303
1303
|
MarkDecoration.prototype.point = false;
|
|
1304
1304
|
class LineDecoration extends Decoration {
|
|
1305
1305
|
constructor(spec) {
|
|
1306
|
-
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1306
|
+
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1307
1307
|
}
|
|
1308
1308
|
eq(other) {
|
|
1309
1309
|
return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
|
|
@@ -1440,7 +1440,7 @@ class LineView extends ContentView {
|
|
|
1440
1440
|
reuseDOM(node) {
|
|
1441
1441
|
if (node.nodeName == "DIV") {
|
|
1442
1442
|
this.setDOM(node);
|
|
1443
|
-
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1443
|
+
this.dirty |= 4 /* Dirty.Attrs */ | 2 /* Dirty.Node */;
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
1446
|
sync(track) {
|
|
@@ -1450,7 +1450,7 @@ class LineView extends ContentView {
|
|
|
1450
1450
|
this.dom.className = "cm-line";
|
|
1451
1451
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1452
1452
|
}
|
|
1453
|
-
else if (this.dirty & 4 /* Attrs */) {
|
|
1453
|
+
else if (this.dirty & 4 /* Dirty.Attrs */) {
|
|
1454
1454
|
clearAttributes(this.dom);
|
|
1455
1455
|
this.dom.className = "cm-line";
|
|
1456
1456
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1580,7 +1580,7 @@ class ContentBuilder {
|
|
|
1580
1580
|
this.content = [];
|
|
1581
1581
|
this.curLine = null;
|
|
1582
1582
|
this.breakAtStart = 0;
|
|
1583
|
-
this.pendingBuffer = 0 /* No */;
|
|
1583
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1584
1584
|
// Set to false directly after a widget that covers the position after it
|
|
1585
1585
|
this.atCursorPos = true;
|
|
1586
1586
|
this.openStart = -1;
|
|
@@ -1606,7 +1606,7 @@ class ContentBuilder {
|
|
|
1606
1606
|
flushBuffer(active) {
|
|
1607
1607
|
if (this.pendingBuffer) {
|
|
1608
1608
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1609
|
-
this.pendingBuffer = 0 /* No */;
|
|
1609
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
1612
|
addBlockWidget(view) {
|
|
@@ -1618,7 +1618,7 @@ class ContentBuilder {
|
|
|
1618
1618
|
if (!openEnd)
|
|
1619
1619
|
this.flushBuffer([]);
|
|
1620
1620
|
else
|
|
1621
|
-
this.pendingBuffer = 0 /* No */;
|
|
1621
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1622
1622
|
if (!this.posCovered())
|
|
1623
1623
|
this.getLine();
|
|
1624
1624
|
}
|
|
@@ -1646,7 +1646,7 @@ class ContentBuilder {
|
|
|
1646
1646
|
this.textOff = 0;
|
|
1647
1647
|
}
|
|
1648
1648
|
}
|
|
1649
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1649
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
|
|
1650
1650
|
this.flushBuffer(active.slice(0, openStart));
|
|
1651
1651
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1652
1652
|
this.atCursorPos = true;
|
|
@@ -1681,8 +1681,8 @@ class ContentBuilder {
|
|
|
1681
1681
|
let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
|
|
1682
1682
|
let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
|
|
1683
1683
|
let line = this.getLine();
|
|
1684
|
-
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
|
|
1685
|
-
this.pendingBuffer = 0 /* No */;
|
|
1684
|
+
if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore)
|
|
1685
|
+
this.pendingBuffer = 0 /* Buf.No */;
|
|
1686
1686
|
this.flushBuffer(active);
|
|
1687
1687
|
if (cursorBefore) {
|
|
1688
1688
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1690,7 +1690,7 @@ class ContentBuilder {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
line.append(wrapMarks(view, active), openStart);
|
|
1692
1692
|
this.atCursorPos = cursorAfter;
|
|
1693
|
-
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1693
|
+
this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
|
|
1694
1694
|
}
|
|
1695
1695
|
}
|
|
1696
1696
|
else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
|
|
@@ -1983,7 +1983,7 @@ class ViewUpdate {
|
|
|
1983
1983
|
let focus = view.hasFocus;
|
|
1984
1984
|
if (focus != view.inputState.notifiedFocused) {
|
|
1985
1985
|
view.inputState.notifiedFocused = focus;
|
|
1986
|
-
this.flags |= 1 /* Focus */;
|
|
1986
|
+
this.flags |= 1 /* UpdateFlag.Focus */;
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
1989
|
/**
|
|
@@ -1998,27 +1998,27 @@ class ViewUpdate {
|
|
|
1998
1998
|
update.
|
|
1999
1999
|
*/
|
|
2000
2000
|
get viewportChanged() {
|
|
2001
|
-
return (this.flags & 4 /* Viewport */) > 0;
|
|
2001
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
2002
2002
|
}
|
|
2003
2003
|
/**
|
|
2004
2004
|
Indicates whether the height of a block element in the editor
|
|
2005
2005
|
changed in this update.
|
|
2006
2006
|
*/
|
|
2007
2007
|
get heightChanged() {
|
|
2008
|
-
return (this.flags & 2 /* Height */) > 0;
|
|
2008
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2009
2009
|
}
|
|
2010
2010
|
/**
|
|
2011
2011
|
Returns true when the document was modified or the size of the
|
|
2012
2012
|
editor, or elements within the editor, changed.
|
|
2013
2013
|
*/
|
|
2014
2014
|
get geometryChanged() {
|
|
2015
|
-
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2015
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2016
2016
|
}
|
|
2017
2017
|
/**
|
|
2018
2018
|
True when this update indicates a focus change.
|
|
2019
2019
|
*/
|
|
2020
2020
|
get focusChanged() {
|
|
2021
|
-
return (this.flags & 1 /* Focus */) > 0;
|
|
2021
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2022
2022
|
}
|
|
2023
2023
|
/**
|
|
2024
2024
|
Whether the document changed in this update.
|
|
@@ -2076,12 +2076,12 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2076
2076
|
}
|
|
2077
2077
|
function charType(ch) {
|
|
2078
2078
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2079
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2079
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2080
2080
|
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 */;
|
|
2081
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2082
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :
|
|
2083
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :
|
|
2084
|
+
ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;
|
|
2085
2085
|
}
|
|
2086
2086
|
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2087
2087
|
/**
|
|
@@ -2146,8 +2146,8 @@ class BidiSpan {
|
|
|
2146
2146
|
// Reused array of character types
|
|
2147
2147
|
const types = [];
|
|
2148
2148
|
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))
|
|
2149
|
+
let len = line.length, outerType = direction == LTR ? 1 /* T.L */ : 2 /* T.R */, oppositeType = direction == LTR ? 2 /* T.R */ : 1 /* T.L */;
|
|
2150
|
+
if (!line || outerType == 1 /* T.L */ && !BidiRE.test(line))
|
|
2151
2151
|
return trivialOrder(len);
|
|
2152
2152
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2153
2153
|
// change the type of the NSM to the type of the previous
|
|
@@ -2161,12 +2161,12 @@ function computeOrder(line, direction) {
|
|
|
2161
2161
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2162
2162
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2163
2163
|
let type = charType(line.charCodeAt(i));
|
|
2164
|
-
if (type == 512 /* NSM */)
|
|
2164
|
+
if (type == 512 /* T.NSM */)
|
|
2165
2165
|
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 */)
|
|
2166
|
+
else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
|
|
2167
|
+
type = 16 /* T.AN */;
|
|
2168
|
+
types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
|
|
2169
|
+
if (type & 7 /* T.Strong */)
|
|
2170
2170
|
prevStrong = type;
|
|
2171
2171
|
prev = type;
|
|
2172
2172
|
}
|
|
@@ -2180,26 +2180,26 @@ function computeOrder(line, direction) {
|
|
|
2180
2180
|
// (Left after this: L, R, EN+AN, NI)
|
|
2181
2181
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2182
2182
|
let type = types[i];
|
|
2183
|
-
if (type == 128 /* CS */) {
|
|
2184
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2183
|
+
if (type == 128 /* T.CS */) {
|
|
2184
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
|
|
2185
2185
|
type = types[i] = prev;
|
|
2186
2186
|
else
|
|
2187
|
-
types[i] = 256 /* NI */;
|
|
2187
|
+
types[i] = 256 /* T.NI */;
|
|
2188
2188
|
}
|
|
2189
|
-
else if (type == 64 /* ET */) {
|
|
2189
|
+
else if (type == 64 /* T.ET */) {
|
|
2190
2190
|
let end = i + 1;
|
|
2191
|
-
while (end < len && types[end] == 64 /* ET */)
|
|
2191
|
+
while (end < len && types[end] == 64 /* T.ET */)
|
|
2192
2192
|
end++;
|
|
2193
|
-
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2193
|
+
let replace = (i && prev == 8 /* T.EN */) || (end < len && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;
|
|
2194
2194
|
for (let j = i; j < end; j++)
|
|
2195
2195
|
types[j] = replace;
|
|
2196
2196
|
i = end - 1;
|
|
2197
2197
|
}
|
|
2198
|
-
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2199
|
-
types[i] = 1 /* L */;
|
|
2198
|
+
else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
|
|
2199
|
+
types[i] = 1 /* T.L */;
|
|
2200
2200
|
}
|
|
2201
2201
|
prev = type;
|
|
2202
|
-
if (type & 7 /* Strong */)
|
|
2202
|
+
if (type & 7 /* T.Strong */)
|
|
2203
2203
|
prevStrong = type;
|
|
2204
2204
|
}
|
|
2205
2205
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2214,9 +2214,9 @@ function computeOrder(line, direction) {
|
|
|
2214
2214
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2215
2215
|
if (BracketStack[sJ + 1] == -br) {
|
|
2216
2216
|
let flags = BracketStack[sJ + 2];
|
|
2217
|
-
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2218
|
-
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2219
|
-
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2217
|
+
let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
|
|
2218
|
+
!(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
|
|
2219
|
+
(flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
|
|
2220
2220
|
if (type)
|
|
2221
2221
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2222
2222
|
sI = sJ;
|
|
@@ -2224,7 +2224,7 @@ function computeOrder(line, direction) {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
}
|
|
2226
2226
|
}
|
|
2227
|
-
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2227
|
+
else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
|
|
2228
2228
|
break;
|
|
2229
2229
|
}
|
|
2230
2230
|
else {
|
|
@@ -2233,20 +2233,20 @@ function computeOrder(line, direction) {
|
|
|
2233
2233
|
BracketStack[sI++] = context;
|
|
2234
2234
|
}
|
|
2235
2235
|
}
|
|
2236
|
-
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2236
|
+
else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
|
|
2237
2237
|
let embed = type == outerType;
|
|
2238
|
-
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2238
|
+
context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
|
|
2239
2239
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2240
2240
|
let cur = BracketStack[sJ + 2];
|
|
2241
|
-
if (cur & 2 /* EmbedInside */)
|
|
2241
|
+
if (cur & 2 /* Bracketed.EmbedInside */)
|
|
2242
2242
|
break;
|
|
2243
2243
|
if (embed) {
|
|
2244
|
-
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2244
|
+
BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
|
|
2245
2245
|
}
|
|
2246
2246
|
else {
|
|
2247
|
-
if (cur & 4 /* OppositeInside */)
|
|
2247
|
+
if (cur & 4 /* Bracketed.OppositeInside */)
|
|
2248
2248
|
break;
|
|
2249
|
-
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2249
|
+
BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
2252
|
}
|
|
@@ -2259,13 +2259,13 @@ function computeOrder(line, direction) {
|
|
|
2259
2259
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2260
2260
|
// (Left after this: L, R, EN+AN)
|
|
2261
2261
|
for (let i = 0; i < len; i++) {
|
|
2262
|
-
if (types[i] == 256 /* NI */) {
|
|
2262
|
+
if (types[i] == 256 /* T.NI */) {
|
|
2263
2263
|
let end = i + 1;
|
|
2264
|
-
while (end < len && types[end] == 256 /* NI */)
|
|
2264
|
+
while (end < len && types[end] == 256 /* T.NI */)
|
|
2265
2265
|
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;
|
|
2266
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* T.L */;
|
|
2267
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* T.L */;
|
|
2268
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
|
|
2269
2269
|
for (let j = i; j < end; j++)
|
|
2270
2270
|
types[j] = replace;
|
|
2271
2271
|
i = end - 1;
|
|
@@ -2277,15 +2277,15 @@ function computeOrder(line, direction) {
|
|
|
2277
2277
|
// explicit embedding into account, we can build up the order on
|
|
2278
2278
|
// the fly, without following the level-based algorithm.
|
|
2279
2279
|
let order = [];
|
|
2280
|
-
if (outerType == 1 /* L */) {
|
|
2280
|
+
if (outerType == 1 /* T.L */) {
|
|
2281
2281
|
for (let i = 0; i < len;) {
|
|
2282
|
-
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2283
|
-
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2282
|
+
let start = i, rtl = types[i++] != 1 /* T.L */;
|
|
2283
|
+
while (i < len && rtl == (types[i] != 1 /* T.L */))
|
|
2284
2284
|
i++;
|
|
2285
2285
|
if (rtl) {
|
|
2286
2286
|
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 */))
|
|
2287
|
+
let end = j, l = types[--j] != 2 /* T.R */;
|
|
2288
|
+
while (j > start && l == (types[j - 1] != 2 /* T.R */))
|
|
2289
2289
|
j--;
|
|
2290
2290
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2291
2291
|
}
|
|
@@ -2297,8 +2297,8 @@ function computeOrder(line, direction) {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
else {
|
|
2299
2299
|
for (let i = 0; i < len;) {
|
|
2300
|
-
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2301
|
-
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2300
|
+
let start = i, rtl = types[i++] == 2 /* T.R */;
|
|
2301
|
+
while (i < len && rtl == (types[i] == 2 /* T.R */))
|
|
2302
2302
|
i++;
|
|
2303
2303
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2304
2304
|
}
|
|
@@ -2519,7 +2519,7 @@ class DocView extends ContentView {
|
|
|
2519
2519
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2520
2520
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2521
2521
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2522
|
-
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2522
|
+
if (this.dirty == 0 /* Dirty.Not */ && changedRanges.length == 0) {
|
|
2523
2523
|
return false;
|
|
2524
2524
|
}
|
|
2525
2525
|
else {
|
|
@@ -2548,7 +2548,7 @@ class DocView extends ContentView {
|
|
|
2548
2548
|
// to detect that situation.
|
|
2549
2549
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2550
2550
|
this.sync(track);
|
|
2551
|
-
this.dirty = 0 /* Not */;
|
|
2551
|
+
this.dirty = 0 /* Dirty.Not */;
|
|
2552
2552
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2553
2553
|
this.forceSelection = true;
|
|
2554
2554
|
this.dom.style.height = "";
|
|
@@ -2577,8 +2577,7 @@ class DocView extends ContentView {
|
|
|
2577
2577
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2578
2578
|
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2579
2579
|
this.view.observer.readSelectionRange();
|
|
2580
|
-
if (!(fromPointer || this.mayControlSelection())
|
|
2581
|
-
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
2580
|
+
if (!(fromPointer || this.mayControlSelection()))
|
|
2582
2581
|
return;
|
|
2583
2582
|
let force = this.forceSelection;
|
|
2584
2583
|
this.forceSelection = false;
|
|
@@ -2615,10 +2614,10 @@ class DocView extends ContentView {
|
|
|
2615
2614
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2616
2615
|
if (browser.gecko) {
|
|
2617
2616
|
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);
|
|
2617
|
+
if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
|
|
2618
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);
|
|
2620
2619
|
if (text)
|
|
2621
|
-
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2620
|
+
anchor = new DOMPos(text, nextTo == 1 /* NextTo.Before */ ? 0 : text.nodeValue.length);
|
|
2622
2621
|
}
|
|
2623
2622
|
}
|
|
2624
2623
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -2950,8 +2949,8 @@ function nearbyTextNode(node, offset, side) {
|
|
|
2950
2949
|
function nextToUneditable(node, offset) {
|
|
2951
2950
|
if (node.nodeType != 1)
|
|
2952
2951
|
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);
|
|
2952
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
|
|
2953
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
|
|
2955
2954
|
}
|
|
2956
2955
|
class DecorationComparator$1 {
|
|
2957
2956
|
constructor() {
|
|
@@ -3306,7 +3305,7 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3306
3305
|
for (let set of atoms) {
|
|
3307
3306
|
set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
|
|
3308
3307
|
if (pos.from > from && pos.from < to) {
|
|
3309
|
-
pos = oldPos.
|
|
3308
|
+
pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
|
|
3310
3309
|
moved = true;
|
|
3311
3310
|
}
|
|
3312
3311
|
});
|
|
@@ -3348,7 +3347,6 @@ class InputState {
|
|
|
3348
3347
|
// composition)
|
|
3349
3348
|
this.compositionFirstChange = null;
|
|
3350
3349
|
this.compositionEndedAt = 0;
|
|
3351
|
-
this.rapidCompositionStart = false;
|
|
3352
3350
|
this.mouseSelection = null;
|
|
3353
3351
|
for (let type in handlers) {
|
|
3354
3352
|
let handler = handlers[type];
|
|
@@ -3496,8 +3494,7 @@ class InputState {
|
|
|
3496
3494
|
return false;
|
|
3497
3495
|
}
|
|
3498
3496
|
mustFlushObserver(event) {
|
|
3499
|
-
return
|
|
3500
|
-
event.type == "compositionend" && !browser.ios;
|
|
3497
|
+
return event.type == "keydown" && event.keyCode != 229;
|
|
3501
3498
|
}
|
|
3502
3499
|
startMouseSelection(mouseSelection) {
|
|
3503
3500
|
if (this.mouseSelection)
|
|
@@ -3765,8 +3762,7 @@ function basicMouseSelection(view, event) {
|
|
|
3765
3762
|
return {
|
|
3766
3763
|
update(update) {
|
|
3767
3764
|
if (update.docChanged) {
|
|
3768
|
-
|
|
3769
|
-
start.pos = update.changes.mapPos(start.pos);
|
|
3765
|
+
start.pos = update.changes.mapPos(start.pos);
|
|
3770
3766
|
startSel = startSel.map(update.changes);
|
|
3771
3767
|
lastEvent = null;
|
|
3772
3768
|
}
|
|
@@ -3779,8 +3775,6 @@ function basicMouseSelection(view, event) {
|
|
|
3779
3775
|
cur = last = queryPos(view, event);
|
|
3780
3776
|
lastEvent = event;
|
|
3781
3777
|
}
|
|
3782
|
-
if (!cur || !start)
|
|
3783
|
-
return startSel;
|
|
3784
3778
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3785
3779
|
if (start.pos != cur.pos && !extend) {
|
|
3786
3780
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -3952,36 +3946,24 @@ handlers.blur = view => {
|
|
|
3952
3946
|
view.observer.clearSelectionRange();
|
|
3953
3947
|
updateForFocusChange(view);
|
|
3954
3948
|
};
|
|
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
3949
|
handlers.compositionstart = handlers.compositionupdate = view => {
|
|
3967
3950
|
if (view.inputState.compositionFirstChange == null)
|
|
3968
3951
|
view.inputState.compositionFirstChange = true;
|
|
3969
3952
|
if (view.inputState.composing < 0) {
|
|
3970
3953
|
// FIXME possibly set a timeout to clear it again on Android
|
|
3971
3954
|
view.inputState.composing = 0;
|
|
3972
|
-
if (view.docView.compositionDeco.size) {
|
|
3973
|
-
view.observer.flush();
|
|
3974
|
-
forceClearComposition(view, true);
|
|
3975
|
-
}
|
|
3976
3955
|
}
|
|
3977
3956
|
};
|
|
3978
3957
|
handlers.compositionend = view => {
|
|
3979
3958
|
view.inputState.composing = -1;
|
|
3980
3959
|
view.inputState.compositionEndedAt = Date.now();
|
|
3981
3960
|
view.inputState.compositionFirstChange = null;
|
|
3961
|
+
if (browser.chrome && browser.android)
|
|
3962
|
+
view.observer.flushSoon();
|
|
3982
3963
|
setTimeout(() => {
|
|
3983
|
-
if
|
|
3984
|
-
|
|
3964
|
+
// Force the composition state to be cleared if it hasn't already been
|
|
3965
|
+
if (view.inputState.composing < 0 && view.docView.compositionDeco.size)
|
|
3966
|
+
view.update([]);
|
|
3985
3967
|
}, 50);
|
|
3986
3968
|
};
|
|
3987
3969
|
handlers.contextmenu = view => {
|
|
@@ -4151,13 +4133,13 @@ const Epsilon = 1e-3;
|
|
|
4151
4133
|
class HeightMap {
|
|
4152
4134
|
constructor(length, // The number of characters covered
|
|
4153
4135
|
height, // Height of this part of the document
|
|
4154
|
-
flags = 2 /* Outdated */) {
|
|
4136
|
+
flags = 2 /* Flag.Outdated */) {
|
|
4155
4137
|
this.length = length;
|
|
4156
4138
|
this.height = height;
|
|
4157
4139
|
this.flags = flags;
|
|
4158
4140
|
}
|
|
4159
|
-
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4160
|
-
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4141
|
+
get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
|
|
4142
|
+
set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
|
|
4161
4143
|
setHeight(oracle, height) {
|
|
4162
4144
|
if (this.height != height) {
|
|
4163
4145
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4284,7 +4266,7 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4284
4266
|
}
|
|
4285
4267
|
replace(_from, _to, nodes) {
|
|
4286
4268
|
let node = nodes[0];
|
|
4287
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4269
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
|
|
4288
4270
|
Math.abs(this.length - node.length) < 10) {
|
|
4289
4271
|
if (node instanceof HeightMapGap)
|
|
4290
4272
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4410,12 +4392,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4410
4392
|
}
|
|
4411
4393
|
class HeightMapBranch extends HeightMap {
|
|
4412
4394
|
constructor(left, brk, right) {
|
|
4413
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4395
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
|
|
4414
4396
|
this.left = left;
|
|
4415
4397
|
this.right = right;
|
|
4416
4398
|
this.size = left.size + right.size;
|
|
4417
4399
|
}
|
|
4418
|
-
get break() { return this.flags & 1 /* Break */; }
|
|
4400
|
+
get break() { return this.flags & 1 /* Flag.Break */; }
|
|
4419
4401
|
blockAt(height, doc, top, offset) {
|
|
4420
4402
|
let mid = top + this.left.height;
|
|
4421
4403
|
return height < mid ? this.left.blockAt(height, doc, top, offset)
|
|
@@ -4599,7 +4581,7 @@ class NodeBuilder {
|
|
|
4599
4581
|
blankContent(from, to) {
|
|
4600
4582
|
let gap = new HeightMapGap(to - from);
|
|
4601
4583
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4602
|
-
gap.flags |= 4 /* SingleLine */;
|
|
4584
|
+
gap.flags |= 4 /* Flag.SingleLine */;
|
|
4603
4585
|
return gap;
|
|
4604
4586
|
}
|
|
4605
4587
|
ensureLine() {
|
|
@@ -4797,7 +4779,7 @@ class ViewState {
|
|
|
4797
4779
|
}
|
|
4798
4780
|
}
|
|
4799
4781
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
4800
|
-
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
4782
|
+
this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
|
|
4801
4783
|
new BigScaler(this.heightOracle.doc, this.heightMap, this.viewports);
|
|
4802
4784
|
}
|
|
4803
4785
|
updateViewportLines() {
|
|
@@ -4815,18 +4797,18 @@ class ViewState {
|
|
|
4815
4797
|
let prevHeight = this.heightMap.height;
|
|
4816
4798
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
4817
4799
|
if (this.heightMap.height != prevHeight)
|
|
4818
|
-
update.flags |= 2 /* Height */;
|
|
4800
|
+
update.flags |= 2 /* UpdateFlag.Height */;
|
|
4819
4801
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
4820
4802
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
4821
4803
|
!this.viewportIsAppropriate(viewport))
|
|
4822
4804
|
viewport = this.getViewport(0, scrollTarget);
|
|
4823
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
4805
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||
|
|
4824
4806
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
4825
4807
|
this.viewport = viewport;
|
|
4826
4808
|
this.updateForViewport();
|
|
4827
4809
|
if (updateLines)
|
|
4828
4810
|
this.updateViewportLines();
|
|
4829
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4811
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4830
4812
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
4831
4813
|
update.flags |= this.computeVisibleRanges();
|
|
4832
4814
|
if (scrollTarget)
|
|
@@ -4850,13 +4832,13 @@ class ViewState {
|
|
|
4850
4832
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4851
4833
|
this.paddingTop = paddingTop;
|
|
4852
4834
|
this.paddingBottom = paddingBottom;
|
|
4853
|
-
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4835
|
+
result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
|
|
4854
4836
|
}
|
|
4855
4837
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4856
4838
|
if (oracle.lineWrapping)
|
|
4857
4839
|
measureContent = true;
|
|
4858
4840
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4859
|
-
result |= 8 /* Geometry */;
|
|
4841
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4860
4842
|
}
|
|
4861
4843
|
// Pixel viewport
|
|
4862
4844
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
@@ -4874,7 +4856,7 @@ class ViewState {
|
|
|
4874
4856
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
4875
4857
|
this.contentDOMWidth = contentWidth;
|
|
4876
4858
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
4877
|
-
result |= 8 /* Geometry */;
|
|
4859
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4878
4860
|
}
|
|
4879
4861
|
if (measureContent) {
|
|
4880
4862
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -4885,7 +4867,7 @@ class ViewState {
|
|
|
4885
4867
|
refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
|
|
4886
4868
|
if (refresh) {
|
|
4887
4869
|
view.docView.minWidth = 0;
|
|
4888
|
-
result |= 8 /* Geometry */;
|
|
4870
|
+
result |= 8 /* UpdateFlag.Geometry */;
|
|
4889
4871
|
}
|
|
4890
4872
|
}
|
|
4891
4873
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -4898,16 +4880,16 @@ class ViewState {
|
|
|
4898
4880
|
this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
4899
4881
|
}
|
|
4900
4882
|
if (oracle.heightChanged)
|
|
4901
|
-
result |= 2 /* Height */;
|
|
4883
|
+
result |= 2 /* UpdateFlag.Height */;
|
|
4902
4884
|
}
|
|
4903
4885
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
4904
4886
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
|
|
4905
4887
|
if (viewportChange)
|
|
4906
4888
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
4907
4889
|
this.updateForViewport();
|
|
4908
|
-
if ((result & 2 /* Height */) || viewportChange)
|
|
4890
|
+
if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
|
|
4909
4891
|
this.updateViewportLines();
|
|
4910
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
|
|
4892
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* LG.DoubleMargin */)
|
|
4911
4893
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
|
|
4912
4894
|
result |= this.computeVisibleRanges();
|
|
4913
4895
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -4926,9 +4908,9 @@ class ViewState {
|
|
|
4926
4908
|
// This will divide VP.Margin between the top and the
|
|
4927
4909
|
// bottom, depending on the bias (the change in viewport position
|
|
4928
4910
|
// 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));
|
|
4911
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
|
|
4930
4912
|
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);
|
|
4913
|
+
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).to);
|
|
4932
4914
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
4933
4915
|
if (scrollTarget) {
|
|
4934
4916
|
let { head } = scrollTarget.range;
|
|
@@ -4941,7 +4923,7 @@ class ViewState {
|
|
|
4941
4923
|
topPos = block.top;
|
|
4942
4924
|
else
|
|
4943
4925
|
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);
|
|
4926
|
+
viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).to);
|
|
4945
4927
|
}
|
|
4946
4928
|
}
|
|
4947
4929
|
return viewport;
|
|
@@ -4958,10 +4940,10 @@ class ViewState {
|
|
|
4958
4940
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4959
4941
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
4960
4942
|
let { visibleTop, visibleBottom } = this;
|
|
4961
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
4943
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4962
4944
|
(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 */);
|
|
4945
|
+
bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
|
|
4946
|
+
(top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
|
|
4965
4947
|
}
|
|
4966
4948
|
mapLineGaps(gaps, changes) {
|
|
4967
4949
|
if (!gaps.length || changes.empty)
|
|
@@ -4985,20 +4967,20 @@ class ViewState {
|
|
|
4985
4967
|
if (this.defaultTextDirection != Direction.LTR)
|
|
4986
4968
|
return gaps;
|
|
4987
4969
|
for (let line of this.viewportLines) {
|
|
4988
|
-
if (line.length < 4000 /* DoubleMargin */)
|
|
4970
|
+
if (line.length < 4000 /* LG.DoubleMargin */)
|
|
4989
4971
|
continue;
|
|
4990
4972
|
let structure = lineStructure(line.from, line.to, this.stateDeco);
|
|
4991
|
-
if (structure.total < 4000 /* DoubleMargin */)
|
|
4973
|
+
if (structure.total < 4000 /* LG.DoubleMargin */)
|
|
4992
4974
|
continue;
|
|
4993
4975
|
let viewFrom, viewTo;
|
|
4994
4976
|
if (this.heightOracle.lineWrapping) {
|
|
4995
|
-
let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4977
|
+
let marginHeight = (2000 /* LG.Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
|
|
4996
4978
|
viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
|
|
4997
4979
|
viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
|
|
4998
4980
|
}
|
|
4999
4981
|
else {
|
|
5000
4982
|
let totalWidth = structure.total * this.heightOracle.charWidth;
|
|
5001
|
-
let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
|
|
4983
|
+
let marginWidth = 2000 /* LG.Margin */ * this.heightOracle.charWidth;
|
|
5002
4984
|
viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
|
|
5003
4985
|
viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
|
|
5004
4986
|
}
|
|
@@ -5010,13 +4992,13 @@ class ViewState {
|
|
|
5010
4992
|
let sel = this.state.selection.main;
|
|
5011
4993
|
// Make sure the gaps don't cover a selection end
|
|
5012
4994
|
if (sel.from >= line.from && sel.from <= line.to)
|
|
5013
|
-
cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
|
|
4995
|
+
cutRange(outside, sel.from - 10 /* LG.SelectionMargin */, sel.from + 10 /* LG.SelectionMargin */);
|
|
5014
4996
|
if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
|
|
5015
|
-
cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
|
|
4997
|
+
cutRange(outside, sel.to - 10 /* LG.SelectionMargin */, sel.to + 10 /* LG.SelectionMargin */);
|
|
5016
4998
|
for (let { from, to } of outside)
|
|
5017
|
-
if (to - from > 1000 /* HalfMargin */) {
|
|
4999
|
+
if (to - from > 1000 /* LG.HalfMargin */) {
|
|
5018
5000
|
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 */) ||
|
|
5001
|
+
Math.abs(gap.from - from) < 1000 /* LG.HalfMargin */ && Math.abs(gap.to - to) < 1000 /* LG.HalfMargin */) ||
|
|
5020
5002
|
new LineGap(from, to, this.gapSize(line, from, to, structure)));
|
|
5021
5003
|
}
|
|
5022
5004
|
}
|
|
@@ -5049,7 +5031,7 @@ class ViewState {
|
|
|
5049
5031
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5050
5032
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5051
5033
|
this.visibleRanges = ranges;
|
|
5052
|
-
return changed ? 4 /* Viewport */ : 0;
|
|
5034
|
+
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
5053
5035
|
}
|
|
5054
5036
|
lineBlockAt(pos) {
|
|
5055
5037
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5155,7 +5137,7 @@ class BigScaler {
|
|
|
5155
5137
|
vpHeight += bottom - top;
|
|
5156
5138
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5157
5139
|
});
|
|
5158
|
-
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5140
|
+
this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5159
5141
|
for (let obj of this.viewports) {
|
|
5160
5142
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5161
5143
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5458,6 +5440,7 @@ class DOMObserver {
|
|
|
5458
5440
|
this.resizeTimeout = -1;
|
|
5459
5441
|
this.queue = [];
|
|
5460
5442
|
this.delayedAndroidKey = null;
|
|
5443
|
+
this.lastChange = 0;
|
|
5461
5444
|
this.scrollTargets = [];
|
|
5462
5445
|
this.intersection = null;
|
|
5463
5446
|
this.resize = null;
|
|
@@ -5504,8 +5487,7 @@ class DOMObserver {
|
|
|
5504
5487
|
});
|
|
5505
5488
|
this.resize.observe(view.scrollDOM);
|
|
5506
5489
|
}
|
|
5507
|
-
this.win = view.
|
|
5508
|
-
this.addWindowListeners(this.win);
|
|
5490
|
+
this.addWindowListeners(this.win = view.win);
|
|
5509
5491
|
this.start();
|
|
5510
5492
|
if (typeof IntersectionObserver == "function") {
|
|
5511
5493
|
this.intersection = new IntersectionObserver(entries => {
|
|
@@ -5684,26 +5666,34 @@ class DOMObserver {
|
|
|
5684
5666
|
// detected (via beforeinput or keydown), and then tries to flush
|
|
5685
5667
|
// them or, if that has no effect, dispatches the given key.
|
|
5686
5668
|
delayAndroidKey(key, keyCode) {
|
|
5669
|
+
var _a;
|
|
5687
5670
|
if (!this.delayedAndroidKey)
|
|
5688
|
-
requestAnimationFrame(() => {
|
|
5671
|
+
this.view.win.requestAnimationFrame(() => {
|
|
5689
5672
|
let key = this.delayedAndroidKey;
|
|
5690
5673
|
this.delayedAndroidKey = null;
|
|
5691
5674
|
this.delayedFlush = -1;
|
|
5692
|
-
if (!this.flush())
|
|
5675
|
+
if (!this.flush() && key.force)
|
|
5693
5676
|
dispatchKey(this.dom, key.key, key.keyCode);
|
|
5694
5677
|
});
|
|
5695
5678
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5696
5679
|
// Enter always takes precedence.
|
|
5697
5680
|
if (!this.delayedAndroidKey || key == "Enter")
|
|
5698
|
-
this.delayedAndroidKey = {
|
|
5681
|
+
this.delayedAndroidKey = {
|
|
5682
|
+
key, keyCode,
|
|
5683
|
+
// Only run the key handler when no changes are detected if
|
|
5684
|
+
// this isn't coming right after another change, in which case
|
|
5685
|
+
// it is probably part of a weird chain of updates, and should
|
|
5686
|
+
// be ignored if it returns the DOM to its previous state.
|
|
5687
|
+
force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
|
|
5688
|
+
};
|
|
5699
5689
|
}
|
|
5700
5690
|
flushSoon() {
|
|
5701
5691
|
if (this.delayedFlush < 0)
|
|
5702
|
-
this.delayedFlush =
|
|
5692
|
+
this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
|
|
5703
5693
|
}
|
|
5704
5694
|
forceFlush() {
|
|
5705
5695
|
if (this.delayedFlush >= 0) {
|
|
5706
|
-
|
|
5696
|
+
this.view.win.cancelAnimationFrame(this.delayedFlush);
|
|
5707
5697
|
this.delayedFlush = -1;
|
|
5708
5698
|
}
|
|
5709
5699
|
this.flush();
|
|
@@ -5737,13 +5727,15 @@ class DOMObserver {
|
|
|
5737
5727
|
// managing those will make sure processRecords is called and the
|
|
5738
5728
|
// view is resynchronized after
|
|
5739
5729
|
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
|
|
5740
|
-
return;
|
|
5730
|
+
return false;
|
|
5741
5731
|
if (readSelection)
|
|
5742
5732
|
this.readSelectionRange();
|
|
5743
5733
|
let { from, to, typeOver } = this.processRecords();
|
|
5744
5734
|
let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
|
|
5745
5735
|
if (from < 0 && !newSel)
|
|
5746
|
-
return;
|
|
5736
|
+
return false;
|
|
5737
|
+
if (from > -1)
|
|
5738
|
+
this.lastChange = Date.now();
|
|
5747
5739
|
this.view.inputState.lastFocusTime = 0;
|
|
5748
5740
|
this.selectionChanged = false;
|
|
5749
5741
|
let startState = this.view.state;
|
|
@@ -5759,7 +5751,7 @@ class DOMObserver {
|
|
|
5759
5751
|
return null;
|
|
5760
5752
|
cView.markDirty(rec.type == "attributes");
|
|
5761
5753
|
if (rec.type == "attributes")
|
|
5762
|
-
cView.dirty |= 4 /* Attrs */;
|
|
5754
|
+
cView.dirty |= 4 /* Dirty.Attrs */;
|
|
5763
5755
|
if (rec.type == "childList") {
|
|
5764
5756
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
5765
5757
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -6086,7 +6078,7 @@ class EditorView {
|
|
|
6086
6078
|
/**
|
|
6087
6079
|
@internal
|
|
6088
6080
|
*/
|
|
6089
|
-
this.updateState = 2 /* Updating */;
|
|
6081
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6090
6082
|
/**
|
|
6091
6083
|
@internal
|
|
6092
6084
|
*/
|
|
@@ -6125,7 +6117,7 @@ class EditorView {
|
|
|
6125
6117
|
this.docView = new DocView(this);
|
|
6126
6118
|
this.mountStyles();
|
|
6127
6119
|
this.updateAttrs();
|
|
6128
|
-
this.updateState = 0 /* Idle */;
|
|
6120
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6129
6121
|
this.requestMeasure();
|
|
6130
6122
|
if (config.parent)
|
|
6131
6123
|
config.parent.appendChild(this.dom);
|
|
@@ -6173,6 +6165,10 @@ class EditorView {
|
|
|
6173
6165
|
The document or shadow root that the view lives in.
|
|
6174
6166
|
*/
|
|
6175
6167
|
get root() { return this._root; }
|
|
6168
|
+
/**
|
|
6169
|
+
@internal
|
|
6170
|
+
*/
|
|
6171
|
+
get win() { return this.dom.ownerDocument.defaultView; }
|
|
6176
6172
|
dispatch(...input) {
|
|
6177
6173
|
this._dispatch(input.length == 1 && input[0] instanceof Transaction ? input[0]
|
|
6178
6174
|
: this.state.update(...input));
|
|
@@ -6186,7 +6182,7 @@ class EditorView {
|
|
|
6186
6182
|
as a primitive.
|
|
6187
6183
|
*/
|
|
6188
6184
|
update(transactions) {
|
|
6189
|
-
if (this.updateState != 0 /* Idle */)
|
|
6185
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6190
6186
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6191
6187
|
let redrawn = false, attrsChanged = false, update;
|
|
6192
6188
|
let state = this.state;
|
|
@@ -6206,7 +6202,7 @@ class EditorView {
|
|
|
6206
6202
|
update = ViewUpdate.create(this, state, transactions);
|
|
6207
6203
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6208
6204
|
try {
|
|
6209
|
-
this.updateState = 2 /* Updating */;
|
|
6205
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6210
6206
|
for (let tr of transactions) {
|
|
6211
6207
|
if (scrollTarget)
|
|
6212
6208
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6232,7 +6228,7 @@ class EditorView {
|
|
|
6232
6228
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6233
6229
|
}
|
|
6234
6230
|
finally {
|
|
6235
|
-
this.updateState = 0 /* Idle */;
|
|
6231
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6236
6232
|
}
|
|
6237
6233
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6238
6234
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6250,13 +6246,13 @@ class EditorView {
|
|
|
6250
6246
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6251
6247
|
*/
|
|
6252
6248
|
setState(newState) {
|
|
6253
|
-
if (this.updateState != 0 /* Idle */)
|
|
6249
|
+
if (this.updateState != 0 /* UpdateState.Idle */)
|
|
6254
6250
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6255
6251
|
if (this.destroyed) {
|
|
6256
6252
|
this.viewState.state = newState;
|
|
6257
6253
|
return;
|
|
6258
6254
|
}
|
|
6259
|
-
this.updateState = 2 /* Updating */;
|
|
6255
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6260
6256
|
let hadFocus = this.hasFocus;
|
|
6261
6257
|
try {
|
|
6262
6258
|
for (let plugin of this.plugins)
|
|
@@ -6273,7 +6269,7 @@ class EditorView {
|
|
|
6273
6269
|
this.bidiCache = [];
|
|
6274
6270
|
}
|
|
6275
6271
|
finally {
|
|
6276
|
-
this.updateState = 0 /* Idle */;
|
|
6272
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6277
6273
|
}
|
|
6278
6274
|
if (hadFocus)
|
|
6279
6275
|
this.focus();
|
|
@@ -6324,7 +6320,7 @@ class EditorView {
|
|
|
6324
6320
|
let refHeight = scrollTop > scrollHeight - clientHeight - 4 ? scrollHeight : scrollTop;
|
|
6325
6321
|
try {
|
|
6326
6322
|
for (let i = 0;; i++) {
|
|
6327
|
-
this.updateState = 1 /* Measuring */;
|
|
6323
|
+
this.updateState = 1 /* UpdateState.Measuring */;
|
|
6328
6324
|
let oldViewport = this.viewport;
|
|
6329
6325
|
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6330
6326
|
let changed = this.viewState.measure(this);
|
|
@@ -6338,7 +6334,7 @@ class EditorView {
|
|
|
6338
6334
|
}
|
|
6339
6335
|
let measuring = [];
|
|
6340
6336
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6341
|
-
if (!(changed & 4 /* Viewport */))
|
|
6337
|
+
if (!(changed & 4 /* UpdateFlag.Viewport */))
|
|
6342
6338
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6343
6339
|
let measured = measuring.map(m => {
|
|
6344
6340
|
try {
|
|
@@ -6355,7 +6351,7 @@ class EditorView {
|
|
|
6355
6351
|
updated = update;
|
|
6356
6352
|
else
|
|
6357
6353
|
updated.flags |= changed;
|
|
6358
|
-
this.updateState = 2 /* Updating */;
|
|
6354
|
+
this.updateState = 2 /* UpdateState.Updating */;
|
|
6359
6355
|
if (!update.empty) {
|
|
6360
6356
|
this.updatePlugins(update);
|
|
6361
6357
|
this.inputState.update(update);
|
|
@@ -6393,7 +6389,7 @@ class EditorView {
|
|
|
6393
6389
|
}
|
|
6394
6390
|
}
|
|
6395
6391
|
finally {
|
|
6396
|
-
this.updateState = 0 /* Idle */;
|
|
6392
|
+
this.updateState = 0 /* UpdateState.Idle */;
|
|
6397
6393
|
this.measureScheduled = -1;
|
|
6398
6394
|
}
|
|
6399
6395
|
if (updated && !updated.empty)
|
|
@@ -6452,9 +6448,9 @@ class EditorView {
|
|
|
6452
6448
|
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6453
6449
|
}
|
|
6454
6450
|
readMeasured() {
|
|
6455
|
-
if (this.updateState == 2 /* Updating */)
|
|
6451
|
+
if (this.updateState == 2 /* UpdateState.Updating */)
|
|
6456
6452
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6457
|
-
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6453
|
+
if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
|
|
6458
6454
|
this.measure(false);
|
|
6459
6455
|
}
|
|
6460
6456
|
/**
|
|
@@ -6467,7 +6463,7 @@ class EditorView {
|
|
|
6467
6463
|
*/
|
|
6468
6464
|
requestMeasure(request) {
|
|
6469
6465
|
if (this.measureScheduled < 0)
|
|
6470
|
-
this.measureScheduled = requestAnimationFrame(() => this.measure());
|
|
6466
|
+
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6471
6467
|
if (request) {
|
|
6472
6468
|
if (request.key != null)
|
|
6473
6469
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
@@ -7342,7 +7338,7 @@ function measureRange(view, range) {
|
|
|
7342
7338
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7343
7339
|
}
|
|
7344
7340
|
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");
|
|
7341
|
+
return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
|
|
7346
7342
|
}
|
|
7347
7343
|
function pieces({ top, bottom, horizontal }) {
|
|
7348
7344
|
let pieces = [];
|
|
@@ -8039,7 +8035,6 @@ const tooltipConfig = /*@__PURE__*/Facet.define({
|
|
|
8039
8035
|
});
|
|
8040
8036
|
const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
8041
8037
|
constructor(view) {
|
|
8042
|
-
var _a;
|
|
8043
8038
|
this.view = view;
|
|
8044
8039
|
this.inView = true;
|
|
8045
8040
|
this.lastTransaction = 0;
|
|
@@ -8057,7 +8052,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8057
8052
|
this.measureSoon();
|
|
8058
8053
|
}, { threshold: [1] }) : null;
|
|
8059
8054
|
this.observeIntersection();
|
|
8060
|
-
|
|
8055
|
+
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
8061
8056
|
this.maybeMeasure();
|
|
8062
8057
|
}
|
|
8063
8058
|
createContainer() {
|
|
@@ -8130,11 +8125,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8130
8125
|
return tooltipView;
|
|
8131
8126
|
}
|
|
8132
8127
|
destroy() {
|
|
8133
|
-
var _a
|
|
8134
|
-
|
|
8128
|
+
var _a;
|
|
8129
|
+
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
8135
8130
|
for (let { dom } of this.manager.tooltipViews)
|
|
8136
8131
|
dom.remove();
|
|
8137
|
-
(
|
|
8132
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
8138
8133
|
clearTimeout(this.measureTimeout);
|
|
8139
8134
|
}
|
|
8140
8135
|
readMeasure() {
|
|
@@ -8165,12 +8160,12 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8165
8160
|
continue;
|
|
8166
8161
|
}
|
|
8167
8162
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8168
|
-
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8163
|
+
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
8169
8164
|
let width = size.right - size.left, height = size.bottom - size.top;
|
|
8170
8165
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
|
|
8171
8166
|
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);
|
|
8167
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
8168
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
8174
8169
|
let above = !!tooltip.above;
|
|
8175
8170
|
if (!tooltip.strictSide && (above
|
|
8176
8171
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8192,7 +8187,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8192
8187
|
dom.style.left = left + "px";
|
|
8193
8188
|
}
|
|
8194
8189
|
if (arrow)
|
|
8195
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8190
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */)}px`;
|
|
8196
8191
|
if (tView.overlap !== true)
|
|
8197
8192
|
others.push({ left, top, right, bottom: top + height });
|
|
8198
8193
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8234,8 +8229,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8234
8229
|
color: "white"
|
|
8235
8230
|
},
|
|
8236
8231
|
".cm-tooltip-arrow": {
|
|
8237
|
-
height: `${7 /* Size */}px`,
|
|
8238
|
-
width: `${7 /* Size */ * 2}px`,
|
|
8232
|
+
height: `${7 /* Arrow.Size */}px`,
|
|
8233
|
+
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
8239
8234
|
position: "absolute",
|
|
8240
8235
|
zIndex: -1,
|
|
8241
8236
|
overflow: "hidden",
|
|
@@ -8244,26 +8239,26 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8244
8239
|
position: "absolute",
|
|
8245
8240
|
width: 0,
|
|
8246
8241
|
height: 0,
|
|
8247
|
-
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8248
|
-
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8242
|
+
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8243
|
+
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
8249
8244
|
},
|
|
8250
8245
|
".cm-tooltip-above &": {
|
|
8251
|
-
bottom: `-${7 /* Size */}px`,
|
|
8246
|
+
bottom: `-${7 /* Arrow.Size */}px`,
|
|
8252
8247
|
"&:before": {
|
|
8253
|
-
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8248
|
+
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8254
8249
|
},
|
|
8255
8250
|
"&:after": {
|
|
8256
|
-
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8251
|
+
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8257
8252
|
bottom: "1px"
|
|
8258
8253
|
}
|
|
8259
8254
|
},
|
|
8260
8255
|
".cm-tooltip-below &": {
|
|
8261
|
-
top: `-${7 /* Size */}px`,
|
|
8256
|
+
top: `-${7 /* Arrow.Size */}px`,
|
|
8262
8257
|
"&:before": {
|
|
8263
|
-
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8258
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
8264
8259
|
},
|
|
8265
8260
|
"&:after": {
|
|
8266
|
-
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8261
|
+
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
8267
8262
|
top: "1px"
|
|
8268
8263
|
}
|
|
8269
8264
|
},
|
|
@@ -8408,7 +8403,7 @@ class HoverPlugin {
|
|
|
8408
8403
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
8409
8404
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
8410
8405
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
8411
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
8406
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* Hover.MaxDist */))) {
|
|
8412
8407
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
8413
8408
|
this.pending = null;
|
|
8414
8409
|
}
|
|
@@ -8490,7 +8485,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
8490
8485
|
});
|
|
8491
8486
|
return [
|
|
8492
8487
|
hoverState,
|
|
8493
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
8488
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
8494
8489
|
showHoverTooltipHost
|
|
8495
8490
|
];
|
|
8496
8491
|
}
|