@uiw/react-codemirror 4.12.4 → 4.13.1
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 +1 -0
- package/cjs/index.js +56 -71
- package/cjs/index.js.map +1 -1
- package/cjs/theme/light.js +0 -3
- package/cjs/theme/light.js.map +1 -1
- package/cjs/useCodeMirror.js +45 -78
- package/cjs/useCodeMirror.js.map +1 -1
- package/cjs/utils.js +0 -2
- package/cjs/utils.js.map +1 -1
- package/dist/mdeditor.js +89 -85
- package/dist/mdeditor.min.js +1 -1
- package/esm/index.js +27 -28
- package/esm/index.js.map +1 -1
- package/esm/theme/light.js.map +1 -1
- package/esm/useCodeMirror.js +2 -18
- package/esm/useCodeMirror.js.map +1 -1
- package/esm/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/mdeditor.js
CHANGED
|
@@ -154,25 +154,20 @@ function _defineProperty(obj, key, value) {
|
|
|
154
154
|
} else {
|
|
155
155
|
obj[key] = value;
|
|
156
156
|
}
|
|
157
|
-
|
|
158
157
|
return obj;
|
|
159
158
|
}
|
|
160
159
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
|
|
161
160
|
|
|
162
|
-
|
|
163
161
|
function ownKeys(object, enumerableOnly) {
|
|
164
162
|
var keys = Object.keys(object);
|
|
165
|
-
|
|
166
163
|
if (Object.getOwnPropertySymbols) {
|
|
167
164
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
168
165
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
169
166
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
170
167
|
})), keys.push.apply(keys, symbols);
|
|
171
168
|
}
|
|
172
|
-
|
|
173
169
|
return keys;
|
|
174
170
|
}
|
|
175
|
-
|
|
176
171
|
function _objectSpread2(target) {
|
|
177
172
|
for (var i = 1; i < arguments.length; i++) {
|
|
178
173
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -182,7 +177,6 @@ function _objectSpread2(target) {
|
|
|
182
177
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
183
178
|
});
|
|
184
179
|
}
|
|
185
|
-
|
|
186
180
|
return target;
|
|
187
181
|
}
|
|
188
182
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
|
|
@@ -191,13 +185,11 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
191
185
|
var target = {};
|
|
192
186
|
var sourceKeys = Object.keys(source);
|
|
193
187
|
var key, i;
|
|
194
|
-
|
|
195
188
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
196
189
|
key = sourceKeys[i];
|
|
197
190
|
if (excluded.indexOf(key) >= 0) continue;
|
|
198
191
|
target[key] = source[key];
|
|
199
192
|
}
|
|
200
|
-
|
|
201
193
|
return target;
|
|
202
194
|
}
|
|
203
195
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
@@ -206,10 +198,8 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
206
198
|
if (source == null) return {};
|
|
207
199
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
208
200
|
var key, i;
|
|
209
|
-
|
|
210
201
|
if (Object.getOwnPropertySymbols) {
|
|
211
202
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
212
|
-
|
|
213
203
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
214
204
|
key = sourceSymbolKeys[i];
|
|
215
205
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -217,7 +207,6 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
217
207
|
target[key] = source[key];
|
|
218
208
|
}
|
|
219
209
|
}
|
|
220
|
-
|
|
221
210
|
return target;
|
|
222
211
|
}
|
|
223
212
|
// EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
|
|
@@ -229,18 +218,14 @@ function _arrayWithHoles(arr) {
|
|
|
229
218
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
230
219
|
function _iterableToArrayLimit(arr, i) {
|
|
231
220
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
232
|
-
|
|
233
221
|
if (_i == null) return;
|
|
234
222
|
var _arr = [];
|
|
235
223
|
var _n = true;
|
|
236
224
|
var _d = false;
|
|
237
|
-
|
|
238
225
|
var _s, _e;
|
|
239
|
-
|
|
240
226
|
try {
|
|
241
227
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
242
228
|
_arr.push(_s.value);
|
|
243
|
-
|
|
244
229
|
if (i && _arr.length === i) break;
|
|
245
230
|
}
|
|
246
231
|
} catch (err) {
|
|
@@ -253,17 +238,14 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
253
238
|
if (_d) throw _e;
|
|
254
239
|
}
|
|
255
240
|
}
|
|
256
|
-
|
|
257
241
|
return _arr;
|
|
258
242
|
}
|
|
259
243
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
260
244
|
function _arrayLikeToArray(arr, len) {
|
|
261
245
|
if (len == null || len > arr.length) len = arr.length;
|
|
262
|
-
|
|
263
246
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
264
247
|
arr2[i] = arr[i];
|
|
265
248
|
}
|
|
266
|
-
|
|
267
249
|
return arr2;
|
|
268
250
|
}
|
|
269
251
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
@@ -2200,23 +2182,25 @@ class Modifier {
|
|
|
2200
2182
|
let set = [], tag = new Tag(set, base, mods);
|
|
2201
2183
|
for (let m of mods)
|
|
2202
2184
|
m.instances.push(tag);
|
|
2203
|
-
let configs =
|
|
2185
|
+
let configs = powerSet(mods);
|
|
2204
2186
|
for (let parent of base.set)
|
|
2205
|
-
|
|
2206
|
-
|
|
2187
|
+
if (!parent.modified.length)
|
|
2188
|
+
for (let config of configs)
|
|
2189
|
+
set.push(Modifier.get(parent, config));
|
|
2207
2190
|
return tag;
|
|
2208
2191
|
}
|
|
2209
2192
|
}
|
|
2210
2193
|
function sameArray(a, b) {
|
|
2211
2194
|
return a.length == b.length && a.every((x, i) => x == b[i]);
|
|
2212
2195
|
}
|
|
2213
|
-
function
|
|
2214
|
-
let
|
|
2196
|
+
function powerSet(array) {
|
|
2197
|
+
let sets = [[]];
|
|
2215
2198
|
for (let i = 0; i < array.length; i++) {
|
|
2216
|
-
for (let
|
|
2217
|
-
|
|
2199
|
+
for (let j = 0, e = sets.length; j < e; j++) {
|
|
2200
|
+
sets.push(sets[j].concat(array[i]));
|
|
2201
|
+
}
|
|
2218
2202
|
}
|
|
2219
|
-
return
|
|
2203
|
+
return sets.sort((a, b) => b.length - a.length);
|
|
2220
2204
|
}
|
|
2221
2205
|
/// This function is used to add a set of tags to a language syntax
|
|
2222
2206
|
/// via [`NodeSet.extend`](#common.NodeSet.extend) or
|
|
@@ -2976,8 +2960,13 @@ class Language {
|
|
|
2976
2960
|
The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
|
|
2977
2961
|
used for this language.
|
|
2978
2962
|
*/
|
|
2979
|
-
data, parser, extraExtensions = []
|
|
2963
|
+
data, parser, extraExtensions = [],
|
|
2964
|
+
/**
|
|
2965
|
+
A language name.
|
|
2966
|
+
*/
|
|
2967
|
+
name = "") {
|
|
2980
2968
|
this.data = data;
|
|
2969
|
+
this.name = name;
|
|
2981
2970
|
// Kludge to define EditorState.tree as a debugging helper,
|
|
2982
2971
|
// without the EditorState package actually knowing about
|
|
2983
2972
|
// languages and lezer trees.
|
|
@@ -3065,8 +3054,8 @@ A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language)
|
|
|
3065
3054
|
parsers.
|
|
3066
3055
|
*/
|
|
3067
3056
|
class LRLanguage extends (/* unused pure expression or super */ null && (Language)) {
|
|
3068
|
-
constructor(data, parser) {
|
|
3069
|
-
super(data, parser);
|
|
3057
|
+
constructor(data, parser, name) {
|
|
3058
|
+
super(data, parser, [], name);
|
|
3070
3059
|
this.parser = parser;
|
|
3071
3060
|
}
|
|
3072
3061
|
/**
|
|
@@ -3076,14 +3065,14 @@ class LRLanguage extends (/* unused pure expression or super */ null && (Languag
|
|
|
3076
3065
|
let data = defineLanguageFacet(spec.languageData);
|
|
3077
3066
|
return new LRLanguage(data, spec.parser.configure({
|
|
3078
3067
|
props: [languageDataProp.add(type => type.isTop ? data : undefined)]
|
|
3079
|
-
}));
|
|
3068
|
+
}), spec.name);
|
|
3080
3069
|
}
|
|
3081
3070
|
/**
|
|
3082
3071
|
Create a new instance of this language with a reconfigured
|
|
3083
|
-
version of its parser.
|
|
3072
|
+
version of its parser and optionally a new name.
|
|
3084
3073
|
*/
|
|
3085
|
-
configure(options) {
|
|
3086
|
-
return new LRLanguage(this.data, this.parser.configure(options));
|
|
3074
|
+
configure(options, name) {
|
|
3075
|
+
return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
|
|
3087
3076
|
}
|
|
3088
3077
|
get allowsNesting() { return this.parser.hasWrappers(); }
|
|
3089
3078
|
}
|
|
@@ -3430,14 +3419,14 @@ class LanguageState {
|
|
|
3430
3419
|
// state updates with parse work beyond the viewport.
|
|
3431
3420
|
let upto = this.context.treeLen == tr.startState.doc.length ? undefined
|
|
3432
3421
|
: Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
|
|
3433
|
-
if (!newCx.work(20 /* Apply */, upto))
|
|
3422
|
+
if (!newCx.work(20 /* Work.Apply */, upto))
|
|
3434
3423
|
newCx.takeTree();
|
|
3435
3424
|
return new LanguageState(newCx);
|
|
3436
3425
|
}
|
|
3437
3426
|
static init(state) {
|
|
3438
|
-
let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
|
|
3427
|
+
let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
|
|
3439
3428
|
let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
|
|
3440
|
-
if (!parseState.work(20 /* Apply */, vpTo))
|
|
3429
|
+
if (!parseState.work(20 /* Work.Apply */, vpTo))
|
|
3441
3430
|
parseState.takeTree();
|
|
3442
3431
|
return new LanguageState(parseState);
|
|
3443
3432
|
}
|
|
@@ -3454,14 +3443,14 @@ Language.state = /*@__PURE__*/state_.StateField.define({
|
|
|
3454
3443
|
}
|
|
3455
3444
|
});
|
|
3456
3445
|
let requestIdle = (callback) => {
|
|
3457
|
-
let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
|
|
3446
|
+
let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
|
|
3458
3447
|
return () => clearTimeout(timeout);
|
|
3459
3448
|
};
|
|
3460
3449
|
if (typeof requestIdleCallback != "undefined")
|
|
3461
3450
|
requestIdle = (callback) => {
|
|
3462
3451
|
let idle = -1, timeout = setTimeout(() => {
|
|
3463
|
-
idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
|
|
3464
|
-
}, 100 /* MinPause */);
|
|
3452
|
+
idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
|
|
3453
|
+
}, 100 /* Work.MinPause */);
|
|
3465
3454
|
return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
|
|
3466
3455
|
};
|
|
3467
3456
|
const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
|
|
@@ -3484,7 +3473,7 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
|
|
|
3484
3473
|
this.scheduleWork();
|
|
3485
3474
|
if (update.docChanged) {
|
|
3486
3475
|
if (this.view.hasFocus)
|
|
3487
|
-
this.chunkBudget += 50 /* ChangeBonus */;
|
|
3476
|
+
this.chunkBudget += 50 /* Work.ChangeBonus */;
|
|
3488
3477
|
this.scheduleWork();
|
|
3489
3478
|
}
|
|
3490
3479
|
this.checkAsyncSchedule(cx);
|
|
@@ -3500,19 +3489,19 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
|
|
|
3500
3489
|
this.working = null;
|
|
3501
3490
|
let now = Date.now();
|
|
3502
3491
|
if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
|
|
3503
|
-
this.chunkEnd = now + 30000 /* ChunkTime */;
|
|
3504
|
-
this.chunkBudget = 3000 /* ChunkBudget */;
|
|
3492
|
+
this.chunkEnd = now + 30000 /* Work.ChunkTime */;
|
|
3493
|
+
this.chunkBudget = 3000 /* Work.ChunkBudget */;
|
|
3505
3494
|
}
|
|
3506
3495
|
if (this.chunkBudget <= 0)
|
|
3507
3496
|
return; // No more budget
|
|
3508
3497
|
let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
|
|
3509
|
-
if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
|
|
3498
|
+
if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
|
|
3510
3499
|
return;
|
|
3511
|
-
let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
|
|
3500
|
+
let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
|
|
3512
3501
|
let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
|
|
3513
3502
|
let done = field.context.work(() => {
|
|
3514
3503
|
return isInputPending && isInputPending() || Date.now() > endTime;
|
|
3515
|
-
}, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
|
|
3504
|
+
}, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
|
|
3516
3505
|
this.chunkBudget -= Date.now() - now;
|
|
3517
3506
|
if (done || this.chunkBudget <= 0) {
|
|
3518
3507
|
field.context.takeTree();
|
|
@@ -3550,7 +3539,14 @@ current language on a state.
|
|
|
3550
3539
|
*/
|
|
3551
3540
|
const language = /*@__PURE__*/state_.Facet.define({
|
|
3552
3541
|
combine(languages) { return languages.length ? languages[0] : null; },
|
|
3553
|
-
enables: [
|
|
3542
|
+
enables: language => [
|
|
3543
|
+
Language.state,
|
|
3544
|
+
parseWorker,
|
|
3545
|
+
view_.EditorView.contentAttributes.compute([language], state => {
|
|
3546
|
+
let lang = state.facet(language);
|
|
3547
|
+
return lang && lang.name ? { "data-language": lang.name } : {};
|
|
3548
|
+
})
|
|
3549
|
+
]
|
|
3554
3550
|
});
|
|
3555
3551
|
/**
|
|
3556
3552
|
This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
|
|
@@ -3680,8 +3676,10 @@ class LanguageDescription {
|
|
|
3680
3676
|
|
|
3681
3677
|
/**
|
|
3682
3678
|
Facet that defines a way to provide a function that computes the
|
|
3683
|
-
appropriate indentation depth
|
|
3684
|
-
`
|
|
3679
|
+
appropriate indentation depth, as a column number (see
|
|
3680
|
+
[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given
|
|
3681
|
+
line, or `null` to indicate no appropriate indentation could be
|
|
3682
|
+
determined.
|
|
3685
3683
|
*/
|
|
3686
3684
|
const indentService = /*@__PURE__*/state_.Facet.define();
|
|
3687
3685
|
/**
|
|
@@ -3726,12 +3724,13 @@ function indentString(state, cols) {
|
|
|
3726
3724
|
return result;
|
|
3727
3725
|
}
|
|
3728
3726
|
/**
|
|
3729
|
-
Get the indentation at the given position.
|
|
3730
|
-
[indent services](https://codemirror.net/6/docs/ref/#language.indentService)
|
|
3731
|
-
and if none of those return an indentation,
|
|
3732
|
-
syntax tree for the [indent node
|
|
3733
|
-
and use that if found. Returns a
|
|
3734
|
-
be determined, and null
|
|
3727
|
+
Get the indentation, as a column number, at the given position.
|
|
3728
|
+
Will first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)
|
|
3729
|
+
that are registered, and if none of those return an indentation,
|
|
3730
|
+
this will check the syntax tree for the [indent node
|
|
3731
|
+
prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a
|
|
3732
|
+
number when an indentation could be determined, and null
|
|
3733
|
+
otherwise.
|
|
3735
3734
|
*/
|
|
3736
3735
|
function getIndentation(context, pos) {
|
|
3737
3736
|
if (context instanceof state_.EditorState)
|
|
@@ -3866,8 +3865,9 @@ class IndentContext {
|
|
|
3866
3865
|
/**
|
|
3867
3866
|
A syntax tree node prop used to associate indentation strategies
|
|
3868
3867
|
with node types. Such a strategy is a function from an indentation
|
|
3869
|
-
context to a column number
|
|
3870
|
-
|
|
3868
|
+
context to a column number (see also
|
|
3869
|
+
[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
|
|
3870
|
+
indicates that no definitive indentation can be determined.
|
|
3871
3871
|
*/
|
|
3872
3872
|
const indentNodeProp = /*@__PURE__*/new dist_NodeProp();
|
|
3873
3873
|
// Compute the indentation for a given position from the syntax tree.
|
|
@@ -4458,7 +4458,12 @@ A highlight style associates CSS styles with higlighting
|
|
|
4458
4458
|
[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
|
|
4459
4459
|
*/
|
|
4460
4460
|
class HighlightStyle {
|
|
4461
|
-
constructor(
|
|
4461
|
+
constructor(
|
|
4462
|
+
/**
|
|
4463
|
+
The tag styles used to create this highlight style.
|
|
4464
|
+
*/
|
|
4465
|
+
specs, options) {
|
|
4466
|
+
this.specs = specs;
|
|
4462
4467
|
let modSpec;
|
|
4463
4468
|
function def(spec) {
|
|
4464
4469
|
let cls = StyleModule.newName();
|
|
@@ -4469,7 +4474,7 @@ class HighlightStyle {
|
|
|
4469
4474
|
const scopeOpt = options.scope;
|
|
4470
4475
|
this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
|
|
4471
4476
|
: scopeOpt ? (type) => type == scopeOpt : undefined;
|
|
4472
|
-
this.style = tagHighlighter(
|
|
4477
|
+
this.style = tagHighlighter(specs.map(style => ({
|
|
4473
4478
|
tag: style.tag,
|
|
4474
4479
|
class: style.class || def(Object.assign({}, style, { tag: null }))
|
|
4475
4480
|
})), {
|
|
@@ -4948,6 +4953,7 @@ class StringStream {
|
|
|
4948
4953
|
|
|
4949
4954
|
function fullParser(spec) {
|
|
4950
4955
|
return {
|
|
4956
|
+
name: spec.name || "",
|
|
4951
4957
|
token: spec.token,
|
|
4952
4958
|
blankLine: spec.blankLine || (() => { }),
|
|
4953
4959
|
startState: spec.startState || (() => true),
|
|
@@ -4980,7 +4986,7 @@ class StreamLanguage extends (/* unused pure expression or super */ null && (Lan
|
|
|
4980
4986
|
return new Parse(self, input, fragments, ranges);
|
|
4981
4987
|
}
|
|
4982
4988
|
};
|
|
4983
|
-
super(data, impl, [indentService.of((cx, pos) => this.getIndent(cx, pos))]);
|
|
4989
|
+
super(data, impl, [indentService.of((cx, pos) => this.getIndent(cx, pos))], parser.name);
|
|
4984
4990
|
this.topNode = docID(data);
|
|
4985
4991
|
self = this;
|
|
4986
4992
|
this.streamParser = p;
|
|
@@ -5006,7 +5012,7 @@ class StreamLanguage extends (/* unused pure expression or super */ null && (Lan
|
|
|
5006
5012
|
state = this.streamParser.startState(cx.unit);
|
|
5007
5013
|
statePos = 0;
|
|
5008
5014
|
}
|
|
5009
|
-
if (pos - statePos > 10000 /* MaxIndentScanDist */)
|
|
5015
|
+
if (pos - statePos > 10000 /* C.MaxIndentScanDist */)
|
|
5010
5016
|
return null;
|
|
5011
5017
|
while (statePos < pos) {
|
|
5012
5018
|
let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);
|
|
@@ -5085,7 +5091,7 @@ class Parse {
|
|
|
5085
5091
|
this.chunks.push(tree.children[i]);
|
|
5086
5092
|
this.chunkPos.push(tree.positions[i]);
|
|
5087
5093
|
}
|
|
5088
|
-
if (context && this.parsedPos < context.viewport.from - 100000 /* MaxDistanceBeforeViewport */) {
|
|
5094
|
+
if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */) {
|
|
5089
5095
|
this.state = this.lang.streamParser.startState(getIndentUnit(context.state));
|
|
5090
5096
|
context.skipUntilInView(this.parsedPos, context.viewport.from);
|
|
5091
5097
|
this.parsedPos = context.viewport.from;
|
|
@@ -5095,7 +5101,7 @@ class Parse {
|
|
|
5095
5101
|
advance() {
|
|
5096
5102
|
let context = ParseContext.get();
|
|
5097
5103
|
let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);
|
|
5098
|
-
let end = Math.min(parseEnd, this.chunkStart + 2048 /* ChunkSize */);
|
|
5104
|
+
let end = Math.min(parseEnd, this.chunkStart + 2048 /* C.ChunkSize */);
|
|
5099
5105
|
if (context)
|
|
5100
5106
|
end = Math.min(end, context.viewport.to);
|
|
5101
5107
|
while (this.parsedPos < end)
|
|
@@ -5179,7 +5185,7 @@ class Parse {
|
|
|
5179
5185
|
let token = readToken(streamParser.token, stream, this.state);
|
|
5180
5186
|
if (token)
|
|
5181
5187
|
offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, 4, offset);
|
|
5182
|
-
if (stream.start > 10000 /* MaxLineLength */)
|
|
5188
|
+
if (stream.start > 10000 /* C.MaxLineLength */)
|
|
5183
5189
|
break;
|
|
5184
5190
|
}
|
|
5185
5191
|
}
|
|
@@ -5195,7 +5201,7 @@ class Parse {
|
|
|
5195
5201
|
length: this.parsedPos - this.chunkStart,
|
|
5196
5202
|
nodeSet,
|
|
5197
5203
|
topID: 0,
|
|
5198
|
-
maxBufferLength: 2048 /* ChunkSize */,
|
|
5204
|
+
maxBufferLength: 2048 /* C.ChunkSize */,
|
|
5199
5205
|
reused: this.chunkReused
|
|
5200
5206
|
});
|
|
5201
5207
|
tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);
|
|
@@ -6313,7 +6319,7 @@ function deleteBy(target, by) {
|
|
|
6313
6319
|
}
|
|
6314
6320
|
else {
|
|
6315
6321
|
from = skipAtomic(target, from, false);
|
|
6316
|
-
to = skipAtomic(target,
|
|
6322
|
+
to = skipAtomic(target, to, true);
|
|
6317
6323
|
}
|
|
6318
6324
|
return from == to ? { range } : { changes: { from, to }, range: state_.EditorSelection.cursor(from) };
|
|
6319
6325
|
});
|
|
@@ -7085,7 +7091,7 @@ class RegExpCursor {
|
|
|
7085
7091
|
if (match) {
|
|
7086
7092
|
let from = this.curLineStart + match.index, to = from + match[0].length;
|
|
7087
7093
|
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
7088
|
-
if (from == this.curLine.length)
|
|
7094
|
+
if (from == this.curLineStart + this.curLine.length)
|
|
7089
7095
|
this.nextLine();
|
|
7090
7096
|
if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
|
|
7091
7097
|
this.value = { from, to, match };
|
|
@@ -7479,10 +7485,17 @@ class SearchQuery {
|
|
|
7479
7485
|
this.regexp = !!config.regexp;
|
|
7480
7486
|
this.replace = config.replace || "";
|
|
7481
7487
|
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
|
7482
|
-
this.unquoted = this.
|
|
7488
|
+
this.unquoted = this.unquote(this.search);
|
|
7483
7489
|
this.wholeWord = !!config.wholeWord;
|
|
7484
7490
|
}
|
|
7485
7491
|
/**
|
|
7492
|
+
@internal
|
|
7493
|
+
*/
|
|
7494
|
+
unquote(text) {
|
|
7495
|
+
return this.literal ? text :
|
|
7496
|
+
text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
|
|
7497
|
+
}
|
|
7498
|
+
/**
|
|
7486
7499
|
Compare this query to another query.
|
|
7487
7500
|
*/
|
|
7488
7501
|
eq(other) {
|
|
@@ -7556,7 +7569,7 @@ class StringQuery extends QueryType {
|
|
|
7556
7569
|
return this.prevMatchInRange(state, 0, curFrom) ||
|
|
7557
7570
|
this.prevMatchInRange(state, curTo, state.doc.length);
|
|
7558
7571
|
}
|
|
7559
|
-
getReplacement(_result) { return this.spec.replace; }
|
|
7572
|
+
getReplacement(_result) { return this.spec.unquote(this.spec.replace); }
|
|
7560
7573
|
matchAll(state, limit) {
|
|
7561
7574
|
let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
7562
7575
|
while (!cursor.next().done) {
|
|
@@ -7615,10 +7628,10 @@ class RegExpQuery extends QueryType {
|
|
|
7615
7628
|
this.prevMatchInRange(state, curTo, state.doc.length);
|
|
7616
7629
|
}
|
|
7617
7630
|
getReplacement(result) {
|
|
7618
|
-
return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
|
7631
|
+
return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
|
7619
7632
|
: i == "&" ? result.match[0]
|
|
7620
7633
|
: i != "0" && +i < result.match.length ? result.match[i]
|
|
7621
|
-
: m);
|
|
7634
|
+
: m));
|
|
7622
7635
|
}
|
|
7623
7636
|
matchAll(state, limit) {
|
|
7624
7637
|
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
|
@@ -7924,6 +7937,7 @@ class SearchPanel {
|
|
|
7924
7937
|
"aria-label": phrase(view, "Find"),
|
|
7925
7938
|
class: "cm-textfield",
|
|
7926
7939
|
name: "search",
|
|
7940
|
+
form: "",
|
|
7927
7941
|
"main-field": "true",
|
|
7928
7942
|
onchange: this.commit,
|
|
7929
7943
|
onkeyup: this.commit
|
|
@@ -7934,24 +7948,28 @@ class SearchPanel {
|
|
|
7934
7948
|
"aria-label": phrase(view, "Replace"),
|
|
7935
7949
|
class: "cm-textfield",
|
|
7936
7950
|
name: "replace",
|
|
7951
|
+
form: "",
|
|
7937
7952
|
onchange: this.commit,
|
|
7938
7953
|
onkeyup: this.commit
|
|
7939
7954
|
});
|
|
7940
7955
|
this.caseField = crelt("input", {
|
|
7941
7956
|
type: "checkbox",
|
|
7942
7957
|
name: "case",
|
|
7958
|
+
form: "",
|
|
7943
7959
|
checked: query.caseSensitive,
|
|
7944
7960
|
onchange: this.commit
|
|
7945
7961
|
});
|
|
7946
7962
|
this.reField = crelt("input", {
|
|
7947
7963
|
type: "checkbox",
|
|
7948
7964
|
name: "re",
|
|
7965
|
+
form: "",
|
|
7949
7966
|
checked: query.regexp,
|
|
7950
7967
|
onchange: this.commit
|
|
7951
7968
|
});
|
|
7952
7969
|
this.wordField = crelt("input", {
|
|
7953
7970
|
type: "checkbox",
|
|
7954
7971
|
name: "word",
|
|
7972
|
+
form: "",
|
|
7955
7973
|
checked: query.wholeWord,
|
|
7956
7974
|
onchange: this.commit
|
|
7957
7975
|
});
|
|
@@ -10639,7 +10657,6 @@ function lintGutter(config = {}) {
|
|
|
10639
10657
|
|
|
10640
10658
|
|
|
10641
10659
|
|
|
10642
|
-
|
|
10643
10660
|
/**
|
|
10644
10661
|
This is an extension value that just pulls together a number of
|
|
10645
10662
|
extensions that you might want in a basic editor. It is meant as a
|
|
@@ -10681,37 +10698,28 @@ var basicSetup = function basicSetup(options) {
|
|
|
10681
10698
|
if (options === void 0) {
|
|
10682
10699
|
options = {};
|
|
10683
10700
|
}
|
|
10684
|
-
|
|
10685
10701
|
var keymaps = [];
|
|
10686
|
-
|
|
10687
10702
|
if (options.closeBracketsKeymap !== false) {
|
|
10688
10703
|
keymaps = keymaps.concat(closeBracketsKeymap);
|
|
10689
10704
|
}
|
|
10690
|
-
|
|
10691
10705
|
if (options.defaultKeymap !== false) {
|
|
10692
10706
|
keymaps = keymaps.concat(defaultKeymap);
|
|
10693
10707
|
}
|
|
10694
|
-
|
|
10695
10708
|
if (options.searchKeymap !== false) {
|
|
10696
10709
|
keymaps = keymaps.concat(searchKeymap);
|
|
10697
10710
|
}
|
|
10698
|
-
|
|
10699
10711
|
if (options.historyKeymap !== false) {
|
|
10700
10712
|
keymaps = keymaps.concat(historyKeymap);
|
|
10701
10713
|
}
|
|
10702
|
-
|
|
10703
10714
|
if (options.foldKeymap !== false) {
|
|
10704
10715
|
keymaps = keymaps.concat(foldKeymap);
|
|
10705
10716
|
}
|
|
10706
|
-
|
|
10707
10717
|
if (options.completionKeymap !== false) {
|
|
10708
10718
|
keymaps = keymaps.concat(completionKeymap);
|
|
10709
10719
|
}
|
|
10710
|
-
|
|
10711
10720
|
if (options.lintKeymap !== false) {
|
|
10712
10721
|
keymaps = keymaps.concat(lintKeymap);
|
|
10713
10722
|
}
|
|
10714
|
-
|
|
10715
10723
|
var extensions = [];
|
|
10716
10724
|
if (options.lineNumbers !== false) extensions.push((0,view_.lineNumbers)());
|
|
10717
10725
|
if (options.highlightActiveLineGutter !== false) extensions.push((0,view_.highlightActiveLineGutter)());
|
|
@@ -10732,9 +10740,9 @@ var basicSetup = function basicSetup(options) {
|
|
|
10732
10740
|
if (options.crosshairCursor !== false) extensions.push((0,view_.crosshairCursor)());
|
|
10733
10741
|
if (options.highlightActiveLine !== false) extensions.push((0,view_.highlightActiveLine)());
|
|
10734
10742
|
if (options.highlightSelectionMatches !== false) extensions.push(highlightSelectionMatches());
|
|
10743
|
+
if (options.tabSize && typeof options.tabSize === 'number') extensions.push(dist_indentUnit.of(' '.repeat(options.tabSize)));
|
|
10735
10744
|
return extensions.concat([view_.keymap.of(keymaps.flat())]).filter(Boolean);
|
|
10736
10745
|
};
|
|
10737
|
-
|
|
10738
10746
|
/**
|
|
10739
10747
|
A minimal set of extensions to create a functional editor. Only
|
|
10740
10748
|
includes [the default keymap](https://codemirror.net/6/docs/ref/#commands.defaultKeymap), [undo
|
|
@@ -10747,17 +10755,13 @@ var minimalSetup = function minimalSetup(options) {
|
|
|
10747
10755
|
if (options === void 0) {
|
|
10748
10756
|
options = {};
|
|
10749
10757
|
}
|
|
10750
|
-
|
|
10751
10758
|
var keymaps = [];
|
|
10752
|
-
|
|
10753
10759
|
if (options.defaultKeymap !== false) {
|
|
10754
10760
|
keymaps = keymaps.concat(defaultKeymap);
|
|
10755
10761
|
}
|
|
10756
|
-
|
|
10757
10762
|
if (options.historyKeymap !== false) {
|
|
10758
10763
|
keymaps = keymaps.concat(historyKeymap);
|
|
10759
10764
|
}
|
|
10760
|
-
|
|
10761
10765
|
var extensions = [];
|
|
10762
10766
|
if (options.highlightSpecialChars !== false) extensions.push((0,view_.highlightSpecialChars)());
|
|
10763
10767
|
if (options.history !== false) extensions.push(dist_history());
|