@cascivo/editor 0.2.18 → 0.2.20
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 +1 -0
- package/dist/node/index.js +1516 -0
- package/package.json +10 -3
|
@@ -0,0 +1,1516 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e, useAnchorPosition as t, useControllableSignal as n, useId as r, useSignal as i, useSignalEffect as a, useSignals as o } from "@cascivo/core";
|
|
3
|
+
import { builtin as s, t as c } from "@cascivo/i18n";
|
|
4
|
+
import { forwardRef as l, useImperativeHandle as u, useRef as d } from "react";
|
|
5
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
+
//#region src/engine/tokenize.ts
|
|
7
|
+
var ee = /* @__PURE__ */ new Map(), m = "\0", te = 0;
|
|
8
|
+
function h(e, t, n) {
|
|
9
|
+
let r = `${e.name}${m}${n}${m}${t}`, i = ee.get(r);
|
|
10
|
+
if (i) return i;
|
|
11
|
+
te++;
|
|
12
|
+
let { tokens: a, state: o } = e.tokenizeLine(t, n), s = {
|
|
13
|
+
tokens: a,
|
|
14
|
+
endState: o
|
|
15
|
+
};
|
|
16
|
+
return ee.set(r, s), s;
|
|
17
|
+
}
|
|
18
|
+
function g(e, t) {
|
|
19
|
+
let n = t.split("\n"), r = [], i = e.initialState;
|
|
20
|
+
for (let t of n) {
|
|
21
|
+
let n = h(e, t, i);
|
|
22
|
+
r.push(n.tokens), i = n.endState;
|
|
23
|
+
}
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
26
|
+
function ne(e, t, n, r, i) {
|
|
27
|
+
let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i.startStateOf(t, a), c = [];
|
|
28
|
+
for (let n = a; n < o; n++) {
|
|
29
|
+
let r = h(e, t[n], s);
|
|
30
|
+
c.push(r.tokens), i.setEndState(n, r.endState), s = r.endState;
|
|
31
|
+
}
|
|
32
|
+
return c;
|
|
33
|
+
}
|
|
34
|
+
function re(e, t, n, r, i) {
|
|
35
|
+
let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i, c = [];
|
|
36
|
+
for (let n = a; n < o; n++) {
|
|
37
|
+
let r = h(e, t[n], s);
|
|
38
|
+
c.push(r.tokens), s = r.endState;
|
|
39
|
+
}
|
|
40
|
+
return c;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/engine/line-state.ts
|
|
44
|
+
function ie(e) {
|
|
45
|
+
let t = [], n = (n, r) => {
|
|
46
|
+
let i = Math.min(r, n.length - 1), a = t.length;
|
|
47
|
+
if (a > i) return;
|
|
48
|
+
let o = a === 0 ? e.initialState : t[a - 1];
|
|
49
|
+
for (; a <= i; a++) {
|
|
50
|
+
let r = h(e, n[a], o);
|
|
51
|
+
t[a] = r.endState, o = r.endState;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
grammar: e,
|
|
56
|
+
get length() {
|
|
57
|
+
return t.length;
|
|
58
|
+
},
|
|
59
|
+
ensure: n,
|
|
60
|
+
startStateOf: (r, i) => i <= 0 ? e.initialState : (n(r, i - 1), t[i - 1]),
|
|
61
|
+
setEndState: (e, n) => {
|
|
62
|
+
t[e] = n;
|
|
63
|
+
},
|
|
64
|
+
invalidateFrom: (e) => {
|
|
65
|
+
let n = Math.max(0, e);
|
|
66
|
+
n < t.length && (t.length = n);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/engine/registry.ts
|
|
72
|
+
var _ = /* @__PURE__ */ new Map(), v = {
|
|
73
|
+
name: "plaintext",
|
|
74
|
+
initialState: "default",
|
|
75
|
+
tokenizeLine: (e) => ({
|
|
76
|
+
tokens: e.length > 0 ? [{
|
|
77
|
+
kind: "plain",
|
|
78
|
+
value: e
|
|
79
|
+
}] : [],
|
|
80
|
+
state: "default"
|
|
81
|
+
})
|
|
82
|
+
};
|
|
83
|
+
_.set(v.name, v);
|
|
84
|
+
function y(e) {
|
|
85
|
+
_.set(e.name, e);
|
|
86
|
+
}
|
|
87
|
+
function ae(e) {
|
|
88
|
+
if (e !== void 0) {
|
|
89
|
+
let t = _.get(e);
|
|
90
|
+
if (t) return t;
|
|
91
|
+
}
|
|
92
|
+
return _.get("plaintext");
|
|
93
|
+
}
|
|
94
|
+
function b() {
|
|
95
|
+
return [..._.keys()];
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/grammars/rules.ts
|
|
99
|
+
function x(e) {
|
|
100
|
+
let t = {};
|
|
101
|
+
for (let [n, r] of Object.entries(e.states)) t[n] = r.map((e) => {
|
|
102
|
+
let t = `${e.match.flags.replace(/[gy]/g, "")}y`, n = {
|
|
103
|
+
re: new RegExp(e.match.source, t),
|
|
104
|
+
kind: e.kind
|
|
105
|
+
};
|
|
106
|
+
return e.push !== void 0 && (n.push = e.push), e.pop !== void 0 && (n.pop = e.pop), n;
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
name: e.name,
|
|
110
|
+
initialState: "default",
|
|
111
|
+
tokenizeLine(e, n) {
|
|
112
|
+
let r = t[n] ? n : "default", i = [], a = -1, o = 0, s = (t) => {
|
|
113
|
+
a >= 0 && (i.push({
|
|
114
|
+
kind: "plain",
|
|
115
|
+
value: e.slice(a, t)
|
|
116
|
+
}), a = -1);
|
|
117
|
+
};
|
|
118
|
+
for (; o < e.length;) {
|
|
119
|
+
let n = t[r], c = !1;
|
|
120
|
+
for (let a of n) {
|
|
121
|
+
a.re.lastIndex = o;
|
|
122
|
+
let n = a.re.exec(e);
|
|
123
|
+
if (n !== null && n.index === o && n[0].length > 0) {
|
|
124
|
+
s(o), i.push({
|
|
125
|
+
kind: a.kind,
|
|
126
|
+
value: n[0]
|
|
127
|
+
}), o += n[0].length, a.pop ? r = "default" : a.push && t[a.push] && (r = a.push), c = !0;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
c || (a < 0 && (a = o), o++);
|
|
132
|
+
}
|
|
133
|
+
return s(e.length), {
|
|
134
|
+
tokens: i,
|
|
135
|
+
state: r
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/grammars/plaintext.ts
|
|
142
|
+
var oe = {
|
|
143
|
+
name: "plaintext",
|
|
144
|
+
initialState: "default",
|
|
145
|
+
tokenizeLine: (e) => ({
|
|
146
|
+
tokens: e.length > 0 ? [{
|
|
147
|
+
kind: "plain",
|
|
148
|
+
value: e
|
|
149
|
+
}] : [],
|
|
150
|
+
state: "default"
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
y(oe);
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/grammars/json.ts
|
|
156
|
+
var se = x({
|
|
157
|
+
name: "json",
|
|
158
|
+
states: { default: [
|
|
159
|
+
{
|
|
160
|
+
match: /"(?:[^"\\]|\\.)*"(?=\s*:)/,
|
|
161
|
+
kind: "property"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
match: /"(?:[^"\\]|\\.)*"/,
|
|
165
|
+
kind: "string"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
match: /\b(?:true|false|null)\b/,
|
|
169
|
+
kind: "boolean"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
match: /-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/,
|
|
173
|
+
kind: "number"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
match: /[{}[\],]/,
|
|
177
|
+
kind: "punctuation"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
match: /:/,
|
|
181
|
+
kind: "operator"
|
|
182
|
+
}
|
|
183
|
+
] }
|
|
184
|
+
});
|
|
185
|
+
y(se);
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/grammars/clike.ts
|
|
188
|
+
var ce = /* @__PURE__ */ "async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.export.extends.finally.for.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.with.yield.as.from.get.set".split(".");
|
|
189
|
+
function le(e) {
|
|
190
|
+
return RegExp(`(?:${e.join("|")})\\b`);
|
|
191
|
+
}
|
|
192
|
+
function S(e, t, n = []) {
|
|
193
|
+
let r = [
|
|
194
|
+
{
|
|
195
|
+
match: /\/\/.*/,
|
|
196
|
+
kind: "comment"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
match: /\/\*/,
|
|
200
|
+
kind: "comment",
|
|
201
|
+
push: "block"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
match: /`/,
|
|
205
|
+
kind: "string",
|
|
206
|
+
push: "template"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
match: /'(?:[^'\\]|\\.)*'/,
|
|
210
|
+
kind: "string"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
match: /"(?:[^"\\]|\\.)*"/,
|
|
214
|
+
kind: "string"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
match: /0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:\d[\d_]*\.?\d*|\.\d+)(?:[eE][+-]?\d+)?n?/,
|
|
218
|
+
kind: "number"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
match: /\b(?:true|false|null|undefined|NaN|Infinity)\b/,
|
|
222
|
+
kind: "boolean"
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
return n.length > 0 && r.push({
|
|
226
|
+
match: le(n),
|
|
227
|
+
kind: "type"
|
|
228
|
+
}), r.push({
|
|
229
|
+
match: le(t),
|
|
230
|
+
kind: "keyword"
|
|
231
|
+
}, {
|
|
232
|
+
match: /[A-Za-z_$][\w$]*(?=\s*\()/,
|
|
233
|
+
kind: "function"
|
|
234
|
+
}, {
|
|
235
|
+
match: /[A-Z][\w$]*/,
|
|
236
|
+
kind: "type"
|
|
237
|
+
}, {
|
|
238
|
+
match: /[A-Za-z_$][\w$]*/,
|
|
239
|
+
kind: "variable"
|
|
240
|
+
}, {
|
|
241
|
+
match: /[+\-*/%=<>!&|^~?]+/,
|
|
242
|
+
kind: "operator"
|
|
243
|
+
}, {
|
|
244
|
+
match: /[{}()[\];,.:]/,
|
|
245
|
+
kind: "punctuation"
|
|
246
|
+
}), x({
|
|
247
|
+
name: e,
|
|
248
|
+
states: {
|
|
249
|
+
default: r,
|
|
250
|
+
block: [
|
|
251
|
+
{
|
|
252
|
+
match: /\*\//,
|
|
253
|
+
kind: "comment",
|
|
254
|
+
pop: !0
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
match: /[^*]+/,
|
|
258
|
+
kind: "comment"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
match: /\*/,
|
|
262
|
+
kind: "comment"
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
template: [
|
|
266
|
+
{
|
|
267
|
+
match: /\\./,
|
|
268
|
+
kind: "string"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
match: /`/,
|
|
272
|
+
kind: "string",
|
|
273
|
+
pop: !0
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
match: /\$\{/,
|
|
277
|
+
kind: "punctuation"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
match: /[^`\\$]+/,
|
|
281
|
+
kind: "string"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
match: /\$/,
|
|
285
|
+
kind: "string"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/grammars/javascript.ts
|
|
293
|
+
var ue = S("javascript", ce);
|
|
294
|
+
y(ue);
|
|
295
|
+
var de = S("typescript", ce, [
|
|
296
|
+
"interface",
|
|
297
|
+
"type",
|
|
298
|
+
"enum",
|
|
299
|
+
"implements",
|
|
300
|
+
"namespace",
|
|
301
|
+
"declare",
|
|
302
|
+
"abstract",
|
|
303
|
+
"readonly",
|
|
304
|
+
"public",
|
|
305
|
+
"private",
|
|
306
|
+
"protected",
|
|
307
|
+
"keyof",
|
|
308
|
+
"infer",
|
|
309
|
+
"satisfies",
|
|
310
|
+
"is",
|
|
311
|
+
"asserts",
|
|
312
|
+
"override",
|
|
313
|
+
"string",
|
|
314
|
+
"number",
|
|
315
|
+
"boolean",
|
|
316
|
+
"any",
|
|
317
|
+
"unknown",
|
|
318
|
+
"never",
|
|
319
|
+
"object"
|
|
320
|
+
]);
|
|
321
|
+
y(de);
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/grammars/css.ts
|
|
324
|
+
var C = x({
|
|
325
|
+
name: "css",
|
|
326
|
+
states: {
|
|
327
|
+
default: [
|
|
328
|
+
{
|
|
329
|
+
match: /\/\*/,
|
|
330
|
+
kind: "comment",
|
|
331
|
+
push: "block"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
match: /@[\w-]+/,
|
|
335
|
+
kind: "keyword"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
match: /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/,
|
|
339
|
+
kind: "string"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
match: /#[0-9a-fA-F]{3,8}\b/,
|
|
343
|
+
kind: "number"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
match: /-?\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw|s|ms|deg|fr|ch|ex)?/,
|
|
347
|
+
kind: "number"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
match: /--[\w-]+/,
|
|
351
|
+
kind: "variable"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
match: /[.#][\w-]+/,
|
|
355
|
+
kind: "tag"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
match: /&|::?[\w-]+/,
|
|
359
|
+
kind: "tag"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
match: /[\w-]+(?=\s*:)/,
|
|
363
|
+
kind: "property"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
match: /[\w-]+(?=\s*\()/,
|
|
367
|
+
kind: "function"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
match: /[{}();,:]/,
|
|
371
|
+
kind: "punctuation"
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
block: [
|
|
375
|
+
{
|
|
376
|
+
match: /\*\//,
|
|
377
|
+
kind: "comment",
|
|
378
|
+
pop: !0
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
match: /[^*]+/,
|
|
382
|
+
kind: "comment"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
match: /\*/,
|
|
386
|
+
kind: "comment"
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
y(C);
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/grammars/html.ts
|
|
394
|
+
var fe = x({
|
|
395
|
+
name: "html",
|
|
396
|
+
states: {
|
|
397
|
+
default: [
|
|
398
|
+
{
|
|
399
|
+
match: /<!--/,
|
|
400
|
+
kind: "comment",
|
|
401
|
+
push: "comment"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
match: /<!?\/?[A-Za-z][\w-]*/,
|
|
405
|
+
kind: "tag",
|
|
406
|
+
push: "tag"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
match: /&[a-zA-Z#0-9]+;/,
|
|
410
|
+
kind: "boolean"
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
comment: [
|
|
414
|
+
{
|
|
415
|
+
match: /-->/,
|
|
416
|
+
kind: "comment",
|
|
417
|
+
pop: !0
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
match: /[^-]+/,
|
|
421
|
+
kind: "comment"
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
match: /-/,
|
|
425
|
+
kind: "comment"
|
|
426
|
+
}
|
|
427
|
+
],
|
|
428
|
+
tag: [
|
|
429
|
+
{
|
|
430
|
+
match: /\/?>/,
|
|
431
|
+
kind: "tag",
|
|
432
|
+
pop: !0
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
match: /"(?:[^"\\]|\\.)*"|'[^']*'/,
|
|
436
|
+
kind: "string"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
match: /[\w-]+(?=\s*=)/,
|
|
440
|
+
kind: "attr"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
match: /=/,
|
|
444
|
+
kind: "operator"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
match: /[\w-]+/,
|
|
448
|
+
kind: "attr"
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
y(fe);
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/grammars/markdown.ts
|
|
456
|
+
var pe = x({
|
|
457
|
+
name: "markdown",
|
|
458
|
+
states: {
|
|
459
|
+
default: [
|
|
460
|
+
{
|
|
461
|
+
match: /^```.*/,
|
|
462
|
+
kind: "keyword",
|
|
463
|
+
push: "fence"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
match: /^~~~.*/,
|
|
467
|
+
kind: "keyword",
|
|
468
|
+
push: "fenceTilde"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
match: /^\s*([-*_])(?:[ \t]*\1){2,}[ \t]*$/,
|
|
472
|
+
kind: "comment"
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
match: /^#{1,6}\s.*/,
|
|
476
|
+
kind: "keyword"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
match: /^\s*[-*+]\s+\[[ xX]\]/,
|
|
480
|
+
kind: "boolean"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
match: /^\s*(?:[-*+]|\d+\.)\s/,
|
|
484
|
+
kind: "operator"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
match: /^\s*>\s?.*/,
|
|
488
|
+
kind: "comment"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
match: /`[^`]+`/,
|
|
492
|
+
kind: "string"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
match: /~~[^~]+~~/,
|
|
496
|
+
kind: "comment"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
match: /\*\*[^*]+\*\*|__[^_]+__/,
|
|
500
|
+
kind: "keyword"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
match: /\*[^*\s][^*]*\*|_[^_\s][^_]*_/,
|
|
504
|
+
kind: "type"
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
match: /!?\[[^\]]*\]\([^)]*\)/,
|
|
508
|
+
kind: "function"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
fence: [{
|
|
512
|
+
match: /^```.*/,
|
|
513
|
+
kind: "keyword",
|
|
514
|
+
pop: !0
|
|
515
|
+
}, {
|
|
516
|
+
match: /.+/,
|
|
517
|
+
kind: "string"
|
|
518
|
+
}],
|
|
519
|
+
fenceTilde: [{
|
|
520
|
+
match: /^~~~.*/,
|
|
521
|
+
kind: "keyword",
|
|
522
|
+
pop: !0
|
|
523
|
+
}, {
|
|
524
|
+
match: /.+/,
|
|
525
|
+
kind: "string"
|
|
526
|
+
}]
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
y(pe);
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/grammars/bash.ts
|
|
532
|
+
var me = x({
|
|
533
|
+
name: "bash",
|
|
534
|
+
states: { default: [
|
|
535
|
+
{
|
|
536
|
+
match: /#.*/,
|
|
537
|
+
kind: "comment"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
match: /"(?:[^"\\]|\\.)*"/,
|
|
541
|
+
kind: "string"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
match: /'[^']*'/,
|
|
545
|
+
kind: "string"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
match: /\b(?:if|then|else|elif|fi|for|while|until|do|done|case|esac|in|function|select|return|exit|break|continue|local|export|readonly|declare|echo|cd|source|set|unset)\b/,
|
|
549
|
+
kind: "keyword"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
match: /\$\{[^}]*\}|\$[A-Za-z_]\w*|\$[0-9@*#?$!]/,
|
|
553
|
+
kind: "variable"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
match: /-?\b\d+\b/,
|
|
557
|
+
kind: "number"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
match: /[A-Za-z_][\w-]*(?=\s*\(\s*\))/,
|
|
561
|
+
kind: "function"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
match: /[|&;<>()]+|&&|\|\||=/,
|
|
565
|
+
kind: "operator"
|
|
566
|
+
}
|
|
567
|
+
] }
|
|
568
|
+
});
|
|
569
|
+
y(me);
|
|
570
|
+
var w = {
|
|
571
|
+
root: "_root_1m6ns_2",
|
|
572
|
+
gutter: "_gutter_1m6ns_17",
|
|
573
|
+
gutterLine: "_gutterLine_1m6ns_28",
|
|
574
|
+
gutterActive: "_gutterActive_1m6ns_35",
|
|
575
|
+
pre: "_pre_1m6ns_45",
|
|
576
|
+
code: "_code_1m6ns_57",
|
|
577
|
+
line: "_line_1m6ns_62",
|
|
578
|
+
plain: "_plain_1m6ns_77",
|
|
579
|
+
keyword: "_keyword_1m6ns_80",
|
|
580
|
+
string: "_string_1m6ns_83",
|
|
581
|
+
number: "_number_1m6ns_86",
|
|
582
|
+
comment: "_comment_1m6ns_89",
|
|
583
|
+
function: "_function_1m6ns_93",
|
|
584
|
+
type: "_type_1m6ns_96",
|
|
585
|
+
operator: "_operator_1m6ns_99",
|
|
586
|
+
punctuation: "_punctuation_1m6ns_102",
|
|
587
|
+
variable: "_variable_1m6ns_105",
|
|
588
|
+
tag: "_tag_1m6ns_108",
|
|
589
|
+
attr: "_attr_1m6ns_111",
|
|
590
|
+
regexp: "_regexp_1m6ns_114",
|
|
591
|
+
boolean: "_boolean_1m6ns_117",
|
|
592
|
+
property: "_property_1m6ns_120",
|
|
593
|
+
match: "_match_1m6ns_125",
|
|
594
|
+
matchCurrent: "_matchCurrent_1m6ns_129",
|
|
595
|
+
bracketMatch: "_bracketMatch_1m6ns_133"
|
|
596
|
+
};
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region src/editor/view.tsx
|
|
599
|
+
function he(e, t) {
|
|
600
|
+
let n = "";
|
|
601
|
+
for (let r of t) e >= r.start && e < r.end && (n = n ? `${n} ${r.className}` : r.className);
|
|
602
|
+
return n;
|
|
603
|
+
}
|
|
604
|
+
function ge(t, n, r, i) {
|
|
605
|
+
let a = n + t.value.length, o = new Set([n, a]);
|
|
606
|
+
for (let e of r) e.start > n && e.start < a && o.add(e.start), e.end > n && e.end < a && o.add(e.end);
|
|
607
|
+
if (o.size === 2) {
|
|
608
|
+
let a = he(n, r);
|
|
609
|
+
return /* @__PURE__ */ f("span", {
|
|
610
|
+
className: a ? e(w[t.kind], a) : w[t.kind],
|
|
611
|
+
children: t.value
|
|
612
|
+
}, i);
|
|
613
|
+
}
|
|
614
|
+
let s = [...o].sort((e, t) => e - t), c = [];
|
|
615
|
+
for (let i = 0; i < s.length - 1; i++) {
|
|
616
|
+
let a = s[i], o = s[i + 1], l = he(a, r);
|
|
617
|
+
c.push(/* @__PURE__ */ f("span", {
|
|
618
|
+
className: l ? e(w[t.kind], l) : w[t.kind],
|
|
619
|
+
children: t.value.slice(a - n, o - n)
|
|
620
|
+
}, a));
|
|
621
|
+
}
|
|
622
|
+
return /* @__PURE__ */ f("span", { children: c }, i);
|
|
623
|
+
}
|
|
624
|
+
function _e(e, t = 0, n = t + e.length, r) {
|
|
625
|
+
let i = [];
|
|
626
|
+
for (let a = t; a < n; a++) {
|
|
627
|
+
let n = e[a - t], o = r?.filter((e) => e.line === a);
|
|
628
|
+
i.push(/* @__PURE__ */ f("span", {
|
|
629
|
+
className: w.line,
|
|
630
|
+
children: n.length === 0 ? "" : o && o.length > 0 ? (() => {
|
|
631
|
+
let e = 0;
|
|
632
|
+
return n.map((t, n) => {
|
|
633
|
+
let r = ge(t, e, o, n);
|
|
634
|
+
return e += t.value.length, r;
|
|
635
|
+
});
|
|
636
|
+
})() : n.map((e, t) => /* @__PURE__ */ f("span", {
|
|
637
|
+
className: w[e.kind],
|
|
638
|
+
children: e.value
|
|
639
|
+
}, t))
|
|
640
|
+
}, a));
|
|
641
|
+
}
|
|
642
|
+
return i;
|
|
643
|
+
}
|
|
644
|
+
function ve({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
|
|
645
|
+
let c = [];
|
|
646
|
+
for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ f("span", {
|
|
647
|
+
className: w.gutterLine,
|
|
648
|
+
children: e
|
|
649
|
+
}, e));
|
|
650
|
+
return /* @__PURE__ */ p("div", {
|
|
651
|
+
ref: n,
|
|
652
|
+
className: t,
|
|
653
|
+
"aria-hidden": "true",
|
|
654
|
+
children: [
|
|
655
|
+
s && /* @__PURE__ */ f("div", { className: w.gutterActive }),
|
|
656
|
+
a > 0 && /* @__PURE__ */ f("div", { style: { blockSize: a } }),
|
|
657
|
+
c,
|
|
658
|
+
o > 0 && /* @__PURE__ */ f("div", { style: { blockSize: o } })
|
|
659
|
+
]
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
var T = {
|
|
663
|
+
root: "_root_18xci_2",
|
|
664
|
+
textarea: "_textarea_18xci_18",
|
|
665
|
+
gutter: "_gutter_18xci_23",
|
|
666
|
+
codeArea: "_codeArea_18xci_36",
|
|
667
|
+
pre: "_pre_18xci_43",
|
|
668
|
+
currentLine: "_currentLine_18xci_58"
|
|
669
|
+
}, E = {
|
|
670
|
+
panel: "_panel_hawkv_2",
|
|
671
|
+
row: "_row_hawkv_20",
|
|
672
|
+
input: "_input_hawkv_26",
|
|
673
|
+
count: "_count_hawkv_44",
|
|
674
|
+
button: "_button_hawkv_52",
|
|
675
|
+
toggle: "_toggle_hawkv_53",
|
|
676
|
+
active: "_active_hawkv_80"
|
|
677
|
+
};
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/editor/code-editor/find-panel.tsx
|
|
680
|
+
function ye(t) {
|
|
681
|
+
o();
|
|
682
|
+
let n = t.matchCount === 0 ? c(s.editor.noMatches) : c(s.editor.findCount, {
|
|
683
|
+
current: t.currentIndex + 1,
|
|
684
|
+
total: t.matchCount
|
|
685
|
+
});
|
|
686
|
+
return /* @__PURE__ */ p("div", {
|
|
687
|
+
className: E.panel,
|
|
688
|
+
role: "search",
|
|
689
|
+
"aria-label": c(s.editor.find),
|
|
690
|
+
children: [/* @__PURE__ */ p("div", {
|
|
691
|
+
className: E.row,
|
|
692
|
+
children: [
|
|
693
|
+
/* @__PURE__ */ f("button", {
|
|
694
|
+
type: "button",
|
|
695
|
+
className: E.toggle,
|
|
696
|
+
"aria-label": c(s.editor.toggleReplace),
|
|
697
|
+
"aria-expanded": t.replaceMode,
|
|
698
|
+
onClick: t.onToggleReplace,
|
|
699
|
+
children: t.replaceMode ? "▾" : "▸"
|
|
700
|
+
}),
|
|
701
|
+
/* @__PURE__ */ f("input", {
|
|
702
|
+
className: E.input,
|
|
703
|
+
value: t.query,
|
|
704
|
+
placeholder: c(s.editor.findPlaceholder),
|
|
705
|
+
"aria-label": c(s.editor.find),
|
|
706
|
+
autoFocus: !0,
|
|
707
|
+
autoComplete: "off",
|
|
708
|
+
spellCheck: !1,
|
|
709
|
+
onChange: (e) => t.onQueryChange(e.currentTarget.value),
|
|
710
|
+
onKeyDown: (e) => {
|
|
711
|
+
e.key === "Enter" ? (e.preventDefault(), e.shiftKey ? t.onPrev() : t.onNext()) : e.key === "Escape" && (e.preventDefault(), t.onClose());
|
|
712
|
+
}
|
|
713
|
+
}),
|
|
714
|
+
/* @__PURE__ */ f("span", {
|
|
715
|
+
className: E.count,
|
|
716
|
+
"aria-live": "polite",
|
|
717
|
+
children: n
|
|
718
|
+
}),
|
|
719
|
+
/* @__PURE__ */ f("button", {
|
|
720
|
+
type: "button",
|
|
721
|
+
className: E.button,
|
|
722
|
+
"aria-label": c(s.editor.previous),
|
|
723
|
+
onClick: t.onPrev,
|
|
724
|
+
children: "‹"
|
|
725
|
+
}),
|
|
726
|
+
/* @__PURE__ */ f("button", {
|
|
727
|
+
type: "button",
|
|
728
|
+
className: E.button,
|
|
729
|
+
"aria-label": c(s.editor.next),
|
|
730
|
+
onClick: t.onNext,
|
|
731
|
+
children: "›"
|
|
732
|
+
}),
|
|
733
|
+
/* @__PURE__ */ f("button", {
|
|
734
|
+
type: "button",
|
|
735
|
+
className: e(E.button, t.caseSensitive && E.active),
|
|
736
|
+
"aria-pressed": t.caseSensitive,
|
|
737
|
+
"aria-label": c(s.editor.matchCase),
|
|
738
|
+
onClick: t.onToggleCase,
|
|
739
|
+
children: "Aa"
|
|
740
|
+
}),
|
|
741
|
+
/* @__PURE__ */ f("button", {
|
|
742
|
+
type: "button",
|
|
743
|
+
className: E.button,
|
|
744
|
+
"aria-label": c(s.editor.close),
|
|
745
|
+
onClick: t.onClose,
|
|
746
|
+
children: "×"
|
|
747
|
+
})
|
|
748
|
+
]
|
|
749
|
+
}), t.replaceMode && /* @__PURE__ */ p("div", {
|
|
750
|
+
className: E.row,
|
|
751
|
+
children: [
|
|
752
|
+
/* @__PURE__ */ f("input", {
|
|
753
|
+
className: E.input,
|
|
754
|
+
value: t.replaceQuery,
|
|
755
|
+
placeholder: c(s.editor.replacePlaceholder),
|
|
756
|
+
"aria-label": c(s.editor.replace),
|
|
757
|
+
autoComplete: "off",
|
|
758
|
+
spellCheck: !1,
|
|
759
|
+
onChange: (e) => t.onReplaceChange(e.currentTarget.value),
|
|
760
|
+
onKeyDown: (e) => {
|
|
761
|
+
e.key === "Escape" ? (e.preventDefault(), t.onClose()) : e.key === "Enter" && (e.preventDefault(), t.onReplace());
|
|
762
|
+
}
|
|
763
|
+
}),
|
|
764
|
+
/* @__PURE__ */ f("button", {
|
|
765
|
+
type: "button",
|
|
766
|
+
className: E.button,
|
|
767
|
+
onClick: t.onReplace,
|
|
768
|
+
children: c(s.editor.replaceOne)
|
|
769
|
+
}),
|
|
770
|
+
/* @__PURE__ */ f("button", {
|
|
771
|
+
type: "button",
|
|
772
|
+
className: E.button,
|
|
773
|
+
onClick: t.onReplaceAll,
|
|
774
|
+
children: c(s.editor.replaceAll)
|
|
775
|
+
})
|
|
776
|
+
]
|
|
777
|
+
})]
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region src/editor/code-editor/find.ts
|
|
782
|
+
var D = /\w/;
|
|
783
|
+
function be(e) {
|
|
784
|
+
return e !== void 0 && D.test(e);
|
|
785
|
+
}
|
|
786
|
+
function xe(e, t, n = {}) {
|
|
787
|
+
if (t.length === 0) return [];
|
|
788
|
+
let r = n.caseSensitive ? e : e.toLowerCase(), i = n.caseSensitive ? t : t.toLowerCase(), a = [], o = 0;
|
|
789
|
+
for (;;) {
|
|
790
|
+
let t = r.indexOf(i, o);
|
|
791
|
+
if (t === -1) break;
|
|
792
|
+
let s = t + i.length;
|
|
793
|
+
(!n.wholeWord || !be(e[t - 1]) && !be(e[s])) && a.push({
|
|
794
|
+
start: t,
|
|
795
|
+
end: s
|
|
796
|
+
}), o = s > t ? s : t + 1;
|
|
797
|
+
}
|
|
798
|
+
return a;
|
|
799
|
+
}
|
|
800
|
+
function Se(e, t) {
|
|
801
|
+
let n = 0, r = 0;
|
|
802
|
+
for (let i = 0; i < t && i < e.length; i++) e[i] === "\n" && (n++, r = i + 1);
|
|
803
|
+
return {
|
|
804
|
+
line: n,
|
|
805
|
+
col: t - r
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
function Ce(e, t, n, r) {
|
|
809
|
+
return t.map((t, i) => {
|
|
810
|
+
let { line: a, col: o } = Se(e, t.start);
|
|
811
|
+
return {
|
|
812
|
+
line: a,
|
|
813
|
+
start: o,
|
|
814
|
+
end: o + (t.end - t.start),
|
|
815
|
+
className: i === n ? r.current : r.match
|
|
816
|
+
};
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
function we(e, t, n) {
|
|
820
|
+
let r = e;
|
|
821
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
822
|
+
let i = t[e];
|
|
823
|
+
r = r.slice(0, i.start) + n + r.slice(i.end);
|
|
824
|
+
}
|
|
825
|
+
return r;
|
|
826
|
+
}
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/editor/code-editor/brackets.ts
|
|
829
|
+
var O = {
|
|
830
|
+
"(": ")",
|
|
831
|
+
"[": "]",
|
|
832
|
+
"{": "}"
|
|
833
|
+
}, k = {
|
|
834
|
+
")": "(",
|
|
835
|
+
"]": "[",
|
|
836
|
+
"}": "}"
|
|
837
|
+
};
|
|
838
|
+
function A(e, t, n, r) {
|
|
839
|
+
let i = 0;
|
|
840
|
+
for (let a = t; a < e.length; a++) {
|
|
841
|
+
let t = e[a];
|
|
842
|
+
if (t === n) i++;
|
|
843
|
+
else if (t === r && --i === 0) return a;
|
|
844
|
+
}
|
|
845
|
+
return -1;
|
|
846
|
+
}
|
|
847
|
+
function j(e, t, n, r) {
|
|
848
|
+
let i = 0;
|
|
849
|
+
for (let a = t; a >= 0; a--) {
|
|
850
|
+
let t = e[a];
|
|
851
|
+
if (t === r) i++;
|
|
852
|
+
else if (t === n && --i === 0) return a;
|
|
853
|
+
}
|
|
854
|
+
return -1;
|
|
855
|
+
}
|
|
856
|
+
function Te(e, t) {
|
|
857
|
+
let n = e[t];
|
|
858
|
+
if (n && n in O) {
|
|
859
|
+
let r = A(e, t, n, O[n]);
|
|
860
|
+
if (r !== -1) return {
|
|
861
|
+
open: t,
|
|
862
|
+
close: r
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
let r = e[t - 1];
|
|
866
|
+
if (r && r in k) {
|
|
867
|
+
let n = j(e, t - 1, k[r], r);
|
|
868
|
+
if (n !== -1) return {
|
|
869
|
+
open: n,
|
|
870
|
+
close: t - 1
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
if (r && r in O) {
|
|
874
|
+
let n = A(e, t - 1, r, O[r]);
|
|
875
|
+
if (n !== -1) return {
|
|
876
|
+
open: t - 1,
|
|
877
|
+
close: n
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
if (n && n in k) {
|
|
881
|
+
let r = j(e, t, k[n], n);
|
|
882
|
+
if (r !== -1) return {
|
|
883
|
+
open: r,
|
|
884
|
+
close: t
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
function Ee(e, t, n) {
|
|
889
|
+
return [t.open, t.close].map((t) => {
|
|
890
|
+
let { line: r, col: i } = Se(e, t);
|
|
891
|
+
return {
|
|
892
|
+
line: r,
|
|
893
|
+
start: i,
|
|
894
|
+
end: i + 1,
|
|
895
|
+
className: n
|
|
896
|
+
};
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region src/editor/code-editor/history.ts
|
|
901
|
+
function De(e = 200) {
|
|
902
|
+
let t = [], n = -1, r = !1;
|
|
903
|
+
return {
|
|
904
|
+
record(i, a) {
|
|
905
|
+
let o = a?.coalesce ?? !1;
|
|
906
|
+
n < t.length - 1 && (t = t.slice(0, n + 1)), o && r && n >= 0 ? t[n] = i : (t.push(i), n = t.length - 1, t.length > e && (t.shift(), n--)), r = o;
|
|
907
|
+
},
|
|
908
|
+
undo() {
|
|
909
|
+
if (!(n <= 0)) return n--, r = !1, t[n];
|
|
910
|
+
},
|
|
911
|
+
redo() {
|
|
912
|
+
if (!(n >= t.length - 1)) return n++, r = !1, t[n];
|
|
913
|
+
},
|
|
914
|
+
reset(e) {
|
|
915
|
+
t = [e], n = 0, r = !1;
|
|
916
|
+
},
|
|
917
|
+
canUndo() {
|
|
918
|
+
return n > 0;
|
|
919
|
+
},
|
|
920
|
+
canRedo() {
|
|
921
|
+
return n < t.length - 1;
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region src/editor/code-editor/keymap.ts
|
|
927
|
+
var Oe = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
|
|
928
|
+
function ke(e) {
|
|
929
|
+
let t = [];
|
|
930
|
+
(Oe ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
|
|
931
|
+
let n = e.key;
|
|
932
|
+
return n.length === 1 && (n = n.toLowerCase()), t.push(n), t.join("-");
|
|
933
|
+
}
|
|
934
|
+
function Ae(e, t) {
|
|
935
|
+
let n = new Map(Object.entries(e));
|
|
936
|
+
if (t) for (let [e, r] of Object.entries(t)) n.set(e, r);
|
|
937
|
+
return n;
|
|
938
|
+
}
|
|
939
|
+
function je(e, t) {
|
|
940
|
+
let n = e.get(ke(t.event));
|
|
941
|
+
return n ? n(t) : !1;
|
|
942
|
+
}
|
|
943
|
+
function Me(e) {
|
|
944
|
+
let t = () => e.insertSpaces ? " ".repeat(e.tabSize) : " ";
|
|
945
|
+
return {
|
|
946
|
+
indent: ({ textarea: e, setText: n }) => {
|
|
947
|
+
let { selectionStart: r, selectionEnd: i, value: a } = e, o = a.lastIndexOf("\n", r - 1) + 1;
|
|
948
|
+
if (r === i) e.setRangeText(t(), r, i, "end");
|
|
949
|
+
else {
|
|
950
|
+
let n = a.slice(o, i).replace(/^/gm, t());
|
|
951
|
+
e.setRangeText(n, o, i, "select");
|
|
952
|
+
}
|
|
953
|
+
return n(e.value), !0;
|
|
954
|
+
},
|
|
955
|
+
dedent: ({ textarea: t, setText: n }) => {
|
|
956
|
+
let { selectionStart: r, selectionEnd: i, value: a } = t, o = a.lastIndexOf("\n", r - 1) + 1, s = a.slice(o, i).replace(RegExp(`^(?:\\t| {1,${e.tabSize}})`, "gm"), "");
|
|
957
|
+
return t.setRangeText(s, o, i, "select"), n(t.value), !0;
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/editor/code-editor/sync.ts
|
|
963
|
+
function Ne(e, t) {
|
|
964
|
+
if (e === t) return {
|
|
965
|
+
from: e.length,
|
|
966
|
+
to: e.length,
|
|
967
|
+
insert: ""
|
|
968
|
+
};
|
|
969
|
+
let n = Math.min(e.length, t.length), r = 0;
|
|
970
|
+
for (; r < n && e[r] === t[r];) r++;
|
|
971
|
+
let i = e.length, a = t.length;
|
|
972
|
+
for (; i > r && a > r && e[i - 1] === t[a - 1];) i--, a--;
|
|
973
|
+
return {
|
|
974
|
+
from: r,
|
|
975
|
+
to: i,
|
|
976
|
+
insert: t.slice(r, a)
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
function M(e, t) {
|
|
980
|
+
return e <= t.from ? e : e >= t.to ? e + (t.insert.length - (t.to - t.from)) : t.from + t.insert.length;
|
|
981
|
+
}
|
|
982
|
+
function Pe(e, t, n) {
|
|
983
|
+
return {
|
|
984
|
+
start: M(e, n),
|
|
985
|
+
end: M(t, n)
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/editor/code-editor/caret.ts
|
|
990
|
+
function N(e, t) {
|
|
991
|
+
let n = 0;
|
|
992
|
+
for (let r of e) r === " " ? n += t - n % t : n += 1;
|
|
993
|
+
return n;
|
|
994
|
+
}
|
|
995
|
+
function Fe(e, t, n) {
|
|
996
|
+
let { line: r, col: i } = Se(e, t), a = N(e.slice(t - i, t), n.tabSize);
|
|
997
|
+
return {
|
|
998
|
+
top: r * n.lineHeight - n.scrollTop + n.padTop,
|
|
999
|
+
left: a * n.charWidth - n.scrollLeft + n.padLeft
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
function Ie(e, t) {
|
|
1003
|
+
if (typeof document > "u") return null;
|
|
1004
|
+
let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0, i = n.nextNode();
|
|
1005
|
+
for (; i;) {
|
|
1006
|
+
let e = i.textContent?.length ?? 0;
|
|
1007
|
+
if (t <= r + e) {
|
|
1008
|
+
let e = document.createRange();
|
|
1009
|
+
e.setStart(i, Math.max(0, t - r)), e.collapse(!0);
|
|
1010
|
+
let n = e.getClientRects();
|
|
1011
|
+
return n.length > 0 ? n[0] : e.getBoundingClientRect();
|
|
1012
|
+
}
|
|
1013
|
+
r += e, i = n.nextNode();
|
|
1014
|
+
}
|
|
1015
|
+
return null;
|
|
1016
|
+
}
|
|
1017
|
+
function Le(e) {
|
|
1018
|
+
if (typeof document > "u") return 0;
|
|
1019
|
+
let t = getComputedStyle(e), n = document.createElement("span");
|
|
1020
|
+
n.style.position = "absolute", n.style.visibility = "hidden", n.style.whiteSpace = "pre", n.style.font = t.font, n.style.letterSpacing = t.letterSpacing, n.style.tabSize = t.tabSize, n.textContent = "0".repeat(10), document.body.appendChild(n);
|
|
1021
|
+
let r = n.getBoundingClientRect().width / 10;
|
|
1022
|
+
return n.remove(), r;
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/editor/code-editor/slash-trigger.ts
|
|
1026
|
+
function Re(e, t) {
|
|
1027
|
+
for (let n = t - 1; n >= 0; n--) {
|
|
1028
|
+
let r = e[n];
|
|
1029
|
+
if (r === "/") {
|
|
1030
|
+
let r = e[n - 1];
|
|
1031
|
+
return r === void 0 || /\s/.test(r) ? {
|
|
1032
|
+
start: n,
|
|
1033
|
+
query: e.slice(n + 1, t)
|
|
1034
|
+
} : null;
|
|
1035
|
+
}
|
|
1036
|
+
if (r === void 0 || /\s/.test(r)) return null;
|
|
1037
|
+
}
|
|
1038
|
+
return null;
|
|
1039
|
+
}
|
|
1040
|
+
function ze(e, t) {
|
|
1041
|
+
if (t === "") return [...e];
|
|
1042
|
+
let n = t.toLowerCase();
|
|
1043
|
+
return e.filter((e) => e.label.toLowerCase().includes(n) || (e.keywords?.some((e) => e.toLowerCase().includes(n)) ?? !1));
|
|
1044
|
+
}
|
|
1045
|
+
var P = {
|
|
1046
|
+
menu: "_menu_zkolh_2",
|
|
1047
|
+
option: "_option_zkolh_24",
|
|
1048
|
+
active: "_active_zkolh_35",
|
|
1049
|
+
label: "_label_zkolh_39",
|
|
1050
|
+
hint: "_hint_zkolh_44",
|
|
1051
|
+
empty: "_empty_zkolh_50"
|
|
1052
|
+
}, Be = l(function({ id: t, items: n, activeIndex: r, onSelect: i, onHover: a, style: l }, u) {
|
|
1053
|
+
return o(), /* @__PURE__ */ f("ul", {
|
|
1054
|
+
ref: u,
|
|
1055
|
+
id: t,
|
|
1056
|
+
className: P.menu,
|
|
1057
|
+
role: "listbox",
|
|
1058
|
+
"aria-label": c(s.editor.commandMenu),
|
|
1059
|
+
style: l,
|
|
1060
|
+
children: n.length === 0 ? /* @__PURE__ */ f("li", {
|
|
1061
|
+
className: P.empty,
|
|
1062
|
+
role: "presentation",
|
|
1063
|
+
children: c(s.editor.commandMenuEmpty)
|
|
1064
|
+
}) : n.map((n, o) => /* @__PURE__ */ p("li", {
|
|
1065
|
+
id: `${t}-opt-${o}`,
|
|
1066
|
+
role: "option",
|
|
1067
|
+
"aria-selected": o === r,
|
|
1068
|
+
className: e(P.option, o === r && P.active),
|
|
1069
|
+
onMouseEnter: () => a(o),
|
|
1070
|
+
onMouseDown: (e) => {
|
|
1071
|
+
e.preventDefault(), i(o);
|
|
1072
|
+
},
|
|
1073
|
+
children: [/* @__PURE__ */ f("span", {
|
|
1074
|
+
className: P.label,
|
|
1075
|
+
children: n.label
|
|
1076
|
+
}), n.hint !== void 0 && /* @__PURE__ */ f("span", {
|
|
1077
|
+
className: P.hint,
|
|
1078
|
+
children: n.hint
|
|
1079
|
+
})]
|
|
1080
|
+
}, n.id))
|
|
1081
|
+
});
|
|
1082
|
+
}), Ve = 2e3, F = l(function({ value: l, defaultValue: ee, onValueChange: m, language: te = "plaintext", lineNumbers: h = !0, tabSize: g = 2, insertSpaces: _ = !0, wrap: v = !1, virtualize: y, readOnly: b = !1, disabled: x = !1, spellCheck: oe = !1, label: se, onSave: ce, keymap: le, decorations: S, theme: ue, bracketMatching: de = !1, commands: C, className: fe, style: pe, onKeyDown: me, ...he }, ge) {
|
|
1083
|
+
o();
|
|
1084
|
+
let E = d(ce);
|
|
1085
|
+
E.current = ce;
|
|
1086
|
+
let [D, be] = n({
|
|
1087
|
+
value: l,
|
|
1088
|
+
defaultValue: ee ?? "",
|
|
1089
|
+
onChange: m
|
|
1090
|
+
}), O = d(null), k = d(null), A = d(null), j = d(null), Oe = d([]), ke = d(null);
|
|
1091
|
+
ke.current === null && (ke.current = De(), ke.current.reset({
|
|
1092
|
+
text: D.value,
|
|
1093
|
+
selectionStart: 0,
|
|
1094
|
+
selectionEnd: 0
|
|
1095
|
+
}));
|
|
1096
|
+
let M = ke.current, N = d(null), P = d(void 0), F = d(D.value), He = d(void 0), I = d(!1), L = d({
|
|
1097
|
+
start: 0,
|
|
1098
|
+
end: 0
|
|
1099
|
+
}), R = (e, t, n) => {
|
|
1100
|
+
He.current = e, F.current = e, M.record({
|
|
1101
|
+
text: e,
|
|
1102
|
+
selectionStart: t.start,
|
|
1103
|
+
selectionEnd: t.end
|
|
1104
|
+
}, { coalesce: n }), be(e);
|
|
1105
|
+
}, Ue = (e) => {
|
|
1106
|
+
let t = j.current;
|
|
1107
|
+
R(e, t ? {
|
|
1108
|
+
start: t.selectionStart,
|
|
1109
|
+
end: t.selectionEnd
|
|
1110
|
+
} : L.current, !1);
|
|
1111
|
+
}, We = (e) => {
|
|
1112
|
+
let t = j.current;
|
|
1113
|
+
if (!t) return;
|
|
1114
|
+
I.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd), be(e.text), He.current = e.text, F.current = e.text, L.current = {
|
|
1115
|
+
start: e.selectionStart,
|
|
1116
|
+
end: e.selectionEnd
|
|
1117
|
+
}, U.value = e.selectionStart;
|
|
1118
|
+
let n = e.text.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1119
|
+
O.current?.style.setProperty("--cascivo-editor-caret-line", String(n)), I.current = !1;
|
|
1120
|
+
}, Ge = () => {
|
|
1121
|
+
let e = M.undo();
|
|
1122
|
+
e && We(e);
|
|
1123
|
+
}, Ke = () => {
|
|
1124
|
+
let e = M.redo();
|
|
1125
|
+
e && We(e);
|
|
1126
|
+
}, z = i(D.value), qe = i(0), Je = i(0), B = i(0), V = i(!1), Ye = i(""), Xe = i(""), Ze = i(!1), Qe = i(!1), H = i(0), U = i(0), $e = i(0), W = i(!1), et = i(0), tt = i(""), G = i(0), nt = i(-1), rt = i(0), it = d(null), at = d(null), ot = r("slash-menu");
|
|
1127
|
+
a(() => {
|
|
1128
|
+
let e = D.value;
|
|
1129
|
+
if (typeof requestAnimationFrame != "function") {
|
|
1130
|
+
z.value = e;
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
let t = requestAnimationFrame(() => {
|
|
1134
|
+
z.value = e;
|
|
1135
|
+
});
|
|
1136
|
+
return () => cancelAnimationFrame(t);
|
|
1137
|
+
}), a(() => {
|
|
1138
|
+
let e = D.value;
|
|
1139
|
+
if (I.current || e === F.current) return;
|
|
1140
|
+
if (e === He.current) {
|
|
1141
|
+
F.current = e;
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
let t = j.current, n = Ne(F.current, e), r = Pe(L.current.start, L.current.end, n);
|
|
1145
|
+
t && (I.current = !0, t.value !== e && (t.value = e), t.setSelectionRange(r.start, r.end), I.current = !1), L.current = r, M.reset({
|
|
1146
|
+
text: e,
|
|
1147
|
+
selectionStart: r.start,
|
|
1148
|
+
selectionEnd: r.end
|
|
1149
|
+
}), F.current = e;
|
|
1150
|
+
}), a(() => {
|
|
1151
|
+
let e = j.current;
|
|
1152
|
+
if (!e) return;
|
|
1153
|
+
let t = () => {
|
|
1154
|
+
let t = Number.parseFloat(getComputedStyle(e).lineHeight);
|
|
1155
|
+
B.value = Number.isFinite(t) && t > 0 ? t : 0, Je.value = e.clientHeight;
|
|
1156
|
+
let n = Le(e);
|
|
1157
|
+
n > 0 && (rt.value = n);
|
|
1158
|
+
}, n = () => {
|
|
1159
|
+
qe.value = e.scrollTop, Je.value = e.clientHeight, k.current && (k.current.scrollTop = e.scrollTop, k.current.scrollLeft = e.scrollLeft), A.current && (A.current.scrollTop = e.scrollTop);
|
|
1160
|
+
}, r = () => {
|
|
1161
|
+
let t = e.value.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1162
|
+
O.current?.style.setProperty("--cascivo-editor-caret-line", String(t)), L.current = {
|
|
1163
|
+
start: e.selectionStart,
|
|
1164
|
+
end: e.selectionEnd
|
|
1165
|
+
}, U.value = e.selectionStart;
|
|
1166
|
+
}, i = () => {
|
|
1167
|
+
document.activeElement === e && r();
|
|
1168
|
+
}, a = 0, o = -1, s = () => {
|
|
1169
|
+
n(), e.scrollTop === o ? a = 0 : (o = e.scrollTop, a = requestAnimationFrame(s));
|
|
1170
|
+
}, c = () => {
|
|
1171
|
+
n(), a === 0 && typeof requestAnimationFrame == "function" && (o = -1, a = requestAnimationFrame(s));
|
|
1172
|
+
};
|
|
1173
|
+
t(), r(), e.addEventListener("scroll", c), e.addEventListener("keyup", r), e.addEventListener("click", r), e.addEventListener("input", r), document.addEventListener("selectionchange", i);
|
|
1174
|
+
let l;
|
|
1175
|
+
typeof ResizeObserver < "u" && (l = new ResizeObserver(() => {
|
|
1176
|
+
t(), n();
|
|
1177
|
+
}), l.observe(e));
|
|
1178
|
+
let u = !1, d = document.fonts;
|
|
1179
|
+
return d?.ready && d.ready.then(() => {
|
|
1180
|
+
u || t();
|
|
1181
|
+
}).catch(() => {}), () => {
|
|
1182
|
+
u = !0, a !== 0 && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(a), l?.disconnect(), e.removeEventListener("scroll", c), e.removeEventListener("keyup", r), e.removeEventListener("click", r), e.removeEventListener("input", r), document.removeEventListener("selectionchange", i);
|
|
1183
|
+
};
|
|
1184
|
+
}), a(() => {
|
|
1185
|
+
let e = U.value, t = D.value;
|
|
1186
|
+
if (!C || C.length === 0 || b || x) {
|
|
1187
|
+
W.value &&= !1;
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
let n = Re(t, e);
|
|
1191
|
+
if (!n) {
|
|
1192
|
+
nt.value = -1, W.value &&= !1;
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (n.start === nt.value) {
|
|
1196
|
+
W.value &&= !1;
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
W.value || (G.value = 0), W.value = !0, et.value = n.start, tt.value = n.query;
|
|
1200
|
+
}), a(() => {
|
|
1201
|
+
if (!W.value) return;
|
|
1202
|
+
let e = it.current, t = j.current;
|
|
1203
|
+
if (!e || !t) return;
|
|
1204
|
+
let n = et.value, r = e.offsetParent, i, a, o = k.current, s = (v || D.value.includes(" ")) && o ? Ie(o, n) : null;
|
|
1205
|
+
if (s && r) {
|
|
1206
|
+
let e = r.getBoundingClientRect();
|
|
1207
|
+
i = s.bottom - e.top, a = s.left - e.left;
|
|
1208
|
+
} else {
|
|
1209
|
+
let e = getComputedStyle(t), r = Fe(D.value, n, {
|
|
1210
|
+
charWidth: rt.value,
|
|
1211
|
+
lineHeight: B.value,
|
|
1212
|
+
scrollTop: t.scrollTop,
|
|
1213
|
+
scrollLeft: t.scrollLeft,
|
|
1214
|
+
padTop: Number.parseFloat(e.paddingTop) || 0,
|
|
1215
|
+
padLeft: Number.parseFloat(e.paddingLeft) || 0,
|
|
1216
|
+
tabSize: g
|
|
1217
|
+
});
|
|
1218
|
+
i = r.top + B.value, a = r.left;
|
|
1219
|
+
}
|
|
1220
|
+
e.style.top = `${i}px`, e.style.left = `${a}px`;
|
|
1221
|
+
});
|
|
1222
|
+
let K = ae(te);
|
|
1223
|
+
(N.current === null || N.current.grammar !== K) && (N.current = ie(K), P.current = void 0);
|
|
1224
|
+
let q = N.current, st = z.value.split("\n"), J = st.length;
|
|
1225
|
+
Oe.current = st;
|
|
1226
|
+
let ct = z.value, lt = P.current;
|
|
1227
|
+
if (ct !== lt) {
|
|
1228
|
+
let e = lt === void 0 ? 0 : (() => {
|
|
1229
|
+
let e = Ne(lt, ct);
|
|
1230
|
+
return lt.slice(0, e.from).split("\n").length - 1;
|
|
1231
|
+
})();
|
|
1232
|
+
q.invalidateFrom(e), P.current = ct;
|
|
1233
|
+
}
|
|
1234
|
+
let ut = B.value > 0, Y = ut ? B.value : 20, dt = (y ?? J > 1e3) && !v, X = 0, Z = J;
|
|
1235
|
+
if (dt) if (ut) {
|
|
1236
|
+
X = Math.max(0, Math.floor(qe.value / Y) - 12);
|
|
1237
|
+
let e = Math.ceil(Je.value / Y);
|
|
1238
|
+
Z = Math.min(J, X + e + 24);
|
|
1239
|
+
} else Z = Math.min(J, 200);
|
|
1240
|
+
let ft = dt && X > q.length ? X - q.length : 0, pt = !dt || X === 0 || q.length >= X || ft <= 2e3, mt;
|
|
1241
|
+
pt ? mt = ne(K, st, X, Z, q) : ($e.value, mt = re(K, st, X, Z, K.initialState));
|
|
1242
|
+
let ht = X * Y, gt = (J - Z) * Y;
|
|
1243
|
+
a(() => {
|
|
1244
|
+
z.value, $e.value;
|
|
1245
|
+
let e = B.value, t = Oe.current, n = t.length;
|
|
1246
|
+
if (!((y ?? n > 1e3) && !v && e > 0)) return;
|
|
1247
|
+
let r = Math.max(0, Math.floor(qe.value / e) - 12);
|
|
1248
|
+
if (r === 0 || q.length >= r || q.length >= n) return;
|
|
1249
|
+
let i = () => {
|
|
1250
|
+
q.ensure(t, Math.min(r - 1, q.length + Ve)), $e.value++;
|
|
1251
|
+
};
|
|
1252
|
+
if (typeof requestAnimationFrame != "function") {
|
|
1253
|
+
i();
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
let a = requestAnimationFrame(i);
|
|
1257
|
+
return () => cancelAnimationFrame(a);
|
|
1258
|
+
});
|
|
1259
|
+
let Q = V.value ? xe(z.value, Ye.value, { caseSensitive: Ze.value }) : [];
|
|
1260
|
+
H.value >= Q.length && (H.value = Math.max(0, Q.length - 1));
|
|
1261
|
+
let _t = Q.length > 0 ? Ce(z.value, Q, H.value, {
|
|
1262
|
+
match: w.match,
|
|
1263
|
+
current: w.matchCurrent
|
|
1264
|
+
}) : [], vt = typeof S == "function" ? S(z.value) : S ?? [], yt = [];
|
|
1265
|
+
if (de) {
|
|
1266
|
+
let e = Te(z.value, U.value);
|
|
1267
|
+
e && (yt = Ee(z.value, e, w.bracketMatch));
|
|
1268
|
+
}
|
|
1269
|
+
let bt = [
|
|
1270
|
+
...vt,
|
|
1271
|
+
...yt,
|
|
1272
|
+
..._t
|
|
1273
|
+
], xt = bt.length > 0 ? bt : void 0, St = (e) => {
|
|
1274
|
+
let t = Q[e], n = j.current;
|
|
1275
|
+
if (!(!t || !n) && (n.focus(), n.setSelectionRange(t.start, t.end), L.current = {
|
|
1276
|
+
start: t.start,
|
|
1277
|
+
end: t.end
|
|
1278
|
+
}, Y > 0)) {
|
|
1279
|
+
let { line: e } = Se(n.value, t.start), r = e * Y;
|
|
1280
|
+
(r < n.scrollTop || r > n.scrollTop + n.clientHeight - Y) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
|
|
1281
|
+
}
|
|
1282
|
+
}, Ct = () => {
|
|
1283
|
+
Q.length !== 0 && (H.value = (H.value + 1) % Q.length, St(H.value));
|
|
1284
|
+
}, wt = () => {
|
|
1285
|
+
Q.length !== 0 && (H.value = (H.value - 1 + Q.length) % Q.length, St(H.value));
|
|
1286
|
+
}, Tt = () => {
|
|
1287
|
+
let e = Q[H.value], t = j.current;
|
|
1288
|
+
!e || !t || b || x || (t.setRangeText(Xe.value, e.start, e.end, "end"), R(t.value, {
|
|
1289
|
+
start: t.selectionStart,
|
|
1290
|
+
end: t.selectionEnd
|
|
1291
|
+
}, !1));
|
|
1292
|
+
}, Et = () => {
|
|
1293
|
+
if (Q.length === 0 || b || x) return;
|
|
1294
|
+
let e = we(z.value, Q, Xe.value), t = j.current;
|
|
1295
|
+
t && (t.value = e), R(e, {
|
|
1296
|
+
start: t?.selectionStart ?? 0,
|
|
1297
|
+
end: t?.selectionEnd ?? 0
|
|
1298
|
+
}, !1);
|
|
1299
|
+
}, Dt = (e) => {
|
|
1300
|
+
Qe.value = e, V.value = !0;
|
|
1301
|
+
}, Ot = () => {
|
|
1302
|
+
V.value = !1, j.current?.focus();
|
|
1303
|
+
}, $ = W.value ? ze(C ?? [], tt.value) : [];
|
|
1304
|
+
G.value >= $.length && (G.value = Math.max(0, $.length - 1));
|
|
1305
|
+
let kt = $.map((e) => ({
|
|
1306
|
+
id: e.id,
|
|
1307
|
+
label: e.label,
|
|
1308
|
+
...e.hint !== void 0 && { hint: e.hint }
|
|
1309
|
+
})), { anchorStyle: At, floatingStyle: jt } = t({
|
|
1310
|
+
anchorRef: it,
|
|
1311
|
+
floatingRef: at,
|
|
1312
|
+
placement: "bottom-start",
|
|
1313
|
+
enabled: W
|
|
1314
|
+
}), Mt = {
|
|
1315
|
+
applyEdit: ({ from: e, to: t }, n) => {
|
|
1316
|
+
let r = j.current;
|
|
1317
|
+
r && (r.setRangeText(n, e, t, "end"), R(r.value, {
|
|
1318
|
+
start: r.selectionStart,
|
|
1319
|
+
end: r.selectionEnd
|
|
1320
|
+
}, !1));
|
|
1321
|
+
},
|
|
1322
|
+
getSelection: () => {
|
|
1323
|
+
let e = j.current;
|
|
1324
|
+
return e ? {
|
|
1325
|
+
start: e.selectionStart,
|
|
1326
|
+
end: e.selectionEnd
|
|
1327
|
+
} : { ...L.current };
|
|
1328
|
+
},
|
|
1329
|
+
focus: () => j.current?.focus(),
|
|
1330
|
+
undo: Ge,
|
|
1331
|
+
redo: Ke,
|
|
1332
|
+
openFind: () => Dt(!1),
|
|
1333
|
+
openCommandMenu: () => {
|
|
1334
|
+
let e = j.current;
|
|
1335
|
+
!e || !C || C.length === 0 || b || x || (e.focus(), e.setRangeText("/", e.selectionStart, e.selectionEnd, "end"), R(e.value, {
|
|
1336
|
+
start: e.selectionStart,
|
|
1337
|
+
end: e.selectionEnd
|
|
1338
|
+
}, !1), U.value = e.selectionStart, L.current = {
|
|
1339
|
+
start: e.selectionStart,
|
|
1340
|
+
end: e.selectionEnd
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
u(ge, () => Mt);
|
|
1345
|
+
let Nt = (e) => {
|
|
1346
|
+
let t = $[e], n = j.current;
|
|
1347
|
+
if (!t || !n || b || x) return;
|
|
1348
|
+
let r = et.value, i = n.selectionStart;
|
|
1349
|
+
n.setRangeText(t.insert ?? "", r, i, "end"), R(n.value, {
|
|
1350
|
+
start: n.selectionStart,
|
|
1351
|
+
end: n.selectionEnd
|
|
1352
|
+
}, !1), U.value = n.selectionStart, L.current = {
|
|
1353
|
+
start: n.selectionStart,
|
|
1354
|
+
end: n.selectionEnd
|
|
1355
|
+
}, W.value = !1, G.value = 0, n.focus(), t.run?.(Mt);
|
|
1356
|
+
}, Pt = (e) => {
|
|
1357
|
+
let t = e.currentTarget, n = !b && !x, r = {};
|
|
1358
|
+
if (n) {
|
|
1359
|
+
let { indent: e, dedent: t } = Me({
|
|
1360
|
+
tabSize: g,
|
|
1361
|
+
insertSpaces: _
|
|
1362
|
+
});
|
|
1363
|
+
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (Ge(), !0);
|
|
1364
|
+
let n = () => (Ke(), !0);
|
|
1365
|
+
r["Mod-Shift-z"] = n, r["Mod-y"] = n;
|
|
1366
|
+
}
|
|
1367
|
+
if (r["Mod-f"] = () => (Dt(!1), !0), r["Mod-Alt-f"] = () => (Dt(!0), !0), r["Mod-s"] = () => {
|
|
1368
|
+
let e = E.current;
|
|
1369
|
+
return e ? (e(D.value), !0) : !1;
|
|
1370
|
+
}, V.value && (r.Escape = () => (Ot(), !0)), W.value) {
|
|
1371
|
+
let e = (e) => () => {
|
|
1372
|
+
let t = $.length;
|
|
1373
|
+
return t > 0 && (G.value = (G.value + e + t) % t), !0;
|
|
1374
|
+
};
|
|
1375
|
+
r.ArrowDown = e(1), r.ArrowUp = e(-1);
|
|
1376
|
+
let t = () => ($.length > 0 && Nt(G.value), !0);
|
|
1377
|
+
r.Enter = t, r.Tab = t, r.Escape = () => (nt.value = et.value, W.value = !1, !0);
|
|
1378
|
+
}
|
|
1379
|
+
je(Ae(r, le), {
|
|
1380
|
+
textarea: t,
|
|
1381
|
+
event: e,
|
|
1382
|
+
setText: Ue
|
|
1383
|
+
}) && e.preventDefault(), me?.(e);
|
|
1384
|
+
}, Ft = {
|
|
1385
|
+
"--cascivo-editor-tab-size": g,
|
|
1386
|
+
...ue,
|
|
1387
|
+
...pe
|
|
1388
|
+
};
|
|
1389
|
+
return /* @__PURE__ */ p("div", {
|
|
1390
|
+
ref: O,
|
|
1391
|
+
className: e(T.root, fe),
|
|
1392
|
+
"data-wrap": v,
|
|
1393
|
+
"data-line-numbers": h,
|
|
1394
|
+
style: Ft,
|
|
1395
|
+
children: [h && /* @__PURE__ */ f(ve, {
|
|
1396
|
+
count: J,
|
|
1397
|
+
className: T.gutter,
|
|
1398
|
+
gutterRef: A,
|
|
1399
|
+
start: X,
|
|
1400
|
+
end: Z,
|
|
1401
|
+
topPad: ht,
|
|
1402
|
+
bottomPad: gt,
|
|
1403
|
+
activeLine: !0
|
|
1404
|
+
}), /* @__PURE__ */ p("div", {
|
|
1405
|
+
className: T.codeArea,
|
|
1406
|
+
children: [
|
|
1407
|
+
/* @__PURE__ */ p("pre", {
|
|
1408
|
+
ref: k,
|
|
1409
|
+
className: T.pre,
|
|
1410
|
+
"aria-hidden": "true",
|
|
1411
|
+
children: [
|
|
1412
|
+
/* @__PURE__ */ f("div", { className: T.currentLine }),
|
|
1413
|
+
ht > 0 && /* @__PURE__ */ f("div", { style: { blockSize: ht } }),
|
|
1414
|
+
/* @__PURE__ */ f("code", { children: _e(mt, X, Z, xt) }),
|
|
1415
|
+
gt > 0 && /* @__PURE__ */ f("div", { style: { blockSize: gt } })
|
|
1416
|
+
]
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ f("textarea", {
|
|
1419
|
+
ref: j,
|
|
1420
|
+
className: T.textarea,
|
|
1421
|
+
value: D.value,
|
|
1422
|
+
onChange: (e) => {
|
|
1423
|
+
let t = e.currentTarget, n = t.value, r = Math.abs(n.length - F.current.length) === 1;
|
|
1424
|
+
R(n, {
|
|
1425
|
+
start: t.selectionStart,
|
|
1426
|
+
end: t.selectionEnd
|
|
1427
|
+
}, r);
|
|
1428
|
+
},
|
|
1429
|
+
onKeyDown: Pt,
|
|
1430
|
+
readOnly: b,
|
|
1431
|
+
disabled: x,
|
|
1432
|
+
spellCheck: oe,
|
|
1433
|
+
role: "combobox",
|
|
1434
|
+
"aria-label": se ?? c(s.editor.label),
|
|
1435
|
+
"aria-expanded": W.value,
|
|
1436
|
+
"aria-controls": W.value ? ot : void 0,
|
|
1437
|
+
"aria-activedescendant": W.value ? `${ot}-opt-${G.value}` : void 0,
|
|
1438
|
+
autoCapitalize: "off",
|
|
1439
|
+
autoCorrect: "off",
|
|
1440
|
+
autoComplete: "off",
|
|
1441
|
+
wrap: v ? "soft" : "off",
|
|
1442
|
+
...he
|
|
1443
|
+
}),
|
|
1444
|
+
/* @__PURE__ */ f("div", {
|
|
1445
|
+
ref: it,
|
|
1446
|
+
"aria-hidden": "true",
|
|
1447
|
+
style: {
|
|
1448
|
+
position: "absolute",
|
|
1449
|
+
inlineSize: 0,
|
|
1450
|
+
blockSize: 0,
|
|
1451
|
+
...At
|
|
1452
|
+
}
|
|
1453
|
+
}),
|
|
1454
|
+
W.value && /* @__PURE__ */ f(Be, {
|
|
1455
|
+
ref: at,
|
|
1456
|
+
id: ot,
|
|
1457
|
+
items: kt,
|
|
1458
|
+
activeIndex: G.value,
|
|
1459
|
+
onSelect: Nt,
|
|
1460
|
+
onHover: (e) => G.value = e,
|
|
1461
|
+
style: jt
|
|
1462
|
+
}),
|
|
1463
|
+
V.value && /* @__PURE__ */ f(ye, {
|
|
1464
|
+
query: Ye.value,
|
|
1465
|
+
replaceQuery: Xe.value,
|
|
1466
|
+
replaceMode: Qe.value,
|
|
1467
|
+
caseSensitive: Ze.value,
|
|
1468
|
+
matchCount: Q.length,
|
|
1469
|
+
currentIndex: Q.length > 0 ? H.value : -1,
|
|
1470
|
+
onQueryChange: (e) => {
|
|
1471
|
+
Ye.value = e, H.value = 0;
|
|
1472
|
+
},
|
|
1473
|
+
onReplaceChange: (e) => Xe.value = e,
|
|
1474
|
+
onNext: Ct,
|
|
1475
|
+
onPrev: wt,
|
|
1476
|
+
onReplace: Tt,
|
|
1477
|
+
onReplaceAll: Et,
|
|
1478
|
+
onToggleCase: () => Ze.value = !Ze.value,
|
|
1479
|
+
onToggleReplace: () => Qe.value = !Qe.value,
|
|
1480
|
+
onClose: Ot
|
|
1481
|
+
})
|
|
1482
|
+
]
|
|
1483
|
+
})]
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
//#endregion
|
|
1487
|
+
//#region src/editor/highlight/highlight.tsx
|
|
1488
|
+
function He({ value: t, language: n = "plaintext", lineNumbers: r = !1, wrap: i = !1, tabSize: a = 2, label: s, className: c, preRef: l, gutterRef: u, style: d, ...ee }) {
|
|
1489
|
+
o();
|
|
1490
|
+
let m = ae(n), te = t.split("\n"), h = ne(m, te, 0, te.length, ie(m)), g = {
|
|
1491
|
+
"--cascivo-editor-tab-size": a,
|
|
1492
|
+
...d
|
|
1493
|
+
};
|
|
1494
|
+
return /* @__PURE__ */ p("div", {
|
|
1495
|
+
className: e(w.root, c),
|
|
1496
|
+
"data-wrap": i,
|
|
1497
|
+
"data-line-numbers": r,
|
|
1498
|
+
style: g,
|
|
1499
|
+
"aria-label": s,
|
|
1500
|
+
...ee,
|
|
1501
|
+
children: [r && /* @__PURE__ */ f(ve, {
|
|
1502
|
+
count: h.length,
|
|
1503
|
+
className: w.gutter,
|
|
1504
|
+
gutterRef: u
|
|
1505
|
+
}), /* @__PURE__ */ f("pre", {
|
|
1506
|
+
ref: l,
|
|
1507
|
+
className: w.pre,
|
|
1508
|
+
children: /* @__PURE__ */ f("code", {
|
|
1509
|
+
className: w.code,
|
|
1510
|
+
children: _e(h)
|
|
1511
|
+
})
|
|
1512
|
+
})]
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
//#endregion
|
|
1516
|
+
export { F as CodeEditor, He as Highlight, me as bash, ie as createLineStateIndex, x as createRuleGrammar, C as css, ae as getGrammar, fe as html, ue as javascript, se as json, b as listGrammars, pe as markdown, oe as plaintext, y as registerGrammar, h as tokenize, g as tokenizeDocument, ne as tokenizeRange, de as typescript };
|