@uiw/react-codemirror 4.11.6 → 4.12.2
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/README.md +48 -0
- package/cjs/index.d.ts +8 -1
- package/cjs/index.js +4 -2
- package/cjs/index.js.map +3 -2
- package/cjs/useCodeMirror.js +5 -4
- package/cjs/useCodeMirror.js.map +7 -2
- package/dist/mdeditor.js +201 -127
- package/dist/mdeditor.min.js +1 -1
- package/esm/index.d.ts +8 -1
- package/esm/index.js +5 -3
- package/esm/index.js.map +3 -2
- package/esm/useCodeMirror.js +5 -3
- package/esm/useCodeMirror.js.map +7 -2
- package/package.json +5 -2
- package/src/index.tsx +10 -1
- package/src/useCodeMirror.ts +6 -2
package/dist/mdeditor.js
CHANGED
|
@@ -612,6 +612,10 @@ class dist_Tree {
|
|
|
612
612
|
/// position. If 1, it'll move into nodes that start at the
|
|
613
613
|
/// position. With 0, it'll only enter nodes that cover the position
|
|
614
614
|
/// from both sides.
|
|
615
|
+
///
|
|
616
|
+
/// Note that this will not enter
|
|
617
|
+
/// [overlays](#common.MountedTree.overlay), and you often want
|
|
618
|
+
/// [`resolveInner`](#common.Tree.resolveInner) instead.
|
|
615
619
|
resolve(pos, side = 0) {
|
|
616
620
|
let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
|
|
617
621
|
CachedNode.set(this, node);
|
|
@@ -2094,14 +2098,14 @@ function enterFragments(mounts, ranges) {
|
|
|
2094
2098
|
for (let i = 0, pos = from;; i++) {
|
|
2095
2099
|
let last = i == changes.length, end = last ? to : changes[i].from;
|
|
2096
2100
|
if (end > pos)
|
|
2097
|
-
result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos, frag.to <= end));
|
|
2101
|
+
result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));
|
|
2098
2102
|
if (last)
|
|
2099
2103
|
break;
|
|
2100
2104
|
pos = changes[i].to;
|
|
2101
2105
|
}
|
|
2102
2106
|
}
|
|
2103
2107
|
else {
|
|
2104
|
-
result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos, frag.to <= endPos));
|
|
2108
|
+
result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));
|
|
2105
2109
|
}
|
|
2106
2110
|
}
|
|
2107
2111
|
return result;
|
|
@@ -6899,7 +6903,8 @@ class SearchCursor {
|
|
|
6899
6903
|
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
6900
6904
|
(when supported).
|
|
6901
6905
|
*/
|
|
6902
|
-
constructor(text, query, from = 0, to = text.length, normalize) {
|
|
6906
|
+
constructor(text, query, from = 0, to = text.length, normalize, test) {
|
|
6907
|
+
this.test = test;
|
|
6903
6908
|
/**
|
|
6904
6909
|
The current match (only holds a meaningful value after
|
|
6905
6910
|
[`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
|
|
@@ -6993,6 +6998,8 @@ class SearchCursor {
|
|
|
6993
6998
|
else
|
|
6994
6999
|
this.matches.push(1, pos);
|
|
6995
7000
|
}
|
|
7001
|
+
if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferPos))
|
|
7002
|
+
match = null;
|
|
6996
7003
|
return match;
|
|
6997
7004
|
}
|
|
6998
7005
|
}
|
|
@@ -7030,6 +7037,7 @@ class RegExpCursor {
|
|
|
7030
7037
|
if (/\\[sWDnr]|\n|\r|\[\^/.test(query))
|
|
7031
7038
|
return new MultilineRegExpCursor(text, query, options, from, to);
|
|
7032
7039
|
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
7040
|
+
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
7033
7041
|
this.iter = text.iter();
|
|
7034
7042
|
let startLine = text.lineAt(from);
|
|
7035
7043
|
this.curLineStart = startLine.from;
|
|
@@ -7067,7 +7075,7 @@ class RegExpCursor {
|
|
|
7067
7075
|
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
7068
7076
|
if (from == this.curLine.length)
|
|
7069
7077
|
this.nextLine();
|
|
7070
|
-
if (from < to || from > this.value.to) {
|
|
7078
|
+
if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
|
|
7071
7079
|
this.value = { from, to, match };
|
|
7072
7080
|
return this;
|
|
7073
7081
|
}
|
|
@@ -7120,6 +7128,7 @@ class MultilineRegExpCursor {
|
|
|
7120
7128
|
this.value = empty;
|
|
7121
7129
|
this.matchPos = toCharEnd(text, from);
|
|
7122
7130
|
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
7131
|
+
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
7123
7132
|
this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Base */));
|
|
7124
7133
|
}
|
|
7125
7134
|
chunkEnd(pos) {
|
|
@@ -7134,24 +7143,23 @@ class MultilineRegExpCursor {
|
|
|
7134
7143
|
this.re.lastIndex = off + 1;
|
|
7135
7144
|
match = this.re.exec(this.flat.text);
|
|
7136
7145
|
}
|
|
7137
|
-
// If a match goes almost to the end of a noncomplete chunk, try
|
|
7138
|
-
// again, since it'll likely be able to match more
|
|
7139
|
-
if (match && this.flat.to < this.to && match.index + match[0].length > this.flat.text.length - 10)
|
|
7140
|
-
match = null;
|
|
7141
7146
|
if (match) {
|
|
7142
7147
|
let from = this.flat.from + match.index, to = from + match[0].length;
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
this.done = true;
|
|
7148
|
+
// If a match goes almost to the end of a noncomplete chunk, try
|
|
7149
|
+
// again, since it'll likely be able to match more
|
|
7150
|
+
if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) &&
|
|
7151
|
+
(!this.test || this.test(from, to, match))) {
|
|
7152
|
+
this.value = { from, to, match };
|
|
7153
|
+
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
7150
7154
|
return this;
|
|
7151
7155
|
}
|
|
7152
|
-
// Grow the flattened doc
|
|
7153
|
-
this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
7154
7156
|
}
|
|
7157
|
+
if (this.flat.to == this.to) {
|
|
7158
|
+
this.done = true;
|
|
7159
|
+
return this;
|
|
7160
|
+
}
|
|
7161
|
+
// Grow the flattened doc
|
|
7162
|
+
this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
7155
7163
|
}
|
|
7156
7164
|
}
|
|
7157
7165
|
}
|
|
@@ -7427,13 +7435,13 @@ const selectNextOccurrence = ({ state, dispatch }) => {
|
|
|
7427
7435
|
|
|
7428
7436
|
const searchConfigFacet = /*@__PURE__*/state_.Facet.define({
|
|
7429
7437
|
combine(configs) {
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
createPanel:
|
|
7436
|
-
};
|
|
7438
|
+
return (0,state_.combineConfig)(configs, {
|
|
7439
|
+
top: false,
|
|
7440
|
+
caseSensitive: false,
|
|
7441
|
+
literal: false,
|
|
7442
|
+
wholeWord: false,
|
|
7443
|
+
createPanel: view => new SearchPanel(view)
|
|
7444
|
+
});
|
|
7437
7445
|
}
|
|
7438
7446
|
});
|
|
7439
7447
|
/**
|
|
@@ -7460,13 +7468,15 @@ class SearchQuery {
|
|
|
7460
7468
|
this.replace = config.replace || "";
|
|
7461
7469
|
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
|
7462
7470
|
this.unquoted = this.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
|
|
7471
|
+
this.wholeWord = !!config.wholeWord;
|
|
7463
7472
|
}
|
|
7464
7473
|
/**
|
|
7465
7474
|
Compare this query to another query.
|
|
7466
7475
|
*/
|
|
7467
7476
|
eq(other) {
|
|
7468
7477
|
return this.search == other.search && this.replace == other.replace &&
|
|
7469
|
-
this.caseSensitive == other.caseSensitive && this.regexp == other.regexp
|
|
7478
|
+
this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&
|
|
7479
|
+
this.wholeWord == other.wholeWord;
|
|
7470
7480
|
}
|
|
7471
7481
|
/**
|
|
7472
7482
|
@internal
|
|
@@ -7476,10 +7486,13 @@ class SearchQuery {
|
|
|
7476
7486
|
}
|
|
7477
7487
|
/**
|
|
7478
7488
|
Get a search cursor for this query, searching through the given
|
|
7479
|
-
range in the given
|
|
7489
|
+
range in the given state.
|
|
7480
7490
|
*/
|
|
7481
|
-
getCursor(
|
|
7482
|
-
|
|
7491
|
+
getCursor(state, from = 0, to) {
|
|
7492
|
+
let st = state.doc ? state : state_.EditorState.create({ doc: state });
|
|
7493
|
+
if (to == null)
|
|
7494
|
+
to = st.doc.length;
|
|
7495
|
+
return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);
|
|
7483
7496
|
}
|
|
7484
7497
|
}
|
|
7485
7498
|
class QueryType {
|
|
@@ -7487,25 +7500,37 @@ class QueryType {
|
|
|
7487
7500
|
this.spec = spec;
|
|
7488
7501
|
}
|
|
7489
7502
|
}
|
|
7490
|
-
function stringCursor(spec,
|
|
7491
|
-
return new SearchCursor(doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase());
|
|
7503
|
+
function stringCursor(spec, state, from, to) {
|
|
7504
|
+
return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);
|
|
7505
|
+
}
|
|
7506
|
+
function stringWordTest(doc, categorizer) {
|
|
7507
|
+
return (from, to, buf, bufPos) => {
|
|
7508
|
+
if (bufPos > from || bufPos + buf.length < to) {
|
|
7509
|
+
bufPos = Math.max(0, from - 2);
|
|
7510
|
+
buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));
|
|
7511
|
+
}
|
|
7512
|
+
return categorizer(charAfter(buf, from - bufPos)) != state_.CharCategory.Word ||
|
|
7513
|
+
categorizer(charBefore(buf, to - bufPos)) != state_.CharCategory.Word ||
|
|
7514
|
+
(categorizer(charBefore(buf, from - bufPos)) != state_.CharCategory.Word &&
|
|
7515
|
+
categorizer(charAfter(buf, to - bufPos)) != state_.CharCategory.Word);
|
|
7516
|
+
};
|
|
7492
7517
|
}
|
|
7493
7518
|
class StringQuery extends QueryType {
|
|
7494
7519
|
constructor(spec) {
|
|
7495
7520
|
super(spec);
|
|
7496
7521
|
}
|
|
7497
|
-
nextMatch(
|
|
7498
|
-
let cursor = stringCursor(this.spec,
|
|
7522
|
+
nextMatch(state, curFrom, curTo) {
|
|
7523
|
+
let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();
|
|
7499
7524
|
if (cursor.done)
|
|
7500
|
-
cursor = stringCursor(this.spec,
|
|
7525
|
+
cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();
|
|
7501
7526
|
return cursor.done ? null : cursor.value;
|
|
7502
7527
|
}
|
|
7503
7528
|
// Searching in reverse is, rather than implementing inverted search
|
|
7504
7529
|
// cursor, done by scanning chunk after chunk forward.
|
|
7505
|
-
prevMatchInRange(
|
|
7530
|
+
prevMatchInRange(state, from, to) {
|
|
7506
7531
|
for (let pos = to;;) {
|
|
7507
7532
|
let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);
|
|
7508
|
-
let cursor = stringCursor(this.spec,
|
|
7533
|
+
let cursor = stringCursor(this.spec, state, start, pos), range = null;
|
|
7509
7534
|
while (!cursor.nextOverlapping().done)
|
|
7510
7535
|
range = cursor.value;
|
|
7511
7536
|
if (range)
|
|
@@ -7515,13 +7540,13 @@ class StringQuery extends QueryType {
|
|
|
7515
7540
|
pos -= 10000 /* ChunkSize */;
|
|
7516
7541
|
}
|
|
7517
7542
|
}
|
|
7518
|
-
prevMatch(
|
|
7519
|
-
return this.prevMatchInRange(
|
|
7520
|
-
this.prevMatchInRange(
|
|
7543
|
+
prevMatch(state, curFrom, curTo) {
|
|
7544
|
+
return this.prevMatchInRange(state, 0, curFrom) ||
|
|
7545
|
+
this.prevMatchInRange(state, curTo, state.doc.length);
|
|
7521
7546
|
}
|
|
7522
7547
|
getReplacement(_result) { return this.spec.replace; }
|
|
7523
|
-
matchAll(
|
|
7524
|
-
let cursor = stringCursor(this.spec,
|
|
7548
|
+
matchAll(state, limit) {
|
|
7549
|
+
let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
7525
7550
|
while (!cursor.next().done) {
|
|
7526
7551
|
if (ranges.length >= limit)
|
|
7527
7552
|
return null;
|
|
@@ -7529,26 +7554,42 @@ class StringQuery extends QueryType {
|
|
|
7529
7554
|
}
|
|
7530
7555
|
return ranges;
|
|
7531
7556
|
}
|
|
7532
|
-
highlight(
|
|
7533
|
-
let cursor = stringCursor(this.spec,
|
|
7557
|
+
highlight(state, from, to, add) {
|
|
7558
|
+
let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));
|
|
7534
7559
|
while (!cursor.next().done)
|
|
7535
7560
|
add(cursor.value.from, cursor.value.to);
|
|
7536
7561
|
}
|
|
7537
7562
|
}
|
|
7538
|
-
function regexpCursor(spec,
|
|
7539
|
-
return new RegExpCursor(doc, spec.search,
|
|
7563
|
+
function regexpCursor(spec, state, from, to) {
|
|
7564
|
+
return new RegExpCursor(state.doc, spec.search, {
|
|
7565
|
+
ignoreCase: !spec.caseSensitive,
|
|
7566
|
+
test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined
|
|
7567
|
+
}, from, to);
|
|
7568
|
+
}
|
|
7569
|
+
function charBefore(str, index) {
|
|
7570
|
+
return str.slice((0,state_.findClusterBreak)(str, index, false), index);
|
|
7571
|
+
}
|
|
7572
|
+
function charAfter(str, index) {
|
|
7573
|
+
return str.slice(index, (0,state_.findClusterBreak)(str, index));
|
|
7574
|
+
}
|
|
7575
|
+
function regexpWordTest(categorizer) {
|
|
7576
|
+
return (_from, _to, match) => !match[0].length ||
|
|
7577
|
+
categorizer(charAfter(match.input, match.index)) != state_.CharCategory.Word ||
|
|
7578
|
+
categorizer(charBefore(match.input, match.index + match[0].length)) != state_.CharCategory.Word ||
|
|
7579
|
+
(categorizer(charBefore(match.input, match.index)) != state_.CharCategory.Word &&
|
|
7580
|
+
categorizer(charAfter(match.input, match.index + match[0].length)) != state_.CharCategory.Word);
|
|
7540
7581
|
}
|
|
7541
7582
|
class RegExpQuery extends QueryType {
|
|
7542
|
-
nextMatch(
|
|
7543
|
-
let cursor = regexpCursor(this.spec,
|
|
7583
|
+
nextMatch(state, curFrom, curTo) {
|
|
7584
|
+
let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();
|
|
7544
7585
|
if (cursor.done)
|
|
7545
|
-
cursor = regexpCursor(this.spec,
|
|
7586
|
+
cursor = regexpCursor(this.spec, state, 0, curFrom).next();
|
|
7546
7587
|
return cursor.done ? null : cursor.value;
|
|
7547
7588
|
}
|
|
7548
|
-
prevMatchInRange(
|
|
7589
|
+
prevMatchInRange(state, from, to) {
|
|
7549
7590
|
for (let size = 1;; size++) {
|
|
7550
7591
|
let start = Math.max(from, to - size * 10000 /* ChunkSize */);
|
|
7551
|
-
let cursor = regexpCursor(this.spec,
|
|
7592
|
+
let cursor = regexpCursor(this.spec, state, start, to), range = null;
|
|
7552
7593
|
while (!cursor.next().done)
|
|
7553
7594
|
range = cursor.value;
|
|
7554
7595
|
if (range && (start == from || range.from > start + 10))
|
|
@@ -7557,9 +7598,9 @@ class RegExpQuery extends QueryType {
|
|
|
7557
7598
|
return null;
|
|
7558
7599
|
}
|
|
7559
7600
|
}
|
|
7560
|
-
prevMatch(
|
|
7561
|
-
return this.prevMatchInRange(
|
|
7562
|
-
this.prevMatchInRange(
|
|
7601
|
+
prevMatch(state, curFrom, curTo) {
|
|
7602
|
+
return this.prevMatchInRange(state, 0, curFrom) ||
|
|
7603
|
+
this.prevMatchInRange(state, curTo, state.doc.length);
|
|
7563
7604
|
}
|
|
7564
7605
|
getReplacement(result) {
|
|
7565
7606
|
return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
|
@@ -7567,8 +7608,8 @@ class RegExpQuery extends QueryType {
|
|
|
7567
7608
|
: i != "0" && +i < result.match.length ? result.match[i]
|
|
7568
7609
|
: m);
|
|
7569
7610
|
}
|
|
7570
|
-
matchAll(
|
|
7571
|
-
let cursor = regexpCursor(this.spec,
|
|
7611
|
+
matchAll(state, limit) {
|
|
7612
|
+
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
7572
7613
|
while (!cursor.next().done) {
|
|
7573
7614
|
if (ranges.length >= limit)
|
|
7574
7615
|
return null;
|
|
@@ -7576,8 +7617,8 @@ class RegExpQuery extends QueryType {
|
|
|
7576
7617
|
}
|
|
7577
7618
|
return ranges;
|
|
7578
7619
|
}
|
|
7579
|
-
highlight(
|
|
7580
|
-
let cursor = regexpCursor(this.spec,
|
|
7620
|
+
highlight(state, from, to, add) {
|
|
7621
|
+
let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* HighlightMargin */), Math.min(to + 250 /* HighlightMargin */, state.doc.length));
|
|
7581
7622
|
while (!cursor.next().done)
|
|
7582
7623
|
add(cursor.value.from, cursor.value.to);
|
|
7583
7624
|
}
|
|
@@ -7646,7 +7687,7 @@ const searchHighlighter = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
7646
7687
|
let { from, to } = ranges[i];
|
|
7647
7688
|
while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* HighlightMargin */)
|
|
7648
7689
|
to = ranges[++i].to;
|
|
7649
|
-
query.highlight(view.state
|
|
7690
|
+
query.highlight(view.state, from, to, (from, to) => {
|
|
7650
7691
|
let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
|
|
7651
7692
|
builder.add(from, to, selected ? selectedMatchMark : matchMark);
|
|
7652
7693
|
});
|
|
@@ -7670,7 +7711,7 @@ end.
|
|
|
7670
7711
|
*/
|
|
7671
7712
|
const findNext = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
7672
7713
|
let { to } = view.state.selection.main;
|
|
7673
|
-
let next = query.nextMatch(view.state
|
|
7714
|
+
let next = query.nextMatch(view.state, to, to);
|
|
7674
7715
|
if (!next)
|
|
7675
7716
|
return false;
|
|
7676
7717
|
view.dispatch({
|
|
@@ -7688,7 +7729,7 @@ of the document to start searching at the end again.
|
|
|
7688
7729
|
*/
|
|
7689
7730
|
const findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
7690
7731
|
let { state } = view, { from } = state.selection.main;
|
|
7691
|
-
let range = query.prevMatch(state
|
|
7732
|
+
let range = query.prevMatch(state, from, from);
|
|
7692
7733
|
if (!range)
|
|
7693
7734
|
return false;
|
|
7694
7735
|
view.dispatch({
|
|
@@ -7703,7 +7744,7 @@ const findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
|
7703
7744
|
Select all instances of the search query.
|
|
7704
7745
|
*/
|
|
7705
7746
|
const selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
7706
|
-
let ranges = query.matchAll(view.state
|
|
7747
|
+
let ranges = query.matchAll(view.state, 1000);
|
|
7707
7748
|
if (!ranges || !ranges.length)
|
|
7708
7749
|
return false;
|
|
7709
7750
|
view.dispatch({
|
|
@@ -7741,7 +7782,7 @@ const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
|
7741
7782
|
let { state } = view, { from, to } = state.selection.main;
|
|
7742
7783
|
if (state.readOnly)
|
|
7743
7784
|
return false;
|
|
7744
|
-
let next = query.nextMatch(state
|
|
7785
|
+
let next = query.nextMatch(state, from, from);
|
|
7745
7786
|
if (!next)
|
|
7746
7787
|
return false;
|
|
7747
7788
|
let changes = [], selection, replacement;
|
|
@@ -7749,7 +7790,7 @@ const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
|
7749
7790
|
if (next.from == from && next.to == to) {
|
|
7750
7791
|
replacement = state.toText(query.getReplacement(next));
|
|
7751
7792
|
changes.push({ from: next.from, to: next.to, insert: replacement });
|
|
7752
|
-
next = query.nextMatch(state
|
|
7793
|
+
next = query.nextMatch(state, next.from, next.to);
|
|
7753
7794
|
announce.push(view_.EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
|
|
7754
7795
|
}
|
|
7755
7796
|
if (next) {
|
|
@@ -7772,7 +7813,7 @@ replacement.
|
|
|
7772
7813
|
const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
7773
7814
|
if (view.state.readOnly)
|
|
7774
7815
|
return false;
|
|
7775
|
-
let changes = query.matchAll(view.state
|
|
7816
|
+
let changes = query.matchAll(view.state, 1e9).map(match => {
|
|
7776
7817
|
let { from, to } = match;
|
|
7777
7818
|
return { from, to, insert: query.getReplacement(match) };
|
|
7778
7819
|
});
|
|
@@ -7790,7 +7831,7 @@ function createSearchPanel(view) {
|
|
|
7790
7831
|
return view.state.facet(searchConfigFacet).createPanel(view);
|
|
7791
7832
|
}
|
|
7792
7833
|
function defaultQuery(state, fallback) {
|
|
7793
|
-
var _a, _b, _c;
|
|
7834
|
+
var _a, _b, _c, _d;
|
|
7794
7835
|
let sel = state.selection.main;
|
|
7795
7836
|
let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
|
|
7796
7837
|
if (fallback && !selText)
|
|
@@ -7800,6 +7841,7 @@ function defaultQuery(state, fallback) {
|
|
|
7800
7841
|
search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\n/g, "\\n"),
|
|
7801
7842
|
caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,
|
|
7802
7843
|
literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,
|
|
7844
|
+
wholeWord: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _d !== void 0 ? _d : config.wholeWord
|
|
7803
7845
|
});
|
|
7804
7846
|
}
|
|
7805
7847
|
/**
|
|
@@ -7895,6 +7937,12 @@ class SearchPanel {
|
|
|
7895
7937
|
checked: query.regexp,
|
|
7896
7938
|
onchange: this.commit
|
|
7897
7939
|
});
|
|
7940
|
+
this.wordField = crelt("input", {
|
|
7941
|
+
type: "checkbox",
|
|
7942
|
+
name: "word",
|
|
7943
|
+
checked: query.wholeWord,
|
|
7944
|
+
onchange: this.commit
|
|
7945
|
+
});
|
|
7898
7946
|
function button(name, onclick, content) {
|
|
7899
7947
|
return crelt("button", { class: "cm-button", name, onclick, type: "button" }, content);
|
|
7900
7948
|
}
|
|
@@ -7905,6 +7953,7 @@ class SearchPanel {
|
|
|
7905
7953
|
button("select", () => selectMatches(view), [phrase(view, "all")]),
|
|
7906
7954
|
crelt("label", null, [this.caseField, phrase(view, "match case")]),
|
|
7907
7955
|
crelt("label", null, [this.reField, phrase(view, "regexp")]),
|
|
7956
|
+
crelt("label", null, [this.wordField, phrase(view, "by word")]),
|
|
7908
7957
|
...view.state.readOnly ? [] : [
|
|
7909
7958
|
crelt("br"),
|
|
7910
7959
|
this.replaceField,
|
|
@@ -7924,7 +7973,8 @@ class SearchPanel {
|
|
|
7924
7973
|
search: this.searchField.value,
|
|
7925
7974
|
caseSensitive: this.caseField.checked,
|
|
7926
7975
|
regexp: this.reField.checked,
|
|
7927
|
-
|
|
7976
|
+
wholeWord: this.wordField.checked,
|
|
7977
|
+
replace: this.replaceField.value,
|
|
7928
7978
|
});
|
|
7929
7979
|
if (!query.eq(this.query)) {
|
|
7930
7980
|
this.query = query;
|
|
@@ -7957,6 +8007,7 @@ class SearchPanel {
|
|
|
7957
8007
|
this.replaceField.value = query.replace;
|
|
7958
8008
|
this.caseField.checked = query.caseSensitive;
|
|
7959
8009
|
this.reField.checked = query.regexp;
|
|
8010
|
+
this.wordField.checked = query.wholeWord;
|
|
7960
8011
|
}
|
|
7961
8012
|
mount() {
|
|
7962
8013
|
this.searchField.select();
|
|
@@ -8257,7 +8308,7 @@ class FuzzyMatcher {
|
|
|
8257
8308
|
if (chars.length == 1) {
|
|
8258
8309
|
let first = (0,state_.codePointAt)(word, 0);
|
|
8259
8310
|
return first == chars[0] ? [0, 0, (0,state_.codePointSize)(first)]
|
|
8260
|
-
: first == folded[0] ? [-200 /* CaseFold */, 0, (0,state_.codePointSize)(first)] : null;
|
|
8311
|
+
: first == folded[0] ? [-200 /* Penalty.CaseFold */, 0, (0,state_.codePointSize)(first)] : null;
|
|
8261
8312
|
}
|
|
8262
8313
|
let direct = word.indexOf(this.pattern);
|
|
8263
8314
|
if (direct == 0)
|
|
@@ -8285,7 +8336,7 @@ class FuzzyMatcher {
|
|
|
8285
8336
|
let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
|
|
8286
8337
|
let hasLower = /[a-z]/.test(word), wordAdjacent = true;
|
|
8287
8338
|
// Go over the option's text, scanning for the various kinds of matches
|
|
8288
|
-
for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) {
|
|
8339
|
+
for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
|
|
8289
8340
|
let next = (0,state_.codePointAt)(word, i);
|
|
8290
8341
|
if (direct < 0) {
|
|
8291
8342
|
if (preciseTo < len && next == chars[preciseTo])
|
|
@@ -8303,9 +8354,9 @@ class FuzzyMatcher {
|
|
|
8303
8354
|
}
|
|
8304
8355
|
}
|
|
8305
8356
|
let ch, type = next < 0xff
|
|
8306
|
-
? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Lower */ : next >= 65 && next <= 90 ? 1 /* Upper */ : 0 /* NonWord */)
|
|
8307
|
-
: ((ch = (0,state_.fromCodePoint)(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */);
|
|
8308
|
-
if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) {
|
|
8357
|
+
? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
|
|
8358
|
+
: ((ch = (0,state_.fromCodePoint)(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
|
|
8359
|
+
if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
|
|
8309
8360
|
if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
|
|
8310
8361
|
byWord[byWordTo++] = i;
|
|
8311
8362
|
else if (byWord.length)
|
|
@@ -8315,17 +8366,17 @@ class FuzzyMatcher {
|
|
|
8315
8366
|
i += (0,state_.codePointSize)(next);
|
|
8316
8367
|
}
|
|
8317
8368
|
if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
|
|
8318
|
-
return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word);
|
|
8369
|
+
return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
|
|
8319
8370
|
if (adjacentTo == len && adjacentStart == 0)
|
|
8320
|
-
return [-200 /* CaseFold */ - word.length, 0, adjacentEnd];
|
|
8371
|
+
return [-200 /* Penalty.CaseFold */ - word.length, 0, adjacentEnd];
|
|
8321
8372
|
if (direct > -1)
|
|
8322
|
-
return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length];
|
|
8373
|
+
return [-700 /* Penalty.NotStart */ - word.length, direct, direct + this.pattern.length];
|
|
8323
8374
|
if (adjacentTo == len)
|
|
8324
|
-
return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd];
|
|
8375
|
+
return [-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, adjacentStart, adjacentEnd];
|
|
8325
8376
|
if (byWordTo == len)
|
|
8326
|
-
return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ +
|
|
8327
|
-
(wordAdjacent ? 0 : -1100 /* Gap */), byWord, word);
|
|
8328
|
-
return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word);
|
|
8377
|
+
return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
|
|
8378
|
+
(wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
|
|
8379
|
+
return chars.length == 2 ? null : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
|
|
8329
8380
|
}
|
|
8330
8381
|
result(score, positions, word) {
|
|
8331
8382
|
let result = [score - word.length], i = 1;
|
|
@@ -8471,7 +8522,7 @@ class CompletionTooltip {
|
|
|
8471
8522
|
}
|
|
8472
8523
|
updateSel() {
|
|
8473
8524
|
let cState = this.view.state.field(this.stateField), open = cState.open;
|
|
8474
|
-
if (open.selected < this.range.from || open.selected >= this.range.to) {
|
|
8525
|
+
if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
|
|
8475
8526
|
this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
|
|
8476
8527
|
this.list.remove();
|
|
8477
8528
|
this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
|
|
@@ -8532,26 +8583,47 @@ class CompletionTooltip {
|
|
|
8532
8583
|
let sel = this.dom.querySelector("[aria-selected]");
|
|
8533
8584
|
if (!sel || !this.info)
|
|
8534
8585
|
return null;
|
|
8586
|
+
let win = this.dom.ownerDocument.defaultView;
|
|
8535
8587
|
let listRect = this.dom.getBoundingClientRect();
|
|
8536
8588
|
let infoRect = this.info.getBoundingClientRect();
|
|
8537
8589
|
let selRect = sel.getBoundingClientRect();
|
|
8538
|
-
if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
|
|
8590
|
+
if (selRect.top > Math.min(win.innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
|
|
8539
8591
|
return null;
|
|
8540
|
-
let
|
|
8541
|
-
let
|
|
8542
|
-
let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right;
|
|
8592
|
+
let rtl = this.view.textDirection == view_.Direction.RTL, left = rtl, narrow = false, maxWidth;
|
|
8593
|
+
let top = "", bottom = "";
|
|
8594
|
+
let spaceLeft = listRect.left, spaceRight = win.innerWidth - listRect.right;
|
|
8543
8595
|
if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
|
|
8544
8596
|
left = false;
|
|
8545
8597
|
else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
|
|
8546
8598
|
left = true;
|
|
8547
|
-
|
|
8599
|
+
if (infoRect.width <= (left ? spaceLeft : spaceRight)) {
|
|
8600
|
+
top = (Math.max(0, Math.min(selRect.top, win.innerHeight - infoRect.height)) - listRect.top) + "px";
|
|
8601
|
+
maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight) + "px";
|
|
8602
|
+
}
|
|
8603
|
+
else {
|
|
8604
|
+
narrow = true;
|
|
8605
|
+
maxWidth = Math.min(400 /* Info.Width */, (rtl ? listRect.right : win.innerWidth - listRect.left) - 30 /* Info.Margin */) + "px";
|
|
8606
|
+
let spaceBelow = win.innerHeight - listRect.bottom;
|
|
8607
|
+
if (spaceBelow >= infoRect.height || spaceBelow > listRect.top) // Below the completion
|
|
8608
|
+
top = (selRect.bottom - listRect.top) + "px";
|
|
8609
|
+
else // Above it
|
|
8610
|
+
bottom = (listRect.bottom - selRect.top) + "px";
|
|
8611
|
+
}
|
|
8612
|
+
return {
|
|
8613
|
+
top, bottom, maxWidth,
|
|
8614
|
+
class: narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right",
|
|
8615
|
+
};
|
|
8548
8616
|
}
|
|
8549
8617
|
positionInfo(pos) {
|
|
8550
8618
|
if (this.info) {
|
|
8551
|
-
this.info.style.top = (pos ? pos.top : -1e6) + "px";
|
|
8552
8619
|
if (pos) {
|
|
8553
|
-
this.info.
|
|
8554
|
-
this.info.
|
|
8620
|
+
this.info.style.top = pos.top;
|
|
8621
|
+
this.info.style.bottom = pos.bottom;
|
|
8622
|
+
this.info.style.maxWidth = pos.maxWidth;
|
|
8623
|
+
this.info.className = "cm-tooltip cm-completionInfo cm-completionInfo-" + pos.class;
|
|
8624
|
+
}
|
|
8625
|
+
else {
|
|
8626
|
+
this.info.style.top = "-1e6px";
|
|
8555
8627
|
}
|
|
8556
8628
|
}
|
|
8557
8629
|
}
|
|
@@ -8689,7 +8761,7 @@ class CompletionState {
|
|
|
8689
8761
|
state.languageDataAt("autocomplete", cur(state)).map(asSource);
|
|
8690
8762
|
let active = sources.map(source => {
|
|
8691
8763
|
let value = this.active.find(s => s.source == source) ||
|
|
8692
|
-
new ActiveSource(source, this.active.some(a => a.state != 0 /* Inactive */) ? 1 /* Pending */ : 0 /* Inactive */);
|
|
8764
|
+
new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
|
|
8693
8765
|
return value.update(tr, conf);
|
|
8694
8766
|
});
|
|
8695
8767
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
@@ -8697,8 +8769,8 @@ class CompletionState {
|
|
|
8697
8769
|
let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
8698
8770
|
!sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf)
|
|
8699
8771
|
: this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
|
|
8700
|
-
if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
|
|
8701
|
-
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */) : a);
|
|
8772
|
+
if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
|
|
8773
|
+
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
|
|
8702
8774
|
for (let effect of tr.effects)
|
|
8703
8775
|
if (effect.is(setSelectedEffect))
|
|
8704
8776
|
open = open && open.setSelected(effect.value, this.id);
|
|
@@ -8752,13 +8824,13 @@ class ActiveSource {
|
|
|
8752
8824
|
value = value.handleUserEvent(tr, event, conf);
|
|
8753
8825
|
else if (tr.docChanged)
|
|
8754
8826
|
value = value.handleChange(tr);
|
|
8755
|
-
else if (tr.selection && value.state != 0 /* Inactive */)
|
|
8756
|
-
value = new ActiveSource(value.source, 0 /* Inactive */);
|
|
8827
|
+
else if (tr.selection && value.state != 0 /* State.Inactive */)
|
|
8828
|
+
value = new ActiveSource(value.source, 0 /* State.Inactive */);
|
|
8757
8829
|
for (let effect of tr.effects) {
|
|
8758
8830
|
if (effect.is(startCompletionEffect))
|
|
8759
|
-
value = new ActiveSource(value.source, 1 /* Pending */, effect.value ? cur(tr.state) : -1);
|
|
8831
|
+
value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value ? cur(tr.state) : -1);
|
|
8760
8832
|
else if (effect.is(closeCompletionEffect))
|
|
8761
|
-
value = new ActiveSource(value.source, 0 /* Inactive */);
|
|
8833
|
+
value = new ActiveSource(value.source, 0 /* State.Inactive */);
|
|
8762
8834
|
else if (effect.is(setActiveEffect))
|
|
8763
8835
|
for (let active of effect.value)
|
|
8764
8836
|
if (active.source == value.source)
|
|
@@ -8767,10 +8839,10 @@ class ActiveSource {
|
|
|
8767
8839
|
return value;
|
|
8768
8840
|
}
|
|
8769
8841
|
handleUserEvent(tr, type, conf) {
|
|
8770
|
-
return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* Pending */);
|
|
8842
|
+
return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* State.Pending */);
|
|
8771
8843
|
}
|
|
8772
8844
|
handleChange(tr) {
|
|
8773
|
-
return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
|
|
8845
|
+
return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
|
|
8774
8846
|
}
|
|
8775
8847
|
map(changes) {
|
|
8776
8848
|
return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
|
|
@@ -8778,7 +8850,7 @@ class ActiveSource {
|
|
|
8778
8850
|
}
|
|
8779
8851
|
class ActiveResult extends ActiveSource {
|
|
8780
8852
|
constructor(source, explicitPos, result, from, to) {
|
|
8781
|
-
super(source, 2 /* Result */, explicitPos);
|
|
8853
|
+
super(source, 2 /* State.Result */, explicitPos);
|
|
8782
8854
|
this.result = result;
|
|
8783
8855
|
this.from = from;
|
|
8784
8856
|
this.to = to;
|
|
@@ -8791,17 +8863,17 @@ class ActiveResult extends ActiveSource {
|
|
|
8791
8863
|
if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
|
|
8792
8864
|
pos > to ||
|
|
8793
8865
|
type == "delete" && cur(tr.startState) == this.from)
|
|
8794
|
-
return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* Pending */ : 0 /* Inactive */);
|
|
8866
|
+
return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* State.Pending */ : 0 /* State.Inactive */);
|
|
8795
8867
|
let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos), updated;
|
|
8796
8868
|
if (checkValid(this.result.validFor, tr.state, from, to))
|
|
8797
8869
|
return new ActiveResult(this.source, explicitPos, this.result, from, to);
|
|
8798
8870
|
if (this.result.update &&
|
|
8799
8871
|
(updated = this.result.update(this.result, from, to, new CompletionContext(tr.state, pos, explicitPos >= 0))))
|
|
8800
8872
|
return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur(tr.state));
|
|
8801
|
-
return new ActiveSource(this.source, 1 /* Pending */, explicitPos);
|
|
8873
|
+
return new ActiveSource(this.source, 1 /* State.Pending */, explicitPos);
|
|
8802
8874
|
}
|
|
8803
8875
|
handleChange(tr) {
|
|
8804
|
-
return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
|
|
8876
|
+
return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
|
|
8805
8877
|
}
|
|
8806
8878
|
map(mapping) {
|
|
8807
8879
|
return mapping.empty ? this :
|
|
@@ -8879,7 +8951,7 @@ Close the currently active completion.
|
|
|
8879
8951
|
*/
|
|
8880
8952
|
const closeCompletion = (view) => {
|
|
8881
8953
|
let cState = view.state.field(completionState, false);
|
|
8882
|
-
if (!cState || !cState.active.some(a => a.state != 0 /* Inactive */))
|
|
8954
|
+
if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
|
|
8883
8955
|
return false;
|
|
8884
8956
|
view.dispatch({ effects: closeCompletionEffect.of(null) });
|
|
8885
8957
|
return true;
|
|
@@ -8902,9 +8974,9 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
8902
8974
|
this.debounceUpdate = -1;
|
|
8903
8975
|
this.running = [];
|
|
8904
8976
|
this.debounceAccept = -1;
|
|
8905
|
-
this.composing = 0 /* None */;
|
|
8977
|
+
this.composing = 0 /* CompositionState.None */;
|
|
8906
8978
|
for (let active of view.state.field(completionState).active)
|
|
8907
|
-
if (active.state == 1 /* Pending */)
|
|
8979
|
+
if (active.state == 1 /* State.Pending */)
|
|
8908
8980
|
this.startQuery(active);
|
|
8909
8981
|
}
|
|
8910
8982
|
update(update) {
|
|
@@ -8935,21 +9007,21 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
8935
9007
|
}
|
|
8936
9008
|
if (this.debounceUpdate > -1)
|
|
8937
9009
|
clearTimeout(this.debounceUpdate);
|
|
8938
|
-
this.debounceUpdate = cState.active.some(a => a.state == 1 /* Pending */ && !this.running.some(q => q.active.source == a.source))
|
|
9010
|
+
this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
|
|
8939
9011
|
? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
|
|
8940
|
-
if (this.composing != 0 /* None */)
|
|
9012
|
+
if (this.composing != 0 /* CompositionState.None */)
|
|
8941
9013
|
for (let tr of update.transactions) {
|
|
8942
9014
|
if (getUserEvent(tr) == "input")
|
|
8943
|
-
this.composing = 2 /* Changed */;
|
|
8944
|
-
else if (this.composing == 2 /* Changed */ && tr.selection)
|
|
8945
|
-
this.composing = 3 /* ChangedAndMoved */;
|
|
9015
|
+
this.composing = 2 /* CompositionState.Changed */;
|
|
9016
|
+
else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
|
|
9017
|
+
this.composing = 3 /* CompositionState.ChangedAndMoved */;
|
|
8946
9018
|
}
|
|
8947
9019
|
}
|
|
8948
9020
|
startUpdate() {
|
|
8949
9021
|
this.debounceUpdate = -1;
|
|
8950
9022
|
let { state } = this.view, cState = state.field(completionState);
|
|
8951
9023
|
for (let active of cState.active) {
|
|
8952
|
-
if (active.state == 1 /* Pending */ && !this.running.some(r => r.active.source == active.source))
|
|
9024
|
+
if (active.state == 1 /* State.Pending */ && !this.running.some(r => r.active.source == active.source))
|
|
8953
9025
|
this.startQuery(active);
|
|
8954
9026
|
}
|
|
8955
9027
|
}
|
|
@@ -9000,14 +9072,14 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
9000
9072
|
}
|
|
9001
9073
|
}
|
|
9002
9074
|
let current = this.view.state.field(completionState).active.find(a => a.source == query.active.source);
|
|
9003
|
-
if (current && current.state == 1 /* Pending */) {
|
|
9075
|
+
if (current && current.state == 1 /* State.Pending */) {
|
|
9004
9076
|
if (query.done == null) {
|
|
9005
9077
|
// Explicitly failed. Should clear the pending status if it
|
|
9006
9078
|
// hasn't been re-set in the meantime.
|
|
9007
|
-
let active = new ActiveSource(query.active.source, 0 /* Inactive */);
|
|
9079
|
+
let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
|
|
9008
9080
|
for (let tr of query.updates)
|
|
9009
9081
|
active = active.update(tr, conf);
|
|
9010
|
-
if (active.state != 1 /* Pending */)
|
|
9082
|
+
if (active.state != 1 /* State.Pending */)
|
|
9011
9083
|
updated.push(active);
|
|
9012
9084
|
}
|
|
9013
9085
|
else {
|
|
@@ -9027,15 +9099,15 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
9027
9099
|
this.view.dispatch({ effects: closeCompletionEffect.of(null) });
|
|
9028
9100
|
},
|
|
9029
9101
|
compositionstart() {
|
|
9030
|
-
this.composing = 1 /* Started */;
|
|
9102
|
+
this.composing = 1 /* CompositionState.Started */;
|
|
9031
9103
|
},
|
|
9032
9104
|
compositionend() {
|
|
9033
|
-
if (this.composing == 3 /* ChangedAndMoved */) {
|
|
9105
|
+
if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
|
|
9034
9106
|
// Safari fires compositionend events synchronously, possibly
|
|
9035
9107
|
// from inside an update, so dispatch asynchronously to avoid reentrancy
|
|
9036
9108
|
setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
|
|
9037
9109
|
}
|
|
9038
|
-
this.composing = 0 /* None */;
|
|
9110
|
+
this.composing = 0 /* CompositionState.None */;
|
|
9039
9111
|
}
|
|
9040
9112
|
}
|
|
9041
9113
|
});
|
|
@@ -9080,10 +9152,13 @@ const autocomplete_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
9080
9152
|
position: "absolute",
|
|
9081
9153
|
padding: "3px 9px",
|
|
9082
9154
|
width: "max-content",
|
|
9083
|
-
maxWidth:
|
|
9155
|
+
maxWidth: `${400 /* Info.Width */}px`,
|
|
9156
|
+
boxSizing: "border-box"
|
|
9084
9157
|
},
|
|
9085
9158
|
".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
|
|
9086
9159
|
".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
|
|
9160
|
+
".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
|
|
9161
|
+
".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
|
|
9087
9162
|
"&light .cm-snippetField": { backgroundColor: "#00000022" },
|
|
9088
9163
|
"&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
|
|
9089
9164
|
".cm-snippetFieldPosition": {
|
|
@@ -9418,7 +9493,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
|
|
|
9418
9493
|
if (!seen[m[0]] && pos + m.index != ignoreAt) {
|
|
9419
9494
|
result.push({ type: "text", label: m[0] });
|
|
9420
9495
|
seen[m[0]] = true;
|
|
9421
|
-
if (result.length >= 2000 /* MaxList */)
|
|
9496
|
+
if (result.length >= 2000 /* C.MaxList */)
|
|
9422
9497
|
return;
|
|
9423
9498
|
}
|
|
9424
9499
|
}
|
|
@@ -9426,7 +9501,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
|
|
|
9426
9501
|
}
|
|
9427
9502
|
}
|
|
9428
9503
|
function collectWords(doc, cache, wordRE, to, ignoreAt) {
|
|
9429
|
-
let big = doc.length >= 1000 /* MinCacheLen */;
|
|
9504
|
+
let big = doc.length >= 1000 /* C.MinCacheLen */;
|
|
9430
9505
|
let cached = big && cache.get(doc);
|
|
9431
9506
|
if (cached)
|
|
9432
9507
|
return cached;
|
|
@@ -9434,7 +9509,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
|
|
|
9434
9509
|
if (doc.children) {
|
|
9435
9510
|
let pos = 0;
|
|
9436
9511
|
for (let ch of doc.children) {
|
|
9437
|
-
if (ch.length >= 1000 /* MinCacheLen */) {
|
|
9512
|
+
if (ch.length >= 1000 /* C.MinCacheLen */) {
|
|
9438
9513
|
for (let c of collectWords(ch, cache, wordRE, to - pos, ignoreAt - pos)) {
|
|
9439
9514
|
if (!seen[c.label]) {
|
|
9440
9515
|
seen[c.label] = true;
|
|
@@ -9451,7 +9526,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
|
|
|
9451
9526
|
else {
|
|
9452
9527
|
storeWords(doc, wordRE, result, seen, ignoreAt);
|
|
9453
9528
|
}
|
|
9454
|
-
if (big && result.length < 2000 /* MaxList */)
|
|
9529
|
+
if (big && result.length < 2000 /* C.MaxList */)
|
|
9455
9530
|
cache.set(doc, result);
|
|
9456
9531
|
return result;
|
|
9457
9532
|
}
|
|
@@ -9467,7 +9542,7 @@ const completeAnyWord = context => {
|
|
|
9467
9542
|
if (!token && !context.explicit)
|
|
9468
9543
|
return null;
|
|
9469
9544
|
let from = token ? token.from : context.pos;
|
|
9470
|
-
let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* Range */, from);
|
|
9545
|
+
let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* C.Range */, from);
|
|
9471
9546
|
return { from, options, validFor: mapRE(re, s => "^" + s) };
|
|
9472
9547
|
};
|
|
9473
9548
|
|
|
@@ -9556,14 +9631,13 @@ const deleteBracketPair = ({ state, dispatch }) => {
|
|
|
9556
9631
|
for (let token of tokens) {
|
|
9557
9632
|
if (token == before && nextChar(state.doc, range.head) == closing((0,state_.codePointAt)(token, 0)))
|
|
9558
9633
|
return { changes: { from: range.head - token.length, to: range.head + token.length },
|
|
9559
|
-
range: state_.EditorSelection.cursor(range.head - token.length)
|
|
9560
|
-
userEvent: "delete.backward" };
|
|
9634
|
+
range: state_.EditorSelection.cursor(range.head - token.length) };
|
|
9561
9635
|
}
|
|
9562
9636
|
}
|
|
9563
9637
|
return { range: dont = range };
|
|
9564
9638
|
});
|
|
9565
9639
|
if (!dont)
|
|
9566
|
-
dispatch(state.update(changes, { scrollIntoView: true }));
|
|
9640
|
+
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete.backward" }));
|
|
9567
9641
|
return !dont;
|
|
9568
9642
|
};
|
|
9569
9643
|
/**
|
|
@@ -9749,8 +9823,8 @@ returns `null`.
|
|
|
9749
9823
|
*/
|
|
9750
9824
|
function completionStatus(state) {
|
|
9751
9825
|
let cState = state.field(completionState, false);
|
|
9752
|
-
return cState && cState.active.some(a => a.state == 1 /* Pending */) ? "pending"
|
|
9753
|
-
: cState && cState.active.some(a => a.state != 0 /* Inactive */) ? "active" : null;
|
|
9826
|
+
return cState && cState.active.some(a => a.state == 1 /* State.Pending */) ? "pending"
|
|
9827
|
+
: cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null;
|
|
9754
9828
|
}
|
|
9755
9829
|
const completionArrayCache = /*@__PURE__*/new WeakMap;
|
|
9756
9830
|
/**
|
|
@@ -10669,12 +10743,12 @@ var theme_one_dark_ = __webpack_require__(362);
|
|
|
10669
10743
|
;// CONCATENATED MODULE: ./src/utils.ts
|
|
10670
10744
|
var getStatistics=function getStatistics(view){return{line:view.state.doc.lineAt(view.state.selection.main.from),lineCount:view.state.doc.lines,lineBreak:view.state.lineBreak,length:view.state.doc.length,readOnly:view.state.readOnly,tabSize:view.state.tabSize,selection:view.state.selection,selectionAsSingle:view.state.selection.asSingle().main,ranges:view.state.selection.ranges,selectionCode:view.state.sliceDoc(view.state.selection.main.from,view.state.selection.main.to),selections:view.state.selection.ranges.map(function(r){return view.state.sliceDoc(r.from,r.to);}),selectedText:view.state.selection.ranges.some(function(r){return!r.empty;})};};
|
|
10671
10745
|
;// CONCATENATED MODULE: ./src/useCodeMirror.ts
|
|
10672
|
-
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$readOnly=props.readOnly,readOnly=_props$readOnly===void 0?false:_props$readOnly,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}onStatistics&&onStatistics(getStatistics(vu));});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){if(typeof defaultBasicSetup==='boolean'){getExtensions.unshift(basicSetup());}else{getExtensions.unshift(basicSetup(defaultBasicSetup));}}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(readOnly){getExtensions.push(state_.EditorState.readOnly.of(true));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var
|
|
10746
|
+
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$readOnly=props.readOnly,readOnly=_props$readOnly===void 0?false:_props$readOnly,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root,initialState=props.initialState;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}onStatistics&&onStatistics(getStatistics(vu));});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){if(typeof defaultBasicSetup==='boolean'){getExtensions.unshift(basicSetup());}else{getExtensions.unshift(basicSetup(defaultBasicSetup));}}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(readOnly){getExtensions.push(state_.EditorState.readOnly.of(true));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var config={doc:value,selection:selection,extensions:getExtensions};var stateCurrent=initialState?state_.EditorState.fromJSON(initialState.json,config,initialState.fields):state_.EditorState.create(config);setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);onCreateEditor&&onCreateEditor(viewCurrent,stateCurrent);}}return function(){if(view){setState(undefined);setView(undefined);}};},[container,state]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return setContainer(props.container);},[props.container]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return function(){if(view){view.destroy();setView(undefined);}};},[view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(autoFocus&&view){view.focus();}},[autoFocus,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(view){view.dispatch({effects:state_.StateEffect.reconfigure.of(getExtensions)});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10673
10747
|
},[theme,extensions,height,minHeight,maxHeight,width,minWidth,maxWidth,placeholderStr,editable,readOnly,defaultIndentWithTab,defaultBasicSetup,onChange,onUpdate]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var currentValue=view?view.state.doc.toString():'';if(view&&value!==currentValue){view.dispatch({changes:{from:0,to:currentValue.length,insert:value||''}});}},[value,view]);return{state:state,setState:setState,view:view,setView:setView,container:container,setContainer:setContainer};}
|
|
10674
10748
|
// EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js
|
|
10675
10749
|
var jsx_runtime = __webpack_require__(605);
|
|
10676
10750
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
10677
|
-
var _excluded=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"];var ReactCodeMirror=/*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,readOnly=props.readOnly,root=props.root,other=_objectWithoutProperties(props,_excluded);var editor=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var _useCodeMirror=useCodeMirror({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,readOnly:readOnly,selection:selection,onChange:onChange,onStatistics:onStatistics,onCreateEditor:onCreateEditor,onUpdate:onUpdate,extensions:extensions}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container,setContainer=_useCodeMirror.setContainer;(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return{editor:editor.current,state:state,view:view};},[editor,container,state,view]);// check type of value
|
|
10751
|
+
var _excluded=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"];var ReactCodeMirror=/*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,readOnly=props.readOnly,root=props.root,initialState=props.initialState,other=_objectWithoutProperties(props,_excluded);var editor=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var _useCodeMirror=useCodeMirror({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,readOnly:readOnly,selection:selection,onChange:onChange,onStatistics:onStatistics,onCreateEditor:onCreateEditor,onUpdate:onUpdate,extensions:extensions,initialState:initialState}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container,setContainer=_useCodeMirror.setContainer;(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return{editor:editor.current,state:state,view:view};},[editor,container,state,view]);// check type of value
|
|
10678
10752
|
if(typeof value!=='string'){throw new Error("value must be typeof string but got ".concat(typeof value));}var defaultClassNames=typeof theme==='string'?"cm-theme-".concat(theme):'cm-theme';return/*#__PURE__*/(0,jsx_runtime.jsx)("div",_objectSpread2({ref:editor,className:"".concat(defaultClassNames).concat(className?" ".concat(className):'')},other));});ReactCodeMirror.displayName='CodeMirror';/* harmony default export */ const src = (ReactCodeMirror);
|
|
10679
10753
|
})();
|
|
10680
10754
|
|