@codemirror/view 6.22.2 → 6.23.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 +30 -0
- package/dist/index.cjs +611 -546
- package/dist/index.d.cts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +611 -546
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Text, RangeSet, MapMode, RangeValue,
|
|
1
|
+
import { Text, RangeSet, MapMode, RangeValue, findClusterBreak, EditorSelection, Facet, StateEffect, ChangeSet, findColumn, CharCategory, Annotation, EditorState, Transaction, Prec, 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
|
|
|
@@ -869,7 +869,8 @@ class WidgetView extends ContentView {
|
|
|
869
869
|
this.prevWidget.destroy(this.dom);
|
|
870
870
|
this.prevWidget = null;
|
|
871
871
|
this.setDOM(this.widget.toDOM(view));
|
|
872
|
-
this.
|
|
872
|
+
if (!this.widget.editable)
|
|
873
|
+
this.dom.contentEditable = "false";
|
|
873
874
|
}
|
|
874
875
|
}
|
|
875
876
|
getSide() { return this.side; }
|
|
@@ -1292,7 +1293,8 @@ class BlockWidgetView extends ContentView {
|
|
|
1292
1293
|
this.prevWidget.destroy(this.dom);
|
|
1293
1294
|
this.prevWidget = null;
|
|
1294
1295
|
this.setDOM(this.widget.toDOM(view));
|
|
1295
|
-
this.
|
|
1296
|
+
if (!this.widget.editable)
|
|
1297
|
+
this.dom.contentEditable = "false";
|
|
1296
1298
|
}
|
|
1297
1299
|
}
|
|
1298
1300
|
get overrideDOMText() {
|
|
@@ -1397,6 +1399,10 @@ class WidgetType {
|
|
|
1397
1399
|
*/
|
|
1398
1400
|
get isHidden() { return false; }
|
|
1399
1401
|
/**
|
|
1402
|
+
@internal
|
|
1403
|
+
*/
|
|
1404
|
+
get editable() { return false; }
|
|
1405
|
+
/**
|
|
1400
1406
|
This is called when the an instance of the widget is removed
|
|
1401
1407
|
from the editor view.
|
|
1402
1408
|
*/
|
|
@@ -1782,486 +1788,123 @@ class NullWidget extends WidgetType {
|
|
|
1782
1788
|
get isHidden() { return true; }
|
|
1783
1789
|
}
|
|
1784
1790
|
|
|
1785
|
-
const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
|
|
1786
|
-
const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
|
|
1787
|
-
const mouseSelectionStyle = /*@__PURE__*/Facet.define();
|
|
1788
|
-
const exceptionSink = /*@__PURE__*/Facet.define();
|
|
1789
|
-
const updateListener = /*@__PURE__*/Facet.define();
|
|
1790
|
-
const inputHandler = /*@__PURE__*/Facet.define();
|
|
1791
|
-
const focusChangeEffect = /*@__PURE__*/Facet.define();
|
|
1792
|
-
const perLineTextDirection = /*@__PURE__*/Facet.define({
|
|
1793
|
-
combine: values => values.some(x => x)
|
|
1794
|
-
});
|
|
1795
|
-
const nativeSelectionHidden = /*@__PURE__*/Facet.define({
|
|
1796
|
-
combine: values => values.some(x => x)
|
|
1797
|
-
});
|
|
1798
|
-
class ScrollTarget {
|
|
1799
|
-
constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5,
|
|
1800
|
-
// This data structure is abused to also store precise scroll
|
|
1801
|
-
// snapshots, instead of a `scrollIntoView` request. When this
|
|
1802
|
-
// flag is `true`, `range` points at a position in the reference
|
|
1803
|
-
// line, `yMargin` holds the difference between the top of that
|
|
1804
|
-
// line and the top of the editor, and `xMargin` holds the
|
|
1805
|
-
// editor's `scrollLeft`.
|
|
1806
|
-
isSnapshot = false) {
|
|
1807
|
-
this.range = range;
|
|
1808
|
-
this.y = y;
|
|
1809
|
-
this.x = x;
|
|
1810
|
-
this.yMargin = yMargin;
|
|
1811
|
-
this.xMargin = xMargin;
|
|
1812
|
-
this.isSnapshot = isSnapshot;
|
|
1813
|
-
}
|
|
1814
|
-
map(changes) {
|
|
1815
|
-
return changes.empty ? this :
|
|
1816
|
-
new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
|
|
1817
|
-
}
|
|
1818
|
-
clip(state) {
|
|
1819
|
-
return this.range.to <= state.doc.length ? this :
|
|
1820
|
-
new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
const scrollIntoView = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });
|
|
1824
1791
|
/**
|
|
1825
|
-
|
|
1826
|
-
probably only be used by extension code that allows client code to
|
|
1827
|
-
provide functions, and calls those functions in a context where an
|
|
1828
|
-
exception can't be propagated to calling code in a reasonable way
|
|
1829
|
-
(for example when in an event handler).
|
|
1830
|
-
|
|
1831
|
-
Either calls a handler registered with
|
|
1832
|
-
[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
|
|
1833
|
-
`window.onerror`, if defined, or `console.error` (in which case
|
|
1834
|
-
it'll pass `context`, when given, as first argument).
|
|
1792
|
+
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
1835
1793
|
*/
|
|
1836
|
-
function
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1794
|
+
var Direction = /*@__PURE__*/(function (Direction) {
|
|
1795
|
+
// (These are chosen to match the base levels, in bidi algorithm
|
|
1796
|
+
// terms, of spans in that direction.)
|
|
1797
|
+
/**
|
|
1798
|
+
Left-to-right.
|
|
1799
|
+
*/
|
|
1800
|
+
Direction[Direction["LTR"] = 0] = "LTR";
|
|
1801
|
+
/**
|
|
1802
|
+
Right-to-left.
|
|
1803
|
+
*/
|
|
1804
|
+
Direction[Direction["RTL"] = 1] = "RTL";
|
|
1805
|
+
return Direction})(Direction || (Direction = {}));
|
|
1806
|
+
const LTR = Direction.LTR, RTL = Direction.RTL;
|
|
1807
|
+
// Decode a string with each type encoded as log2(type)
|
|
1808
|
+
function dec(str) {
|
|
1809
|
+
let result = [];
|
|
1810
|
+
for (let i = 0; i < str.length; i++)
|
|
1811
|
+
result.push(1 << +str[i]);
|
|
1812
|
+
return result;
|
|
1846
1813
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1814
|
+
// Character types for codepoints 0 to 0xf8
|
|
1815
|
+
const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
|
|
1816
|
+
// Character types for codepoints 0x600 to 0x6f9
|
|
1817
|
+
const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
|
|
1818
|
+
const Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];
|
|
1819
|
+
// There's a lot more in
|
|
1820
|
+
// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
|
|
1821
|
+
// which are left out to keep code size down.
|
|
1822
|
+
for (let p of ["()", "[]", "{}"]) {
|
|
1823
|
+
let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
|
|
1824
|
+
Brackets[l] = r;
|
|
1825
|
+
Brackets[r] = -l;
|
|
1826
|
+
}
|
|
1827
|
+
function charType(ch) {
|
|
1828
|
+
return ch <= 0xf7 ? LowTypes[ch] :
|
|
1829
|
+
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
1830
|
+
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
1831
|
+
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
1832
|
+
0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :
|
|
1833
|
+
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;
|
|
1834
|
+
}
|
|
1835
|
+
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
1850
1836
|
/**
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
that happen in the view.
|
|
1837
|
+
Represents a contiguous range of text that has a single direction
|
|
1838
|
+
(as in left-to-right or right-to-left).
|
|
1854
1839
|
*/
|
|
1855
|
-
class
|
|
1856
|
-
constructor(
|
|
1840
|
+
class BidiSpan {
|
|
1857
1841
|
/**
|
|
1858
|
-
|
|
1842
|
+
The direction of this span.
|
|
1859
1843
|
*/
|
|
1860
|
-
|
|
1844
|
+
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
1861
1845
|
/**
|
|
1862
1846
|
@internal
|
|
1863
1847
|
*/
|
|
1864
|
-
|
|
1848
|
+
constructor(
|
|
1865
1849
|
/**
|
|
1866
|
-
|
|
1850
|
+
The start of the span (relative to the start of the line).
|
|
1867
1851
|
*/
|
|
1868
|
-
|
|
1852
|
+
from,
|
|
1869
1853
|
/**
|
|
1870
|
-
|
|
1854
|
+
The end of the span.
|
|
1871
1855
|
*/
|
|
1872
|
-
|
|
1873
|
-
this.id = id;
|
|
1874
|
-
this.create = create;
|
|
1875
|
-
this.domEventHandlers = domEventHandlers;
|
|
1876
|
-
this.domEventObservers = domEventObservers;
|
|
1877
|
-
this.extension = buildExtensions(this);
|
|
1878
|
-
}
|
|
1856
|
+
to,
|
|
1879
1857
|
/**
|
|
1880
|
-
|
|
1881
|
-
|
|
1858
|
+
The ["bidi
|
|
1859
|
+
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
1860
|
+
of the span (in this context, 0 means
|
|
1861
|
+
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
1862
|
+
number inside right-to-left text).
|
|
1882
1863
|
*/
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
if (deco)
|
|
1888
|
-
ext.push(decorations.of(view => {
|
|
1889
|
-
let pluginInst = view.plugin(plugin);
|
|
1890
|
-
return pluginInst ? deco(pluginInst) : Decoration.none;
|
|
1891
|
-
}));
|
|
1892
|
-
if (provide)
|
|
1893
|
-
ext.push(provide(plugin));
|
|
1894
|
-
return ext;
|
|
1895
|
-
});
|
|
1864
|
+
level) {
|
|
1865
|
+
this.from = from;
|
|
1866
|
+
this.to = to;
|
|
1867
|
+
this.level = level;
|
|
1896
1868
|
}
|
|
1897
1869
|
/**
|
|
1898
|
-
|
|
1899
|
-
editor view as argument.
|
|
1870
|
+
@internal
|
|
1900
1871
|
*/
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
this.value = this.spec.create(view);
|
|
1922
|
-
}
|
|
1923
|
-
catch (e) {
|
|
1924
|
-
logException(view.state, e, "CodeMirror plugin crashed");
|
|
1925
|
-
this.deactivate();
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
else if (this.mustUpdate) {
|
|
1930
|
-
let update = this.mustUpdate;
|
|
1931
|
-
this.mustUpdate = null;
|
|
1932
|
-
if (this.value.update) {
|
|
1933
|
-
try {
|
|
1934
|
-
this.value.update(update);
|
|
1935
|
-
}
|
|
1936
|
-
catch (e) {
|
|
1937
|
-
logException(update.state, e, "CodeMirror plugin crashed");
|
|
1938
|
-
if (this.value.destroy)
|
|
1939
|
-
try {
|
|
1940
|
-
this.value.destroy();
|
|
1941
|
-
}
|
|
1942
|
-
catch (_) { }
|
|
1943
|
-
this.deactivate();
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
return this;
|
|
1948
|
-
}
|
|
1949
|
-
destroy(view) {
|
|
1950
|
-
var _a;
|
|
1951
|
-
if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
|
|
1952
|
-
try {
|
|
1953
|
-
this.value.destroy();
|
|
1954
|
-
}
|
|
1955
|
-
catch (e) {
|
|
1956
|
-
logException(view.state, e, "CodeMirror plugin crashed");
|
|
1872
|
+
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
1873
|
+
/**
|
|
1874
|
+
@internal
|
|
1875
|
+
*/
|
|
1876
|
+
forward(forward, dir) { return forward == (this.dir == dir); }
|
|
1877
|
+
/**
|
|
1878
|
+
@internal
|
|
1879
|
+
*/
|
|
1880
|
+
static find(order, index, level, assoc) {
|
|
1881
|
+
let maybe = -1;
|
|
1882
|
+
for (let i = 0; i < order.length; i++) {
|
|
1883
|
+
let span = order[i];
|
|
1884
|
+
if (span.from <= index && span.to >= index) {
|
|
1885
|
+
if (span.level == level)
|
|
1886
|
+
return i;
|
|
1887
|
+
// When multiple spans match, if assoc != 0, take the one that
|
|
1888
|
+
// covers that side, otherwise take the one with the minimum
|
|
1889
|
+
// level.
|
|
1890
|
+
if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
|
|
1891
|
+
maybe = i;
|
|
1957
1892
|
}
|
|
1958
1893
|
}
|
|
1894
|
+
if (maybe < 0)
|
|
1895
|
+
throw new RangeError("Index out of range");
|
|
1896
|
+
return maybe;
|
|
1959
1897
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1898
|
+
}
|
|
1899
|
+
function isolatesEq(a, b) {
|
|
1900
|
+
if (a.length != b.length)
|
|
1901
|
+
return false;
|
|
1902
|
+
for (let i = 0; i < a.length; i++) {
|
|
1903
|
+
let iA = a[i], iB = b[i];
|
|
1904
|
+
if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))
|
|
1905
|
+
return false;
|
|
1962
1906
|
}
|
|
1963
|
-
|
|
1964
|
-
const editorAttributes = /*@__PURE__*/Facet.define();
|
|
1965
|
-
const contentAttributes = /*@__PURE__*/Facet.define();
|
|
1966
|
-
// Provide decorations
|
|
1967
|
-
const decorations = /*@__PURE__*/Facet.define();
|
|
1968
|
-
const atomicRanges = /*@__PURE__*/Facet.define();
|
|
1969
|
-
const bidiIsolatedRanges = /*@__PURE__*/Facet.define();
|
|
1970
|
-
function getIsolatedRanges(view, from, to) {
|
|
1971
|
-
let isolates = view.state.facet(bidiIsolatedRanges);
|
|
1972
|
-
if (!isolates.length)
|
|
1973
|
-
return isolates;
|
|
1974
|
-
let sets = isolates.map(i => i instanceof Function ? i(view) : i);
|
|
1975
|
-
let result = [];
|
|
1976
|
-
RangeSet.spans(sets, from, to, {
|
|
1977
|
-
point() { },
|
|
1978
|
-
span(from, to, active, open) {
|
|
1979
|
-
let level = result;
|
|
1980
|
-
for (let i = active.length - 1; i >= 0; i--, open--) {
|
|
1981
|
-
let iso = active[i].spec.bidiIsolate, update;
|
|
1982
|
-
if (iso == null)
|
|
1983
|
-
continue;
|
|
1984
|
-
if (open > 0 && level.length &&
|
|
1985
|
-
(update = level[level.length - 1]).to == from && update.direction == iso) {
|
|
1986
|
-
update.to = to;
|
|
1987
|
-
level = update.inner;
|
|
1988
|
-
}
|
|
1989
|
-
else {
|
|
1990
|
-
let add = { from, to, direction: iso, inner: [] };
|
|
1991
|
-
level.push(add);
|
|
1992
|
-
level = add.inner;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
});
|
|
1997
|
-
return result;
|
|
1998
|
-
}
|
|
1999
|
-
const scrollMargins = /*@__PURE__*/Facet.define();
|
|
2000
|
-
function getScrollMargins(view) {
|
|
2001
|
-
let left = 0, right = 0, top = 0, bottom = 0;
|
|
2002
|
-
for (let source of view.state.facet(scrollMargins)) {
|
|
2003
|
-
let m = source(view);
|
|
2004
|
-
if (m) {
|
|
2005
|
-
if (m.left != null)
|
|
2006
|
-
left = Math.max(left, m.left);
|
|
2007
|
-
if (m.right != null)
|
|
2008
|
-
right = Math.max(right, m.right);
|
|
2009
|
-
if (m.top != null)
|
|
2010
|
-
top = Math.max(top, m.top);
|
|
2011
|
-
if (m.bottom != null)
|
|
2012
|
-
bottom = Math.max(bottom, m.bottom);
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
return { left, right, top, bottom };
|
|
2016
|
-
}
|
|
2017
|
-
const styleModule = /*@__PURE__*/Facet.define();
|
|
2018
|
-
class ChangedRange {
|
|
2019
|
-
constructor(fromA, toA, fromB, toB) {
|
|
2020
|
-
this.fromA = fromA;
|
|
2021
|
-
this.toA = toA;
|
|
2022
|
-
this.fromB = fromB;
|
|
2023
|
-
this.toB = toB;
|
|
2024
|
-
}
|
|
2025
|
-
join(other) {
|
|
2026
|
-
return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
|
|
2027
|
-
}
|
|
2028
|
-
addToSet(set) {
|
|
2029
|
-
let i = set.length, me = this;
|
|
2030
|
-
for (; i > 0; i--) {
|
|
2031
|
-
let range = set[i - 1];
|
|
2032
|
-
if (range.fromA > me.toA)
|
|
2033
|
-
continue;
|
|
2034
|
-
if (range.toA < me.fromA)
|
|
2035
|
-
break;
|
|
2036
|
-
me = me.join(range);
|
|
2037
|
-
set.splice(i - 1, 1);
|
|
2038
|
-
}
|
|
2039
|
-
set.splice(i, 0, me);
|
|
2040
|
-
return set;
|
|
2041
|
-
}
|
|
2042
|
-
static extendWithRanges(diff, ranges) {
|
|
2043
|
-
if (ranges.length == 0)
|
|
2044
|
-
return diff;
|
|
2045
|
-
let result = [];
|
|
2046
|
-
for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
|
|
2047
|
-
let next = dI == diff.length ? null : diff[dI], off = posA - posB;
|
|
2048
|
-
let end = next ? next.fromB : 1e9;
|
|
2049
|
-
while (rI < ranges.length && ranges[rI] < end) {
|
|
2050
|
-
let from = ranges[rI], to = ranges[rI + 1];
|
|
2051
|
-
let fromB = Math.max(posB, from), toB = Math.min(end, to);
|
|
2052
|
-
if (fromB <= toB)
|
|
2053
|
-
new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
|
|
2054
|
-
if (to > end)
|
|
2055
|
-
break;
|
|
2056
|
-
else
|
|
2057
|
-
rI += 2;
|
|
2058
|
-
}
|
|
2059
|
-
if (!next)
|
|
2060
|
-
return result;
|
|
2061
|
-
new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
|
|
2062
|
-
posA = next.toA;
|
|
2063
|
-
posB = next.toB;
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
/**
|
|
2068
|
-
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
2069
|
-
class, which describe what happened, whenever the view is updated.
|
|
2070
|
-
*/
|
|
2071
|
-
class ViewUpdate {
|
|
2072
|
-
constructor(
|
|
2073
|
-
/**
|
|
2074
|
-
The editor view that the update is associated with.
|
|
2075
|
-
*/
|
|
2076
|
-
view,
|
|
2077
|
-
/**
|
|
2078
|
-
The new editor state.
|
|
2079
|
-
*/
|
|
2080
|
-
state,
|
|
2081
|
-
/**
|
|
2082
|
-
The transactions involved in the update. May be empty.
|
|
2083
|
-
*/
|
|
2084
|
-
transactions) {
|
|
2085
|
-
this.view = view;
|
|
2086
|
-
this.state = state;
|
|
2087
|
-
this.transactions = transactions;
|
|
2088
|
-
/**
|
|
2089
|
-
@internal
|
|
2090
|
-
*/
|
|
2091
|
-
this.flags = 0;
|
|
2092
|
-
this.startState = view.state;
|
|
2093
|
-
this.changes = ChangeSet.empty(this.startState.doc.length);
|
|
2094
|
-
for (let tr of transactions)
|
|
2095
|
-
this.changes = this.changes.compose(tr.changes);
|
|
2096
|
-
let changedRanges = [];
|
|
2097
|
-
this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
|
|
2098
|
-
this.changedRanges = changedRanges;
|
|
2099
|
-
}
|
|
2100
|
-
/**
|
|
2101
|
-
@internal
|
|
2102
|
-
*/
|
|
2103
|
-
static create(view, state, transactions) {
|
|
2104
|
-
return new ViewUpdate(view, state, transactions);
|
|
2105
|
-
}
|
|
2106
|
-
/**
|
|
2107
|
-
Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
|
|
2108
|
-
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
|
|
2109
|
-
update.
|
|
2110
|
-
*/
|
|
2111
|
-
get viewportChanged() {
|
|
2112
|
-
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
Indicates whether the height of a block element in the editor
|
|
2116
|
-
changed in this update.
|
|
2117
|
-
*/
|
|
2118
|
-
get heightChanged() {
|
|
2119
|
-
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2120
|
-
}
|
|
2121
|
-
/**
|
|
2122
|
-
Returns true when the document was modified or the size of the
|
|
2123
|
-
editor, or elements within the editor, changed.
|
|
2124
|
-
*/
|
|
2125
|
-
get geometryChanged() {
|
|
2126
|
-
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2127
|
-
}
|
|
2128
|
-
/**
|
|
2129
|
-
True when this update indicates a focus change.
|
|
2130
|
-
*/
|
|
2131
|
-
get focusChanged() {
|
|
2132
|
-
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
Whether the document changed in this update.
|
|
2136
|
-
*/
|
|
2137
|
-
get docChanged() {
|
|
2138
|
-
return !this.changes.empty;
|
|
2139
|
-
}
|
|
2140
|
-
/**
|
|
2141
|
-
Whether the selection was explicitly set in this update.
|
|
2142
|
-
*/
|
|
2143
|
-
get selectionSet() {
|
|
2144
|
-
return this.transactions.some(tr => tr.selection);
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
@internal
|
|
2148
|
-
*/
|
|
2149
|
-
get empty() { return this.flags == 0 && this.transactions.length == 0; }
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
/**
|
|
2153
|
-
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
2154
|
-
*/
|
|
2155
|
-
var Direction = /*@__PURE__*/(function (Direction) {
|
|
2156
|
-
// (These are chosen to match the base levels, in bidi algorithm
|
|
2157
|
-
// terms, of spans in that direction.)
|
|
2158
|
-
/**
|
|
2159
|
-
Left-to-right.
|
|
2160
|
-
*/
|
|
2161
|
-
Direction[Direction["LTR"] = 0] = "LTR";
|
|
2162
|
-
/**
|
|
2163
|
-
Right-to-left.
|
|
2164
|
-
*/
|
|
2165
|
-
Direction[Direction["RTL"] = 1] = "RTL";
|
|
2166
|
-
return Direction})(Direction || (Direction = {}));
|
|
2167
|
-
const LTR = Direction.LTR, RTL = Direction.RTL;
|
|
2168
|
-
// Decode a string with each type encoded as log2(type)
|
|
2169
|
-
function dec(str) {
|
|
2170
|
-
let result = [];
|
|
2171
|
-
for (let i = 0; i < str.length; i++)
|
|
2172
|
-
result.push(1 << +str[i]);
|
|
2173
|
-
return result;
|
|
2174
|
-
}
|
|
2175
|
-
// Character types for codepoints 0 to 0xf8
|
|
2176
|
-
const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
|
|
2177
|
-
// Character types for codepoints 0x600 to 0x6f9
|
|
2178
|
-
const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
|
|
2179
|
-
const Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];
|
|
2180
|
-
// There's a lot more in
|
|
2181
|
-
// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
|
|
2182
|
-
// which are left out to keep code size down.
|
|
2183
|
-
for (let p of ["()", "[]", "{}"]) {
|
|
2184
|
-
let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
|
|
2185
|
-
Brackets[l] = r;
|
|
2186
|
-
Brackets[r] = -l;
|
|
2187
|
-
}
|
|
2188
|
-
function charType(ch) {
|
|
2189
|
-
return ch <= 0xf7 ? LowTypes[ch] :
|
|
2190
|
-
0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
|
|
2191
|
-
0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
|
|
2192
|
-
0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
|
|
2193
|
-
0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :
|
|
2194
|
-
0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;
|
|
2195
|
-
}
|
|
2196
|
-
const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
|
|
2197
|
-
/**
|
|
2198
|
-
Represents a contiguous range of text that has a single direction
|
|
2199
|
-
(as in left-to-right or right-to-left).
|
|
2200
|
-
*/
|
|
2201
|
-
class BidiSpan {
|
|
2202
|
-
/**
|
|
2203
|
-
The direction of this span.
|
|
2204
|
-
*/
|
|
2205
|
-
get dir() { return this.level % 2 ? RTL : LTR; }
|
|
2206
|
-
/**
|
|
2207
|
-
@internal
|
|
2208
|
-
*/
|
|
2209
|
-
constructor(
|
|
2210
|
-
/**
|
|
2211
|
-
The start of the span (relative to the start of the line).
|
|
2212
|
-
*/
|
|
2213
|
-
from,
|
|
2214
|
-
/**
|
|
2215
|
-
The end of the span.
|
|
2216
|
-
*/
|
|
2217
|
-
to,
|
|
2218
|
-
/**
|
|
2219
|
-
The ["bidi
|
|
2220
|
-
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
2221
|
-
of the span (in this context, 0 means
|
|
2222
|
-
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
2223
|
-
number inside right-to-left text).
|
|
2224
|
-
*/
|
|
2225
|
-
level) {
|
|
2226
|
-
this.from = from;
|
|
2227
|
-
this.to = to;
|
|
2228
|
-
this.level = level;
|
|
2229
|
-
}
|
|
2230
|
-
/**
|
|
2231
|
-
@internal
|
|
2232
|
-
*/
|
|
2233
|
-
side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
|
|
2234
|
-
/**
|
|
2235
|
-
@internal
|
|
2236
|
-
*/
|
|
2237
|
-
static find(order, index, level, assoc) {
|
|
2238
|
-
let maybe = -1;
|
|
2239
|
-
for (let i = 0; i < order.length; i++) {
|
|
2240
|
-
let span = order[i];
|
|
2241
|
-
if (span.from <= index && span.to >= index) {
|
|
2242
|
-
if (span.level == level)
|
|
2243
|
-
return i;
|
|
2244
|
-
// When multiple spans match, if assoc != 0, take the one that
|
|
2245
|
-
// covers that side, otherwise take the one with the minimum
|
|
2246
|
-
// level.
|
|
2247
|
-
if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
|
|
2248
|
-
maybe = i;
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
if (maybe < 0)
|
|
2252
|
-
throw new RangeError("Index out of range");
|
|
2253
|
-
return maybe;
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
function isolatesEq(a, b) {
|
|
2257
|
-
if (a.length != b.length)
|
|
2258
|
-
return false;
|
|
2259
|
-
for (let i = 0; i < a.length; i++) {
|
|
2260
|
-
let iA = a[i], iB = b[i];
|
|
2261
|
-
if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))
|
|
2262
|
-
return false;
|
|
2263
|
-
}
|
|
2264
|
-
return true;
|
|
1907
|
+
return true;
|
|
2265
1908
|
}
|
|
2266
1909
|
// Reused array of character types
|
|
2267
1910
|
const types = [];
|
|
@@ -2546,80 +2189,455 @@ function emitSpans(line, from, to, level, baseLevel, isolates, order) {
|
|
|
2546
2189
|
else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
|
|
2547
2190
|
break;
|
|
2548
2191
|
}
|
|
2549
|
-
else {
|
|
2550
|
-
iScan--;
|
|
2192
|
+
else {
|
|
2193
|
+
iScan--;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
if (recurse)
|
|
2197
|
+
emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
|
|
2198
|
+
else if (iScan < iCh)
|
|
2199
|
+
order.push(new BidiSpan(iScan, iCh, localLevel));
|
|
2200
|
+
iCh = iScan;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
function computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {
|
|
2205
|
+
let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);
|
|
2206
|
+
computeCharTypes(line, from, to, isolates, outerType);
|
|
2207
|
+
processBracketPairs(line, from, to, isolates, outerType);
|
|
2208
|
+
processNeutrals(from, to, isolates, outerType);
|
|
2209
|
+
emitSpans(line, from, to, level, baseLevel, isolates, order);
|
|
2210
|
+
}
|
|
2211
|
+
function computeOrder(line, direction, isolates) {
|
|
2212
|
+
if (!line)
|
|
2213
|
+
return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];
|
|
2214
|
+
if (direction == LTR && !isolates.length && !BidiRE.test(line))
|
|
2215
|
+
return trivialOrder(line.length);
|
|
2216
|
+
if (isolates.length)
|
|
2217
|
+
while (line.length > types.length)
|
|
2218
|
+
types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps
|
|
2219
|
+
let order = [], level = direction == LTR ? 0 : 1;
|
|
2220
|
+
computeSectionOrder(line, level, level, isolates, 0, line.length, order);
|
|
2221
|
+
return order;
|
|
2222
|
+
}
|
|
2223
|
+
function trivialOrder(length) {
|
|
2224
|
+
return [new BidiSpan(0, length, 0)];
|
|
2225
|
+
}
|
|
2226
|
+
let movedOver = "";
|
|
2227
|
+
// This implementation moves strictly visually, without concern for a
|
|
2228
|
+
// traversal visiting every logical position in the string. It will
|
|
2229
|
+
// still do so for simple input, but situations like multiple isolates
|
|
2230
|
+
// with the same level next to each other, or text going against the
|
|
2231
|
+
// main dir at the end of the line, will make some positions
|
|
2232
|
+
// unreachable with this motion. Each visible cursor position will
|
|
2233
|
+
// correspond to the lower-level bidi span that touches it.
|
|
2234
|
+
//
|
|
2235
|
+
// The alternative would be to solve an order globally for a given
|
|
2236
|
+
// line, making sure that it includes every position, but that would
|
|
2237
|
+
// require associating non-canonical (higher bidi span level)
|
|
2238
|
+
// positions with a given visual position, which is likely to confuse
|
|
2239
|
+
// people. (And would generally be a lot more complicated.)
|
|
2240
|
+
function moveVisually(line, order, dir, start, forward) {
|
|
2241
|
+
var _a;
|
|
2242
|
+
let startIndex = start.head - line.from;
|
|
2243
|
+
let spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
|
|
2244
|
+
let span = order[spanI], spanEnd = span.side(forward, dir);
|
|
2245
|
+
// End of span
|
|
2246
|
+
if (startIndex == spanEnd) {
|
|
2247
|
+
let nextI = spanI += forward ? 1 : -1;
|
|
2248
|
+
if (nextI < 0 || nextI >= order.length)
|
|
2249
|
+
return null;
|
|
2250
|
+
span = order[spanI = nextI];
|
|
2251
|
+
startIndex = span.side(!forward, dir);
|
|
2252
|
+
spanEnd = span.side(forward, dir);
|
|
2253
|
+
}
|
|
2254
|
+
let nextIndex = findClusterBreak(line.text, startIndex, span.forward(forward, dir));
|
|
2255
|
+
if (nextIndex < span.from || nextIndex > span.to)
|
|
2256
|
+
nextIndex = spanEnd;
|
|
2257
|
+
movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
|
|
2258
|
+
let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
|
|
2259
|
+
if (nextSpan && nextIndex == spanEnd && nextSpan.level + (forward ? 0 : 1) < span.level)
|
|
2260
|
+
return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
|
|
2261
|
+
return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
|
|
2262
|
+
}
|
|
2263
|
+
function autoDirection(text, from, to) {
|
|
2264
|
+
for (let i = from; i < to; i++) {
|
|
2265
|
+
let type = charType(text.charCodeAt(i));
|
|
2266
|
+
if (type == 1 /* T.L */)
|
|
2267
|
+
return LTR;
|
|
2268
|
+
if (type == 2 /* T.R */ || type == 4 /* T.AL */)
|
|
2269
|
+
return RTL;
|
|
2270
|
+
}
|
|
2271
|
+
return LTR;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
|
|
2275
|
+
const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
|
|
2276
|
+
const mouseSelectionStyle = /*@__PURE__*/Facet.define();
|
|
2277
|
+
const exceptionSink = /*@__PURE__*/Facet.define();
|
|
2278
|
+
const updateListener = /*@__PURE__*/Facet.define();
|
|
2279
|
+
const inputHandler = /*@__PURE__*/Facet.define();
|
|
2280
|
+
const focusChangeEffect = /*@__PURE__*/Facet.define();
|
|
2281
|
+
const perLineTextDirection = /*@__PURE__*/Facet.define({
|
|
2282
|
+
combine: values => values.some(x => x)
|
|
2283
|
+
});
|
|
2284
|
+
const nativeSelectionHidden = /*@__PURE__*/Facet.define({
|
|
2285
|
+
combine: values => values.some(x => x)
|
|
2286
|
+
});
|
|
2287
|
+
class ScrollTarget {
|
|
2288
|
+
constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5,
|
|
2289
|
+
// This data structure is abused to also store precise scroll
|
|
2290
|
+
// snapshots, instead of a `scrollIntoView` request. When this
|
|
2291
|
+
// flag is `true`, `range` points at a position in the reference
|
|
2292
|
+
// line, `yMargin` holds the difference between the top of that
|
|
2293
|
+
// line and the top of the editor, and `xMargin` holds the
|
|
2294
|
+
// editor's `scrollLeft`.
|
|
2295
|
+
isSnapshot = false) {
|
|
2296
|
+
this.range = range;
|
|
2297
|
+
this.y = y;
|
|
2298
|
+
this.x = x;
|
|
2299
|
+
this.yMargin = yMargin;
|
|
2300
|
+
this.xMargin = xMargin;
|
|
2301
|
+
this.isSnapshot = isSnapshot;
|
|
2302
|
+
}
|
|
2303
|
+
map(changes) {
|
|
2304
|
+
return changes.empty ? this :
|
|
2305
|
+
new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
|
|
2306
|
+
}
|
|
2307
|
+
clip(state) {
|
|
2308
|
+
return this.range.to <= state.doc.length ? this :
|
|
2309
|
+
new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
const scrollIntoView = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });
|
|
2313
|
+
/**
|
|
2314
|
+
Log or report an unhandled exception in client code. Should
|
|
2315
|
+
probably only be used by extension code that allows client code to
|
|
2316
|
+
provide functions, and calls those functions in a context where an
|
|
2317
|
+
exception can't be propagated to calling code in a reasonable way
|
|
2318
|
+
(for example when in an event handler).
|
|
2319
|
+
|
|
2320
|
+
Either calls a handler registered with
|
|
2321
|
+
[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
|
|
2322
|
+
`window.onerror`, if defined, or `console.error` (in which case
|
|
2323
|
+
it'll pass `context`, when given, as first argument).
|
|
2324
|
+
*/
|
|
2325
|
+
function logException(state, exception, context) {
|
|
2326
|
+
let handler = state.facet(exceptionSink);
|
|
2327
|
+
if (handler.length)
|
|
2328
|
+
handler[0](exception);
|
|
2329
|
+
else if (window.onerror)
|
|
2330
|
+
window.onerror(String(exception), context, undefined, undefined, exception);
|
|
2331
|
+
else if (context)
|
|
2332
|
+
console.error(context + ":", exception);
|
|
2333
|
+
else
|
|
2334
|
+
console.error(exception);
|
|
2335
|
+
}
|
|
2336
|
+
const editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });
|
|
2337
|
+
let nextPluginID = 0;
|
|
2338
|
+
const viewPlugin = /*@__PURE__*/Facet.define();
|
|
2339
|
+
/**
|
|
2340
|
+
View plugins associate stateful values with a view. They can
|
|
2341
|
+
influence the way the content is drawn, and are notified of things
|
|
2342
|
+
that happen in the view.
|
|
2343
|
+
*/
|
|
2344
|
+
class ViewPlugin {
|
|
2345
|
+
constructor(
|
|
2346
|
+
/**
|
|
2347
|
+
@internal
|
|
2348
|
+
*/
|
|
2349
|
+
id,
|
|
2350
|
+
/**
|
|
2351
|
+
@internal
|
|
2352
|
+
*/
|
|
2353
|
+
create,
|
|
2354
|
+
/**
|
|
2355
|
+
@internal
|
|
2356
|
+
*/
|
|
2357
|
+
domEventHandlers,
|
|
2358
|
+
/**
|
|
2359
|
+
@internal
|
|
2360
|
+
*/
|
|
2361
|
+
domEventObservers, buildExtensions) {
|
|
2362
|
+
this.id = id;
|
|
2363
|
+
this.create = create;
|
|
2364
|
+
this.domEventHandlers = domEventHandlers;
|
|
2365
|
+
this.domEventObservers = domEventObservers;
|
|
2366
|
+
this.extension = buildExtensions(this);
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
Define a plugin from a constructor function that creates the
|
|
2370
|
+
plugin's value, given an editor view.
|
|
2371
|
+
*/
|
|
2372
|
+
static define(create, spec) {
|
|
2373
|
+
const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
|
|
2374
|
+
return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, plugin => {
|
|
2375
|
+
let ext = [viewPlugin.of(plugin)];
|
|
2376
|
+
if (deco)
|
|
2377
|
+
ext.push(decorations.of(view => {
|
|
2378
|
+
let pluginInst = view.plugin(plugin);
|
|
2379
|
+
return pluginInst ? deco(pluginInst) : Decoration.none;
|
|
2380
|
+
}));
|
|
2381
|
+
if (provide)
|
|
2382
|
+
ext.push(provide(plugin));
|
|
2383
|
+
return ext;
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
Create a plugin for a class whose constructor takes a single
|
|
2388
|
+
editor view as argument.
|
|
2389
|
+
*/
|
|
2390
|
+
static fromClass(cls, spec) {
|
|
2391
|
+
return ViewPlugin.define(view => new cls(view), spec);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
class PluginInstance {
|
|
2395
|
+
constructor(spec) {
|
|
2396
|
+
this.spec = spec;
|
|
2397
|
+
// When starting an update, all plugins have this field set to the
|
|
2398
|
+
// update object, indicating they need to be updated. When finished
|
|
2399
|
+
// updating, it is set to `false`. Retrieving a plugin that needs to
|
|
2400
|
+
// be updated with `view.plugin` forces an eager update.
|
|
2401
|
+
this.mustUpdate = null;
|
|
2402
|
+
// This is null when the plugin is initially created, but
|
|
2403
|
+
// initialized on the first update.
|
|
2404
|
+
this.value = null;
|
|
2405
|
+
}
|
|
2406
|
+
update(view) {
|
|
2407
|
+
if (!this.value) {
|
|
2408
|
+
if (this.spec) {
|
|
2409
|
+
try {
|
|
2410
|
+
this.value = this.spec.create(view);
|
|
2411
|
+
}
|
|
2412
|
+
catch (e) {
|
|
2413
|
+
logException(view.state, e, "CodeMirror plugin crashed");
|
|
2414
|
+
this.deactivate();
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
else if (this.mustUpdate) {
|
|
2419
|
+
let update = this.mustUpdate;
|
|
2420
|
+
this.mustUpdate = null;
|
|
2421
|
+
if (this.value.update) {
|
|
2422
|
+
try {
|
|
2423
|
+
this.value.update(update);
|
|
2424
|
+
}
|
|
2425
|
+
catch (e) {
|
|
2426
|
+
logException(update.state, e, "CodeMirror plugin crashed");
|
|
2427
|
+
if (this.value.destroy)
|
|
2428
|
+
try {
|
|
2429
|
+
this.value.destroy();
|
|
2430
|
+
}
|
|
2431
|
+
catch (_) { }
|
|
2432
|
+
this.deactivate();
|
|
2551
2433
|
}
|
|
2552
2434
|
}
|
|
2553
|
-
if (recurse)
|
|
2554
|
-
emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
|
|
2555
|
-
else if (iScan < iCh)
|
|
2556
|
-
order.push(new BidiSpan(iScan, iCh, localLevel));
|
|
2557
|
-
iCh = iScan;
|
|
2558
2435
|
}
|
|
2436
|
+
return this;
|
|
2437
|
+
}
|
|
2438
|
+
destroy(view) {
|
|
2439
|
+
var _a;
|
|
2440
|
+
if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
|
|
2441
|
+
try {
|
|
2442
|
+
this.value.destroy();
|
|
2443
|
+
}
|
|
2444
|
+
catch (e) {
|
|
2445
|
+
logException(view.state, e, "CodeMirror plugin crashed");
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
deactivate() {
|
|
2450
|
+
this.spec = this.value = null;
|
|
2559
2451
|
}
|
|
2560
2452
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
function
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2453
|
+
const editorAttributes = /*@__PURE__*/Facet.define();
|
|
2454
|
+
const contentAttributes = /*@__PURE__*/Facet.define();
|
|
2455
|
+
// Provide decorations
|
|
2456
|
+
const decorations = /*@__PURE__*/Facet.define();
|
|
2457
|
+
const outerDecorations = /*@__PURE__*/Facet.define();
|
|
2458
|
+
const atomicRanges = /*@__PURE__*/Facet.define();
|
|
2459
|
+
const bidiIsolatedRanges = /*@__PURE__*/Facet.define();
|
|
2460
|
+
function getIsolatedRanges(view, line) {
|
|
2461
|
+
let isolates = view.state.facet(bidiIsolatedRanges);
|
|
2462
|
+
if (!isolates.length)
|
|
2463
|
+
return isolates;
|
|
2464
|
+
let sets = isolates.map(i => i instanceof Function ? i(view) : i);
|
|
2465
|
+
let result = [];
|
|
2466
|
+
RangeSet.spans(sets, line.from, line.to, {
|
|
2467
|
+
point() { },
|
|
2468
|
+
span(fromDoc, toDoc, active, open) {
|
|
2469
|
+
let from = fromDoc - line.from, to = toDoc - line.from;
|
|
2470
|
+
let level = result;
|
|
2471
|
+
for (let i = active.length - 1; i >= 0; i--, open--) {
|
|
2472
|
+
let direction = active[i].spec.bidiIsolate, update;
|
|
2473
|
+
if (direction == null)
|
|
2474
|
+
direction = autoDirection(line.text, from, to);
|
|
2475
|
+
if (open > 0 && level.length &&
|
|
2476
|
+
(update = level[level.length - 1]).to == from && update.direction == direction) {
|
|
2477
|
+
update.to = to;
|
|
2478
|
+
level = update.inner;
|
|
2479
|
+
}
|
|
2480
|
+
else {
|
|
2481
|
+
let add = { from, to, direction, inner: [] };
|
|
2482
|
+
level.push(add);
|
|
2483
|
+
level = add.inner;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
return result;
|
|
2579
2489
|
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2490
|
+
const scrollMargins = /*@__PURE__*/Facet.define();
|
|
2491
|
+
function getScrollMargins(view) {
|
|
2492
|
+
let left = 0, right = 0, top = 0, bottom = 0;
|
|
2493
|
+
for (let source of view.state.facet(scrollMargins)) {
|
|
2494
|
+
let m = source(view);
|
|
2495
|
+
if (m) {
|
|
2496
|
+
if (m.left != null)
|
|
2497
|
+
left = Math.max(left, m.left);
|
|
2498
|
+
if (m.right != null)
|
|
2499
|
+
right = Math.max(right, m.right);
|
|
2500
|
+
if (m.top != null)
|
|
2501
|
+
top = Math.max(top, m.top);
|
|
2502
|
+
if (m.bottom != null)
|
|
2503
|
+
bottom = Math.max(bottom, m.bottom);
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
return { left, right, top, bottom };
|
|
2582
2507
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2508
|
+
const styleModule = /*@__PURE__*/Facet.define();
|
|
2509
|
+
class ChangedRange {
|
|
2510
|
+
constructor(fromA, toA, fromB, toB) {
|
|
2511
|
+
this.fromA = fromA;
|
|
2512
|
+
this.toA = toA;
|
|
2513
|
+
this.fromB = fromB;
|
|
2514
|
+
this.toB = toB;
|
|
2515
|
+
}
|
|
2516
|
+
join(other) {
|
|
2517
|
+
return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
|
|
2518
|
+
}
|
|
2519
|
+
addToSet(set) {
|
|
2520
|
+
let i = set.length, me = this;
|
|
2521
|
+
for (; i > 0; i--) {
|
|
2522
|
+
let range = set[i - 1];
|
|
2523
|
+
if (range.fromA > me.toA)
|
|
2524
|
+
continue;
|
|
2525
|
+
if (range.toA < me.fromA)
|
|
2526
|
+
break;
|
|
2527
|
+
me = me.join(range);
|
|
2528
|
+
set.splice(i - 1, 1);
|
|
2593
2529
|
}
|
|
2530
|
+
set.splice(i, 0, me);
|
|
2531
|
+
return set;
|
|
2594
2532
|
}
|
|
2595
|
-
|
|
2596
|
-
if (
|
|
2597
|
-
return
|
|
2598
|
-
let
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2533
|
+
static extendWithRanges(diff, ranges) {
|
|
2534
|
+
if (ranges.length == 0)
|
|
2535
|
+
return diff;
|
|
2536
|
+
let result = [];
|
|
2537
|
+
for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
|
|
2538
|
+
let next = dI == diff.length ? null : diff[dI], off = posA - posB;
|
|
2539
|
+
let end = next ? next.fromB : 1e9;
|
|
2540
|
+
while (rI < ranges.length && ranges[rI] < end) {
|
|
2541
|
+
let from = ranges[rI], to = ranges[rI + 1];
|
|
2542
|
+
let fromB = Math.max(posB, from), toB = Math.min(end, to);
|
|
2543
|
+
if (fromB <= toB)
|
|
2544
|
+
new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
|
|
2545
|
+
if (to > end)
|
|
2546
|
+
break;
|
|
2547
|
+
else
|
|
2548
|
+
rI += 2;
|
|
2549
|
+
}
|
|
2550
|
+
if (!next)
|
|
2551
|
+
return result;
|
|
2552
|
+
new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
|
|
2553
|
+
posA = next.toA;
|
|
2554
|
+
posB = next.toB;
|
|
2555
|
+
}
|
|
2611
2556
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
2560
|
+
class, which describe what happened, whenever the view is updated.
|
|
2561
|
+
*/
|
|
2562
|
+
class ViewUpdate {
|
|
2563
|
+
constructor(
|
|
2564
|
+
/**
|
|
2565
|
+
The editor view that the update is associated with.
|
|
2566
|
+
*/
|
|
2567
|
+
view,
|
|
2568
|
+
/**
|
|
2569
|
+
The new editor state.
|
|
2570
|
+
*/
|
|
2571
|
+
state,
|
|
2572
|
+
/**
|
|
2573
|
+
The transactions involved in the update. May be empty.
|
|
2574
|
+
*/
|
|
2575
|
+
transactions) {
|
|
2576
|
+
this.view = view;
|
|
2577
|
+
this.state = state;
|
|
2578
|
+
this.transactions = transactions;
|
|
2579
|
+
/**
|
|
2580
|
+
@internal
|
|
2581
|
+
*/
|
|
2582
|
+
this.flags = 0;
|
|
2583
|
+
this.startState = view.state;
|
|
2584
|
+
this.changes = ChangeSet.empty(this.startState.doc.length);
|
|
2585
|
+
for (let tr of transactions)
|
|
2586
|
+
this.changes = this.changes.compose(tr.changes);
|
|
2587
|
+
let changedRanges = [];
|
|
2588
|
+
this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
|
|
2589
|
+
this.changedRanges = changedRanges;
|
|
2590
|
+
}
|
|
2591
|
+
/**
|
|
2592
|
+
@internal
|
|
2593
|
+
*/
|
|
2594
|
+
static create(view, state, transactions) {
|
|
2595
|
+
return new ViewUpdate(view, state, transactions);
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
|
|
2599
|
+
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
|
|
2600
|
+
update.
|
|
2601
|
+
*/
|
|
2602
|
+
get viewportChanged() {
|
|
2603
|
+
return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
Indicates whether the height of a block element in the editor
|
|
2607
|
+
changed in this update.
|
|
2608
|
+
*/
|
|
2609
|
+
get heightChanged() {
|
|
2610
|
+
return (this.flags & 2 /* UpdateFlag.Height */) > 0;
|
|
2611
|
+
}
|
|
2612
|
+
/**
|
|
2613
|
+
Returns true when the document was modified or the size of the
|
|
2614
|
+
editor, or elements within the editor, changed.
|
|
2615
|
+
*/
|
|
2616
|
+
get geometryChanged() {
|
|
2617
|
+
return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
True when this update indicates a focus change.
|
|
2621
|
+
*/
|
|
2622
|
+
get focusChanged() {
|
|
2623
|
+
return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
Whether the document changed in this update.
|
|
2627
|
+
*/
|
|
2628
|
+
get docChanged() {
|
|
2629
|
+
return !this.changes.empty;
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
Whether the selection was explicitly set in this update.
|
|
2633
|
+
*/
|
|
2634
|
+
get selectionSet() {
|
|
2635
|
+
return this.transactions.some(tr => tr.selection);
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
@internal
|
|
2639
|
+
*/
|
|
2640
|
+
get empty() { return this.flags == 0 && this.transactions.length == 0; }
|
|
2623
2641
|
}
|
|
2624
2642
|
|
|
2625
2643
|
class DocView extends ContentView {
|
|
@@ -2829,9 +2847,8 @@ class DocView extends ContentView {
|
|
|
2829
2847
|
}
|
|
2830
2848
|
let domSel = this.view.observer.selectionRange;
|
|
2831
2849
|
// If the selection is already here, or in an equivalent position, don't touch it
|
|
2832
|
-
if (force || !domSel.focusNode ||
|
|
2833
|
-
!isEquivalentPosition(
|
|
2834
|
-
!isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
|
|
2850
|
+
if (force || !domSel.focusNode || (!isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
|
|
2851
|
+
!isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) && !this.suppressWidgetCursorChange(domSel, main)) {
|
|
2835
2852
|
this.view.observer.ignore(() => {
|
|
2836
2853
|
// Chrome Android will hide the virtual keyboard when tapping
|
|
2837
2854
|
// inside an uneditable node, and not bring it back when we
|
|
@@ -2892,6 +2909,14 @@ class DocView extends ContentView {
|
|
|
2892
2909
|
this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);
|
|
2893
2910
|
this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
|
|
2894
2911
|
}
|
|
2912
|
+
// If a zero-length widget is inserted next to the cursor during
|
|
2913
|
+
// composition, avoid moving it across it and disrupting the
|
|
2914
|
+
// composition.
|
|
2915
|
+
suppressWidgetCursorChange(sel, cursor) {
|
|
2916
|
+
return this.hasComposition && cursor.empty &&
|
|
2917
|
+
isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset) &&
|
|
2918
|
+
this.posFromDOM(sel.focusNode, sel.focusOffset) == cursor.head;
|
|
2919
|
+
}
|
|
2895
2920
|
enforceCursorAssoc() {
|
|
2896
2921
|
if (this.hasComposition)
|
|
2897
2922
|
return;
|
|
@@ -3100,6 +3125,16 @@ class DocView extends ContentView {
|
|
|
3100
3125
|
let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
|
|
3101
3126
|
return dynamic ? d(this.view) : d;
|
|
3102
3127
|
});
|
|
3128
|
+
let dynamicOuter = false, outerDeco = this.view.state.facet(outerDecorations).map((d, i) => {
|
|
3129
|
+
let dynamic = typeof d == "function";
|
|
3130
|
+
if (dynamic)
|
|
3131
|
+
dynamicOuter = true;
|
|
3132
|
+
return dynamic ? d(this.view) : d;
|
|
3133
|
+
});
|
|
3134
|
+
if (outerDeco.length) {
|
|
3135
|
+
this.dynamicDecorationMap[allDeco.length] = dynamicOuter;
|
|
3136
|
+
allDeco.push(RangeSet.join(outerDeco));
|
|
3137
|
+
}
|
|
3103
3138
|
for (let i = allDeco.length; i < allDeco.length + 3; i++)
|
|
3104
3139
|
this.dynamicDecorationMap[i] = false;
|
|
3105
3140
|
return this.decorations = [
|
|
@@ -3143,6 +3178,7 @@ class BlockGapWidget extends WidgetType {
|
|
|
3143
3178
|
}
|
|
3144
3179
|
toDOM() {
|
|
3145
3180
|
let elt = document.createElement("div");
|
|
3181
|
+
elt.className = "cm-gap";
|
|
3146
3182
|
this.updateDOM(elt);
|
|
3147
3183
|
return elt;
|
|
3148
3184
|
}
|
|
@@ -3151,6 +3187,7 @@ class BlockGapWidget extends WidgetType {
|
|
|
3151
3187
|
elt.style.height = this.height + "px";
|
|
3152
3188
|
return true;
|
|
3153
3189
|
}
|
|
3190
|
+
get editable() { return true; }
|
|
3154
3191
|
get estimatedHeight() { return this.height; }
|
|
3155
3192
|
}
|
|
3156
3193
|
function findCompositionNode(view, headPos) {
|
|
@@ -3547,7 +3584,7 @@ function moveByChar(view, start, forward, by) {
|
|
|
3547
3584
|
char = "\n";
|
|
3548
3585
|
line = view.state.doc.line(line.number + (forward ? 1 : -1));
|
|
3549
3586
|
spans = view.bidiSpans(line);
|
|
3550
|
-
next =
|
|
3587
|
+
next = view.visualLineSide(line, !forward);
|
|
3551
3588
|
}
|
|
3552
3589
|
if (!check) {
|
|
3553
3590
|
if (!by)
|
|
@@ -3952,8 +3989,7 @@ class MouseSelection {
|
|
|
3952
3989
|
}
|
|
3953
3990
|
select(event) {
|
|
3954
3991
|
let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
|
|
3955
|
-
if (this.mustSelect || !selection.eq(view.state.selection)
|
|
3956
|
-
selection.main.assoc != view.state.selection.main.assoc && this.dragging === false)
|
|
3992
|
+
if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
|
|
3957
3993
|
this.view.dispatch({
|
|
3958
3994
|
selection,
|
|
3959
3995
|
userEvent: "select.pointer"
|
|
@@ -5810,7 +5846,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5810
5846
|
flexShrink: 0,
|
|
5811
5847
|
display: "block",
|
|
5812
5848
|
whiteSpace: "pre",
|
|
5813
|
-
wordWrap: "normal",
|
|
5849
|
+
wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
|
|
5814
5850
|
boxSizing: "border-box",
|
|
5815
5851
|
minHeight: "100%",
|
|
5816
5852
|
padding: "4px 0",
|
|
@@ -5820,9 +5856,9 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5820
5856
|
}
|
|
5821
5857
|
},
|
|
5822
5858
|
".cm-lineWrapping": {
|
|
5823
|
-
whiteSpace_fallback: "pre-wrap",
|
|
5859
|
+
whiteSpace_fallback: "pre-wrap", // For IE
|
|
5824
5860
|
whiteSpace: "break-spaces",
|
|
5825
|
-
wordBreak: "break-word",
|
|
5861
|
+
wordBreak: "break-word", // For Safari, which doesn't support overflow-wrap: anywhere
|
|
5826
5862
|
overflowWrap: "anywhere",
|
|
5827
5863
|
flexShrink: 1
|
|
5828
5864
|
},
|
|
@@ -5881,6 +5917,9 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5881
5917
|
"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
|
|
5882
5918
|
display: "block"
|
|
5883
5919
|
},
|
|
5920
|
+
".cm-iso": {
|
|
5921
|
+
unicodeBidi: "isolate"
|
|
5922
|
+
},
|
|
5884
5923
|
".cm-announced": {
|
|
5885
5924
|
position: "fixed",
|
|
5886
5925
|
top: "-10000px"
|
|
@@ -5910,7 +5949,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5910
5949
|
color: "#ccc"
|
|
5911
5950
|
},
|
|
5912
5951
|
".cm-gutter": {
|
|
5913
|
-
display: "flex !important",
|
|
5952
|
+
display: "flex !important", // Necessary -- prevents margin collapsing
|
|
5914
5953
|
flexDirection: "column",
|
|
5915
5954
|
flexShrink: 0,
|
|
5916
5955
|
boxSizing: "border-box",
|
|
@@ -6164,6 +6203,16 @@ class DOMChange {
|
|
|
6164
6203
|
!contains(view.contentDOM, domSel.anchorNode)
|
|
6165
6204
|
? view.state.selection.main.anchor
|
|
6166
6205
|
: view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
|
|
6206
|
+
// iOS will refuse to select the block gaps when doing select-all
|
|
6207
|
+
let vp = view.viewport;
|
|
6208
|
+
if (browser.ios && view.state.selection.main.empty && head != anchor &&
|
|
6209
|
+
(vp.from > 0 || vp.to < view.state.doc.length)) {
|
|
6210
|
+
let offFrom = vp.from - Math.min(head, anchor), offTo = vp.to - Math.max(head, anchor);
|
|
6211
|
+
if ((offFrom == 0 || offFrom == 1) && (offTo == 0 || offTo == -1)) {
|
|
6212
|
+
head = 0;
|
|
6213
|
+
anchor = view.state.doc.length;
|
|
6214
|
+
}
|
|
6215
|
+
}
|
|
6167
6216
|
this.newSel = EditorSelection.single(anchor, head);
|
|
6168
6217
|
}
|
|
6169
6218
|
}
|
|
@@ -6941,6 +6990,8 @@ class EditorView {
|
|
|
6941
6990
|
this.dom = document.createElement("div");
|
|
6942
6991
|
this.dom.appendChild(this.announceDOM);
|
|
6943
6992
|
this.dom.appendChild(this.scrollDOM);
|
|
6993
|
+
if (config.parent)
|
|
6994
|
+
config.parent.appendChild(this.dom);
|
|
6944
6995
|
let { dispatch } = config;
|
|
6945
6996
|
this.dispatchTransactions = config.dispatchTransactions ||
|
|
6946
6997
|
(dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||
|
|
@@ -6961,8 +7012,6 @@ class EditorView {
|
|
|
6961
7012
|
this.updateAttrs();
|
|
6962
7013
|
this.updateState = 0 /* UpdateState.Idle */;
|
|
6963
7014
|
this.requestMeasure();
|
|
6964
|
-
if (config.parent)
|
|
6965
|
-
config.parent.appendChild(this.dom);
|
|
6966
7015
|
}
|
|
6967
7016
|
dispatch(...input) {
|
|
6968
7017
|
let trs = input.length == 1 && input[0] instanceof Transaction ? input
|
|
@@ -7453,6 +7502,17 @@ class EditorView {
|
|
|
7453
7502
|
return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));
|
|
7454
7503
|
}
|
|
7455
7504
|
/**
|
|
7505
|
+
Get the cursor position visually at the start or end of a line.
|
|
7506
|
+
Note that this may differ from the _logical_ position at its
|
|
7507
|
+
start or end (which is simply at `line.from`/`line.to`) if text
|
|
7508
|
+
at the start or end goes against the line's base text direction.
|
|
7509
|
+
*/
|
|
7510
|
+
visualLineSide(line, end) {
|
|
7511
|
+
let order = this.bidiSpans(line), dir = this.textDirectionAt(line.from);
|
|
7512
|
+
let span = order[end ? order.length - 1 : 0];
|
|
7513
|
+
return EditorSelection.cursor(span.side(end, dir) + line.from, span.forward(!end, dir) ? 1 : -1);
|
|
7514
|
+
}
|
|
7515
|
+
/**
|
|
7456
7516
|
Move to the next line boundary in the given direction. If
|
|
7457
7517
|
`includeWrap` is true, line wrapping is on, and there is a
|
|
7458
7518
|
further wrap point on the current line, the wrap point will be
|
|
@@ -7584,11 +7644,11 @@ class EditorView {
|
|
|
7584
7644
|
let dir = this.textDirectionAt(line.from), isolates;
|
|
7585
7645
|
for (let entry of this.bidiCache) {
|
|
7586
7646
|
if (entry.from == line.from && entry.dir == dir &&
|
|
7587
|
-
(entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line
|
|
7647
|
+
(entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line))))
|
|
7588
7648
|
return entry.order;
|
|
7589
7649
|
}
|
|
7590
7650
|
if (!isolates)
|
|
7591
|
-
isolates = getIsolatedRanges(this, line
|
|
7651
|
+
isolates = getIsolatedRanges(this, line);
|
|
7592
7652
|
let order = computeOrder(line.text, dir, isolates);
|
|
7593
7653
|
this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));
|
|
7594
7654
|
return order;
|
|
@@ -7833,6 +7893,16 @@ containing the decorations to
|
|
|
7833
7893
|
*/
|
|
7834
7894
|
EditorView.decorations = decorations;
|
|
7835
7895
|
/**
|
|
7896
|
+
Facet that works much like
|
|
7897
|
+
[`decorations`](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), but puts its
|
|
7898
|
+
inputs at the very bottom of the precedence stack, meaning mark
|
|
7899
|
+
decorations provided here will only be split by other, partially
|
|
7900
|
+
overlapping \`outerDecorations\` ranges, and wrap around all
|
|
7901
|
+
regular decorations. Use this for mark elements that should, as
|
|
7902
|
+
much as possible, remain in one piece.
|
|
7903
|
+
*/
|
|
7904
|
+
EditorView.outerDecorations = outerDecorations;
|
|
7905
|
+
/**
|
|
7836
7906
|
Used to provide ranges that should be treated as atoms as far as
|
|
7837
7907
|
cursor motion is concerned. This causes methods like
|
|
7838
7908
|
[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
|
|
@@ -9297,16 +9367,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9297
9367
|
// positioning.
|
|
9298
9368
|
makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
|
|
9299
9369
|
}
|
|
9300
|
-
else {
|
|
9370
|
+
else if (dom.style.top == Outside && dom.style.left == "0px") {
|
|
9301
9371
|
// On other browsers, we have to awkwardly try and use other
|
|
9302
9372
|
// information to detect a transform.
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
}
|
|
9306
|
-
else if (dom.style.top == Outside && dom.style.left == "0px") {
|
|
9307
|
-
let rect = dom.getBoundingClientRect();
|
|
9308
|
-
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
|
|
9309
|
-
}
|
|
9373
|
+
let rect = dom.getBoundingClientRect();
|
|
9374
|
+
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
|
|
9310
9375
|
}
|
|
9311
9376
|
}
|
|
9312
9377
|
if (makeAbsolute || this.position == "absolute") {
|