@aiao/code-editor 0.0.8 → 0.0.9

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.
Files changed (27) hide show
  1. package/dist/{index-qH2lMs0G.js → index-4oLq9F9B.js} +4 -4
  2. package/dist/{index-CpRVx97-.js → index-9NH8hlZ-.js} +2 -2
  3. package/dist/{index-DEB5VK0f.js → index-BFXNCCbG.js} +23 -22
  4. package/dist/{index-D0BZOY-S.js → index-BLHYcXXK.js} +4 -4
  5. package/dist/{index-Bg1KDWyt.js → index-BQU3Rb2C.js} +3 -3
  6. package/dist/{index-CrbQBmWq.js → index-Bg18ePld.js} +2 -2
  7. package/dist/{index-D0svJS59.js → index-Bp5lqnbN.js} +3 -3
  8. package/dist/{index-srIksFxX.js → index-Bqzq8A1N.js} +2 -2
  9. package/dist/{index-Dy-OpkyQ.js → index-Bx-s4g99.js} +2 -2
  10. package/dist/{index-C71CZfUx.js → index-BxX25QmV.js} +19 -18
  11. package/dist/{index-Ds4AioqO.js → index-CFCzgc33.js} +3 -3
  12. package/dist/{index-D93XVMi1.js → index-CL7JTU9M.js} +3 -3
  13. package/dist/{index-DIaXGPFp.js → index-CZGsg2Zk.js} +73 -64
  14. package/dist/{index-ZJkjD9tT.js → index-CipmEceX.js} +4 -4
  15. package/dist/{index-BuVm7ZG6.js → index-Cv4vvpa2.js} +1 -1
  16. package/dist/index-D4hhdPbZ.js +6153 -0
  17. package/dist/{index-CqvQj6d-.js → index-DhNQ8g9I.js} +3 -3
  18. package/dist/{index-BNuasEBW.js → index-Djp53tAP.js} +2 -2
  19. package/dist/{index-CQ6JWNwi.js → index-KlsAFhIj.js} +3 -3
  20. package/dist/{index-BMiCCEB1.js → index-OntZqtu6.js} +2 -2
  21. package/dist/{index-CzovO10m.js → index-PGnZjMCR.js} +3 -3
  22. package/dist/{index-BvS1cnHq.js → index-TyYoYgss.js} +3 -3
  23. package/dist/{index-Dp8osI_J.js → index-oMSPmlXA.js} +2 -2
  24. package/dist/{index-C44L0DmY.js → index-rQC6Gbk0.js} +2 -2
  25. package/dist/index.js +11 -11
  26. package/package.json +4 -1
  27. package/dist/index-Dyi9rNIT.js +0 -391
@@ -1,6 +1,6 @@
1
- import { L as v, E as i, C as _ } from "./index-BuVm7ZG6.js";
2
- import { s as W, t as e, a as g, L as x, f as p, i as U, d as V, c as E } from "./index-DIaXGPFp.js";
3
- import { defineCSSCompletionSource as N } from "./index-Dp8osI_J.js";
1
+ import { L as v, E as i, C as _ } from "./index-Cv4vvpa2.js";
2
+ import { s as W, t as e, a as g, L as x, f as p, i as U, d as V, c as E } from "./index-CZGsg2Zk.js";
3
+ import { defineCSSCompletionSource as N } from "./index-oMSPmlXA.js";
4
4
  const j = 168, X = 169, C = 170, I = 1, D = 2, w = 3, L = 171, F = 172, Y = 4, z = 173, K = 5, A = 174, T = 175, Z = 176, s = 177, G = 6, q = 7, B = 8, H = 9, c = 0, R = [
5
5
  9,
6
6
  10,
@@ -1,5 +1,5 @@
1
- import { L as r } from "./index-BuVm7ZG6.js";
2
- import { s as e, t as O, a as s, L as X, i as l, f as Y, c as $, h as S, B as o, d as t } from "./index-DIaXGPFp.js";
1
+ import { L as r } from "./index-Cv4vvpa2.js";
2
+ import { s as e, t as O, a as s, L as X, i as l, f as Y, c as $, h as S, B as o, d as t } from "./index-CZGsg2Zk.js";
3
3
  const Z = e({
4
4
  null: O.null,
5
5
  instanceof: O.operatorKeyword,
@@ -1,6 +1,6 @@
1
- import { L as re, a as ae, i as ne, f as ie, s as se, c as oe, t as i, b as le } from "./index-DIaXGPFp.js";
2
- import { L as ce, E as de } from "./index-BuVm7ZG6.js";
3
- import { i as me, c as ue } from "./index-Dyi9rNIT.js";
1
+ import { L as re, a as ae, i as ne, f as ie, s as se, c as oe, t as i, b as le } from "./index-CZGsg2Zk.js";
2
+ import { L as ce, E as de } from "./index-Cv4vvpa2.js";
3
+ import { i as me, c as ue } from "./index-D4hhdPbZ.js";
4
4
  const pe = 36, X = 1, fe = 2, b = 3, C = 4, _e = 5, ge = 6, he = 7, ye = 8, be = 9, ve = 10, ke = 11, xe = 12, Oe = 13, we = 14, Qe = 15, Ce = 16, Se = 17, I = 18, qe = 19, E = 20, W = 21, R = 22, Pe = 23, Te = 24;
5
5
  function q(t) {
6
6
  return t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 48 && t <= 57;
@@ -1,5 +1,5 @@
1
- import { L as G, E as A, C as N } from "./index-BuVm7ZG6.js";
2
- import { s as I, t as p, E as Y, a as j, L as U, b as k, e as Z, i as B, f as D, g as M } from "./index-DIaXGPFp.js";
1
+ import { L as G, E as A, C as N } from "./index-Cv4vvpa2.js";
2
+ import { s as I, t as p, E as Y, a as j, L as U, b as k, e as Z, i as B, f as D, g as M } from "./index-CZGsg2Zk.js";
3
3
  const h = 1, F = 2, L = 3, K = 4, H = 5, J = 36, ee = 37, te = 38, Oe = 11, oe = 13;
4
4
  function re(e) {
5
5
  return e == 45 || e == 46 || e == 58 || e >= 65 && e <= 90 || e == 95 || e >= 97 && e <= 122 || e >= 161;
@@ -1,6 +1,6 @@
1
- import { L as V, E as X } from "./index-BuVm7ZG6.js";
2
- import { s as d, t as $, a as Z, L as R, p as s, i as t, f as y, c, h as U, d as l } from "./index-DIaXGPFp.js";
3
- import { html as w } from "./index-qH2lMs0G.js";
1
+ import { L as V, E as X } from "./index-Cv4vvpa2.js";
2
+ import { s as d, t as $, a as Z, L as R, p as s, i as t, f as y, c, h as U, d as l } from "./index-CZGsg2Zk.js";
3
+ import { html as w } from "./index-4oLq9F9B.js";
4
4
  const W = 1, p = 2, q = 275, u = 3, b = 276, _ = 277, f = 278, m = 4, k = 5, G = 6, x = 7, n = 8, h = 9, v = 10, g = 11, j = 12, E = 13, I = 14, N = 15, L = 16, F = 17, C = 18, H = 19, A = 20, K = 21, D = 22, B = 23, M = 24, J = 25, OO = 26, $O = 27, QO = 28, iO = 29, aO = 30, TO = 31, PO = 32, XO = 33, SO = 34, cO = 35, eO = 36, oO = 37, _O = 38, nO = 39, zO = 40, rO = 41, YO = 42, VO = 43, dO = 44, ZO = 45, RO = 46, sO = 47, tO = 48, yO = 49, UO = 50, lO = 51, wO = 52, WO = 53, pO = 54, qO = 55, uO = 56, bO = 57, fO = 58, mO = 59, kO = 60, GO = 61, xO = 62, e = 63, hO = 64, vO = 65, gO = 66, jO = {
5
5
  abstract: m,
6
6
  and: k,
@@ -1,6 +1,6 @@
1
- import { L as D, E as h, C as L } from "./index-BuVm7ZG6.js";
2
- import { s as H, t as n, a as B, L as K, b as M, i as OO, f as eO, h as f, d as iO, N as aO, I as nO } from "./index-DIaXGPFp.js";
3
- import { i as rO, c as QO, s as d } from "./index-Dyi9rNIT.js";
1
+ import { L as D, E as h, C as L } from "./index-Cv4vvpa2.js";
2
+ import { s as H, t as n, a as B, L as K, b as M, i as OO, f as eO, h as f, d as iO, N as aO, I as nO } from "./index-CZGsg2Zk.js";
3
+ import { i as rO, c as QO, s as d } from "./index-D4hhdPbZ.js";
4
4
  const tO = 1, Z = 194, j = 195, oO = 196, x = 197, dO = 198, sO = 199, lO = 200, TO = 2, E = 3, u = 201, SO = 24, pO = 25, qO = 49, gO = 50, PO = 55, mO = 56, $O = 57, hO = 59, cO = 60, fO = 61, XO = 62, yO = 63, zO = 65, WO = 238, vO = 71, RO = 241, kO = 242, _O = 243, xO = 244, uO = 245, UO = 246, bO = 247, VO = 248, Y = 72, GO = 249, wO = 250, ZO = 251, jO = 252, EO = 253, YO = 254, FO = 255, CO = 256, JO = 73, AO = 77, NO = 263, IO = 112, DO = 130, LO = 151, HO = 152, BO = 155, p = 10, q = 13, k = 32, c = 9, _ = 35, KO = 40, MO = 46, R = 123, U = 125, F = 39, C = 34, b = 92, Oe = 111, ee = 120, ie = 78, ae = 117, ne = 85, re = /* @__PURE__ */ new Set([
5
5
  pO,
6
6
  qO,
@@ -1,5 +1,5 @@
1
- import { L as w, E as p, a as Y } from "./index-BuVm7ZG6.js";
2
- import { s as x, t as r, a as q, L as j, b as G, i as R, f as T, c as E, d as _, N as C, I as U } from "./index-DIaXGPFp.js";
1
+ import { L as w, E as p, a as Y } from "./index-Cv4vvpa2.js";
2
+ import { s as x, t as r, a as q, L as j, b as G, i as R, f as T, c as E, d as _, N as C, I as U } from "./index-CZGsg2Zk.js";
3
3
  const V = 122, g = 1, Z = 123, W = 124, b = 2, N = 125, I = 3, F = 4, X = [
4
4
  9,
5
5
  10,
@@ -1,5 +1,5 @@
1
- import { L as Z, E as t } from "./index-BuVm7ZG6.js";
2
- import { s as o, t as Q, a as s, L as n, i as x, f as V, c as a, h as S, B as c, d as T } from "./index-DIaXGPFp.js";
1
+ import { L as Z, E as t } from "./index-Cv4vvpa2.js";
2
+ import { s as o, t as Q, a as s, L as n, i as x, f as V, c as a, h as S, B as c, d as T } from "./index-CZGsg2Zk.js";
3
3
  const r = 1, j = 2, l = 3, z = 82, f = 76, u = 117, W = 85, w = 97, q = 122, d = 65, g = 90, _ = 95, i = 48, Y = 34, m = 40, P = 41, k = 32, U = 62, R = new t((O) => {
4
4
  if (O.next == f || O.next == W ? O.advance() : O.next == u && (O.advance(), O.next == i + 8 && O.advance()), O.next != z || (O.advance(), O.next != Y)) return;
5
5
  O.advance();
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { Q as S, a3 as r, Y as t, a1 as L, a0 as o, a6 as e, X as p, a5 as P, Z as Q, V as T, U as X, a7 as i, _ as J, a2 as M, $ as U, a4 as c } from "./index-DIaXGPFp.js";
1
+ import { a1 as S, ac as r, a5 as t, aa as L, a9 as e, af as o, a4 as p, ae as P, a6 as T, a3 as c, a2 as i, ag as J, a7 as M, ab as Q, a8 as X, ad as d } from "./index-CZGsg2Zk.js";
2
2
  export {
3
3
  S as CSS,
4
4
  r as HTML,
5
5
  t as JSON,
6
6
  L as JSX,
7
- o as JavaScript,
8
- e as Markdown,
7
+ e as JavaScript,
8
+ o as Markdown,
9
9
  p as PostgreSQL,
10
10
  P as Python,
11
- Q as SCSS,
12
- T as SQL,
13
- X as SQLite,
14
- i as SUPPORT_LANGUAGES,
15
- J as Sass,
16
- M as TSX,
17
- U as TypeScript,
18
- c as XML
11
+ T as SCSS,
12
+ c as SQL,
13
+ i as SQLite,
14
+ J as SUPPORT_LANGUAGES,
15
+ M as Sass,
16
+ Q as TSX,
17
+ X as TypeScript,
18
+ d as XML
19
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiao/code-editor",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -18,6 +18,9 @@
18
18
  "dist",
19
19
  "!**/*.tsbuildinfo"
20
20
  ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
21
24
  "dependencies": {
22
25
  "@codemirror/lang-css": "^6.3.1",
23
26
  "@codemirror/lang-javascript": "^6.2.4",
@@ -1,391 +0,0 @@
1
- import { b as E, C as T, F as L, G as A, S as x, H as D, o as O, E as w, w as P, e as k, J as g, q as M, K as R, M as v, W as B, R as W } from "./index-DIaXGPFp.js";
2
- class te {
3
- /**
4
- Create a new completion context. (Mostly useful for testing
5
- completion sources—in the editor, the extension will create
6
- these for you.)
7
- */
8
- constructor(t, e, n, i) {
9
- this.state = t, this.pos = e, this.explicit = n, this.view = i, this.abortListeners = [], this.abortOnDocChange = !1;
10
- }
11
- /**
12
- Get the extent, content, and (if there is a token) type of the
13
- token before `this.pos`.
14
- */
15
- tokenBefore(t) {
16
- let e = E(this.state).resolveInner(this.pos, -1);
17
- for (; e && t.indexOf(e.name) < 0; )
18
- e = e.parent;
19
- return e ? {
20
- from: e.from,
21
- to: this.pos,
22
- text: this.state.sliceDoc(e.from, this.pos),
23
- type: e.type
24
- } : null;
25
- }
26
- /**
27
- Get the match of the given expression directly before the
28
- cursor.
29
- */
30
- matchBefore(t) {
31
- let e = this.state.doc.lineAt(this.pos), n = Math.max(e.from, this.pos - 250), i = e.text.slice(n - e.from, this.pos - e.from), l = i.search(q(t));
32
- return l < 0 ? null : { from: n + l, to: this.pos, text: i.slice(l) };
33
- }
34
- /**
35
- Yields true when the query has been aborted. Can be useful in
36
- asynchronous queries to avoid doing work that will be ignored.
37
- */
38
- get aborted() {
39
- return this.abortListeners == null;
40
- }
41
- /**
42
- Allows you to register abort handlers, which will be called when
43
- the query is
44
- [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
45
-
46
- By default, running queries will not be aborted for regular
47
- typing or backspacing, on the assumption that they are likely to
48
- return a result with a
49
- [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
50
- allows the result to be used after all. Passing `onDocChange:
51
- true` will cause this query to be aborted for any document
52
- change.
53
- */
54
- addEventListener(t, e, n) {
55
- t == "abort" && this.abortListeners && (this.abortListeners.push(e), n && n.onDocChange && (this.abortOnDocChange = !0));
56
- }
57
- }
58
- function S(o) {
59
- let t = Object.keys(o).join(""), e = /\w/.test(t);
60
- return e && (t = t.replace(/\w/g, "")), `[${e ? "\\w" : ""}${t.replace(/[^\w\s]/g, "\\$&")}]`;
61
- }
62
- function j(o) {
63
- let t = /* @__PURE__ */ Object.create(null), e = /* @__PURE__ */ Object.create(null);
64
- for (let { label: i } of o) {
65
- t[i[0]] = !0;
66
- for (let l = 1; l < i.length; l++)
67
- e[i[l]] = !0;
68
- }
69
- let n = S(t) + S(e) + "*$";
70
- return [new RegExp("^" + n), new RegExp(n)];
71
- }
72
- function ne(o) {
73
- let t = o.map((i) => typeof i == "string" ? { label: i } : i), [e, n] = t.every((i) => /^\w+$/.test(i.label)) ? [/\w*$/, /\w+$/] : j(t);
74
- return (i) => {
75
- let l = i.matchBefore(n);
76
- return l || i.explicit ? { from: l ? l.from : i.pos, options: t, validFor: e } : null;
77
- };
78
- }
79
- function oe(o, t) {
80
- return (e) => {
81
- for (let n = E(e.state).resolveInner(e.pos, -1); n; n = n.parent) {
82
- if (o.indexOf(n.name) > -1)
83
- return null;
84
- if (n.type.isTop)
85
- break;
86
- }
87
- return t(e);
88
- };
89
- }
90
- function q(o, t) {
91
- var e;
92
- let { source: n } = o, i = n[n.length - 1] != "$";
93
- return i ? new RegExp(`(?:${n})${i ? "$" : ""}`, (e = o.flags) !== null && e !== void 0 ? e : o.ignoreCase ? "i" : "") : o;
94
- }
95
- const H = /* @__PURE__ */ T.define(), V = /* @__PURE__ */ w.baseTheme({
96
- ".cm-tooltip.cm-tooltip-autocomplete": {
97
- "& > ul": {
98
- fontFamily: "monospace",
99
- whiteSpace: "nowrap",
100
- overflow: "hidden auto",
101
- maxWidth_fallback: "700px",
102
- maxWidth: "min(700px, 95vw)",
103
- minWidth: "250px",
104
- maxHeight: "10em",
105
- height: "100%",
106
- listStyle: "none",
107
- margin: 0,
108
- padding: 0,
109
- "& > li, & > completion-section": {
110
- padding: "1px 3px",
111
- lineHeight: 1.2
112
- },
113
- "& > li": {
114
- overflowX: "hidden",
115
- textOverflow: "ellipsis",
116
- cursor: "pointer"
117
- },
118
- "& > completion-section": {
119
- display: "list-item",
120
- borderBottom: "1px solid silver",
121
- paddingLeft: "0.5em",
122
- opacity: 0.7
123
- }
124
- }
125
- },
126
- "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
127
- background: "#17c",
128
- color: "white"
129
- },
130
- "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
131
- background: "#777"
132
- },
133
- "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
134
- background: "#347",
135
- color: "white"
136
- },
137
- "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
138
- background: "#444"
139
- },
140
- ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
141
- content: '"···"',
142
- opacity: 0.5,
143
- display: "block",
144
- textAlign: "center"
145
- },
146
- ".cm-tooltip.cm-completionInfo": {
147
- position: "absolute",
148
- padding: "3px 9px",
149
- width: "max-content",
150
- maxWidth: "400px",
151
- boxSizing: "border-box",
152
- whiteSpace: "pre-line"
153
- },
154
- ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
155
- ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
156
- ".cm-completionInfo.cm-completionInfo-left-narrow": { right: "30px" },
157
- ".cm-completionInfo.cm-completionInfo-right-narrow": { left: "30px" },
158
- "&light .cm-snippetField": { backgroundColor: "#00000022" },
159
- "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
160
- ".cm-snippetFieldPosition": {
161
- verticalAlign: "text-top",
162
- width: 0,
163
- height: "1.15em",
164
- display: "inline-block",
165
- margin: "0 -0.7px -.7em",
166
- borderLeft: "1.4px dotted #888"
167
- },
168
- ".cm-completionMatchedText": {
169
- textDecoration: "underline"
170
- },
171
- ".cm-completionDetail": {
172
- marginLeft: "0.5em",
173
- fontStyle: "italic"
174
- },
175
- ".cm-completionIcon": {
176
- fontSize: "90%",
177
- width: ".8em",
178
- display: "inline-block",
179
- textAlign: "center",
180
- paddingRight: ".6em",
181
- opacity: "0.6",
182
- boxSizing: "content-box"
183
- },
184
- ".cm-completionIcon-function, .cm-completionIcon-method": {
185
- "&:after": { content: "'ƒ'" }
186
- },
187
- ".cm-completionIcon-class": {
188
- "&:after": { content: "'○'" }
189
- },
190
- ".cm-completionIcon-interface": {
191
- "&:after": { content: "'◌'" }
192
- },
193
- ".cm-completionIcon-variable": {
194
- "&:after": { content: "'𝑥'" }
195
- },
196
- ".cm-completionIcon-constant": {
197
- "&:after": { content: "'𝐶'" }
198
- },
199
- ".cm-completionIcon-type": {
200
- "&:after": { content: "'𝑡'" }
201
- },
202
- ".cm-completionIcon-enum": {
203
- "&:after": { content: "'∪'" }
204
- },
205
- ".cm-completionIcon-property": {
206
- "&:after": { content: "'□'" }
207
- },
208
- ".cm-completionIcon-keyword": {
209
- "&:after": { content: "'🔑︎'" }
210
- // Disable emoji rendering
211
- },
212
- ".cm-completionIcon-namespace": {
213
- "&:after": { content: "'▢'" }
214
- },
215
- ".cm-completionIcon-text": {
216
- "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
217
- }
218
- });
219
- class z {
220
- constructor(t, e, n, i) {
221
- this.field = t, this.line = e, this.from = n, this.to = i;
222
- }
223
- }
224
- class b {
225
- constructor(t, e, n) {
226
- this.field = t, this.from = e, this.to = n;
227
- }
228
- map(t) {
229
- let e = t.mapPos(this.from, -1, v.TrackDel), n = t.mapPos(this.to, 1, v.TrackDel);
230
- return e == null || n == null ? null : new b(this.field, e, n);
231
- }
232
- }
233
- class I {
234
- constructor(t, e) {
235
- this.lines = t, this.fieldPositions = e;
236
- }
237
- instantiate(t, e) {
238
- let n = [], i = [e], l = t.doc.lineAt(e), f = /^\s*/.exec(l.text)[0];
239
- for (let r of this.lines) {
240
- if (n.length) {
241
- let a = f, c = /^\t*/.exec(r)[0].length;
242
- for (let s = 0; s < c; s++)
243
- a += t.facet(P);
244
- i.push(e + a.length - c), r = a + r.slice(c);
245
- }
246
- n.push(r), e += r.length + 1;
247
- }
248
- let p = this.fieldPositions.map((r) => new b(r.field, i[r.line] + r.from, i[r.line] + r.to));
249
- return { text: n, ranges: p };
250
- }
251
- static parse(t) {
252
- let e = [], n = [], i = [], l;
253
- for (let f of t.split(/\r\n?|\n/)) {
254
- for (; l = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(f); ) {
255
- let p = l[1] ? +l[1] : null, r = l[2] || l[3] || "", a = -1, c = r.replace(/\\[{}]/g, (s) => s[1]);
256
- for (let s = 0; s < e.length; s++)
257
- (p != null ? e[s].seq == p : c && e[s].name == c) && (a = s);
258
- if (a < 0) {
259
- let s = 0;
260
- for (; s < e.length && (p == null || e[s].seq != null && e[s].seq < p); )
261
- s++;
262
- e.splice(s, 0, { seq: p, name: c }), a = s;
263
- for (let d of i)
264
- d.field >= a && d.field++;
265
- }
266
- for (let s of i)
267
- if (s.line == n.length && s.from > l.index) {
268
- let d = l[2] ? 3 + (l[1] || "").length : 2;
269
- s.from -= d, s.to -= d;
270
- }
271
- i.push(new z(a, n.length, l.index, l.index + c.length)), f = f.slice(0, l.index) + r + f.slice(l.index + l[0].length);
272
- }
273
- f = f.replace(/\\([{}])/g, (p, r, a) => {
274
- for (let c of i)
275
- c.line == n.length && c.from > a && (c.from--, c.to--);
276
- return r;
277
- }), n.push(f);
278
- }
279
- return new I(n, i);
280
- }
281
- }
282
- let K = /* @__PURE__ */ g.widget({ widget: /* @__PURE__ */ new class extends B {
283
- toDOM() {
284
- let o = document.createElement("span");
285
- return o.className = "cm-snippetFieldPosition", o;
286
- }
287
- ignoreEvent() {
288
- return !1;
289
- }
290
- }() }), N = /* @__PURE__ */ g.mark({ class: "cm-snippetField" });
291
- class m {
292
- constructor(t, e) {
293
- this.ranges = t, this.active = e, this.deco = g.set(t.map((n) => (n.from == n.to ? K : N).range(n.from, n.to)), !0);
294
- }
295
- map(t) {
296
- let e = [];
297
- for (let n of this.ranges) {
298
- let i = n.map(t);
299
- if (!i)
300
- return null;
301
- e.push(i);
302
- }
303
- return new m(e, this.active);
304
- }
305
- selectionInsideField(t) {
306
- return t.ranges.every((e) => this.ranges.some((n) => n.field == this.active && n.from <= e.from && n.to >= e.to));
307
- }
308
- }
309
- const h = /* @__PURE__ */ x.define({
310
- map(o, t) {
311
- return o && o.map(t);
312
- }
313
- }), X = /* @__PURE__ */ x.define(), u = /* @__PURE__ */ D.define({
314
- create() {
315
- return null;
316
- },
317
- update(o, t) {
318
- for (let e of t.effects) {
319
- if (e.is(h))
320
- return e.value;
321
- if (e.is(X) && o)
322
- return new m(o.ranges, e.value);
323
- }
324
- return o && t.docChanged && (o = o.map(t.changes)), o && t.selection && !o.selectionInsideField(t.selection) && (o = null), o;
325
- },
326
- provide: (o) => w.decorations.from(o, (t) => t ? t.deco : g.none)
327
- });
328
- function y(o, t) {
329
- return k.create(o.filter((e) => e.field == t).map((e) => k.range(e.from, e.to)));
330
- }
331
- function G(o) {
332
- let t = I.parse(o);
333
- return (e, n, i, l) => {
334
- let { text: f, ranges: p } = t.instantiate(e.state, i), { main: r } = e.state.selection, a = {
335
- changes: { from: i, to: l == r.from ? r.to : l, insert: A.of(f) },
336
- scrollIntoView: !0,
337
- annotations: n ? [H.of(n), L.userEvent.of("input.complete")] : void 0
338
- };
339
- if (p.length && (a.selection = y(p, 0)), p.some((c) => c.field > 0)) {
340
- let c = new m(p, 0), s = a.effects = [h.of(c)];
341
- e.state.field(u, !1) === void 0 && s.push(x.appendConfig.of([u, Z, _, V]));
342
- }
343
- e.dispatch(e.state.update(a));
344
- };
345
- }
346
- function $(o) {
347
- return ({ state: t, dispatch: e }) => {
348
- let n = t.field(u, !1);
349
- if (!n || o < 0 && n.active == 0)
350
- return !1;
351
- let i = n.active + o, l = o > 0 && !n.ranges.some((f) => f.field == i + o);
352
- return e(t.update({
353
- selection: y(n.ranges, i),
354
- effects: h.of(l ? null : new m(n.ranges, i)),
355
- scrollIntoView: !0
356
- })), !0;
357
- };
358
- }
359
- const J = ({ state: o, dispatch: t }) => o.field(u, !1) ? (t(o.update({ effects: h.of(null) })), !0) : !1, U = /* @__PURE__ */ $(1), Y = /* @__PURE__ */ $(-1), Q = [
360
- { key: "Tab", run: U, shift: Y },
361
- { key: "Escape", run: J }
362
- ], F = /* @__PURE__ */ R.define({
363
- combine(o) {
364
- return o.length ? o[0] : Q;
365
- }
366
- }), Z = /* @__PURE__ */ O.highest(/* @__PURE__ */ M.compute([F], (o) => o.facet(F)));
367
- function ie(o, t) {
368
- return { ...t, apply: G(o) };
369
- }
370
- const _ = /* @__PURE__ */ w.domEventHandlers({
371
- mousedown(o, t) {
372
- let e = t.state.field(u, !1), n;
373
- if (!e || (n = t.posAtCoords({ x: o.clientX, y: o.clientY })) == null)
374
- return !1;
375
- let i = e.ranges.find((l) => l.from <= n && l.to >= n);
376
- return !i || i.field == e.active ? !1 : (t.dispatch({
377
- selection: y(e.ranges, i.field),
378
- effects: h.of(e.ranges.some((l) => l.field > i.field) ? new m(e.ranges, i.field) : null),
379
- scrollIntoView: !0
380
- }), !0);
381
- }
382
- }), C = /* @__PURE__ */ new class extends W {
383
- }();
384
- C.startSide = 1;
385
- C.endSide = -1;
386
- export {
387
- te as C,
388
- ne as c,
389
- oe as i,
390
- ie as s
391
- };