@cascivo/editor 0.18.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -0
- package/dist/index.js +279 -279
- package/dist/node/index.js +279 -279
- package/package.json +3 -3
package/dist/node/index.js
CHANGED
|
@@ -4,50 +4,50 @@ import { builtin as s, t as c } from "@cascivo/i18n";
|
|
|
4
4
|
import { forwardRef as l, useImperativeHandle as u, useRef as d } from "react";
|
|
5
5
|
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
6
|
//#region src/engine/tokenize.ts
|
|
7
|
-
var ee = /* @__PURE__ */ new Map(),
|
|
8
|
-
function
|
|
9
|
-
let r = `${e.name}${
|
|
7
|
+
var ee = /* @__PURE__ */ new Map(), te = "\0", ne = 0;
|
|
8
|
+
function m(e, t, n) {
|
|
9
|
+
let r = `${e.name}${te}${n}${te}${t}`, i = ee.get(r);
|
|
10
10
|
if (i) return i;
|
|
11
|
-
|
|
11
|
+
ne++;
|
|
12
12
|
let { tokens: a, state: o } = e.tokenizeLine(t, n), s = {
|
|
13
13
|
tokens: a,
|
|
14
14
|
endState: o
|
|
15
15
|
};
|
|
16
16
|
return ee.set(r, s), s;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function h(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 = m(e, t, i);
|
|
22
22
|
r.push(n.tokens), i = n.endState;
|
|
23
23
|
}
|
|
24
24
|
return r;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function re(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 = m(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
|
|
34
|
+
function ie(e, t, n, r, i) {
|
|
35
35
|
let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i, c = [];
|
|
36
36
|
for (let n = a; n < o; n++) {
|
|
37
|
-
let r =
|
|
37
|
+
let r = m(e, t[n], s);
|
|
38
38
|
c.push(r.tokens), s = r.endState;
|
|
39
39
|
}
|
|
40
40
|
return c;
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/engine/line-state.ts
|
|
44
|
-
function
|
|
44
|
+
function ae(e) {
|
|
45
45
|
let t = [], n = (n, r) => {
|
|
46
46
|
let i = Math.min(r, n.length - 1), a = t.length;
|
|
47
47
|
if (a > i) return;
|
|
48
48
|
let o = a === 0 ? e.initialState : t[a - 1];
|
|
49
49
|
for (; a <= i; a++) {
|
|
50
|
-
let r =
|
|
50
|
+
let r = m(e, n[a], o);
|
|
51
51
|
t[a] = r.endState, o = r.endState;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
@@ -69,7 +69,7 @@ function ie(e) {
|
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/engine/registry.ts
|
|
72
|
-
var
|
|
72
|
+
var g = /* @__PURE__ */ new Map(), _ = {
|
|
73
73
|
name: "plaintext",
|
|
74
74
|
initialState: "default",
|
|
75
75
|
tokenizeLine: (e) => ({
|
|
@@ -80,23 +80,23 @@ var _ = /* @__PURE__ */ new Map(), v = {
|
|
|
80
80
|
state: "default"
|
|
81
81
|
})
|
|
82
82
|
};
|
|
83
|
-
|
|
84
|
-
function
|
|
85
|
-
|
|
83
|
+
g.set(_.name, _);
|
|
84
|
+
function v(e) {
|
|
85
|
+
g.set(e.name, e);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function oe(e) {
|
|
88
88
|
if (e !== void 0) {
|
|
89
|
-
let t =
|
|
89
|
+
let t = g.get(e);
|
|
90
90
|
if (t) return t;
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return g.get("plaintext");
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
return [...
|
|
94
|
+
function y() {
|
|
95
|
+
return [...g.keys()];
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/grammars/rules.ts
|
|
99
|
-
function
|
|
99
|
+
function b(e) {
|
|
100
100
|
let t = {};
|
|
101
101
|
for (let [n, r] of Object.entries(e.states)) t[n] = r.map((e) => {
|
|
102
102
|
let t = `${e.match.flags.replace(/[gy]/g, "")}y`, n = {
|
|
@@ -139,7 +139,7 @@ function x(e) {
|
|
|
139
139
|
}
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/grammars/plaintext.ts
|
|
142
|
-
var
|
|
142
|
+
var se = {
|
|
143
143
|
name: "plaintext",
|
|
144
144
|
initialState: "default",
|
|
145
145
|
tokenizeLine: (e) => ({
|
|
@@ -150,10 +150,10 @@ var oe = {
|
|
|
150
150
|
state: "default"
|
|
151
151
|
})
|
|
152
152
|
};
|
|
153
|
-
|
|
153
|
+
v(se);
|
|
154
154
|
//#endregion
|
|
155
155
|
//#region src/grammars/json.ts
|
|
156
|
-
var
|
|
156
|
+
var ce = b({
|
|
157
157
|
name: "json",
|
|
158
158
|
states: { default: [
|
|
159
159
|
{
|
|
@@ -182,14 +182,14 @@ var se = x({
|
|
|
182
182
|
}
|
|
183
183
|
] }
|
|
184
184
|
});
|
|
185
|
-
|
|
185
|
+
v(ce);
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/grammars/clike.ts
|
|
188
|
-
var
|
|
189
|
-
function
|
|
188
|
+
var le = /* @__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 ue(e) {
|
|
190
190
|
return RegExp(`(?:${e.join("|")})\\b`);
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function de(e, t, n = []) {
|
|
193
193
|
let r = [
|
|
194
194
|
{
|
|
195
195
|
match: /\/\/.*/,
|
|
@@ -223,10 +223,10 @@ function S(e, t, n = []) {
|
|
|
223
223
|
}
|
|
224
224
|
];
|
|
225
225
|
return n.length > 0 && r.push({
|
|
226
|
-
match:
|
|
226
|
+
match: ue(n),
|
|
227
227
|
kind: "type"
|
|
228
228
|
}), r.push({
|
|
229
|
-
match:
|
|
229
|
+
match: ue(t),
|
|
230
230
|
kind: "keyword"
|
|
231
231
|
}, {
|
|
232
232
|
match: /[A-Za-z_$][\w$]*(?=\s*\()/,
|
|
@@ -243,7 +243,7 @@ function S(e, t, n = []) {
|
|
|
243
243
|
}, {
|
|
244
244
|
match: /[{}()[\];,.:]/,
|
|
245
245
|
kind: "punctuation"
|
|
246
|
-
}),
|
|
246
|
+
}), b({
|
|
247
247
|
name: e,
|
|
248
248
|
states: {
|
|
249
249
|
default: r,
|
|
@@ -290,9 +290,9 @@ function S(e, t, n = []) {
|
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/grammars/javascript.ts
|
|
293
|
-
var
|
|
294
|
-
|
|
295
|
-
var
|
|
293
|
+
var x = de("javascript", le);
|
|
294
|
+
v(x);
|
|
295
|
+
var fe = de("typescript", le, [
|
|
296
296
|
"interface",
|
|
297
297
|
"type",
|
|
298
298
|
"enum",
|
|
@@ -318,10 +318,10 @@ var de = S("typescript", ce, [
|
|
|
318
318
|
"never",
|
|
319
319
|
"object"
|
|
320
320
|
]);
|
|
321
|
-
|
|
321
|
+
v(fe);
|
|
322
322
|
//#endregion
|
|
323
323
|
//#region src/grammars/css.ts
|
|
324
|
-
var
|
|
324
|
+
var pe = b({
|
|
325
325
|
name: "css",
|
|
326
326
|
states: {
|
|
327
327
|
default: [
|
|
@@ -388,10 +388,10 @@ var C = x({
|
|
|
388
388
|
]
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
|
-
|
|
391
|
+
v(pe);
|
|
392
392
|
//#endregion
|
|
393
393
|
//#region src/grammars/html.ts
|
|
394
|
-
var
|
|
394
|
+
var S = b({
|
|
395
395
|
name: "html",
|
|
396
396
|
states: {
|
|
397
397
|
default: [
|
|
@@ -450,10 +450,10 @@ var fe = x({
|
|
|
450
450
|
]
|
|
451
451
|
}
|
|
452
452
|
});
|
|
453
|
-
|
|
453
|
+
v(S);
|
|
454
454
|
//#endregion
|
|
455
455
|
//#region src/grammars/markdown.ts
|
|
456
|
-
var
|
|
456
|
+
var me = b({
|
|
457
457
|
name: "markdown",
|
|
458
458
|
states: {
|
|
459
459
|
default: [
|
|
@@ -526,10 +526,10 @@ var pe = x({
|
|
|
526
526
|
}]
|
|
527
527
|
}
|
|
528
528
|
});
|
|
529
|
-
|
|
529
|
+
v(me);
|
|
530
530
|
//#endregion
|
|
531
531
|
//#region src/grammars/bash.ts
|
|
532
|
-
var
|
|
532
|
+
var he = b({
|
|
533
533
|
name: "bash",
|
|
534
534
|
states: { default: [
|
|
535
535
|
{
|
|
@@ -566,8 +566,8 @@ var me = x({
|
|
|
566
566
|
}
|
|
567
567
|
] }
|
|
568
568
|
});
|
|
569
|
-
|
|
570
|
-
var
|
|
569
|
+
v(he);
|
|
570
|
+
var C = {
|
|
571
571
|
root: "_root_1m6ns_2",
|
|
572
572
|
gutter: "_gutter_1m6ns_17",
|
|
573
573
|
gutterLine: "_gutterLine_1m6ns_28",
|
|
@@ -596,55 +596,55 @@ var w = {
|
|
|
596
596
|
};
|
|
597
597
|
//#endregion
|
|
598
598
|
//#region src/editor/view.tsx
|
|
599
|
-
function
|
|
599
|
+
function ge(e, t) {
|
|
600
600
|
let n = "";
|
|
601
601
|
for (let r of t) e >= r.start && e < r.end && (n = n ? `${n} ${r.className}` : r.className);
|
|
602
602
|
return n;
|
|
603
603
|
}
|
|
604
|
-
function
|
|
604
|
+
function _e(t, n, r, i) {
|
|
605
605
|
let a = n + t.value.length, o = new Set([n, a]);
|
|
606
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
607
|
if (o.size === 2) {
|
|
608
|
-
let a =
|
|
608
|
+
let a = ge(n, r);
|
|
609
609
|
return /* @__PURE__ */ f("span", {
|
|
610
|
-
className: a ? e(
|
|
610
|
+
className: a ? e(C[t.kind], a) : C[t.kind],
|
|
611
611
|
children: t.value
|
|
612
612
|
}, i);
|
|
613
613
|
}
|
|
614
614
|
let s = [...o].sort((e, t) => e - t), c = [];
|
|
615
615
|
for (let i = 0; i < s.length - 1; i++) {
|
|
616
|
-
let a = s[i], o = s[i + 1], l =
|
|
616
|
+
let a = s[i], o = s[i + 1], l = ge(a, r);
|
|
617
617
|
c.push(/* @__PURE__ */ f("span", {
|
|
618
|
-
className: l ? e(
|
|
618
|
+
className: l ? e(C[t.kind], l) : C[t.kind],
|
|
619
619
|
children: t.value.slice(a - n, o - n)
|
|
620
620
|
}, a));
|
|
621
621
|
}
|
|
622
622
|
return /* @__PURE__ */ f("span", { children: c }, i);
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function ve(e, t = 0, n = t + e.length, r) {
|
|
625
625
|
let i = [];
|
|
626
626
|
for (let a = t; a < n; a++) {
|
|
627
627
|
let n = e[a - t], o = r?.filter((e) => e.line === a);
|
|
628
628
|
i.push(/* @__PURE__ */ f("span", {
|
|
629
|
-
className:
|
|
629
|
+
className: C.line,
|
|
630
630
|
children: n.length === 0 ? "" : o && o.length > 0 ? (() => {
|
|
631
631
|
let e = 0;
|
|
632
632
|
return n.map((t, n) => {
|
|
633
|
-
let r =
|
|
633
|
+
let r = _e(t, e, o, n);
|
|
634
634
|
return e += t.value.length, r;
|
|
635
635
|
});
|
|
636
636
|
})() : n.map((e, t) => /* @__PURE__ */ f("span", {
|
|
637
|
-
className:
|
|
637
|
+
className: C[e.kind],
|
|
638
638
|
children: e.value
|
|
639
639
|
}, t))
|
|
640
640
|
}, a));
|
|
641
641
|
}
|
|
642
642
|
return i;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function ye({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
|
|
645
645
|
let c = [];
|
|
646
646
|
for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ f("span", {
|
|
647
|
-
className:
|
|
647
|
+
className: C.gutterLine,
|
|
648
648
|
children: e
|
|
649
649
|
}, e));
|
|
650
650
|
return /* @__PURE__ */ p("div", {
|
|
@@ -652,21 +652,21 @@ function ve({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, to
|
|
|
652
652
|
className: t,
|
|
653
653
|
"aria-hidden": "true",
|
|
654
654
|
children: [
|
|
655
|
-
s && /* @__PURE__ */ f("div", { className:
|
|
655
|
+
s && /* @__PURE__ */ f("div", { className: C.gutterActive }),
|
|
656
656
|
a > 0 && /* @__PURE__ */ f("div", { style: { blockSize: a } }),
|
|
657
657
|
c,
|
|
658
658
|
o > 0 && /* @__PURE__ */ f("div", { style: { blockSize: o } })
|
|
659
659
|
]
|
|
660
660
|
});
|
|
661
661
|
}
|
|
662
|
-
var
|
|
662
|
+
var w = {
|
|
663
663
|
root: "_root_18xci_2",
|
|
664
664
|
textarea: "_textarea_18xci_18",
|
|
665
665
|
gutter: "_gutter_18xci_23",
|
|
666
666
|
codeArea: "_codeArea_18xci_36",
|
|
667
667
|
pre: "_pre_18xci_43",
|
|
668
668
|
currentLine: "_currentLine_18xci_58"
|
|
669
|
-
},
|
|
669
|
+
}, T = {
|
|
670
670
|
panel: "_panel_hawkv_2",
|
|
671
671
|
row: "_row_hawkv_20",
|
|
672
672
|
input: "_input_hawkv_26",
|
|
@@ -677,29 +677,29 @@ var T = {
|
|
|
677
677
|
};
|
|
678
678
|
//#endregion
|
|
679
679
|
//#region src/editor/code-editor/find-panel.tsx
|
|
680
|
-
function
|
|
680
|
+
function be(t) {
|
|
681
681
|
o();
|
|
682
682
|
let n = t.matchCount === 0 ? c(s.editor.noMatches) : c(s.editor.findCount, {
|
|
683
683
|
current: t.currentIndex + 1,
|
|
684
684
|
total: t.matchCount
|
|
685
685
|
});
|
|
686
686
|
return /* @__PURE__ */ p("div", {
|
|
687
|
-
className:
|
|
687
|
+
className: T.panel,
|
|
688
688
|
role: "search",
|
|
689
689
|
"aria-label": c(s.editor.find),
|
|
690
690
|
children: [/* @__PURE__ */ p("div", {
|
|
691
|
-
className:
|
|
691
|
+
className: T.row,
|
|
692
692
|
children: [
|
|
693
693
|
/* @__PURE__ */ f("button", {
|
|
694
694
|
type: "button",
|
|
695
|
-
className:
|
|
695
|
+
className: T.toggle,
|
|
696
696
|
"aria-label": c(s.editor.toggleReplace),
|
|
697
697
|
"aria-expanded": t.replaceMode,
|
|
698
698
|
onClick: t.onToggleReplace,
|
|
699
699
|
children: t.replaceMode ? "▾" : "▸"
|
|
700
700
|
}),
|
|
701
701
|
/* @__PURE__ */ f("input", {
|
|
702
|
-
className:
|
|
702
|
+
className: T.input,
|
|
703
703
|
value: t.query,
|
|
704
704
|
placeholder: c(s.editor.findPlaceholder),
|
|
705
705
|
"aria-label": c(s.editor.find),
|
|
@@ -712,27 +712,27 @@ function ye(t) {
|
|
|
712
712
|
}
|
|
713
713
|
}),
|
|
714
714
|
/* @__PURE__ */ f("span", {
|
|
715
|
-
className:
|
|
715
|
+
className: T.count,
|
|
716
716
|
"aria-live": "polite",
|
|
717
717
|
children: n
|
|
718
718
|
}),
|
|
719
719
|
/* @__PURE__ */ f("button", {
|
|
720
720
|
type: "button",
|
|
721
|
-
className:
|
|
721
|
+
className: T.button,
|
|
722
722
|
"aria-label": c(s.editor.previous),
|
|
723
723
|
onClick: t.onPrev,
|
|
724
724
|
children: "‹"
|
|
725
725
|
}),
|
|
726
726
|
/* @__PURE__ */ f("button", {
|
|
727
727
|
type: "button",
|
|
728
|
-
className:
|
|
728
|
+
className: T.button,
|
|
729
729
|
"aria-label": c(s.editor.next),
|
|
730
730
|
onClick: t.onNext,
|
|
731
731
|
children: "›"
|
|
732
732
|
}),
|
|
733
733
|
/* @__PURE__ */ f("button", {
|
|
734
734
|
type: "button",
|
|
735
|
-
className: e(
|
|
735
|
+
className: e(T.button, t.caseSensitive && T.active),
|
|
736
736
|
"aria-pressed": t.caseSensitive,
|
|
737
737
|
"aria-label": c(s.editor.matchCase),
|
|
738
738
|
onClick: t.onToggleCase,
|
|
@@ -740,17 +740,17 @@ function ye(t) {
|
|
|
740
740
|
}),
|
|
741
741
|
/* @__PURE__ */ f("button", {
|
|
742
742
|
type: "button",
|
|
743
|
-
className:
|
|
743
|
+
className: T.button,
|
|
744
744
|
"aria-label": c(s.editor.close),
|
|
745
745
|
onClick: t.onClose,
|
|
746
746
|
children: "×"
|
|
747
747
|
})
|
|
748
748
|
]
|
|
749
749
|
}), t.replaceMode && /* @__PURE__ */ p("div", {
|
|
750
|
-
className:
|
|
750
|
+
className: T.row,
|
|
751
751
|
children: [
|
|
752
752
|
/* @__PURE__ */ f("input", {
|
|
753
|
-
className:
|
|
753
|
+
className: T.input,
|
|
754
754
|
value: t.replaceQuery,
|
|
755
755
|
placeholder: c(s.editor.replacePlaceholder),
|
|
756
756
|
"aria-label": c(s.editor.replace),
|
|
@@ -763,13 +763,13 @@ function ye(t) {
|
|
|
763
763
|
}),
|
|
764
764
|
/* @__PURE__ */ f("button", {
|
|
765
765
|
type: "button",
|
|
766
|
-
className:
|
|
766
|
+
className: T.button,
|
|
767
767
|
onClick: t.onReplace,
|
|
768
768
|
children: c(s.editor.replaceOne)
|
|
769
769
|
}),
|
|
770
770
|
/* @__PURE__ */ f("button", {
|
|
771
771
|
type: "button",
|
|
772
|
-
className:
|
|
772
|
+
className: T.button,
|
|
773
773
|
onClick: t.onReplaceAll,
|
|
774
774
|
children: c(s.editor.replaceAll)
|
|
775
775
|
})
|
|
@@ -779,25 +779,25 @@ function ye(t) {
|
|
|
779
779
|
}
|
|
780
780
|
//#endregion
|
|
781
781
|
//#region src/editor/code-editor/find.ts
|
|
782
|
-
var
|
|
783
|
-
function
|
|
784
|
-
return e !== void 0 &&
|
|
782
|
+
var xe = /\w/;
|
|
783
|
+
function E(e) {
|
|
784
|
+
return e !== void 0 && xe.test(e);
|
|
785
785
|
}
|
|
786
|
-
function
|
|
786
|
+
function Se(e, t, n = {}) {
|
|
787
787
|
if (t.length === 0) return [];
|
|
788
788
|
let r = n.caseSensitive ? e : e.toLowerCase(), i = n.caseSensitive ? t : t.toLowerCase(), a = [], o = 0;
|
|
789
789
|
for (;;) {
|
|
790
790
|
let t = r.indexOf(i, o);
|
|
791
791
|
if (t === -1) break;
|
|
792
792
|
let s = t + i.length;
|
|
793
|
-
(!n.wholeWord || !
|
|
793
|
+
(!n.wholeWord || !E(e[t - 1]) && !E(e[s])) && a.push({
|
|
794
794
|
start: t,
|
|
795
795
|
end: s
|
|
796
796
|
}), o = s > t ? s : t + 1;
|
|
797
797
|
}
|
|
798
798
|
return a;
|
|
799
799
|
}
|
|
800
|
-
function
|
|
800
|
+
function Ce(e, t) {
|
|
801
801
|
let n = 0, r = 0;
|
|
802
802
|
for (let i = 0; i < t && i < e.length; i++) e[i] === "\n" && (n++, r = i + 1);
|
|
803
803
|
return {
|
|
@@ -805,9 +805,9 @@ function Se(e, t) {
|
|
|
805
805
|
col: t - r
|
|
806
806
|
};
|
|
807
807
|
}
|
|
808
|
-
function
|
|
808
|
+
function we(e, t, n, r) {
|
|
809
809
|
return t.map((t, i) => {
|
|
810
|
-
let { line: a, col: o } =
|
|
810
|
+
let { line: a, col: o } = Ce(e, t.start);
|
|
811
811
|
return {
|
|
812
812
|
line: a,
|
|
813
813
|
start: o,
|
|
@@ -816,7 +816,7 @@ function Ce(e, t, n, r) {
|
|
|
816
816
|
};
|
|
817
817
|
});
|
|
818
818
|
}
|
|
819
|
-
function
|
|
819
|
+
function Te(e, t, n) {
|
|
820
820
|
let r = e;
|
|
821
821
|
for (let e = t.length - 1; e >= 0; e--) {
|
|
822
822
|
let i = t[e];
|
|
@@ -826,16 +826,16 @@ function we(e, t, n) {
|
|
|
826
826
|
}
|
|
827
827
|
//#endregion
|
|
828
828
|
//#region src/editor/code-editor/brackets.ts
|
|
829
|
-
var
|
|
829
|
+
var D = {
|
|
830
830
|
"(": ")",
|
|
831
831
|
"[": "]",
|
|
832
832
|
"{": "}"
|
|
833
|
-
},
|
|
833
|
+
}, O = {
|
|
834
834
|
")": "(",
|
|
835
835
|
"]": "[",
|
|
836
836
|
"}": "}"
|
|
837
837
|
};
|
|
838
|
-
function
|
|
838
|
+
function k(e, t, n, r) {
|
|
839
839
|
let i = 0;
|
|
840
840
|
for (let a = t; a < e.length; a++) {
|
|
841
841
|
let t = e[a];
|
|
@@ -844,7 +844,7 @@ function A(e, t, n, r) {
|
|
|
844
844
|
}
|
|
845
845
|
return -1;
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function A(e, t, n, r) {
|
|
848
848
|
let i = 0;
|
|
849
849
|
for (let a = t; a >= 0; a--) {
|
|
850
850
|
let t = e[a];
|
|
@@ -853,41 +853,41 @@ function j(e, t, n, r) {
|
|
|
853
853
|
}
|
|
854
854
|
return -1;
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function Ee(e, t) {
|
|
857
857
|
let n = e[t];
|
|
858
|
-
if (n && n in
|
|
859
|
-
let r =
|
|
858
|
+
if (n && n in D) {
|
|
859
|
+
let r = k(e, t, n, D[n]);
|
|
860
860
|
if (r !== -1) return {
|
|
861
861
|
open: t,
|
|
862
862
|
close: r
|
|
863
863
|
};
|
|
864
864
|
}
|
|
865
865
|
let r = e[t - 1];
|
|
866
|
-
if (r && r in
|
|
867
|
-
let n =
|
|
866
|
+
if (r && r in O) {
|
|
867
|
+
let n = A(e, t - 1, O[r], r);
|
|
868
868
|
if (n !== -1) return {
|
|
869
869
|
open: n,
|
|
870
870
|
close: t - 1
|
|
871
871
|
};
|
|
872
872
|
}
|
|
873
|
-
if (r && r in
|
|
874
|
-
let n =
|
|
873
|
+
if (r && r in D) {
|
|
874
|
+
let n = k(e, t - 1, r, D[r]);
|
|
875
875
|
if (n !== -1) return {
|
|
876
876
|
open: t - 1,
|
|
877
877
|
close: n
|
|
878
878
|
};
|
|
879
879
|
}
|
|
880
|
-
if (n && n in
|
|
881
|
-
let r =
|
|
880
|
+
if (n && n in O) {
|
|
881
|
+
let r = A(e, t, O[n], n);
|
|
882
882
|
if (r !== -1) return {
|
|
883
883
|
open: r,
|
|
884
884
|
close: t
|
|
885
885
|
};
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function De(e, t, n) {
|
|
889
889
|
return [t.open, t.close].map((t) => {
|
|
890
|
-
let { line: r, col: i } =
|
|
890
|
+
let { line: r, col: i } = Ce(e, t);
|
|
891
891
|
return {
|
|
892
892
|
line: r,
|
|
893
893
|
start: i,
|
|
@@ -898,7 +898,7 @@ function Ee(e, t, n) {
|
|
|
898
898
|
}
|
|
899
899
|
//#endregion
|
|
900
900
|
//#region src/editor/code-editor/history.ts
|
|
901
|
-
function
|
|
901
|
+
function Oe(e = 200) {
|
|
902
902
|
let t = [], n = -1, r = !1;
|
|
903
903
|
return {
|
|
904
904
|
record(i, a) {
|
|
@@ -924,10 +924,10 @@ function De(e = 200) {
|
|
|
924
924
|
}
|
|
925
925
|
//#endregion
|
|
926
926
|
//#region src/editor/code-editor/keymap.ts
|
|
927
|
-
var
|
|
927
|
+
var j = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
|
|
928
928
|
function ke(e) {
|
|
929
929
|
let t = [];
|
|
930
|
-
(
|
|
930
|
+
(j ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
|
|
931
931
|
let n = e.key;
|
|
932
932
|
return n.length === 1 && (n = n.toLowerCase()), t.push(n), t.join("-");
|
|
933
933
|
}
|
|
@@ -993,7 +993,7 @@ function N(e, t) {
|
|
|
993
993
|
return n;
|
|
994
994
|
}
|
|
995
995
|
function Fe(e, t, n) {
|
|
996
|
-
let { line: r, col: i } =
|
|
996
|
+
let { line: r, col: i } = Ce(e, t), a = N(e.slice(t - i, t), n.tabSize);
|
|
997
997
|
return {
|
|
998
998
|
top: r * n.lineHeight - n.scrollTop + n.padTop,
|
|
999
999
|
left: a * n.charWidth - n.scrollLeft + n.padLeft
|
|
@@ -1079,53 +1079,53 @@ var P = {
|
|
|
1079
1079
|
})]
|
|
1080
1080
|
}, n.id))
|
|
1081
1081
|
});
|
|
1082
|
-
}), Ve = 2e3,
|
|
1082
|
+
}), Ve = 2e3, He = l(function({ value: l, defaultValue: ee, onValueChange: te, language: ne = "plaintext", lineNumbers: m = !0, tabSize: h = 2, insertSpaces: g = !0, wrap: _ = !1, virtualize: v, readOnly: y = !1, disabled: b = !1, spellCheck: se = !1, label: ce, ariaLabel: le, onSave: ue, keymap: de, decorations: x, theme: fe, bracketMatching: pe = !1, commands: S, className: me, style: he, onKeyDown: ge, ..._e }, T) {
|
|
1083
1083
|
o();
|
|
1084
|
-
let
|
|
1085
|
-
|
|
1086
|
-
let [
|
|
1084
|
+
let xe = d(ue);
|
|
1085
|
+
xe.current = ue;
|
|
1086
|
+
let [E, D] = n({
|
|
1087
1087
|
value: l,
|
|
1088
1088
|
defaultValue: ee ?? "",
|
|
1089
|
-
onChange:
|
|
1090
|
-
}), O = d(null), k = d(null), A = d(null), j = d(null),
|
|
1091
|
-
|
|
1092
|
-
text:
|
|
1089
|
+
onChange: te
|
|
1090
|
+
}), O = d(null), k = d(null), A = d(null), j = d(null), ke = d([]), M = d(null);
|
|
1091
|
+
M.current === null && (M.current = Oe(), M.current.reset({
|
|
1092
|
+
text: E.value,
|
|
1093
1093
|
selectionStart: 0,
|
|
1094
1094
|
selectionEnd: 0
|
|
1095
1095
|
}));
|
|
1096
|
-
let
|
|
1096
|
+
let N = M.current, P = d(null), He = d(void 0), F = d(E.value), Ue = d(void 0), I = d(!1), L = d({
|
|
1097
1097
|
start: 0,
|
|
1098
1098
|
end: 0
|
|
1099
1099
|
}), R = (e, t, n) => {
|
|
1100
|
-
|
|
1100
|
+
Ue.current = e, F.current = e, N.record({
|
|
1101
1101
|
text: e,
|
|
1102
1102
|
selectionStart: t.start,
|
|
1103
1103
|
selectionEnd: t.end
|
|
1104
|
-
}, { coalesce: n }),
|
|
1105
|
-
},
|
|
1104
|
+
}, { coalesce: n }), D(e);
|
|
1105
|
+
}, We = (e) => {
|
|
1106
1106
|
let t = j.current;
|
|
1107
1107
|
R(e, t ? {
|
|
1108
1108
|
start: t.selectionStart,
|
|
1109
1109
|
end: t.selectionEnd
|
|
1110
1110
|
} : L.current, !1);
|
|
1111
|
-
},
|
|
1111
|
+
}, Ge = (e) => {
|
|
1112
1112
|
let t = j.current;
|
|
1113
1113
|
if (!t) return;
|
|
1114
|
-
I.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd),
|
|
1114
|
+
I.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd), D(e.text), Ue.current = e.text, F.current = e.text, L.current = {
|
|
1115
1115
|
start: e.selectionStart,
|
|
1116
1116
|
end: e.selectionEnd
|
|
1117
1117
|
}, U.value = e.selectionStart;
|
|
1118
1118
|
let n = e.text.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1119
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
1120
|
}, Ke = () => {
|
|
1124
|
-
let e =
|
|
1125
|
-
e &&
|
|
1126
|
-
},
|
|
1121
|
+
let e = N.undo();
|
|
1122
|
+
e && Ge(e);
|
|
1123
|
+
}, qe = () => {
|
|
1124
|
+
let e = N.redo();
|
|
1125
|
+
e && Ge(e);
|
|
1126
|
+
}, z = i(E.value), Je = i(0), Ye = i(0), B = i(0), V = i(!1), Xe = i(""), Ze = i(""), Qe = i(!1), $e = i(!1), H = i(0), U = i(0), et = i(0), W = i(!1), tt = i(0), nt = i(""), G = i(0), rt = i(-1), it = i(0), at = d(null), ot = d(null), st = r("slash-menu");
|
|
1127
1127
|
a(() => {
|
|
1128
|
-
let e =
|
|
1128
|
+
let e = E.value;
|
|
1129
1129
|
if (typeof requestAnimationFrame != "function") {
|
|
1130
1130
|
z.value = e;
|
|
1131
1131
|
return;
|
|
@@ -1135,14 +1135,14 @@ var P = {
|
|
|
1135
1135
|
});
|
|
1136
1136
|
return () => cancelAnimationFrame(t);
|
|
1137
1137
|
}), a(() => {
|
|
1138
|
-
let e =
|
|
1138
|
+
let e = E.value;
|
|
1139
1139
|
if (I.current || e === F.current) return;
|
|
1140
|
-
if (e ===
|
|
1140
|
+
if (e === Ue.current) {
|
|
1141
1141
|
F.current = e;
|
|
1142
1142
|
return;
|
|
1143
1143
|
}
|
|
1144
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,
|
|
1145
|
+
t && (I.current = !0, t.value !== e && (t.value = e), t.setSelectionRange(r.start, r.end), I.current = !1), L.current = r, N.reset({
|
|
1146
1146
|
text: e,
|
|
1147
1147
|
selectionStart: r.start,
|
|
1148
1148
|
selectionEnd: r.end
|
|
@@ -1152,11 +1152,11 @@ var P = {
|
|
|
1152
1152
|
if (!e) return;
|
|
1153
1153
|
let t = () => {
|
|
1154
1154
|
let t = Number.parseFloat(getComputedStyle(e).lineHeight);
|
|
1155
|
-
B.value = Number.isFinite(t) && t > 0 ? t : 0,
|
|
1155
|
+
B.value = Number.isFinite(t) && t > 0 ? t : 0, Ye.value = e.clientHeight;
|
|
1156
1156
|
let n = Le(e);
|
|
1157
|
-
n > 0 && (
|
|
1157
|
+
n > 0 && (it.value = n);
|
|
1158
1158
|
}, n = () => {
|
|
1159
|
-
|
|
1159
|
+
Je.value = e.scrollTop, Ye.value = e.clientHeight, k.current && (k.current.scrollTop = e.scrollTop, k.current.scrollLeft = e.scrollLeft), A.current && (A.current.scrollTop = e.scrollTop);
|
|
1160
1160
|
}, r = () => {
|
|
1161
1161
|
let t = e.value.slice(0, e.selectionStart).split("\n").length - 1;
|
|
1162
1162
|
O.current?.style.setProperty("--cascivo-editor-caret-line", String(t)), L.current = {
|
|
@@ -1182,72 +1182,72 @@ var P = {
|
|
|
1182
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
1183
|
};
|
|
1184
1184
|
}), a(() => {
|
|
1185
|
-
let e = U.value, t =
|
|
1186
|
-
if (!
|
|
1185
|
+
let e = U.value, t = E.value;
|
|
1186
|
+
if (!S || S.length === 0 || y || b) {
|
|
1187
1187
|
W.value &&= !1;
|
|
1188
1188
|
return;
|
|
1189
1189
|
}
|
|
1190
1190
|
let n = Re(t, e);
|
|
1191
1191
|
if (!n) {
|
|
1192
|
-
|
|
1192
|
+
rt.value = -1, W.value &&= !1;
|
|
1193
1193
|
return;
|
|
1194
1194
|
}
|
|
1195
|
-
if (n.start ===
|
|
1195
|
+
if (n.start === rt.value) {
|
|
1196
1196
|
W.value &&= !1;
|
|
1197
1197
|
return;
|
|
1198
1198
|
}
|
|
1199
|
-
W.value || (G.value = 0), W.value = !0,
|
|
1199
|
+
W.value || (G.value = 0), W.value = !0, tt.value = n.start, nt.value = n.query;
|
|
1200
1200
|
}), a(() => {
|
|
1201
1201
|
if (!W.value) return;
|
|
1202
|
-
let e =
|
|
1202
|
+
let e = at.current, t = j.current;
|
|
1203
1203
|
if (!e || !t) return;
|
|
1204
|
-
let n =
|
|
1204
|
+
let n = tt.value, r = e.offsetParent, i, a, o = k.current, s = (_ || E.value.includes(" ")) && o ? Ie(o, n) : null;
|
|
1205
1205
|
if (s && r) {
|
|
1206
1206
|
let e = r.getBoundingClientRect();
|
|
1207
1207
|
i = s.bottom - e.top, a = s.left - e.left;
|
|
1208
1208
|
} else {
|
|
1209
|
-
let e = getComputedStyle(t), r = Fe(
|
|
1210
|
-
charWidth:
|
|
1209
|
+
let e = getComputedStyle(t), r = Fe(E.value, n, {
|
|
1210
|
+
charWidth: it.value,
|
|
1211
1211
|
lineHeight: B.value,
|
|
1212
1212
|
scrollTop: t.scrollTop,
|
|
1213
1213
|
scrollLeft: t.scrollLeft,
|
|
1214
1214
|
padTop: Number.parseFloat(e.paddingTop) || 0,
|
|
1215
1215
|
padLeft: Number.parseFloat(e.paddingLeft) || 0,
|
|
1216
|
-
tabSize:
|
|
1216
|
+
tabSize: h
|
|
1217
1217
|
});
|
|
1218
1218
|
i = r.top + B.value, a = r.left;
|
|
1219
1219
|
}
|
|
1220
1220
|
e.style.top = `${i}px`, e.style.left = `${a}px`;
|
|
1221
1221
|
});
|
|
1222
|
-
let K =
|
|
1223
|
-
(
|
|
1224
|
-
let q =
|
|
1225
|
-
|
|
1226
|
-
let
|
|
1227
|
-
if (
|
|
1228
|
-
let e =
|
|
1229
|
-
let e = Ne(
|
|
1230
|
-
return
|
|
1222
|
+
let K = oe(ne);
|
|
1223
|
+
(P.current === null || P.current.grammar !== K) && (P.current = ae(K), He.current = void 0);
|
|
1224
|
+
let q = P.current, ct = z.value.split("\n"), J = ct.length;
|
|
1225
|
+
ke.current = ct;
|
|
1226
|
+
let lt = z.value, ut = He.current;
|
|
1227
|
+
if (lt !== ut) {
|
|
1228
|
+
let e = ut === void 0 ? 0 : (() => {
|
|
1229
|
+
let e = Ne(ut, lt);
|
|
1230
|
+
return ut.slice(0, e.from).split("\n").length - 1;
|
|
1231
1231
|
})();
|
|
1232
|
-
q.invalidateFrom(e),
|
|
1232
|
+
q.invalidateFrom(e), He.current = lt;
|
|
1233
1233
|
}
|
|
1234
|
-
let
|
|
1235
|
-
if (
|
|
1236
|
-
X = Math.max(0, Math.floor(
|
|
1237
|
-
let e = Math.ceil(
|
|
1234
|
+
let dt = B.value > 0, Y = dt ? B.value : 20, ft = (v ?? J > 1e3) && !_, X = 0, Z = J;
|
|
1235
|
+
if (ft) if (dt) {
|
|
1236
|
+
X = Math.max(0, Math.floor(Je.value / Y) - 12);
|
|
1237
|
+
let e = Math.ceil(Ye.value / Y);
|
|
1238
1238
|
Z = Math.min(J, X + e + 24);
|
|
1239
1239
|
} else Z = Math.min(J, 200);
|
|
1240
|
-
let
|
|
1241
|
-
|
|
1242
|
-
let
|
|
1240
|
+
let pt = ft && X > q.length ? X - q.length : 0, mt = !ft || X === 0 || q.length >= X || pt <= 2e3, ht;
|
|
1241
|
+
mt ? ht = re(K, ct, X, Z, q) : (et.value, ht = ie(K, ct, X, Z, K.initialState));
|
|
1242
|
+
let gt = X * Y, _t = (J - Z) * Y;
|
|
1243
1243
|
a(() => {
|
|
1244
|
-
z.value,
|
|
1245
|
-
let e = B.value, t =
|
|
1246
|
-
if (!((
|
|
1247
|
-
let r = Math.max(0, Math.floor(
|
|
1244
|
+
z.value, et.value;
|
|
1245
|
+
let e = B.value, t = ke.current, n = t.length;
|
|
1246
|
+
if (!((v ?? n > 1e3) && !_ && e > 0)) return;
|
|
1247
|
+
let r = Math.max(0, Math.floor(Je.value / e) - 12);
|
|
1248
1248
|
if (r === 0 || q.length >= r || q.length >= n) return;
|
|
1249
1249
|
let i = () => {
|
|
1250
|
-
q.ensure(t, Math.min(r - 1, q.length + Ve)),
|
|
1250
|
+
q.ensure(t, Math.min(r - 1, q.length + Ve)), et.value++;
|
|
1251
1251
|
};
|
|
1252
1252
|
if (typeof requestAnimationFrame != "function") {
|
|
1253
1253
|
i();
|
|
@@ -1256,62 +1256,62 @@ var P = {
|
|
|
1256
1256
|
let a = requestAnimationFrame(i);
|
|
1257
1257
|
return () => cancelAnimationFrame(a);
|
|
1258
1258
|
});
|
|
1259
|
-
let Q = V.value ?
|
|
1259
|
+
let Q = V.value ? Se(z.value, Xe.value, { caseSensitive: Qe.value }) : [];
|
|
1260
1260
|
H.value >= Q.length && (H.value = Math.max(0, Q.length - 1));
|
|
1261
|
-
let
|
|
1262
|
-
match:
|
|
1263
|
-
current:
|
|
1264
|
-
}) : [],
|
|
1265
|
-
if (
|
|
1266
|
-
let e =
|
|
1267
|
-
e && (
|
|
1261
|
+
let vt = Q.length > 0 ? we(z.value, Q, H.value, {
|
|
1262
|
+
match: C.match,
|
|
1263
|
+
current: C.matchCurrent
|
|
1264
|
+
}) : [], yt = typeof x == "function" ? x(z.value) : x ?? [], bt = [];
|
|
1265
|
+
if (pe) {
|
|
1266
|
+
let e = Ee(z.value, U.value);
|
|
1267
|
+
e && (bt = De(z.value, e, C.bracketMatch));
|
|
1268
1268
|
}
|
|
1269
|
-
let
|
|
1270
|
-
...vt,
|
|
1269
|
+
let xt = [
|
|
1271
1270
|
...yt,
|
|
1272
|
-
...
|
|
1273
|
-
|
|
1271
|
+
...bt,
|
|
1272
|
+
...vt
|
|
1273
|
+
], St = xt.length > 0 ? xt : void 0, Ct = (e) => {
|
|
1274
1274
|
let t = Q[e], n = j.current;
|
|
1275
1275
|
if (!(!t || !n) && (n.focus(), n.setSelectionRange(t.start, t.end), L.current = {
|
|
1276
1276
|
start: t.start,
|
|
1277
1277
|
end: t.end
|
|
1278
1278
|
}, Y > 0)) {
|
|
1279
|
-
let { line: e } =
|
|
1279
|
+
let { line: e } = Ce(n.value, t.start), r = e * Y;
|
|
1280
1280
|
(r < n.scrollTop || r > n.scrollTop + n.clientHeight - Y) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
|
|
1281
1281
|
}
|
|
1282
|
-
}, Ct = () => {
|
|
1283
|
-
Q.length !== 0 && (H.value = (H.value + 1) % Q.length, St(H.value));
|
|
1284
1282
|
}, wt = () => {
|
|
1285
|
-
Q.length !== 0 && (H.value = (H.value
|
|
1283
|
+
Q.length !== 0 && (H.value = (H.value + 1) % Q.length, Ct(H.value));
|
|
1286
1284
|
}, Tt = () => {
|
|
1285
|
+
Q.length !== 0 && (H.value = (H.value - 1 + Q.length) % Q.length, Ct(H.value));
|
|
1286
|
+
}, Et = () => {
|
|
1287
1287
|
let e = Q[H.value], t = j.current;
|
|
1288
|
-
!e || !t ||
|
|
1288
|
+
!e || !t || y || b || (t.setRangeText(Ze.value, e.start, e.end, "end"), R(t.value, {
|
|
1289
1289
|
start: t.selectionStart,
|
|
1290
1290
|
end: t.selectionEnd
|
|
1291
1291
|
}, !1));
|
|
1292
|
-
},
|
|
1293
|
-
if (Q.length === 0 ||
|
|
1294
|
-
let e =
|
|
1292
|
+
}, Dt = () => {
|
|
1293
|
+
if (Q.length === 0 || y || b) return;
|
|
1294
|
+
let e = Te(z.value, Q, Ze.value), t = j.current;
|
|
1295
1295
|
t && (t.value = e), R(e, {
|
|
1296
1296
|
start: t?.selectionStart ?? 0,
|
|
1297
1297
|
end: t?.selectionEnd ?? 0
|
|
1298
1298
|
}, !1);
|
|
1299
|
-
},
|
|
1300
|
-
|
|
1301
|
-
},
|
|
1299
|
+
}, Ot = (e) => {
|
|
1300
|
+
$e.value = e, V.value = !0;
|
|
1301
|
+
}, kt = () => {
|
|
1302
1302
|
V.value = !1, j.current?.focus();
|
|
1303
|
-
}, $ = W.value ? ze(
|
|
1303
|
+
}, $ = W.value ? ze(S ?? [], nt.value) : [];
|
|
1304
1304
|
G.value >= $.length && (G.value = Math.max(0, $.length - 1));
|
|
1305
|
-
let
|
|
1305
|
+
let At = $.map((e) => ({
|
|
1306
1306
|
id: e.id,
|
|
1307
1307
|
label: e.label,
|
|
1308
1308
|
...e.hint !== void 0 && { hint: e.hint }
|
|
1309
|
-
})), { anchorStyle:
|
|
1310
|
-
anchorRef:
|
|
1311
|
-
floatingRef:
|
|
1309
|
+
})), { anchorStyle: jt, floatingStyle: Mt } = t({
|
|
1310
|
+
anchorRef: at,
|
|
1311
|
+
floatingRef: ot,
|
|
1312
1312
|
placement: "bottom-start",
|
|
1313
1313
|
enabled: W
|
|
1314
|
-
}),
|
|
1314
|
+
}), Nt = {
|
|
1315
1315
|
applyEdit: ({ from: e, to: t }, n) => {
|
|
1316
1316
|
let r = j.current;
|
|
1317
1317
|
r && (r.setRangeText(n, e, t, "end"), R(r.value, {
|
|
@@ -1327,12 +1327,12 @@ var P = {
|
|
|
1327
1327
|
} : { ...L.current };
|
|
1328
1328
|
},
|
|
1329
1329
|
focus: () => j.current?.focus(),
|
|
1330
|
-
undo:
|
|
1331
|
-
redo:
|
|
1332
|
-
openFind: () =>
|
|
1330
|
+
undo: Ke,
|
|
1331
|
+
redo: qe,
|
|
1332
|
+
openFind: () => Ot(!1),
|
|
1333
1333
|
openCommandMenu: () => {
|
|
1334
1334
|
let e = j.current;
|
|
1335
|
-
!e || !
|
|
1335
|
+
!e || !S || S.length === 0 || y || b || (e.focus(), e.setRangeText("/", e.selectionStart, e.selectionEnd, "end"), R(e.value, {
|
|
1336
1336
|
start: e.selectionStart,
|
|
1337
1337
|
end: e.selectionEnd
|
|
1338
1338
|
}, !1), U.value = e.selectionStart, L.current = {
|
|
@@ -1341,84 +1341,84 @@ var P = {
|
|
|
1341
1341
|
});
|
|
1342
1342
|
}
|
|
1343
1343
|
};
|
|
1344
|
-
u(
|
|
1345
|
-
let
|
|
1344
|
+
u(T, () => Nt);
|
|
1345
|
+
let Pt = (e) => {
|
|
1346
1346
|
let t = $[e], n = j.current;
|
|
1347
|
-
if (!t || !n ||
|
|
1348
|
-
let r =
|
|
1347
|
+
if (!t || !n || y || b) return;
|
|
1348
|
+
let r = tt.value, i = n.selectionStart;
|
|
1349
1349
|
n.setRangeText(t.insert ?? "", r, i, "end"), R(n.value, {
|
|
1350
1350
|
start: n.selectionStart,
|
|
1351
1351
|
end: n.selectionEnd
|
|
1352
1352
|
}, !1), U.value = n.selectionStart, L.current = {
|
|
1353
1353
|
start: n.selectionStart,
|
|
1354
1354
|
end: n.selectionEnd
|
|
1355
|
-
}, W.value = !1, G.value = 0, n.focus(), t.run?.(
|
|
1356
|
-
},
|
|
1357
|
-
let t = e.currentTarget, n = !
|
|
1355
|
+
}, W.value = !1, G.value = 0, n.focus(), t.run?.(Nt);
|
|
1356
|
+
}, Ft = (e) => {
|
|
1357
|
+
let t = e.currentTarget, n = !y && !b, r = {};
|
|
1358
1358
|
if (n) {
|
|
1359
1359
|
let { indent: e, dedent: t } = Me({
|
|
1360
|
-
tabSize:
|
|
1361
|
-
insertSpaces:
|
|
1360
|
+
tabSize: h,
|
|
1361
|
+
insertSpaces: g
|
|
1362
1362
|
});
|
|
1363
|
-
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (
|
|
1364
|
-
let n = () => (
|
|
1363
|
+
r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (Ke(), !0);
|
|
1364
|
+
let n = () => (qe(), !0);
|
|
1365
1365
|
r["Mod-Shift-z"] = n, r["Mod-y"] = n;
|
|
1366
1366
|
}
|
|
1367
|
-
if (r["Mod-f"] = () => (
|
|
1368
|
-
let e =
|
|
1369
|
-
return e ? (e(
|
|
1370
|
-
}, V.value && (r.Escape = () => (
|
|
1367
|
+
if (r["Mod-f"] = () => (Ot(!1), !0), r["Mod-Alt-f"] = () => (Ot(!0), !0), r["Mod-s"] = () => {
|
|
1368
|
+
let e = xe.current;
|
|
1369
|
+
return e ? (e(E.value), !0) : !1;
|
|
1370
|
+
}, V.value && (r.Escape = () => (kt(), !0)), W.value) {
|
|
1371
1371
|
let e = (e) => () => {
|
|
1372
1372
|
let t = $.length;
|
|
1373
1373
|
return t > 0 && (G.value = (G.value + e + t) % t), !0;
|
|
1374
1374
|
};
|
|
1375
1375
|
r.ArrowDown = e(1), r.ArrowUp = e(-1);
|
|
1376
|
-
let t = () => ($.length > 0 &&
|
|
1377
|
-
r.Enter = t, r.Tab = t, r.Escape = () => (
|
|
1376
|
+
let t = () => ($.length > 0 && Pt(G.value), !0);
|
|
1377
|
+
r.Enter = t, r.Tab = t, r.Escape = () => (rt.value = tt.value, W.value = !1, !0);
|
|
1378
1378
|
}
|
|
1379
|
-
je(Ae(r,
|
|
1379
|
+
je(Ae(r, de), {
|
|
1380
1380
|
textarea: t,
|
|
1381
1381
|
event: e,
|
|
1382
|
-
setText:
|
|
1383
|
-
}) && e.preventDefault(),
|
|
1384
|
-
},
|
|
1385
|
-
"--cascivo-editor-tab-size":
|
|
1386
|
-
...
|
|
1387
|
-
...
|
|
1382
|
+
setText: We
|
|
1383
|
+
}) && e.preventDefault(), ge?.(e);
|
|
1384
|
+
}, It = {
|
|
1385
|
+
"--cascivo-editor-tab-size": h,
|
|
1386
|
+
...fe,
|
|
1387
|
+
...he
|
|
1388
1388
|
};
|
|
1389
1389
|
return /* @__PURE__ */ p("div", {
|
|
1390
1390
|
ref: O,
|
|
1391
|
-
className: e(
|
|
1392
|
-
"data-wrap":
|
|
1393
|
-
"data-line-numbers":
|
|
1394
|
-
style:
|
|
1395
|
-
children: [
|
|
1391
|
+
className: e(w.root, me),
|
|
1392
|
+
"data-wrap": _,
|
|
1393
|
+
"data-line-numbers": m,
|
|
1394
|
+
style: It,
|
|
1395
|
+
children: [m && /* @__PURE__ */ f(ye, {
|
|
1396
1396
|
count: J,
|
|
1397
|
-
className:
|
|
1397
|
+
className: w.gutter,
|
|
1398
1398
|
gutterRef: A,
|
|
1399
1399
|
start: X,
|
|
1400
1400
|
end: Z,
|
|
1401
|
-
topPad:
|
|
1402
|
-
bottomPad:
|
|
1401
|
+
topPad: gt,
|
|
1402
|
+
bottomPad: _t,
|
|
1403
1403
|
activeLine: !0
|
|
1404
1404
|
}), /* @__PURE__ */ p("div", {
|
|
1405
|
-
className:
|
|
1405
|
+
className: w.codeArea,
|
|
1406
1406
|
children: [
|
|
1407
1407
|
/* @__PURE__ */ p("pre", {
|
|
1408
1408
|
ref: k,
|
|
1409
|
-
className:
|
|
1409
|
+
className: w.pre,
|
|
1410
1410
|
"aria-hidden": "true",
|
|
1411
1411
|
children: [
|
|
1412
|
-
/* @__PURE__ */ f("div", { className:
|
|
1413
|
-
|
|
1414
|
-
/* @__PURE__ */ f("code", { children:
|
|
1415
|
-
|
|
1412
|
+
/* @__PURE__ */ f("div", { className: w.currentLine }),
|
|
1413
|
+
gt > 0 && /* @__PURE__ */ f("div", { style: { blockSize: gt } }),
|
|
1414
|
+
/* @__PURE__ */ f("code", { children: ve(ht, X, Z, St) }),
|
|
1415
|
+
_t > 0 && /* @__PURE__ */ f("div", { style: { blockSize: _t } })
|
|
1416
1416
|
]
|
|
1417
1417
|
}),
|
|
1418
1418
|
/* @__PURE__ */ f("textarea", {
|
|
1419
1419
|
ref: j,
|
|
1420
|
-
className:
|
|
1421
|
-
value:
|
|
1420
|
+
className: w.textarea,
|
|
1421
|
+
value: E.value,
|
|
1422
1422
|
onChange: (e) => {
|
|
1423
1423
|
let t = e.currentTarget, n = t.value, r = Math.abs(n.length - F.current.length) === 1;
|
|
1424
1424
|
R(n, {
|
|
@@ -1426,58 +1426,58 @@ var P = {
|
|
|
1426
1426
|
end: t.selectionEnd
|
|
1427
1427
|
}, r);
|
|
1428
1428
|
},
|
|
1429
|
-
onKeyDown:
|
|
1430
|
-
readOnly:
|
|
1431
|
-
disabled:
|
|
1432
|
-
spellCheck:
|
|
1429
|
+
onKeyDown: Ft,
|
|
1430
|
+
readOnly: y,
|
|
1431
|
+
disabled: b,
|
|
1432
|
+
spellCheck: se,
|
|
1433
1433
|
role: "combobox",
|
|
1434
|
-
"aria-label":
|
|
1434
|
+
"aria-label": le ?? ce ?? c(s.editor.label),
|
|
1435
1435
|
"aria-expanded": W.value,
|
|
1436
|
-
"aria-controls": W.value ?
|
|
1437
|
-
"aria-activedescendant": W.value ? `${
|
|
1436
|
+
"aria-controls": W.value ? st : void 0,
|
|
1437
|
+
"aria-activedescendant": W.value ? `${st}-opt-${G.value}` : void 0,
|
|
1438
1438
|
autoCapitalize: "off",
|
|
1439
1439
|
autoCorrect: "off",
|
|
1440
1440
|
autoComplete: "off",
|
|
1441
|
-
wrap:
|
|
1442
|
-
...
|
|
1441
|
+
wrap: _ ? "soft" : "off",
|
|
1442
|
+
..._e
|
|
1443
1443
|
}),
|
|
1444
1444
|
/* @__PURE__ */ f("div", {
|
|
1445
|
-
ref:
|
|
1445
|
+
ref: at,
|
|
1446
1446
|
"aria-hidden": "true",
|
|
1447
1447
|
style: {
|
|
1448
1448
|
position: "absolute",
|
|
1449
1449
|
inlineSize: 0,
|
|
1450
1450
|
blockSize: 0,
|
|
1451
|
-
...
|
|
1451
|
+
...jt
|
|
1452
1452
|
}
|
|
1453
1453
|
}),
|
|
1454
1454
|
W.value && /* @__PURE__ */ f(Be, {
|
|
1455
|
-
ref:
|
|
1456
|
-
id:
|
|
1457
|
-
items:
|
|
1455
|
+
ref: ot,
|
|
1456
|
+
id: st,
|
|
1457
|
+
items: At,
|
|
1458
1458
|
activeIndex: G.value,
|
|
1459
|
-
onSelect:
|
|
1459
|
+
onSelect: Pt,
|
|
1460
1460
|
onHover: (e) => G.value = e,
|
|
1461
|
-
style:
|
|
1461
|
+
style: Mt
|
|
1462
1462
|
}),
|
|
1463
|
-
V.value && /* @__PURE__ */ f(
|
|
1464
|
-
query:
|
|
1465
|
-
replaceQuery:
|
|
1466
|
-
replaceMode:
|
|
1467
|
-
caseSensitive:
|
|
1463
|
+
V.value && /* @__PURE__ */ f(be, {
|
|
1464
|
+
query: Xe.value,
|
|
1465
|
+
replaceQuery: Ze.value,
|
|
1466
|
+
replaceMode: $e.value,
|
|
1467
|
+
caseSensitive: Qe.value,
|
|
1468
1468
|
matchCount: Q.length,
|
|
1469
1469
|
currentIndex: Q.length > 0 ? H.value : -1,
|
|
1470
1470
|
onQueryChange: (e) => {
|
|
1471
|
-
|
|
1471
|
+
Xe.value = e, H.value = 0;
|
|
1472
1472
|
},
|
|
1473
|
-
onReplaceChange: (e) =>
|
|
1474
|
-
onNext:
|
|
1475
|
-
onPrev:
|
|
1476
|
-
onReplace:
|
|
1477
|
-
onReplaceAll:
|
|
1478
|
-
onToggleCase: () =>
|
|
1479
|
-
onToggleReplace: () =>
|
|
1480
|
-
onClose:
|
|
1473
|
+
onReplaceChange: (e) => Ze.value = e,
|
|
1474
|
+
onNext: wt,
|
|
1475
|
+
onPrev: Tt,
|
|
1476
|
+
onReplace: Et,
|
|
1477
|
+
onReplaceAll: Dt,
|
|
1478
|
+
onToggleCase: () => Qe.value = !Qe.value,
|
|
1479
|
+
onToggleReplace: () => $e.value = !$e.value,
|
|
1480
|
+
onClose: kt
|
|
1481
1481
|
})
|
|
1482
1482
|
]
|
|
1483
1483
|
})]
|
|
@@ -1485,32 +1485,32 @@ var P = {
|
|
|
1485
1485
|
});
|
|
1486
1486
|
//#endregion
|
|
1487
1487
|
//#region src/editor/highlight/highlight.tsx
|
|
1488
|
-
function
|
|
1488
|
+
function F({ value: t, language: n = "plaintext", lineNumbers: r = !1, wrap: i = !1, tabSize: a = 2, label: s, ariaLabel: c, className: l, preRef: u, gutterRef: d, style: ee, ...te }) {
|
|
1489
1489
|
o();
|
|
1490
|
-
let
|
|
1490
|
+
let ne = oe(n), m = t.split("\n"), h = re(ne, m, 0, m.length, ae(ne)), ie = {
|
|
1491
1491
|
"--cascivo-editor-tab-size": a,
|
|
1492
|
-
...
|
|
1492
|
+
...ee
|
|
1493
1493
|
};
|
|
1494
1494
|
return /* @__PURE__ */ p("div", {
|
|
1495
|
-
className: e(
|
|
1495
|
+
className: e(C.root, l),
|
|
1496
1496
|
"data-wrap": i,
|
|
1497
1497
|
"data-line-numbers": r,
|
|
1498
|
-
style:
|
|
1499
|
-
"aria-label": s,
|
|
1500
|
-
...
|
|
1501
|
-
children: [r && /* @__PURE__ */ f(
|
|
1498
|
+
style: ie,
|
|
1499
|
+
"aria-label": c ?? s,
|
|
1500
|
+
...te,
|
|
1501
|
+
children: [r && /* @__PURE__ */ f(ye, {
|
|
1502
1502
|
count: h.length,
|
|
1503
|
-
className:
|
|
1504
|
-
gutterRef:
|
|
1503
|
+
className: C.gutter,
|
|
1504
|
+
gutterRef: d
|
|
1505
1505
|
}), /* @__PURE__ */ f("pre", {
|
|
1506
|
-
ref:
|
|
1507
|
-
className:
|
|
1506
|
+
ref: u,
|
|
1507
|
+
className: C.pre,
|
|
1508
1508
|
children: /* @__PURE__ */ f("code", {
|
|
1509
|
-
className:
|
|
1510
|
-
children:
|
|
1509
|
+
className: C.code,
|
|
1510
|
+
children: ve(h)
|
|
1511
1511
|
})
|
|
1512
1512
|
})]
|
|
1513
1513
|
});
|
|
1514
1514
|
}
|
|
1515
1515
|
//#endregion
|
|
1516
|
-
export {
|
|
1516
|
+
export { He as CodeEditor, F as Highlight, he as bash, ae as createLineStateIndex, b as createRuleGrammar, pe as css, oe as getGrammar, S as html, x as javascript, ce as json, y as listGrammars, me as markdown, se as plaintext, v as registerGrammar, m as tokenize, h as tokenizeDocument, re as tokenizeRange, fe as typescript };
|