@codemirror/view 6.12.0 → 6.13.0
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 +14 -0
- package/dist/index.cjs +330 -274
- package/dist/index.d.cts +1969 -0
- package/dist/index.d.ts +34 -17
- package/dist/index.js +331 -275
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -335,7 +335,7 @@ class ContentView {
|
|
|
335
335
|
constructor() {
|
|
336
336
|
this.parent = null;
|
|
337
337
|
this.dom = null;
|
|
338
|
-
this.dirty = 2 /*
|
|
338
|
+
this.dirty = 2 /* Node */;
|
|
339
339
|
}
|
|
340
340
|
get overrideDOMText() { return null; }
|
|
341
341
|
get posAtStart() {
|
|
@@ -357,7 +357,7 @@ class ContentView {
|
|
|
357
357
|
return this.posBefore(view) + view.length;
|
|
358
358
|
}
|
|
359
359
|
sync(view, track) {
|
|
360
|
-
if (this.dirty & 2 /*
|
|
360
|
+
if (this.dirty & 2 /* Node */) {
|
|
361
361
|
let parent = this.dom;
|
|
362
362
|
let prev = null, next;
|
|
363
363
|
for (let child of this.children) {
|
|
@@ -368,7 +368,7 @@ class ContentView {
|
|
|
368
368
|
child.reuseDOM(next);
|
|
369
369
|
}
|
|
370
370
|
child.sync(view, track);
|
|
371
|
-
child.dirty = 0 /*
|
|
371
|
+
child.dirty = 0 /* Not */;
|
|
372
372
|
}
|
|
373
373
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
374
374
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -388,11 +388,11 @@ class ContentView {
|
|
|
388
388
|
while (next)
|
|
389
389
|
next = rm$1(next);
|
|
390
390
|
}
|
|
391
|
-
else if (this.dirty & 1 /*
|
|
391
|
+
else if (this.dirty & 1 /* Child */) {
|
|
392
392
|
for (let child of this.children)
|
|
393
393
|
if (child.dirty) {
|
|
394
394
|
child.sync(view, track);
|
|
395
|
-
child.dirty = 0 /*
|
|
395
|
+
child.dirty = 0 /* Not */;
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
}
|
|
@@ -457,16 +457,16 @@ class ContentView {
|
|
|
457
457
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
458
458
|
}
|
|
459
459
|
markDirty(andParent = false) {
|
|
460
|
-
this.dirty |= 2 /*
|
|
460
|
+
this.dirty |= 2 /* Node */;
|
|
461
461
|
this.markParentsDirty(andParent);
|
|
462
462
|
}
|
|
463
463
|
markParentsDirty(childList) {
|
|
464
464
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
465
465
|
if (childList)
|
|
466
|
-
parent.dirty |= 2 /*
|
|
467
|
-
if (parent.dirty & 1 /*
|
|
466
|
+
parent.dirty |= 2 /* Node */;
|
|
467
|
+
if (parent.dirty & 1 /* Child */)
|
|
468
468
|
return;
|
|
469
|
-
parent.dirty |= 1 /*
|
|
469
|
+
parent.dirty |= 1 /* Child */;
|
|
470
470
|
childList = false;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
@@ -745,13 +745,13 @@ class MarkView extends ContentView {
|
|
|
745
745
|
reuseDOM(node) {
|
|
746
746
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
747
747
|
this.setDOM(node);
|
|
748
|
-
this.dirty |= 4 /*
|
|
748
|
+
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
sync(view, track) {
|
|
752
752
|
if (!this.dom)
|
|
753
753
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
754
|
-
else if (this.dirty & 4 /*
|
|
754
|
+
else if (this.dirty & 4 /* Attrs */)
|
|
755
755
|
this.setAttrs(this.dom);
|
|
756
756
|
super.sync(view, track);
|
|
757
757
|
}
|
|
@@ -822,9 +822,6 @@ function textCoords(text, pos, side) {
|
|
|
822
822
|
}
|
|
823
823
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
824
824
|
class WidgetView extends ContentView {
|
|
825
|
-
static create(widget, length, side) {
|
|
826
|
-
return new (widget.customView || WidgetView)(widget, length, side);
|
|
827
|
-
}
|
|
828
825
|
constructor(widget, length, side) {
|
|
829
826
|
super();
|
|
830
827
|
this.widget = widget;
|
|
@@ -832,6 +829,9 @@ class WidgetView extends ContentView {
|
|
|
832
829
|
this.side = side;
|
|
833
830
|
this.prevWidget = null;
|
|
834
831
|
}
|
|
832
|
+
static create(widget, length, side) {
|
|
833
|
+
return new (widget.customView || WidgetView)(widget, length, side);
|
|
834
|
+
}
|
|
835
835
|
split(from) {
|
|
836
836
|
let result = WidgetView.create(this.widget, this.length - from, this.side);
|
|
837
837
|
this.length -= from;
|
|
@@ -891,12 +891,13 @@ class WidgetView extends ContentView {
|
|
|
891
891
|
let rects = this.dom.getClientRects(), rect = null;
|
|
892
892
|
if (!rects.length)
|
|
893
893
|
return null;
|
|
894
|
-
|
|
894
|
+
let fromBack = this.side ? this.side < 0 : pos > 0;
|
|
895
|
+
for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {
|
|
895
896
|
rect = rects[i];
|
|
896
897
|
if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
|
|
897
898
|
break;
|
|
898
899
|
}
|
|
899
|
-
return this.length ? rect : flattenRect(rect,
|
|
900
|
+
return this.length ? rect : flattenRect(rect, !fromBack);
|
|
900
901
|
}
|
|
901
902
|
get isEditable() { return false; }
|
|
902
903
|
get isWidget() { return true; }
|
|
@@ -1216,6 +1217,13 @@ class WidgetType {
|
|
|
1216
1217
|
*/
|
|
1217
1218
|
get estimatedHeight() { return -1; }
|
|
1218
1219
|
/**
|
|
1220
|
+
For inline widgets that are displayed inline (as opposed to
|
|
1221
|
+
`inline-block`) and introduce line breaks (through `<br>` tags
|
|
1222
|
+
or textual newlines), this must indicate the amount of line
|
|
1223
|
+
breaks they introduce. Defaults to 0.
|
|
1224
|
+
*/
|
|
1225
|
+
get lineBreaks() { return 0; }
|
|
1226
|
+
/**
|
|
1219
1227
|
Can be used to configure which kinds of events inside the widget
|
|
1220
1228
|
should be ignored by the editor. The default is to ignore all
|
|
1221
1229
|
events.
|
|
@@ -1318,8 +1326,8 @@ class Decoration extends state.RangeValue {
|
|
|
1318
1326
|
given position.
|
|
1319
1327
|
*/
|
|
1320
1328
|
static widget(spec) {
|
|
1321
|
-
let side = spec.side || 0, block = !!spec.block;
|
|
1322
|
-
side += block ? (side > 0 ? 300000000 /*
|
|
1329
|
+
let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;
|
|
1330
|
+
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1323
1331
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1324
1332
|
}
|
|
1325
1333
|
/**
|
|
@@ -1329,13 +1337,13 @@ class Decoration extends state.RangeValue {
|
|
|
1329
1337
|
static replace(spec) {
|
|
1330
1338
|
let block = !!spec.block, startSide, endSide;
|
|
1331
1339
|
if (spec.isBlockGap) {
|
|
1332
|
-
startSide = -500000000 /*
|
|
1333
|
-
endSide = 400000000 /*
|
|
1340
|
+
startSide = -500000000 /* GapStart */;
|
|
1341
|
+
endSide = 400000000 /* GapEnd */;
|
|
1334
1342
|
}
|
|
1335
1343
|
else {
|
|
1336
1344
|
let { start, end } = getInclusive(spec, block);
|
|
1337
|
-
startSide = (start ? (block ? -300000000 /*
|
|
1338
|
-
endSide = (end ? (block ? 200000000 /*
|
|
1345
|
+
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1346
|
+
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1339
1347
|
}
|
|
1340
1348
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1341
1349
|
}
|
|
@@ -1366,7 +1374,7 @@ Decoration.none = state.RangeSet.empty;
|
|
|
1366
1374
|
class MarkDecoration extends Decoration {
|
|
1367
1375
|
constructor(spec) {
|
|
1368
1376
|
let { start, end } = getInclusive(spec);
|
|
1369
|
-
super(start ? -1 /*
|
|
1377
|
+
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1370
1378
|
this.tagName = spec.tagName || "span";
|
|
1371
1379
|
this.class = spec.class || "";
|
|
1372
1380
|
this.attrs = spec.attributes || null;
|
|
@@ -1387,7 +1395,7 @@ class MarkDecoration extends Decoration {
|
|
|
1387
1395
|
MarkDecoration.prototype.point = false;
|
|
1388
1396
|
class LineDecoration extends Decoration {
|
|
1389
1397
|
constructor(spec) {
|
|
1390
|
-
super(-200000000 /*
|
|
1398
|
+
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1391
1399
|
}
|
|
1392
1400
|
eq(other) {
|
|
1393
1401
|
return other instanceof LineDecoration &&
|
|
@@ -1414,7 +1422,9 @@ class PointDecoration extends Decoration {
|
|
|
1414
1422
|
return this.startSide < this.endSide ? exports.BlockType.WidgetRange
|
|
1415
1423
|
: this.startSide <= 0 ? exports.BlockType.WidgetBefore : exports.BlockType.WidgetAfter;
|
|
1416
1424
|
}
|
|
1417
|
-
get heightRelevant() {
|
|
1425
|
+
get heightRelevant() {
|
|
1426
|
+
return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
|
|
1427
|
+
}
|
|
1418
1428
|
eq(other) {
|
|
1419
1429
|
return other instanceof PointDecoration &&
|
|
1420
1430
|
widgetsEq(this.widget, other.widget) &&
|
|
@@ -1526,7 +1536,7 @@ class LineView extends ContentView {
|
|
|
1526
1536
|
reuseDOM(node) {
|
|
1527
1537
|
if (node.nodeName == "DIV") {
|
|
1528
1538
|
this.setDOM(node);
|
|
1529
|
-
this.dirty |= 4 /*
|
|
1539
|
+
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1530
1540
|
}
|
|
1531
1541
|
}
|
|
1532
1542
|
sync(view, track) {
|
|
@@ -1536,7 +1546,7 @@ class LineView extends ContentView {
|
|
|
1536
1546
|
this.dom.className = "cm-line";
|
|
1537
1547
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1538
1548
|
}
|
|
1539
|
-
else if (this.dirty & 4 /*
|
|
1549
|
+
else if (this.dirty & 4 /* Attrs */) {
|
|
1540
1550
|
clearAttributes(this.dom);
|
|
1541
1551
|
this.dom.className = "cm-line";
|
|
1542
1552
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1684,7 +1694,7 @@ class ContentBuilder {
|
|
|
1684
1694
|
this.content = [];
|
|
1685
1695
|
this.curLine = null;
|
|
1686
1696
|
this.breakAtStart = 0;
|
|
1687
|
-
this.pendingBuffer = 0 /*
|
|
1697
|
+
this.pendingBuffer = 0 /* No */;
|
|
1688
1698
|
this.bufferMarks = [];
|
|
1689
1699
|
// Set to false directly after a widget that covers the position after it
|
|
1690
1700
|
this.atCursorPos = true;
|
|
@@ -1711,7 +1721,7 @@ class ContentBuilder {
|
|
|
1711
1721
|
flushBuffer(active = this.bufferMarks) {
|
|
1712
1722
|
if (this.pendingBuffer) {
|
|
1713
1723
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1714
|
-
this.pendingBuffer = 0 /*
|
|
1724
|
+
this.pendingBuffer = 0 /* No */;
|
|
1715
1725
|
}
|
|
1716
1726
|
}
|
|
1717
1727
|
addBlockWidget(view) {
|
|
@@ -1723,7 +1733,7 @@ class ContentBuilder {
|
|
|
1723
1733
|
if (this.pendingBuffer && openEnd <= this.bufferMarks.length)
|
|
1724
1734
|
this.flushBuffer();
|
|
1725
1735
|
else
|
|
1726
|
-
this.pendingBuffer = 0 /*
|
|
1736
|
+
this.pendingBuffer = 0 /* No */;
|
|
1727
1737
|
if (!this.posCovered())
|
|
1728
1738
|
this.getLine();
|
|
1729
1739
|
}
|
|
@@ -1752,7 +1762,7 @@ class ContentBuilder {
|
|
|
1752
1762
|
this.textOff = 0;
|
|
1753
1763
|
}
|
|
1754
1764
|
}
|
|
1755
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /*
|
|
1765
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1756
1766
|
this.flushBuffer(active.slice(active.length - openStart));
|
|
1757
1767
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1758
1768
|
this.atCursorPos = true;
|
|
@@ -1788,8 +1798,8 @@ class ContentBuilder {
|
|
|
1788
1798
|
(from < to || deco.startSide > 0);
|
|
1789
1799
|
let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
|
|
1790
1800
|
let line = this.getLine();
|
|
1791
|
-
if (this.pendingBuffer == 2 /*
|
|
1792
|
-
this.pendingBuffer = 0 /*
|
|
1801
|
+
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore && !view.isEditable)
|
|
1802
|
+
this.pendingBuffer = 0 /* No */;
|
|
1793
1803
|
this.flushBuffer(active);
|
|
1794
1804
|
if (cursorBefore) {
|
|
1795
1805
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1797,7 +1807,7 @@ class ContentBuilder {
|
|
|
1797
1807
|
}
|
|
1798
1808
|
line.append(wrapMarks(view, active), openStart);
|
|
1799
1809
|
this.atCursorPos = cursorAfter;
|
|
1800
|
-
this.pendingBuffer = !cursorAfter ? 0 /*
|
|
1810
|
+
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to || openStart > active.length ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1801
1811
|
if (this.pendingBuffer)
|
|
1802
1812
|
this.bufferMarks = active.slice();
|
|
1803
1813
|
}
|
|
@@ -2124,27 +2134,27 @@ class ViewUpdate {
|
|
|
2124
2134
|
update.
|
|
2125
2135
|
*/
|
|
2126
2136
|
get viewportChanged() {
|
|
2127
|
-
return (this.flags & 4 /*
|
|
2137
|
+
return (this.flags & 4 /* Viewport */) > 0;
|
|
2128
2138
|
}
|
|
2129
2139
|
/**
|
|
2130
2140
|
Indicates whether the height of a block element in the editor
|
|
2131
2141
|
changed in this update.
|
|
2132
2142
|
*/
|
|
2133
2143
|
get heightChanged() {
|
|
2134
|
-
return (this.flags & 2 /*
|
|
2144
|
+
return (this.flags & 2 /* Height */) > 0;
|
|
2135
2145
|
}
|
|
2136
2146
|
/**
|
|
2137
2147
|
Returns true when the document was modified or the size of the
|
|
2138
2148
|
editor, or elements within the editor, changed.
|
|
2139
2149
|
*/
|
|
2140
2150
|
get geometryChanged() {
|
|
2141
|
-
return this.docChanged || (this.flags & (8 /*
|
|
2151
|
+
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2142
2152
|
}
|
|
2143
2153
|
/**
|
|
2144
2154
|
True when this update indicates a focus change.
|
|
2145
2155
|
*/
|
|
2146
2156
|
get focusChanged() {
|
|
2147
|
-
return (this.flags & 1 /*
|
|
2157
|
+
return (this.flags & 1 /* Focus */) > 0;
|
|
2148
2158
|
}
|
|
2149
2159
|
/**
|
|
2150
2160
|
Whether the document changed in this update.
|
|
@@ -2203,12 +2213,12 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2203
2213
|
}
|
|
2204
2214
|
function charType(ch) {
|
|
2205
2215
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2206
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /*
|
|
2216
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2207
2217
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2208
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /*
|
|
2209
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /*
|
|
2210
|
-
0xfb50 <= ch && ch <= 0xfdff ? 4 /*
|
|
2211
|
-
ch == 0x200c ? 256 /*
|
|
2218
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2219
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2220
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* AL */ :
|
|
2221
|
+
ch == 0x200c ? 256 /* NI */ : 1 /* L */;
|
|
2212
2222
|
}
|
|
2213
2223
|
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2214
2224
|
/**
|
|
@@ -2216,10 +2226,6 @@ Represents a contiguous range of text that has a single direction
|
|
|
2216
2226
|
(as in left-to-right or right-to-left).
|
|
2217
2227
|
*/
|
|
2218
2228
|
class BidiSpan {
|
|
2219
|
-
/**
|
|
2220
|
-
The direction of this span.
|
|
2221
|
-
*/
|
|
2222
|
-
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2223
2229
|
/**
|
|
2224
2230
|
@internal
|
|
2225
2231
|
*/
|
|
@@ -2245,6 +2251,10 @@ class BidiSpan {
|
|
|
2245
2251
|
this.level = level;
|
|
2246
2252
|
}
|
|
2247
2253
|
/**
|
|
2254
|
+
The direction of this span.
|
|
2255
|
+
*/
|
|
2256
|
+
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2257
|
+
/**
|
|
2248
2258
|
@internal
|
|
2249
2259
|
*/
|
|
2250
2260
|
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
@@ -2273,8 +2283,8 @@ class BidiSpan {
|
|
|
2273
2283
|
// Reused array of character types
|
|
2274
2284
|
const types = [];
|
|
2275
2285
|
function computeOrder(line, direction) {
|
|
2276
|
-
let len = line.length, outerType = direction == LTR ? 1 /*
|
|
2277
|
-
if (!line || outerType == 1 /*
|
|
2286
|
+
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2287
|
+
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2278
2288
|
return trivialOrder(len);
|
|
2279
2289
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2280
2290
|
// change the type of the NSM to the type of the previous
|
|
@@ -2288,12 +2298,12 @@ function computeOrder(line, direction) {
|
|
|
2288
2298
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2289
2299
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2290
2300
|
let type = charType(line.charCodeAt(i));
|
|
2291
|
-
if (type == 512 /*
|
|
2301
|
+
if (type == 512 /* NSM */)
|
|
2292
2302
|
type = prev;
|
|
2293
|
-
else if (type == 8 /*
|
|
2294
|
-
type = 16 /*
|
|
2295
|
-
types[i] = type == 4 /*
|
|
2296
|
-
if (type & 7 /*
|
|
2303
|
+
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2304
|
+
type = 16 /* AN */;
|
|
2305
|
+
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2306
|
+
if (type & 7 /* Strong */)
|
|
2297
2307
|
prevStrong = type;
|
|
2298
2308
|
prev = type;
|
|
2299
2309
|
}
|
|
@@ -2307,26 +2317,26 @@ function computeOrder(line, direction) {
|
|
|
2307
2317
|
// (Left after this: L, R, EN+AN, NI)
|
|
2308
2318
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2309
2319
|
let type = types[i];
|
|
2310
|
-
if (type == 128 /*
|
|
2311
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /*
|
|
2320
|
+
if (type == 128 /* CS */) {
|
|
2321
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2312
2322
|
type = types[i] = prev;
|
|
2313
2323
|
else
|
|
2314
|
-
types[i] = 256 /*
|
|
2324
|
+
types[i] = 256 /* NI */;
|
|
2315
2325
|
}
|
|
2316
|
-
else if (type == 64 /*
|
|
2326
|
+
else if (type == 64 /* ET */) {
|
|
2317
2327
|
let end = i + 1;
|
|
2318
|
-
while (end < len && types[end] == 64 /*
|
|
2328
|
+
while (end < len && types[end] == 64 /* ET */)
|
|
2319
2329
|
end++;
|
|
2320
|
-
let replace = (i && prev == 8 /*
|
|
2330
|
+
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2321
2331
|
for (let j = i; j < end; j++)
|
|
2322
2332
|
types[j] = replace;
|
|
2323
2333
|
i = end - 1;
|
|
2324
2334
|
}
|
|
2325
|
-
else if (type == 8 /*
|
|
2326
|
-
types[i] = 1 /*
|
|
2335
|
+
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2336
|
+
types[i] = 1 /* L */;
|
|
2327
2337
|
}
|
|
2328
2338
|
prev = type;
|
|
2329
|
-
if (type & 7 /*
|
|
2339
|
+
if (type & 7 /* Strong */)
|
|
2330
2340
|
prevStrong = type;
|
|
2331
2341
|
}
|
|
2332
2342
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2341,9 +2351,9 @@ function computeOrder(line, direction) {
|
|
|
2341
2351
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2342
2352
|
if (BracketStack[sJ + 1] == -br) {
|
|
2343
2353
|
let flags = BracketStack[sJ + 2];
|
|
2344
|
-
let type = (flags & 2 /*
|
|
2345
|
-
!(flags & 4 /*
|
|
2346
|
-
(flags & 1 /*
|
|
2354
|
+
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2355
|
+
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2356
|
+
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2347
2357
|
if (type)
|
|
2348
2358
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2349
2359
|
sI = sJ;
|
|
@@ -2351,7 +2361,7 @@ function computeOrder(line, direction) {
|
|
|
2351
2361
|
}
|
|
2352
2362
|
}
|
|
2353
2363
|
}
|
|
2354
|
-
else if (BracketStack.length == 189 /*
|
|
2364
|
+
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2355
2365
|
break;
|
|
2356
2366
|
}
|
|
2357
2367
|
else {
|
|
@@ -2360,20 +2370,20 @@ function computeOrder(line, direction) {
|
|
|
2360
2370
|
BracketStack[sI++] = context;
|
|
2361
2371
|
}
|
|
2362
2372
|
}
|
|
2363
|
-
else if ((type = types[i]) == 2 /*
|
|
2373
|
+
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2364
2374
|
let embed = type == outerType;
|
|
2365
|
-
context = embed ? 0 : 1 /*
|
|
2375
|
+
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2366
2376
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2367
2377
|
let cur = BracketStack[sJ + 2];
|
|
2368
|
-
if (cur & 2 /*
|
|
2378
|
+
if (cur & 2 /* EmbedInside */)
|
|
2369
2379
|
break;
|
|
2370
2380
|
if (embed) {
|
|
2371
|
-
BracketStack[sJ + 2] |= 2 /*
|
|
2381
|
+
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2372
2382
|
}
|
|
2373
2383
|
else {
|
|
2374
|
-
if (cur & 4 /*
|
|
2384
|
+
if (cur & 4 /* OppositeInside */)
|
|
2375
2385
|
break;
|
|
2376
|
-
BracketStack[sJ + 2] |= 4 /*
|
|
2386
|
+
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2377
2387
|
}
|
|
2378
2388
|
}
|
|
2379
2389
|
}
|
|
@@ -2386,13 +2396,13 @@ function computeOrder(line, direction) {
|
|
|
2386
2396
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2387
2397
|
// (Left after this: L, R, EN+AN)
|
|
2388
2398
|
for (let i = 0; i < len; i++) {
|
|
2389
|
-
if (types[i] == 256 /*
|
|
2399
|
+
if (types[i] == 256 /* NI */) {
|
|
2390
2400
|
let end = i + 1;
|
|
2391
|
-
while (end < len && types[end] == 256 /*
|
|
2401
|
+
while (end < len && types[end] == 256 /* NI */)
|
|
2392
2402
|
end++;
|
|
2393
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /*
|
|
2394
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /*
|
|
2395
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /*
|
|
2403
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2404
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2405
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2396
2406
|
for (let j = i; j < end; j++)
|
|
2397
2407
|
types[j] = replace;
|
|
2398
2408
|
i = end - 1;
|
|
@@ -2404,15 +2414,15 @@ function computeOrder(line, direction) {
|
|
|
2404
2414
|
// explicit embedding into account, we can build up the order on
|
|
2405
2415
|
// the fly, without following the level-based algorithm.
|
|
2406
2416
|
let order = [];
|
|
2407
|
-
if (outerType == 1 /*
|
|
2417
|
+
if (outerType == 1 /* L */) {
|
|
2408
2418
|
for (let i = 0; i < len;) {
|
|
2409
|
-
let start = i, rtl = types[i++] != 1 /*
|
|
2410
|
-
while (i < len && rtl == (types[i] != 1 /*
|
|
2419
|
+
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2420
|
+
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2411
2421
|
i++;
|
|
2412
2422
|
if (rtl) {
|
|
2413
2423
|
for (let j = i; j > start;) {
|
|
2414
|
-
let end = j, l = types[--j] != 2 /*
|
|
2415
|
-
while (j > start && l == (types[j - 1] != 2 /*
|
|
2424
|
+
let end = j, l = types[--j] != 2 /* R */;
|
|
2425
|
+
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2416
2426
|
j--;
|
|
2417
2427
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2418
2428
|
}
|
|
@@ -2424,8 +2434,8 @@ function computeOrder(line, direction) {
|
|
|
2424
2434
|
}
|
|
2425
2435
|
else {
|
|
2426
2436
|
for (let i = 0; i < len;) {
|
|
2427
|
-
let start = i, rtl = types[i++] == 2 /*
|
|
2428
|
-
while (i < len && rtl == (types[i] == 2 /*
|
|
2437
|
+
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2438
|
+
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2429
2439
|
i++;
|
|
2430
2440
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2431
2441
|
}
|
|
@@ -2585,7 +2595,6 @@ class DOMPoint {
|
|
|
2585
2595
|
}
|
|
2586
2596
|
|
|
2587
2597
|
class DocView extends ContentView {
|
|
2588
|
-
get length() { return this.view.state.doc.length; }
|
|
2589
2598
|
constructor(view) {
|
|
2590
2599
|
super();
|
|
2591
2600
|
this.view = view;
|
|
@@ -2616,10 +2625,8 @@ class DocView extends ContentView {
|
|
|
2616
2625
|
this.updateDeco();
|
|
2617
2626
|
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
|
|
2618
2627
|
}
|
|
2619
|
-
|
|
2620
|
-
//
|
|
2621
|
-
// position, if we know the editor is going to scroll that position
|
|
2622
|
-
// into view.
|
|
2628
|
+
get length() { return this.view.state.doc.length; }
|
|
2629
|
+
// Update the document view to a given state.
|
|
2623
2630
|
update(update) {
|
|
2624
2631
|
let changedRanges = update.changedRanges;
|
|
2625
2632
|
if (this.minWidth > 0 && changedRanges.length) {
|
|
@@ -2646,7 +2653,7 @@ class DocView extends ContentView {
|
|
|
2646
2653
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2647
2654
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2648
2655
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2649
|
-
if (this.dirty == 0 /*
|
|
2656
|
+
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2650
2657
|
return false;
|
|
2651
2658
|
}
|
|
2652
2659
|
else {
|
|
@@ -2675,7 +2682,7 @@ class DocView extends ContentView {
|
|
|
2675
2682
|
// to detect that situation.
|
|
2676
2683
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2677
2684
|
this.sync(this.view, track);
|
|
2678
|
-
this.dirty = 0 /*
|
|
2685
|
+
this.dirty = 0 /* Not */;
|
|
2679
2686
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2680
2687
|
this.forceSelection = true;
|
|
2681
2688
|
this.dom.style.height = "";
|
|
@@ -2744,10 +2751,10 @@ class DocView extends ContentView {
|
|
|
2744
2751
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2745
2752
|
if (browser.gecko) {
|
|
2746
2753
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2747
|
-
if (nextTo && nextTo != (1 /*
|
|
2748
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /*
|
|
2754
|
+
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2755
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2749
2756
|
if (text)
|
|
2750
|
-
anchor = new DOMPos(text, nextTo == 1 /*
|
|
2757
|
+
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2751
2758
|
}
|
|
2752
2759
|
}
|
|
2753
2760
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -3028,8 +3035,12 @@ function computeCompositionDeco(view, changes) {
|
|
|
3028
3035
|
return Decoration.none;
|
|
3029
3036
|
let { from, to, node, text: textNode } = surrounding;
|
|
3030
3037
|
let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
|
|
3031
|
-
let { state } = view,
|
|
3032
|
-
|
|
3038
|
+
let { state } = view, reader = new DOMReader([], state);
|
|
3039
|
+
if (node.nodeType == 3)
|
|
3040
|
+
reader.readTextNode(node);
|
|
3041
|
+
else
|
|
3042
|
+
reader.readRange(node.firstChild, null);
|
|
3043
|
+
let { text } = reader;
|
|
3033
3044
|
if (text.indexOf(LineBreakPlaceholder) > -1)
|
|
3034
3045
|
return Decoration.none; // Don't try to preserve multi-line compositions
|
|
3035
3046
|
if (newTo - newFrom < text.length) {
|
|
@@ -3093,8 +3104,8 @@ function nearbyTextNode(startNode, startOffset, side) {
|
|
|
3093
3104
|
function nextToUneditable(node, offset) {
|
|
3094
3105
|
if (node.nodeType != 1)
|
|
3095
3106
|
return 0;
|
|
3096
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /*
|
|
3097
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /*
|
|
3107
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
3108
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
3098
3109
|
}
|
|
3099
3110
|
class DecorationComparator$1 {
|
|
3100
3111
|
constructor() {
|
|
@@ -3376,9 +3387,18 @@ function isSuspiciousChromeCaretResult(node, offset, x) {
|
|
|
3376
3387
|
: textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
|
|
3377
3388
|
return x - rect.left > 5;
|
|
3378
3389
|
}
|
|
3390
|
+
function blockAt(view, pos) {
|
|
3391
|
+
let line = view.lineBlockAt(pos);
|
|
3392
|
+
if (Array.isArray(line.type))
|
|
3393
|
+
for (let l of line.type) {
|
|
3394
|
+
if (l.to > pos || l.to == pos && (l.to == line.to || l.type == exports.BlockType.Text))
|
|
3395
|
+
return l;
|
|
3396
|
+
}
|
|
3397
|
+
return line;
|
|
3398
|
+
}
|
|
3379
3399
|
function moveToLineBoundary(view, start, forward, includeWrap) {
|
|
3380
|
-
let line = view
|
|
3381
|
-
let coords = !includeWrap || !view.lineWrapping ? null
|
|
3400
|
+
let line = blockAt(view, start.head);
|
|
3401
|
+
let coords = !includeWrap || line.type != exports.BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
|
|
3382
3402
|
: view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
|
|
3383
3403
|
if (coords) {
|
|
3384
3404
|
let editorRect = view.dom.getBoundingClientRect();
|
|
@@ -3388,9 +3408,7 @@ function moveToLineBoundary(view, start, forward, includeWrap) {
|
|
|
3388
3408
|
if (pos != null)
|
|
3389
3409
|
return state.EditorSelection.cursor(pos, forward ? -1 : 1);
|
|
3390
3410
|
}
|
|
3391
|
-
|
|
3392
|
-
let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
|
|
3393
|
-
return state.EditorSelection.cursor(end, forward ? -1 : 1);
|
|
3411
|
+
return state.EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
|
|
3394
3412
|
}
|
|
3395
3413
|
function moveByChar(view, start, forward, by) {
|
|
3396
3414
|
let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
|
|
@@ -3476,10 +3494,6 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3476
3494
|
|
|
3477
3495
|
// This will also be where dragging info and such goes
|
|
3478
3496
|
class InputState {
|
|
3479
|
-
setSelectionOrigin(origin) {
|
|
3480
|
-
this.lastSelectionOrigin = origin;
|
|
3481
|
-
this.lastSelectionTime = Date.now();
|
|
3482
|
-
}
|
|
3483
3497
|
constructor(view) {
|
|
3484
3498
|
this.lastKeyCode = 0;
|
|
3485
3499
|
this.lastKeyTime = 0;
|
|
@@ -3576,6 +3590,10 @@ class InputState {
|
|
|
3576
3590
|
if (browser.safari)
|
|
3577
3591
|
view.contentDOM.addEventListener("input", () => null);
|
|
3578
3592
|
}
|
|
3593
|
+
setSelectionOrigin(origin) {
|
|
3594
|
+
this.lastSelectionOrigin = origin;
|
|
3595
|
+
this.lastSelectionTime = Date.now();
|
|
3596
|
+
}
|
|
3579
3597
|
ensureHandlers(view, plugins) {
|
|
3580
3598
|
var _a;
|
|
3581
3599
|
let handlers;
|
|
@@ -4379,34 +4397,25 @@ class BlockInfo {
|
|
|
4379
4397
|
*/
|
|
4380
4398
|
height,
|
|
4381
4399
|
/**
|
|
4382
|
-
@internal
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
@internal
|
|
4400
|
+
@internal Weird packed field that holds an array of children
|
|
4401
|
+
for composite blocks, a decoration for block widgets, and a
|
|
4402
|
+
number indicating the amount of widget-create line breaks for
|
|
4403
|
+
text blocks.
|
|
4387
4404
|
*/
|
|
4388
|
-
|
|
4405
|
+
_content) {
|
|
4389
4406
|
this.from = from;
|
|
4390
4407
|
this.length = length;
|
|
4391
4408
|
this.top = top;
|
|
4392
4409
|
this.height = height;
|
|
4393
|
-
this.
|
|
4394
|
-
this.deco = deco;
|
|
4410
|
+
this._content = _content;
|
|
4395
4411
|
}
|
|
4396
4412
|
/**
|
|
4397
4413
|
The type of element this is. When querying lines, this may be
|
|
4398
4414
|
an array of all the blocks that make up the line.
|
|
4399
4415
|
*/
|
|
4400
4416
|
get type() {
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
}
|
|
4404
|
-
/**
|
|
4405
|
-
If this is a widget block, this will return the widget
|
|
4406
|
-
associated with it.
|
|
4407
|
-
*/
|
|
4408
|
-
get widget() {
|
|
4409
|
-
return this.deco && this.deco.widget;
|
|
4417
|
+
return typeof this._content == "number" ? exports.BlockType.Text :
|
|
4418
|
+
Array.isArray(this._content) ? this._content : this._content.type;
|
|
4410
4419
|
}
|
|
4411
4420
|
/**
|
|
4412
4421
|
The end of the element as a document position.
|
|
@@ -4417,11 +4426,26 @@ class BlockInfo {
|
|
|
4417
4426
|
*/
|
|
4418
4427
|
get bottom() { return this.top + this.height; }
|
|
4419
4428
|
/**
|
|
4429
|
+
If this is a widget block, this will return the widget
|
|
4430
|
+
associated with it.
|
|
4431
|
+
*/
|
|
4432
|
+
get widget() {
|
|
4433
|
+
return this._content instanceof PointDecoration ? this._content.widget : null;
|
|
4434
|
+
}
|
|
4435
|
+
/**
|
|
4436
|
+
If this is a textblock, this holds the number of line breaks
|
|
4437
|
+
that appear in widgets inside the block.
|
|
4438
|
+
*/
|
|
4439
|
+
get widgetLineBreaks() {
|
|
4440
|
+
return typeof this._content == "number" ? this._content : 0;
|
|
4441
|
+
}
|
|
4442
|
+
/**
|
|
4420
4443
|
@internal
|
|
4421
4444
|
*/
|
|
4422
4445
|
join(other) {
|
|
4423
|
-
let
|
|
4424
|
-
|
|
4446
|
+
let content = (Array.isArray(this._content) ? this._content : [this])
|
|
4447
|
+
.concat(Array.isArray(other._content) ? other._content : [other]);
|
|
4448
|
+
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
|
|
4425
4449
|
}
|
|
4426
4450
|
}
|
|
4427
4451
|
var QueryType;
|
|
@@ -4434,13 +4458,13 @@ const Epsilon = 1e-3;
|
|
|
4434
4458
|
class HeightMap {
|
|
4435
4459
|
constructor(length, // The number of characters covered
|
|
4436
4460
|
height, // Height of this part of the document
|
|
4437
|
-
flags = 2 /*
|
|
4461
|
+
flags = 2 /* Outdated */) {
|
|
4438
4462
|
this.length = length;
|
|
4439
4463
|
this.height = height;
|
|
4440
4464
|
this.flags = flags;
|
|
4441
4465
|
}
|
|
4442
|
-
get outdated() { return (this.flags & 2 /*
|
|
4443
|
-
set outdated(value) { this.flags = (value ? 2 /*
|
|
4466
|
+
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4467
|
+
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4444
4468
|
setHeight(oracle, height) {
|
|
4445
4469
|
if (this.height != height) {
|
|
4446
4470
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4542,7 +4566,7 @@ class HeightMapBlock extends HeightMap {
|
|
|
4542
4566
|
this.deco = deco;
|
|
4543
4567
|
}
|
|
4544
4568
|
blockAt(_height, _oracle, top, offset) {
|
|
4545
|
-
return new BlockInfo(offset, this.length, top, this.height,
|
|
4569
|
+
return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);
|
|
4546
4570
|
}
|
|
4547
4571
|
lineAt(_value, _type, oracle, top, offset) {
|
|
4548
4572
|
return this.blockAt(0, oracle, top, offset);
|
|
@@ -4564,10 +4588,14 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4564
4588
|
super(length, height, null);
|
|
4565
4589
|
this.collapsed = 0; // Amount of collapsed content in the line
|
|
4566
4590
|
this.widgetHeight = 0; // Maximum inline widget height
|
|
4591
|
+
this.breaks = 0; // Number of widget-introduced line breaks on the line
|
|
4592
|
+
}
|
|
4593
|
+
blockAt(_height, _oracle, top, offset) {
|
|
4594
|
+
return new BlockInfo(offset, this.length, top, this.height, this.breaks);
|
|
4567
4595
|
}
|
|
4568
4596
|
replace(_from, _to, nodes) {
|
|
4569
4597
|
let node = nodes[0];
|
|
4570
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /*
|
|
4598
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4571
4599
|
Math.abs(this.length - node.length) < 10) {
|
|
4572
4600
|
if (node instanceof HeightMapGap)
|
|
4573
4601
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4585,7 +4613,8 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4585
4613
|
if (measured && measured.from <= offset && measured.more)
|
|
4586
4614
|
this.setHeight(oracle, measured.heights[measured.index++]);
|
|
4587
4615
|
else if (force || this.outdated)
|
|
4588
|
-
this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed))
|
|
4616
|
+
this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +
|
|
4617
|
+
this.breaks * oracle.lineHeight);
|
|
4589
4618
|
this.outdated = false;
|
|
4590
4619
|
return this;
|
|
4591
4620
|
}
|
|
@@ -4616,12 +4645,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4616
4645
|
let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);
|
|
4617
4646
|
let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
|
|
4618
4647
|
let lineTop = Math.max(top, height - lineHeight / 2);
|
|
4619
|
-
return new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4648
|
+
return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);
|
|
4620
4649
|
}
|
|
4621
4650
|
else {
|
|
4622
4651
|
let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
|
|
4623
4652
|
let { from, length } = oracle.doc.line(firstLine + line);
|
|
4624
|
-
return new BlockInfo(from, length, top + perLine * line, perLine,
|
|
4653
|
+
return new BlockInfo(from, length, top + perLine * line, perLine, 0);
|
|
4625
4654
|
}
|
|
4626
4655
|
}
|
|
4627
4656
|
lineAt(value, type, oracle, top, offset) {
|
|
@@ -4629,13 +4658,13 @@ class HeightMapGap extends HeightMap {
|
|
|
4629
4658
|
return this.blockAt(value, oracle, top, offset);
|
|
4630
4659
|
if (type == QueryType.ByPosNoHeight) {
|
|
4631
4660
|
let { from, to } = oracle.doc.lineAt(value);
|
|
4632
|
-
return new BlockInfo(from, to - from, 0, 0,
|
|
4661
|
+
return new BlockInfo(from, to - from, 0, 0, 0);
|
|
4633
4662
|
}
|
|
4634
4663
|
let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
|
|
4635
4664
|
let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
|
|
4636
4665
|
let linesAbove = line.number - firstLine;
|
|
4637
4666
|
let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
|
|
4638
|
-
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight,
|
|
4667
|
+
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);
|
|
4639
4668
|
}
|
|
4640
4669
|
forEachLine(from, to, oracle, top, offset, f) {
|
|
4641
4670
|
from = Math.max(from, offset);
|
|
@@ -4648,7 +4677,7 @@ class HeightMapGap extends HeightMap {
|
|
|
4648
4677
|
lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
|
|
4649
4678
|
}
|
|
4650
4679
|
let lineHeight = perLine + perChar * line.length;
|
|
4651
|
-
f(new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4680
|
+
f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));
|
|
4652
4681
|
lineTop += lineHeight;
|
|
4653
4682
|
pos = line.to + 1;
|
|
4654
4683
|
}
|
|
@@ -4719,12 +4748,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4719
4748
|
}
|
|
4720
4749
|
class HeightMapBranch extends HeightMap {
|
|
4721
4750
|
constructor(left, brk, right) {
|
|
4722
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /*
|
|
4751
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4723
4752
|
this.left = left;
|
|
4724
4753
|
this.right = right;
|
|
4725
4754
|
this.size = left.size + right.size;
|
|
4726
4755
|
}
|
|
4727
|
-
get break() { return this.flags & 1 /*
|
|
4756
|
+
get break() { return this.flags & 1 /* Break */; }
|
|
4728
4757
|
blockAt(height, oracle, top, offset) {
|
|
4729
4758
|
let mid = top + this.left.height;
|
|
4730
4759
|
return height < mid ? this.left.blockAt(height, oracle, top, offset)
|
|
@@ -4874,14 +4903,15 @@ class NodeBuilder {
|
|
|
4874
4903
|
point(from, to, deco) {
|
|
4875
4904
|
if (from < to || deco.heightRelevant) {
|
|
4876
4905
|
let height = deco.widget ? deco.widget.estimatedHeight : 0;
|
|
4906
|
+
let breaks = deco.widget ? deco.widget.lineBreaks : 0;
|
|
4877
4907
|
if (height < 0)
|
|
4878
4908
|
height = this.oracle.lineHeight;
|
|
4879
4909
|
let len = to - from;
|
|
4880
4910
|
if (deco.block) {
|
|
4881
4911
|
this.addBlock(new HeightMapBlock(len, height, deco));
|
|
4882
4912
|
}
|
|
4883
|
-
else if (len || height >= relevantWidgetHeight) {
|
|
4884
|
-
this.addLineDeco(height, len);
|
|
4913
|
+
else if (len || breaks || height >= relevantWidgetHeight) {
|
|
4914
|
+
this.addLineDeco(height, breaks, len);
|
|
4885
4915
|
}
|
|
4886
4916
|
}
|
|
4887
4917
|
else if (to > from) {
|
|
@@ -4908,7 +4938,7 @@ class NodeBuilder {
|
|
|
4908
4938
|
blankContent(from, to) {
|
|
4909
4939
|
let gap = new HeightMapGap(to - from);
|
|
4910
4940
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4911
|
-
gap.flags |= 4 /*
|
|
4941
|
+
gap.flags |= 4 /* SingleLine */;
|
|
4912
4942
|
return gap;
|
|
4913
4943
|
}
|
|
4914
4944
|
ensureLine() {
|
|
@@ -4931,11 +4961,12 @@ class NodeBuilder {
|
|
|
4931
4961
|
if (type != exports.BlockType.WidgetBefore)
|
|
4932
4962
|
this.covering = block;
|
|
4933
4963
|
}
|
|
4934
|
-
addLineDeco(height, length) {
|
|
4964
|
+
addLineDeco(height, breaks, length) {
|
|
4935
4965
|
let line = this.ensureLine();
|
|
4936
4966
|
line.length += length;
|
|
4937
4967
|
line.collapsed += length;
|
|
4938
4968
|
line.widgetHeight = Math.max(line.widgetHeight, height);
|
|
4969
|
+
line.breaks += breaks;
|
|
4939
4970
|
this.writtenTo = this.pos = this.pos + length;
|
|
4940
4971
|
}
|
|
4941
4972
|
finish(from) {
|
|
@@ -5069,6 +5100,14 @@ class ViewState {
|
|
|
5069
5100
|
this.contentDOMHeight = 0;
|
|
5070
5101
|
this.editorHeight = 0;
|
|
5071
5102
|
this.editorWidth = 0;
|
|
5103
|
+
this.scrollTop = 0;
|
|
5104
|
+
this.scrolledToBottom = true;
|
|
5105
|
+
// The vertical position (document-relative) to which to anchor the
|
|
5106
|
+
// scroll position. -1 means anchor to the end of the document.
|
|
5107
|
+
this.scrollAnchorPos = 0;
|
|
5108
|
+
// The height at the anchor position. Set by the DOM update phase.
|
|
5109
|
+
// -1 means no height available.
|
|
5110
|
+
this.scrollAnchorHeight = -1;
|
|
5072
5111
|
// See VP.MaxDOMHeight
|
|
5073
5112
|
this.scaler = IdScaler;
|
|
5074
5113
|
this.scrollTarget = null;
|
|
@@ -5109,7 +5148,7 @@ class ViewState {
|
|
|
5109
5148
|
}
|
|
5110
5149
|
}
|
|
5111
5150
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
5112
|
-
this.scaler = this.heightMap.height <= 7000000 /*
|
|
5151
|
+
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
5113
5152
|
new BigScaler(this.heightOracle, this.heightMap, this.viewports);
|
|
5114
5153
|
}
|
|
5115
5154
|
updateViewportLines() {
|
|
@@ -5125,20 +5164,29 @@ class ViewState {
|
|
|
5125
5164
|
let contentChanges = update.changedRanges;
|
|
5126
5165
|
let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : state.ChangeSet.empty(this.state.doc.length)));
|
|
5127
5166
|
let prevHeight = this.heightMap.height;
|
|
5167
|
+
let scrollAnchor = this.scrolledToBottom ? null : this.lineBlockAtHeight(this.scrollTop);
|
|
5128
5168
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
5129
5169
|
if (this.heightMap.height != prevHeight)
|
|
5130
|
-
update.flags |= 2 /*
|
|
5170
|
+
update.flags |= 2 /* Height */;
|
|
5171
|
+
if (scrollAnchor) {
|
|
5172
|
+
this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);
|
|
5173
|
+
this.scrollAnchorHeight = scrollAnchor.top;
|
|
5174
|
+
}
|
|
5175
|
+
else {
|
|
5176
|
+
this.scrollAnchorPos = -1;
|
|
5177
|
+
this.scrollAnchorHeight = this.heightMap.height;
|
|
5178
|
+
}
|
|
5131
5179
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
5132
5180
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
5133
5181
|
!this.viewportIsAppropriate(viewport))
|
|
5134
5182
|
viewport = this.getViewport(0, scrollTarget);
|
|
5135
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /*
|
|
5183
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
5136
5184
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
5137
5185
|
this.viewport = viewport;
|
|
5138
5186
|
this.updateForViewport();
|
|
5139
5187
|
if (updateLines)
|
|
5140
5188
|
this.updateViewportLines();
|
|
5141
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /*
|
|
5189
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* Margin */ << 1))
|
|
5142
5190
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
5143
5191
|
update.flags |= this.computeVisibleRanges();
|
|
5144
5192
|
if (scrollTarget)
|
|
@@ -5164,14 +5212,19 @@ class ViewState {
|
|
|
5164
5212
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
5165
5213
|
this.paddingTop = paddingTop;
|
|
5166
5214
|
this.paddingBottom = paddingBottom;
|
|
5167
|
-
result |= 8 /*
|
|
5215
|
+
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
5168
5216
|
}
|
|
5169
5217
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
5170
5218
|
if (oracle.lineWrapping)
|
|
5171
5219
|
measureContent = true;
|
|
5172
5220
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
5173
|
-
result |= 8 /*
|
|
5221
|
+
result |= 8 /* Geometry */;
|
|
5174
5222
|
}
|
|
5223
|
+
if (this.scrollTop != view.scrollDOM.scrollTop) {
|
|
5224
|
+
this.scrollAnchorHeight = -1;
|
|
5225
|
+
this.scrollTop = view.scrollDOM.scrollTop;
|
|
5226
|
+
}
|
|
5227
|
+
this.scrolledToBottom = this.scrollTop > view.scrollDOM.scrollHeight - view.scrollDOM.clientHeight - 4;
|
|
5175
5228
|
// Pixel viewport
|
|
5176
5229
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
5177
5230
|
let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
|
|
@@ -5188,7 +5241,7 @@ class ViewState {
|
|
|
5188
5241
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
5189
5242
|
this.contentDOMWidth = domRect.width;
|
|
5190
5243
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
5191
|
-
result |= 8 /*
|
|
5244
|
+
result |= 8 /* Geometry */;
|
|
5192
5245
|
}
|
|
5193
5246
|
if (measureContent) {
|
|
5194
5247
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -5199,7 +5252,7 @@ class ViewState {
|
|
|
5199
5252
|
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
|
|
5200
5253
|
if (refresh) {
|
|
5201
5254
|
view.docView.minWidth = 0;
|
|
5202
|
-
result |= 8 /*
|
|
5255
|
+
result |= 8 /* Geometry */;
|
|
5203
5256
|
}
|
|
5204
5257
|
}
|
|
5205
5258
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -5212,7 +5265,7 @@ class ViewState {
|
|
|
5212
5265
|
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, state.Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
5213
5266
|
}
|
|
5214
5267
|
if (oracle.heightChanged)
|
|
5215
|
-
result |= 2 /*
|
|
5268
|
+
result |= 2 /* Height */;
|
|
5216
5269
|
}
|
|
5217
5270
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
5218
5271
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||
|
|
@@ -5220,9 +5273,9 @@ class ViewState {
|
|
|
5220
5273
|
if (viewportChange)
|
|
5221
5274
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
5222
5275
|
this.updateForViewport();
|
|
5223
|
-
if ((result & 2 /*
|
|
5276
|
+
if ((result & 2 /* Height */) || viewportChange)
|
|
5224
5277
|
this.updateViewportLines();
|
|
5225
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /*
|
|
5278
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* Margin */ << 1))
|
|
5226
5279
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));
|
|
5227
5280
|
result |= this.computeVisibleRanges();
|
|
5228
5281
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -5241,10 +5294,10 @@ class ViewState {
|
|
|
5241
5294
|
// This will divide VP.Margin between the top and the
|
|
5242
5295
|
// bottom, depending on the bias (the change in viewport position
|
|
5243
5296
|
// since the last update). It'll hold a number between 0 and 1
|
|
5244
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /*
|
|
5297
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
5245
5298
|
let map = this.heightMap, oracle = this.heightOracle;
|
|
5246
5299
|
let { visibleTop, visibleBottom } = this;
|
|
5247
|
-
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /*
|
|
5300
|
+
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType.ByHeight, oracle, 0, 0).to);
|
|
5248
5301
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
5249
5302
|
if (scrollTarget) {
|
|
5250
5303
|
let { head } = scrollTarget.range;
|
|
@@ -5257,7 +5310,7 @@ class ViewState {
|
|
|
5257
5310
|
topPos = block.top;
|
|
5258
5311
|
else
|
|
5259
5312
|
topPos = block.bottom - viewHeight;
|
|
5260
|
-
viewport = new Viewport(map.lineAt(topPos - 1000 /*
|
|
5313
|
+
viewport = new Viewport(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).to);
|
|
5261
5314
|
}
|
|
5262
5315
|
}
|
|
5263
5316
|
return viewport;
|
|
@@ -5274,10 +5327,10 @@ class ViewState {
|
|
|
5274
5327
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
5275
5328
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
5276
5329
|
let { visibleTop, visibleBottom } = this;
|
|
5277
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /*
|
|
5330
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
5278
5331
|
(to == this.state.doc.length ||
|
|
5279
|
-
bottom >= visibleBottom + Math.max(10 /*
|
|
5280
|
-
(top > visibleTop - 2 * 1000 /*
|
|
5332
|
+
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
5333
|
+
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
5281
5334
|
}
|
|
5282
5335
|
mapLineGaps(gaps, changes) {
|
|
5283
5336
|
if (!gaps.length || changes.empty)
|
|
@@ -5297,7 +5350,7 @@ class ViewState {
|
|
|
5297
5350
|
// the artifacts this might produce from the user.
|
|
5298
5351
|
ensureLineGaps(current, mayMeasure) {
|
|
5299
5352
|
let wrapping = this.heightOracle.lineWrapping;
|
|
5300
|
-
let margin = wrapping ? 10000 /*
|
|
5353
|
+
let margin = wrapping ? 10000 /* MarginWrap */ : 2000 /* Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;
|
|
5301
5354
|
// The non-wrapping logic won't work at all in predominantly right-to-left text.
|
|
5302
5355
|
if (this.defaultTextDirection != exports.Direction.LTR && !wrapping)
|
|
5303
5356
|
return [];
|
|
@@ -5310,8 +5363,8 @@ class ViewState {
|
|
|
5310
5363
|
avoid.push(sel.to);
|
|
5311
5364
|
for (let pos of avoid) {
|
|
5312
5365
|
if (pos > from && pos < to) {
|
|
5313
|
-
addGap(from, pos - 10 /*
|
|
5314
|
-
addGap(pos + 10 /*
|
|
5366
|
+
addGap(from, pos - 10 /* SelectionMargin */, line, structure);
|
|
5367
|
+
addGap(pos + 10 /* SelectionMargin */, to, line, structure);
|
|
5315
5368
|
return;
|
|
5316
5369
|
}
|
|
5317
5370
|
}
|
|
@@ -5405,7 +5458,7 @@ class ViewState {
|
|
|
5405
5458
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5406
5459
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5407
5460
|
this.visibleRanges = ranges;
|
|
5408
|
-
return changed ? 4 /*
|
|
5461
|
+
return changed ? 4 /* Viewport */ : 0;
|
|
5409
5462
|
}
|
|
5410
5463
|
lineBlockAt(pos) {
|
|
5411
5464
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5497,7 +5550,7 @@ class BigScaler {
|
|
|
5497
5550
|
vpHeight += bottom - top;
|
|
5498
5551
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5499
5552
|
});
|
|
5500
|
-
this.scale = (7000000 /*
|
|
5553
|
+
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5501
5554
|
for (let obj of this.viewports) {
|
|
5502
5555
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5503
5556
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5531,7 +5584,7 @@ function scaleBlock(block, scaler) {
|
|
|
5531
5584
|
if (scaler.scale == 1)
|
|
5532
5585
|
return block;
|
|
5533
5586
|
let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
|
|
5534
|
-
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, block.
|
|
5587
|
+
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);
|
|
5535
5588
|
}
|
|
5536
5589
|
|
|
5537
5590
|
const theme = state.Facet.define({ combine: strs => strs.join(" ") });
|
|
@@ -6391,7 +6444,7 @@ class DOMObserver {
|
|
|
6391
6444
|
return null;
|
|
6392
6445
|
cView.markDirty(rec.type == "attributes");
|
|
6393
6446
|
if (rec.type == "attributes")
|
|
6394
|
-
cView.dirty |= 4 /*
|
|
6447
|
+
cView.dirty |= 4 /* Attrs */;
|
|
6395
6448
|
if (rec.type == "childList") {
|
|
6396
6449
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
6397
6450
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -6499,53 +6552,6 @@ line number gutter. It handles events and dispatches state
|
|
|
6499
6552
|
transactions for editing actions.
|
|
6500
6553
|
*/
|
|
6501
6554
|
class EditorView {
|
|
6502
|
-
/**
|
|
6503
|
-
The current editor state.
|
|
6504
|
-
*/
|
|
6505
|
-
get state() { return this.viewState.state; }
|
|
6506
|
-
/**
|
|
6507
|
-
To be able to display large documents without consuming too much
|
|
6508
|
-
memory or overloading the browser, CodeMirror only draws the
|
|
6509
|
-
code that is visible (plus a margin around it) to the DOM. This
|
|
6510
|
-
property tells you the extent of the current drawn viewport, in
|
|
6511
|
-
document positions.
|
|
6512
|
-
*/
|
|
6513
|
-
get viewport() { return this.viewState.viewport; }
|
|
6514
|
-
/**
|
|
6515
|
-
When there are, for example, large collapsed ranges in the
|
|
6516
|
-
viewport, its size can be a lot bigger than the actual visible
|
|
6517
|
-
content. Thus, if you are doing something like styling the
|
|
6518
|
-
content in the viewport, it is preferable to only do so for
|
|
6519
|
-
these ranges, which are the subset of the viewport that is
|
|
6520
|
-
actually drawn.
|
|
6521
|
-
*/
|
|
6522
|
-
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6523
|
-
/**
|
|
6524
|
-
Returns false when the editor is entirely scrolled out of view
|
|
6525
|
-
or otherwise hidden.
|
|
6526
|
-
*/
|
|
6527
|
-
get inView() { return this.viewState.inView; }
|
|
6528
|
-
/**
|
|
6529
|
-
Indicates whether the user is currently composing text via
|
|
6530
|
-
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6531
|
-
one change has been made in the current composition.
|
|
6532
|
-
*/
|
|
6533
|
-
get composing() { return this.inputState.composing > 0; }
|
|
6534
|
-
/**
|
|
6535
|
-
Indicates whether the user is currently in composing state. Note
|
|
6536
|
-
that on some platforms, like Android, this will be the case a
|
|
6537
|
-
lot, since just putting the cursor on a word starts a
|
|
6538
|
-
composition there.
|
|
6539
|
-
*/
|
|
6540
|
-
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6541
|
-
/**
|
|
6542
|
-
The document or shadow root that the view lives in.
|
|
6543
|
-
*/
|
|
6544
|
-
get root() { return this._root; }
|
|
6545
|
-
/**
|
|
6546
|
-
@internal
|
|
6547
|
-
*/
|
|
6548
|
-
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6549
6555
|
/**
|
|
6550
6556
|
Construct a new view. You'll want to either provide a `parent`
|
|
6551
6557
|
option, or put `view.dom` into your document after creating a
|
|
@@ -6561,7 +6567,7 @@ class EditorView {
|
|
|
6561
6567
|
/**
|
|
6562
6568
|
@internal
|
|
6563
6569
|
*/
|
|
6564
|
-
this.updateState = 2 /*
|
|
6570
|
+
this.updateState = 2 /* Updating */;
|
|
6565
6571
|
/**
|
|
6566
6572
|
@internal
|
|
6567
6573
|
*/
|
|
@@ -6594,11 +6600,58 @@ class EditorView {
|
|
|
6594
6600
|
this.docView = new DocView(this);
|
|
6595
6601
|
this.mountStyles();
|
|
6596
6602
|
this.updateAttrs();
|
|
6597
|
-
this.updateState = 0 /*
|
|
6603
|
+
this.updateState = 0 /* Idle */;
|
|
6598
6604
|
this.requestMeasure();
|
|
6599
6605
|
if (config.parent)
|
|
6600
6606
|
config.parent.appendChild(this.dom);
|
|
6601
6607
|
}
|
|
6608
|
+
/**
|
|
6609
|
+
The current editor state.
|
|
6610
|
+
*/
|
|
6611
|
+
get state() { return this.viewState.state; }
|
|
6612
|
+
/**
|
|
6613
|
+
To be able to display large documents without consuming too much
|
|
6614
|
+
memory or overloading the browser, CodeMirror only draws the
|
|
6615
|
+
code that is visible (plus a margin around it) to the DOM. This
|
|
6616
|
+
property tells you the extent of the current drawn viewport, in
|
|
6617
|
+
document positions.
|
|
6618
|
+
*/
|
|
6619
|
+
get viewport() { return this.viewState.viewport; }
|
|
6620
|
+
/**
|
|
6621
|
+
When there are, for example, large collapsed ranges in the
|
|
6622
|
+
viewport, its size can be a lot bigger than the actual visible
|
|
6623
|
+
content. Thus, if you are doing something like styling the
|
|
6624
|
+
content in the viewport, it is preferable to only do so for
|
|
6625
|
+
these ranges, which are the subset of the viewport that is
|
|
6626
|
+
actually drawn.
|
|
6627
|
+
*/
|
|
6628
|
+
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6629
|
+
/**
|
|
6630
|
+
Returns false when the editor is entirely scrolled out of view
|
|
6631
|
+
or otherwise hidden.
|
|
6632
|
+
*/
|
|
6633
|
+
get inView() { return this.viewState.inView; }
|
|
6634
|
+
/**
|
|
6635
|
+
Indicates whether the user is currently composing text via
|
|
6636
|
+
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6637
|
+
one change has been made in the current composition.
|
|
6638
|
+
*/
|
|
6639
|
+
get composing() { return this.inputState.composing > 0; }
|
|
6640
|
+
/**
|
|
6641
|
+
Indicates whether the user is currently in composing state. Note
|
|
6642
|
+
that on some platforms, like Android, this will be the case a
|
|
6643
|
+
lot, since just putting the cursor on a word starts a
|
|
6644
|
+
composition there.
|
|
6645
|
+
*/
|
|
6646
|
+
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6647
|
+
/**
|
|
6648
|
+
The document or shadow root that the view lives in.
|
|
6649
|
+
*/
|
|
6650
|
+
get root() { return this._root; }
|
|
6651
|
+
/**
|
|
6652
|
+
@internal
|
|
6653
|
+
*/
|
|
6654
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6602
6655
|
dispatch(...input) {
|
|
6603
6656
|
let tr = input.length == 1 && input[0] instanceof state.Transaction ? input[0]
|
|
6604
6657
|
: this.state.update(...input);
|
|
@@ -6613,7 +6666,7 @@ class EditorView {
|
|
|
6613
6666
|
as a primitive.
|
|
6614
6667
|
*/
|
|
6615
6668
|
update(transactions) {
|
|
6616
|
-
if (this.updateState != 0 /*
|
|
6669
|
+
if (this.updateState != 0 /* Idle */)
|
|
6617
6670
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6618
6671
|
let redrawn = false, attrsChanged = false, update;
|
|
6619
6672
|
let state$1 = this.state;
|
|
@@ -6630,7 +6683,7 @@ class EditorView {
|
|
|
6630
6683
|
if (transactions.some(tr => tr.annotation(isFocusChange))) {
|
|
6631
6684
|
this.inputState.notifiedFocused = focus;
|
|
6632
6685
|
// If a focus-change transaction is being dispatched, set this update flag.
|
|
6633
|
-
focusFlag = 1 /*
|
|
6686
|
+
focusFlag = 1 /* Focus */;
|
|
6634
6687
|
}
|
|
6635
6688
|
else if (focus != this.inputState.notifiedFocused) {
|
|
6636
6689
|
this.inputState.notifiedFocused = focus;
|
|
@@ -6638,7 +6691,7 @@ class EditorView {
|
|
|
6638
6691
|
// add a flag to this update
|
|
6639
6692
|
dispatchFocus = focusChangeTransaction(state$1, focus);
|
|
6640
6693
|
if (!dispatchFocus)
|
|
6641
|
-
focusFlag = 1 /*
|
|
6694
|
+
focusFlag = 1 /* Focus */;
|
|
6642
6695
|
}
|
|
6643
6696
|
// If there was a pending DOM change, eagerly read it and try to
|
|
6644
6697
|
// apply it after the given transactions.
|
|
@@ -6661,7 +6714,7 @@ class EditorView {
|
|
|
6661
6714
|
update.flags |= focusFlag;
|
|
6662
6715
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6663
6716
|
try {
|
|
6664
|
-
this.updateState = 2 /*
|
|
6717
|
+
this.updateState = 2 /* Updating */;
|
|
6665
6718
|
for (let tr of transactions) {
|
|
6666
6719
|
if (scrollTarget)
|
|
6667
6720
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6687,7 +6740,7 @@ class EditorView {
|
|
|
6687
6740
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6688
6741
|
}
|
|
6689
6742
|
finally {
|
|
6690
|
-
this.updateState = 0 /*
|
|
6743
|
+
this.updateState = 0 /* Idle */;
|
|
6691
6744
|
}
|
|
6692
6745
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6693
6746
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6714,13 +6767,13 @@ class EditorView {
|
|
|
6714
6767
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6715
6768
|
*/
|
|
6716
6769
|
setState(newState) {
|
|
6717
|
-
if (this.updateState != 0 /*
|
|
6770
|
+
if (this.updateState != 0 /* Idle */)
|
|
6718
6771
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6719
6772
|
if (this.destroyed) {
|
|
6720
6773
|
this.viewState.state = newState;
|
|
6721
6774
|
return;
|
|
6722
6775
|
}
|
|
6723
|
-
this.updateState = 2 /*
|
|
6776
|
+
this.updateState = 2 /* Updating */;
|
|
6724
6777
|
let hadFocus = this.hasFocus;
|
|
6725
6778
|
try {
|
|
6726
6779
|
for (let plugin of this.plugins)
|
|
@@ -6737,7 +6790,7 @@ class EditorView {
|
|
|
6737
6790
|
this.bidiCache = [];
|
|
6738
6791
|
}
|
|
6739
6792
|
finally {
|
|
6740
|
-
this.updateState = 0 /*
|
|
6793
|
+
this.updateState = 0 /* Idle */;
|
|
6741
6794
|
}
|
|
6742
6795
|
if (hadFocus)
|
|
6743
6796
|
this.focus();
|
|
@@ -6784,13 +6837,23 @@ class EditorView {
|
|
|
6784
6837
|
if (flush)
|
|
6785
6838
|
this.observer.forceFlush();
|
|
6786
6839
|
let updated = null;
|
|
6787
|
-
let
|
|
6788
|
-
|
|
6840
|
+
let sDOM = this.scrollDOM, { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
|
|
6841
|
+
this.viewState.scrollAnchorHeight = -1;
|
|
6842
|
+
if (scrollAnchorHeight < 0 || sDOM.scrollTop != this.viewState.scrollTop) {
|
|
6843
|
+
if (sDOM.scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
|
|
6844
|
+
scrollAnchorPos = -1;
|
|
6845
|
+
scrollAnchorHeight = this.viewState.heightMap.height;
|
|
6846
|
+
}
|
|
6847
|
+
else {
|
|
6848
|
+
let block = this.viewState.lineBlockAtHeight(sDOM.scrollTop);
|
|
6849
|
+
scrollAnchorPos = block.from;
|
|
6850
|
+
scrollAnchorHeight = block.top;
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6789
6853
|
try {
|
|
6790
6854
|
for (let i = 0;; i++) {
|
|
6791
|
-
this.updateState = 1 /*
|
|
6855
|
+
this.updateState = 1 /* Measuring */;
|
|
6792
6856
|
let oldViewport = this.viewport;
|
|
6793
|
-
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6794
6857
|
let changed = this.viewState.measure(this);
|
|
6795
6858
|
if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
|
|
6796
6859
|
break;
|
|
@@ -6802,7 +6865,7 @@ class EditorView {
|
|
|
6802
6865
|
}
|
|
6803
6866
|
let measuring = [];
|
|
6804
6867
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6805
|
-
if (!(changed & 4 /*
|
|
6868
|
+
if (!(changed & 4 /* Viewport */))
|
|
6806
6869
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6807
6870
|
let measured = measuring.map(m => {
|
|
6808
6871
|
try {
|
|
@@ -6819,7 +6882,7 @@ class EditorView {
|
|
|
6819
6882
|
updated = update;
|
|
6820
6883
|
else
|
|
6821
6884
|
updated.flags |= changed;
|
|
6822
|
-
this.updateState = 2 /*
|
|
6885
|
+
this.updateState = 2 /* Updating */;
|
|
6823
6886
|
if (!update.empty) {
|
|
6824
6887
|
this.updatePlugins(update);
|
|
6825
6888
|
this.inputState.update(update);
|
|
@@ -6843,10 +6906,12 @@ class EditorView {
|
|
|
6843
6906
|
this.viewState.scrollTarget = null;
|
|
6844
6907
|
scrolled = true;
|
|
6845
6908
|
}
|
|
6846
|
-
else {
|
|
6847
|
-
let
|
|
6909
|
+
else if (scrollAnchorHeight > -1) {
|
|
6910
|
+
let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :
|
|
6911
|
+
this.viewState.lineBlockAt(scrollAnchorPos).top;
|
|
6912
|
+
let diff = newAnchorHeight - scrollAnchorHeight;
|
|
6848
6913
|
if (diff > 1 || diff < -1) {
|
|
6849
|
-
|
|
6914
|
+
sDOM.scrollTop += diff;
|
|
6850
6915
|
scrolled = true;
|
|
6851
6916
|
}
|
|
6852
6917
|
}
|
|
@@ -6856,10 +6921,11 @@ class EditorView {
|
|
|
6856
6921
|
if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
|
|
6857
6922
|
!scrolled && this.measureRequests.length == 0)
|
|
6858
6923
|
break;
|
|
6924
|
+
scrollAnchorHeight = -1;
|
|
6859
6925
|
}
|
|
6860
6926
|
}
|
|
6861
6927
|
finally {
|
|
6862
|
-
this.updateState = 0 /*
|
|
6928
|
+
this.updateState = 0 /* Idle */;
|
|
6863
6929
|
this.measureScheduled = -1;
|
|
6864
6930
|
}
|
|
6865
6931
|
if (updated && !updated.empty)
|
|
@@ -6918,9 +6984,9 @@ class EditorView {
|
|
|
6918
6984
|
styleMod.StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6919
6985
|
}
|
|
6920
6986
|
readMeasured() {
|
|
6921
|
-
if (this.updateState == 2 /*
|
|
6987
|
+
if (this.updateState == 2 /* Updating */)
|
|
6922
6988
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6923
|
-
if (this.updateState == 0 /*
|
|
6989
|
+
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6924
6990
|
this.measure(false);
|
|
6925
6991
|
}
|
|
6926
6992
|
/**
|
|
@@ -7714,15 +7780,6 @@ function wrappedLine(view, pos, inside) {
|
|
|
7714
7780
|
to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
|
|
7715
7781
|
type: exports.BlockType.Text };
|
|
7716
7782
|
}
|
|
7717
|
-
function blockAt(view, pos) {
|
|
7718
|
-
let line = view.lineBlockAt(pos);
|
|
7719
|
-
if (Array.isArray(line.type))
|
|
7720
|
-
for (let l of line.type) {
|
|
7721
|
-
if (l.to > pos || l.to == pos && (l.to == line.to || l.type == exports.BlockType.Text))
|
|
7722
|
-
return l;
|
|
7723
|
-
}
|
|
7724
|
-
return line;
|
|
7725
|
-
}
|
|
7726
7783
|
function rectanglesForRange(view, className, range) {
|
|
7727
7784
|
if (range.to <= view.viewport.from || range.from >= view.viewport.to)
|
|
7728
7785
|
return [];
|
|
@@ -7736,12 +7793,10 @@ function rectanglesForRange(view, className, range) {
|
|
|
7736
7793
|
let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
|
|
7737
7794
|
let visualStart = startBlock.type == exports.BlockType.Text ? startBlock : null;
|
|
7738
7795
|
let visualEnd = endBlock.type == exports.BlockType.Text ? endBlock : null;
|
|
7739
|
-
if (view.lineWrapping)
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
visualEnd = wrappedLine(view, to, visualEnd);
|
|
7744
|
-
}
|
|
7796
|
+
if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
|
|
7797
|
+
visualStart = wrappedLine(view, from, visualStart);
|
|
7798
|
+
if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
|
|
7799
|
+
visualEnd = wrappedLine(view, to, visualEnd);
|
|
7745
7800
|
if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
|
|
7746
7801
|
return pieces(drawForLine(range.from, range.to, visualStart));
|
|
7747
7802
|
}
|
|
@@ -7749,14 +7804,15 @@ function rectanglesForRange(view, className, range) {
|
|
|
7749
7804
|
let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
|
|
7750
7805
|
let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
|
|
7751
7806
|
let between = [];
|
|
7752
|
-
if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0)
|
|
7807
|
+
if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||
|
|
7808
|
+
startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)
|
|
7753
7809
|
between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
|
|
7754
7810
|
else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == exports.BlockType.Text)
|
|
7755
7811
|
top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
|
|
7756
7812
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7757
7813
|
}
|
|
7758
7814
|
function piece(left, top, right, bottom) {
|
|
7759
|
-
return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /*
|
|
7815
|
+
return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */);
|
|
7760
7816
|
}
|
|
7761
7817
|
function pieces({ top, bottom, horizontal }) {
|
|
7762
7818
|
let pieces = [];
|
|
@@ -8771,12 +8827,12 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8771
8827
|
continue;
|
|
8772
8828
|
}
|
|
8773
8829
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8774
|
-
let arrowHeight = arrow ? 7 /*
|
|
8830
|
+
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8775
8831
|
let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
|
|
8776
8832
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == exports.Direction.LTR;
|
|
8777
8833
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8778
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /*
|
|
8779
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /*
|
|
8834
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8835
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8780
8836
|
let above = !!tooltip.above;
|
|
8781
8837
|
if (!tooltip.strictSide && (above
|
|
8782
8838
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8810,7 +8866,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
8810
8866
|
dom.style.left = left + "px";
|
|
8811
8867
|
}
|
|
8812
8868
|
if (arrow)
|
|
8813
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /*
|
|
8869
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8814
8870
|
if (tView.overlap !== true)
|
|
8815
8871
|
others.push({ left, top, right, bottom: top + height });
|
|
8816
8872
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8853,8 +8909,8 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8853
8909
|
color: "white"
|
|
8854
8910
|
},
|
|
8855
8911
|
".cm-tooltip-arrow": {
|
|
8856
|
-
height: `${7 /*
|
|
8857
|
-
width: `${7 /*
|
|
8912
|
+
height: `${7 /* Size */}px`,
|
|
8913
|
+
width: `${7 /* Size */ * 2}px`,
|
|
8858
8914
|
position: "absolute",
|
|
8859
8915
|
zIndex: -1,
|
|
8860
8916
|
overflow: "hidden",
|
|
@@ -8863,26 +8919,26 @@ const baseTheme = EditorView.baseTheme({
|
|
|
8863
8919
|
position: "absolute",
|
|
8864
8920
|
width: 0,
|
|
8865
8921
|
height: 0,
|
|
8866
|
-
borderLeft: `${7 /*
|
|
8867
|
-
borderRight: `${7 /*
|
|
8922
|
+
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8923
|
+
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8868
8924
|
},
|
|
8869
8925
|
".cm-tooltip-above &": {
|
|
8870
|
-
bottom: `-${7 /*
|
|
8926
|
+
bottom: `-${7 /* Size */}px`,
|
|
8871
8927
|
"&:before": {
|
|
8872
|
-
borderTop: `${7 /*
|
|
8928
|
+
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8873
8929
|
},
|
|
8874
8930
|
"&:after": {
|
|
8875
|
-
borderTop: `${7 /*
|
|
8931
|
+
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8876
8932
|
bottom: "1px"
|
|
8877
8933
|
}
|
|
8878
8934
|
},
|
|
8879
8935
|
".cm-tooltip-below &": {
|
|
8880
|
-
top: `-${7 /*
|
|
8936
|
+
top: `-${7 /* Size */}px`,
|
|
8881
8937
|
"&:before": {
|
|
8882
|
-
borderBottom: `${7 /*
|
|
8938
|
+
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8883
8939
|
},
|
|
8884
8940
|
"&:after": {
|
|
8885
|
-
borderBottom: `${7 /*
|
|
8941
|
+
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8886
8942
|
top: "1px"
|
|
8887
8943
|
}
|
|
8888
8944
|
},
|
|
@@ -8907,10 +8963,6 @@ const showTooltip = state.Facet.define({
|
|
|
8907
8963
|
});
|
|
8908
8964
|
const showHoverTooltip = state.Facet.define();
|
|
8909
8965
|
class HoverTooltipHost {
|
|
8910
|
-
// Needs to be static so that host tooltip instances always match
|
|
8911
|
-
static create(view) {
|
|
8912
|
-
return new HoverTooltipHost(view);
|
|
8913
|
-
}
|
|
8914
8966
|
constructor(view) {
|
|
8915
8967
|
this.view = view;
|
|
8916
8968
|
this.mounted = false;
|
|
@@ -8918,6 +8970,10 @@ class HoverTooltipHost {
|
|
|
8918
8970
|
this.dom.classList.add("cm-tooltip-hover");
|
|
8919
8971
|
this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
|
|
8920
8972
|
}
|
|
8973
|
+
// Needs to be static so that host tooltip instances always match
|
|
8974
|
+
static create(view) {
|
|
8975
|
+
return new HoverTooltipHost(view);
|
|
8976
|
+
}
|
|
8921
8977
|
createHostedView(tooltip) {
|
|
8922
8978
|
let hostedView = tooltip.create(this.view);
|
|
8923
8979
|
hostedView.dom.classList.add("cm-tooltip-section");
|
|
@@ -9032,7 +9088,7 @@ class HoverPlugin {
|
|
|
9032
9088
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
9033
9089
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
9034
9090
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
9035
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /*
|
|
9091
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
9036
9092
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
9037
9093
|
this.pending = null;
|
|
9038
9094
|
}
|
|
@@ -9114,7 +9170,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
9114
9170
|
});
|
|
9115
9171
|
return [
|
|
9116
9172
|
hoverState,
|
|
9117
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /*
|
|
9173
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
9118
9174
|
showHoverTooltipHost
|
|
9119
9175
|
];
|
|
9120
9176
|
}
|