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