@uiw/react-codemirror 4.12.3 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 = permute(mods);
2185
+ let configs = powerSet(mods);
2204
2186
  for (let parent of base.set)
2205
- for (let config of configs)
2206
- set.push(Modifier.get(parent, config));
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 permute(array) {
2214
- let result = [array];
2196
+ function powerSet(array) {
2197
+ let sets = [[]];
2215
2198
  for (let i = 0; i < array.length; i++) {
2216
- for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
2217
- result.push(a);
2199
+ for (let j = 0, e = sets.length; j < e; j++) {
2200
+ sets.push(sets[j].concat(array[i]));
2201
+ }
2218
2202
  }
2219
- return result;
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
@@ -2314,6 +2298,8 @@ class Rule {
2314
2298
  this.context = context;
2315
2299
  this.next = next;
2316
2300
  }
2301
+ get opaque() { return this.mode == 0 /* Opaque */; }
2302
+ get inherit() { return this.mode == 1 /* Inherit */; }
2317
2303
  sort(other) {
2318
2304
  if (!other || other.depth < this.depth) {
2319
2305
  this.next = other;
@@ -2324,6 +2310,7 @@ class Rule {
2324
2310
  }
2325
2311
  get depth() { return this.context ? this.context.length : 0; }
2326
2312
  }
2313
+ Rule.empty = new Rule([], 2 /* Normal */, null);
2327
2314
  /// Define a [highlighter](#highlight.Highlighter) from an array of
2328
2315
  /// tag/class pairs. Classes associated with more specific tags will
2329
2316
  /// take precedence.
@@ -2351,7 +2338,7 @@ function tagHighlighter(tags, options) {
2351
2338
  }
2352
2339
  return cls;
2353
2340
  },
2354
- scope: scope
2341
+ scope
2355
2342
  };
2356
2343
  }
2357
2344
  function highlightTags(highlighters, tags) {
@@ -2404,25 +2391,17 @@ class HighlightBuilder {
2404
2391
  if (type.isTop)
2405
2392
  highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
2406
2393
  let cls = inheritedClass;
2407
- let rule = type.prop(ruleNodeProp), opaque = false;
2408
- while (rule) {
2409
- if (!rule.context || cursor.matchContext(rule.context)) {
2410
- let tagCls = highlightTags(highlighters, rule.tags);
2411
- if (tagCls) {
2412
- if (cls)
2413
- cls += " ";
2414
- cls += tagCls;
2415
- if (rule.mode == 1 /* Inherit */)
2416
- inheritedClass += (inheritedClass ? " " : "") + tagCls;
2417
- else if (rule.mode == 0 /* Opaque */)
2418
- opaque = true;
2419
- }
2420
- break;
2421
- }
2422
- rule = rule.next;
2394
+ let rule = getStyleTags(cursor) || Rule.empty;
2395
+ let tagCls = highlightTags(highlighters, rule.tags);
2396
+ if (tagCls) {
2397
+ if (cls)
2398
+ cls += " ";
2399
+ cls += tagCls;
2400
+ if (rule.mode == 1 /* Inherit */)
2401
+ inheritedClass += (inheritedClass ? " " : "") + tagCls;
2423
2402
  }
2424
2403
  this.startSpan(cursor.from, cls);
2425
- if (opaque)
2404
+ if (rule.opaque)
2426
2405
  return;
2427
2406
  let mounted = cursor.tree && cursor.tree.prop(dist_NodeProp.mounted);
2428
2407
  if (mounted && mounted.overlay) {
@@ -2465,6 +2444,15 @@ class HighlightBuilder {
2465
2444
  }
2466
2445
  }
2467
2446
  }
2447
+ /// Match a syntax node's [highlight rules](#highlight.styleTags). If
2448
+ /// there's a match, return its set of tags, and whether it is
2449
+ /// opaque (uses a `!`) or applies to all child nodes (`/...`).
2450
+ function getStyleTags(node) {
2451
+ let rule = node.type.prop(ruleNodeProp);
2452
+ while (rule && rule.context && !node.matchContext(rule.context))
2453
+ rule = rule.next;
2454
+ return rule || null;
2455
+ }
2468
2456
  const t = Tag.define;
2469
2457
  const comment = t(), dist_name = t(), typeName = t(dist_name), propertyName = t(dist_name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
2470
2458
  /// The default set of highlighting [tags](#highlight.Tag).
@@ -2565,7 +2553,7 @@ const tags = {
2565
2553
  moduleKeyword: t(keyword),
2566
2554
  /// An operator.
2567
2555
  operator,
2568
- /// An [operator](#highlight.tags.operator) that defines something.
2556
+ /// An [operator](#highlight.tags.operator) that dereferences something.
2569
2557
  derefOperator: t(operator),
2570
2558
  /// Arithmetic-related [operator](#highlight.tags.operator).
2571
2559
  arithmeticOperator: t(operator),
@@ -2972,8 +2960,13 @@ class Language {
2972
2960
  The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
2973
2961
  used for this language.
2974
2962
  */
2975
- data, parser, extraExtensions = []) {
2963
+ data, parser, extraExtensions = [],
2964
+ /**
2965
+ A language name.
2966
+ */
2967
+ name = "") {
2976
2968
  this.data = data;
2969
+ this.name = name;
2977
2970
  // Kludge to define EditorState.tree as a debugging helper,
2978
2971
  // without the EditorState package actually knowing about
2979
2972
  // languages and lezer trees.
@@ -3061,8 +3054,8 @@ A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language)
3061
3054
  parsers.
3062
3055
  */
3063
3056
  class LRLanguage extends (/* unused pure expression or super */ null && (Language)) {
3064
- constructor(data, parser) {
3065
- super(data, parser);
3057
+ constructor(data, parser, name) {
3058
+ super(data, parser, [], name);
3066
3059
  this.parser = parser;
3067
3060
  }
3068
3061
  /**
@@ -3072,14 +3065,14 @@ class LRLanguage extends (/* unused pure expression or super */ null && (Languag
3072
3065
  let data = defineLanguageFacet(spec.languageData);
3073
3066
  return new LRLanguage(data, spec.parser.configure({
3074
3067
  props: [languageDataProp.add(type => type.isTop ? data : undefined)]
3075
- }));
3068
+ }), spec.name);
3076
3069
  }
3077
3070
  /**
3078
3071
  Create a new instance of this language with a reconfigured
3079
- version of its parser.
3072
+ version of its parser and optionally a new name.
3080
3073
  */
3081
- configure(options) {
3082
- 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);
3083
3076
  }
3084
3077
  get allowsNesting() { return this.parser.hasWrappers(); }
3085
3078
  }
@@ -3426,14 +3419,14 @@ class LanguageState {
3426
3419
  // state updates with parse work beyond the viewport.
3427
3420
  let upto = this.context.treeLen == tr.startState.doc.length ? undefined
3428
3421
  : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
3429
- if (!newCx.work(20 /* Apply */, upto))
3422
+ if (!newCx.work(20 /* Work.Apply */, upto))
3430
3423
  newCx.takeTree();
3431
3424
  return new LanguageState(newCx);
3432
3425
  }
3433
3426
  static init(state) {
3434
- let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
3427
+ let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
3435
3428
  let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
3436
- if (!parseState.work(20 /* Apply */, vpTo))
3429
+ if (!parseState.work(20 /* Work.Apply */, vpTo))
3437
3430
  parseState.takeTree();
3438
3431
  return new LanguageState(parseState);
3439
3432
  }
@@ -3450,14 +3443,14 @@ Language.state = /*@__PURE__*/state_.StateField.define({
3450
3443
  }
3451
3444
  });
3452
3445
  let requestIdle = (callback) => {
3453
- let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
3446
+ let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
3454
3447
  return () => clearTimeout(timeout);
3455
3448
  };
3456
3449
  if (typeof requestIdleCallback != "undefined")
3457
3450
  requestIdle = (callback) => {
3458
3451
  let idle = -1, timeout = setTimeout(() => {
3459
- idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
3460
- }, 100 /* MinPause */);
3452
+ idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
3453
+ }, 100 /* Work.MinPause */);
3461
3454
  return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
3462
3455
  };
3463
3456
  const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
@@ -3480,7 +3473,7 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
3480
3473
  this.scheduleWork();
3481
3474
  if (update.docChanged) {
3482
3475
  if (this.view.hasFocus)
3483
- this.chunkBudget += 50 /* ChangeBonus */;
3476
+ this.chunkBudget += 50 /* Work.ChangeBonus */;
3484
3477
  this.scheduleWork();
3485
3478
  }
3486
3479
  this.checkAsyncSchedule(cx);
@@ -3496,19 +3489,19 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
3496
3489
  this.working = null;
3497
3490
  let now = Date.now();
3498
3491
  if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
3499
- this.chunkEnd = now + 30000 /* ChunkTime */;
3500
- this.chunkBudget = 3000 /* ChunkBudget */;
3492
+ this.chunkEnd = now + 30000 /* Work.ChunkTime */;
3493
+ this.chunkBudget = 3000 /* Work.ChunkBudget */;
3501
3494
  }
3502
3495
  if (this.chunkBudget <= 0)
3503
3496
  return; // No more budget
3504
3497
  let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
3505
- 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 */))
3506
3499
  return;
3507
- 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);
3508
3501
  let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
3509
3502
  let done = field.context.work(() => {
3510
3503
  return isInputPending && isInputPending() || Date.now() > endTime;
3511
- }, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
3504
+ }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
3512
3505
  this.chunkBudget -= Date.now() - now;
3513
3506
  if (done || this.chunkBudget <= 0) {
3514
3507
  field.context.takeTree();
@@ -3546,7 +3539,14 @@ current language on a state.
3546
3539
  */
3547
3540
  const language = /*@__PURE__*/state_.Facet.define({
3548
3541
  combine(languages) { return languages.length ? languages[0] : null; },
3549
- enables: [Language.state, parseWorker]
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
+ ]
3550
3550
  });
3551
3551
  /**
3552
3552
  This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
@@ -3676,8 +3676,10 @@ class LanguageDescription {
3676
3676
 
3677
3677
  /**
3678
3678
  Facet that defines a way to provide a function that computes the
3679
- appropriate indentation depth at the start of a given line, or
3680
- `null` to indicate no appropriate indentation could be determined.
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.
3681
3683
  */
3682
3684
  const indentService = /*@__PURE__*/state_.Facet.define();
3683
3685
  /**
@@ -3722,12 +3724,13 @@ function indentString(state, cols) {
3722
3724
  return result;
3723
3725
  }
3724
3726
  /**
3725
- Get the indentation at the given position. Will first consult any
3726
- [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
3727
- and if none of those return an indentation, this will check the
3728
- syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
3729
- and use that if found. Returns a number when an indentation could
3730
- be determined, and null otherwise.
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.
3731
3734
  */
3732
3735
  function getIndentation(context, pos) {
3733
3736
  if (context instanceof state_.EditorState)
@@ -3862,8 +3865,9 @@ class IndentContext {
3862
3865
  /**
3863
3866
  A syntax tree node prop used to associate indentation strategies
3864
3867
  with node types. Such a strategy is a function from an indentation
3865
- context to a column number or null, where null indicates that no
3866
- definitive indentation can be determined.
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.
3867
3871
  */
3868
3872
  const indentNodeProp = /*@__PURE__*/new dist_NodeProp();
3869
3873
  // Compute the indentation for a given position from the syntax tree.
@@ -4454,7 +4458,12 @@ A highlight style associates CSS styles with higlighting
4454
4458
  [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
4455
4459
  */
4456
4460
  class HighlightStyle {
4457
- constructor(spec, options) {
4461
+ constructor(
4462
+ /**
4463
+ The tag styles used to create this highlight style.
4464
+ */
4465
+ specs, options) {
4466
+ this.specs = specs;
4458
4467
  let modSpec;
4459
4468
  function def(spec) {
4460
4469
  let cls = StyleModule.newName();
@@ -4465,7 +4474,7 @@ class HighlightStyle {
4465
4474
  const scopeOpt = options.scope;
4466
4475
  this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
4467
4476
  : scopeOpt ? (type) => type == scopeOpt : undefined;
4468
- this.style = tagHighlighter(spec.map(style => ({
4477
+ this.style = tagHighlighter(specs.map(style => ({
4469
4478
  tag: style.tag,
4470
4479
  class: style.class || def(Object.assign({}, style, { tag: null }))
4471
4480
  })), {
@@ -4944,6 +4953,7 @@ class StringStream {
4944
4953
 
4945
4954
  function fullParser(spec) {
4946
4955
  return {
4956
+ name: spec.name || "",
4947
4957
  token: spec.token,
4948
4958
  blankLine: spec.blankLine || (() => { }),
4949
4959
  startState: spec.startState || (() => true),
@@ -4976,7 +4986,7 @@ class StreamLanguage extends (/* unused pure expression or super */ null && (Lan
4976
4986
  return new Parse(self, input, fragments, ranges);
4977
4987
  }
4978
4988
  };
4979
- 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);
4980
4990
  this.topNode = docID(data);
4981
4991
  self = this;
4982
4992
  this.streamParser = p;
@@ -5002,7 +5012,7 @@ class StreamLanguage extends (/* unused pure expression or super */ null && (Lan
5002
5012
  state = this.streamParser.startState(cx.unit);
5003
5013
  statePos = 0;
5004
5014
  }
5005
- if (pos - statePos > 10000 /* MaxIndentScanDist */)
5015
+ if (pos - statePos > 10000 /* C.MaxIndentScanDist */)
5006
5016
  return null;
5007
5017
  while (statePos < pos) {
5008
5018
  let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);
@@ -5081,7 +5091,7 @@ class Parse {
5081
5091
  this.chunks.push(tree.children[i]);
5082
5092
  this.chunkPos.push(tree.positions[i]);
5083
5093
  }
5084
- if (context && this.parsedPos < context.viewport.from - 100000 /* MaxDistanceBeforeViewport */) {
5094
+ if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */) {
5085
5095
  this.state = this.lang.streamParser.startState(getIndentUnit(context.state));
5086
5096
  context.skipUntilInView(this.parsedPos, context.viewport.from);
5087
5097
  this.parsedPos = context.viewport.from;
@@ -5091,7 +5101,7 @@ class Parse {
5091
5101
  advance() {
5092
5102
  let context = ParseContext.get();
5093
5103
  let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);
5094
- let end = Math.min(parseEnd, this.chunkStart + 2048 /* ChunkSize */);
5104
+ let end = Math.min(parseEnd, this.chunkStart + 2048 /* C.ChunkSize */);
5095
5105
  if (context)
5096
5106
  end = Math.min(end, context.viewport.to);
5097
5107
  while (this.parsedPos < end)
@@ -5175,7 +5185,7 @@ class Parse {
5175
5185
  let token = readToken(streamParser.token, stream, this.state);
5176
5186
  if (token)
5177
5187
  offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, 4, offset);
5178
- if (stream.start > 10000 /* MaxLineLength */)
5188
+ if (stream.start > 10000 /* C.MaxLineLength */)
5179
5189
  break;
5180
5190
  }
5181
5191
  }
@@ -5191,7 +5201,7 @@ class Parse {
5191
5201
  length: this.parsedPos - this.chunkStart,
5192
5202
  nodeSet,
5193
5203
  topID: 0,
5194
- maxBufferLength: 2048 /* ChunkSize */,
5204
+ maxBufferLength: 2048 /* C.ChunkSize */,
5195
5205
  reused: this.chunkReused
5196
5206
  });
5197
5207
  tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);
@@ -5319,35 +5329,35 @@ The line comment syntax is taken from the
5319
5329
  [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
5320
5330
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
5321
5331
  */
5322
- const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
5332
+ const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);
5323
5333
  /**
5324
5334
  Comment the current selection using line comments.
5325
5335
  */
5326
- const lineComment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeLineComment, 1 /* Comment */)));
5336
+ const lineComment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeLineComment, 1 /* CommentOption.Comment */)));
5327
5337
  /**
5328
5338
  Uncomment the current selection using line comments.
5329
5339
  */
5330
- const lineUncomment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeLineComment, 2 /* Uncomment */)));
5340
+ const lineUncomment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeLineComment, 2 /* CommentOption.Uncomment */)));
5331
5341
  /**
5332
5342
  Comment or uncomment the current selection using block comments.
5333
5343
  The block comment syntax is taken from the
5334
5344
  [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
5335
5345
  data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
5336
5346
  */
5337
- const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
5347
+ const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);
5338
5348
  /**
5339
5349
  Comment the current selection using block comments.
5340
5350
  */
5341
- const blockComment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeBlockComment, 1 /* Comment */)));
5351
+ const blockComment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeBlockComment, 1 /* CommentOption.Comment */)));
5342
5352
  /**
5343
5353
  Uncomment the current selection using block comments.
5344
5354
  */
5345
- const blockUncomment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeBlockComment, 2 /* Uncomment */)));
5355
+ const blockUncomment = /*@__PURE__*/(/* unused pure expression or super */ null && (command(changeBlockComment, 2 /* CommentOption.Uncomment */)));
5346
5356
  /**
5347
5357
  Comment or uncomment the lines around the current selection using
5348
5358
  block comments.
5349
5359
  */
5350
- const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
5360
+ const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);
5351
5361
  function getConfig(state, pos = state.selection.main.head) {
5352
5362
  let data = state.languageDataAt("commentTokens", pos);
5353
5363
  return data.length ? data[0] : {};
@@ -5406,14 +5416,14 @@ function changeBlockComment(option, state, ranges = state.selection.ranges) {
5406
5416
  if (!tokens.every(c => c))
5407
5417
  return null;
5408
5418
  let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
5409
- if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
5419
+ if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {
5410
5420
  return { changes: state.changes(ranges.map((range, i) => {
5411
5421
  if (comments[i])
5412
5422
  return [];
5413
5423
  return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
5414
5424
  })) };
5415
5425
  }
5416
- else if (option != 1 /* Comment */ && comments.some(c => c)) {
5426
+ else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {
5417
5427
  let changes = [];
5418
5428
  for (let i = 0, comment; i < comments.length; i++)
5419
5429
  if (comment = comments[i]) {
@@ -5453,7 +5463,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
5453
5463
  if (lines.length == startI + 1)
5454
5464
  lines[startI].single = true;
5455
5465
  }
5456
- if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
5466
+ if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
5457
5467
  let changes = [];
5458
5468
  for (let { line, token, indent, empty, single } of lines)
5459
5469
  if (single || !empty)
@@ -5461,7 +5471,7 @@ function changeLineComment(option, state, ranges = state.selection.ranges) {
5461
5471
  let changeSet = state.changes(changes);
5462
5472
  return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
5463
5473
  }
5464
- else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
5474
+ else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {
5465
5475
  let changes = [];
5466
5476
  for (let { line, comment, token } of lines)
5467
5477
  if (comment >= 0) {
@@ -5515,12 +5525,12 @@ const historyField_ = /*@__PURE__*/state_.StateField.define({
5515
5525
  if (fromHist) {
5516
5526
  let selection = tr.docChanged ? state_.EditorSelection.single(changeEnd(tr.changes)) : undefined;
5517
5527
  let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
5518
- let other = from == 0 /* Done */ ? state.undone : state.done;
5528
+ let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;
5519
5529
  if (item)
5520
5530
  other = updateBranch(other, other.length, config.minDepth, item);
5521
5531
  else
5522
5532
  other = addSelection(other, tr.startState.selection);
5523
- return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
5533
+ return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);
5524
5534
  }
5525
5535
  let isolate = tr.annotation(isolateHistory);
5526
5536
  if (isolate == "full" || isolate == "before")
@@ -5588,37 +5598,37 @@ function cmd(side, selection) {
5588
5598
  Undo a single group of history events. Returns false if no group
5589
5599
  was available.
5590
5600
  */
5591
- const undo = /*@__PURE__*/cmd(0 /* Done */, false);
5601
+ const undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);
5592
5602
  /**
5593
5603
  Redo a group of history events. Returns false if no group was
5594
5604
  available.
5595
5605
  */
5596
- const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
5606
+ const redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);
5597
5607
  /**
5598
5608
  Undo a change or selection change.
5599
5609
  */
5600
- const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
5610
+ const undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);
5601
5611
  /**
5602
5612
  Redo a change or selection change.
5603
5613
  */
5604
- const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
5614
+ const redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);
5605
5615
  function depth(side) {
5606
5616
  return function (state) {
5607
5617
  let histState = state.field(historyField_, false);
5608
5618
  if (!histState)
5609
5619
  return 0;
5610
- let branch = side == 0 /* Done */ ? histState.done : histState.undone;
5620
+ let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;
5611
5621
  return branch.length - (branch.length && !branch[0].changes ? 1 : 0);
5612
5622
  };
5613
5623
  }
5614
5624
  /**
5615
5625
  The amount of undoable change events available in a given state.
5616
5626
  */
5617
- const undoDepth = /*@__PURE__*/(/* unused pure expression or super */ null && (depth(0 /* Done */)));
5627
+ const undoDepth = /*@__PURE__*/(/* unused pure expression or super */ null && (depth(0 /* BranchName.Done */)));
5618
5628
  /**
5619
5629
  The amount of redoable change events available in a given state.
5620
5630
  */
5621
- const redoDepth = /*@__PURE__*/(/* unused pure expression or super */ null && (depth(1 /* Undone */)));
5631
+ const redoDepth = /*@__PURE__*/(/* unused pure expression or super */ null && (depth(1 /* BranchName.Undone */)));
5622
5632
  // History events store groups of changes or effects that need to be
5623
5633
  // undone/redone together.
5624
5634
  class HistEvent {
@@ -5796,7 +5806,7 @@ class HistoryState {
5796
5806
  return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
5797
5807
  }
5798
5808
  pop(side, state, selection) {
5799
- let branch = side == 0 /* Done */ ? this.done : this.undone;
5809
+ let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;
5800
5810
  if (branch.length == 0)
5801
5811
  return null;
5802
5812
  let event = branch[branch.length - 1];
@@ -5804,7 +5814,7 @@ class HistoryState {
5804
5814
  return state.update({
5805
5815
  selection: event.selectionsAfter[event.selectionsAfter.length - 1],
5806
5816
  annotations: fromHistory.of({ side, rest: popSelection(branch) }),
5807
- userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
5817
+ userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo",
5808
5818
  scrollIntoView: true
5809
5819
  });
5810
5820
  }
@@ -5821,7 +5831,7 @@ class HistoryState {
5821
5831
  effects: event.effects,
5822
5832
  annotations: fromHistory.of({ side, rest }),
5823
5833
  filter: false,
5824
- userEvent: side == 0 /* Done */ ? "undo" : "redo",
5834
+ userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo",
5825
5835
  scrollIntoView: true
5826
5836
  });
5827
5837
  }
@@ -6288,26 +6298,34 @@ const simplifySelection = ({ state, dispatch }) => {
6288
6298
  dispatch(setSel(state, selection));
6289
6299
  return true;
6290
6300
  };
6291
- function deleteBy({ state, dispatch }, by) {
6292
- if (state.readOnly)
6301
+ function deleteBy(target, by) {
6302
+ if (target.state.readOnly)
6293
6303
  return false;
6294
- let event = "delete.selection";
6304
+ let event = "delete.selection", { state } = target;
6295
6305
  let changes = state.changeByRange(range => {
6296
6306
  let { from, to } = range;
6297
6307
  if (from == to) {
6298
6308
  let towards = by(from);
6299
- if (towards < from)
6309
+ if (towards < from) {
6300
6310
  event = "delete.backward";
6301
- else if (towards > from)
6311
+ towards = skipAtomic(target, towards, false);
6312
+ }
6313
+ else if (towards > from) {
6302
6314
  event = "delete.forward";
6315
+ towards = skipAtomic(target, towards, true);
6316
+ }
6303
6317
  from = Math.min(from, towards);
6304
6318
  to = Math.max(to, towards);
6305
6319
  }
6320
+ else {
6321
+ from = skipAtomic(target, from, false);
6322
+ to = skipAtomic(target, to, true);
6323
+ }
6306
6324
  return from == to ? { range } : { changes: { from, to }, range: state_.EditorSelection.cursor(from) };
6307
6325
  });
6308
6326
  if (changes.changes.empty)
6309
6327
  return false;
6310
- dispatch(state.update(changes, {
6328
+ target.dispatch(state.update(changes, {
6311
6329
  scrollIntoView: true,
6312
6330
  userEvent: event,
6313
6331
  effects: event == "delete.selection" ? view_.EditorView.announce.of(state.phrase("Selection deleted")) : undefined
@@ -6339,7 +6357,7 @@ const deleteByChar = (target, forward) => deleteBy(target, pos => {
6339
6357
  if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))
6340
6358
  targetPos += forward ? 1 : -1;
6341
6359
  }
6342
- return skipAtomic(target, targetPos, forward);
6360
+ return targetPos;
6343
6361
  });
6344
6362
  /**
6345
6363
  Delete the selection, or, for cursor selections, the character
@@ -6368,7 +6386,7 @@ const deleteByGroup = (target, forward) => deleteBy(target, start => {
6368
6386
  cat = nextCat;
6369
6387
  pos = next;
6370
6388
  }
6371
- return skipAtomic(target, pos, forward);
6389
+ return pos;
6372
6390
  });
6373
6391
  /**
6374
6392
  Delete the selection or backward until the end of the next
@@ -6387,7 +6405,7 @@ line, delete the line break after it.
6387
6405
  */
6388
6406
  const deleteToLineEnd = view => deleteBy(view, pos => {
6389
6407
  let lineEnd = view.lineBlockAt(pos).to;
6390
- return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
6408
+ return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);
6391
6409
  });
6392
6410
  /**
6393
6411
  Delete the selection, or, if it is a cursor selection, delete to
@@ -6396,7 +6414,7 @@ line, delete the line break before it.
6396
6414
  */
6397
6415
  const deleteToLineStart = view => deleteBy(view, pos => {
6398
6416
  let lineStart = view.lineBlockAt(pos).from;
6399
- return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
6417
+ return pos > lineStart ? lineStart : Math.max(0, pos - 1);
6400
6418
  });
6401
6419
  /**
6402
6420
  Delete all whitespace directly before a line end from the
@@ -7073,7 +7091,7 @@ class RegExpCursor {
7073
7091
  if (match) {
7074
7092
  let from = this.curLineStart + match.index, to = from + match[0].length;
7075
7093
  this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
7076
- if (from == this.curLine.length)
7094
+ if (from == this.curLineStart + this.curLine.length)
7077
7095
  this.nextLine();
7078
7096
  if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
7079
7097
  this.value = { from, to, match };
@@ -7129,7 +7147,7 @@ class MultilineRegExpCursor {
7129
7147
  this.matchPos = toCharEnd(text, from);
7130
7148
  this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
7131
7149
  this.test = options === null || options === void 0 ? void 0 : options.test;
7132
- this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Base */));
7150
+ this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));
7133
7151
  }
7134
7152
  chunkEnd(pos) {
7135
7153
  return pos >= this.to ? this.to : this.text.lineAt(pos).to;
@@ -7467,10 +7485,17 @@ class SearchQuery {
7467
7485
  this.regexp = !!config.regexp;
7468
7486
  this.replace = config.replace || "";
7469
7487
  this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
7470
- this.unquoted = this.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
7488
+ this.unquoted = this.unquote(this.search);
7471
7489
  this.wholeWord = !!config.wholeWord;
7472
7490
  }
7473
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
+ /**
7474
7499
  Compare this query to another query.
7475
7500
  */
7476
7501
  eq(other) {
@@ -7509,10 +7534,10 @@ function stringWordTest(doc, categorizer) {
7509
7534
  bufPos = Math.max(0, from - 2);
7510
7535
  buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));
7511
7536
  }
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);
7537
+ return (categorizer(charBefore(buf, from - bufPos)) != state_.CharCategory.Word ||
7538
+ categorizer(charAfter(buf, from - bufPos)) != state_.CharCategory.Word) &&
7539
+ (categorizer(charAfter(buf, to - bufPos)) != state_.CharCategory.Word ||
7540
+ categorizer(charBefore(buf, to - bufPos)) != state_.CharCategory.Word);
7516
7541
  };
7517
7542
  }
7518
7543
  class StringQuery extends QueryType {
@@ -7529,7 +7554,7 @@ class StringQuery extends QueryType {
7529
7554
  // cursor, done by scanning chunk after chunk forward.
7530
7555
  prevMatchInRange(state, from, to) {
7531
7556
  for (let pos = to;;) {
7532
- let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);
7557
+ let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);
7533
7558
  let cursor = stringCursor(this.spec, state, start, pos), range = null;
7534
7559
  while (!cursor.nextOverlapping().done)
7535
7560
  range = cursor.value;
@@ -7537,14 +7562,14 @@ class StringQuery extends QueryType {
7537
7562
  return range;
7538
7563
  if (start == from)
7539
7564
  return null;
7540
- pos -= 10000 /* ChunkSize */;
7565
+ pos -= 10000 /* FindPrev.ChunkSize */;
7541
7566
  }
7542
7567
  }
7543
7568
  prevMatch(state, curFrom, curTo) {
7544
7569
  return this.prevMatchInRange(state, 0, curFrom) ||
7545
7570
  this.prevMatchInRange(state, curTo, state.doc.length);
7546
7571
  }
7547
- getReplacement(_result) { return this.spec.replace; }
7572
+ getReplacement(_result) { return this.spec.unquote(this.spec.replace); }
7548
7573
  matchAll(state, limit) {
7549
7574
  let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];
7550
7575
  while (!cursor.next().done) {
@@ -7574,10 +7599,10 @@ function charAfter(str, index) {
7574
7599
  }
7575
7600
  function regexpWordTest(categorizer) {
7576
7601
  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);
7602
+ (categorizer(charBefore(match.input, match.index)) != state_.CharCategory.Word ||
7603
+ categorizer(charAfter(match.input, match.index)) != state_.CharCategory.Word) &&
7604
+ (categorizer(charAfter(match.input, match.index + match[0].length)) != state_.CharCategory.Word ||
7605
+ categorizer(charBefore(match.input, match.index + match[0].length)) != state_.CharCategory.Word);
7581
7606
  }
7582
7607
  class RegExpQuery extends QueryType {
7583
7608
  nextMatch(state, curFrom, curTo) {
@@ -7588,7 +7613,7 @@ class RegExpQuery extends QueryType {
7588
7613
  }
7589
7614
  prevMatchInRange(state, from, to) {
7590
7615
  for (let size = 1;; size++) {
7591
- let start = Math.max(from, to - size * 10000 /* ChunkSize */);
7616
+ let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);
7592
7617
  let cursor = regexpCursor(this.spec, state, start, to), range = null;
7593
7618
  while (!cursor.next().done)
7594
7619
  range = cursor.value;
@@ -7603,10 +7628,10 @@ class RegExpQuery extends QueryType {
7603
7628
  this.prevMatchInRange(state, curTo, state.doc.length);
7604
7629
  }
7605
7630
  getReplacement(result) {
7606
- return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
7631
+ return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
7607
7632
  : i == "&" ? result.match[0]
7608
7633
  : i != "0" && +i < result.match.length ? result.match[i]
7609
- : m);
7634
+ : m));
7610
7635
  }
7611
7636
  matchAll(state, limit) {
7612
7637
  let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
@@ -7618,7 +7643,7 @@ class RegExpQuery extends QueryType {
7618
7643
  return ranges;
7619
7644
  }
7620
7645
  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));
7646
+ let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));
7622
7647
  while (!cursor.next().done)
7623
7648
  add(cursor.value.from, cursor.value.to);
7624
7649
  }
@@ -7685,7 +7710,7 @@ const searchHighlighter = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
7685
7710
  let builder = new state_.RangeSetBuilder();
7686
7711
  for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
7687
7712
  let { from, to } = ranges[i];
7688
- while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* HighlightMargin */)
7713
+ while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */)
7689
7714
  to = ranges[++i].to;
7690
7715
  query.highlight(view.state, from, to, (from, to) => {
7691
7716
  let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
@@ -7912,6 +7937,7 @@ class SearchPanel {
7912
7937
  "aria-label": phrase(view, "Find"),
7913
7938
  class: "cm-textfield",
7914
7939
  name: "search",
7940
+ form: "",
7915
7941
  "main-field": "true",
7916
7942
  onchange: this.commit,
7917
7943
  onkeyup: this.commit
@@ -7922,24 +7948,28 @@ class SearchPanel {
7922
7948
  "aria-label": phrase(view, "Replace"),
7923
7949
  class: "cm-textfield",
7924
7950
  name: "replace",
7951
+ form: "",
7925
7952
  onchange: this.commit,
7926
7953
  onkeyup: this.commit
7927
7954
  });
7928
7955
  this.caseField = crelt("input", {
7929
7956
  type: "checkbox",
7930
7957
  name: "case",
7958
+ form: "",
7931
7959
  checked: query.caseSensitive,
7932
7960
  onchange: this.commit
7933
7961
  });
7934
7962
  this.reField = crelt("input", {
7935
7963
  type: "checkbox",
7936
7964
  name: "re",
7965
+ form: "",
7937
7966
  checked: query.regexp,
7938
7967
  onchange: this.commit
7939
7968
  });
7940
7969
  this.wordField = crelt("input", {
7941
7970
  type: "checkbox",
7942
7971
  name: "word",
7972
+ form: "",
7943
7973
  checked: query.wholeWord,
7944
7974
  onchange: this.commit
7945
7975
  });
@@ -8584,7 +8614,7 @@ class CompletionTooltip {
8584
8614
  let sel = this.dom.querySelector("[aria-selected]");
8585
8615
  if (!sel || !this.info)
8586
8616
  return null;
8587
- let win = this.dom.ownerDocument.defaultView;
8617
+ let win = this.dom.ownerDocument.defaultView || window;
8588
8618
  let listRect = this.dom.getBoundingClientRect();
8589
8619
  let infoRect = this.info.getBoundingClientRect();
8590
8620
  let selRect = sel.getBoundingClientRect();
@@ -9166,6 +9196,7 @@ const autocomplete_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
9166
9196
  verticalAlign: "text-top",
9167
9197
  width: 0,
9168
9198
  height: "1.15em",
9199
+ display: "inline-block",
9169
9200
  margin: "0 -0.7px -.7em",
9170
9201
  borderLeft: "1.4px dotted #888"
9171
9202
  },
@@ -9549,7 +9580,8 @@ const completeAnyWord = context => {
9549
9580
 
9550
9581
  const defaults = {
9551
9582
  brackets: ["(", "[", "{", "'", '"'],
9552
- before: ")]}:;>"
9583
+ before: ")]}:;>",
9584
+ stringPrefixes: []
9553
9585
  };
9554
9586
  const closeBracketEffect = /*@__PURE__*/state_.StateEffect.define({
9555
9587
  map(value, mapping) {
@@ -9665,7 +9697,7 @@ function insertBracket(state, bracket) {
9665
9697
  for (let tok of tokens) {
9666
9698
  let closed = closing((0,state_.codePointAt)(tok, 0));
9667
9699
  if (bracket == tok)
9668
- return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1)
9700
+ return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1, conf)
9669
9701
  : handleOpen(state, tok, closed, conf.before || defaults.before);
9670
9702
  if (bracket == closed && closedBracketAt(state, state.selection.main.from))
9671
9703
  return handleClose(state, tok, closed);
@@ -9720,13 +9752,14 @@ function handleClose(state, _open, close) {
9720
9752
  }
9721
9753
  // Handles cases where the open and close token are the same, and
9722
9754
  // possibly triple quotes (as in `"""abc"""`-style quoting).
9723
- function handleSame(state, token, allowTriple) {
9755
+ function handleSame(state, token, allowTriple, config) {
9756
+ let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes;
9724
9757
  let dont = null, changes = state.changeByRange(range => {
9725
9758
  if (!range.empty)
9726
9759
  return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
9727
9760
  effects: closeBracketEffect.of(range.to + token.length),
9728
9761
  range: state_.EditorSelection.range(range.anchor + token.length, range.head + token.length) };
9729
- let pos = range.head, next = nextChar(state.doc, pos);
9762
+ let pos = range.head, next = nextChar(state.doc, pos), start;
9730
9763
  if (next == token) {
9731
9764
  if (nodeStart(state, pos)) {
9732
9765
  return { changes: { insert: token + token, from: pos },
@@ -9740,14 +9773,14 @@ function handleSame(state, token, allowTriple) {
9740
9773
  }
9741
9774
  }
9742
9775
  else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
9743
- nodeStart(state, pos - 2 * token.length)) {
9776
+ (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 &&
9777
+ nodeStart(state, start)) {
9744
9778
  return { changes: { insert: token + token + token + token, from: pos },
9745
9779
  effects: closeBracketEffect.of(pos + token.length),
9746
9780
  range: state_.EditorSelection.cursor(pos + token.length) };
9747
9781
  }
9748
9782
  else if (state.charCategorizer(pos)(next) != state_.CharCategory.Word) {
9749
- let prev = state.sliceDoc(pos - 1, pos);
9750
- if (prev != token && state.charCategorizer(pos)(prev) != state_.CharCategory.Word && !probablyInString(state, pos, token))
9783
+ if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes))
9751
9784
  return { changes: { insert: token + token, from: pos },
9752
9785
  effects: closeBracketEffect.of(pos + token.length),
9753
9786
  range: state_.EditorSelection.cursor(pos + token.length) };
@@ -9763,12 +9796,15 @@ function nodeStart(state, pos) {
9763
9796
  let tree = dist_syntaxTree(state).resolveInner(pos + 1);
9764
9797
  return tree.parent && tree.from == pos;
9765
9798
  }
9766
- function probablyInString(state, pos, quoteToken) {
9799
+ function probablyInString(state, pos, quoteToken, prefixes) {
9767
9800
  let node = dist_syntaxTree(state).resolveInner(pos, -1);
9801
+ let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0);
9768
9802
  for (let i = 0; i < 5; i++) {
9769
- if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken) {
9803
+ let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix));
9804
+ let quotePos = start.indexOf(quoteToken);
9805
+ if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) {
9770
9806
  let first = node.firstChild;
9771
- while (first && first.from == node.from && first.to - first.from > quoteToken.length) {
9807
+ while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) {
9772
9808
  if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken)
9773
9809
  return false;
9774
9810
  first = first.firstChild;
@@ -9782,6 +9818,17 @@ function probablyInString(state, pos, quoteToken) {
9782
9818
  }
9783
9819
  return false;
9784
9820
  }
9821
+ function canStartStringAt(state, pos, prefixes) {
9822
+ let charCat = state.charCategorizer(pos);
9823
+ if (charCat(state.sliceDoc(pos - 1, pos)) != state_.CharCategory.Word)
9824
+ return pos;
9825
+ for (let prefix of prefixes) {
9826
+ let start = pos - prefix.length;
9827
+ if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != state_.CharCategory.Word)
9828
+ return start;
9829
+ }
9830
+ return -1;
9831
+ }
9785
9832
 
9786
9833
  /**
9787
9834
  Returns an extension that enables autocompletion.
@@ -10610,7 +10657,6 @@ function lintGutter(config = {}) {
10610
10657
 
10611
10658
 
10612
10659
 
10613
-
10614
10660
  /**
10615
10661
  This is an extension value that just pulls together a number of
10616
10662
  extensions that you might want in a basic editor. It is meant as a
@@ -10652,37 +10698,28 @@ var basicSetup = function basicSetup(options) {
10652
10698
  if (options === void 0) {
10653
10699
  options = {};
10654
10700
  }
10655
-
10656
10701
  var keymaps = [];
10657
-
10658
10702
  if (options.closeBracketsKeymap !== false) {
10659
10703
  keymaps = keymaps.concat(closeBracketsKeymap);
10660
10704
  }
10661
-
10662
10705
  if (options.defaultKeymap !== false) {
10663
10706
  keymaps = keymaps.concat(defaultKeymap);
10664
10707
  }
10665
-
10666
10708
  if (options.searchKeymap !== false) {
10667
10709
  keymaps = keymaps.concat(searchKeymap);
10668
10710
  }
10669
-
10670
10711
  if (options.historyKeymap !== false) {
10671
10712
  keymaps = keymaps.concat(historyKeymap);
10672
10713
  }
10673
-
10674
10714
  if (options.foldKeymap !== false) {
10675
10715
  keymaps = keymaps.concat(foldKeymap);
10676
10716
  }
10677
-
10678
10717
  if (options.completionKeymap !== false) {
10679
10718
  keymaps = keymaps.concat(completionKeymap);
10680
10719
  }
10681
-
10682
10720
  if (options.lintKeymap !== false) {
10683
10721
  keymaps = keymaps.concat(lintKeymap);
10684
10722
  }
10685
-
10686
10723
  var extensions = [];
10687
10724
  if (options.lineNumbers !== false) extensions.push((0,view_.lineNumbers)());
10688
10725
  if (options.highlightActiveLineGutter !== false) extensions.push((0,view_.highlightActiveLineGutter)());
@@ -10703,9 +10740,9 @@ var basicSetup = function basicSetup(options) {
10703
10740
  if (options.crosshairCursor !== false) extensions.push((0,view_.crosshairCursor)());
10704
10741
  if (options.highlightActiveLine !== false) extensions.push((0,view_.highlightActiveLine)());
10705
10742
  if (options.highlightSelectionMatches !== false) extensions.push(highlightSelectionMatches());
10743
+ if (options.tabSize && typeof options.tabSize === 'number') extensions.push(dist_indentUnit.of(' '.repeat(options.tabSize)));
10706
10744
  return extensions.concat([view_.keymap.of(keymaps.flat())]).filter(Boolean);
10707
10745
  };
10708
-
10709
10746
  /**
10710
10747
  A minimal set of extensions to create a functional editor. Only
10711
10748
  includes [the default keymap](https://codemirror.net/6/docs/ref/#commands.defaultKeymap), [undo
@@ -10718,17 +10755,13 @@ var minimalSetup = function minimalSetup(options) {
10718
10755
  if (options === void 0) {
10719
10756
  options = {};
10720
10757
  }
10721
-
10722
10758
  var keymaps = [];
10723
-
10724
10759
  if (options.defaultKeymap !== false) {
10725
10760
  keymaps = keymaps.concat(defaultKeymap);
10726
10761
  }
10727
-
10728
10762
  if (options.historyKeymap !== false) {
10729
10763
  keymaps = keymaps.concat(historyKeymap);
10730
10764
  }
10731
-
10732
10765
  var extensions = [];
10733
10766
  if (options.highlightSpecialChars !== false) extensions.push((0,view_.highlightSpecialChars)());
10734
10767
  if (options.history !== false) extensions.push(dist_history());