@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, EditorState, findColumn, CharCategory, Annotation,
|
|
1
|
+
import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, EditorState, findColumn, CharCategory, Annotation, Prec, Transaction, codePointAt, codePointSize, combineConfig, StateField, RangeSetBuilder, countColumn } from '@codemirror/state';
|
|
2
2
|
import { StyleModule } from 'style-mod';
|
|
3
3
|
import { keyName, base, shift } from 'w3c-keyname';
|
|
4
4
|
|
|
@@ -331,7 +331,7 @@ class ContentView {
|
|
|
331
331
|
constructor() {
|
|
332
332
|
this.parent = null;
|
|
333
333
|
this.dom = null;
|
|
334
|
-
this.dirty = 2 /*
|
|
334
|
+
this.dirty = 2 /* Node */;
|
|
335
335
|
}
|
|
336
336
|
get overrideDOMText() { return null; }
|
|
337
337
|
get posAtStart() {
|
|
@@ -353,7 +353,7 @@ class ContentView {
|
|
|
353
353
|
return this.posBefore(view) + view.length;
|
|
354
354
|
}
|
|
355
355
|
sync(view, track) {
|
|
356
|
-
if (this.dirty & 2 /*
|
|
356
|
+
if (this.dirty & 2 /* Node */) {
|
|
357
357
|
let parent = this.dom;
|
|
358
358
|
let prev = null, next;
|
|
359
359
|
for (let child of this.children) {
|
|
@@ -364,7 +364,7 @@ class ContentView {
|
|
|
364
364
|
child.reuseDOM(next);
|
|
365
365
|
}
|
|
366
366
|
child.sync(view, track);
|
|
367
|
-
child.dirty = 0 /*
|
|
367
|
+
child.dirty = 0 /* Not */;
|
|
368
368
|
}
|
|
369
369
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
370
370
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -384,11 +384,11 @@ class ContentView {
|
|
|
384
384
|
while (next)
|
|
385
385
|
next = rm$1(next);
|
|
386
386
|
}
|
|
387
|
-
else if (this.dirty & 1 /*
|
|
387
|
+
else if (this.dirty & 1 /* Child */) {
|
|
388
388
|
for (let child of this.children)
|
|
389
389
|
if (child.dirty) {
|
|
390
390
|
child.sync(view, track);
|
|
391
|
-
child.dirty = 0 /*
|
|
391
|
+
child.dirty = 0 /* Not */;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
}
|
|
@@ -453,16 +453,16 @@ class ContentView {
|
|
|
453
453
|
endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
|
|
454
454
|
}
|
|
455
455
|
markDirty(andParent = false) {
|
|
456
|
-
this.dirty |= 2 /*
|
|
456
|
+
this.dirty |= 2 /* Node */;
|
|
457
457
|
this.markParentsDirty(andParent);
|
|
458
458
|
}
|
|
459
459
|
markParentsDirty(childList) {
|
|
460
460
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
461
461
|
if (childList)
|
|
462
|
-
parent.dirty |= 2 /*
|
|
463
|
-
if (parent.dirty & 1 /*
|
|
462
|
+
parent.dirty |= 2 /* Node */;
|
|
463
|
+
if (parent.dirty & 1 /* Child */)
|
|
464
464
|
return;
|
|
465
|
-
parent.dirty |= 1 /*
|
|
465
|
+
parent.dirty |= 1 /* Child */;
|
|
466
466
|
childList = false;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
@@ -741,13 +741,13 @@ class MarkView extends ContentView {
|
|
|
741
741
|
reuseDOM(node) {
|
|
742
742
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
743
743
|
this.setDOM(node);
|
|
744
|
-
this.dirty |= 4 /*
|
|
744
|
+
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
sync(view, track) {
|
|
748
748
|
if (!this.dom)
|
|
749
749
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
750
|
-
else if (this.dirty & 4 /*
|
|
750
|
+
else if (this.dirty & 4 /* Attrs */)
|
|
751
751
|
this.setAttrs(this.dom);
|
|
752
752
|
super.sync(view, track);
|
|
753
753
|
}
|
|
@@ -818,9 +818,6 @@ function textCoords(text, pos, side) {
|
|
|
818
818
|
}
|
|
819
819
|
// Also used for collapsed ranges that don't have a placeholder widget!
|
|
820
820
|
class WidgetView extends ContentView {
|
|
821
|
-
static create(widget, length, side) {
|
|
822
|
-
return new (widget.customView || WidgetView)(widget, length, side);
|
|
823
|
-
}
|
|
824
821
|
constructor(widget, length, side) {
|
|
825
822
|
super();
|
|
826
823
|
this.widget = widget;
|
|
@@ -828,6 +825,9 @@ class WidgetView extends ContentView {
|
|
|
828
825
|
this.side = side;
|
|
829
826
|
this.prevWidget = null;
|
|
830
827
|
}
|
|
828
|
+
static create(widget, length, side) {
|
|
829
|
+
return new (widget.customView || WidgetView)(widget, length, side);
|
|
830
|
+
}
|
|
831
831
|
split(from) {
|
|
832
832
|
let result = WidgetView.create(this.widget, this.length - from, this.side);
|
|
833
833
|
this.length -= from;
|
|
@@ -887,12 +887,13 @@ class WidgetView extends ContentView {
|
|
|
887
887
|
let rects = this.dom.getClientRects(), rect = null;
|
|
888
888
|
if (!rects.length)
|
|
889
889
|
return null;
|
|
890
|
-
|
|
890
|
+
let fromBack = this.side ? this.side < 0 : pos > 0;
|
|
891
|
+
for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {
|
|
891
892
|
rect = rects[i];
|
|
892
893
|
if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
|
|
893
894
|
break;
|
|
894
895
|
}
|
|
895
|
-
return this.length ? rect : flattenRect(rect,
|
|
896
|
+
return this.length ? rect : flattenRect(rect, !fromBack);
|
|
896
897
|
}
|
|
897
898
|
get isEditable() { return false; }
|
|
898
899
|
get isWidget() { return true; }
|
|
@@ -1212,6 +1213,13 @@ class WidgetType {
|
|
|
1212
1213
|
*/
|
|
1213
1214
|
get estimatedHeight() { return -1; }
|
|
1214
1215
|
/**
|
|
1216
|
+
For inline widgets that are displayed inline (as opposed to
|
|
1217
|
+
`inline-block`) and introduce line breaks (through `<br>` tags
|
|
1218
|
+
or textual newlines), this must indicate the amount of line
|
|
1219
|
+
breaks they introduce. Defaults to 0.
|
|
1220
|
+
*/
|
|
1221
|
+
get lineBreaks() { return 0; }
|
|
1222
|
+
/**
|
|
1215
1223
|
Can be used to configure which kinds of events inside the widget
|
|
1216
1224
|
should be ignored by the editor. The default is to ignore all
|
|
1217
1225
|
events.
|
|
@@ -1313,8 +1321,8 @@ class Decoration extends RangeValue {
|
|
|
1313
1321
|
given position.
|
|
1314
1322
|
*/
|
|
1315
1323
|
static widget(spec) {
|
|
1316
|
-
let side = spec.side || 0, block = !!spec.block;
|
|
1317
|
-
side += block ? (side > 0 ? 300000000 /*
|
|
1324
|
+
let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;
|
|
1325
|
+
side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
|
|
1318
1326
|
return new PointDecoration(spec, side, side, block, spec.widget || null, false);
|
|
1319
1327
|
}
|
|
1320
1328
|
/**
|
|
@@ -1324,13 +1332,13 @@ class Decoration extends RangeValue {
|
|
|
1324
1332
|
static replace(spec) {
|
|
1325
1333
|
let block = !!spec.block, startSide, endSide;
|
|
1326
1334
|
if (spec.isBlockGap) {
|
|
1327
|
-
startSide = -500000000 /*
|
|
1328
|
-
endSide = 400000000 /*
|
|
1335
|
+
startSide = -500000000 /* GapStart */;
|
|
1336
|
+
endSide = 400000000 /* GapEnd */;
|
|
1329
1337
|
}
|
|
1330
1338
|
else {
|
|
1331
1339
|
let { start, end } = getInclusive(spec, block);
|
|
1332
|
-
startSide = (start ? (block ? -300000000 /*
|
|
1333
|
-
endSide = (end ? (block ? 200000000 /*
|
|
1340
|
+
startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
|
|
1341
|
+
endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
|
|
1334
1342
|
}
|
|
1335
1343
|
return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
|
|
1336
1344
|
}
|
|
@@ -1361,7 +1369,7 @@ Decoration.none = RangeSet.empty;
|
|
|
1361
1369
|
class MarkDecoration extends Decoration {
|
|
1362
1370
|
constructor(spec) {
|
|
1363
1371
|
let { start, end } = getInclusive(spec);
|
|
1364
|
-
super(start ? -1 /*
|
|
1372
|
+
super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
|
|
1365
1373
|
this.tagName = spec.tagName || "span";
|
|
1366
1374
|
this.class = spec.class || "";
|
|
1367
1375
|
this.attrs = spec.attributes || null;
|
|
@@ -1382,7 +1390,7 @@ class MarkDecoration extends Decoration {
|
|
|
1382
1390
|
MarkDecoration.prototype.point = false;
|
|
1383
1391
|
class LineDecoration extends Decoration {
|
|
1384
1392
|
constructor(spec) {
|
|
1385
|
-
super(-200000000 /*
|
|
1393
|
+
super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
|
|
1386
1394
|
}
|
|
1387
1395
|
eq(other) {
|
|
1388
1396
|
return other instanceof LineDecoration &&
|
|
@@ -1409,7 +1417,9 @@ class PointDecoration extends Decoration {
|
|
|
1409
1417
|
return this.startSide < this.endSide ? BlockType.WidgetRange
|
|
1410
1418
|
: this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;
|
|
1411
1419
|
}
|
|
1412
|
-
get heightRelevant() {
|
|
1420
|
+
get heightRelevant() {
|
|
1421
|
+
return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
|
|
1422
|
+
}
|
|
1413
1423
|
eq(other) {
|
|
1414
1424
|
return other instanceof PointDecoration &&
|
|
1415
1425
|
widgetsEq(this.widget, other.widget) &&
|
|
@@ -1521,7 +1531,7 @@ class LineView extends ContentView {
|
|
|
1521
1531
|
reuseDOM(node) {
|
|
1522
1532
|
if (node.nodeName == "DIV") {
|
|
1523
1533
|
this.setDOM(node);
|
|
1524
|
-
this.dirty |= 4 /*
|
|
1534
|
+
this.dirty |= 4 /* Attrs */ | 2 /* Node */;
|
|
1525
1535
|
}
|
|
1526
1536
|
}
|
|
1527
1537
|
sync(view, track) {
|
|
@@ -1531,7 +1541,7 @@ class LineView extends ContentView {
|
|
|
1531
1541
|
this.dom.className = "cm-line";
|
|
1532
1542
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
1533
1543
|
}
|
|
1534
|
-
else if (this.dirty & 4 /*
|
|
1544
|
+
else if (this.dirty & 4 /* Attrs */) {
|
|
1535
1545
|
clearAttributes(this.dom);
|
|
1536
1546
|
this.dom.className = "cm-line";
|
|
1537
1547
|
this.prevAttrs = this.attrs ? null : undefined;
|
|
@@ -1679,7 +1689,7 @@ class ContentBuilder {
|
|
|
1679
1689
|
this.content = [];
|
|
1680
1690
|
this.curLine = null;
|
|
1681
1691
|
this.breakAtStart = 0;
|
|
1682
|
-
this.pendingBuffer = 0 /*
|
|
1692
|
+
this.pendingBuffer = 0 /* No */;
|
|
1683
1693
|
this.bufferMarks = [];
|
|
1684
1694
|
// Set to false directly after a widget that covers the position after it
|
|
1685
1695
|
this.atCursorPos = true;
|
|
@@ -1706,7 +1716,7 @@ class ContentBuilder {
|
|
|
1706
1716
|
flushBuffer(active = this.bufferMarks) {
|
|
1707
1717
|
if (this.pendingBuffer) {
|
|
1708
1718
|
this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
|
|
1709
|
-
this.pendingBuffer = 0 /*
|
|
1719
|
+
this.pendingBuffer = 0 /* No */;
|
|
1710
1720
|
}
|
|
1711
1721
|
}
|
|
1712
1722
|
addBlockWidget(view) {
|
|
@@ -1718,7 +1728,7 @@ class ContentBuilder {
|
|
|
1718
1728
|
if (this.pendingBuffer && openEnd <= this.bufferMarks.length)
|
|
1719
1729
|
this.flushBuffer();
|
|
1720
1730
|
else
|
|
1721
|
-
this.pendingBuffer = 0 /*
|
|
1731
|
+
this.pendingBuffer = 0 /* No */;
|
|
1722
1732
|
if (!this.posCovered())
|
|
1723
1733
|
this.getLine();
|
|
1724
1734
|
}
|
|
@@ -1747,7 +1757,7 @@ class ContentBuilder {
|
|
|
1747
1757
|
this.textOff = 0;
|
|
1748
1758
|
}
|
|
1749
1759
|
}
|
|
1750
|
-
let take = Math.min(this.text.length - this.textOff, length, 512 /*
|
|
1760
|
+
let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
|
|
1751
1761
|
this.flushBuffer(active.slice(active.length - openStart));
|
|
1752
1762
|
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
|
|
1753
1763
|
this.atCursorPos = true;
|
|
@@ -1783,8 +1793,8 @@ class ContentBuilder {
|
|
|
1783
1793
|
(from < to || deco.startSide > 0);
|
|
1784
1794
|
let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
|
|
1785
1795
|
let line = this.getLine();
|
|
1786
|
-
if (this.pendingBuffer == 2 /*
|
|
1787
|
-
this.pendingBuffer = 0 /*
|
|
1796
|
+
if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore && !view.isEditable)
|
|
1797
|
+
this.pendingBuffer = 0 /* No */;
|
|
1788
1798
|
this.flushBuffer(active);
|
|
1789
1799
|
if (cursorBefore) {
|
|
1790
1800
|
line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
|
|
@@ -1792,7 +1802,7 @@ class ContentBuilder {
|
|
|
1792
1802
|
}
|
|
1793
1803
|
line.append(wrapMarks(view, active), openStart);
|
|
1794
1804
|
this.atCursorPos = cursorAfter;
|
|
1795
|
-
this.pendingBuffer = !cursorAfter ? 0 /*
|
|
1805
|
+
this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to || openStart > active.length ? 1 /* Yes */ : 2 /* IfCursor */;
|
|
1796
1806
|
if (this.pendingBuffer)
|
|
1797
1807
|
this.bufferMarks = active.slice();
|
|
1798
1808
|
}
|
|
@@ -2119,27 +2129,27 @@ class ViewUpdate {
|
|
|
2119
2129
|
update.
|
|
2120
2130
|
*/
|
|
2121
2131
|
get viewportChanged() {
|
|
2122
|
-
return (this.flags & 4 /*
|
|
2132
|
+
return (this.flags & 4 /* Viewport */) > 0;
|
|
2123
2133
|
}
|
|
2124
2134
|
/**
|
|
2125
2135
|
Indicates whether the height of a block element in the editor
|
|
2126
2136
|
changed in this update.
|
|
2127
2137
|
*/
|
|
2128
2138
|
get heightChanged() {
|
|
2129
|
-
return (this.flags & 2 /*
|
|
2139
|
+
return (this.flags & 2 /* Height */) > 0;
|
|
2130
2140
|
}
|
|
2131
2141
|
/**
|
|
2132
2142
|
Returns true when the document was modified or the size of the
|
|
2133
2143
|
editor, or elements within the editor, changed.
|
|
2134
2144
|
*/
|
|
2135
2145
|
get geometryChanged() {
|
|
2136
|
-
return this.docChanged || (this.flags & (8 /*
|
|
2146
|
+
return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
|
|
2137
2147
|
}
|
|
2138
2148
|
/**
|
|
2139
2149
|
True when this update indicates a focus change.
|
|
2140
2150
|
*/
|
|
2141
2151
|
get focusChanged() {
|
|
2142
|
-
return (this.flags & 1 /*
|
|
2152
|
+
return (this.flags & 1 /* Focus */) > 0;
|
|
2143
2153
|
}
|
|
2144
2154
|
/**
|
|
2145
2155
|
Whether the document changed in this update.
|
|
@@ -2197,12 +2207,12 @@ for (let p of ["()", "[]", "{}"]) {
|
|
|
2197
2207
|
}
|
|
2198
2208
|
function charType(ch) {
|
|
2199
2209
|
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2200
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /*
|
|
2210
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
|
|
2201
2211
|
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2202
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /*
|
|
2203
|
-
0x2000 <= ch && ch <= 0x200b ? 256 /*
|
|
2204
|
-
0xfb50 <= ch && ch <= 0xfdff ? 4 /*
|
|
2205
|
-
ch == 0x200c ? 256 /*
|
|
2212
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
|
|
2213
|
+
0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
|
|
2214
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* AL */ :
|
|
2215
|
+
ch == 0x200c ? 256 /* NI */ : 1 /* L */;
|
|
2206
2216
|
}
|
|
2207
2217
|
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2208
2218
|
/**
|
|
@@ -2210,10 +2220,6 @@ Represents a contiguous range of text that has a single direction
|
|
|
2210
2220
|
(as in left-to-right or right-to-left).
|
|
2211
2221
|
*/
|
|
2212
2222
|
class BidiSpan {
|
|
2213
|
-
/**
|
|
2214
|
-
The direction of this span.
|
|
2215
|
-
*/
|
|
2216
|
-
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2217
2223
|
/**
|
|
2218
2224
|
@internal
|
|
2219
2225
|
*/
|
|
@@ -2239,6 +2245,10 @@ class BidiSpan {
|
|
|
2239
2245
|
this.level = level;
|
|
2240
2246
|
}
|
|
2241
2247
|
/**
|
|
2248
|
+
The direction of this span.
|
|
2249
|
+
*/
|
|
2250
|
+
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2251
|
+
/**
|
|
2242
2252
|
@internal
|
|
2243
2253
|
*/
|
|
2244
2254
|
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
@@ -2267,8 +2277,8 @@ class BidiSpan {
|
|
|
2267
2277
|
// Reused array of character types
|
|
2268
2278
|
const types = [];
|
|
2269
2279
|
function computeOrder(line, direction) {
|
|
2270
|
-
let len = line.length, outerType = direction == LTR ? 1 /*
|
|
2271
|
-
if (!line || outerType == 1 /*
|
|
2280
|
+
let len = line.length, outerType = direction == LTR ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR ? 2 /* R */ : 1 /* L */;
|
|
2281
|
+
if (!line || outerType == 1 /* L */ && !BidiRE.test(line))
|
|
2272
2282
|
return trivialOrder(len);
|
|
2273
2283
|
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
|
2274
2284
|
// change the type of the NSM to the type of the previous
|
|
@@ -2282,12 +2292,12 @@ function computeOrder(line, direction) {
|
|
|
2282
2292
|
// (Left after this: L, R, EN, AN, ET, CS, NI)
|
|
2283
2293
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2284
2294
|
let type = charType(line.charCodeAt(i));
|
|
2285
|
-
if (type == 512 /*
|
|
2295
|
+
if (type == 512 /* NSM */)
|
|
2286
2296
|
type = prev;
|
|
2287
|
-
else if (type == 8 /*
|
|
2288
|
-
type = 16 /*
|
|
2289
|
-
types[i] = type == 4 /*
|
|
2290
|
-
if (type & 7 /*
|
|
2297
|
+
else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
|
|
2298
|
+
type = 16 /* AN */;
|
|
2299
|
+
types[i] = type == 4 /* AL */ ? 2 /* R */ : type;
|
|
2300
|
+
if (type & 7 /* Strong */)
|
|
2291
2301
|
prevStrong = type;
|
|
2292
2302
|
prev = type;
|
|
2293
2303
|
}
|
|
@@ -2301,26 +2311,26 @@ function computeOrder(line, direction) {
|
|
|
2301
2311
|
// (Left after this: L, R, EN+AN, NI)
|
|
2302
2312
|
for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
|
|
2303
2313
|
let type = types[i];
|
|
2304
|
-
if (type == 128 /*
|
|
2305
|
-
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /*
|
|
2314
|
+
if (type == 128 /* CS */) {
|
|
2315
|
+
if (i < len - 1 && prev == types[i + 1] && (prev & 24 /* Num */))
|
|
2306
2316
|
type = types[i] = prev;
|
|
2307
2317
|
else
|
|
2308
|
-
types[i] = 256 /*
|
|
2318
|
+
types[i] = 256 /* NI */;
|
|
2309
2319
|
}
|
|
2310
|
-
else if (type == 64 /*
|
|
2320
|
+
else if (type == 64 /* ET */) {
|
|
2311
2321
|
let end = i + 1;
|
|
2312
|
-
while (end < len && types[end] == 64 /*
|
|
2322
|
+
while (end < len && types[end] == 64 /* ET */)
|
|
2313
2323
|
end++;
|
|
2314
|
-
let replace = (i && prev == 8 /*
|
|
2324
|
+
let replace = (i && prev == 8 /* EN */) || (end < len && types[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
|
|
2315
2325
|
for (let j = i; j < end; j++)
|
|
2316
2326
|
types[j] = replace;
|
|
2317
2327
|
i = end - 1;
|
|
2318
2328
|
}
|
|
2319
|
-
else if (type == 8 /*
|
|
2320
|
-
types[i] = 1 /*
|
|
2329
|
+
else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
|
|
2330
|
+
types[i] = 1 /* L */;
|
|
2321
2331
|
}
|
|
2322
2332
|
prev = type;
|
|
2323
|
-
if (type & 7 /*
|
|
2333
|
+
if (type & 7 /* Strong */)
|
|
2324
2334
|
prevStrong = type;
|
|
2325
2335
|
}
|
|
2326
2336
|
// N0. Process bracket pairs in an isolating run sequence
|
|
@@ -2335,9 +2345,9 @@ function computeOrder(line, direction) {
|
|
|
2335
2345
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2336
2346
|
if (BracketStack[sJ + 1] == -br) {
|
|
2337
2347
|
let flags = BracketStack[sJ + 2];
|
|
2338
|
-
let type = (flags & 2 /*
|
|
2339
|
-
!(flags & 4 /*
|
|
2340
|
-
(flags & 1 /*
|
|
2348
|
+
let type = (flags & 2 /* EmbedInside */) ? outerType :
|
|
2349
|
+
!(flags & 4 /* OppositeInside */) ? 0 :
|
|
2350
|
+
(flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
|
|
2341
2351
|
if (type)
|
|
2342
2352
|
types[i] = types[BracketStack[sJ]] = type;
|
|
2343
2353
|
sI = sJ;
|
|
@@ -2345,7 +2355,7 @@ function computeOrder(line, direction) {
|
|
|
2345
2355
|
}
|
|
2346
2356
|
}
|
|
2347
2357
|
}
|
|
2348
|
-
else if (BracketStack.length == 189 /*
|
|
2358
|
+
else if (BracketStack.length == 189 /* MaxDepth */) {
|
|
2349
2359
|
break;
|
|
2350
2360
|
}
|
|
2351
2361
|
else {
|
|
@@ -2354,20 +2364,20 @@ function computeOrder(line, direction) {
|
|
|
2354
2364
|
BracketStack[sI++] = context;
|
|
2355
2365
|
}
|
|
2356
2366
|
}
|
|
2357
|
-
else if ((type = types[i]) == 2 /*
|
|
2367
|
+
else if ((type = types[i]) == 2 /* R */ || type == 1 /* L */) {
|
|
2358
2368
|
let embed = type == outerType;
|
|
2359
|
-
context = embed ? 0 : 1 /*
|
|
2369
|
+
context = embed ? 0 : 1 /* OppositeBefore */;
|
|
2360
2370
|
for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
|
|
2361
2371
|
let cur = BracketStack[sJ + 2];
|
|
2362
|
-
if (cur & 2 /*
|
|
2372
|
+
if (cur & 2 /* EmbedInside */)
|
|
2363
2373
|
break;
|
|
2364
2374
|
if (embed) {
|
|
2365
|
-
BracketStack[sJ + 2] |= 2 /*
|
|
2375
|
+
BracketStack[sJ + 2] |= 2 /* EmbedInside */;
|
|
2366
2376
|
}
|
|
2367
2377
|
else {
|
|
2368
|
-
if (cur & 4 /*
|
|
2378
|
+
if (cur & 4 /* OppositeInside */)
|
|
2369
2379
|
break;
|
|
2370
|
-
BracketStack[sJ + 2] |= 4 /*
|
|
2380
|
+
BracketStack[sJ + 2] |= 4 /* OppositeInside */;
|
|
2371
2381
|
}
|
|
2372
2382
|
}
|
|
2373
2383
|
}
|
|
@@ -2380,13 +2390,13 @@ function computeOrder(line, direction) {
|
|
|
2380
2390
|
// N2. Any remaining neutrals take the embedding direction.
|
|
2381
2391
|
// (Left after this: L, R, EN+AN)
|
|
2382
2392
|
for (let i = 0; i < len; i++) {
|
|
2383
|
-
if (types[i] == 256 /*
|
|
2393
|
+
if (types[i] == 256 /* NI */) {
|
|
2384
2394
|
let end = i + 1;
|
|
2385
|
-
while (end < len && types[end] == 256 /*
|
|
2395
|
+
while (end < len && types[end] == 256 /* NI */)
|
|
2386
2396
|
end++;
|
|
2387
|
-
let beforeL = (i ? types[i - 1] : outerType) == 1 /*
|
|
2388
|
-
let afterL = (end < len ? types[end] : outerType) == 1 /*
|
|
2389
|
-
let replace = beforeL == afterL ? (beforeL ? 1 /*
|
|
2397
|
+
let beforeL = (i ? types[i - 1] : outerType) == 1 /* L */;
|
|
2398
|
+
let afterL = (end < len ? types[end] : outerType) == 1 /* L */;
|
|
2399
|
+
let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
|
|
2390
2400
|
for (let j = i; j < end; j++)
|
|
2391
2401
|
types[j] = replace;
|
|
2392
2402
|
i = end - 1;
|
|
@@ -2398,15 +2408,15 @@ function computeOrder(line, direction) {
|
|
|
2398
2408
|
// explicit embedding into account, we can build up the order on
|
|
2399
2409
|
// the fly, without following the level-based algorithm.
|
|
2400
2410
|
let order = [];
|
|
2401
|
-
if (outerType == 1 /*
|
|
2411
|
+
if (outerType == 1 /* L */) {
|
|
2402
2412
|
for (let i = 0; i < len;) {
|
|
2403
|
-
let start = i, rtl = types[i++] != 1 /*
|
|
2404
|
-
while (i < len && rtl == (types[i] != 1 /*
|
|
2413
|
+
let start = i, rtl = types[i++] != 1 /* L */;
|
|
2414
|
+
while (i < len && rtl == (types[i] != 1 /* L */))
|
|
2405
2415
|
i++;
|
|
2406
2416
|
if (rtl) {
|
|
2407
2417
|
for (let j = i; j > start;) {
|
|
2408
|
-
let end = j, l = types[--j] != 2 /*
|
|
2409
|
-
while (j > start && l == (types[j - 1] != 2 /*
|
|
2418
|
+
let end = j, l = types[--j] != 2 /* R */;
|
|
2419
|
+
while (j > start && l == (types[j - 1] != 2 /* R */))
|
|
2410
2420
|
j--;
|
|
2411
2421
|
order.push(new BidiSpan(j, end, l ? 2 : 1));
|
|
2412
2422
|
}
|
|
@@ -2418,8 +2428,8 @@ function computeOrder(line, direction) {
|
|
|
2418
2428
|
}
|
|
2419
2429
|
else {
|
|
2420
2430
|
for (let i = 0; i < len;) {
|
|
2421
|
-
let start = i, rtl = types[i++] == 2 /*
|
|
2422
|
-
while (i < len && rtl == (types[i] == 2 /*
|
|
2431
|
+
let start = i, rtl = types[i++] == 2 /* R */;
|
|
2432
|
+
while (i < len && rtl == (types[i] == 2 /* R */))
|
|
2423
2433
|
i++;
|
|
2424
2434
|
order.push(new BidiSpan(start, i, rtl ? 1 : 2));
|
|
2425
2435
|
}
|
|
@@ -2579,7 +2589,6 @@ class DOMPoint {
|
|
|
2579
2589
|
}
|
|
2580
2590
|
|
|
2581
2591
|
class DocView extends ContentView {
|
|
2582
|
-
get length() { return this.view.state.doc.length; }
|
|
2583
2592
|
constructor(view) {
|
|
2584
2593
|
super();
|
|
2585
2594
|
this.view = view;
|
|
@@ -2610,10 +2619,8 @@ class DocView extends ContentView {
|
|
|
2610
2619
|
this.updateDeco();
|
|
2611
2620
|
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
|
|
2612
2621
|
}
|
|
2613
|
-
|
|
2614
|
-
//
|
|
2615
|
-
// position, if we know the editor is going to scroll that position
|
|
2616
|
-
// into view.
|
|
2622
|
+
get length() { return this.view.state.doc.length; }
|
|
2623
|
+
// Update the document view to a given state.
|
|
2617
2624
|
update(update) {
|
|
2618
2625
|
let changedRanges = update.changedRanges;
|
|
2619
2626
|
if (this.minWidth > 0 && changedRanges.length) {
|
|
@@ -2640,7 +2647,7 @@ class DocView extends ContentView {
|
|
|
2640
2647
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
2641
2648
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
2642
2649
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
2643
|
-
if (this.dirty == 0 /*
|
|
2650
|
+
if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
|
|
2644
2651
|
return false;
|
|
2645
2652
|
}
|
|
2646
2653
|
else {
|
|
@@ -2669,7 +2676,7 @@ class DocView extends ContentView {
|
|
|
2669
2676
|
// to detect that situation.
|
|
2670
2677
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
|
|
2671
2678
|
this.sync(this.view, track);
|
|
2672
|
-
this.dirty = 0 /*
|
|
2679
|
+
this.dirty = 0 /* Not */;
|
|
2673
2680
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
2674
2681
|
this.forceSelection = true;
|
|
2675
2682
|
this.dom.style.height = "";
|
|
@@ -2738,10 +2745,10 @@ class DocView extends ContentView {
|
|
|
2738
2745
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2739
2746
|
if (browser.gecko) {
|
|
2740
2747
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
2741
|
-
if (nextTo && nextTo != (1 /*
|
|
2742
|
-
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /*
|
|
2748
|
+
if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
|
|
2749
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
|
|
2743
2750
|
if (text)
|
|
2744
|
-
anchor = new DOMPos(text, nextTo == 1 /*
|
|
2751
|
+
anchor = new DOMPos(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
|
|
2745
2752
|
}
|
|
2746
2753
|
}
|
|
2747
2754
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -3022,8 +3029,12 @@ function computeCompositionDeco(view, changes) {
|
|
|
3022
3029
|
return Decoration.none;
|
|
3023
3030
|
let { from, to, node, text: textNode } = surrounding;
|
|
3024
3031
|
let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
|
|
3025
|
-
let { state } = view,
|
|
3026
|
-
|
|
3032
|
+
let { state } = view, reader = new DOMReader([], state);
|
|
3033
|
+
if (node.nodeType == 3)
|
|
3034
|
+
reader.readTextNode(node);
|
|
3035
|
+
else
|
|
3036
|
+
reader.readRange(node.firstChild, null);
|
|
3037
|
+
let { text } = reader;
|
|
3027
3038
|
if (text.indexOf(LineBreakPlaceholder) > -1)
|
|
3028
3039
|
return Decoration.none; // Don't try to preserve multi-line compositions
|
|
3029
3040
|
if (newTo - newFrom < text.length) {
|
|
@@ -3087,8 +3098,8 @@ function nearbyTextNode(startNode, startOffset, side) {
|
|
|
3087
3098
|
function nextToUneditable(node, offset) {
|
|
3088
3099
|
if (node.nodeType != 1)
|
|
3089
3100
|
return 0;
|
|
3090
|
-
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /*
|
|
3091
|
-
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /*
|
|
3101
|
+
return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
|
|
3102
|
+
(offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
|
|
3092
3103
|
}
|
|
3093
3104
|
class DecorationComparator$1 {
|
|
3094
3105
|
constructor() {
|
|
@@ -3370,9 +3381,18 @@ function isSuspiciousChromeCaretResult(node, offset, x) {
|
|
|
3370
3381
|
: textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
|
|
3371
3382
|
return x - rect.left > 5;
|
|
3372
3383
|
}
|
|
3384
|
+
function blockAt(view, pos) {
|
|
3385
|
+
let line = view.lineBlockAt(pos);
|
|
3386
|
+
if (Array.isArray(line.type))
|
|
3387
|
+
for (let l of line.type) {
|
|
3388
|
+
if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
|
|
3389
|
+
return l;
|
|
3390
|
+
}
|
|
3391
|
+
return line;
|
|
3392
|
+
}
|
|
3373
3393
|
function moveToLineBoundary(view, start, forward, includeWrap) {
|
|
3374
|
-
let line = view
|
|
3375
|
-
let coords = !includeWrap || !view.lineWrapping ? null
|
|
3394
|
+
let line = blockAt(view, start.head);
|
|
3395
|
+
let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
|
|
3376
3396
|
: view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
|
|
3377
3397
|
if (coords) {
|
|
3378
3398
|
let editorRect = view.dom.getBoundingClientRect();
|
|
@@ -3382,9 +3402,7 @@ function moveToLineBoundary(view, start, forward, includeWrap) {
|
|
|
3382
3402
|
if (pos != null)
|
|
3383
3403
|
return EditorSelection.cursor(pos, forward ? -1 : 1);
|
|
3384
3404
|
}
|
|
3385
|
-
|
|
3386
|
-
let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
|
|
3387
|
-
return EditorSelection.cursor(end, forward ? -1 : 1);
|
|
3405
|
+
return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
|
|
3388
3406
|
}
|
|
3389
3407
|
function moveByChar(view, start, forward, by) {
|
|
3390
3408
|
let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
|
|
@@ -3470,10 +3488,6 @@ function skipAtoms(view, oldPos, pos) {
|
|
|
3470
3488
|
|
|
3471
3489
|
// This will also be where dragging info and such goes
|
|
3472
3490
|
class InputState {
|
|
3473
|
-
setSelectionOrigin(origin) {
|
|
3474
|
-
this.lastSelectionOrigin = origin;
|
|
3475
|
-
this.lastSelectionTime = Date.now();
|
|
3476
|
-
}
|
|
3477
3491
|
constructor(view) {
|
|
3478
3492
|
this.lastKeyCode = 0;
|
|
3479
3493
|
this.lastKeyTime = 0;
|
|
@@ -3570,6 +3584,10 @@ class InputState {
|
|
|
3570
3584
|
if (browser.safari)
|
|
3571
3585
|
view.contentDOM.addEventListener("input", () => null);
|
|
3572
3586
|
}
|
|
3587
|
+
setSelectionOrigin(origin) {
|
|
3588
|
+
this.lastSelectionOrigin = origin;
|
|
3589
|
+
this.lastSelectionTime = Date.now();
|
|
3590
|
+
}
|
|
3573
3591
|
ensureHandlers(view, plugins) {
|
|
3574
3592
|
var _a;
|
|
3575
3593
|
let handlers;
|
|
@@ -4373,34 +4391,25 @@ class BlockInfo {
|
|
|
4373
4391
|
*/
|
|
4374
4392
|
height,
|
|
4375
4393
|
/**
|
|
4376
|
-
@internal
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
@internal
|
|
4394
|
+
@internal Weird packed field that holds an array of children
|
|
4395
|
+
for composite blocks, a decoration for block widgets, and a
|
|
4396
|
+
number indicating the amount of widget-create line breaks for
|
|
4397
|
+
text blocks.
|
|
4381
4398
|
*/
|
|
4382
|
-
|
|
4399
|
+
_content) {
|
|
4383
4400
|
this.from = from;
|
|
4384
4401
|
this.length = length;
|
|
4385
4402
|
this.top = top;
|
|
4386
4403
|
this.height = height;
|
|
4387
|
-
this.
|
|
4388
|
-
this.deco = deco;
|
|
4404
|
+
this._content = _content;
|
|
4389
4405
|
}
|
|
4390
4406
|
/**
|
|
4391
4407
|
The type of element this is. When querying lines, this may be
|
|
4392
4408
|
an array of all the blocks that make up the line.
|
|
4393
4409
|
*/
|
|
4394
4410
|
get type() {
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
}
|
|
4398
|
-
/**
|
|
4399
|
-
If this is a widget block, this will return the widget
|
|
4400
|
-
associated with it.
|
|
4401
|
-
*/
|
|
4402
|
-
get widget() {
|
|
4403
|
-
return this.deco && this.deco.widget;
|
|
4411
|
+
return typeof this._content == "number" ? BlockType.Text :
|
|
4412
|
+
Array.isArray(this._content) ? this._content : this._content.type;
|
|
4404
4413
|
}
|
|
4405
4414
|
/**
|
|
4406
4415
|
The end of the element as a document position.
|
|
@@ -4411,11 +4420,26 @@ class BlockInfo {
|
|
|
4411
4420
|
*/
|
|
4412
4421
|
get bottom() { return this.top + this.height; }
|
|
4413
4422
|
/**
|
|
4423
|
+
If this is a widget block, this will return the widget
|
|
4424
|
+
associated with it.
|
|
4425
|
+
*/
|
|
4426
|
+
get widget() {
|
|
4427
|
+
return this._content instanceof PointDecoration ? this._content.widget : null;
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
If this is a textblock, this holds the number of line breaks
|
|
4431
|
+
that appear in widgets inside the block.
|
|
4432
|
+
*/
|
|
4433
|
+
get widgetLineBreaks() {
|
|
4434
|
+
return typeof this._content == "number" ? this._content : 0;
|
|
4435
|
+
}
|
|
4436
|
+
/**
|
|
4414
4437
|
@internal
|
|
4415
4438
|
*/
|
|
4416
4439
|
join(other) {
|
|
4417
|
-
let
|
|
4418
|
-
|
|
4440
|
+
let content = (Array.isArray(this._content) ? this._content : [this])
|
|
4441
|
+
.concat(Array.isArray(other._content) ? other._content : [other]);
|
|
4442
|
+
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
|
|
4419
4443
|
}
|
|
4420
4444
|
}
|
|
4421
4445
|
var QueryType = /*@__PURE__*/(function (QueryType) {
|
|
@@ -4427,13 +4451,13 @@ const Epsilon = 1e-3;
|
|
|
4427
4451
|
class HeightMap {
|
|
4428
4452
|
constructor(length, // The number of characters covered
|
|
4429
4453
|
height, // Height of this part of the document
|
|
4430
|
-
flags = 2 /*
|
|
4454
|
+
flags = 2 /* Outdated */) {
|
|
4431
4455
|
this.length = length;
|
|
4432
4456
|
this.height = height;
|
|
4433
4457
|
this.flags = flags;
|
|
4434
4458
|
}
|
|
4435
|
-
get outdated() { return (this.flags & 2 /*
|
|
4436
|
-
set outdated(value) { this.flags = (value ? 2 /*
|
|
4459
|
+
get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
|
|
4460
|
+
set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
|
|
4437
4461
|
setHeight(oracle, height) {
|
|
4438
4462
|
if (this.height != height) {
|
|
4439
4463
|
if (Math.abs(this.height - height) > Epsilon)
|
|
@@ -4535,7 +4559,7 @@ class HeightMapBlock extends HeightMap {
|
|
|
4535
4559
|
this.deco = deco;
|
|
4536
4560
|
}
|
|
4537
4561
|
blockAt(_height, _oracle, top, offset) {
|
|
4538
|
-
return new BlockInfo(offset, this.length, top, this.height,
|
|
4562
|
+
return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);
|
|
4539
4563
|
}
|
|
4540
4564
|
lineAt(_value, _type, oracle, top, offset) {
|
|
4541
4565
|
return this.blockAt(0, oracle, top, offset);
|
|
@@ -4557,10 +4581,14 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4557
4581
|
super(length, height, null);
|
|
4558
4582
|
this.collapsed = 0; // Amount of collapsed content in the line
|
|
4559
4583
|
this.widgetHeight = 0; // Maximum inline widget height
|
|
4584
|
+
this.breaks = 0; // Number of widget-introduced line breaks on the line
|
|
4585
|
+
}
|
|
4586
|
+
blockAt(_height, _oracle, top, offset) {
|
|
4587
|
+
return new BlockInfo(offset, this.length, top, this.height, this.breaks);
|
|
4560
4588
|
}
|
|
4561
4589
|
replace(_from, _to, nodes) {
|
|
4562
4590
|
let node = nodes[0];
|
|
4563
|
-
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /*
|
|
4591
|
+
if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* SingleLine */)) &&
|
|
4564
4592
|
Math.abs(this.length - node.length) < 10) {
|
|
4565
4593
|
if (node instanceof HeightMapGap)
|
|
4566
4594
|
node = new HeightMapText(node.length, this.height);
|
|
@@ -4578,7 +4606,8 @@ class HeightMapText extends HeightMapBlock {
|
|
|
4578
4606
|
if (measured && measured.from <= offset && measured.more)
|
|
4579
4607
|
this.setHeight(oracle, measured.heights[measured.index++]);
|
|
4580
4608
|
else if (force || this.outdated)
|
|
4581
|
-
this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed))
|
|
4609
|
+
this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +
|
|
4610
|
+
this.breaks * oracle.lineHeight);
|
|
4582
4611
|
this.outdated = false;
|
|
4583
4612
|
return this;
|
|
4584
4613
|
}
|
|
@@ -4609,12 +4638,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4609
4638
|
let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);
|
|
4610
4639
|
let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
|
|
4611
4640
|
let lineTop = Math.max(top, height - lineHeight / 2);
|
|
4612
|
-
return new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4641
|
+
return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);
|
|
4613
4642
|
}
|
|
4614
4643
|
else {
|
|
4615
4644
|
let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
|
|
4616
4645
|
let { from, length } = oracle.doc.line(firstLine + line);
|
|
4617
|
-
return new BlockInfo(from, length, top + perLine * line, perLine,
|
|
4646
|
+
return new BlockInfo(from, length, top + perLine * line, perLine, 0);
|
|
4618
4647
|
}
|
|
4619
4648
|
}
|
|
4620
4649
|
lineAt(value, type, oracle, top, offset) {
|
|
@@ -4622,13 +4651,13 @@ class HeightMapGap extends HeightMap {
|
|
|
4622
4651
|
return this.blockAt(value, oracle, top, offset);
|
|
4623
4652
|
if (type == QueryType.ByPosNoHeight) {
|
|
4624
4653
|
let { from, to } = oracle.doc.lineAt(value);
|
|
4625
|
-
return new BlockInfo(from, to - from, 0, 0,
|
|
4654
|
+
return new BlockInfo(from, to - from, 0, 0, 0);
|
|
4626
4655
|
}
|
|
4627
4656
|
let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
|
|
4628
4657
|
let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
|
|
4629
4658
|
let linesAbove = line.number - firstLine;
|
|
4630
4659
|
let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
|
|
4631
|
-
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight,
|
|
4660
|
+
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);
|
|
4632
4661
|
}
|
|
4633
4662
|
forEachLine(from, to, oracle, top, offset, f) {
|
|
4634
4663
|
from = Math.max(from, offset);
|
|
@@ -4641,7 +4670,7 @@ class HeightMapGap extends HeightMap {
|
|
|
4641
4670
|
lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
|
|
4642
4671
|
}
|
|
4643
4672
|
let lineHeight = perLine + perChar * line.length;
|
|
4644
|
-
f(new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4673
|
+
f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));
|
|
4645
4674
|
lineTop += lineHeight;
|
|
4646
4675
|
pos = line.to + 1;
|
|
4647
4676
|
}
|
|
@@ -4712,12 +4741,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4712
4741
|
}
|
|
4713
4742
|
class HeightMapBranch extends HeightMap {
|
|
4714
4743
|
constructor(left, brk, right) {
|
|
4715
|
-
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /*
|
|
4744
|
+
super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
|
|
4716
4745
|
this.left = left;
|
|
4717
4746
|
this.right = right;
|
|
4718
4747
|
this.size = left.size + right.size;
|
|
4719
4748
|
}
|
|
4720
|
-
get break() { return this.flags & 1 /*
|
|
4749
|
+
get break() { return this.flags & 1 /* Break */; }
|
|
4721
4750
|
blockAt(height, oracle, top, offset) {
|
|
4722
4751
|
let mid = top + this.left.height;
|
|
4723
4752
|
return height < mid ? this.left.blockAt(height, oracle, top, offset)
|
|
@@ -4867,14 +4896,15 @@ class NodeBuilder {
|
|
|
4867
4896
|
point(from, to, deco) {
|
|
4868
4897
|
if (from < to || deco.heightRelevant) {
|
|
4869
4898
|
let height = deco.widget ? deco.widget.estimatedHeight : 0;
|
|
4899
|
+
let breaks = deco.widget ? deco.widget.lineBreaks : 0;
|
|
4870
4900
|
if (height < 0)
|
|
4871
4901
|
height = this.oracle.lineHeight;
|
|
4872
4902
|
let len = to - from;
|
|
4873
4903
|
if (deco.block) {
|
|
4874
4904
|
this.addBlock(new HeightMapBlock(len, height, deco));
|
|
4875
4905
|
}
|
|
4876
|
-
else if (len || height >= relevantWidgetHeight) {
|
|
4877
|
-
this.addLineDeco(height, len);
|
|
4906
|
+
else if (len || breaks || height >= relevantWidgetHeight) {
|
|
4907
|
+
this.addLineDeco(height, breaks, len);
|
|
4878
4908
|
}
|
|
4879
4909
|
}
|
|
4880
4910
|
else if (to > from) {
|
|
@@ -4901,7 +4931,7 @@ class NodeBuilder {
|
|
|
4901
4931
|
blankContent(from, to) {
|
|
4902
4932
|
let gap = new HeightMapGap(to - from);
|
|
4903
4933
|
if (this.oracle.doc.lineAt(from).to == to)
|
|
4904
|
-
gap.flags |= 4 /*
|
|
4934
|
+
gap.flags |= 4 /* SingleLine */;
|
|
4905
4935
|
return gap;
|
|
4906
4936
|
}
|
|
4907
4937
|
ensureLine() {
|
|
@@ -4924,11 +4954,12 @@ class NodeBuilder {
|
|
|
4924
4954
|
if (type != BlockType.WidgetBefore)
|
|
4925
4955
|
this.covering = block;
|
|
4926
4956
|
}
|
|
4927
|
-
addLineDeco(height, length) {
|
|
4957
|
+
addLineDeco(height, breaks, length) {
|
|
4928
4958
|
let line = this.ensureLine();
|
|
4929
4959
|
line.length += length;
|
|
4930
4960
|
line.collapsed += length;
|
|
4931
4961
|
line.widgetHeight = Math.max(line.widgetHeight, height);
|
|
4962
|
+
line.breaks += breaks;
|
|
4932
4963
|
this.writtenTo = this.pos = this.pos + length;
|
|
4933
4964
|
}
|
|
4934
4965
|
finish(from) {
|
|
@@ -5062,6 +5093,14 @@ class ViewState {
|
|
|
5062
5093
|
this.contentDOMHeight = 0;
|
|
5063
5094
|
this.editorHeight = 0;
|
|
5064
5095
|
this.editorWidth = 0;
|
|
5096
|
+
this.scrollTop = 0;
|
|
5097
|
+
this.scrolledToBottom = true;
|
|
5098
|
+
// The vertical position (document-relative) to which to anchor the
|
|
5099
|
+
// scroll position. -1 means anchor to the end of the document.
|
|
5100
|
+
this.scrollAnchorPos = 0;
|
|
5101
|
+
// The height at the anchor position. Set by the DOM update phase.
|
|
5102
|
+
// -1 means no height available.
|
|
5103
|
+
this.scrollAnchorHeight = -1;
|
|
5065
5104
|
// See VP.MaxDOMHeight
|
|
5066
5105
|
this.scaler = IdScaler;
|
|
5067
5106
|
this.scrollTarget = null;
|
|
@@ -5102,7 +5141,7 @@ class ViewState {
|
|
|
5102
5141
|
}
|
|
5103
5142
|
}
|
|
5104
5143
|
this.viewports = viewports.sort((a, b) => a.from - b.from);
|
|
5105
|
-
this.scaler = this.heightMap.height <= 7000000 /*
|
|
5144
|
+
this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler :
|
|
5106
5145
|
new BigScaler(this.heightOracle, this.heightMap, this.viewports);
|
|
5107
5146
|
}
|
|
5108
5147
|
updateViewportLines() {
|
|
@@ -5118,20 +5157,29 @@ class ViewState {
|
|
|
5118
5157
|
let contentChanges = update.changedRanges;
|
|
5119
5158
|
let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
|
|
5120
5159
|
let prevHeight = this.heightMap.height;
|
|
5160
|
+
let scrollAnchor = this.scrolledToBottom ? null : this.lineBlockAtHeight(this.scrollTop);
|
|
5121
5161
|
this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
|
|
5122
5162
|
if (this.heightMap.height != prevHeight)
|
|
5123
|
-
update.flags |= 2 /*
|
|
5163
|
+
update.flags |= 2 /* Height */;
|
|
5164
|
+
if (scrollAnchor) {
|
|
5165
|
+
this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);
|
|
5166
|
+
this.scrollAnchorHeight = scrollAnchor.top;
|
|
5167
|
+
}
|
|
5168
|
+
else {
|
|
5169
|
+
this.scrollAnchorPos = -1;
|
|
5170
|
+
this.scrollAnchorHeight = this.heightMap.height;
|
|
5171
|
+
}
|
|
5124
5172
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
5125
5173
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
5126
5174
|
!this.viewportIsAppropriate(viewport))
|
|
5127
5175
|
viewport = this.getViewport(0, scrollTarget);
|
|
5128
|
-
let updateLines = !update.changes.empty || (update.flags & 2 /*
|
|
5176
|
+
let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
|
|
5129
5177
|
viewport.from != this.viewport.from || viewport.to != this.viewport.to;
|
|
5130
5178
|
this.viewport = viewport;
|
|
5131
5179
|
this.updateForViewport();
|
|
5132
5180
|
if (updateLines)
|
|
5133
5181
|
this.updateViewportLines();
|
|
5134
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /*
|
|
5182
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* Margin */ << 1))
|
|
5135
5183
|
this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
|
|
5136
5184
|
update.flags |= this.computeVisibleRanges();
|
|
5137
5185
|
if (scrollTarget)
|
|
@@ -5157,14 +5205,19 @@ class ViewState {
|
|
|
5157
5205
|
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
5158
5206
|
this.paddingTop = paddingTop;
|
|
5159
5207
|
this.paddingBottom = paddingBottom;
|
|
5160
|
-
result |= 8 /*
|
|
5208
|
+
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
5161
5209
|
}
|
|
5162
5210
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
5163
5211
|
if (oracle.lineWrapping)
|
|
5164
5212
|
measureContent = true;
|
|
5165
5213
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
5166
|
-
result |= 8 /*
|
|
5214
|
+
result |= 8 /* Geometry */;
|
|
5167
5215
|
}
|
|
5216
|
+
if (this.scrollTop != view.scrollDOM.scrollTop) {
|
|
5217
|
+
this.scrollAnchorHeight = -1;
|
|
5218
|
+
this.scrollTop = view.scrollDOM.scrollTop;
|
|
5219
|
+
}
|
|
5220
|
+
this.scrolledToBottom = this.scrollTop > view.scrollDOM.scrollHeight - view.scrollDOM.clientHeight - 4;
|
|
5168
5221
|
// Pixel viewport
|
|
5169
5222
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
5170
5223
|
let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
|
|
@@ -5181,7 +5234,7 @@ class ViewState {
|
|
|
5181
5234
|
if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
|
|
5182
5235
|
this.contentDOMWidth = domRect.width;
|
|
5183
5236
|
this.editorHeight = view.scrollDOM.clientHeight;
|
|
5184
|
-
result |= 8 /*
|
|
5237
|
+
result |= 8 /* Geometry */;
|
|
5185
5238
|
}
|
|
5186
5239
|
if (measureContent) {
|
|
5187
5240
|
let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
|
|
@@ -5192,7 +5245,7 @@ class ViewState {
|
|
|
5192
5245
|
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
|
|
5193
5246
|
if (refresh) {
|
|
5194
5247
|
view.docView.minWidth = 0;
|
|
5195
|
-
result |= 8 /*
|
|
5248
|
+
result |= 8 /* Geometry */;
|
|
5196
5249
|
}
|
|
5197
5250
|
}
|
|
5198
5251
|
if (dTop > 0 && dBottom > 0)
|
|
@@ -5205,7 +5258,7 @@ class ViewState {
|
|
|
5205
5258
|
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
5206
5259
|
}
|
|
5207
5260
|
if (oracle.heightChanged)
|
|
5208
|
-
result |= 2 /*
|
|
5261
|
+
result |= 2 /* Height */;
|
|
5209
5262
|
}
|
|
5210
5263
|
let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
|
|
5211
5264
|
this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||
|
|
@@ -5213,9 +5266,9 @@ class ViewState {
|
|
|
5213
5266
|
if (viewportChange)
|
|
5214
5267
|
this.viewport = this.getViewport(bias, this.scrollTarget);
|
|
5215
5268
|
this.updateForViewport();
|
|
5216
|
-
if ((result & 2 /*
|
|
5269
|
+
if ((result & 2 /* Height */) || viewportChange)
|
|
5217
5270
|
this.updateViewportLines();
|
|
5218
|
-
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /*
|
|
5271
|
+
if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* Margin */ << 1))
|
|
5219
5272
|
this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));
|
|
5220
5273
|
result |= this.computeVisibleRanges();
|
|
5221
5274
|
if (this.mustEnforceCursorAssoc) {
|
|
@@ -5234,10 +5287,10 @@ class ViewState {
|
|
|
5234
5287
|
// This will divide VP.Margin between the top and the
|
|
5235
5288
|
// bottom, depending on the bias (the change in viewport position
|
|
5236
5289
|
// since the last update). It'll hold a number between 0 and 1
|
|
5237
|
-
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /*
|
|
5290
|
+
let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
|
|
5238
5291
|
let map = this.heightMap, oracle = this.heightOracle;
|
|
5239
5292
|
let { visibleTop, visibleBottom } = this;
|
|
5240
|
-
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /*
|
|
5293
|
+
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);
|
|
5241
5294
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
5242
5295
|
if (scrollTarget) {
|
|
5243
5296
|
let { head } = scrollTarget.range;
|
|
@@ -5250,7 +5303,7 @@ class ViewState {
|
|
|
5250
5303
|
topPos = block.top;
|
|
5251
5304
|
else
|
|
5252
5305
|
topPos = block.bottom - viewHeight;
|
|
5253
|
-
viewport = new Viewport(map.lineAt(topPos - 1000 /*
|
|
5306
|
+
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);
|
|
5254
5307
|
}
|
|
5255
5308
|
}
|
|
5256
5309
|
return viewport;
|
|
@@ -5267,10 +5320,10 @@ class ViewState {
|
|
|
5267
5320
|
let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
5268
5321
|
let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);
|
|
5269
5322
|
let { visibleTop, visibleBottom } = this;
|
|
5270
|
-
return (from == 0 || top <= visibleTop - Math.max(10 /*
|
|
5323
|
+
return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
|
|
5271
5324
|
(to == this.state.doc.length ||
|
|
5272
|
-
bottom >= visibleBottom + Math.max(10 /*
|
|
5273
|
-
(top > visibleTop - 2 * 1000 /*
|
|
5325
|
+
bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
|
|
5326
|
+
(top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
|
|
5274
5327
|
}
|
|
5275
5328
|
mapLineGaps(gaps, changes) {
|
|
5276
5329
|
if (!gaps.length || changes.empty)
|
|
@@ -5290,7 +5343,7 @@ class ViewState {
|
|
|
5290
5343
|
// the artifacts this might produce from the user.
|
|
5291
5344
|
ensureLineGaps(current, mayMeasure) {
|
|
5292
5345
|
let wrapping = this.heightOracle.lineWrapping;
|
|
5293
|
-
let margin = wrapping ? 10000 /*
|
|
5346
|
+
let margin = wrapping ? 10000 /* MarginWrap */ : 2000 /* Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;
|
|
5294
5347
|
// The non-wrapping logic won't work at all in predominantly right-to-left text.
|
|
5295
5348
|
if (this.defaultTextDirection != Direction.LTR && !wrapping)
|
|
5296
5349
|
return [];
|
|
@@ -5303,8 +5356,8 @@ class ViewState {
|
|
|
5303
5356
|
avoid.push(sel.to);
|
|
5304
5357
|
for (let pos of avoid) {
|
|
5305
5358
|
if (pos > from && pos < to) {
|
|
5306
|
-
addGap(from, pos - 10 /*
|
|
5307
|
-
addGap(pos + 10 /*
|
|
5359
|
+
addGap(from, pos - 10 /* SelectionMargin */, line, structure);
|
|
5360
|
+
addGap(pos + 10 /* SelectionMargin */, to, line, structure);
|
|
5308
5361
|
return;
|
|
5309
5362
|
}
|
|
5310
5363
|
}
|
|
@@ -5398,7 +5451,7 @@ class ViewState {
|
|
|
5398
5451
|
let changed = ranges.length != this.visibleRanges.length ||
|
|
5399
5452
|
this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
|
|
5400
5453
|
this.visibleRanges = ranges;
|
|
5401
|
-
return changed ? 4 /*
|
|
5454
|
+
return changed ? 4 /* Viewport */ : 0;
|
|
5402
5455
|
}
|
|
5403
5456
|
lineBlockAt(pos) {
|
|
5404
5457
|
return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
|
|
@@ -5490,7 +5543,7 @@ class BigScaler {
|
|
|
5490
5543
|
vpHeight += bottom - top;
|
|
5491
5544
|
return { from, to, top, bottom, domTop: 0, domBottom: 0 };
|
|
5492
5545
|
});
|
|
5493
|
-
this.scale = (7000000 /*
|
|
5546
|
+
this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
|
|
5494
5547
|
for (let obj of this.viewports) {
|
|
5495
5548
|
obj.domTop = domBase + (obj.top - base) * this.scale;
|
|
5496
5549
|
domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
|
|
@@ -5524,7 +5577,7 @@ function scaleBlock(block, scaler) {
|
|
|
5524
5577
|
if (scaler.scale == 1)
|
|
5525
5578
|
return block;
|
|
5526
5579
|
let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
|
|
5527
|
-
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, block.
|
|
5580
|
+
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);
|
|
5528
5581
|
}
|
|
5529
5582
|
|
|
5530
5583
|
const theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(" ") });
|
|
@@ -6384,7 +6437,7 @@ class DOMObserver {
|
|
|
6384
6437
|
return null;
|
|
6385
6438
|
cView.markDirty(rec.type == "attributes");
|
|
6386
6439
|
if (rec.type == "attributes")
|
|
6387
|
-
cView.dirty |= 4 /*
|
|
6440
|
+
cView.dirty |= 4 /* Attrs */;
|
|
6388
6441
|
if (rec.type == "childList") {
|
|
6389
6442
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
6390
6443
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -6492,53 +6545,6 @@ line number gutter. It handles events and dispatches state
|
|
|
6492
6545
|
transactions for editing actions.
|
|
6493
6546
|
*/
|
|
6494
6547
|
class EditorView {
|
|
6495
|
-
/**
|
|
6496
|
-
The current editor state.
|
|
6497
|
-
*/
|
|
6498
|
-
get state() { return this.viewState.state; }
|
|
6499
|
-
/**
|
|
6500
|
-
To be able to display large documents without consuming too much
|
|
6501
|
-
memory or overloading the browser, CodeMirror only draws the
|
|
6502
|
-
code that is visible (plus a margin around it) to the DOM. This
|
|
6503
|
-
property tells you the extent of the current drawn viewport, in
|
|
6504
|
-
document positions.
|
|
6505
|
-
*/
|
|
6506
|
-
get viewport() { return this.viewState.viewport; }
|
|
6507
|
-
/**
|
|
6508
|
-
When there are, for example, large collapsed ranges in the
|
|
6509
|
-
viewport, its size can be a lot bigger than the actual visible
|
|
6510
|
-
content. Thus, if you are doing something like styling the
|
|
6511
|
-
content in the viewport, it is preferable to only do so for
|
|
6512
|
-
these ranges, which are the subset of the viewport that is
|
|
6513
|
-
actually drawn.
|
|
6514
|
-
*/
|
|
6515
|
-
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6516
|
-
/**
|
|
6517
|
-
Returns false when the editor is entirely scrolled out of view
|
|
6518
|
-
or otherwise hidden.
|
|
6519
|
-
*/
|
|
6520
|
-
get inView() { return this.viewState.inView; }
|
|
6521
|
-
/**
|
|
6522
|
-
Indicates whether the user is currently composing text via
|
|
6523
|
-
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6524
|
-
one change has been made in the current composition.
|
|
6525
|
-
*/
|
|
6526
|
-
get composing() { return this.inputState.composing > 0; }
|
|
6527
|
-
/**
|
|
6528
|
-
Indicates whether the user is currently in composing state. Note
|
|
6529
|
-
that on some platforms, like Android, this will be the case a
|
|
6530
|
-
lot, since just putting the cursor on a word starts a
|
|
6531
|
-
composition there.
|
|
6532
|
-
*/
|
|
6533
|
-
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6534
|
-
/**
|
|
6535
|
-
The document or shadow root that the view lives in.
|
|
6536
|
-
*/
|
|
6537
|
-
get root() { return this._root; }
|
|
6538
|
-
/**
|
|
6539
|
-
@internal
|
|
6540
|
-
*/
|
|
6541
|
-
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6542
6548
|
/**
|
|
6543
6549
|
Construct a new view. You'll want to either provide a `parent`
|
|
6544
6550
|
option, or put `view.dom` into your document after creating a
|
|
@@ -6554,7 +6560,7 @@ class EditorView {
|
|
|
6554
6560
|
/**
|
|
6555
6561
|
@internal
|
|
6556
6562
|
*/
|
|
6557
|
-
this.updateState = 2 /*
|
|
6563
|
+
this.updateState = 2 /* Updating */;
|
|
6558
6564
|
/**
|
|
6559
6565
|
@internal
|
|
6560
6566
|
*/
|
|
@@ -6587,11 +6593,58 @@ class EditorView {
|
|
|
6587
6593
|
this.docView = new DocView(this);
|
|
6588
6594
|
this.mountStyles();
|
|
6589
6595
|
this.updateAttrs();
|
|
6590
|
-
this.updateState = 0 /*
|
|
6596
|
+
this.updateState = 0 /* Idle */;
|
|
6591
6597
|
this.requestMeasure();
|
|
6592
6598
|
if (config.parent)
|
|
6593
6599
|
config.parent.appendChild(this.dom);
|
|
6594
6600
|
}
|
|
6601
|
+
/**
|
|
6602
|
+
The current editor state.
|
|
6603
|
+
*/
|
|
6604
|
+
get state() { return this.viewState.state; }
|
|
6605
|
+
/**
|
|
6606
|
+
To be able to display large documents without consuming too much
|
|
6607
|
+
memory or overloading the browser, CodeMirror only draws the
|
|
6608
|
+
code that is visible (plus a margin around it) to the DOM. This
|
|
6609
|
+
property tells you the extent of the current drawn viewport, in
|
|
6610
|
+
document positions.
|
|
6611
|
+
*/
|
|
6612
|
+
get viewport() { return this.viewState.viewport; }
|
|
6613
|
+
/**
|
|
6614
|
+
When there are, for example, large collapsed ranges in the
|
|
6615
|
+
viewport, its size can be a lot bigger than the actual visible
|
|
6616
|
+
content. Thus, if you are doing something like styling the
|
|
6617
|
+
content in the viewport, it is preferable to only do so for
|
|
6618
|
+
these ranges, which are the subset of the viewport that is
|
|
6619
|
+
actually drawn.
|
|
6620
|
+
*/
|
|
6621
|
+
get visibleRanges() { return this.viewState.visibleRanges; }
|
|
6622
|
+
/**
|
|
6623
|
+
Returns false when the editor is entirely scrolled out of view
|
|
6624
|
+
or otherwise hidden.
|
|
6625
|
+
*/
|
|
6626
|
+
get inView() { return this.viewState.inView; }
|
|
6627
|
+
/**
|
|
6628
|
+
Indicates whether the user is currently composing text via
|
|
6629
|
+
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
6630
|
+
one change has been made in the current composition.
|
|
6631
|
+
*/
|
|
6632
|
+
get composing() { return this.inputState.composing > 0; }
|
|
6633
|
+
/**
|
|
6634
|
+
Indicates whether the user is currently in composing state. Note
|
|
6635
|
+
that on some platforms, like Android, this will be the case a
|
|
6636
|
+
lot, since just putting the cursor on a word starts a
|
|
6637
|
+
composition there.
|
|
6638
|
+
*/
|
|
6639
|
+
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
6640
|
+
/**
|
|
6641
|
+
The document or shadow root that the view lives in.
|
|
6642
|
+
*/
|
|
6643
|
+
get root() { return this._root; }
|
|
6644
|
+
/**
|
|
6645
|
+
@internal
|
|
6646
|
+
*/
|
|
6647
|
+
get win() { return this.dom.ownerDocument.defaultView || window; }
|
|
6595
6648
|
dispatch(...input) {
|
|
6596
6649
|
let tr = input.length == 1 && input[0] instanceof Transaction ? input[0]
|
|
6597
6650
|
: this.state.update(...input);
|
|
@@ -6606,7 +6659,7 @@ class EditorView {
|
|
|
6606
6659
|
as a primitive.
|
|
6607
6660
|
*/
|
|
6608
6661
|
update(transactions) {
|
|
6609
|
-
if (this.updateState != 0 /*
|
|
6662
|
+
if (this.updateState != 0 /* Idle */)
|
|
6610
6663
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6611
6664
|
let redrawn = false, attrsChanged = false, update;
|
|
6612
6665
|
let state = this.state;
|
|
@@ -6623,7 +6676,7 @@ class EditorView {
|
|
|
6623
6676
|
if (transactions.some(tr => tr.annotation(isFocusChange))) {
|
|
6624
6677
|
this.inputState.notifiedFocused = focus;
|
|
6625
6678
|
// If a focus-change transaction is being dispatched, set this update flag.
|
|
6626
|
-
focusFlag = 1 /*
|
|
6679
|
+
focusFlag = 1 /* Focus */;
|
|
6627
6680
|
}
|
|
6628
6681
|
else if (focus != this.inputState.notifiedFocused) {
|
|
6629
6682
|
this.inputState.notifiedFocused = focus;
|
|
@@ -6631,7 +6684,7 @@ class EditorView {
|
|
|
6631
6684
|
// add a flag to this update
|
|
6632
6685
|
dispatchFocus = focusChangeTransaction(state, focus);
|
|
6633
6686
|
if (!dispatchFocus)
|
|
6634
|
-
focusFlag = 1 /*
|
|
6687
|
+
focusFlag = 1 /* Focus */;
|
|
6635
6688
|
}
|
|
6636
6689
|
// If there was a pending DOM change, eagerly read it and try to
|
|
6637
6690
|
// apply it after the given transactions.
|
|
@@ -6654,7 +6707,7 @@ class EditorView {
|
|
|
6654
6707
|
update.flags |= focusFlag;
|
|
6655
6708
|
let scrollTarget = this.viewState.scrollTarget;
|
|
6656
6709
|
try {
|
|
6657
|
-
this.updateState = 2 /*
|
|
6710
|
+
this.updateState = 2 /* Updating */;
|
|
6658
6711
|
for (let tr of transactions) {
|
|
6659
6712
|
if (scrollTarget)
|
|
6660
6713
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
@@ -6680,7 +6733,7 @@ class EditorView {
|
|
|
6680
6733
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6681
6734
|
}
|
|
6682
6735
|
finally {
|
|
6683
|
-
this.updateState = 0 /*
|
|
6736
|
+
this.updateState = 0 /* Idle */;
|
|
6684
6737
|
}
|
|
6685
6738
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6686
6739
|
this.viewState.mustMeasureContent = true;
|
|
@@ -6707,13 +6760,13 @@ class EditorView {
|
|
|
6707
6760
|
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
|
|
6708
6761
|
*/
|
|
6709
6762
|
setState(newState) {
|
|
6710
|
-
if (this.updateState != 0 /*
|
|
6763
|
+
if (this.updateState != 0 /* Idle */)
|
|
6711
6764
|
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
|
|
6712
6765
|
if (this.destroyed) {
|
|
6713
6766
|
this.viewState.state = newState;
|
|
6714
6767
|
return;
|
|
6715
6768
|
}
|
|
6716
|
-
this.updateState = 2 /*
|
|
6769
|
+
this.updateState = 2 /* Updating */;
|
|
6717
6770
|
let hadFocus = this.hasFocus;
|
|
6718
6771
|
try {
|
|
6719
6772
|
for (let plugin of this.plugins)
|
|
@@ -6730,7 +6783,7 @@ class EditorView {
|
|
|
6730
6783
|
this.bidiCache = [];
|
|
6731
6784
|
}
|
|
6732
6785
|
finally {
|
|
6733
|
-
this.updateState = 0 /*
|
|
6786
|
+
this.updateState = 0 /* Idle */;
|
|
6734
6787
|
}
|
|
6735
6788
|
if (hadFocus)
|
|
6736
6789
|
this.focus();
|
|
@@ -6777,13 +6830,23 @@ class EditorView {
|
|
|
6777
6830
|
if (flush)
|
|
6778
6831
|
this.observer.forceFlush();
|
|
6779
6832
|
let updated = null;
|
|
6780
|
-
let
|
|
6781
|
-
|
|
6833
|
+
let sDOM = this.scrollDOM, { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
|
|
6834
|
+
this.viewState.scrollAnchorHeight = -1;
|
|
6835
|
+
if (scrollAnchorHeight < 0 || sDOM.scrollTop != this.viewState.scrollTop) {
|
|
6836
|
+
if (sDOM.scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
|
|
6837
|
+
scrollAnchorPos = -1;
|
|
6838
|
+
scrollAnchorHeight = this.viewState.heightMap.height;
|
|
6839
|
+
}
|
|
6840
|
+
else {
|
|
6841
|
+
let block = this.viewState.lineBlockAtHeight(sDOM.scrollTop);
|
|
6842
|
+
scrollAnchorPos = block.from;
|
|
6843
|
+
scrollAnchorHeight = block.top;
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6782
6846
|
try {
|
|
6783
6847
|
for (let i = 0;; i++) {
|
|
6784
|
-
this.updateState = 1 /*
|
|
6848
|
+
this.updateState = 1 /* Measuring */;
|
|
6785
6849
|
let oldViewport = this.viewport;
|
|
6786
|
-
let refBlock = this.viewState.lineBlockAtHeight(refHeight);
|
|
6787
6850
|
let changed = this.viewState.measure(this);
|
|
6788
6851
|
if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
|
|
6789
6852
|
break;
|
|
@@ -6795,7 +6858,7 @@ class EditorView {
|
|
|
6795
6858
|
}
|
|
6796
6859
|
let measuring = [];
|
|
6797
6860
|
// Only run measure requests in this cycle when the viewport didn't change
|
|
6798
|
-
if (!(changed & 4 /*
|
|
6861
|
+
if (!(changed & 4 /* Viewport */))
|
|
6799
6862
|
[this.measureRequests, measuring] = [measuring, this.measureRequests];
|
|
6800
6863
|
let measured = measuring.map(m => {
|
|
6801
6864
|
try {
|
|
@@ -6812,7 +6875,7 @@ class EditorView {
|
|
|
6812
6875
|
updated = update;
|
|
6813
6876
|
else
|
|
6814
6877
|
updated.flags |= changed;
|
|
6815
|
-
this.updateState = 2 /*
|
|
6878
|
+
this.updateState = 2 /* Updating */;
|
|
6816
6879
|
if (!update.empty) {
|
|
6817
6880
|
this.updatePlugins(update);
|
|
6818
6881
|
this.inputState.update(update);
|
|
@@ -6836,10 +6899,12 @@ class EditorView {
|
|
|
6836
6899
|
this.viewState.scrollTarget = null;
|
|
6837
6900
|
scrolled = true;
|
|
6838
6901
|
}
|
|
6839
|
-
else {
|
|
6840
|
-
let
|
|
6902
|
+
else if (scrollAnchorHeight > -1) {
|
|
6903
|
+
let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :
|
|
6904
|
+
this.viewState.lineBlockAt(scrollAnchorPos).top;
|
|
6905
|
+
let diff = newAnchorHeight - scrollAnchorHeight;
|
|
6841
6906
|
if (diff > 1 || diff < -1) {
|
|
6842
|
-
|
|
6907
|
+
sDOM.scrollTop += diff;
|
|
6843
6908
|
scrolled = true;
|
|
6844
6909
|
}
|
|
6845
6910
|
}
|
|
@@ -6849,10 +6914,11 @@ class EditorView {
|
|
|
6849
6914
|
if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
|
|
6850
6915
|
!scrolled && this.measureRequests.length == 0)
|
|
6851
6916
|
break;
|
|
6917
|
+
scrollAnchorHeight = -1;
|
|
6852
6918
|
}
|
|
6853
6919
|
}
|
|
6854
6920
|
finally {
|
|
6855
|
-
this.updateState = 0 /*
|
|
6921
|
+
this.updateState = 0 /* Idle */;
|
|
6856
6922
|
this.measureScheduled = -1;
|
|
6857
6923
|
}
|
|
6858
6924
|
if (updated && !updated.empty)
|
|
@@ -6911,9 +6977,9 @@ class EditorView {
|
|
|
6911
6977
|
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse());
|
|
6912
6978
|
}
|
|
6913
6979
|
readMeasured() {
|
|
6914
|
-
if (this.updateState == 2 /*
|
|
6980
|
+
if (this.updateState == 2 /* Updating */)
|
|
6915
6981
|
throw new Error("Reading the editor layout isn't allowed during an update");
|
|
6916
|
-
if (this.updateState == 0 /*
|
|
6982
|
+
if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
|
|
6917
6983
|
this.measure(false);
|
|
6918
6984
|
}
|
|
6919
6985
|
/**
|
|
@@ -7707,15 +7773,6 @@ function wrappedLine(view, pos, inside) {
|
|
|
7707
7773
|
to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
|
|
7708
7774
|
type: BlockType.Text };
|
|
7709
7775
|
}
|
|
7710
|
-
function blockAt(view, pos) {
|
|
7711
|
-
let line = view.lineBlockAt(pos);
|
|
7712
|
-
if (Array.isArray(line.type))
|
|
7713
|
-
for (let l of line.type) {
|
|
7714
|
-
if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
|
|
7715
|
-
return l;
|
|
7716
|
-
}
|
|
7717
|
-
return line;
|
|
7718
|
-
}
|
|
7719
7776
|
function rectanglesForRange(view, className, range) {
|
|
7720
7777
|
if (range.to <= view.viewport.from || range.from >= view.viewport.to)
|
|
7721
7778
|
return [];
|
|
@@ -7729,12 +7786,10 @@ function rectanglesForRange(view, className, range) {
|
|
|
7729
7786
|
let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
|
|
7730
7787
|
let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
|
|
7731
7788
|
let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
|
|
7732
|
-
if (view.lineWrapping)
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
visualEnd = wrappedLine(view, to, visualEnd);
|
|
7737
|
-
}
|
|
7789
|
+
if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
|
|
7790
|
+
visualStart = wrappedLine(view, from, visualStart);
|
|
7791
|
+
if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
|
|
7792
|
+
visualEnd = wrappedLine(view, to, visualEnd);
|
|
7738
7793
|
if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
|
|
7739
7794
|
return pieces(drawForLine(range.from, range.to, visualStart));
|
|
7740
7795
|
}
|
|
@@ -7742,14 +7797,15 @@ function rectanglesForRange(view, className, range) {
|
|
|
7742
7797
|
let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
|
|
7743
7798
|
let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
|
|
7744
7799
|
let between = [];
|
|
7745
|
-
if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0)
|
|
7800
|
+
if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||
|
|
7801
|
+
startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)
|
|
7746
7802
|
between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
|
|
7747
7803
|
else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)
|
|
7748
7804
|
top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
|
|
7749
7805
|
return pieces(top).concat(between).concat(pieces(bottom));
|
|
7750
7806
|
}
|
|
7751
7807
|
function piece(left, top, right, bottom) {
|
|
7752
|
-
return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /*
|
|
7808
|
+
return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */);
|
|
7753
7809
|
}
|
|
7754
7810
|
function pieces({ top, bottom, horizontal }) {
|
|
7755
7811
|
let pieces = [];
|
|
@@ -8764,12 +8820,12 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8764
8820
|
continue;
|
|
8765
8821
|
}
|
|
8766
8822
|
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
8767
|
-
let arrowHeight = arrow ? 7 /*
|
|
8823
|
+
let arrowHeight = arrow ? 7 /* Size */ : 0;
|
|
8768
8824
|
let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
|
|
8769
8825
|
let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
|
|
8770
8826
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
8771
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /*
|
|
8772
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /*
|
|
8827
|
+
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
|
|
8828
|
+
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
|
|
8773
8829
|
let above = !!tooltip.above;
|
|
8774
8830
|
if (!tooltip.strictSide && (above
|
|
8775
8831
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
@@ -8803,7 +8859,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
8803
8859
|
dom.style.left = left + "px";
|
|
8804
8860
|
}
|
|
8805
8861
|
if (arrow)
|
|
8806
|
-
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /*
|
|
8862
|
+
arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
|
|
8807
8863
|
if (tView.overlap !== true)
|
|
8808
8864
|
others.push({ left, top, right, bottom: top + height });
|
|
8809
8865
|
dom.classList.toggle("cm-tooltip-above", above);
|
|
@@ -8846,8 +8902,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8846
8902
|
color: "white"
|
|
8847
8903
|
},
|
|
8848
8904
|
".cm-tooltip-arrow": {
|
|
8849
|
-
height: `${7 /*
|
|
8850
|
-
width: `${7 /*
|
|
8905
|
+
height: `${7 /* Size */}px`,
|
|
8906
|
+
width: `${7 /* Size */ * 2}px`,
|
|
8851
8907
|
position: "absolute",
|
|
8852
8908
|
zIndex: -1,
|
|
8853
8909
|
overflow: "hidden",
|
|
@@ -8856,26 +8912,26 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
8856
8912
|
position: "absolute",
|
|
8857
8913
|
width: 0,
|
|
8858
8914
|
height: 0,
|
|
8859
|
-
borderLeft: `${7 /*
|
|
8860
|
-
borderRight: `${7 /*
|
|
8915
|
+
borderLeft: `${7 /* Size */}px solid transparent`,
|
|
8916
|
+
borderRight: `${7 /* Size */}px solid transparent`,
|
|
8861
8917
|
},
|
|
8862
8918
|
".cm-tooltip-above &": {
|
|
8863
|
-
bottom: `-${7 /*
|
|
8919
|
+
bottom: `-${7 /* Size */}px`,
|
|
8864
8920
|
"&:before": {
|
|
8865
|
-
borderTop: `${7 /*
|
|
8921
|
+
borderTop: `${7 /* Size */}px solid #bbb`,
|
|
8866
8922
|
},
|
|
8867
8923
|
"&:after": {
|
|
8868
|
-
borderTop: `${7 /*
|
|
8924
|
+
borderTop: `${7 /* Size */}px solid #f5f5f5`,
|
|
8869
8925
|
bottom: "1px"
|
|
8870
8926
|
}
|
|
8871
8927
|
},
|
|
8872
8928
|
".cm-tooltip-below &": {
|
|
8873
|
-
top: `-${7 /*
|
|
8929
|
+
top: `-${7 /* Size */}px`,
|
|
8874
8930
|
"&:before": {
|
|
8875
|
-
borderBottom: `${7 /*
|
|
8931
|
+
borderBottom: `${7 /* Size */}px solid #bbb`,
|
|
8876
8932
|
},
|
|
8877
8933
|
"&:after": {
|
|
8878
|
-
borderBottom: `${7 /*
|
|
8934
|
+
borderBottom: `${7 /* Size */}px solid #f5f5f5`,
|
|
8879
8935
|
top: "1px"
|
|
8880
8936
|
}
|
|
8881
8937
|
},
|
|
@@ -8900,10 +8956,6 @@ const showTooltip = /*@__PURE__*/Facet.define({
|
|
|
8900
8956
|
});
|
|
8901
8957
|
const showHoverTooltip = /*@__PURE__*/Facet.define();
|
|
8902
8958
|
class HoverTooltipHost {
|
|
8903
|
-
// Needs to be static so that host tooltip instances always match
|
|
8904
|
-
static create(view) {
|
|
8905
|
-
return new HoverTooltipHost(view);
|
|
8906
|
-
}
|
|
8907
8959
|
constructor(view) {
|
|
8908
8960
|
this.view = view;
|
|
8909
8961
|
this.mounted = false;
|
|
@@ -8911,6 +8963,10 @@ class HoverTooltipHost {
|
|
|
8911
8963
|
this.dom.classList.add("cm-tooltip-hover");
|
|
8912
8964
|
this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
|
|
8913
8965
|
}
|
|
8966
|
+
// Needs to be static so that host tooltip instances always match
|
|
8967
|
+
static create(view) {
|
|
8968
|
+
return new HoverTooltipHost(view);
|
|
8969
|
+
}
|
|
8914
8970
|
createHostedView(tooltip) {
|
|
8915
8971
|
let hostedView = tooltip.create(this.view);
|
|
8916
8972
|
hostedView.dom.classList.add("cm-tooltip-section");
|
|
@@ -9025,7 +9081,7 @@ class HoverPlugin {
|
|
|
9025
9081
|
if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
|
|
9026
9082
|
let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
|
|
9027
9083
|
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
9028
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /*
|
|
9084
|
+
: !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
|
|
9029
9085
|
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
9030
9086
|
this.pending = null;
|
|
9031
9087
|
}
|
|
@@ -9107,7 +9163,7 @@ function hoverTooltip(source, options = {}) {
|
|
|
9107
9163
|
});
|
|
9108
9164
|
return [
|
|
9109
9165
|
hoverState,
|
|
9110
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /*
|
|
9166
|
+
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
|
|
9111
9167
|
showHoverTooltipHost
|
|
9112
9168
|
];
|
|
9113
9169
|
}
|