@cascivo/editor 0.2.5 → 0.2.6
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 +430 -387
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
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
3
|
import { builtin as s, t as c } from "@cascivo/i18n";
|
|
4
|
-
import { forwardRef as l, useImperativeHandle as
|
|
5
|
-
import { jsx as
|
|
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
6
|
//#region src/engine/tokenize.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let r = `${e.name}${m}${n}${m}${t}`, i =
|
|
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
10
|
if (i) return i;
|
|
11
|
-
|
|
11
|
+
te++;
|
|
12
12
|
let { tokens: a, state: o } = e.tokenizeLine(t, n), s = {
|
|
13
13
|
tokens: a,
|
|
14
14
|
endState: o
|
|
15
15
|
};
|
|
16
|
-
return
|
|
16
|
+
return ee.set(r, s), s;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function g(e, t) {
|
|
19
19
|
let n = t.split("\n"), r = [], i = e.initialState;
|
|
20
20
|
for (let t of n) {
|
|
21
|
-
let n =
|
|
21
|
+
let n = h(e, t, i);
|
|
22
22
|
r.push(n.tokens), i = n.endState;
|
|
23
23
|
}
|
|
24
24
|
return r;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function ne(e, t, n, r, i) {
|
|
27
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
28
|
for (let n = a; n < o; n++) {
|
|
29
|
-
let r =
|
|
29
|
+
let r = h(e, t[n], s);
|
|
30
30
|
c.push(r.tokens), i.setEndState(n, r.endState), s = r.endState;
|
|
31
31
|
}
|
|
32
32
|
return c;
|
|
33
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
|
+
}
|
|
34
42
|
//#endregion
|
|
35
43
|
//#region src/engine/line-state.ts
|
|
36
|
-
function
|
|
44
|
+
function ie(e) {
|
|
37
45
|
let t = [], n = (n, r) => {
|
|
38
46
|
let i = Math.min(r, n.length - 1), a = t.length;
|
|
39
47
|
if (a > i) return;
|
|
40
48
|
let o = a === 0 ? e.initialState : t[a - 1];
|
|
41
49
|
for (; a <= i; a++) {
|
|
42
|
-
let r =
|
|
50
|
+
let r = h(e, n[a], o);
|
|
43
51
|
t[a] = r.endState, o = r.endState;
|
|
44
52
|
}
|
|
45
53
|
};
|
|
@@ -61,7 +69,7 @@ function ne(e) {
|
|
|
61
69
|
}
|
|
62
70
|
//#endregion
|
|
63
71
|
//#region src/engine/registry.ts
|
|
64
|
-
var
|
|
72
|
+
var _ = /* @__PURE__ */ new Map(), v = {
|
|
65
73
|
name: "plaintext",
|
|
66
74
|
initialState: "default",
|
|
67
75
|
tokenizeLine: (e) => ({
|
|
@@ -72,23 +80,23 @@ var v = /* @__PURE__ */ new Map(), y = {
|
|
|
72
80
|
state: "default"
|
|
73
81
|
})
|
|
74
82
|
};
|
|
75
|
-
|
|
76
|
-
function
|
|
77
|
-
|
|
83
|
+
_.set(v.name, v);
|
|
84
|
+
function y(e) {
|
|
85
|
+
_.set(e.name, e);
|
|
78
86
|
}
|
|
79
|
-
function
|
|
87
|
+
function ae(e) {
|
|
80
88
|
if (e !== void 0) {
|
|
81
|
-
let t =
|
|
89
|
+
let t = _.get(e);
|
|
82
90
|
if (t) return t;
|
|
83
91
|
}
|
|
84
|
-
return
|
|
92
|
+
return _.get("plaintext");
|
|
85
93
|
}
|
|
86
|
-
function
|
|
87
|
-
return [...
|
|
94
|
+
function b() {
|
|
95
|
+
return [..._.keys()];
|
|
88
96
|
}
|
|
89
97
|
//#endregion
|
|
90
98
|
//#region src/grammars/rules.ts
|
|
91
|
-
function
|
|
99
|
+
function x(e) {
|
|
92
100
|
let t = {};
|
|
93
101
|
for (let [n, r] of Object.entries(e.states)) t[n] = r.map((e) => {
|
|
94
102
|
let t = `${e.match.flags.replace(/[gy]/g, "")}y`, n = {
|
|
@@ -131,7 +139,7 @@ function S(e) {
|
|
|
131
139
|
}
|
|
132
140
|
//#endregion
|
|
133
141
|
//#region src/grammars/plaintext.ts
|
|
134
|
-
var
|
|
142
|
+
var oe = {
|
|
135
143
|
name: "plaintext",
|
|
136
144
|
initialState: "default",
|
|
137
145
|
tokenizeLine: (e) => ({
|
|
@@ -142,10 +150,10 @@ var ie = {
|
|
|
142
150
|
state: "default"
|
|
143
151
|
})
|
|
144
152
|
};
|
|
145
|
-
|
|
153
|
+
y(oe);
|
|
146
154
|
//#endregion
|
|
147
155
|
//#region src/grammars/json.ts
|
|
148
|
-
var
|
|
156
|
+
var se = x({
|
|
149
157
|
name: "json",
|
|
150
158
|
states: { default: [
|
|
151
159
|
{
|
|
@@ -174,14 +182,14 @@ var ae = S({
|
|
|
174
182
|
}
|
|
175
183
|
] }
|
|
176
184
|
});
|
|
177
|
-
|
|
185
|
+
y(se);
|
|
178
186
|
//#endregion
|
|
179
187
|
//#region src/grammars/clike.ts
|
|
180
|
-
var
|
|
181
|
-
function
|
|
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) {
|
|
182
190
|
return RegExp(`(?:${e.join("|")})\\b`);
|
|
183
191
|
}
|
|
184
|
-
function
|
|
192
|
+
function S(e, t, n = []) {
|
|
185
193
|
let r = [
|
|
186
194
|
{
|
|
187
195
|
match: /\/\/.*/,
|
|
@@ -215,10 +223,10 @@ function C(e, t, n = []) {
|
|
|
215
223
|
}
|
|
216
224
|
];
|
|
217
225
|
return n.length > 0 && r.push({
|
|
218
|
-
match:
|
|
226
|
+
match: le(n),
|
|
219
227
|
kind: "type"
|
|
220
228
|
}), r.push({
|
|
221
|
-
match:
|
|
229
|
+
match: le(t),
|
|
222
230
|
kind: "keyword"
|
|
223
231
|
}, {
|
|
224
232
|
match: /[A-Za-z_$][\w$]*(?=\s*\()/,
|
|
@@ -235,7 +243,7 @@ function C(e, t, n = []) {
|
|
|
235
243
|
}, {
|
|
236
244
|
match: /[{}()[\];,.:]/,
|
|
237
245
|
kind: "punctuation"
|
|
238
|
-
}),
|
|
246
|
+
}), x({
|
|
239
247
|
name: e,
|
|
240
248
|
states: {
|
|
241
249
|
default: r,
|
|
@@ -282,9 +290,9 @@ function C(e, t, n = []) {
|
|
|
282
290
|
}
|
|
283
291
|
//#endregion
|
|
284
292
|
//#region src/grammars/javascript.ts
|
|
285
|
-
var
|
|
286
|
-
|
|
287
|
-
var
|
|
293
|
+
var ue = S("javascript", ce);
|
|
294
|
+
y(ue);
|
|
295
|
+
var de = S("typescript", ce, [
|
|
288
296
|
"interface",
|
|
289
297
|
"type",
|
|
290
298
|
"enum",
|
|
@@ -310,10 +318,10 @@ var le = C("typescript", oe, [
|
|
|
310
318
|
"never",
|
|
311
319
|
"object"
|
|
312
320
|
]);
|
|
313
|
-
|
|
321
|
+
y(de);
|
|
314
322
|
//#endregion
|
|
315
323
|
//#region src/grammars/css.ts
|
|
316
|
-
var
|
|
324
|
+
var C = x({
|
|
317
325
|
name: "css",
|
|
318
326
|
states: {
|
|
319
327
|
default: [
|
|
@@ -380,10 +388,10 @@ var w = S({
|
|
|
380
388
|
]
|
|
381
389
|
}
|
|
382
390
|
});
|
|
383
|
-
|
|
391
|
+
y(C);
|
|
384
392
|
//#endregion
|
|
385
393
|
//#region src/grammars/html.ts
|
|
386
|
-
var
|
|
394
|
+
var fe = x({
|
|
387
395
|
name: "html",
|
|
388
396
|
states: {
|
|
389
397
|
default: [
|
|
@@ -442,10 +450,10 @@ var ue = S({
|
|
|
442
450
|
]
|
|
443
451
|
}
|
|
444
452
|
});
|
|
445
|
-
|
|
453
|
+
y(fe);
|
|
446
454
|
//#endregion
|
|
447
455
|
//#region src/grammars/markdown.ts
|
|
448
|
-
var
|
|
456
|
+
var pe = x({
|
|
449
457
|
name: "markdown",
|
|
450
458
|
states: {
|
|
451
459
|
default: [
|
|
@@ -518,10 +526,10 @@ var de = S({
|
|
|
518
526
|
}]
|
|
519
527
|
}
|
|
520
528
|
});
|
|
521
|
-
|
|
529
|
+
y(pe);
|
|
522
530
|
//#endregion
|
|
523
531
|
//#region src/grammars/bash.ts
|
|
524
|
-
var
|
|
532
|
+
var me = x({
|
|
525
533
|
name: "bash",
|
|
526
534
|
states: { default: [
|
|
527
535
|
{
|
|
@@ -558,8 +566,8 @@ var fe = S({
|
|
|
558
566
|
}
|
|
559
567
|
] }
|
|
560
568
|
});
|
|
561
|
-
|
|
562
|
-
var
|
|
569
|
+
y(me);
|
|
570
|
+
var w = {
|
|
563
571
|
root: "_root_1m6ns_2",
|
|
564
572
|
gutter: "_gutter_1m6ns_17",
|
|
565
573
|
gutterLine: "_gutterLine_1m6ns_28",
|
|
@@ -588,77 +596,77 @@ var T = {
|
|
|
588
596
|
};
|
|
589
597
|
//#endregion
|
|
590
598
|
//#region src/editor/view.tsx
|
|
591
|
-
function
|
|
599
|
+
function he(e, t) {
|
|
592
600
|
let n = "";
|
|
593
601
|
for (let r of t) e >= r.start && e < r.end && (n = n ? `${n} ${r.className}` : r.className);
|
|
594
602
|
return n;
|
|
595
603
|
}
|
|
596
|
-
function
|
|
604
|
+
function ge(t, n, r, i) {
|
|
597
605
|
let a = n + t.value.length, o = new Set([n, a]);
|
|
598
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);
|
|
599
607
|
if (o.size === 2) {
|
|
600
|
-
let a =
|
|
601
|
-
return /* @__PURE__ */
|
|
602
|
-
className: a ? e(
|
|
608
|
+
let a = he(n, r);
|
|
609
|
+
return /* @__PURE__ */ f("span", {
|
|
610
|
+
className: a ? e(w[t.kind], a) : w[t.kind],
|
|
603
611
|
children: t.value
|
|
604
612
|
}, i);
|
|
605
613
|
}
|
|
606
614
|
let s = [...o].sort((e, t) => e - t), c = [];
|
|
607
615
|
for (let i = 0; i < s.length - 1; i++) {
|
|
608
|
-
let a = s[i], o = s[i + 1], l =
|
|
609
|
-
c.push(/* @__PURE__ */
|
|
610
|
-
className: l ? e(
|
|
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],
|
|
611
619
|
children: t.value.slice(a - n, o - n)
|
|
612
620
|
}, a));
|
|
613
621
|
}
|
|
614
|
-
return /* @__PURE__ */
|
|
622
|
+
return /* @__PURE__ */ f("span", { children: c }, i);
|
|
615
623
|
}
|
|
616
|
-
function
|
|
624
|
+
function _e(e, t = 0, n = t + e.length, r) {
|
|
617
625
|
let i = [];
|
|
618
626
|
for (let a = t; a < n; a++) {
|
|
619
627
|
let n = e[a - t], o = r?.filter((e) => e.line === a);
|
|
620
|
-
i.push(/* @__PURE__ */
|
|
621
|
-
className:
|
|
628
|
+
i.push(/* @__PURE__ */ f("span", {
|
|
629
|
+
className: w.line,
|
|
622
630
|
children: n.length === 0 ? "" : o && o.length > 0 ? (() => {
|
|
623
631
|
let e = 0;
|
|
624
632
|
return n.map((t, n) => {
|
|
625
|
-
let r =
|
|
633
|
+
let r = ge(t, e, o, n);
|
|
626
634
|
return e += t.value.length, r;
|
|
627
635
|
});
|
|
628
|
-
})() : n.map((e, t) => /* @__PURE__ */
|
|
629
|
-
className:
|
|
636
|
+
})() : n.map((e, t) => /* @__PURE__ */ f("span", {
|
|
637
|
+
className: w[e.kind],
|
|
630
638
|
children: e.value
|
|
631
639
|
}, t))
|
|
632
640
|
}, a));
|
|
633
641
|
}
|
|
634
642
|
return i;
|
|
635
643
|
}
|
|
636
|
-
function
|
|
644
|
+
function ve({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
|
|
637
645
|
let c = [];
|
|
638
|
-
for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */
|
|
639
|
-
className:
|
|
646
|
+
for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ f("span", {
|
|
647
|
+
className: w.gutterLine,
|
|
640
648
|
children: e
|
|
641
649
|
}, e));
|
|
642
|
-
return /* @__PURE__ */
|
|
650
|
+
return /* @__PURE__ */ p("div", {
|
|
643
651
|
ref: n,
|
|
644
652
|
className: t,
|
|
645
653
|
"aria-hidden": "true",
|
|
646
654
|
children: [
|
|
647
|
-
s && /* @__PURE__ */
|
|
648
|
-
a > 0 && /* @__PURE__ */
|
|
655
|
+
s && /* @__PURE__ */ f("div", { className: w.gutterActive }),
|
|
656
|
+
a > 0 && /* @__PURE__ */ f("div", { style: { blockSize: a } }),
|
|
649
657
|
c,
|
|
650
|
-
o > 0 && /* @__PURE__ */
|
|
658
|
+
o > 0 && /* @__PURE__ */ f("div", { style: { blockSize: o } })
|
|
651
659
|
]
|
|
652
660
|
});
|
|
653
661
|
}
|
|
654
|
-
var
|
|
662
|
+
var T = {
|
|
655
663
|
root: "_root_18xci_2",
|
|
656
664
|
textarea: "_textarea_18xci_18",
|
|
657
665
|
gutter: "_gutter_18xci_23",
|
|
658
666
|
codeArea: "_codeArea_18xci_36",
|
|
659
667
|
pre: "_pre_18xci_43",
|
|
660
668
|
currentLine: "_currentLine_18xci_58"
|
|
661
|
-
},
|
|
669
|
+
}, E = {
|
|
662
670
|
panel: "_panel_hawkv_2",
|
|
663
671
|
row: "_row_hawkv_20",
|
|
664
672
|
input: "_input_hawkv_26",
|
|
@@ -669,29 +677,29 @@ var E = {
|
|
|
669
677
|
};
|
|
670
678
|
//#endregion
|
|
671
679
|
//#region src/editor/code-editor/find-panel.tsx
|
|
672
|
-
function
|
|
680
|
+
function ye(t) {
|
|
673
681
|
o();
|
|
674
682
|
let n = t.matchCount === 0 ? c(s.editor.noMatches) : c(s.editor.findCount, {
|
|
675
683
|
current: t.currentIndex + 1,
|
|
676
684
|
total: t.matchCount
|
|
677
685
|
});
|
|
678
|
-
return /* @__PURE__ */
|
|
679
|
-
className:
|
|
686
|
+
return /* @__PURE__ */ p("div", {
|
|
687
|
+
className: E.panel,
|
|
680
688
|
role: "search",
|
|
681
689
|
"aria-label": c(s.editor.find),
|
|
682
|
-
children: [/* @__PURE__ */
|
|
683
|
-
className:
|
|
690
|
+
children: [/* @__PURE__ */ p("div", {
|
|
691
|
+
className: E.row,
|
|
684
692
|
children: [
|
|
685
|
-
/* @__PURE__ */
|
|
693
|
+
/* @__PURE__ */ f("button", {
|
|
686
694
|
type: "button",
|
|
687
|
-
className:
|
|
695
|
+
className: E.toggle,
|
|
688
696
|
"aria-label": c(s.editor.toggleReplace),
|
|
689
697
|
"aria-expanded": t.replaceMode,
|
|
690
698
|
onClick: t.onToggleReplace,
|
|
691
699
|
children: t.replaceMode ? "▾" : "▸"
|
|
692
700
|
}),
|
|
693
|
-
/* @__PURE__ */
|
|
694
|
-
className:
|
|
701
|
+
/* @__PURE__ */ f("input", {
|
|
702
|
+
className: E.input,
|
|
695
703
|
value: t.query,
|
|
696
704
|
placeholder: c(s.editor.findPlaceholder),
|
|
697
705
|
"aria-label": c(s.editor.find),
|
|
@@ -703,46 +711,46 @@ function _e(t) {
|
|
|
703
711
|
e.key === "Enter" ? (e.preventDefault(), e.shiftKey ? t.onPrev() : t.onNext()) : e.key === "Escape" && (e.preventDefault(), t.onClose());
|
|
704
712
|
}
|
|
705
713
|
}),
|
|
706
|
-
/* @__PURE__ */
|
|
707
|
-
className:
|
|
714
|
+
/* @__PURE__ */ f("span", {
|
|
715
|
+
className: E.count,
|
|
708
716
|
"aria-live": "polite",
|
|
709
717
|
children: n
|
|
710
718
|
}),
|
|
711
|
-
/* @__PURE__ */
|
|
719
|
+
/* @__PURE__ */ f("button", {
|
|
712
720
|
type: "button",
|
|
713
|
-
className:
|
|
721
|
+
className: E.button,
|
|
714
722
|
"aria-label": c(s.editor.previous),
|
|
715
723
|
onClick: t.onPrev,
|
|
716
724
|
children: "‹"
|
|
717
725
|
}),
|
|
718
|
-
/* @__PURE__ */
|
|
726
|
+
/* @__PURE__ */ f("button", {
|
|
719
727
|
type: "button",
|
|
720
|
-
className:
|
|
728
|
+
className: E.button,
|
|
721
729
|
"aria-label": c(s.editor.next),
|
|
722
730
|
onClick: t.onNext,
|
|
723
731
|
children: "›"
|
|
724
732
|
}),
|
|
725
|
-
/* @__PURE__ */
|
|
733
|
+
/* @__PURE__ */ f("button", {
|
|
726
734
|
type: "button",
|
|
727
|
-
className: e(
|
|
735
|
+
className: e(E.button, t.caseSensitive && E.active),
|
|
728
736
|
"aria-pressed": t.caseSensitive,
|
|
729
737
|
"aria-label": c(s.editor.matchCase),
|
|
730
738
|
onClick: t.onToggleCase,
|
|
731
739
|
children: "Aa"
|
|
732
740
|
}),
|
|
733
|
-
/* @__PURE__ */
|
|
741
|
+
/* @__PURE__ */ f("button", {
|
|
734
742
|
type: "button",
|
|
735
|
-
className:
|
|
743
|
+
className: E.button,
|
|
736
744
|
"aria-label": c(s.editor.close),
|
|
737
745
|
onClick: t.onClose,
|
|
738
746
|
children: "×"
|
|
739
747
|
})
|
|
740
748
|
]
|
|
741
|
-
}), t.replaceMode && /* @__PURE__ */
|
|
742
|
-
className:
|
|
749
|
+
}), t.replaceMode && /* @__PURE__ */ p("div", {
|
|
750
|
+
className: E.row,
|
|
743
751
|
children: [
|
|
744
|
-
/* @__PURE__ */
|
|
745
|
-
className:
|
|
752
|
+
/* @__PURE__ */ f("input", {
|
|
753
|
+
className: E.input,
|
|
746
754
|
value: t.replaceQuery,
|
|
747
755
|
placeholder: c(s.editor.replacePlaceholder),
|
|
748
756
|
"aria-label": c(s.editor.replace),
|
|
@@ -753,15 +761,15 @@ function _e(t) {
|
|
|
753
761
|
e.key === "Escape" ? (e.preventDefault(), t.onClose()) : e.key === "Enter" && (e.preventDefault(), t.onReplace());
|
|
754
762
|
}
|
|
755
763
|
}),
|
|
756
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ f("button", {
|
|
757
765
|
type: "button",
|
|
758
|
-
className:
|
|
766
|
+
className: E.button,
|
|
759
767
|
onClick: t.onReplace,
|
|
760
768
|
children: c(s.editor.replaceOne)
|
|
761
769
|
}),
|
|
762
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ f("button", {
|
|
763
771
|
type: "button",
|
|
764
|
-
className:
|
|
772
|
+
className: E.button,
|
|
765
773
|
onClick: t.onReplaceAll,
|
|
766
774
|
children: c(s.editor.replaceAll)
|
|
767
775
|
})
|
|
@@ -771,25 +779,25 @@ function _e(t) {
|
|
|
771
779
|
}
|
|
772
780
|
//#endregion
|
|
773
781
|
//#region src/editor/code-editor/find.ts
|
|
774
|
-
var
|
|
775
|
-
function
|
|
776
|
-
return e !== void 0 &&
|
|
782
|
+
var D = /\w/;
|
|
783
|
+
function be(e) {
|
|
784
|
+
return e !== void 0 && D.test(e);
|
|
777
785
|
}
|
|
778
|
-
function
|
|
786
|
+
function xe(e, t, n = {}) {
|
|
779
787
|
if (t.length === 0) return [];
|
|
780
788
|
let r = n.caseSensitive ? e : e.toLowerCase(), i = n.caseSensitive ? t : t.toLowerCase(), a = [], o = 0;
|
|
781
789
|
for (;;) {
|
|
782
790
|
let t = r.indexOf(i, o);
|
|
783
791
|
if (t === -1) break;
|
|
784
792
|
let s = t + i.length;
|
|
785
|
-
(!n.wholeWord || !
|
|
793
|
+
(!n.wholeWord || !be(e[t - 1]) && !be(e[s])) && a.push({
|
|
786
794
|
start: t,
|
|
787
795
|
end: s
|
|
788
796
|
}), o = s > t ? s : t + 1;
|
|
789
797
|
}
|
|
790
798
|
return a;
|
|
791
799
|
}
|
|
792
|
-
function
|
|
800
|
+
function Se(e, t) {
|
|
793
801
|
let n = 0, r = 0;
|
|
794
802
|
for (let i = 0; i < t && i < e.length; i++) e[i] === "\n" && (n++, r = i + 1);
|
|
795
803
|
return {
|
|
@@ -797,9 +805,9 @@ function be(e, t) {
|
|
|
797
805
|
col: t - r
|
|
798
806
|
};
|
|
799
807
|
}
|
|
800
|
-
function
|
|
808
|
+
function Ce(e, t, n, r) {
|
|
801
809
|
return t.map((t, i) => {
|
|
802
|
-
let { line: a, col: o } =
|
|
810
|
+
let { line: a, col: o } = Se(e, t.start);
|
|
803
811
|
return {
|
|
804
812
|
line: a,
|
|
805
813
|
start: o,
|
|
@@ -808,7 +816,7 @@ function xe(e, t, n, r) {
|
|
|
808
816
|
};
|
|
809
817
|
});
|
|
810
818
|
}
|
|
811
|
-
function
|
|
819
|
+
function we(e, t, n) {
|
|
812
820
|
let r = e;
|
|
813
821
|
for (let e = t.length - 1; e >= 0; e--) {
|
|
814
822
|
let i = t[e];
|
|
@@ -818,16 +826,16 @@ function Se(e, t, n) {
|
|
|
818
826
|
}
|
|
819
827
|
//#endregion
|
|
820
828
|
//#region src/editor/code-editor/brackets.ts
|
|
821
|
-
var
|
|
829
|
+
var O = {
|
|
822
830
|
"(": ")",
|
|
823
831
|
"[": "]",
|
|
824
832
|
"{": "}"
|
|
825
|
-
},
|
|
833
|
+
}, k = {
|
|
826
834
|
")": "(",
|
|
827
835
|
"]": "[",
|
|
828
836
|
"}": "}"
|
|
829
837
|
};
|
|
830
|
-
function
|
|
838
|
+
function A(e, t, n, r) {
|
|
831
839
|
let i = 0;
|
|
832
840
|
for (let a = t; a < e.length; a++) {
|
|
833
841
|
let t = e[a];
|
|
@@ -836,7 +844,7 @@ function j(e, t, n, r) {
|
|
|
836
844
|
}
|
|
837
845
|
return -1;
|
|
838
846
|
}
|
|
839
|
-
function
|
|
847
|
+
function j(e, t, n, r) {
|
|
840
848
|
let i = 0;
|
|
841
849
|
for (let a = t; a >= 0; a--) {
|
|
842
850
|
let t = e[a];
|
|
@@ -845,41 +853,41 @@ function M(e, t, n, r) {
|
|
|
845
853
|
}
|
|
846
854
|
return -1;
|
|
847
855
|
}
|
|
848
|
-
function
|
|
856
|
+
function Te(e, t) {
|
|
849
857
|
let n = e[t];
|
|
850
|
-
if (n && n in
|
|
851
|
-
let r =
|
|
858
|
+
if (n && n in O) {
|
|
859
|
+
let r = A(e, t, n, O[n]);
|
|
852
860
|
if (r !== -1) return {
|
|
853
861
|
open: t,
|
|
854
862
|
close: r
|
|
855
863
|
};
|
|
856
864
|
}
|
|
857
865
|
let r = e[t - 1];
|
|
858
|
-
if (r && r in
|
|
859
|
-
let n =
|
|
866
|
+
if (r && r in k) {
|
|
867
|
+
let n = j(e, t - 1, k[r], r);
|
|
860
868
|
if (n !== -1) return {
|
|
861
869
|
open: n,
|
|
862
870
|
close: t - 1
|
|
863
871
|
};
|
|
864
872
|
}
|
|
865
|
-
if (r && r in
|
|
866
|
-
let n =
|
|
873
|
+
if (r && r in O) {
|
|
874
|
+
let n = A(e, t - 1, r, O[r]);
|
|
867
875
|
if (n !== -1) return {
|
|
868
876
|
open: t - 1,
|
|
869
877
|
close: n
|
|
870
878
|
};
|
|
871
879
|
}
|
|
872
|
-
if (n && n in
|
|
873
|
-
let r =
|
|
880
|
+
if (n && n in k) {
|
|
881
|
+
let r = j(e, t, k[n], n);
|
|
874
882
|
if (r !== -1) return {
|
|
875
883
|
open: r,
|
|
876
884
|
close: t
|
|
877
885
|
};
|
|
878
886
|
}
|
|
879
887
|
}
|
|
880
|
-
function
|
|
888
|
+
function Ee(e, t, n) {
|
|
881
889
|
return [t.open, t.close].map((t) => {
|
|
882
|
-
let { line: r, col: i } =
|
|
890
|
+
let { line: r, col: i } = Se(e, t);
|
|
883
891
|
return {
|
|
884
892
|
line: r,
|
|
885
893
|
start: i,
|
|
@@ -890,7 +898,7 @@ function we(e, t, n) {
|
|
|
890
898
|
}
|
|
891
899
|
//#endregion
|
|
892
900
|
//#region src/editor/code-editor/history.ts
|
|
893
|
-
function
|
|
901
|
+
function De(e = 200) {
|
|
894
902
|
let t = [], n = -1, r = !1;
|
|
895
903
|
return {
|
|
896
904
|
record(i, a) {
|
|
@@ -916,23 +924,23 @@ function Te(e = 200) {
|
|
|
916
924
|
}
|
|
917
925
|
//#endregion
|
|
918
926
|
//#region src/editor/code-editor/keymap.ts
|
|
919
|
-
var
|
|
920
|
-
function
|
|
927
|
+
var Oe = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
|
|
928
|
+
function ke(e) {
|
|
921
929
|
let t = [];
|
|
922
|
-
(
|
|
930
|
+
(Oe ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
|
|
923
931
|
let n = e.key;
|
|
924
932
|
return n.length === 1 && (n = n.toLowerCase()), t.push(n), t.join("-");
|
|
925
933
|
}
|
|
926
|
-
function
|
|
934
|
+
function Ae(e, t) {
|
|
927
935
|
let n = new Map(Object.entries(e));
|
|
928
936
|
if (t) for (let [e, r] of Object.entries(t)) n.set(e, r);
|
|
929
937
|
return n;
|
|
930
938
|
}
|
|
931
|
-
function
|
|
932
|
-
let n = e.get(
|
|
939
|
+
function je(e, t) {
|
|
940
|
+
let n = e.get(ke(t.event));
|
|
933
941
|
return n ? n(t) : !1;
|
|
934
942
|
}
|
|
935
|
-
function
|
|
943
|
+
function Me(e) {
|
|
936
944
|
let t = () => e.insertSpaces ? " ".repeat(e.tabSize) : " ";
|
|
937
945
|
return {
|
|
938
946
|
indent: ({ textarea: e, setText: n }) => {
|
|
@@ -952,7 +960,7 @@ function Oe(e) {
|
|
|
952
960
|
}
|
|
953
961
|
//#endregion
|
|
954
962
|
//#region src/editor/code-editor/sync.ts
|
|
955
|
-
function
|
|
963
|
+
function Ne(e, t) {
|
|
956
964
|
if (e === t) return {
|
|
957
965
|
from: e.length,
|
|
958
966
|
to: e.length,
|
|
@@ -968,30 +976,30 @@ function ke(e, t) {
|
|
|
968
976
|
insert: t.slice(r, a)
|
|
969
977
|
};
|
|
970
978
|
}
|
|
971
|
-
function
|
|
979
|
+
function M(e, t) {
|
|
972
980
|
return e <= t.from ? e : e >= t.to ? e + (t.insert.length - (t.to - t.from)) : t.from + t.insert.length;
|
|
973
981
|
}
|
|
974
|
-
function
|
|
982
|
+
function Pe(e, t, n) {
|
|
975
983
|
return {
|
|
976
|
-
start:
|
|
977
|
-
end:
|
|
984
|
+
start: M(e, n),
|
|
985
|
+
end: M(t, n)
|
|
978
986
|
};
|
|
979
987
|
}
|
|
980
988
|
//#endregion
|
|
981
989
|
//#region src/editor/code-editor/caret.ts
|
|
982
|
-
function
|
|
990
|
+
function N(e, t) {
|
|
983
991
|
let n = 0;
|
|
984
992
|
for (let r of e) r === " " ? n += t - n % t : n += 1;
|
|
985
993
|
return n;
|
|
986
994
|
}
|
|
987
|
-
function
|
|
988
|
-
let { line: r, col: i } =
|
|
995
|
+
function Fe(e, t, n) {
|
|
996
|
+
let { line: r, col: i } = Se(e, t), a = N(e.slice(t - i, t), n.tabSize);
|
|
989
997
|
return {
|
|
990
998
|
top: r * n.lineHeight - n.scrollTop + n.padTop,
|
|
991
999
|
left: a * n.charWidth - n.scrollLeft + n.padLeft
|
|
992
1000
|
};
|
|
993
1001
|
}
|
|
994
|
-
function
|
|
1002
|
+
function Ie(e, t) {
|
|
995
1003
|
if (typeof document > "u") return null;
|
|
996
1004
|
let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0, i = n.nextNode();
|
|
997
1005
|
for (; i;) {
|
|
@@ -1006,7 +1014,7 @@ function Me(e, t) {
|
|
|
1006
1014
|
}
|
|
1007
1015
|
return null;
|
|
1008
1016
|
}
|
|
1009
|
-
function
|
|
1017
|
+
function Le(e) {
|
|
1010
1018
|
if (typeof document > "u") return 0;
|
|
1011
1019
|
let t = getComputedStyle(e), n = document.createElement("span");
|
|
1012
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);
|
|
@@ -1015,7 +1023,7 @@ function Ne(e) {
|
|
|
1015
1023
|
}
|
|
1016
1024
|
//#endregion
|
|
1017
1025
|
//#region src/editor/code-editor/slash-trigger.ts
|
|
1018
|
-
function
|
|
1026
|
+
function Re(e, t) {
|
|
1019
1027
|
for (let n = t - 1; n >= 0; n--) {
|
|
1020
1028
|
let r = e[n];
|
|
1021
1029
|
if (r === "/") {
|
|
@@ -1029,411 +1037,446 @@ function Pe(e, t) {
|
|
|
1029
1037
|
}
|
|
1030
1038
|
return null;
|
|
1031
1039
|
}
|
|
1032
|
-
function
|
|
1040
|
+
function ze(e, t) {
|
|
1033
1041
|
if (t === "") return [...e];
|
|
1034
1042
|
let n = t.toLowerCase();
|
|
1035
1043
|
return e.filter((e) => e.label.toLowerCase().includes(n) || (e.keywords?.some((e) => e.toLowerCase().includes(n)) ?? !1));
|
|
1036
1044
|
}
|
|
1037
|
-
var
|
|
1045
|
+
var P = {
|
|
1038
1046
|
menu: "_menu_zkolh_2",
|
|
1039
1047
|
option: "_option_zkolh_24",
|
|
1040
1048
|
active: "_active_zkolh_35",
|
|
1041
1049
|
label: "_label_zkolh_39",
|
|
1042
1050
|
hint: "_hint_zkolh_44",
|
|
1043
1051
|
empty: "_empty_zkolh_50"
|
|
1044
|
-
},
|
|
1045
|
-
return o(), /* @__PURE__ */
|
|
1046
|
-
ref:
|
|
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,
|
|
1047
1055
|
id: t,
|
|
1048
|
-
className:
|
|
1056
|
+
className: P.menu,
|
|
1049
1057
|
role: "listbox",
|
|
1050
1058
|
"aria-label": c(s.editor.commandMenu),
|
|
1051
1059
|
style: l,
|
|
1052
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
1053
|
-
className:
|
|
1060
|
+
children: n.length === 0 ? /* @__PURE__ */ f("li", {
|
|
1061
|
+
className: P.empty,
|
|
1054
1062
|
role: "presentation",
|
|
1055
1063
|
children: c(s.editor.commandMenuEmpty)
|
|
1056
|
-
}) : n.map((n, o) => /* @__PURE__ */
|
|
1064
|
+
}) : n.map((n, o) => /* @__PURE__ */ p("li", {
|
|
1057
1065
|
id: `${t}-opt-${o}`,
|
|
1058
1066
|
role: "option",
|
|
1059
1067
|
"aria-selected": o === r,
|
|
1060
|
-
className: e(
|
|
1068
|
+
className: e(P.option, o === r && P.active),
|
|
1061
1069
|
onMouseEnter: () => a(o),
|
|
1062
1070
|
onMouseDown: (e) => {
|
|
1063
1071
|
e.preventDefault(), i(o);
|
|
1064
1072
|
},
|
|
1065
|
-
children: [/* @__PURE__ */
|
|
1066
|
-
className:
|
|
1073
|
+
children: [/* @__PURE__ */ f("span", {
|
|
1074
|
+
className: P.label,
|
|
1067
1075
|
children: n.label
|
|
1068
|
-
}), n.hint !== void 0 && /* @__PURE__ */
|
|
1069
|
-
className:
|
|
1076
|
+
}), n.hint !== void 0 && /* @__PURE__ */ f("span", {
|
|
1077
|
+
className: P.hint,
|
|
1070
1078
|
children: n.hint
|
|
1071
1079
|
})]
|
|
1072
1080
|
}, n.id))
|
|
1073
1081
|
});
|
|
1074
|
-
}),
|
|
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) {
|
|
1075
1083
|
o();
|
|
1076
|
-
let
|
|
1077
|
-
|
|
1078
|
-
let [
|
|
1084
|
+
let E = d(ce);
|
|
1085
|
+
E.current = ce;
|
|
1086
|
+
let [D, be] = n({
|
|
1079
1087
|
value: l,
|
|
1080
|
-
defaultValue:
|
|
1088
|
+
defaultValue: ee ?? "",
|
|
1081
1089
|
onChange: m
|
|
1082
|
-
}), k =
|
|
1083
|
-
|
|
1084
|
-
text:
|
|
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,
|
|
1085
1093
|
selectionStart: 0,
|
|
1086
1094
|
selectionEnd: 0
|
|
1087
1095
|
}));
|
|
1088
|
-
let
|
|
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({
|
|
1089
1097
|
start: 0,
|
|
1090
1098
|
end: 0
|
|
1091
|
-
}),
|
|
1092
|
-
|
|
1099
|
+
}), R = (e, t, n) => {
|
|
1100
|
+
He.current = e, F.current = e, M.record({
|
|
1093
1101
|
text: e,
|
|
1094
1102
|
selectionStart: t.start,
|
|
1095
1103
|
selectionEnd: t.end
|
|
1096
|
-
}, { coalesce: n }),
|
|
1097
|
-
},
|
|
1098
|
-
let t =
|
|
1099
|
-
|
|
1104
|
+
}, { coalesce: n }), be(e);
|
|
1105
|
+
}, Ue = (e) => {
|
|
1106
|
+
let t = j.current;
|
|
1107
|
+
R(e, t ? {
|
|
1100
1108
|
start: t.selectionStart,
|
|
1101
1109
|
end: t.selectionEnd
|
|
1102
|
-
} :
|
|
1103
|
-
},
|
|
1104
|
-
let t =
|
|
1110
|
+
} : L.current, !1);
|
|
1111
|
+
}, We = (e) => {
|
|
1112
|
+
let t = j.current;
|
|
1105
1113
|
if (!t) return;
|
|
1106
|
-
|
|
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 = {
|
|
1107
1115
|
start: e.selectionStart,
|
|
1108
1116
|
end: e.selectionEnd
|
|
1109
|
-
},
|
|
1117
|
+
}, U.value = e.selectionStart;
|
|
1110
1118
|
let n = e.text.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1111
|
-
|
|
1112
|
-
},
|
|
1113
|
-
let e =
|
|
1114
|
-
e &&
|
|
1115
|
-
},
|
|
1116
|
-
let e =
|
|
1117
|
-
e &&
|
|
1118
|
-
},
|
|
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");
|
|
1119
1127
|
a(() => {
|
|
1120
|
-
let e =
|
|
1128
|
+
let e = D.value;
|
|
1121
1129
|
if (typeof requestAnimationFrame != "function") {
|
|
1122
|
-
|
|
1130
|
+
z.value = e;
|
|
1123
1131
|
return;
|
|
1124
1132
|
}
|
|
1125
1133
|
let t = requestAnimationFrame(() => {
|
|
1126
|
-
|
|
1134
|
+
z.value = e;
|
|
1127
1135
|
});
|
|
1128
1136
|
return () => cancelAnimationFrame(t);
|
|
1129
1137
|
}), a(() => {
|
|
1130
|
-
let e =
|
|
1131
|
-
if (
|
|
1132
|
-
if (e ===
|
|
1133
|
-
|
|
1138
|
+
let e = D.value;
|
|
1139
|
+
if (I.current || e === F.current) return;
|
|
1140
|
+
if (e === He.current) {
|
|
1141
|
+
F.current = e;
|
|
1134
1142
|
return;
|
|
1135
1143
|
}
|
|
1136
|
-
let t =
|
|
1137
|
-
t && (
|
|
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({
|
|
1138
1146
|
text: e,
|
|
1139
1147
|
selectionStart: r.start,
|
|
1140
1148
|
selectionEnd: r.end
|
|
1141
|
-
}),
|
|
1149
|
+
}), F.current = e;
|
|
1142
1150
|
}), a(() => {
|
|
1143
|
-
let e =
|
|
1151
|
+
let e = j.current;
|
|
1144
1152
|
if (!e) return;
|
|
1145
1153
|
let t = () => {
|
|
1146
1154
|
let t = Number.parseFloat(getComputedStyle(e).lineHeight);
|
|
1147
|
-
|
|
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);
|
|
1148
1158
|
}, n = () => {
|
|
1149
|
-
|
|
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);
|
|
1150
1160
|
}, r = () => {
|
|
1151
1161
|
let t = e.value.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1152
|
-
|
|
1162
|
+
O.current?.style.setProperty("--cascivo-editor-caret-line", String(t)), L.current = {
|
|
1153
1163
|
start: e.selectionStart,
|
|
1154
1164
|
end: e.selectionEnd
|
|
1155
|
-
},
|
|
1165
|
+
}, U.value = e.selectionStart;
|
|
1156
1166
|
}, i = () => {
|
|
1157
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));
|
|
1158
1172
|
};
|
|
1159
|
-
|
|
1160
|
-
|
|
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);
|
|
1161
1183
|
};
|
|
1162
1184
|
}), a(() => {
|
|
1163
|
-
let e =
|
|
1164
|
-
if (!
|
|
1165
|
-
|
|
1185
|
+
let e = U.value, t = D.value;
|
|
1186
|
+
if (!C || C.length === 0 || b || x) {
|
|
1187
|
+
W.value &&= !1;
|
|
1166
1188
|
return;
|
|
1167
1189
|
}
|
|
1168
|
-
let n =
|
|
1190
|
+
let n = Re(t, e);
|
|
1169
1191
|
if (!n) {
|
|
1170
|
-
|
|
1192
|
+
nt.value = -1, W.value &&= !1;
|
|
1171
1193
|
return;
|
|
1172
1194
|
}
|
|
1173
|
-
if (n.start ===
|
|
1174
|
-
|
|
1195
|
+
if (n.start === nt.value) {
|
|
1196
|
+
W.value &&= !1;
|
|
1175
1197
|
return;
|
|
1176
1198
|
}
|
|
1177
|
-
|
|
1199
|
+
W.value || (G.value = 0), W.value = !0, et.value = n.start, tt.value = n.query;
|
|
1178
1200
|
}), a(() => {
|
|
1179
|
-
if (!
|
|
1180
|
-
let e =
|
|
1201
|
+
if (!W.value) return;
|
|
1202
|
+
let e = it.current, t = j.current;
|
|
1181
1203
|
if (!e || !t) return;
|
|
1182
|
-
let n =
|
|
1204
|
+
let n = et.value, r = e.offsetParent, i, a, o = k.current, s = (v || D.value.includes(" ")) && o ? Ie(o, n) : null;
|
|
1183
1205
|
if (s && r) {
|
|
1184
1206
|
let e = r.getBoundingClientRect();
|
|
1185
1207
|
i = s.bottom - e.top, a = s.left - e.left;
|
|
1186
1208
|
} else {
|
|
1187
|
-
let e = getComputedStyle(t), r =
|
|
1188
|
-
charWidth:
|
|
1189
|
-
lineHeight:
|
|
1209
|
+
let e = getComputedStyle(t), r = Fe(D.value, n, {
|
|
1210
|
+
charWidth: rt.value,
|
|
1211
|
+
lineHeight: B.value,
|
|
1190
1212
|
scrollTop: t.scrollTop,
|
|
1191
1213
|
scrollLeft: t.scrollLeft,
|
|
1192
1214
|
padTop: Number.parseFloat(e.paddingTop) || 0,
|
|
1193
1215
|
padLeft: Number.parseFloat(e.paddingLeft) || 0,
|
|
1194
|
-
tabSize:
|
|
1216
|
+
tabSize: g
|
|
1195
1217
|
});
|
|
1196
|
-
i = r.top +
|
|
1218
|
+
i = r.top + B.value, a = r.left;
|
|
1197
1219
|
}
|
|
1198
1220
|
e.style.top = `${i}px`, e.style.left = `${a}px`;
|
|
1199
1221
|
});
|
|
1200
|
-
let
|
|
1201
|
-
(
|
|
1202
|
-
let
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
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;
|
|
1207
1231
|
})();
|
|
1208
|
-
|
|
1232
|
+
q.invalidateFrom(e), P.current = ct;
|
|
1209
1233
|
}
|
|
1210
|
-
let Y =
|
|
1211
|
-
if (
|
|
1212
|
-
X = Math.max(0, Math.floor(
|
|
1213
|
-
let e = Math.ceil(
|
|
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);
|
|
1214
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));
|
|
1215
1268
|
}
|
|
1216
|
-
let
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
let e = Ce(H.value, G.value);
|
|
1224
|
-
e && (ft = we(H.value, e, T.bracketMatch));
|
|
1225
|
-
}
|
|
1226
|
-
let pt = [
|
|
1227
|
-
...dt,
|
|
1228
|
-
...ft,
|
|
1229
|
-
...ut
|
|
1230
|
-
], mt = pt.length > 0 ? pt : void 0, ht = (e) => {
|
|
1231
|
-
let t = Q[e], n = M.current;
|
|
1232
|
-
if (!(!t || !n) && (n.focus(), n.setSelectionRange(t.start, t.end), B.current = {
|
|
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 = {
|
|
1233
1276
|
start: t.start,
|
|
1234
1277
|
end: t.end
|
|
1235
1278
|
}, Y > 0)) {
|
|
1236
|
-
let { line: e } =
|
|
1279
|
+
let { line: e } = Se(n.value, t.start), r = e * Y;
|
|
1237
1280
|
(r < n.scrollTop || r > n.scrollTop + n.clientHeight - Y) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
|
|
1238
1281
|
}
|
|
1239
|
-
},
|
|
1240
|
-
Q.length !== 0 && (
|
|
1241
|
-
},
|
|
1242
|
-
Q.length !== 0 && (
|
|
1243
|
-
},
|
|
1244
|
-
let e = Q[
|
|
1245
|
-
!e || !t ||
|
|
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, {
|
|
1246
1289
|
start: t.selectionStart,
|
|
1247
1290
|
end: t.selectionEnd
|
|
1248
1291
|
}, !1));
|
|
1249
|
-
},
|
|
1250
|
-
if (Q.length === 0 ||
|
|
1251
|
-
let e =
|
|
1252
|
-
t && (t.value = e),
|
|
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, {
|
|
1253
1296
|
start: t?.selectionStart ?? 0,
|
|
1254
1297
|
end: t?.selectionEnd ?? 0
|
|
1255
1298
|
}, !1);
|
|
1256
|
-
},
|
|
1257
|
-
|
|
1258
|
-
},
|
|
1259
|
-
|
|
1260
|
-
}, $ =
|
|
1261
|
-
|
|
1262
|
-
let
|
|
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) => ({
|
|
1263
1306
|
id: e.id,
|
|
1264
1307
|
label: e.label,
|
|
1265
1308
|
...e.hint !== void 0 && { hint: e.hint }
|
|
1266
|
-
})), { anchorStyle:
|
|
1267
|
-
anchorRef:
|
|
1268
|
-
floatingRef:
|
|
1309
|
+
})), { anchorStyle: At, floatingStyle: jt } = t({
|
|
1310
|
+
anchorRef: it,
|
|
1311
|
+
floatingRef: at,
|
|
1269
1312
|
placement: "bottom-start",
|
|
1270
|
-
enabled:
|
|
1271
|
-
}),
|
|
1313
|
+
enabled: W
|
|
1314
|
+
}), Mt = {
|
|
1272
1315
|
applyEdit: ({ from: e, to: t }, n) => {
|
|
1273
|
-
let r =
|
|
1274
|
-
r && (r.setRangeText(n, e, t, "end"),
|
|
1316
|
+
let r = j.current;
|
|
1317
|
+
r && (r.setRangeText(n, e, t, "end"), R(r.value, {
|
|
1275
1318
|
start: r.selectionStart,
|
|
1276
1319
|
end: r.selectionEnd
|
|
1277
1320
|
}, !1));
|
|
1278
1321
|
},
|
|
1279
1322
|
getSelection: () => {
|
|
1280
|
-
let e =
|
|
1323
|
+
let e = j.current;
|
|
1281
1324
|
return e ? {
|
|
1282
1325
|
start: e.selectionStart,
|
|
1283
1326
|
end: e.selectionEnd
|
|
1284
|
-
} : { ...
|
|
1327
|
+
} : { ...L.current };
|
|
1285
1328
|
},
|
|
1286
|
-
focus: () =>
|
|
1287
|
-
undo:
|
|
1288
|
-
redo:
|
|
1289
|
-
openFind: () =>
|
|
1329
|
+
focus: () => j.current?.focus(),
|
|
1330
|
+
undo: Ge,
|
|
1331
|
+
redo: Ke,
|
|
1332
|
+
openFind: () => Dt(!1),
|
|
1290
1333
|
openCommandMenu: () => {
|
|
1291
|
-
let e =
|
|
1292
|
-
!e || !
|
|
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, {
|
|
1293
1336
|
start: e.selectionStart,
|
|
1294
1337
|
end: e.selectionEnd
|
|
1295
|
-
}, !1),
|
|
1338
|
+
}, !1), U.value = e.selectionStart, L.current = {
|
|
1296
1339
|
start: e.selectionStart,
|
|
1297
1340
|
end: e.selectionEnd
|
|
1298
1341
|
});
|
|
1299
1342
|
}
|
|
1300
1343
|
};
|
|
1301
|
-
|
|
1302
|
-
let
|
|
1303
|
-
let t = $[e], n =
|
|
1304
|
-
if (!t || !n ||
|
|
1305
|
-
let r =
|
|
1306
|
-
n.setRangeText(t.insert ?? "", r, i, "end"),
|
|
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, {
|
|
1307
1350
|
start: n.selectionStart,
|
|
1308
1351
|
end: n.selectionEnd
|
|
1309
|
-
}, !1),
|
|
1352
|
+
}, !1), U.value = n.selectionStart, L.current = {
|
|
1310
1353
|
start: n.selectionStart,
|
|
1311
1354
|
end: n.selectionEnd
|
|
1312
|
-
},
|
|
1313
|
-
},
|
|
1314
|
-
let t = e.currentTarget, n = !
|
|
1355
|
+
}, W.value = !1, G.value = 0, n.focus(), t.run?.(Mt);
|
|
1356
|
+
}, Pt = (e) => {
|
|
1357
|
+
let t = e.currentTarget, n = !b && !x, r = {};
|
|
1315
1358
|
if (n) {
|
|
1316
|
-
let { indent: e, dedent: t } =
|
|
1317
|
-
tabSize:
|
|
1318
|
-
insertSpaces:
|
|
1359
|
+
let { indent: e, dedent: t } = Me({
|
|
1360
|
+
tabSize: g,
|
|
1361
|
+
insertSpaces: _
|
|
1319
1362
|
});
|
|
1320
|
-
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (
|
|
1321
|
-
let n = () => (
|
|
1363
|
+
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (Ge(), !0);
|
|
1364
|
+
let n = () => (Ke(), !0);
|
|
1322
1365
|
r["Mod-Shift-z"] = n, r["Mod-y"] = n;
|
|
1323
1366
|
}
|
|
1324
|
-
if (r["Mod-f"] = () => (
|
|
1325
|
-
let e =
|
|
1326
|
-
return e ? (e(
|
|
1327
|
-
},
|
|
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) {
|
|
1328
1371
|
let e = (e) => () => {
|
|
1329
1372
|
let t = $.length;
|
|
1330
|
-
return t > 0 && (
|
|
1373
|
+
return t > 0 && (G.value = (G.value + e + t) % t), !0;
|
|
1331
1374
|
};
|
|
1332
1375
|
r.ArrowDown = e(1), r.ArrowUp = e(-1);
|
|
1333
|
-
let t = () => ($.length > 0 &&
|
|
1334
|
-
r.Enter = t, r.Tab = t, r.Escape = () => (
|
|
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);
|
|
1335
1378
|
}
|
|
1336
|
-
|
|
1379
|
+
je(Ae(r, le), {
|
|
1337
1380
|
textarea: t,
|
|
1338
1381
|
event: e,
|
|
1339
|
-
setText:
|
|
1340
|
-
}) && e.preventDefault(),
|
|
1341
|
-
},
|
|
1342
|
-
"--cascivo-editor-tab-size":
|
|
1343
|
-
...
|
|
1344
|
-
...
|
|
1382
|
+
setText: Ue
|
|
1383
|
+
}) && e.preventDefault(), me?.(e);
|
|
1384
|
+
}, Ft = {
|
|
1385
|
+
"--cascivo-editor-tab-size": g,
|
|
1386
|
+
...ue,
|
|
1387
|
+
...pe
|
|
1345
1388
|
};
|
|
1346
|
-
return /* @__PURE__ */
|
|
1347
|
-
ref:
|
|
1348
|
-
className: e(
|
|
1349
|
-
"data-wrap":
|
|
1350
|
-
"data-line-numbers":
|
|
1351
|
-
style:
|
|
1352
|
-
children: [
|
|
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, {
|
|
1353
1396
|
count: J,
|
|
1354
|
-
className:
|
|
1355
|
-
gutterRef:
|
|
1397
|
+
className: T.gutter,
|
|
1398
|
+
gutterRef: A,
|
|
1356
1399
|
start: X,
|
|
1357
1400
|
end: Z,
|
|
1358
|
-
topPad:
|
|
1359
|
-
bottomPad:
|
|
1401
|
+
topPad: ht,
|
|
1402
|
+
bottomPad: gt,
|
|
1360
1403
|
activeLine: !0
|
|
1361
|
-
}), /* @__PURE__ */
|
|
1362
|
-
className:
|
|
1404
|
+
}), /* @__PURE__ */ p("div", {
|
|
1405
|
+
className: T.codeArea,
|
|
1363
1406
|
children: [
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
ref:
|
|
1366
|
-
className:
|
|
1407
|
+
/* @__PURE__ */ p("pre", {
|
|
1408
|
+
ref: k,
|
|
1409
|
+
className: T.pre,
|
|
1367
1410
|
"aria-hidden": "true",
|
|
1368
1411
|
children: [
|
|
1369
|
-
/* @__PURE__ */
|
|
1370
|
-
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
|
|
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 } })
|
|
1373
1416
|
]
|
|
1374
1417
|
}),
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
ref:
|
|
1377
|
-
className:
|
|
1378
|
-
value:
|
|
1418
|
+
/* @__PURE__ */ f("textarea", {
|
|
1419
|
+
ref: j,
|
|
1420
|
+
className: T.textarea,
|
|
1421
|
+
value: D.value,
|
|
1379
1422
|
onChange: (e) => {
|
|
1380
|
-
let t = e.currentTarget, n = t.value, r = Math.abs(n.length -
|
|
1381
|
-
|
|
1423
|
+
let t = e.currentTarget, n = t.value, r = Math.abs(n.length - F.current.length) === 1;
|
|
1424
|
+
R(n, {
|
|
1382
1425
|
start: t.selectionStart,
|
|
1383
1426
|
end: t.selectionEnd
|
|
1384
1427
|
}, r);
|
|
1385
1428
|
},
|
|
1386
|
-
onKeyDown:
|
|
1387
|
-
readOnly:
|
|
1388
|
-
disabled:
|
|
1389
|
-
spellCheck:
|
|
1390
|
-
"aria-label":
|
|
1391
|
-
"aria-expanded":
|
|
1392
|
-
"aria-controls":
|
|
1393
|
-
"aria-activedescendant":
|
|
1429
|
+
onKeyDown: Pt,
|
|
1430
|
+
readOnly: b,
|
|
1431
|
+
disabled: x,
|
|
1432
|
+
spellCheck: oe,
|
|
1433
|
+
"aria-label": se ?? c(s.editor.label),
|
|
1434
|
+
"aria-expanded": W.value,
|
|
1435
|
+
"aria-controls": W.value ? ot : void 0,
|
|
1436
|
+
"aria-activedescendant": W.value ? `${ot}-opt-${G.value}` : void 0,
|
|
1394
1437
|
autoCapitalize: "off",
|
|
1395
1438
|
autoCorrect: "off",
|
|
1396
1439
|
autoComplete: "off",
|
|
1397
|
-
wrap:
|
|
1398
|
-
...
|
|
1440
|
+
wrap: v ? "soft" : "off",
|
|
1441
|
+
...he
|
|
1399
1442
|
}),
|
|
1400
|
-
/* @__PURE__ */
|
|
1401
|
-
ref:
|
|
1443
|
+
/* @__PURE__ */ f("div", {
|
|
1444
|
+
ref: it,
|
|
1402
1445
|
"aria-hidden": "true",
|
|
1403
1446
|
style: {
|
|
1404
1447
|
position: "absolute",
|
|
1405
1448
|
inlineSize: 0,
|
|
1406
1449
|
blockSize: 0,
|
|
1407
|
-
...
|
|
1450
|
+
...At
|
|
1408
1451
|
}
|
|
1409
1452
|
}),
|
|
1410
|
-
|
|
1411
|
-
ref:
|
|
1412
|
-
id:
|
|
1413
|
-
items:
|
|
1414
|
-
activeIndex:
|
|
1415
|
-
onSelect:
|
|
1416
|
-
onHover: (e) =>
|
|
1417
|
-
style:
|
|
1453
|
+
W.value && /* @__PURE__ */ f(Be, {
|
|
1454
|
+
ref: at,
|
|
1455
|
+
id: ot,
|
|
1456
|
+
items: kt,
|
|
1457
|
+
activeIndex: G.value,
|
|
1458
|
+
onSelect: Nt,
|
|
1459
|
+
onHover: (e) => G.value = e,
|
|
1460
|
+
style: jt
|
|
1418
1461
|
}),
|
|
1419
|
-
|
|
1420
|
-
query:
|
|
1421
|
-
replaceQuery:
|
|
1422
|
-
replaceMode:
|
|
1423
|
-
caseSensitive:
|
|
1462
|
+
V.value && /* @__PURE__ */ f(ye, {
|
|
1463
|
+
query: Ye.value,
|
|
1464
|
+
replaceQuery: Xe.value,
|
|
1465
|
+
replaceMode: Qe.value,
|
|
1466
|
+
caseSensitive: Ze.value,
|
|
1424
1467
|
matchCount: Q.length,
|
|
1425
|
-
currentIndex: Q.length > 0 ?
|
|
1468
|
+
currentIndex: Q.length > 0 ? H.value : -1,
|
|
1426
1469
|
onQueryChange: (e) => {
|
|
1427
|
-
|
|
1470
|
+
Ye.value = e, H.value = 0;
|
|
1428
1471
|
},
|
|
1429
|
-
onReplaceChange: (e) =>
|
|
1430
|
-
onNext:
|
|
1431
|
-
onPrev:
|
|
1432
|
-
onReplace:
|
|
1433
|
-
onReplaceAll:
|
|
1434
|
-
onToggleCase: () =>
|
|
1435
|
-
onToggleReplace: () =>
|
|
1436
|
-
onClose:
|
|
1472
|
+
onReplaceChange: (e) => Xe.value = e,
|
|
1473
|
+
onNext: Ct,
|
|
1474
|
+
onPrev: wt,
|
|
1475
|
+
onReplace: Tt,
|
|
1476
|
+
onReplaceAll: Et,
|
|
1477
|
+
onToggleCase: () => Ze.value = !Ze.value,
|
|
1478
|
+
onToggleReplace: () => Qe.value = !Qe.value,
|
|
1479
|
+
onClose: Ot
|
|
1437
1480
|
})
|
|
1438
1481
|
]
|
|
1439
1482
|
})]
|
|
@@ -1441,32 +1484,32 @@ var L = {
|
|
|
1441
1484
|
});
|
|
1442
1485
|
//#endregion
|
|
1443
1486
|
//#region src/editor/highlight/highlight.tsx
|
|
1444
|
-
function
|
|
1487
|
+
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 }) {
|
|
1445
1488
|
o();
|
|
1446
|
-
let m =
|
|
1489
|
+
let m = ae(n), te = t.split("\n"), h = ne(m, te, 0, te.length, ie(m)), g = {
|
|
1447
1490
|
"--cascivo-editor-tab-size": a,
|
|
1448
|
-
...
|
|
1491
|
+
...d
|
|
1449
1492
|
};
|
|
1450
|
-
return /* @__PURE__ */
|
|
1451
|
-
className: e(
|
|
1493
|
+
return /* @__PURE__ */ p("div", {
|
|
1494
|
+
className: e(w.root, c),
|
|
1452
1495
|
"data-wrap": i,
|
|
1453
1496
|
"data-line-numbers": r,
|
|
1454
|
-
style:
|
|
1497
|
+
style: g,
|
|
1455
1498
|
"aria-label": s,
|
|
1456
|
-
...
|
|
1457
|
-
children: [r && /* @__PURE__ */
|
|
1458
|
-
count:
|
|
1459
|
-
className:
|
|
1460
|
-
gutterRef:
|
|
1461
|
-
}), /* @__PURE__ */
|
|
1499
|
+
...ee,
|
|
1500
|
+
children: [r && /* @__PURE__ */ f(ve, {
|
|
1501
|
+
count: h.length,
|
|
1502
|
+
className: w.gutter,
|
|
1503
|
+
gutterRef: u
|
|
1504
|
+
}), /* @__PURE__ */ f("pre", {
|
|
1462
1505
|
ref: l,
|
|
1463
|
-
className:
|
|
1464
|
-
children: /* @__PURE__ */
|
|
1465
|
-
className:
|
|
1466
|
-
children:
|
|
1506
|
+
className: w.pre,
|
|
1507
|
+
children: /* @__PURE__ */ f("code", {
|
|
1508
|
+
className: w.code,
|
|
1509
|
+
children: _e(h)
|
|
1467
1510
|
})
|
|
1468
1511
|
})]
|
|
1469
1512
|
});
|
|
1470
1513
|
}
|
|
1471
1514
|
//#endregion
|
|
1472
|
-
export {
|
|
1515
|
+
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 };
|