@scalar/use-codemirror 0.9.1 → 0.10.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/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import * as Y from "yjs";
7
+ import { yCollab } from "y-codemirror.next";
8
8
  import { ref, watch, onBeforeUnmount, toValue, computed, defineComponent, toRef, openBlock, createElementBlock } from "vue";
9
9
  class Text {
10
10
  /**
@@ -26,7 +26,7 @@ class Text {
26
26
  /**
27
27
  Replace a range of the text with the given content.
28
28
  */
29
- replace(from, to, text2) {
29
+ replace(from, to, text) {
30
30
  [from, to] = clip(this, from, to);
31
31
  let parts = [];
32
32
  this.decompose(
@@ -36,10 +36,10 @@ class Text {
36
36
  2
37
37
  /* Open.To */
38
38
  );
39
- if (text2.length)
40
- text2.decompose(
39
+ if (text.length)
40
+ text.decompose(
41
41
  0,
42
- text2.length,
42
+ text.length,
43
43
  parts,
44
44
  1 | 2
45
45
  /* Open.To */
@@ -51,7 +51,7 @@ class Text {
51
51
  1
52
52
  /* Open.From */
53
53
  );
54
- return TextNode.from(parts, this.length - (to - from) + text2.length);
54
+ return TextNode.from(parts, this.length - (to - from) + text.length);
55
55
  }
56
56
  /**
57
57
  Append another document to this one.
@@ -147,18 +147,18 @@ class Text {
147
147
  /**
148
148
  Create a `Text` instance for the given array of lines.
149
149
  */
150
- static of(text2) {
151
- if (text2.length == 0)
150
+ static of(text) {
151
+ if (text.length == 0)
152
152
  throw new RangeError("A document must have at least one line");
153
- if (text2.length == 1 && !text2[0])
153
+ if (text.length == 1 && !text[0])
154
154
  return Text.empty;
155
- return text2.length <= 32 ? new TextLeaf(text2) : TextNode.from(TextLeaf.split(text2, []));
155
+ return text.length <= 32 ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
156
156
  }
157
157
  }
158
158
  class TextLeaf extends Text {
159
- constructor(text2, length = textLength(text2)) {
159
+ constructor(text, length = textLength(text)) {
160
160
  super();
161
- this.text = text2;
161
+ this.text = text;
162
162
  this.length = length;
163
163
  }
164
164
  get lines() {
@@ -177,26 +177,26 @@ class TextLeaf extends Text {
177
177
  }
178
178
  }
179
179
  decompose(from, to, target, open) {
180
- let text2 = from <= 0 && to >= this.length ? this : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
180
+ let text = from <= 0 && to >= this.length ? this : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
181
181
  if (open & 1) {
182
182
  let prev = target.pop();
183
- let joined = appendText(text2.text, prev.text.slice(), 0, text2.length);
183
+ let joined = appendText(text.text, prev.text.slice(), 0, text.length);
184
184
  if (joined.length <= 32) {
185
- target.push(new TextLeaf(joined, prev.length + text2.length));
185
+ target.push(new TextLeaf(joined, prev.length + text.length));
186
186
  } else {
187
187
  let mid = joined.length >> 1;
188
188
  target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
189
189
  }
190
190
  } else {
191
- target.push(text2);
191
+ target.push(text);
192
192
  }
193
193
  }
194
- replace(from, to, text2) {
195
- if (!(text2 instanceof TextLeaf))
196
- return super.replace(from, to, text2);
194
+ replace(from, to, text) {
195
+ if (!(text instanceof TextLeaf))
196
+ return super.replace(from, to, text);
197
197
  [from, to] = clip(this, from, to);
198
- let lines = appendText(this.text, appendText(text2.text, sliceText(this.text, 0, from)), to);
199
- let newLen = this.length + text2.length - (to - from);
198
+ let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
199
+ let newLen = this.length + text.length - (to - from);
200
200
  if (lines.length <= 32)
201
201
  return new TextLeaf(lines, newLen);
202
202
  return TextNode.from(TextLeaf.split(lines, []), newLen);
@@ -221,9 +221,9 @@ class TextLeaf extends Text {
221
221
  scanIdentical() {
222
222
  return 0;
223
223
  }
224
- static split(text2, target) {
224
+ static split(text, target) {
225
225
  let part = [], len = -1;
226
- for (let line of text2) {
226
+ for (let line of text) {
227
227
  part.push(line);
228
228
  len += line.length + 1;
229
229
  if (part.length == 32) {
@@ -268,24 +268,24 @@ class TextNode extends Text {
268
268
  pos = end + 1;
269
269
  }
270
270
  }
271
- replace(from, to, text2) {
271
+ replace(from, to, text) {
272
272
  [from, to] = clip(this, from, to);
273
- if (text2.lines < this.lines)
273
+ if (text.lines < this.lines)
274
274
  for (let i = 0, pos = 0; i < this.children.length; i++) {
275
275
  let child = this.children[i], end = pos + child.length;
276
276
  if (from >= pos && to <= end) {
277
- let updated = child.replace(from - pos, to - pos, text2);
277
+ let updated = child.replace(from - pos, to - pos, text);
278
278
  let totalLines = this.lines - child.lines + updated.lines;
279
279
  if (updated.lines < totalLines >> 5 - 1 && updated.lines > totalLines >> 5 + 1) {
280
280
  let copy = this.children.slice();
281
281
  copy[i] = updated;
282
- return new TextNode(copy, this.length - (to - from) + text2.length);
282
+ return new TextNode(copy, this.length - (to - from) + text.length);
283
283
  }
284
284
  return super.replace(pos, end, updated);
285
285
  }
286
286
  pos = end + 1;
287
287
  }
288
- return super.replace(from, to, text2);
288
+ return super.replace(from, to, text);
289
289
  }
290
290
  sliceString(from, to = this.length, lineSep = "\n") {
291
291
  [from, to] = clip(this, from, to);
@@ -368,15 +368,15 @@ class TextNode extends Text {
368
368
  }
369
369
  }
370
370
  Text.empty = /* @__PURE__ */ new TextLeaf([""], 0);
371
- function textLength(text2) {
371
+ function textLength(text) {
372
372
  let length = -1;
373
- for (let line of text2)
373
+ for (let line of text)
374
374
  length += line.length + 1;
375
375
  return length;
376
376
  }
377
- function appendText(text2, target, from = 0, to = 1e9) {
378
- for (let pos = 0, i = 0, first = true; i < text2.length && pos <= to; i++) {
379
- let line = text2[i], end = pos + line.length;
377
+ function appendText(text, target, from = 0, to = 1e9) {
378
+ for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
379
+ let line = text[i], end = pos + line.length;
380
380
  if (end >= from) {
381
381
  if (end > to)
382
382
  line = line.slice(0, to - pos);
@@ -392,17 +392,17 @@ function appendText(text2, target, from = 0, to = 1e9) {
392
392
  }
393
393
  return target;
394
394
  }
395
- function sliceText(text2, from, to) {
396
- return appendText(text2, [""], from, to);
395
+ function sliceText(text, from, to) {
396
+ return appendText(text, [""], from, to);
397
397
  }
398
398
  class RawTextCursor {
399
- constructor(text2, dir = 1) {
399
+ constructor(text, dir = 1) {
400
400
  this.dir = dir;
401
401
  this.done = false;
402
402
  this.lineBreak = false;
403
403
  this.value = "";
404
- this.nodes = [text2];
405
- this.offsets = [dir > 0 ? 1 : (text2 instanceof TextLeaf ? text2.text.length : text2.children.length) << 1];
404
+ this.nodes = [text];
405
+ this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
406
406
  }
407
407
  nextInner(skip, dir) {
408
408
  this.done = this.lineBreak = false;
@@ -459,11 +459,11 @@ class RawTextCursor {
459
459
  }
460
460
  }
461
461
  class PartialTextCursor {
462
- constructor(text2, start, end) {
462
+ constructor(text, start, end) {
463
463
  this.value = "";
464
464
  this.done = false;
465
- this.cursor = new RawTextCursor(text2, start > end ? -1 : 1);
466
- this.pos = start > end ? text2.length : 0;
465
+ this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
466
+ this.pos = start > end ? text.length : 0;
467
467
  this.from = Math.min(start, end);
468
468
  this.to = Math.max(start, end);
469
469
  }
@@ -539,11 +539,11 @@ class Line {
539
539
  /**
540
540
  @internal
541
541
  */
542
- constructor(from, to, number2, text2) {
542
+ constructor(from, to, number2, text) {
543
543
  this.from = from;
544
544
  this.to = to;
545
545
  this.number = number2;
546
- this.text = text2;
546
+ this.text = text;
547
547
  }
548
548
  /**
549
549
  The length of the line (not including any line break after it).
@@ -552,9 +552,9 @@ class Line {
552
552
  return this.to - this.from;
553
553
  }
554
554
  }
555
- function clip(text2, from, to) {
556
- from = Math.max(0, Math.min(text2.length, from));
557
- return [from, Math.max(from, Math.min(text2.length, to))];
555
+ function clip(text, from, to) {
556
+ from = Math.max(0, Math.min(text.length, from));
557
+ return [from, Math.max(from, Math.min(text.length, to))];
558
558
  }
559
559
  let extend = /* @__PURE__ */ "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((s) => s ? parseInt(s, 36) : 1);
560
560
  for (let i = 1; i < extend.length; i++)
@@ -822,7 +822,7 @@ class ChangeSet extends ChangeDesc {
822
822
  apply(doc2) {
823
823
  if (this.length != doc2.length)
824
824
  throw new RangeError("Applying change set to a document with the wrong length");
825
- iterChanges(this, (fromA, toA, fromB, _toB, text2) => doc2 = doc2.replace(fromB, fromB + (toA - fromA), text2), false);
825
+ iterChanges(this, (fromA, toA, fromB, _toB, text) => doc2 = doc2.replace(fromB, fromB + (toA - fromA), text), false);
826
826
  return doc2;
827
827
  }
828
828
  mapDesc(other, before = false) {
@@ -1067,18 +1067,18 @@ function iterChanges(desc, f, individual) {
1067
1067
  posA += len;
1068
1068
  posB += len;
1069
1069
  } else {
1070
- let endA = posA, endB = posB, text2 = Text.empty;
1070
+ let endA = posA, endB = posB, text = Text.empty;
1071
1071
  for (; ; ) {
1072
1072
  endA += len;
1073
1073
  endB += ins;
1074
1074
  if (ins && inserted)
1075
- text2 = text2.append(inserted[i - 2 >> 1]);
1075
+ text = text.append(inserted[i - 2 >> 1]);
1076
1076
  if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
1077
1077
  break;
1078
1078
  len = desc.sections[i++];
1079
1079
  ins = desc.sections[i++];
1080
1080
  }
1081
- f(posA, endA, posB, endB, text2);
1081
+ f(posA, endA, posB, endB, text);
1082
1082
  posA = endA;
1083
1083
  posB = endB;
1084
1084
  }
@@ -1699,8 +1699,8 @@ class StateField {
1699
1699
  way it is initialized. Can be useful when you need to provide a
1700
1700
  non-default starting value for the field.
1701
1701
  */
1702
- init(create2) {
1703
- return [this, initField.of({ field: this, create: create2 })];
1702
+ init(create) {
1703
+ return [this, initField.of({ field: this, create })];
1704
1704
  }
1705
1705
  /**
1706
1706
  State field instances can be used as
@@ -2324,12 +2324,12 @@ class EditorState {
2324
2324
  Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
2325
2325
  replaces every selection range with the given content.
2326
2326
  */
2327
- replaceSelection(text2) {
2328
- if (typeof text2 == "string")
2329
- text2 = this.toText(text2);
2327
+ replaceSelection(text) {
2328
+ if (typeof text == "string")
2329
+ text = this.toText(text);
2330
2330
  return this.changeByRange((range) => ({
2331
- changes: { from: range.from, to: range.to, insert: text2 },
2332
- range: EditorSelection.cursor(range.from + text2.length)
2331
+ changes: { from: range.from, to: range.to, insert: text },
2332
+ range: EditorSelection.cursor(range.from + text.length)
2333
2333
  }));
2334
2334
  }
2335
2335
  /**
@@ -2547,18 +2547,18 @@ class EditorState {
2547
2547
  this returns null.
2548
2548
  */
2549
2549
  wordAt(pos) {
2550
- let { text: text2, from, length } = this.doc.lineAt(pos);
2550
+ let { text, from, length } = this.doc.lineAt(pos);
2551
2551
  let cat = this.charCategorizer(pos);
2552
2552
  let start = pos - from, end = pos - from;
2553
2553
  while (start > 0) {
2554
- let prev = findClusterBreak(text2, start, false);
2555
- if (cat(text2.slice(prev, start)) != CharCategory.Word)
2554
+ let prev = findClusterBreak(text, start, false);
2555
+ if (cat(text.slice(prev, start)) != CharCategory.Word)
2556
2556
  break;
2557
2557
  start = prev;
2558
2558
  }
2559
2559
  while (end < length) {
2560
- let next = findClusterBreak(text2, end);
2561
- if (cat(text2.slice(end, next)) != CharCategory.Word)
2560
+ let next = findClusterBreak(text, end);
2561
+ if (cat(text.slice(end, next)) != CharCategory.Word)
2562
2562
  break;
2563
2563
  end = next;
2564
2564
  }
@@ -3514,10 +3514,10 @@ class StyleSet {
3514
3514
  if (this.root.adoptedStyleSheets.indexOf(this.sheet) < 0)
3515
3515
  this.root.adoptedStyleSheets = [this.sheet, ...this.root.adoptedStyleSheets];
3516
3516
  } else {
3517
- let text2 = "";
3517
+ let text = "";
3518
3518
  for (let i = 0; i < this.modules.length; i++)
3519
- text2 += this.modules[i].getRules() + "\n";
3520
- this.styleTag.textContent = text2;
3519
+ text += this.modules[i].getRules() + "\n";
3520
+ this.styleTag.textContent = text;
3521
3521
  let target = this.root.head || this.root;
3522
3522
  if (this.styleTag.parentNode != target)
3523
3523
  target.insertBefore(this.styleTag, target.firstChild);
@@ -4276,14 +4276,14 @@ function mergeChildrenInto(parent, from, to, insert2, openStart, openEnd) {
4276
4276
  replaceRange(parent, fromI, fromOff, toI, toOff, insert2, 0, openStart, openEnd);
4277
4277
  }
4278
4278
  let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
4279
- let doc$1 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
4279
+ let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
4280
4280
  const ie_edge = /* @__PURE__ */ /Edge\/(\d+)/.exec(nav.userAgent);
4281
4281
  const ie_upto10 = /* @__PURE__ */ /MSIE \d/.test(nav.userAgent);
4282
4282
  const ie_11up = /* @__PURE__ */ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
4283
4283
  const ie = !!(ie_upto10 || ie_11up || ie_edge);
4284
4284
  const gecko = !ie && /* @__PURE__ */ /gecko\/(\d+)/i.test(nav.userAgent);
4285
4285
  const chrome = !ie && /* @__PURE__ */ /Chrome\/(\d+)/.exec(nav.userAgent);
4286
- const webkit = "webkitFontSmoothing" in doc$1.documentElement.style;
4286
+ const webkit = "webkitFontSmoothing" in doc.documentElement.style;
4287
4287
  const safari = !ie && /* @__PURE__ */ /Apple Computer/.test(nav.vendor);
4288
4288
  const ios = safari && (/* @__PURE__ */ /Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
4289
4289
  var browser = {
@@ -4291,7 +4291,7 @@ var browser = {
4291
4291
  windows: /* @__PURE__ */ /Win/.test(nav.platform),
4292
4292
  linux: /* @__PURE__ */ /Linux|X11/.test(nav.platform),
4293
4293
  ie,
4294
- ie_version: ie_upto10 ? doc$1.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
4294
+ ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
4295
4295
  gecko,
4296
4296
  gecko_version: gecko ? +(/* @__PURE__ */ /Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
4297
4297
  chrome: !!chrome,
@@ -4301,13 +4301,13 @@ var browser = {
4301
4301
  webkit,
4302
4302
  safari,
4303
4303
  webkit_version: webkit ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
4304
- tabSize: doc$1.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
4304
+ tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
4305
4305
  };
4306
4306
  const MaxJoinLen = 256;
4307
4307
  class TextView extends ContentView {
4308
- constructor(text2) {
4308
+ constructor(text) {
4309
4309
  super();
4310
- this.text = text2;
4310
+ this.text = text;
4311
4311
  }
4312
4312
  get length() {
4313
4313
  return this.text.length;
@@ -4422,8 +4422,8 @@ class MarkView extends ContentView {
4422
4422
  return coordsInChildren(this, pos, side);
4423
4423
  }
4424
4424
  }
4425
- function textCoords(text2, pos, side) {
4426
- let length = text2.nodeValue.length;
4425
+ function textCoords(text, pos, side) {
4426
+ let length = text.nodeValue.length;
4427
4427
  if (pos > length)
4428
4428
  pos = length;
4429
4429
  let from = pos, to = pos, flatten2 = 0;
@@ -4443,7 +4443,7 @@ function textCoords(text2, pos, side) {
4443
4443
  else if (to < length)
4444
4444
  to++;
4445
4445
  }
4446
- let rects = textRange(text2, from, to).getClientRects();
4446
+ let rects = textRange(text, from, to).getClientRects();
4447
4447
  if (!rects.length)
4448
4448
  return null;
4449
4449
  let rect = rects[(flatten2 ? flatten2 < 0 : side >= 0) ? 0 : rects.length - 1];
@@ -4510,8 +4510,8 @@ class WidgetView extends ContentView {
4510
4510
  let top2 = this;
4511
4511
  while (top2.parent)
4512
4512
  top2 = top2.parent;
4513
- let { view } = top2, text2 = view && view.state.doc, start = this.posAtStart;
4514
- return text2 ? text2.slice(start, start + this.length) : Text.empty;
4513
+ let { view } = top2, text = view && view.state.doc, start = this.posAtStart;
4514
+ return text ? text.slice(start, start + this.length) : Text.empty;
4515
4515
  }
4516
4516
  domAtPos(pos) {
4517
4517
  return (this.length ? pos == 0 : this.side > 0) ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
@@ -5347,8 +5347,8 @@ class ContentBuilder {
5347
5347
  if (this.openStart < 0)
5348
5348
  this.openStart = openStart;
5349
5349
  }
5350
- static build(text2, from, to, decorations2, dynamicDecorationMap) {
5351
- let builder = new ContentBuilder(text2, from, to, dynamicDecorationMap);
5350
+ static build(text, from, to, decorations2, dynamicDecorationMap) {
5351
+ let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
5352
5352
  builder.openEnd = RangeSet.spans(decorations2, from, to, builder);
5353
5353
  if (builder.openStart < 0)
5354
5354
  builder.openStart = builder.openEnd;
@@ -5733,9 +5733,9 @@ function moveVisually(line, order, dir, start, forward) {
5733
5733
  return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
5734
5734
  return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
5735
5735
  }
5736
- function autoDirection(text2, from, to) {
5736
+ function autoDirection(text, from, to) {
5737
5737
  for (let i = from; i < to; i++) {
5738
- let type = charType(text2.charCodeAt(i));
5738
+ let type = charType(text.charCodeAt(i));
5739
5739
  if (type == 1)
5740
5740
  return LTR;
5741
5741
  if (type == 2 || type == 4)
@@ -5788,9 +5788,9 @@ const editable = /* @__PURE__ */ Facet.define({ combine: (values2) => values2.le
5788
5788
  let nextPluginID = 0;
5789
5789
  const viewPlugin = /* @__PURE__ */ Facet.define();
5790
5790
  class ViewPlugin {
5791
- constructor(id2, create2, domEventHandlers, domEventObservers, buildExtensions) {
5791
+ constructor(id2, create, domEventHandlers, domEventObservers, buildExtensions) {
5792
5792
  this.id = id2;
5793
- this.create = create2;
5793
+ this.create = create;
5794
5794
  this.domEventHandlers = domEventHandlers;
5795
5795
  this.domEventObservers = domEventObservers;
5796
5796
  this.extension = buildExtensions(this);
@@ -5799,9 +5799,9 @@ class ViewPlugin {
5799
5799
  Define a plugin from a constructor function that creates the
5800
5800
  plugin's value, given an editor view.
5801
5801
  */
5802
- static define(create2, spec) {
5802
+ static define(create, spec) {
5803
5803
  const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
5804
- return new ViewPlugin(nextPluginID++, create2, eventHandlers, eventObservers, (plugin) => {
5804
+ return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, (plugin) => {
5805
5805
  let ext = [viewPlugin.of(plugin)];
5806
5806
  if (deco)
5807
5807
  ext.push(decorations.of((view) => {
@@ -6232,9 +6232,9 @@ class DocView extends ContentView {
6232
6232
  if (browser.gecko) {
6233
6233
  let nextTo = nextToUneditable(anchor.node, anchor.offset);
6234
6234
  if (nextTo && nextTo != (1 | 2)) {
6235
- let text2 = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 ? 1 : -1);
6236
- if (text2)
6237
- anchor = new DOMPos(text2.node, text2.offset);
6235
+ let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 ? 1 : -1);
6236
+ if (text)
6237
+ anchor = new DOMPos(text.node, text.offset);
6238
6238
  }
6239
6239
  }
6240
6240
  rawSel.collapse(anchor.node, anchor.offset);
@@ -6561,10 +6561,10 @@ function findCompositionRange(view, changes, headPos) {
6561
6561
  let found = findCompositionNode(view, headPos);
6562
6562
  if (!found)
6563
6563
  return null;
6564
- let { node: textNode, from, to } = found, text2 = textNode.nodeValue;
6565
- if (/[\n\r]/.test(text2))
6564
+ let { node: textNode, from, to } = found, text = textNode.nodeValue;
6565
+ if (/[\n\r]/.test(text))
6566
6566
  return null;
6567
- if (view.state.doc.sliceString(found.from, found.to) != text2)
6567
+ if (view.state.doc.sliceString(found.from, found.to) != text)
6568
6568
  return null;
6569
6569
  let inv = changes.invertedDesc;
6570
6570
  let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);
@@ -6803,17 +6803,17 @@ function posAtCoords(view, coords, precise, bias = -1) {
6803
6803
  return view.viewport.to == view.state.doc.length ? view.state.doc.length : precise ? null : posAtCoordsImprecise(view, content2, block, x, y);
6804
6804
  let doc2 = view.dom.ownerDocument;
6805
6805
  let root = view.root.elementFromPoint ? view.root : doc2;
6806
- let element2 = root.elementFromPoint(x, y);
6807
- if (element2 && !view.contentDOM.contains(element2))
6808
- element2 = null;
6809
- if (!element2) {
6806
+ let element = root.elementFromPoint(x, y);
6807
+ if (element && !view.contentDOM.contains(element))
6808
+ element = null;
6809
+ if (!element) {
6810
6810
  x = Math.max(content2.left + 1, Math.min(content2.right - 1, x));
6811
- element2 = root.elementFromPoint(x, y);
6812
- if (element2 && !view.contentDOM.contains(element2))
6813
- element2 = null;
6811
+ element = root.elementFromPoint(x, y);
6812
+ if (element && !view.contentDOM.contains(element))
6813
+ element = null;
6814
6814
  }
6815
6815
  let node, offset = -1;
6816
- if (element2 && ((_a2 = view.docView.nearest(element2)) === null || _a2 === void 0 ? void 0 : _a2.isEditable) != false) {
6816
+ if (element && ((_a2 = view.docView.nearest(element)) === null || _a2 === void 0 ? void 0 : _a2.isEditable) != false) {
6817
6817
  if (doc2.caretPositionFromPoint) {
6818
6818
  let pos = doc2.caretPositionFromPoint(x, y);
6819
6819
  if (pos)
@@ -7325,9 +7325,9 @@ function capturePaste(view) {
7325
7325
  }, 50);
7326
7326
  }
7327
7327
  function doPaste(view, input) {
7328
- let { state } = view, changes, i = 1, text2 = state.toText(input);
7329
- let byLine = text2.lines == state.selection.ranges.length;
7330
- let linewise = lastLinewiseCopy != null && state.selection.ranges.every((r) => r.empty) && lastLinewiseCopy == text2.toString();
7328
+ let { state } = view, changes, i = 1, text = state.toText(input);
7329
+ let byLine = text.lines == state.selection.ranges.length;
7330
+ let linewise = lastLinewiseCopy != null && state.selection.ranges.every((r) => r.empty) && lastLinewiseCopy == text.toString();
7331
7331
  if (linewise) {
7332
7332
  let lastLine = -1;
7333
7333
  changes = state.changeByRange((range) => {
@@ -7335,7 +7335,7 @@ function doPaste(view, input) {
7335
7335
  if (line.from == lastLine)
7336
7336
  return { range };
7337
7337
  lastLine = line.from;
7338
- let insert2 = state.toText((byLine ? text2.line(i++).text : input) + state.lineBreak);
7338
+ let insert2 = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
7339
7339
  return {
7340
7340
  changes: { from: line.from, insert: insert2 },
7341
7341
  range: EditorSelection.cursor(range.from + insert2.length)
@@ -7343,14 +7343,14 @@ function doPaste(view, input) {
7343
7343
  });
7344
7344
  } else if (byLine) {
7345
7345
  changes = state.changeByRange((range) => {
7346
- let line = text2.line(i++);
7346
+ let line = text.line(i++);
7347
7347
  return {
7348
7348
  changes: { from: range.from, to: range.to, insert: line.text },
7349
7349
  range: EditorSelection.cursor(range.from + line.length)
7350
7350
  };
7351
7351
  });
7352
7352
  } else {
7353
- changes = state.replaceSelection(text2);
7353
+ changes = state.replaceSelection(text);
7354
7354
  }
7355
7355
  view.dispatch(changes, {
7356
7356
  userEvent: "input.paste",
@@ -7506,13 +7506,13 @@ handlers.dragend = (view) => {
7506
7506
  view.inputState.draggedContent = null;
7507
7507
  return false;
7508
7508
  };
7509
- function dropText(view, event, text2, direct) {
7510
- if (!text2)
7509
+ function dropText(view, event, text, direct) {
7510
+ if (!text)
7511
7511
  return;
7512
7512
  let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
7513
7513
  let { draggedContent } = view.inputState;
7514
7514
  let del = direct && draggedContent && dragMovesSelection(view, event) ? { from: draggedContent.from, to: draggedContent.to } : null;
7515
- let ins = { from: dropPos, insert: text2 };
7515
+ let ins = { from: dropPos, insert: text };
7516
7516
  let changes = view.state.changes(del ? [del, ins] : ins);
7517
7517
  view.focus();
7518
7518
  view.dispatch({
@@ -7529,26 +7529,26 @@ handlers.drop = (view, event) => {
7529
7529
  return true;
7530
7530
  let files = event.dataTransfer.files;
7531
7531
  if (files && files.length) {
7532
- let text2 = Array(files.length), read = 0;
7532
+ let text = Array(files.length), read = 0;
7533
7533
  let finishFile = () => {
7534
7534
  if (++read == files.length)
7535
- dropText(view, event, text2.filter((s) => s != null).join(view.state.lineBreak), false);
7535
+ dropText(view, event, text.filter((s) => s != null).join(view.state.lineBreak), false);
7536
7536
  };
7537
7537
  for (let i = 0; i < files.length; i++) {
7538
7538
  let reader = new FileReader();
7539
7539
  reader.onerror = finishFile;
7540
7540
  reader.onload = () => {
7541
7541
  if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
7542
- text2[i] = reader.result;
7542
+ text[i] = reader.result;
7543
7543
  finishFile();
7544
7544
  };
7545
7545
  reader.readAsText(files[i]);
7546
7546
  }
7547
7547
  return true;
7548
7548
  } else {
7549
- let text2 = event.dataTransfer.getData("Text");
7550
- if (text2) {
7551
- dropText(view, event, text2, true);
7549
+ let text = event.dataTransfer.getData("Text");
7550
+ if (text) {
7551
+ dropText(view, event, text, true);
7552
7552
  return true;
7553
7553
  }
7554
7554
  }
@@ -7567,15 +7567,15 @@ handlers.paste = (view, event) => {
7567
7567
  return false;
7568
7568
  }
7569
7569
  };
7570
- function captureCopy(view, text2) {
7570
+ function captureCopy(view, text) {
7571
7571
  let parent = view.dom.parentNode;
7572
7572
  if (!parent)
7573
7573
  return;
7574
7574
  let target = parent.appendChild(document.createElement("textarea"));
7575
7575
  target.style.cssText = "position: fixed; left: -10000px; top: 10px";
7576
- target.value = text2;
7576
+ target.value = text;
7577
7577
  target.focus();
7578
- target.selectionEnd = text2.length;
7578
+ target.selectionEnd = text.length;
7579
7579
  target.selectionStart = 0;
7580
7580
  setTimeout(() => {
7581
7581
  target.remove();
@@ -7605,10 +7605,10 @@ function copiedRange(state) {
7605
7605
  }
7606
7606
  let lastLinewiseCopy = null;
7607
7607
  handlers.copy = handlers.cut = (view, event) => {
7608
- let { text: text2, ranges, linewise } = copiedRange(view.state);
7609
- if (!text2 && !linewise)
7608
+ let { text, ranges, linewise } = copiedRange(view.state);
7609
+ if (!text && !linewise)
7610
7610
  return false;
7611
- lastLinewiseCopy = linewise ? text2 : null;
7611
+ lastLinewiseCopy = linewise ? text : null;
7612
7612
  if (event.type == "cut" && !view.state.readOnly)
7613
7613
  view.dispatch({
7614
7614
  changes: ranges,
@@ -7618,10 +7618,10 @@ handlers.copy = handlers.cut = (view, event) => {
7618
7618
  let data = brokenClipboardAPI ? null : event.clipboardData;
7619
7619
  if (data) {
7620
7620
  data.clearData();
7621
- data.setData("text/plain", text2);
7621
+ data.setData("text/plain", text);
7622
7622
  return true;
7623
7623
  } else {
7624
- captureCopy(view, text2);
7624
+ captureCopy(view, text);
7625
7625
  return false;
7626
7626
  }
7627
7627
  };
@@ -9237,8 +9237,8 @@ class DOMReader {
9237
9237
  this.text = "";
9238
9238
  this.lineSeparator = state.facet(EditorState.lineSeparator);
9239
9239
  }
9240
- append(text2) {
9241
- this.text += text2;
9240
+ append(text) {
9241
+ this.text += text;
9242
9242
  }
9243
9243
  lineBreak() {
9244
9244
  this.text += LineBreakPlaceholder;
@@ -9263,20 +9263,20 @@ class DOMReader {
9263
9263
  return this;
9264
9264
  }
9265
9265
  readTextNode(node) {
9266
- let text2 = node.nodeValue;
9266
+ let text = node.nodeValue;
9267
9267
  for (let point of this.points)
9268
9268
  if (point.node == node)
9269
- point.pos = this.text.length + Math.min(point.offset, text2.length);
9269
+ point.pos = this.text.length + Math.min(point.offset, text.length);
9270
9270
  for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
9271
9271
  let nextBreak = -1, breakSize = 1, m;
9272
9272
  if (this.lineSeparator) {
9273
- nextBreak = text2.indexOf(this.lineSeparator, off);
9273
+ nextBreak = text.indexOf(this.lineSeparator, off);
9274
9274
  breakSize = this.lineSeparator.length;
9275
- } else if (m = re.exec(text2)) {
9275
+ } else if (m = re.exec(text)) {
9276
9276
  nextBreak = m.index;
9277
9277
  breakSize = m[0].length;
9278
9278
  }
9279
- this.append(text2.slice(off, nextBreak < 0 ? text2.length : nextBreak));
9279
+ this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
9280
9280
  if (nextBreak < 0)
9281
9281
  break;
9282
9282
  this.lineBreak();
@@ -9420,12 +9420,12 @@ function applyDOMChange(view, domChange) {
9420
9420
  return true;
9421
9421
  if (browser.android && (change.from == sel.from && change.to == sel.to && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 || lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46)))
9422
9422
  return true;
9423
- let text2 = change.insert.toString();
9423
+ let text = change.insert.toString();
9424
9424
  if (view.inputState.composing >= 0)
9425
9425
  view.inputState.composing++;
9426
9426
  let defaultTr;
9427
9427
  let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
9428
- if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to, text2, defaultInsert)))
9428
+ if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to, text, defaultInsert)))
9429
9429
  view.dispatch(defaultInsert());
9430
9430
  return true;
9431
9431
  } else if (newSel && !newSel.main.eq(sel)) {
@@ -12073,8 +12073,8 @@ const lineNumberGutter = /* @__PURE__ */ activeGutters.compute([lineNumberConfig
12073
12073
  return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
12074
12074
  },
12075
12075
  updateSpacer(spacer, update) {
12076
- let max2 = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
12077
- return max2 == spacer.number ? spacer : new NumberMarker(max2);
12076
+ let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
12077
+ return max == spacer.number ? spacer : new NumberMarker(max);
12078
12078
  },
12079
12079
  domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
12080
12080
  }));
@@ -12091,572 +12091,6 @@ function maxLineNumber(lines) {
12091
12091
  last = last * 10 + 9;
12092
12092
  return last;
12093
12093
  }
12094
- class YRange {
12095
- /**
12096
- * @param {Y.RelativePosition} yanchor
12097
- * @param {Y.RelativePosition} yhead
12098
- */
12099
- constructor(yanchor, yhead) {
12100
- this.yanchor = yanchor;
12101
- this.yhead = yhead;
12102
- }
12103
- /**
12104
- * @returns {any}
12105
- */
12106
- toJSON() {
12107
- return {
12108
- yanchor: Y.relativePositionToJSON(this.yanchor),
12109
- yhead: Y.relativePositionToJSON(this.yhead)
12110
- };
12111
- }
12112
- /**
12113
- * @param {any} json
12114
- * @return {YRange}
12115
- */
12116
- static fromJSON(json2) {
12117
- return new YRange(Y.createRelativePositionFromJSON(json2.yanchor), Y.createRelativePositionFromJSON(json2.yhead));
12118
- }
12119
- }
12120
- class YSyncConfig {
12121
- constructor(ytext, awareness) {
12122
- this.ytext = ytext;
12123
- this.awareness = awareness;
12124
- this.undoManager = new Y.UndoManager(ytext);
12125
- }
12126
- /**
12127
- * Helper function to transform an absolute index position to a Yjs-based relative position
12128
- * (https://docs.yjs.dev/api/relative-positions).
12129
- *
12130
- * A relative position can be transformed back to an absolute position even after the document has changed. The position is
12131
- * automatically adapted. This does not require any position transformations. Relative positions are computed based on
12132
- * the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always
12133
- * synced up when using relatve positions.
12134
- *
12135
- * ```js
12136
- * import { ySyncFacet } from 'y-codemirror'
12137
- *
12138
- * ..
12139
- * const ysync = view.state.facet(ySyncFacet)
12140
- * // transform an absolute index position to a ypos
12141
- * const ypos = ysync.getYPos(3)
12142
- * // transform the ypos back to an absolute position
12143
- * ysync.fromYPos(ypos) // => 3
12144
- * ```
12145
- *
12146
- * It cannot be guaranteed that absolute index positions can be synced up between peers.
12147
- * This might lead to undesired behavior when implementing features that require that all peers see the
12148
- * same marked range (e.g. a comment plugin).
12149
- *
12150
- * @param {number} pos
12151
- * @param {number} [assoc]
12152
- */
12153
- toYPos(pos, assoc = 0) {
12154
- return Y.createRelativePositionFromTypeIndex(this.ytext, pos, assoc);
12155
- }
12156
- /**
12157
- * @param {Y.RelativePosition | Object} rpos
12158
- */
12159
- fromYPos(rpos) {
12160
- const pos = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(rpos), this.ytext.doc);
12161
- if (pos == null || pos.type !== this.ytext) {
12162
- throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");
12163
- }
12164
- return {
12165
- pos: pos.index,
12166
- assoc: pos.assoc
12167
- };
12168
- }
12169
- /**
12170
- * @param {cmState.SelectionRange} range
12171
- * @return {YRange}
12172
- */
12173
- toYRange(range) {
12174
- const assoc = range.assoc;
12175
- const yanchor = this.toYPos(range.anchor, assoc);
12176
- const yhead = this.toYPos(range.head, assoc);
12177
- return new YRange(yanchor, yhead);
12178
- }
12179
- /**
12180
- * @param {YRange} yrange
12181
- */
12182
- fromYRange(yrange) {
12183
- const anchor = this.fromYPos(yrange.yanchor);
12184
- const head = this.fromYPos(yrange.yhead);
12185
- if (anchor.pos === head.pos) {
12186
- return EditorSelection.cursor(head.pos, head.assoc);
12187
- }
12188
- return EditorSelection.range(anchor.pos, head.pos);
12189
- }
12190
- }
12191
- const ySyncFacet = Facet.define({
12192
- combine(inputs) {
12193
- return inputs[inputs.length - 1];
12194
- }
12195
- });
12196
- const ySyncAnnotation = Annotation.define();
12197
- class YSyncPluginValue {
12198
- /**
12199
- * @param {cmView.EditorView} view
12200
- */
12201
- constructor(view) {
12202
- this.view = view;
12203
- this.conf = view.state.facet(ySyncFacet);
12204
- this._observer = (event, tr) => {
12205
- if (tr.origin !== this.conf) {
12206
- const delta = event.delta;
12207
- const changes = [];
12208
- let pos = 0;
12209
- for (let i = 0; i < delta.length; i++) {
12210
- const d = delta[i];
12211
- if (d.insert != null) {
12212
- changes.push({ from: pos, to: pos, insert: d.insert });
12213
- } else if (d.delete != null) {
12214
- changes.push({ from: pos, to: pos + d.delete, insert: "" });
12215
- pos += d.delete;
12216
- } else {
12217
- pos += d.retain;
12218
- }
12219
- }
12220
- view.dispatch({ changes, annotations: [ySyncAnnotation.of(this.conf)] });
12221
- }
12222
- };
12223
- this._ytext = this.conf.ytext;
12224
- this._ytext.observe(this._observer);
12225
- }
12226
- /**
12227
- * @param {cmView.ViewUpdate} update
12228
- */
12229
- update(update) {
12230
- if (!update.docChanged || update.transactions.length > 0 && update.transactions[0].annotation(ySyncAnnotation) === this.conf) {
12231
- return;
12232
- }
12233
- const ytext = this.conf.ytext;
12234
- ytext.doc.transact(() => {
12235
- let adj = 0;
12236
- update.changes.iterChanges((fromA, toA, fromB, toB, insert2) => {
12237
- const insertText = insert2.sliceString(0, insert2.length, "\n");
12238
- if (fromA !== toA) {
12239
- ytext.delete(fromA + adj, toA - fromA);
12240
- }
12241
- if (insertText.length > 0) {
12242
- ytext.insert(fromA + adj, insertText);
12243
- }
12244
- adj += insertText.length - (toA - fromA);
12245
- });
12246
- }, this.conf);
12247
- }
12248
- destroy() {
12249
- this._ytext.unobserve(this._observer);
12250
- }
12251
- }
12252
- const ySync = ViewPlugin.fromClass(YSyncPluginValue);
12253
- class Pair {
12254
- /**
12255
- * @param {L} left
12256
- * @param {R} right
12257
- */
12258
- constructor(left, right) {
12259
- this.left = left;
12260
- this.right = right;
12261
- }
12262
- }
12263
- const create = (left, right) => new Pair(left, right);
12264
- const forEach = (arr, f) => arr.forEach((p) => f(p.left, p.right));
12265
- const doc = (
12266
- /** @type {Document} */
12267
- typeof document !== "undefined" ? document : {}
12268
- );
12269
- const createElement = (name2) => doc.createElement(name2);
12270
- const createDocumentFragment = () => doc.createDocumentFragment();
12271
- const createTextNode = (text2) => doc.createTextNode(text2);
12272
- typeof DOMParser !== "undefined" ? new DOMParser() : null;
12273
- const setAttributes = (el, attrs) => {
12274
- forEach(attrs, (key, value) => {
12275
- if (value === false) {
12276
- el.removeAttribute(key);
12277
- } else if (value === true) {
12278
- el.setAttribute(key, "");
12279
- } else {
12280
- el.setAttribute(key, value);
12281
- }
12282
- });
12283
- return el;
12284
- };
12285
- const fragment = (children) => {
12286
- const fragment2 = createDocumentFragment();
12287
- for (let i = 0; i < children.length; i++) {
12288
- appendChild(fragment2, children[i]);
12289
- }
12290
- return fragment2;
12291
- };
12292
- const append = (parent, nodes) => {
12293
- appendChild(parent, fragment(nodes));
12294
- return parent;
12295
- };
12296
- const element = (name2, attrs = [], children = []) => append(setAttributes(createElement(name2), attrs), children);
12297
- const text = createTextNode;
12298
- const appendChild = (parent, child) => parent.appendChild(child);
12299
- doc.ELEMENT_NODE;
12300
- doc.TEXT_NODE;
12301
- doc.CDATA_SECTION_NODE;
12302
- doc.COMMENT_NODE;
12303
- doc.DOCUMENT_NODE;
12304
- doc.DOCUMENT_TYPE_NODE;
12305
- doc.DOCUMENT_FRAGMENT_NODE;
12306
- const min = (a, b) => a < b ? a : b;
12307
- const max = (a, b) => a > b ? a : b;
12308
- const yRemoteSelectionsTheme = EditorView.baseTheme({
12309
- ".cm-ySelection": {},
12310
- ".cm-yLineSelection": {
12311
- padding: 0,
12312
- margin: "0px 2px 0px 4px"
12313
- },
12314
- ".cm-ySelectionCaret": {
12315
- position: "relative",
12316
- borderLeft: "1px solid black",
12317
- borderRight: "1px solid black",
12318
- marginLeft: "-1px",
12319
- marginRight: "-1px",
12320
- boxSizing: "border-box",
12321
- display: "inline"
12322
- },
12323
- ".cm-ySelectionCaretDot": {
12324
- borderRadius: "50%",
12325
- position: "absolute",
12326
- width: ".4em",
12327
- height: ".4em",
12328
- top: "-.2em",
12329
- left: "-.2em",
12330
- backgroundColor: "inherit",
12331
- transition: "transform .3s ease-in-out",
12332
- boxSizing: "border-box"
12333
- },
12334
- ".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot": {
12335
- transformOrigin: "bottom center",
12336
- transform: "scale(0)"
12337
- },
12338
- ".cm-ySelectionInfo": {
12339
- position: "absolute",
12340
- top: "-1.05em",
12341
- left: "-1px",
12342
- fontSize: ".75em",
12343
- fontFamily: "serif",
12344
- fontStyle: "normal",
12345
- fontWeight: "normal",
12346
- lineHeight: "normal",
12347
- userSelect: "none",
12348
- color: "white",
12349
- paddingLeft: "2px",
12350
- paddingRight: "2px",
12351
- zIndex: 101,
12352
- transition: "opacity .3s ease-in-out",
12353
- backgroundColor: "inherit",
12354
- // these should be separate
12355
- opacity: 0,
12356
- transitionDelay: "0s",
12357
- whiteSpace: "nowrap"
12358
- },
12359
- ".cm-ySelectionCaret:hover > .cm-ySelectionInfo": {
12360
- opacity: 1,
12361
- transitionDelay: "0s"
12362
- }
12363
- });
12364
- const yRemoteSelectionsAnnotation = Annotation.define();
12365
- class YRemoteCaretWidget extends WidgetType {
12366
- /**
12367
- * @param {string} color
12368
- * @param {string} name
12369
- */
12370
- constructor(color, name2) {
12371
- super();
12372
- this.color = color;
12373
- this.name = name2;
12374
- }
12375
- toDOM() {
12376
- return (
12377
- /** @type {HTMLElement} */
12378
- element("span", [create("class", "cm-ySelectionCaret"), create("style", `background-color: ${this.color}; border-color: ${this.color}`)], [
12379
- text("⁠"),
12380
- element("div", [
12381
- create("class", "cm-ySelectionCaretDot")
12382
- ]),
12383
- text("⁠"),
12384
- element("div", [
12385
- create("class", "cm-ySelectionInfo")
12386
- ], [
12387
- text(this.name)
12388
- ]),
12389
- text("⁠")
12390
- ])
12391
- );
12392
- }
12393
- eq(widget) {
12394
- return widget.color === this.color;
12395
- }
12396
- compare(widget) {
12397
- return widget.color === this.color;
12398
- }
12399
- updateDOM() {
12400
- return false;
12401
- }
12402
- get estimatedHeight() {
12403
- return -1;
12404
- }
12405
- ignoreEvent() {
12406
- return true;
12407
- }
12408
- }
12409
- class YRemoteSelectionsPluginValue {
12410
- /**
12411
- * @param {cmView.EditorView} view
12412
- */
12413
- constructor(view) {
12414
- this.conf = view.state.facet(ySyncFacet);
12415
- this._listener = ({ added, updated, removed }, s, t2) => {
12416
- const clients = added.concat(updated).concat(removed);
12417
- if (clients.findIndex((id2) => id2 !== this.conf.awareness.doc.clientID) >= 0) {
12418
- view.dispatch({ annotations: [yRemoteSelectionsAnnotation.of([])] });
12419
- }
12420
- };
12421
- this._awareness = this.conf.awareness;
12422
- this._awareness.on("change", this._listener);
12423
- this.decorations = RangeSet.of([]);
12424
- }
12425
- destroy() {
12426
- this._awareness.off("change", this._listener);
12427
- }
12428
- /**
12429
- * @param {cmView.ViewUpdate} update
12430
- */
12431
- update(update) {
12432
- const ytext = this.conf.ytext;
12433
- const ydoc = (
12434
- /** @type {Y.Doc} */
12435
- ytext.doc
12436
- );
12437
- const awareness = this.conf.awareness;
12438
- const decorations2 = [];
12439
- const localAwarenessState = this.conf.awareness.getLocalState();
12440
- if (localAwarenessState != null) {
12441
- const hasFocus = update.view.hasFocus && update.view.dom.ownerDocument.hasFocus();
12442
- const sel = hasFocus ? update.state.selection.main : null;
12443
- const currentAnchor = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.anchor);
12444
- const currentHead = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.head);
12445
- if (sel != null) {
12446
- const anchor = Y.createRelativePositionFromTypeIndex(ytext, sel.anchor);
12447
- const head = Y.createRelativePositionFromTypeIndex(ytext, sel.head);
12448
- if (localAwarenessState.cursor == null || !Y.compareRelativePositions(currentAnchor, anchor) || !Y.compareRelativePositions(currentHead, head)) {
12449
- awareness.setLocalStateField("cursor", {
12450
- anchor,
12451
- head
12452
- });
12453
- }
12454
- } else if (localAwarenessState.cursor != null && hasFocus) {
12455
- awareness.setLocalStateField("cursor", null);
12456
- }
12457
- }
12458
- awareness.getStates().forEach((state, clientid) => {
12459
- if (clientid === awareness.doc.clientID) {
12460
- return;
12461
- }
12462
- const cursor = state.cursor;
12463
- if (cursor == null || cursor.anchor == null || cursor.head == null) {
12464
- return;
12465
- }
12466
- const anchor = Y.createAbsolutePositionFromRelativePosition(cursor.anchor, ydoc);
12467
- const head = Y.createAbsolutePositionFromRelativePosition(cursor.head, ydoc);
12468
- if (anchor == null || head == null || anchor.type !== ytext || head.type !== ytext) {
12469
- return;
12470
- }
12471
- const { color = "#30bced", name: name2 = "Anonymous" } = state.user || {};
12472
- const colorLight = state.user && state.user.colorLight || color + "33";
12473
- const start = min(anchor.index, head.index);
12474
- const end = max(anchor.index, head.index);
12475
- const startLine = update.view.state.doc.lineAt(start);
12476
- const endLine = update.view.state.doc.lineAt(end);
12477
- if (startLine.number === endLine.number) {
12478
- decorations2.push({
12479
- from: start,
12480
- to: end,
12481
- value: Decoration.mark({
12482
- attributes: { style: `background-color: ${colorLight}` },
12483
- class: "cm-ySelection"
12484
- })
12485
- });
12486
- } else {
12487
- decorations2.push({
12488
- from: start,
12489
- to: startLine.from + startLine.length,
12490
- value: Decoration.mark({
12491
- attributes: { style: `background-color: ${colorLight}` },
12492
- class: "cm-ySelection"
12493
- })
12494
- });
12495
- decorations2.push({
12496
- from: endLine.from,
12497
- to: end,
12498
- value: Decoration.mark({
12499
- attributes: { style: `background-color: ${colorLight}` },
12500
- class: "cm-ySelection"
12501
- })
12502
- });
12503
- for (let i = startLine.number + 1; i < endLine.number; i++) {
12504
- const linePos = update.view.state.doc.line(i).from;
12505
- decorations2.push({
12506
- from: linePos,
12507
- to: linePos,
12508
- value: Decoration.line({
12509
- attributes: { style: `background-color: ${colorLight}`, class: "cm-yLineSelection" }
12510
- })
12511
- });
12512
- }
12513
- }
12514
- decorations2.push({
12515
- from: head.index,
12516
- to: head.index,
12517
- value: Decoration.widget({
12518
- side: head.index - anchor.index > 0 ? -1 : 1,
12519
- // the local cursor should be rendered outside the remote selection
12520
- block: false,
12521
- widget: new YRemoteCaretWidget(color, name2)
12522
- })
12523
- });
12524
- });
12525
- this.decorations = Decoration.set(decorations2, true);
12526
- }
12527
- }
12528
- const yRemoteSelections = ViewPlugin.fromClass(YRemoteSelectionsPluginValue, {
12529
- decorations: (v) => v.decorations
12530
- });
12531
- const createMutex = () => {
12532
- let token = true;
12533
- return (f, g) => {
12534
- if (token) {
12535
- token = false;
12536
- try {
12537
- f();
12538
- } finally {
12539
- token = true;
12540
- }
12541
- } else if (g !== void 0) {
12542
- g();
12543
- }
12544
- };
12545
- };
12546
- class YUndoManagerConfig {
12547
- /**
12548
- * @param {Y.UndoManager} undoManager
12549
- */
12550
- constructor(undoManager) {
12551
- this.undoManager = undoManager;
12552
- }
12553
- /**
12554
- * @param {any} origin
12555
- */
12556
- addTrackedOrigin(origin) {
12557
- this.undoManager.addTrackedOrigin(origin);
12558
- }
12559
- /**
12560
- * @param {any} origin
12561
- */
12562
- removeTrackedOrigin(origin) {
12563
- this.undoManager.removeTrackedOrigin(origin);
12564
- }
12565
- /**
12566
- * @return {boolean} Whether a change was undone.
12567
- */
12568
- undo() {
12569
- return this.undoManager.undo() != null;
12570
- }
12571
- /**
12572
- * @return {boolean} Whether a change was redone.
12573
- */
12574
- redo() {
12575
- return this.undoManager.redo() != null;
12576
- }
12577
- }
12578
- const yUndoManagerFacet = Facet.define({
12579
- combine(inputs) {
12580
- return inputs[inputs.length - 1];
12581
- }
12582
- });
12583
- class YUndoManagerPluginValue {
12584
- /**
12585
- * @param {cmView.EditorView} view
12586
- */
12587
- constructor(view) {
12588
- this.view = view;
12589
- this.conf = view.state.facet(yUndoManagerFacet);
12590
- this._undoManager = this.conf.undoManager;
12591
- this.syncConf = view.state.facet(ySyncFacet);
12592
- this._beforeChangeSelection = null;
12593
- this._mux = createMutex();
12594
- this._onStackItemAdded = ({ stackItem, changedParentTypes }) => {
12595
- if (changedParentTypes.has(this.syncConf.ytext) && this._beforeChangeSelection && !stackItem.meta.has(this)) {
12596
- stackItem.meta.set(this, this._beforeChangeSelection);
12597
- }
12598
- };
12599
- this._onStackItemPopped = ({ stackItem }) => {
12600
- const sel = stackItem.meta.get(this);
12601
- if (sel) {
12602
- const selection = this.syncConf.fromYRange(sel);
12603
- view.dispatch(view.state.update({ selection }));
12604
- this._storeSelection();
12605
- }
12606
- };
12607
- this._storeSelection = () => {
12608
- this._beforeChangeSelection = this.syncConf.toYRange(this.view.state.selection.main);
12609
- };
12610
- this._undoManager.on("stack-item-added", this._onStackItemAdded);
12611
- this._undoManager.on("stack-item-popped", this._onStackItemPopped);
12612
- this._undoManager.addTrackedOrigin(this.syncConf);
12613
- }
12614
- /**
12615
- * @param {cmView.ViewUpdate} update
12616
- */
12617
- update(update) {
12618
- if (update.selectionSet && (update.transactions.length === 0 || update.transactions[0].annotation(ySyncAnnotation) !== this.syncConf)) {
12619
- this._storeSelection();
12620
- }
12621
- }
12622
- destroy() {
12623
- this._undoManager.off("stack-item-added", this._onStackItemAdded);
12624
- this._undoManager.off("stack-item-popped", this._onStackItemPopped);
12625
- this._undoManager.removeTrackedOrigin(this.syncConf);
12626
- }
12627
- }
12628
- const yUndoManager = ViewPlugin.fromClass(YUndoManagerPluginValue);
12629
- const undo = ({ state, dispatch }) => state.facet(yUndoManagerFacet).undo() || true;
12630
- const redo = ({ state, dispatch }) => state.facet(yUndoManagerFacet).redo() || true;
12631
- const yCollab = (ytext, awareness, { undoManager = new Y.UndoManager(ytext) } = {}) => {
12632
- const ySyncConfig = new YSyncConfig(ytext, awareness);
12633
- const plugins = [
12634
- ySyncFacet.of(ySyncConfig),
12635
- ySync
12636
- ];
12637
- if (awareness) {
12638
- plugins.push(
12639
- yRemoteSelectionsTheme,
12640
- yRemoteSelections
12641
- );
12642
- }
12643
- if (undoManager !== false) {
12644
- plugins.push(
12645
- yUndoManagerFacet.of(new YUndoManagerConfig(undoManager)),
12646
- yUndoManager,
12647
- EditorView.domEventHandlers({
12648
- beforeinput(e, view) {
12649
- if (e.inputType === "historyUndo")
12650
- return undo(view);
12651
- if (e.inputType === "historyRedo")
12652
- return redo(view);
12653
- return false;
12654
- }
12655
- })
12656
- );
12657
- }
12658
- return plugins;
12659
- };
12660
12094
  const DefaultBufferLength = 1024;
12661
12095
  let nextPropID = 0;
12662
12096
  class Range2 {
@@ -15966,18 +15400,18 @@ class IndentContext {
15966
15400
  textAfterPos(pos, bias = 1) {
15967
15401
  if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
15968
15402
  return "";
15969
- let { text: text2, from } = this.lineAt(pos, bias);
15970
- return text2.slice(pos - from, Math.min(text2.length, pos + 100 - from));
15403
+ let { text, from } = this.lineAt(pos, bias);
15404
+ return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
15971
15405
  }
15972
15406
  /**
15973
15407
  Find the column for the given position.
15974
15408
  */
15975
15409
  column(pos, bias = 1) {
15976
- let { text: text2, from } = this.lineAt(pos, bias);
15977
- let result = this.countColumn(text2, pos - from);
15410
+ let { text, from } = this.lineAt(pos, bias);
15411
+ let result = this.countColumn(text, pos - from);
15978
15412
  let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
15979
15413
  if (override > -1)
15980
- result += override - this.countColumn(text2, text2.search(/\S|$/));
15414
+ result += override - this.countColumn(text, text.search(/\S|$/));
15981
15415
  return result;
15982
15416
  }
15983
15417
  /**
@@ -15991,14 +15425,14 @@ class IndentContext {
15991
15425
  Find the indentation column of the line at the given point.
15992
15426
  */
15993
15427
  lineIndent(pos, bias = 1) {
15994
- let { text: text2, from } = this.lineAt(pos, bias);
15428
+ let { text, from } = this.lineAt(pos, bias);
15995
15429
  let override = this.options.overrideIndentation;
15996
15430
  if (override) {
15997
15431
  let overriden = override(from);
15998
15432
  if (overriden > -1)
15999
15433
  return overriden;
16000
15434
  }
16001
- return this.countColumn(text2, text2.search(/\S|$/));
15435
+ return this.countColumn(text, text.search(/\S|$/));
16002
15436
  }
16003
15437
  /**
16004
15438
  Returns the [simulated line
@@ -16480,12 +15914,12 @@ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, b
16480
15914
  let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
16481
15915
  let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
16482
15916
  for (let distance = 0; !iter.next().done && distance <= maxScanDistance; ) {
16483
- let text2 = iter.value;
15917
+ let text = iter.value;
16484
15918
  if (dir < 0)
16485
- distance += text2.length;
15919
+ distance += text.length;
16486
15920
  let basePos = pos + distance * dir;
16487
- for (let pos2 = dir > 0 ? 0 : text2.length - 1, end = dir > 0 ? text2.length : -1; pos2 != end; pos2 += dir) {
16488
- let found = brackets.indexOf(text2[pos2]);
15921
+ for (let pos2 = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos2 != end; pos2 += dir) {
15922
+ let found = brackets.indexOf(text[pos2]);
16489
15923
  if (found < 0 || tree.resolveInner(basePos + pos2, 1).type != tokenType)
16490
15924
  continue;
16491
15925
  if (found % 2 == 0 == dir > 0) {
@@ -16497,7 +15931,7 @@ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, b
16497
15931
  }
16498
15932
  }
16499
15933
  if (dir > 0)
16500
- distance += text2.length;
15934
+ distance += text.length;
16501
15935
  }
16502
15936
  return iter.done ? { start: startToken, matched: false } : null;
16503
15937
  }
@@ -16971,25 +16405,25 @@ function rgbToHSL(r, g, b) {
16971
16405
  const redPercent = r / 255;
16972
16406
  const greenPercent = g / 255;
16973
16407
  const bluePercent = b / 255;
16974
- const min2 = Math.min(redPercent, greenPercent, bluePercent);
16975
- const max2 = Math.max(redPercent, greenPercent, bluePercent);
16976
- const luminance = (max2 + min2) / 2;
16977
- if (max2 === min2) {
16408
+ const min = Math.min(redPercent, greenPercent, bluePercent);
16409
+ const max = Math.max(redPercent, greenPercent, bluePercent);
16410
+ const luminance = (max + min) / 2;
16411
+ if (max === min) {
16978
16412
  return [0, 0, luminance];
16979
16413
  }
16980
16414
  let saturation;
16981
16415
  if (luminance <= 0.5) {
16982
- saturation = (max2 - min2) / (max2 + min2);
16416
+ saturation = (max - min) / (max + min);
16983
16417
  } else {
16984
- saturation = (max2 - min2) / (2 - max2 - min2);
16418
+ saturation = (max - min) / (2 - max - min);
16985
16419
  }
16986
16420
  let hue;
16987
- if (max2 === redPercent) {
16988
- hue = (greenPercent - bluePercent) / (max2 - min2);
16989
- } else if (greenPercent === max2) {
16990
- hue = 2 + (bluePercent - redPercent) / (max2 - min2);
16421
+ if (max === redPercent) {
16422
+ hue = (greenPercent - bluePercent) / (max - min);
16423
+ } else if (greenPercent === max) {
16424
+ hue = 2 + (bluePercent - redPercent) / (max - min);
16991
16425
  } else {
16992
- hue = 4 + (redPercent - greenPercent) / (max2 - min2);
16426
+ hue = 4 + (redPercent - greenPercent) / (max - min);
16993
16427
  }
16994
16428
  hue = Math.round(hue * 60);
16995
16429
  while (hue < 0) {
@@ -17202,14 +16636,14 @@ function ensureAnchor(expr, start) {
17202
16636
  return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a2 = expr.flags) !== null && _a2 !== void 0 ? _a2 : expr.ignoreCase ? "i" : "");
17203
16637
  }
17204
16638
  const pickedCompletion = /* @__PURE__ */ Annotation.define();
17205
- function insertCompletionText(state, text2, from, to) {
16639
+ function insertCompletionText(state, text, from, to) {
17206
16640
  let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
17207
16641
  return Object.assign(Object.assign({}, state.changeByRange((range) => {
17208
16642
  if (range != main && from != to && state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
17209
16643
  return { range };
17210
16644
  return {
17211
- changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: text2 },
17212
- range: EditorSelection.cursor(range.from + fromOff + text2.length)
16645
+ changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: text },
16646
+ range: EditorSelection.cursor(range.from + fromOff + text.length)
17213
16647
  };
17214
16648
  })), { scrollIntoView: true, userEvent: "input.complete" });
17215
16649
  }
@@ -17454,17 +16888,17 @@ function optionContent(config2) {
17454
16888
  });
17455
16889
  return content2.sort((a, b) => a.position - b.position).map((a) => a.render);
17456
16890
  }
17457
- function rangeAroundSelected(total, selected, max2) {
17458
- if (total <= max2)
16891
+ function rangeAroundSelected(total, selected, max) {
16892
+ if (total <= max)
17459
16893
  return { from: 0, to: total };
17460
16894
  if (selected < 0)
17461
16895
  selected = 0;
17462
16896
  if (selected <= total >> 1) {
17463
- let off2 = Math.floor(selected / max2);
17464
- return { from: off2 * max2, to: (off2 + 1) * max2 };
16897
+ let off2 = Math.floor(selected / max);
16898
+ return { from: off2 * max, to: (off2 + 1) * max };
17465
16899
  }
17466
- let off = Math.floor((total - selected) / max2);
17467
- return { from: total - (off + 1) * max2, to: total - off * max2 };
16900
+ let off = Math.floor((total - selected) / max);
16901
+ return { from: total - (off + 1) * max, to: total - off * max };
17468
16902
  }
17469
16903
  class CompletionTooltip {
17470
16904
  constructor(view, stateField, applyCompletion2) {
@@ -17692,9 +17126,9 @@ class CompletionTooltip {
17692
17126
  function completionTooltip(stateField, applyCompletion2) {
17693
17127
  return (view) => new CompletionTooltip(view, stateField, applyCompletion2);
17694
17128
  }
17695
- function scrollIntoView(container, element2) {
17129
+ function scrollIntoView(container, element) {
17696
17130
  let parent = container.getBoundingClientRect();
17697
- let self = element2.getBoundingClientRect();
17131
+ let self = element.getBoundingClientRect();
17698
17132
  let scaleY = parent.height / container.offsetHeight;
17699
17133
  if (self.top < parent.top)
17700
17134
  container.scrollTop -= (parent.top - self.top) / scaleY;
@@ -17986,8 +17420,8 @@ class ActiveResult extends ActiveSource {
17986
17420
  function checkValid(validFor, state, from, to) {
17987
17421
  if (!validFor)
17988
17422
  return false;
17989
- let text2 = state.sliceDoc(from, to);
17990
- return typeof validFor == "function" ? validFor(text2, from, to, state) : ensureAnchor(validFor, true).test(text2);
17423
+ let text = state.sliceDoc(from, to);
17424
+ return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
17991
17425
  }
17992
17426
  const setActiveEffect = /* @__PURE__ */ StateEffect.define({
17993
17427
  map(sources, mapping) {
@@ -18362,21 +17796,21 @@ class Snippet {
18362
17796
  this.fieldPositions = fieldPositions;
18363
17797
  }
18364
17798
  instantiate(state, pos) {
18365
- let text2 = [], lineStart = [pos];
17799
+ let text = [], lineStart = [pos];
18366
17800
  let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
18367
17801
  for (let line of this.lines) {
18368
- if (text2.length) {
17802
+ if (text.length) {
18369
17803
  let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
18370
17804
  for (let i = 0; i < tabs; i++)
18371
17805
  indent += state.facet(indentUnit);
18372
17806
  lineStart.push(pos + indent.length - tabs);
18373
17807
  line = indent + line.slice(tabs);
18374
17808
  }
18375
- text2.push(line);
17809
+ text.push(line);
18376
17810
  pos += line.length + 1;
18377
17811
  }
18378
17812
  let ranges = this.fieldPositions.map((pos2) => new FieldRange(pos2.field, lineStart[pos2.line] + pos2.from, lineStart[pos2.line] + pos2.to));
18379
- return { text: text2, ranges };
17813
+ return { text, ranges };
18380
17814
  }
18381
17815
  static parse(template) {
18382
17816
  let fields = [];
@@ -18476,9 +17910,9 @@ function fieldSelection(ranges, field) {
18476
17910
  function snippet(template) {
18477
17911
  let snippet2 = Snippet.parse(template);
18478
17912
  return (editor, completion, from, to) => {
18479
- let { text: text2, ranges } = snippet2.instantiate(editor.state, from);
17913
+ let { text, ranges } = snippet2.instantiate(editor.state, from);
18480
17914
  let spec = {
18481
- changes: { from, to, insert: Text.of(text2) },
17915
+ changes: { from, to, insert: Text.of(text) },
18482
17916
  scrollIntoView: true,
18483
17917
  annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : void 0
18484
17918
  };
@@ -22339,16 +21773,16 @@ function findOpenTag(node) {
22339
21773
  node = node.parent;
22340
21774
  }
22341
21775
  }
22342
- function elementName$1(doc2, tree, max2 = doc2.length) {
21776
+ function elementName$1(doc2, tree, max = doc2.length) {
22343
21777
  for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
22344
21778
  if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" || ch.name == "JSXMemberExpression")
22345
- return doc2.sliceString(ch.from, Math.min(ch.to, max2));
21779
+ return doc2.sliceString(ch.from, Math.min(ch.to, max));
22346
21780
  }
22347
21781
  return "";
22348
21782
  }
22349
21783
  const android = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent);
22350
- const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text2, defaultInsert) => {
22351
- if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to || text2 != ">" && text2 != "/" || !javascriptLanguage.isActiveAt(view.state, from, -1))
21784
+ const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
21785
+ if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to || text != ">" && text != "/" || !javascriptLanguage.isActiveAt(view.state, from, -1))
22352
21786
  return false;
22353
21787
  let base2 = defaultInsert(), { state } = base2;
22354
21788
  let closeTags = state.changeByRange((range) => {
@@ -22356,17 +21790,17 @@ const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from,
22356
21790
  let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name2;
22357
21791
  if (around.name == "JSXStartTag")
22358
21792
  around = around.parent;
22359
- if (state.doc.sliceString(head - 1, head) != text2 || around.name == "JSXAttributeValue" && around.to > head)
21793
+ if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head)
22360
21794
  ;
22361
- else if (text2 == ">" && around.name == "JSXFragmentTag") {
21795
+ else if (text == ">" && around.name == "JSXFragmentTag") {
22362
21796
  return { range, changes: { from: head, insert: `</>` } };
22363
- } else if (text2 == "/" && around.name == "JSXStartCloseTag") {
21797
+ } else if (text == "/" && around.name == "JSXStartCloseTag") {
22364
21798
  let empty = around.parent, base3 = empty.parent;
22365
21799
  if (base3 && empty.from == head - 2 && ((name2 = elementName$1(state.doc, base3.firstChild, head)) || ((_a2 = base3.firstChild) === null || _a2 === void 0 ? void 0 : _a2.name) == "JSXFragmentTag")) {
22366
21800
  let insert2 = `${name2}>`;
22367
21801
  return { range: EditorSelection.cursor(head + insert2.length, -1), changes: { from: head, insert: insert2 } };
22368
21802
  }
22369
- } else if (text2 == ">") {
21803
+ } else if (text == ">") {
22370
21804
  let openTag = findOpenTag(around);
22371
21805
  if (openTag && openTag.name == "JSXOpenTag" && !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) && (name2 = elementName$1(state.doc, openTag, head)))
22372
21806
  return { range, changes: { from: head, insert: `</${name2}>` } };
@@ -22819,12 +22253,12 @@ class Schema {
22819
22253
  }
22820
22254
  }
22821
22255
  Schema.default = /* @__PURE__ */ new Schema();
22822
- function elementName(doc2, tree, max2 = doc2.length) {
22256
+ function elementName(doc2, tree, max = doc2.length) {
22823
22257
  if (!tree)
22824
22258
  return "";
22825
22259
  let tag = tree.firstChild;
22826
22260
  let name2 = tag && tag.getChild("TagName");
22827
- return name2 ? doc2.sliceString(name2.from, Math.min(name2.to, max2)) : "";
22261
+ return name2 ? doc2.sliceString(name2.from, Math.min(name2.to, max)) : "";
22828
22262
  }
22829
22263
  function findParentElement(tree, skip = false) {
22830
22264
  for (; tree; tree = tree.parent)
@@ -23066,23 +22500,23 @@ function html(config2 = {}) {
23066
22500
  ]);
23067
22501
  }
23068
22502
  const selfClosers = /* @__PURE__ */ new Set(/* @__PURE__ */ "area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));
23069
- const autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text2, insertTransaction) => {
23070
- if (view.composing || view.state.readOnly || from != to || text2 != ">" && text2 != "/" || !htmlLanguage.isActiveAt(view.state, from, -1))
22503
+ const autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
22504
+ if (view.composing || view.state.readOnly || from != to || text != ">" && text != "/" || !htmlLanguage.isActiveAt(view.state, from, -1))
23071
22505
  return false;
23072
22506
  let base2 = insertTransaction(), { state } = base2;
23073
22507
  let closeTags = state.changeByRange((range) => {
23074
22508
  var _a2, _b, _c;
23075
- let didType = state.doc.sliceString(range.from - 1, range.to) == text2;
22509
+ let didType = state.doc.sliceString(range.from - 1, range.to) == text;
23076
22510
  let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name2;
23077
22511
  if (around.name == "TagName" || around.name == "StartTag")
23078
22512
  around = around.parent;
23079
- if (didType && text2 == ">" && around.name == "OpenTag") {
22513
+ if (didType && text == ">" && around.name == "OpenTag") {
23080
22514
  if (((_b = (_a2 = around.parent) === null || _a2 === void 0 ? void 0 : _a2.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" && (name2 = elementName(state.doc, around.parent, head)) && !selfClosers.has(name2)) {
23081
22515
  let to2 = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
23082
22516
  let insert2 = `</${name2}>`;
23083
22517
  return { range, changes: { from: head, to: to2, insert: insert2 } };
23084
22518
  }
23085
- } else if (didType && text2 == "/" && around.name == "IncompleteCloseTag") {
22519
+ } else if (didType && text == "/" && around.name == "IncompleteCloseTag") {
23086
22520
  let base3 = around.parent;
23087
22521
  if (around.from == head - 2 && ((_c = base3.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" && (name2 = elementName(state.doc, base3, head)) && !selfClosers.has(name2)) {
23088
22522
  let to2 = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
@@ -23641,87 +23075,87 @@ var createTheme = (_ref) => {
23641
23075
  const customTheme = createTheme({
23642
23076
  theme: "light",
23643
23077
  settings: {
23644
- background: "var(--theme-background-2, var(--default-theme-background-2))",
23645
- foreground: "var(--theme-color-1, var(--default-theme-color-1))",
23646
- caret: "var(--theme-color-1, var(--default-theme-color-1))",
23078
+ background: "var(--scalar-background-2)",
23079
+ foreground: "var(--scalar-color-1)",
23080
+ caret: "var(--scalar-color-1)",
23647
23081
  // Selection likely needs a hardcoded color due to it not accepting variables
23648
23082
  selection: "rgba(151, 183, 205, 0.2)",
23649
23083
  selectionMatch: "#e3dcce",
23650
- gutterBackground: "var(--theme-background-2, var(--default-theme-background-2))",
23651
- gutterForeground: "var(--theme-color-3, var(--default-theme-color-3))",
23084
+ gutterBackground: "var(--scalar-background-2)",
23085
+ gutterForeground: "var(--scalar-color-3)",
23652
23086
  gutterBorder: "transparent",
23653
- lineHighlight: "var(--theme-background-3, var(--default-theme-background-3))",
23654
- fontFamily: "var(--theme-font-code, var(--default-theme-font-code))"
23087
+ lineHighlight: "var(--scalar-background-3)",
23088
+ fontFamily: "var(--scalar-font-code)"
23655
23089
  },
23656
23090
  styles: [
23657
23091
  {
23658
23092
  tag: [tags$1.standard(tags$1.tagName), tags$1.tagName],
23659
- color: "var(--theme-color-purple, var(--default-theme-color-purple))"
23093
+ color: "var(--scalar-color-purple)"
23660
23094
  },
23661
23095
  {
23662
23096
  tag: [tags$1.comment],
23663
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23097
+ color: "var(--scalar-color-3)"
23664
23098
  },
23665
23099
  {
23666
23100
  tag: [tags$1.className],
23667
- color: "var(--theme-color-orange, var(--default-theme-color-orange))"
23101
+ color: "var(--scalar-color-orange)"
23668
23102
  },
23669
23103
  {
23670
23104
  tag: [tags$1.variableName, tags$1.propertyName, tags$1.attributeName],
23671
- color: "var(--theme-color-1, var(--default-theme-color-1))"
23105
+ color: "var(--scalar-color-1)"
23672
23106
  },
23673
23107
  {
23674
23108
  tag: [tags$1.operator],
23675
- color: "var(--theme-color-2, var(--default-theme-color-2))"
23109
+ color: "var(--scalar-color-2)"
23676
23110
  },
23677
23111
  {
23678
23112
  tag: [tags$1.keyword, tags$1.typeName, tags$1.typeOperator],
23679
- color: "var(--theme-color-green, var(--default-theme-color-green))"
23113
+ color: "var(--scalar-color-green)"
23680
23114
  },
23681
23115
  {
23682
23116
  tag: [tags$1.string],
23683
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
23117
+ color: "var(--scalar-color-blue)"
23684
23118
  },
23685
23119
  {
23686
23120
  tag: [tags$1.bracket, tags$1.regexp, tags$1.meta],
23687
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23121
+ color: "var(--scalar-color-3)"
23688
23122
  },
23689
23123
  {
23690
23124
  tag: [tags$1.number],
23691
- color: "var(--theme-color-blue, var(--default-theme-color-blue))"
23125
+ color: "var(--scalar-color-blue)"
23692
23126
  },
23693
23127
  {
23694
23128
  tag: [tags$1.name, tags$1.quote],
23695
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23129
+ color: "var(--scalar-color-3)"
23696
23130
  },
23697
23131
  {
23698
23132
  tag: [tags$1.heading],
23699
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23133
+ color: "var(--scalar-color-3)",
23700
23134
  fontWeight: "bold"
23701
23135
  },
23702
23136
  {
23703
23137
  tag: [tags$1.emphasis],
23704
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23138
+ color: "var(--scalar-color-3)",
23705
23139
  fontStyle: "italic"
23706
23140
  },
23707
23141
  {
23708
23142
  tag: [tags$1.deleted],
23709
- color: "var(--theme-color-3, var(--default-theme-color-3))",
23143
+ color: "var(--scalar-color-3)",
23710
23144
  backgroundColor: "transparent"
23711
23145
  },
23712
23146
  {
23713
23147
  tag: [tags$1.atom, tags$1.bool, tags$1.special(tags$1.variableName)],
23714
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23148
+ color: "var(--scalar-color-3)"
23715
23149
  },
23716
23150
  {
23717
23151
  tag: [tags$1.url, tags$1.escape, tags$1.regexp, tags$1.link],
23718
- color: "var(--theme-color-1, var(--default-theme-color-1))"
23152
+ color: "var(--scalar-color-1)"
23719
23153
  },
23720
23154
  { tag: tags$1.link, textDecoration: "underline" },
23721
23155
  { tag: tags$1.strikethrough, textDecoration: "line-through" },
23722
23156
  {
23723
23157
  tag: tags$1.invalid,
23724
- color: "var(--theme-color-3, var(--default-theme-color-3))"
23158
+ color: "var(--scalar-color-3)"
23725
23159
  }
23726
23160
  ]
23727
23161
  });
@@ -24020,7 +23454,7 @@ const _export_sfc = (sfc, props) => {
24020
23454
  }
24021
23455
  return target;
24022
23456
  };
24023
- const CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-88edf4c8"]]);
23457
+ const CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-74ed365a"]]);
24024
23458
  export {
24025
23459
  CodeMirror,
24026
23460
  colorPicker,