@veltra/desktop 1.2.16 → 1.2.18
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/dist/components/action/action-group.vue.d.ts +2 -2
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
- package/dist/components/cascade/cascade.vue.d.ts +3 -3
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/code-editor/basic-setup.js +7 -7
- package/dist/components/code-editor/code-editor.js +15 -10
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/empty/empty.vue.d.ts +1 -1
- package/dist/components/file-picker/file-picker.vue.d.ts +1 -1
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
- package/dist/components/password-input/password-input.vue.d.ts +1 -1
- package/dist/components/pop-confirm/pop-confirm.vue.d.ts +1 -1
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tip/tip.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +1750 -0
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js +1719 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +51 -0
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +378 -0
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +31 -0
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +601 -0
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js +1767 -0
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +569 -0
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js +1142 -0
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js +3372 -0
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +165 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js +9770 -0
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js +1567 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +864 -0
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js +235 -0
- package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +470 -0
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js +55 -0
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js +1485 -0
- package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +73 -0
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -0
- package/dist/node_modules/.bun/crelt@1.0.6/node_modules/crelt/index.js +26 -0
- package/dist/node_modules/.bun/crelt@1.0.6/node_modules/crelt/index.js.map +1 -0
- package/dist/node_modules/.bun/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js +95 -0
- package/dist/node_modules/.bun/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js +104 -0
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js.map +1 -0
- package/package.json +20 -18
- package/src/components/code-editor/code-editor.vue +12 -7
|
@@ -0,0 +1,1142 @@
|
|
|
1
|
+
import { CharCategory, EditorSelection, EditorState, Facet, Prec, RangeSetBuilder, StateEffect, StateField, codePointAt, codePointSize, combineConfig, findClusterBreak, fromCodePoint } from "../../../../../@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js";
|
|
2
|
+
import crelt from "../../../../../crelt@1.0.6/node_modules/crelt/index.js";
|
|
3
|
+
import { Decoration, EditorView, ViewPlugin, getPanel, runScopeHandlers, showDialog, showPanel } from "../../../../../@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js";
|
|
4
|
+
//#region ../../node_modules/.bun/@codemirror+search@6.7.1/node_modules/@codemirror/search/dist/index.js
|
|
5
|
+
const basicNormalize = typeof String.prototype.normalize == "function" ? (x) => x.normalize("NFKD") : (x) => x;
|
|
6
|
+
/**
|
|
7
|
+
A search cursor provides an iterator over text matches in a
|
|
8
|
+
document.
|
|
9
|
+
*/
|
|
10
|
+
var SearchCursor = class {
|
|
11
|
+
/**
|
|
12
|
+
Create a text cursor. The query is the search string, `from` to
|
|
13
|
+
`to` provides the region to search.
|
|
14
|
+
|
|
15
|
+
When `normalize` is given, it will be called, on both the query
|
|
16
|
+
string and the content it is matched against, before comparing.
|
|
17
|
+
You can, for example, create a case-insensitive search by
|
|
18
|
+
passing `s => s.toLowerCase()`.
|
|
19
|
+
|
|
20
|
+
Text is always normalized with
|
|
21
|
+
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
22
|
+
(when supported).
|
|
23
|
+
*/
|
|
24
|
+
constructor(text, query, from = 0, to = text.length, normalize, test) {
|
|
25
|
+
this.test = test;
|
|
26
|
+
/**
|
|
27
|
+
The current match (only holds a meaningful value after
|
|
28
|
+
[`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
|
|
29
|
+
`done` is false).
|
|
30
|
+
|
|
31
|
+
The `precise` flag will be set to false if the match starts or
|
|
32
|
+
ends _inside_ a character that, when normalized, expands to
|
|
33
|
+
multiple characters. It indicates that the `from`-`to` range
|
|
34
|
+
covers content that isn't part of the actual match.
|
|
35
|
+
*/
|
|
36
|
+
this.value = {
|
|
37
|
+
from: 0,
|
|
38
|
+
to: 0,
|
|
39
|
+
precise: false
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
Whether the end of the iterated region has been reached.
|
|
43
|
+
*/
|
|
44
|
+
this.done = false;
|
|
45
|
+
this.matches = [];
|
|
46
|
+
this.buffer = "";
|
|
47
|
+
this.bufferPos = 0;
|
|
48
|
+
this.iter = text.iterRange(from, to);
|
|
49
|
+
this.bufferStart = from;
|
|
50
|
+
this.normalize = normalize ? (x) => normalize(basicNormalize(x)) : basicNormalize;
|
|
51
|
+
this.query = this.normalize(query);
|
|
52
|
+
}
|
|
53
|
+
peek() {
|
|
54
|
+
if (this.bufferPos == this.buffer.length) {
|
|
55
|
+
this.bufferStart += this.buffer.length;
|
|
56
|
+
this.iter.next();
|
|
57
|
+
if (this.iter.done) return -1;
|
|
58
|
+
this.bufferPos = 0;
|
|
59
|
+
this.buffer = this.iter.value;
|
|
60
|
+
}
|
|
61
|
+
return codePointAt(this.buffer, this.bufferPos);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
Look for the next match. Updates the iterator's
|
|
65
|
+
[`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
|
|
66
|
+
[`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
|
|
67
|
+
at least once before using the cursor.
|
|
68
|
+
*/
|
|
69
|
+
next() {
|
|
70
|
+
while (this.matches.length) this.matches.pop();
|
|
71
|
+
return this.nextOverlapping();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
The `next` method will ignore matches that partially overlap a
|
|
75
|
+
previous match. This method behaves like `next`, but includes
|
|
76
|
+
such matches.
|
|
77
|
+
*/
|
|
78
|
+
nextOverlapping() {
|
|
79
|
+
for (;;) {
|
|
80
|
+
let next = this.peek();
|
|
81
|
+
if (next < 0) {
|
|
82
|
+
this.done = true;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
let str = fromCodePoint(next), start = this.bufferStart + this.bufferPos;
|
|
86
|
+
this.bufferPos += codePointSize(next);
|
|
87
|
+
let norm = this.normalize(str);
|
|
88
|
+
if (norm.length) for (let i = 0, pos = start, posPrecise = true;; i++) {
|
|
89
|
+
let code = norm.charCodeAt(i);
|
|
90
|
+
let match = this.match(code, pos, posPrecise, this.bufferPos + this.bufferStart, i == norm.length - 1);
|
|
91
|
+
if (match) {
|
|
92
|
+
this.value = match;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
if (i == norm.length - 1) break;
|
|
96
|
+
if (posPrecise && i < str.length && str.charCodeAt(i) == code) pos++;
|
|
97
|
+
else posPrecise = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
match(code, pos, posPrecise, end, endPrecise) {
|
|
102
|
+
let match = null;
|
|
103
|
+
for (let i = 0; i < this.matches.length;) {
|
|
104
|
+
let partial = this.matches[i], keep = false;
|
|
105
|
+
if (this.query.charCodeAt(partial.index) == code) if (partial.index == this.query.length - 1) match = {
|
|
106
|
+
from: partial.from,
|
|
107
|
+
to: end,
|
|
108
|
+
precise: endPrecise && partial.precise
|
|
109
|
+
};
|
|
110
|
+
else {
|
|
111
|
+
partial.index++;
|
|
112
|
+
keep = true;
|
|
113
|
+
}
|
|
114
|
+
if (keep) i++;
|
|
115
|
+
else this.matches.splice(i, 1);
|
|
116
|
+
}
|
|
117
|
+
if (this.query.charCodeAt(0) == code) if (this.query.length == 1) match = {
|
|
118
|
+
from: pos,
|
|
119
|
+
to: end,
|
|
120
|
+
precise: posPrecise && endPrecise
|
|
121
|
+
};
|
|
122
|
+
else this.matches.push({
|
|
123
|
+
from: pos,
|
|
124
|
+
index: 1,
|
|
125
|
+
precise: posPrecise
|
|
126
|
+
});
|
|
127
|
+
if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferStart)) match = null;
|
|
128
|
+
return match;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
if (typeof Symbol != "undefined") SearchCursor.prototype[Symbol.iterator] = function() {
|
|
132
|
+
return this;
|
|
133
|
+
};
|
|
134
|
+
const empty = {
|
|
135
|
+
from: -1,
|
|
136
|
+
to: -1,
|
|
137
|
+
match: /*@__PURE__*/ /.*/.exec(""),
|
|
138
|
+
precise: true
|
|
139
|
+
};
|
|
140
|
+
const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
|
|
141
|
+
/**
|
|
142
|
+
This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
|
|
143
|
+
but searches for a regular expression pattern instead of a plain
|
|
144
|
+
string.
|
|
145
|
+
*/
|
|
146
|
+
var RegExpCursor = class {
|
|
147
|
+
/**
|
|
148
|
+
Create a cursor that will search the given range in the given
|
|
149
|
+
document. `query` should be the raw pattern (as you'd pass it to
|
|
150
|
+
`new RegExp`).
|
|
151
|
+
*/
|
|
152
|
+
constructor(text, query, options, from = 0, to = text.length) {
|
|
153
|
+
this.text = text;
|
|
154
|
+
this.to = to;
|
|
155
|
+
this.curLine = "";
|
|
156
|
+
/**
|
|
157
|
+
Set to `true` when the cursor has reached the end of the search
|
|
158
|
+
range.
|
|
159
|
+
*/
|
|
160
|
+
this.done = false;
|
|
161
|
+
/**
|
|
162
|
+
Will contain an object with the extent of the match and the
|
|
163
|
+
match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
|
|
164
|
+
sucessfully finds a match. The `precise` flag is always true for
|
|
165
|
+
this type of cursor, and only there to make sure this cursor is
|
|
166
|
+
a subtype of `SearchCursor`.
|
|
167
|
+
*/
|
|
168
|
+
this.value = empty;
|
|
169
|
+
if (/\\[sWDnr]|\n|\r|\[\^/.test(query)) return new MultilineRegExpCursor(text, query, options, from, to);
|
|
170
|
+
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
171
|
+
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
172
|
+
this.iter = text.iter();
|
|
173
|
+
let startLine = text.lineAt(from);
|
|
174
|
+
this.curLineStart = startLine.from;
|
|
175
|
+
this.matchPos = toCharEnd(text, from);
|
|
176
|
+
this.getLine(this.curLineStart);
|
|
177
|
+
}
|
|
178
|
+
getLine(skip) {
|
|
179
|
+
this.iter.next(skip);
|
|
180
|
+
if (this.iter.lineBreak) this.curLine = "";
|
|
181
|
+
else {
|
|
182
|
+
this.curLine = this.iter.value;
|
|
183
|
+
if (this.curLineStart + this.curLine.length > this.to) this.curLine = this.curLine.slice(0, this.to - this.curLineStart);
|
|
184
|
+
this.iter.next();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
nextLine() {
|
|
188
|
+
this.curLineStart = this.curLineStart + this.curLine.length + 1;
|
|
189
|
+
if (this.curLineStart > this.to) this.curLine = "";
|
|
190
|
+
else this.getLine(0);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
Move to the next match, if there is one.
|
|
194
|
+
*/
|
|
195
|
+
next() {
|
|
196
|
+
for (let off = this.matchPos - this.curLineStart;;) {
|
|
197
|
+
this.re.lastIndex = off;
|
|
198
|
+
let match = this.matchPos <= this.to && this.re.exec(this.curLine);
|
|
199
|
+
if (match) {
|
|
200
|
+
let from = this.curLineStart + match.index, to = from + match[0].length;
|
|
201
|
+
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
202
|
+
if (from == this.curLineStart + this.curLine.length) this.nextLine();
|
|
203
|
+
if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
|
|
204
|
+
this.value = {
|
|
205
|
+
from,
|
|
206
|
+
to,
|
|
207
|
+
precise: true,
|
|
208
|
+
match
|
|
209
|
+
};
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
off = this.matchPos - this.curLineStart;
|
|
213
|
+
} else if (this.curLineStart + this.curLine.length < this.to) {
|
|
214
|
+
this.nextLine();
|
|
215
|
+
off = 0;
|
|
216
|
+
} else {
|
|
217
|
+
this.done = true;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const flattened = /*@__PURE__*/ new WeakMap();
|
|
224
|
+
var FlattenedDoc = class FlattenedDoc {
|
|
225
|
+
constructor(from, text) {
|
|
226
|
+
this.from = from;
|
|
227
|
+
this.text = text;
|
|
228
|
+
}
|
|
229
|
+
get to() {
|
|
230
|
+
return this.from + this.text.length;
|
|
231
|
+
}
|
|
232
|
+
static get(doc, from, to) {
|
|
233
|
+
let cached = flattened.get(doc);
|
|
234
|
+
if (!cached || cached.from >= to || cached.to <= from) {
|
|
235
|
+
let flat = new FlattenedDoc(from, doc.sliceString(from, to));
|
|
236
|
+
flattened.set(doc, flat);
|
|
237
|
+
return flat;
|
|
238
|
+
}
|
|
239
|
+
if (cached.from == from && cached.to == to) return cached;
|
|
240
|
+
let { text, from: cachedFrom } = cached;
|
|
241
|
+
if (cachedFrom > from) {
|
|
242
|
+
text = doc.sliceString(from, cachedFrom) + text;
|
|
243
|
+
cachedFrom = from;
|
|
244
|
+
}
|
|
245
|
+
if (cached.to < to) text += doc.sliceString(cached.to, to);
|
|
246
|
+
flattened.set(doc, new FlattenedDoc(cachedFrom, text));
|
|
247
|
+
return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var MultilineRegExpCursor = class {
|
|
251
|
+
constructor(text, query, options, from, to) {
|
|
252
|
+
this.text = text;
|
|
253
|
+
this.to = to;
|
|
254
|
+
this.done = false;
|
|
255
|
+
this.value = empty;
|
|
256
|
+
this.matchPos = toCharEnd(text, from);
|
|
257
|
+
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
258
|
+
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
259
|
+
this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5e3));
|
|
260
|
+
}
|
|
261
|
+
chunkEnd(pos) {
|
|
262
|
+
return pos >= this.to ? this.to : this.text.lineAt(pos).to;
|
|
263
|
+
}
|
|
264
|
+
next() {
|
|
265
|
+
for (;;) {
|
|
266
|
+
let off = this.re.lastIndex = this.matchPos - this.flat.from;
|
|
267
|
+
let match = this.re.exec(this.flat.text);
|
|
268
|
+
if (match && !match[0] && match.index == off) {
|
|
269
|
+
this.re.lastIndex = off + 1;
|
|
270
|
+
match = this.re.exec(this.flat.text);
|
|
271
|
+
}
|
|
272
|
+
if (match) {
|
|
273
|
+
let from = this.flat.from + match.index, to = from + match[0].length;
|
|
274
|
+
if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) && (!this.test || this.test(from, to, match))) {
|
|
275
|
+
this.value = {
|
|
276
|
+
from,
|
|
277
|
+
to,
|
|
278
|
+
precise: true,
|
|
279
|
+
match
|
|
280
|
+
};
|
|
281
|
+
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (this.flat.to == this.to) {
|
|
286
|
+
this.done = true;
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
if (typeof Symbol != "undefined") RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] = function() {
|
|
294
|
+
return this;
|
|
295
|
+
};
|
|
296
|
+
function validRegExp(source) {
|
|
297
|
+
try {
|
|
298
|
+
new RegExp(source, baseFlags);
|
|
299
|
+
return true;
|
|
300
|
+
} catch (_a) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function toCharEnd(text, pos) {
|
|
305
|
+
if (pos >= text.length) return pos;
|
|
306
|
+
let line = text.lineAt(pos), next;
|
|
307
|
+
while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 56320 && next < 57344) pos++;
|
|
308
|
+
return pos;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
Command that shows a dialog asking the user for a line number, and
|
|
312
|
+
when a valid position is provided, moves the cursor to that line.
|
|
313
|
+
|
|
314
|
+
Supports line numbers, relative line offsets prefixed with `+` or
|
|
315
|
+
`-`, document percentages suffixed with `%`, and an optional
|
|
316
|
+
column position by adding `:` and a second number after the line
|
|
317
|
+
number.
|
|
318
|
+
*/
|
|
319
|
+
const gotoLine = (view) => {
|
|
320
|
+
let { state } = view;
|
|
321
|
+
let line = String(state.doc.lineAt(view.state.selection.main.head).number);
|
|
322
|
+
let { close, result } = showDialog(view, {
|
|
323
|
+
label: state.phrase("Go to line"),
|
|
324
|
+
input: {
|
|
325
|
+
type: "text",
|
|
326
|
+
name: "line",
|
|
327
|
+
value: line
|
|
328
|
+
},
|
|
329
|
+
focus: true,
|
|
330
|
+
submitLabel: state.phrase("go")
|
|
331
|
+
});
|
|
332
|
+
result.then((form) => {
|
|
333
|
+
let match = form && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(form.elements["line"].value);
|
|
334
|
+
if (!match) {
|
|
335
|
+
view.dispatch({ effects: close });
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
let startLine = state.doc.lineAt(state.selection.main.head);
|
|
339
|
+
let [, sign, ln, cl, percent] = match;
|
|
340
|
+
let col = cl ? +cl.slice(1) : 0;
|
|
341
|
+
let line = ln ? +ln : startLine.number;
|
|
342
|
+
if (ln && percent) {
|
|
343
|
+
let pc = line / 100;
|
|
344
|
+
if (sign) pc = pc * (sign == "-" ? -1 : 1) + startLine.number / state.doc.lines;
|
|
345
|
+
line = Math.round(state.doc.lines * pc);
|
|
346
|
+
} else if (ln && sign) line = line * (sign == "-" ? -1 : 1) + startLine.number;
|
|
347
|
+
let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
|
|
348
|
+
let selection = EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length)));
|
|
349
|
+
view.dispatch({
|
|
350
|
+
effects: [close, EditorView.scrollIntoView(selection.from, { y: "center" })],
|
|
351
|
+
selection
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
return true;
|
|
355
|
+
};
|
|
356
|
+
const defaultHighlightOptions = {
|
|
357
|
+
highlightWordAroundCursor: false,
|
|
358
|
+
minSelectionLength: 1,
|
|
359
|
+
maxMatches: 100,
|
|
360
|
+
wholeWords: false
|
|
361
|
+
};
|
|
362
|
+
const highlightConfig = /*@__PURE__*/ Facet.define({ combine(options) {
|
|
363
|
+
return combineConfig(options, defaultHighlightOptions, {
|
|
364
|
+
highlightWordAroundCursor: (a, b) => a || b,
|
|
365
|
+
minSelectionLength: Math.min,
|
|
366
|
+
maxMatches: Math.min
|
|
367
|
+
});
|
|
368
|
+
} });
|
|
369
|
+
/**
|
|
370
|
+
This extension highlights text that matches the selection. It uses
|
|
371
|
+
the `"cm-selectionMatch"` class for the highlighting. When
|
|
372
|
+
`highlightWordAroundCursor` is enabled, the word at the cursor
|
|
373
|
+
itself will be highlighted with `"cm-selectionMatch-main"`.
|
|
374
|
+
*/
|
|
375
|
+
function highlightSelectionMatches(options) {
|
|
376
|
+
let ext = [defaultTheme, matchHighlighter];
|
|
377
|
+
if (options) ext.push(highlightConfig.of(options));
|
|
378
|
+
return ext;
|
|
379
|
+
}
|
|
380
|
+
const matchDeco = /*@__PURE__*/ Decoration.mark({ class: "cm-selectionMatch" });
|
|
381
|
+
const mainMatchDeco = /*@__PURE__*/ Decoration.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
|
|
382
|
+
function insideWordBoundaries(check, state, from, to) {
|
|
383
|
+
return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) && (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);
|
|
384
|
+
}
|
|
385
|
+
function insideWord(check, state, from, to) {
|
|
386
|
+
return check(state.sliceDoc(from, from + 1)) == CharCategory.Word && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;
|
|
387
|
+
}
|
|
388
|
+
const matchHighlighter = /*@__PURE__*/ ViewPlugin.fromClass(class {
|
|
389
|
+
constructor(view) {
|
|
390
|
+
this.decorations = this.getDeco(view);
|
|
391
|
+
}
|
|
392
|
+
update(update) {
|
|
393
|
+
if (update.selectionSet || update.docChanged || update.viewportChanged) this.decorations = this.getDeco(update.view);
|
|
394
|
+
}
|
|
395
|
+
getDeco(view) {
|
|
396
|
+
let conf = view.state.facet(highlightConfig);
|
|
397
|
+
let { state } = view, sel = state.selection;
|
|
398
|
+
if (sel.ranges.length > 1) return Decoration.none;
|
|
399
|
+
let range = sel.main, query, check = null;
|
|
400
|
+
if (range.empty) {
|
|
401
|
+
if (!conf.highlightWordAroundCursor) return Decoration.none;
|
|
402
|
+
let word = state.wordAt(range.head);
|
|
403
|
+
if (!word) return Decoration.none;
|
|
404
|
+
check = state.charCategorizer(range.head);
|
|
405
|
+
query = state.sliceDoc(word.from, word.to);
|
|
406
|
+
} else {
|
|
407
|
+
let len = range.to - range.from;
|
|
408
|
+
if (len < conf.minSelectionLength || len > 200) return Decoration.none;
|
|
409
|
+
if (conf.wholeWords) {
|
|
410
|
+
query = state.sliceDoc(range.from, range.to);
|
|
411
|
+
check = state.charCategorizer(range.head);
|
|
412
|
+
if (!(insideWordBoundaries(check, state, range.from, range.to) && insideWord(check, state, range.from, range.to))) return Decoration.none;
|
|
413
|
+
} else {
|
|
414
|
+
query = state.sliceDoc(range.from, range.to);
|
|
415
|
+
if (!query) return Decoration.none;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
let deco = [];
|
|
419
|
+
for (let part of view.visibleRanges) {
|
|
420
|
+
let cursor = new SearchCursor(state.doc, query, part.from, part.to);
|
|
421
|
+
while (!cursor.next().done) {
|
|
422
|
+
let { from, to } = cursor.value;
|
|
423
|
+
if (!check || insideWordBoundaries(check, state, from, to)) {
|
|
424
|
+
if (range.empty && from <= range.from && to >= range.to) deco.push(mainMatchDeco.range(from, to));
|
|
425
|
+
else if (from >= range.to || to <= range.from) deco.push(matchDeco.range(from, to));
|
|
426
|
+
if (deco.length > conf.maxMatches) return Decoration.none;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return Decoration.set(deco);
|
|
431
|
+
}
|
|
432
|
+
}, { decorations: (v) => v.decorations });
|
|
433
|
+
const defaultTheme = /*@__PURE__*/ EditorView.baseTheme({
|
|
434
|
+
".cm-selectionMatch": { backgroundColor: "#99ff7780" },
|
|
435
|
+
".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
|
|
436
|
+
});
|
|
437
|
+
const selectWord = ({ state, dispatch }) => {
|
|
438
|
+
let { selection } = state;
|
|
439
|
+
let newSel = EditorSelection.create(selection.ranges.map((range) => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);
|
|
440
|
+
if (newSel.eq(selection)) return false;
|
|
441
|
+
dispatch(state.update({ selection: newSel }));
|
|
442
|
+
return true;
|
|
443
|
+
};
|
|
444
|
+
function findNextOccurrence(state, query) {
|
|
445
|
+
let { main, ranges } = state.selection;
|
|
446
|
+
let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;
|
|
447
|
+
for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
|
|
448
|
+
cursor.next();
|
|
449
|
+
if (cursor.done) {
|
|
450
|
+
if (cycled) return null;
|
|
451
|
+
cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
|
|
452
|
+
cycled = true;
|
|
453
|
+
} else {
|
|
454
|
+
if (cycled && ranges.some((r) => r.from == cursor.value.from)) continue;
|
|
455
|
+
if (fullWord) {
|
|
456
|
+
let word = state.wordAt(cursor.value.from);
|
|
457
|
+
if (!word || word.from != cursor.value.from || word.to != cursor.value.to) continue;
|
|
458
|
+
}
|
|
459
|
+
return cursor.value;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
Select next occurrence of the current selection. Expand selection
|
|
465
|
+
to the surrounding word when the selection is empty.
|
|
466
|
+
*/
|
|
467
|
+
const selectNextOccurrence = ({ state, dispatch }) => {
|
|
468
|
+
let { ranges } = state.selection;
|
|
469
|
+
if (ranges.some((sel) => sel.from === sel.to)) return selectWord({
|
|
470
|
+
state,
|
|
471
|
+
dispatch
|
|
472
|
+
});
|
|
473
|
+
let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
|
|
474
|
+
if (state.selection.ranges.some((r) => state.sliceDoc(r.from, r.to) != searchedText)) return false;
|
|
475
|
+
let range = findNextOccurrence(state, searchedText);
|
|
476
|
+
if (!range) return false;
|
|
477
|
+
dispatch(state.update({
|
|
478
|
+
selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),
|
|
479
|
+
effects: EditorView.scrollIntoView(range.to)
|
|
480
|
+
}));
|
|
481
|
+
return true;
|
|
482
|
+
};
|
|
483
|
+
const searchConfigFacet = /*@__PURE__*/ Facet.define({ combine(configs) {
|
|
484
|
+
return combineConfig(configs, {
|
|
485
|
+
top: false,
|
|
486
|
+
caseSensitive: false,
|
|
487
|
+
literal: false,
|
|
488
|
+
regexp: false,
|
|
489
|
+
wholeWord: false,
|
|
490
|
+
createPanel: (view) => new SearchPanel(view),
|
|
491
|
+
scrollToMatch: (range) => EditorView.scrollIntoView(range)
|
|
492
|
+
});
|
|
493
|
+
} });
|
|
494
|
+
/**
|
|
495
|
+
A search query. Part of the editor's search state.
|
|
496
|
+
*/
|
|
497
|
+
var SearchQuery = class {
|
|
498
|
+
/**
|
|
499
|
+
Create a query object.
|
|
500
|
+
*/
|
|
501
|
+
constructor(config) {
|
|
502
|
+
this.search = config.search;
|
|
503
|
+
this.caseSensitive = !!config.caseSensitive;
|
|
504
|
+
this.literal = !!config.literal;
|
|
505
|
+
this.regexp = !!config.regexp;
|
|
506
|
+
this.replace = config.replace || "";
|
|
507
|
+
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
|
508
|
+
this.unquoted = this.unquote(this.search);
|
|
509
|
+
this.wholeWord = !!config.wholeWord;
|
|
510
|
+
this.test = config.test;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
@internal
|
|
514
|
+
*/
|
|
515
|
+
unquote(text) {
|
|
516
|
+
return this.literal ? text : text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? " " : "\\");
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
Compare this query to another query.
|
|
520
|
+
*/
|
|
521
|
+
eq(other) {
|
|
522
|
+
return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord && this.test == other.test;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
@internal
|
|
526
|
+
*/
|
|
527
|
+
create() {
|
|
528
|
+
return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
Get a search cursor for this query, searching through the given
|
|
532
|
+
range in the given state.
|
|
533
|
+
*/
|
|
534
|
+
getCursor(state, from = 0, to) {
|
|
535
|
+
let st = state.doc ? state : EditorState.create({ doc: state });
|
|
536
|
+
if (to == null) to = st.doc.length;
|
|
537
|
+
return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
var QueryType = class {
|
|
541
|
+
constructor(spec) {
|
|
542
|
+
this.spec = spec;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
function wrapStringTest(test, state, inner) {
|
|
546
|
+
return (from, to, buffer, bufferPos) => {
|
|
547
|
+
if (inner && !inner(from, to, buffer, bufferPos)) return false;
|
|
548
|
+
return test(from >= bufferPos && to <= bufferPos + buffer.length ? buffer.slice(from - bufferPos, to - bufferPos) : state.doc.sliceString(from, to), state, from, to);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function stringCursor(spec, state, from, to) {
|
|
552
|
+
let test;
|
|
553
|
+
if (spec.wholeWord) test = stringWordTest(state.doc, state.charCategorizer(state.selection.main.head));
|
|
554
|
+
if (spec.test) test = wrapStringTest(spec.test, state, test);
|
|
555
|
+
return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? void 0 : (x) => x.toLowerCase(), test);
|
|
556
|
+
}
|
|
557
|
+
function stringWordTest(doc, categorizer) {
|
|
558
|
+
return (from, to, buf, bufPos) => {
|
|
559
|
+
if (bufPos > from || bufPos + buf.length < to) {
|
|
560
|
+
bufPos = Math.max(0, from - 2);
|
|
561
|
+
buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));
|
|
562
|
+
}
|
|
563
|
+
return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word || categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) && (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word || categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
var StringQuery = class extends QueryType {
|
|
567
|
+
constructor(spec) {
|
|
568
|
+
super(spec);
|
|
569
|
+
}
|
|
570
|
+
nextMatch(state, curFrom, curTo) {
|
|
571
|
+
let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();
|
|
572
|
+
if (cursor.done) {
|
|
573
|
+
let end = Math.min(state.doc.length, curFrom + this.spec.unquoted.length);
|
|
574
|
+
cursor = stringCursor(this.spec, state, 0, end).nextOverlapping();
|
|
575
|
+
}
|
|
576
|
+
return cursor.done || cursor.value.from == curFrom && cursor.value.to == curTo ? null : cursor.value;
|
|
577
|
+
}
|
|
578
|
+
prevMatchInRange(state, from, to) {
|
|
579
|
+
for (let pos = to;;) {
|
|
580
|
+
let start = Math.max(from, pos - 1e4 - this.spec.unquoted.length);
|
|
581
|
+
let cursor = stringCursor(this.spec, state, start, pos), range = null;
|
|
582
|
+
while (!cursor.nextOverlapping().done) range = cursor.value;
|
|
583
|
+
if (range) return range;
|
|
584
|
+
if (start == from) return null;
|
|
585
|
+
pos -= 1e4;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
prevMatch(state, curFrom, curTo) {
|
|
589
|
+
let found = this.prevMatchInRange(state, 0, curFrom);
|
|
590
|
+
if (!found) found = this.prevMatchInRange(state, Math.max(0, curTo - this.spec.unquoted.length), state.doc.length);
|
|
591
|
+
return found && (found.from != curFrom || found.to != curTo) ? found : null;
|
|
592
|
+
}
|
|
593
|
+
getReplacement(_result) {
|
|
594
|
+
return this.spec.unquote(this.spec.replace);
|
|
595
|
+
}
|
|
596
|
+
matchAll(state, limit) {
|
|
597
|
+
let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
598
|
+
while (!cursor.next().done) {
|
|
599
|
+
if (ranges.length >= limit) return null;
|
|
600
|
+
ranges.push(cursor.value);
|
|
601
|
+
}
|
|
602
|
+
return ranges;
|
|
603
|
+
}
|
|
604
|
+
highlight(state, from, to, add) {
|
|
605
|
+
let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));
|
|
606
|
+
while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
function wrapRegexpTest(test, state, inner) {
|
|
610
|
+
return (from, to, match) => {
|
|
611
|
+
return (!inner || inner(from, to, match)) && test(match[0], state, from, to);
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function regexpCursor(spec, state, from, to) {
|
|
615
|
+
let test;
|
|
616
|
+
if (spec.wholeWord) test = regexpWordTest(state.charCategorizer(state.selection.main.head));
|
|
617
|
+
if (spec.test) test = wrapRegexpTest(spec.test, state, test);
|
|
618
|
+
return new RegExpCursor(state.doc, spec.search, {
|
|
619
|
+
ignoreCase: !spec.caseSensitive,
|
|
620
|
+
test
|
|
621
|
+
}, from, to);
|
|
622
|
+
}
|
|
623
|
+
function charBefore(str, index) {
|
|
624
|
+
return str.slice(findClusterBreak(str, index, false), index);
|
|
625
|
+
}
|
|
626
|
+
function charAfter(str, index) {
|
|
627
|
+
return str.slice(index, findClusterBreak(str, index));
|
|
628
|
+
}
|
|
629
|
+
function regexpWordTest(categorizer) {
|
|
630
|
+
return (_from, _to, match) => !match[0].length || (categorizer(charBefore(match.input, match.index)) != CharCategory.Word || categorizer(charAfter(match.input, match.index)) != CharCategory.Word) && (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word || categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);
|
|
631
|
+
}
|
|
632
|
+
var RegExpQuery = class extends QueryType {
|
|
633
|
+
nextMatch(state, curFrom, curTo) {
|
|
634
|
+
let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();
|
|
635
|
+
if (cursor.done) cursor = regexpCursor(this.spec, state, 0, curFrom).next();
|
|
636
|
+
return cursor.done ? null : cursor.value;
|
|
637
|
+
}
|
|
638
|
+
prevMatchInRange(state, from, to) {
|
|
639
|
+
for (let size = 1;; size++) {
|
|
640
|
+
let start = Math.max(from, to - size * 1e4);
|
|
641
|
+
let cursor = regexpCursor(this.spec, state, start, to), range = null;
|
|
642
|
+
while (!cursor.next().done) range = cursor.value;
|
|
643
|
+
if (range && (start == from || range.from > start + 10)) return range;
|
|
644
|
+
if (start == from) return null;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
prevMatch(state, curFrom, curTo) {
|
|
648
|
+
return this.prevMatchInRange(state, 0, curFrom) || this.prevMatchInRange(state, curTo, state.doc.length);
|
|
649
|
+
}
|
|
650
|
+
getReplacement(result) {
|
|
651
|
+
return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (m, i) => {
|
|
652
|
+
if (i == "&") return result.match[0];
|
|
653
|
+
if (i == "$") return "$";
|
|
654
|
+
for (let l = i.length; l > 0; l--) {
|
|
655
|
+
let n = +i.slice(0, l);
|
|
656
|
+
if (n > 0 && n < result.match.length) return result.match[n] + i.slice(l);
|
|
657
|
+
}
|
|
658
|
+
return m;
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
matchAll(state, limit) {
|
|
662
|
+
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
663
|
+
while (!cursor.next().done) {
|
|
664
|
+
if (ranges.length >= limit) return null;
|
|
665
|
+
ranges.push(cursor.value);
|
|
666
|
+
}
|
|
667
|
+
return ranges;
|
|
668
|
+
}
|
|
669
|
+
highlight(state, from, to, add) {
|
|
670
|
+
let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250), Math.min(to + 250, state.doc.length));
|
|
671
|
+
while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
A state effect that updates the current search query. Note that
|
|
676
|
+
this only has an effect if the search state has been initialized
|
|
677
|
+
(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
|
|
678
|
+
by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
|
|
679
|
+
once).
|
|
680
|
+
*/
|
|
681
|
+
const setSearchQuery = /*@__PURE__*/ StateEffect.define();
|
|
682
|
+
const togglePanel = /*@__PURE__*/ StateEffect.define();
|
|
683
|
+
const searchState = /*@__PURE__*/ StateField.define({
|
|
684
|
+
create(state) {
|
|
685
|
+
return new SearchState(defaultQuery(state).create(), null);
|
|
686
|
+
},
|
|
687
|
+
update(value, tr) {
|
|
688
|
+
for (let effect of tr.effects) if (effect.is(setSearchQuery)) value = new SearchState(effect.value.create(), value.panel);
|
|
689
|
+
else if (effect.is(togglePanel)) value = new SearchState(value.query, effect.value ? createSearchPanel : null);
|
|
690
|
+
return value;
|
|
691
|
+
},
|
|
692
|
+
provide: (f) => showPanel.from(f, (val) => val.panel)
|
|
693
|
+
});
|
|
694
|
+
var SearchState = class {
|
|
695
|
+
constructor(query, panel) {
|
|
696
|
+
this.query = query;
|
|
697
|
+
this.panel = panel;
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
const matchMark = /*@__PURE__*/ Decoration.mark({ class: "cm-searchMatch" }), selectedMatchMark = /*@__PURE__*/ Decoration.mark({ class: "cm-searchMatch cm-searchMatch-selected" });
|
|
701
|
+
const searchHighlighter = /*@__PURE__*/ ViewPlugin.fromClass(class {
|
|
702
|
+
constructor(view) {
|
|
703
|
+
this.view = view;
|
|
704
|
+
this.decorations = this.highlight(view.state.field(searchState));
|
|
705
|
+
}
|
|
706
|
+
update(update) {
|
|
707
|
+
let state = update.state.field(searchState);
|
|
708
|
+
if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged) this.decorations = this.highlight(state);
|
|
709
|
+
}
|
|
710
|
+
highlight({ query, panel }) {
|
|
711
|
+
if (!panel || !query.spec.valid) return Decoration.none;
|
|
712
|
+
let { view } = this;
|
|
713
|
+
let builder = new RangeSetBuilder();
|
|
714
|
+
for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
|
|
715
|
+
let { from, to } = ranges[i];
|
|
716
|
+
while (i < l - 1 && to > ranges[i + 1].from - 500) to = ranges[++i].to;
|
|
717
|
+
query.highlight(view.state, from, to, (from, to) => {
|
|
718
|
+
let selected = view.state.selection.ranges.some((r) => r.from == from && r.to == to);
|
|
719
|
+
builder.add(from, to, selected ? selectedMatchMark : matchMark);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
return builder.finish();
|
|
723
|
+
}
|
|
724
|
+
}, { decorations: (v) => v.decorations });
|
|
725
|
+
function searchCommand(f) {
|
|
726
|
+
return (view) => {
|
|
727
|
+
let state = view.state.field(searchState, false);
|
|
728
|
+
return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
Open the search panel if it isn't already open, and move the
|
|
733
|
+
selection to the first match after the current main selection.
|
|
734
|
+
Will wrap around to the start of the document when it reaches the
|
|
735
|
+
end.
|
|
736
|
+
*/
|
|
737
|
+
const findNext = /*@__PURE__*/ searchCommand((view, { query }) => {
|
|
738
|
+
let { to } = view.state.selection.main;
|
|
739
|
+
let next = query.nextMatch(view.state, to, to);
|
|
740
|
+
if (!next) return false;
|
|
741
|
+
let selection = EditorSelection.single(next.from, next.to);
|
|
742
|
+
let config = view.state.facet(searchConfigFacet);
|
|
743
|
+
view.dispatch({
|
|
744
|
+
selection,
|
|
745
|
+
effects: [announceMatch(view, next), config.scrollToMatch(selection.main, view)],
|
|
746
|
+
userEvent: "select.search"
|
|
747
|
+
});
|
|
748
|
+
selectSearchInput(view);
|
|
749
|
+
return true;
|
|
750
|
+
});
|
|
751
|
+
/**
|
|
752
|
+
Move the selection to the previous instance of the search query,
|
|
753
|
+
before the current main selection. Will wrap past the start
|
|
754
|
+
of the document to start searching at the end again.
|
|
755
|
+
*/
|
|
756
|
+
const findPrevious = /*@__PURE__*/ searchCommand((view, { query }) => {
|
|
757
|
+
let { state } = view, { from } = state.selection.main;
|
|
758
|
+
let prev = query.prevMatch(state, from, from);
|
|
759
|
+
if (!prev) return false;
|
|
760
|
+
let selection = EditorSelection.single(prev.from, prev.to);
|
|
761
|
+
let config = view.state.facet(searchConfigFacet);
|
|
762
|
+
view.dispatch({
|
|
763
|
+
selection,
|
|
764
|
+
effects: [announceMatch(view, prev), config.scrollToMatch(selection.main, view)],
|
|
765
|
+
userEvent: "select.search"
|
|
766
|
+
});
|
|
767
|
+
selectSearchInput(view);
|
|
768
|
+
return true;
|
|
769
|
+
});
|
|
770
|
+
/**
|
|
771
|
+
Select all instances of the search query.
|
|
772
|
+
*/
|
|
773
|
+
const selectMatches = /*@__PURE__*/ searchCommand((view, { query }) => {
|
|
774
|
+
let ranges = query.matchAll(view.state, 1e3);
|
|
775
|
+
if (!ranges || !ranges.length) return false;
|
|
776
|
+
view.dispatch({
|
|
777
|
+
selection: EditorSelection.create(ranges.map((r) => EditorSelection.range(r.from, r.to))),
|
|
778
|
+
userEvent: "select.search.matches"
|
|
779
|
+
});
|
|
780
|
+
return true;
|
|
781
|
+
});
|
|
782
|
+
/**
|
|
783
|
+
Select all instances of the currently selected text.
|
|
784
|
+
*/
|
|
785
|
+
const selectSelectionMatches = ({ state, dispatch }) => {
|
|
786
|
+
let sel = state.selection;
|
|
787
|
+
if (sel.ranges.length > 1 || sel.main.empty) return false;
|
|
788
|
+
let { from, to } = sel.main;
|
|
789
|
+
let ranges = [], main = 0;
|
|
790
|
+
for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
|
|
791
|
+
if (ranges.length > 1e3) return false;
|
|
792
|
+
if (cur.value.from == from) main = ranges.length;
|
|
793
|
+
ranges.push(EditorSelection.range(cur.value.from, cur.value.to));
|
|
794
|
+
}
|
|
795
|
+
dispatch(state.update({
|
|
796
|
+
selection: EditorSelection.create(ranges, main),
|
|
797
|
+
userEvent: "select.search.matches"
|
|
798
|
+
}));
|
|
799
|
+
return true;
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
Replace the current match of the search query.
|
|
803
|
+
*/
|
|
804
|
+
const replaceNext = /*@__PURE__*/ searchCommand((view, { query }) => {
|
|
805
|
+
let { state } = view, { from, to } = state.selection.main;
|
|
806
|
+
if (state.readOnly) return false;
|
|
807
|
+
let match = query.nextMatch(state, from, from);
|
|
808
|
+
if (!match) return false;
|
|
809
|
+
let next = match;
|
|
810
|
+
let changes = [], selection, replacement;
|
|
811
|
+
let effects = [];
|
|
812
|
+
if (!next.precise) next = query.nextMatch(state, next.from, next.to);
|
|
813
|
+
else if (next.from == from && next.to == to) {
|
|
814
|
+
replacement = state.toText(query.getReplacement(next));
|
|
815
|
+
changes.push({
|
|
816
|
+
from: next.from,
|
|
817
|
+
to: next.to,
|
|
818
|
+
insert: replacement
|
|
819
|
+
});
|
|
820
|
+
next = query.nextMatch(state, next.from, next.to);
|
|
821
|
+
effects.push(EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
|
|
822
|
+
}
|
|
823
|
+
let changeSet = view.state.changes(changes);
|
|
824
|
+
if (next) {
|
|
825
|
+
selection = EditorSelection.single(next.from, next.to).map(changeSet);
|
|
826
|
+
effects.push(announceMatch(view, next));
|
|
827
|
+
effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));
|
|
828
|
+
}
|
|
829
|
+
view.dispatch({
|
|
830
|
+
changes: changeSet,
|
|
831
|
+
selection,
|
|
832
|
+
effects,
|
|
833
|
+
userEvent: "input.replace"
|
|
834
|
+
});
|
|
835
|
+
return true;
|
|
836
|
+
});
|
|
837
|
+
/**
|
|
838
|
+
Replace all instances of the search query with the given
|
|
839
|
+
replacement.
|
|
840
|
+
*/
|
|
841
|
+
const replaceAll = /*@__PURE__*/ searchCommand((view, { query }) => {
|
|
842
|
+
if (view.state.readOnly) return false;
|
|
843
|
+
let changes = [];
|
|
844
|
+
for (let match of query.matchAll(view.state, 1e9)) {
|
|
845
|
+
let { from, to, precise } = match;
|
|
846
|
+
if (precise) changes.push({
|
|
847
|
+
from,
|
|
848
|
+
to,
|
|
849
|
+
insert: query.getReplacement(match)
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
if (!changes.length) return false;
|
|
853
|
+
let announceText = view.state.phrase("replaced $ matches", changes.length) + ".";
|
|
854
|
+
view.dispatch({
|
|
855
|
+
changes,
|
|
856
|
+
effects: EditorView.announce.of(announceText),
|
|
857
|
+
userEvent: "input.replace.all"
|
|
858
|
+
});
|
|
859
|
+
return true;
|
|
860
|
+
});
|
|
861
|
+
function createSearchPanel(view) {
|
|
862
|
+
return view.state.facet(searchConfigFacet).createPanel(view);
|
|
863
|
+
}
|
|
864
|
+
function defaultQuery(state, fallback) {
|
|
865
|
+
var _a, _b, _c, _d, _e;
|
|
866
|
+
let sel = state.selection.main;
|
|
867
|
+
let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
|
|
868
|
+
if (fallback && !selText) return fallback;
|
|
869
|
+
let config = state.facet(searchConfigFacet);
|
|
870
|
+
return new SearchQuery({
|
|
871
|
+
search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\n/g, "\\n"),
|
|
872
|
+
caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,
|
|
873
|
+
literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,
|
|
874
|
+
regexp: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.regexp) !== null && _d !== void 0 ? _d : config.regexp,
|
|
875
|
+
wholeWord: (_e = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _e !== void 0 ? _e : config.wholeWord
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
function getSearchInput(view) {
|
|
879
|
+
let panel = getPanel(view, createSearchPanel);
|
|
880
|
+
return panel && panel.dom.querySelector("[main-field]");
|
|
881
|
+
}
|
|
882
|
+
function selectSearchInput(view) {
|
|
883
|
+
let input = getSearchInput(view);
|
|
884
|
+
if (input && input == view.root.activeElement) input.select();
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
Make sure the search panel is open and focused.
|
|
888
|
+
*/
|
|
889
|
+
const openSearchPanel = (view) => {
|
|
890
|
+
let state = view.state.field(searchState, false);
|
|
891
|
+
if (state && state.panel) {
|
|
892
|
+
let searchInput = getSearchInput(view);
|
|
893
|
+
if (searchInput && searchInput != view.root.activeElement) {
|
|
894
|
+
let query = defaultQuery(view.state, state.query.spec);
|
|
895
|
+
if (query.valid) view.dispatch({ effects: setSearchQuery.of(query) });
|
|
896
|
+
searchInput.focus();
|
|
897
|
+
searchInput.select();
|
|
898
|
+
}
|
|
899
|
+
} else view.dispatch({ effects: [togglePanel.of(true), state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)] });
|
|
900
|
+
return true;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
Close the search panel.
|
|
904
|
+
*/
|
|
905
|
+
const closeSearchPanel = (view) => {
|
|
906
|
+
let state = view.state.field(searchState, false);
|
|
907
|
+
if (!state || !state.panel) return false;
|
|
908
|
+
let panel = getPanel(view, createSearchPanel);
|
|
909
|
+
if (panel && panel.dom.contains(view.root.activeElement)) view.focus();
|
|
910
|
+
view.dispatch({ effects: togglePanel.of(false) });
|
|
911
|
+
return true;
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
Default search-related key bindings.
|
|
915
|
+
|
|
916
|
+
- Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
|
|
917
|
+
- F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
|
|
918
|
+
- Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
|
|
919
|
+
- Mod-Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
|
|
920
|
+
- Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
|
|
921
|
+
*/
|
|
922
|
+
const searchKeymap = [
|
|
923
|
+
{
|
|
924
|
+
key: "Mod-f",
|
|
925
|
+
run: openSearchPanel,
|
|
926
|
+
scope: "editor search-panel"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
key: "F3",
|
|
930
|
+
run: findNext,
|
|
931
|
+
shift: findPrevious,
|
|
932
|
+
scope: "editor search-panel",
|
|
933
|
+
preventDefault: true
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
key: "Mod-g",
|
|
937
|
+
run: findNext,
|
|
938
|
+
shift: findPrevious,
|
|
939
|
+
scope: "editor search-panel",
|
|
940
|
+
preventDefault: true
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
key: "Escape",
|
|
944
|
+
run: closeSearchPanel,
|
|
945
|
+
scope: "editor search-panel"
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
key: "Mod-Shift-l",
|
|
949
|
+
run: selectSelectionMatches
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
key: "Mod-Alt-g",
|
|
953
|
+
run: gotoLine
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
key: "Mod-d",
|
|
957
|
+
run: selectNextOccurrence,
|
|
958
|
+
preventDefault: true
|
|
959
|
+
}
|
|
960
|
+
];
|
|
961
|
+
var SearchPanel = class {
|
|
962
|
+
constructor(view) {
|
|
963
|
+
this.view = view;
|
|
964
|
+
let query = this.query = view.state.field(searchState).query.spec;
|
|
965
|
+
this.commit = this.commit.bind(this);
|
|
966
|
+
this.searchField = crelt("input", {
|
|
967
|
+
value: query.search,
|
|
968
|
+
placeholder: phrase(view, "Find"),
|
|
969
|
+
"aria-label": phrase(view, "Find"),
|
|
970
|
+
class: "cm-textfield",
|
|
971
|
+
name: "search",
|
|
972
|
+
form: "",
|
|
973
|
+
"main-field": "true",
|
|
974
|
+
onchange: this.commit,
|
|
975
|
+
onkeyup: this.commit
|
|
976
|
+
});
|
|
977
|
+
this.replaceField = crelt("input", {
|
|
978
|
+
value: query.replace,
|
|
979
|
+
placeholder: phrase(view, "Replace"),
|
|
980
|
+
"aria-label": phrase(view, "Replace"),
|
|
981
|
+
class: "cm-textfield",
|
|
982
|
+
name: "replace",
|
|
983
|
+
form: "",
|
|
984
|
+
onchange: this.commit,
|
|
985
|
+
onkeyup: this.commit
|
|
986
|
+
});
|
|
987
|
+
this.caseField = crelt("input", {
|
|
988
|
+
type: "checkbox",
|
|
989
|
+
name: "case",
|
|
990
|
+
form: "",
|
|
991
|
+
checked: query.caseSensitive,
|
|
992
|
+
onchange: this.commit
|
|
993
|
+
});
|
|
994
|
+
this.reField = crelt("input", {
|
|
995
|
+
type: "checkbox",
|
|
996
|
+
name: "re",
|
|
997
|
+
form: "",
|
|
998
|
+
checked: query.regexp,
|
|
999
|
+
onchange: this.commit
|
|
1000
|
+
});
|
|
1001
|
+
this.wordField = crelt("input", {
|
|
1002
|
+
type: "checkbox",
|
|
1003
|
+
name: "word",
|
|
1004
|
+
form: "",
|
|
1005
|
+
checked: query.wholeWord,
|
|
1006
|
+
onchange: this.commit
|
|
1007
|
+
});
|
|
1008
|
+
function button(name, onclick, content) {
|
|
1009
|
+
return crelt("button", {
|
|
1010
|
+
class: "cm-button",
|
|
1011
|
+
name,
|
|
1012
|
+
onclick,
|
|
1013
|
+
type: "button"
|
|
1014
|
+
}, content);
|
|
1015
|
+
}
|
|
1016
|
+
this.dom = crelt("div", {
|
|
1017
|
+
onkeydown: (e) => this.keydown(e),
|
|
1018
|
+
class: "cm-search"
|
|
1019
|
+
}, [
|
|
1020
|
+
this.searchField,
|
|
1021
|
+
button("next", () => findNext(view), [phrase(view, "next")]),
|
|
1022
|
+
button("prev", () => findPrevious(view), [phrase(view, "previous")]),
|
|
1023
|
+
button("select", () => selectMatches(view), [phrase(view, "all")]),
|
|
1024
|
+
crelt("label", null, [this.caseField, phrase(view, "match case")]),
|
|
1025
|
+
crelt("label", null, [this.reField, phrase(view, "regexp")]),
|
|
1026
|
+
crelt("label", null, [this.wordField, phrase(view, "by word")]),
|
|
1027
|
+
...view.state.readOnly ? [] : [
|
|
1028
|
+
crelt("br"),
|
|
1029
|
+
this.replaceField,
|
|
1030
|
+
button("replace", () => replaceNext(view), [phrase(view, "replace")]),
|
|
1031
|
+
button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")])
|
|
1032
|
+
],
|
|
1033
|
+
crelt("button", {
|
|
1034
|
+
name: "close",
|
|
1035
|
+
onclick: () => closeSearchPanel(view),
|
|
1036
|
+
"aria-label": phrase(view, "close"),
|
|
1037
|
+
type: "button"
|
|
1038
|
+
}, ["×"])
|
|
1039
|
+
]);
|
|
1040
|
+
}
|
|
1041
|
+
commit() {
|
|
1042
|
+
let query = new SearchQuery({
|
|
1043
|
+
search: this.searchField.value,
|
|
1044
|
+
caseSensitive: this.caseField.checked,
|
|
1045
|
+
regexp: this.reField.checked,
|
|
1046
|
+
wholeWord: this.wordField.checked,
|
|
1047
|
+
replace: this.replaceField.value
|
|
1048
|
+
});
|
|
1049
|
+
if (!query.eq(this.query)) {
|
|
1050
|
+
this.query = query;
|
|
1051
|
+
this.view.dispatch({ effects: setSearchQuery.of(query) });
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
keydown(e) {
|
|
1055
|
+
if (runScopeHandlers(this.view, e, "search-panel")) e.preventDefault();
|
|
1056
|
+
else if (e.keyCode == 13 && e.target == this.searchField) {
|
|
1057
|
+
e.preventDefault();
|
|
1058
|
+
(e.shiftKey ? findPrevious : findNext)(this.view);
|
|
1059
|
+
} else if (e.keyCode == 13 && e.target == this.replaceField) {
|
|
1060
|
+
e.preventDefault();
|
|
1061
|
+
replaceNext(this.view);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
update(update) {
|
|
1065
|
+
for (let tr of update.transactions) for (let effect of tr.effects) if (effect.is(setSearchQuery) && !effect.value.eq(this.query)) this.setQuery(effect.value);
|
|
1066
|
+
}
|
|
1067
|
+
setQuery(query) {
|
|
1068
|
+
this.query = query;
|
|
1069
|
+
this.searchField.value = query.search;
|
|
1070
|
+
this.replaceField.value = query.replace;
|
|
1071
|
+
this.caseField.checked = query.caseSensitive;
|
|
1072
|
+
this.reField.checked = query.regexp;
|
|
1073
|
+
this.wordField.checked = query.wholeWord;
|
|
1074
|
+
}
|
|
1075
|
+
mount() {
|
|
1076
|
+
this.searchField.select();
|
|
1077
|
+
}
|
|
1078
|
+
get pos() {
|
|
1079
|
+
return 80;
|
|
1080
|
+
}
|
|
1081
|
+
get top() {
|
|
1082
|
+
return this.view.state.facet(searchConfigFacet).top;
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
function phrase(view, phrase) {
|
|
1086
|
+
return view.state.phrase(phrase);
|
|
1087
|
+
}
|
|
1088
|
+
const AnnounceMargin = 30;
|
|
1089
|
+
const Break = /[\s\.,:;?!]/;
|
|
1090
|
+
function announceMatch(view, { from, to }) {
|
|
1091
|
+
let line = view.state.doc.lineAt(from), lineEnd = view.state.doc.lineAt(to).to;
|
|
1092
|
+
let start = Math.max(line.from, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
|
|
1093
|
+
let text = view.state.sliceDoc(start, end);
|
|
1094
|
+
if (start != line.from) {
|
|
1095
|
+
for (let i = 0; i < AnnounceMargin; i++) if (!Break.test(text[i + 1]) && Break.test(text[i])) {
|
|
1096
|
+
text = text.slice(i);
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (end != lineEnd) {
|
|
1101
|
+
for (let i = text.length - 1; i > text.length - AnnounceMargin; i--) if (!Break.test(text[i - 1]) && Break.test(text[i])) {
|
|
1102
|
+
text = text.slice(0, i);
|
|
1103
|
+
break;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${line.number}.`);
|
|
1107
|
+
}
|
|
1108
|
+
const baseTheme = /*@__PURE__*/ EditorView.baseTheme({
|
|
1109
|
+
".cm-panel.cm-search": {
|
|
1110
|
+
padding: "2px 6px 4px",
|
|
1111
|
+
position: "relative",
|
|
1112
|
+
"& [name=close]": {
|
|
1113
|
+
position: "absolute",
|
|
1114
|
+
top: "0",
|
|
1115
|
+
right: "4px",
|
|
1116
|
+
backgroundColor: "inherit",
|
|
1117
|
+
border: "none",
|
|
1118
|
+
font: "inherit",
|
|
1119
|
+
padding: 0,
|
|
1120
|
+
margin: 0
|
|
1121
|
+
},
|
|
1122
|
+
"& input, & button, & label": { margin: ".2em .6em .2em 0" },
|
|
1123
|
+
"& input[type=checkbox]": { marginRight: ".2em" },
|
|
1124
|
+
"& label": {
|
|
1125
|
+
fontSize: "80%",
|
|
1126
|
+
whiteSpace: "pre"
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
"&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
|
|
1130
|
+
"&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
|
|
1131
|
+
"&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
|
|
1132
|
+
"&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
|
|
1133
|
+
});
|
|
1134
|
+
const searchExtensions = [
|
|
1135
|
+
searchState,
|
|
1136
|
+
/*@__PURE__*/ Prec.low(searchHighlighter),
|
|
1137
|
+
baseTheme
|
|
1138
|
+
];
|
|
1139
|
+
//#endregion
|
|
1140
|
+
export { highlightSelectionMatches, searchKeymap };
|
|
1141
|
+
|
|
1142
|
+
//# sourceMappingURL=index.js.map
|