@nice2dev/ui 1.4.1 → 1.4.2
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/CHANGELOG.md +44 -0
- package/dist/NiceCodeEditor-DhdjnDLV.cjs +289 -0
- package/dist/{NiceDataGrid-BT6iCUgP.cjs → NiceDataGrid-CrKDzMM1.cjs} +1 -1
- package/dist/{NiceForm-Bysp66Ef.cjs → NiceForm-CT9hEXpc.cjs} +1 -1
- package/dist/NiceLoginForm-C2-WgRn0.cjs +1 -0
- package/dist/NiceMention-BZEHqPrf.cjs +432 -0
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-BbznsXFd.cjs → NiceSavedQueryPanel-C5Ab_NWx.cjs} +1 -1
- package/dist/NiceScheduler-BZQAKEVF.cjs +5 -0
- package/dist/{NiceWindow-pgR4c-kQ.cjs → NiceWindow-BklnkBpu.cjs} +1 -1
- package/dist/charts/NiceLinearGauge.mjs +96 -83
- package/dist/charts/NicePolarChart.mjs +47 -47
- package/dist/charts-BzlvCCg9.cjs +768 -0
- package/dist/charts.cjs +1 -1
- package/dist/{core-lazy-CL4ZIxF-.cjs → core-lazy-VTd5zfoZ.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/display/NiceAvatar.mjs +40 -24
- package/dist/editors/pickers/NiceDateRangeBox.mjs +92 -92
- package/dist/editors/pickers/NiceDateTimePicker.mjs +173 -173
- package/dist/editors/rich/NiceCodeEditor.mjs +645 -584
- package/dist/editors/rich/NiceDocumentEditor.mjs +277 -254
- package/dist/editors.cjs +1 -1
- package/dist/feedback/NiceDrawer.mjs +15 -15
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +202 -202
- package/dist/index.d.ts +18 -0
- package/dist/lazy.cjs +1 -1
- package/dist/navigation/NiceNavShell.mjs +646 -593
- package/dist/navigation/NiceSidebarNav.mjs +844 -823
- package/dist/navigation.cjs +1 -1
- package/dist/overlays/NiceWindow.mjs +91 -91
- package/dist/overlays.cjs +1 -1
- package/dist/planning/NiceScheduler.mjs +170 -169
- package/dist/planning/NiceSchedulerViews.mjs +242 -233
- package/dist/style.css +2 -2
- package/dist/utility/intlNames.mjs +26 -16
- package/package.json +4 -4
- package/dist/NiceCodeEditor-D0QZW88r.cjs +0 -268
- package/dist/NiceLoginForm-FGf32sro.cjs +0 -1
- package/dist/NiceMention-sc8W-DwH.cjs +0 -430
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +0 -1
- package/dist/NiceScheduler-3Ez0zSQJ.cjs +0 -5
- package/dist/charts-B0tHOpJ7.cjs +0 -768
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { injectStyleOnce as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as W, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as ke, useControllableState as de, NiceTutorialButton as tt, resolveTutorial as rt, NiceIcon as O, createTabEscape as We, useThemeIsDark as ot } from "@nice2dev/ui-core";
|
|
3
|
+
import { forwardRef as nt, useRef as v, useState as D, useMemo as Te, useEffect as S, useImperativeHandle as it, useId as ct, useCallback as Oe } from "react";
|
|
4
|
+
import { injectStyleOnce as ye } from "../../utility/injectStyleOnce.mjs";
|
|
5
|
+
const at = [
|
|
6
6
|
{
|
|
7
7
|
target: ".nice-code-editor-wrap",
|
|
8
8
|
titleKey: "tutorial.codeEditor.intro.title",
|
|
@@ -12,333 +12,396 @@ const nt = [
|
|
|
12
12
|
placement: "auto"
|
|
13
13
|
}
|
|
14
14
|
];
|
|
15
|
-
let
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
15
|
+
let re = null, ce = null;
|
|
16
|
+
const dt = "0.45.0", De = `https://cdn.jsdelivr.net/npm/monaco-editor@${dt}/min`, be = `${De}/vs`, Re = 15e3;
|
|
17
|
+
function Ie() {
|
|
18
|
+
const r = window;
|
|
19
|
+
if (r.MonacoEnvironment?.getWorkerUrl)
|
|
20
20
|
return;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
getWorkerUrl: () =>
|
|
21
|
+
const i = `self.MonacoEnvironment={baseUrl:'${De}/'};importScripts('${be}/base/worker/workerMain.js');`, d = URL.createObjectURL(new Blob([i], { type: "text/javascript" }));
|
|
22
|
+
r.MonacoEnvironment = {
|
|
23
|
+
getWorkerUrl: () => d
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
26
|
+
function se(r) {
|
|
27
|
+
if (r !== "auto")
|
|
28
|
+
return r;
|
|
29
29
|
if (typeof document > "u")
|
|
30
30
|
return "vs";
|
|
31
|
-
const
|
|
32
|
-
return
|
|
31
|
+
const i = document.documentElement.dataset.theme;
|
|
32
|
+
return i === "dark" ? "vs-dark" : i === "light" ? "vs" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "vs-dark" : "vs";
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const Pe = "nice-auto";
|
|
35
|
+
let oe;
|
|
36
|
+
function st(r) {
|
|
37
|
+
if (!r || typeof document > "u" || (oe === void 0 && (oe = document.createElement("canvas").getContext("2d")), !oe))
|
|
38
|
+
return null;
|
|
39
|
+
const i = "#010203";
|
|
40
|
+
oe.fillStyle = i, oe.fillStyle = r;
|
|
41
|
+
const d = String(oe.fillStyle);
|
|
42
|
+
if (d === i && r.trim().toLowerCase() !== i)
|
|
43
|
+
return null;
|
|
44
|
+
if (d.startsWith("#"))
|
|
45
|
+
return d;
|
|
46
|
+
const t = d.match(/rgba?\(([^)]+)\)/);
|
|
47
|
+
if (!t)
|
|
48
|
+
return null;
|
|
49
|
+
const [u, C, x, p = 1] = t[1].split(",").map((n) => parseFloat(n)), b = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
50
|
+
return `#${b(u)}${b(C)}${b(x)}${p < 1 ? b(p * 255) : ""}`;
|
|
51
|
+
}
|
|
52
|
+
function lt(r) {
|
|
53
|
+
const i = parseInt(r.slice(1, 3), 16), d = parseInt(r.slice(3, 5), 16), t = parseInt(r.slice(5, 7), 16);
|
|
54
|
+
return (0.299 * i + 0.587 * d + 0.114 * t) / 255;
|
|
55
|
+
}
|
|
56
|
+
function le(r, i, d) {
|
|
57
|
+
if (i !== "auto" || !d || typeof getComputedStyle > "u")
|
|
58
|
+
return se(i);
|
|
59
|
+
const t = getComputedStyle(d), u = (...L) => {
|
|
60
|
+
for (const R of L) {
|
|
61
|
+
const f = st(t.getPropertyValue(R).trim());
|
|
62
|
+
if (f)
|
|
63
|
+
return f;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}, C = u("--nice-bg-primary", "--bg-primary"), x = u("--nice-text-primary", "--text-primary");
|
|
67
|
+
if (!C || !x)
|
|
68
|
+
return se(i);
|
|
69
|
+
const p = u("--nice-bg-secondary", "--bg-secondary") ?? C, b = u("--nice-text-secondary", "--text-secondary") ?? x, n = u("--nice-color-primary", "--primary") ?? x, B = u("--nice-border-color", "--border-color") ?? b, M = n.slice(0, 7);
|
|
70
|
+
return r.editor.defineTheme(Pe, {
|
|
71
|
+
base: lt(C) < 0.5 ? "vs-dark" : "vs",
|
|
72
|
+
inherit: !0,
|
|
73
|
+
rules: [],
|
|
74
|
+
colors: {
|
|
75
|
+
"editor.background": C,
|
|
76
|
+
"editor.foreground": x,
|
|
77
|
+
"editorLineNumber.foreground": b,
|
|
78
|
+
"editorLineNumber.activeForeground": x,
|
|
79
|
+
"editorCursor.foreground": M,
|
|
80
|
+
"editor.selectionBackground": `${M}40`,
|
|
81
|
+
"editor.inactiveSelectionBackground": `${M}26`,
|
|
82
|
+
"editor.lineHighlightBackground": p,
|
|
83
|
+
"editor.lineHighlightBorder": p,
|
|
84
|
+
"editorWidget.background": p,
|
|
85
|
+
"editorWidget.border": B,
|
|
86
|
+
"editorSuggestWidget.background": p,
|
|
87
|
+
"editorSuggestWidget.border": B,
|
|
88
|
+
"minimap.background": C
|
|
89
|
+
}
|
|
90
|
+
}), Pe;
|
|
91
|
+
}
|
|
92
|
+
function ze(r, i) {
|
|
93
|
+
const d = new MutationObserver(i), t = {
|
|
94
|
+
attributes: !0,
|
|
95
|
+
attributeFilter: ["data-theme", "class", "style"]
|
|
96
|
+
};
|
|
97
|
+
d.observe(document.documentElement, t);
|
|
98
|
+
const u = r?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");
|
|
99
|
+
u && u !== document.documentElement && d.observe(u, t);
|
|
100
|
+
const C = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
101
|
+
return C?.addEventListener?.("change", i), () => {
|
|
102
|
+
d.disconnect(), C?.removeEventListener?.("change", i);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function ut(r) {
|
|
106
|
+
if (!r)
|
|
36
107
|
return "";
|
|
37
108
|
try {
|
|
38
|
-
return JSON.stringify([
|
|
109
|
+
return JSON.stringify([r.url, r.language, r.initOptions ?? null]);
|
|
39
110
|
} catch {
|
|
40
|
-
return JSON.stringify([
|
|
111
|
+
return JSON.stringify([r.url, r.language]);
|
|
41
112
|
}
|
|
42
113
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
114
|
+
function Ve() {
|
|
115
|
+
return ce ? Promise.resolve(ce) : re || (re = new Promise((r, i) => {
|
|
45
116
|
if (window.monaco) {
|
|
46
|
-
|
|
117
|
+
Ie(), ce = window.monaco, r(ce);
|
|
47
118
|
return;
|
|
48
119
|
}
|
|
49
|
-
let
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
120
|
+
let d = !1;
|
|
121
|
+
const t = window.setTimeout(() => {
|
|
122
|
+
d || (d = !0, re = null, i(new Error(`Monaco editor failed to load within ${Re}ms`)));
|
|
123
|
+
}, Re), u = document.createElement("script");
|
|
124
|
+
u.src = `${be}/loader.min.js`, u.async = !0, u.onload = () => {
|
|
125
|
+
const C = window.require;
|
|
126
|
+
C.config({ paths: { vs: be } }), Ie(), C(["vs/editor/editor.main"], (x) => {
|
|
127
|
+
d || (d = !0, window.clearTimeout(t), ce = x, r(x));
|
|
57
128
|
});
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
}, document.head.appendChild(
|
|
61
|
-
}),
|
|
129
|
+
}, u.onerror = () => {
|
|
130
|
+
d || (d = !0, window.clearTimeout(t), re = null, i(new Error("Failed to load Monaco Editor loader script")));
|
|
131
|
+
}, document.head.appendChild(u);
|
|
132
|
+
}), re);
|
|
62
133
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
134
|
+
function $e(r) {
|
|
135
|
+
S(() => {
|
|
136
|
+
const i = r.current;
|
|
137
|
+
if (!i)
|
|
67
138
|
return;
|
|
68
|
-
const
|
|
69
|
-
|
|
139
|
+
const d = We(), t = (u) => {
|
|
140
|
+
d(u) && u.stopPropagation();
|
|
70
141
|
};
|
|
71
|
-
return
|
|
72
|
-
}, [
|
|
142
|
+
return i.addEventListener("keydown", t, !0), () => i.removeEventListener("keydown", t, !0);
|
|
143
|
+
}, [r]);
|
|
73
144
|
}
|
|
74
|
-
const
|
|
75
|
-
function(
|
|
76
|
-
const { t
|
|
77
|
-
|
|
145
|
+
const kt = /* @__PURE__ */ nt(
|
|
146
|
+
function(i, d) {
|
|
147
|
+
const { t } = ke();
|
|
148
|
+
ye(ve, Ce);
|
|
78
149
|
const {
|
|
79
|
-
value:
|
|
80
|
-
defaultValue:
|
|
81
|
-
onChange:
|
|
82
|
-
language:
|
|
83
|
-
theme:
|
|
84
|
-
options:
|
|
85
|
-
height:
|
|
86
|
-
width:
|
|
87
|
-
markers:
|
|
88
|
-
decorations:
|
|
89
|
-
completionProvider:
|
|
150
|
+
value: u,
|
|
151
|
+
defaultValue: C,
|
|
152
|
+
onChange: x,
|
|
153
|
+
language: p = "plaintext",
|
|
154
|
+
theme: b = "auto",
|
|
155
|
+
options: n = {},
|
|
156
|
+
height: B = 400,
|
|
157
|
+
width: M = "100%",
|
|
158
|
+
markers: L = [],
|
|
159
|
+
decorations: R = [],
|
|
160
|
+
completionProvider: f,
|
|
90
161
|
onMount: z,
|
|
91
162
|
onCursorPositionChange: E,
|
|
92
|
-
onSelectionChange:
|
|
93
|
-
onSave:
|
|
94
|
-
loading:
|
|
95
|
-
disabled:
|
|
96
|
-
showToolbar:
|
|
163
|
+
onSelectionChange: I,
|
|
164
|
+
onSave: U,
|
|
165
|
+
loading: V,
|
|
166
|
+
disabled: $ = !1,
|
|
167
|
+
showToolbar: Q = !1,
|
|
97
168
|
showStatusBar: j = !1,
|
|
98
|
-
editorSize:
|
|
99
|
-
className:
|
|
100
|
-
"data-testid":
|
|
101
|
-
lsp:
|
|
102
|
-
extraLibs:
|
|
103
|
-
tutorial:
|
|
104
|
-
} =
|
|
105
|
-
value:
|
|
106
|
-
defaultValue:
|
|
169
|
+
editorSize: K = "standard",
|
|
170
|
+
className: Z,
|
|
171
|
+
"data-testid": q,
|
|
172
|
+
lsp: P,
|
|
173
|
+
extraLibs: w,
|
|
174
|
+
tutorial: G
|
|
175
|
+
} = i, [_, X, ee] = de({
|
|
176
|
+
value: u,
|
|
177
|
+
defaultValue: C,
|
|
107
178
|
fallbackValue: "",
|
|
108
|
-
onChange:
|
|
179
|
+
onChange: x,
|
|
109
180
|
componentName: "NiceCodeEditor"
|
|
110
|
-
}),
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
181
|
+
}), Y = v(X);
|
|
182
|
+
Y.current = X;
|
|
183
|
+
const k = v(_);
|
|
184
|
+
k.current = _;
|
|
185
|
+
const l = v(!1), g = v(null);
|
|
186
|
+
$e(g);
|
|
187
|
+
const a = v(null), N = v(null), F = v([]), H = v(null), [T, me] = D(!0), [ne, je] = D(null), [xe, Fe] = D({
|
|
117
188
|
lineNumber: 1,
|
|
118
189
|
column: 1
|
|
119
|
-
}), [
|
|
190
|
+
}), [we, He] = D(""), [pe, Be] = D(n.wordWrap === "on"), ae = Te(() => ({
|
|
120
191
|
automaticLayout: !0,
|
|
121
|
-
readOnly:
|
|
122
|
-
minimap: { enabled:
|
|
123
|
-
lineNumbers:
|
|
124
|
-
wordWrap:
|
|
125
|
-
tabSize:
|
|
126
|
-
insertSpaces:
|
|
127
|
-
fontSize:
|
|
128
|
-
fontFamily:
|
|
129
|
-
fontLigatures:
|
|
130
|
-
cursorStyle:
|
|
131
|
-
cursorBlinking:
|
|
132
|
-
autoClosingBrackets:
|
|
133
|
-
autoClosingQuotes:
|
|
134
|
-
formatOnPaste:
|
|
135
|
-
formatOnType:
|
|
136
|
-
renderWhitespace:
|
|
137
|
-
renderControlCharacters:
|
|
138
|
-
scrollBeyondLastLine:
|
|
139
|
-
smoothScrolling:
|
|
140
|
-
folding:
|
|
141
|
-
showFoldingControls:
|
|
142
|
-
"bracketPairColorization.enabled":
|
|
143
|
-
guides:
|
|
192
|
+
readOnly: $ || n.readOnly,
|
|
193
|
+
minimap: { enabled: n.minimap ?? !0 },
|
|
194
|
+
lineNumbers: n.lineNumbers ?? "on",
|
|
195
|
+
wordWrap: n.wordWrap ?? "off",
|
|
196
|
+
tabSize: n.tabSize ?? 2,
|
|
197
|
+
insertSpaces: n.insertSpaces ?? !0,
|
|
198
|
+
fontSize: n.fontSize ?? 14,
|
|
199
|
+
fontFamily: n.fontFamily ?? "'Fira Code', 'Consolas', 'Monaco', monospace",
|
|
200
|
+
fontLigatures: n.fontLigatures ?? !0,
|
|
201
|
+
cursorStyle: n.cursorStyle ?? "line",
|
|
202
|
+
cursorBlinking: n.cursorBlinking ?? "blink",
|
|
203
|
+
autoClosingBrackets: n.autoClosingBrackets ?? "languageDefined",
|
|
204
|
+
autoClosingQuotes: n.autoClosingQuotes ?? "languageDefined",
|
|
205
|
+
formatOnPaste: n.formatOnPaste ?? !1,
|
|
206
|
+
formatOnType: n.formatOnType ?? !1,
|
|
207
|
+
renderWhitespace: n.renderWhitespace ?? "selection",
|
|
208
|
+
renderControlCharacters: n.renderControlCharacters ?? !1,
|
|
209
|
+
scrollBeyondLastLine: n.scrollBeyondLastLine ?? !0,
|
|
210
|
+
smoothScrolling: n.smoothScrolling ?? !0,
|
|
211
|
+
folding: n.folding ?? !0,
|
|
212
|
+
showFoldingControls: n.showFoldingControls ?? "mouseover",
|
|
213
|
+
"bracketPairColorization.enabled": n.bracketPairColorization ?? !0,
|
|
214
|
+
guides: n.guides ?? {
|
|
144
215
|
bracketPairs: !0,
|
|
145
216
|
indentation: !0,
|
|
146
217
|
highlightActiveIndentation: !0
|
|
147
218
|
},
|
|
148
|
-
stickyScroll: { enabled:
|
|
149
|
-
quickSuggestions:
|
|
150
|
-
suggestOnTriggerCharacters:
|
|
151
|
-
acceptSuggestionOnEnter:
|
|
152
|
-
inlayHints: { enabled:
|
|
153
|
-
}), [
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
if (!
|
|
219
|
+
stickyScroll: { enabled: n.stickyScroll ?? !1 },
|
|
220
|
+
quickSuggestions: n.quickSuggestions ?? !0,
|
|
221
|
+
suggestOnTriggerCharacters: n.suggestOnTriggerCharacters ?? !0,
|
|
222
|
+
acceptSuggestionOnEnter: n.acceptSuggestionOnEnter ?? "on",
|
|
223
|
+
inlayHints: { enabled: n.inlayHints ? "on" : "off" }
|
|
224
|
+
}), [n, $]), ie = v({ onCursorPositionChange: E, onSelectionChange: I, onSave: U, onMount: z });
|
|
225
|
+
ie.current = { onCursorPositionChange: E, onSelectionChange: I, onSave: U, onMount: z };
|
|
226
|
+
const _e = v({ language: p, theme: b, editorOptions: ae });
|
|
227
|
+
_e.current = { language: p, theme: b, editorOptions: ae };
|
|
228
|
+
const Ne = v(P);
|
|
229
|
+
Ne.current = P;
|
|
230
|
+
const Ue = ut(P), Se = v(t);
|
|
231
|
+
Se.current = t, S(() => {
|
|
232
|
+
if (!g.current)
|
|
162
233
|
return;
|
|
163
234
|
let e = !0;
|
|
164
|
-
const
|
|
165
|
-
return
|
|
166
|
-
if (!e || !
|
|
235
|
+
const s = Ne.current;
|
|
236
|
+
return Ve().then(async (c) => {
|
|
237
|
+
if (!e || !g.current)
|
|
167
238
|
return;
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
value:
|
|
171
|
-
language:
|
|
172
|
-
theme:
|
|
173
|
-
...
|
|
239
|
+
N.current = c;
|
|
240
|
+
const h = _e.current, y = c.editor.create(g.current, {
|
|
241
|
+
value: k.current,
|
|
242
|
+
language: h.language,
|
|
243
|
+
theme: se(h.theme),
|
|
244
|
+
...h.editorOptions
|
|
174
245
|
});
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
}),
|
|
178
|
-
(
|
|
179
|
-
|
|
180
|
-
lineNumber:
|
|
181
|
-
column:
|
|
246
|
+
if (a.current = y, me(!1), y.onDidChangeModelContent(() => {
|
|
247
|
+
l.current || Y.current(y.getValue());
|
|
248
|
+
}), y.onDidChangeCursorPosition(
|
|
249
|
+
(m) => {
|
|
250
|
+
Fe({ lineNumber: m.position.lineNumber, column: m.position.column }), ie.current.onCursorPositionChange?.({
|
|
251
|
+
lineNumber: m.position.lineNumber,
|
|
252
|
+
column: m.position.column
|
|
182
253
|
});
|
|
183
254
|
}
|
|
184
|
-
),
|
|
185
|
-
(
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
startLineNumber:
|
|
189
|
-
startColumn:
|
|
190
|
-
endLineNumber:
|
|
191
|
-
endColumn:
|
|
255
|
+
), y.onDidChangeCursorSelection(
|
|
256
|
+
(m) => {
|
|
257
|
+
const A = m.selection, te = y.getModel()?.getValueInRange(A) ?? "";
|
|
258
|
+
He(te), ie.current.onSelectionChange?.({
|
|
259
|
+
startLineNumber: A.startLineNumber,
|
|
260
|
+
startColumn: A.startColumn,
|
|
261
|
+
endLineNumber: A.endLineNumber,
|
|
262
|
+
endColumn: A.endColumn
|
|
192
263
|
});
|
|
193
264
|
}
|
|
194
|
-
),
|
|
195
|
-
|
|
196
|
-
}),
|
|
265
|
+
), y.addCommand(c.KeyMod.CtrlCmd | c.KeyCode.KeyS, () => {
|
|
266
|
+
ie.current.onSave?.(y.getValue());
|
|
267
|
+
}), s && typeof window < "u")
|
|
197
268
|
try {
|
|
198
|
-
await
|
|
269
|
+
await ue(
|
|
199
270
|
"https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"
|
|
200
|
-
), await
|
|
271
|
+
), await ue(
|
|
201
272
|
"https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js"
|
|
202
273
|
);
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
274
|
+
const m = window, A = m.ReconnectingWebSocket, { MonacoLanguageClient: te, CloseAction: Ye, ErrorAction: Je, createConnection: Ee } = m.monacoLanguageClient || {};
|
|
275
|
+
if (te && Ee) {
|
|
276
|
+
const Qe = s.url, Ze = s.language, Me = new A(Qe), Ge = new m.VSCodeWebSocketMessageReader(Me), Xe = new m.VSCodeWebSocketMessageWriter(Me), et = Ee(Ge, Xe), Le = new te({
|
|
206
277
|
name: "LSP Client",
|
|
207
278
|
clientOptions: {
|
|
208
|
-
documentSelector: [
|
|
209
|
-
initializationOptions:
|
|
279
|
+
documentSelector: [Ze],
|
|
280
|
+
initializationOptions: s.initOptions,
|
|
210
281
|
errorHandler: {
|
|
211
|
-
error: () =>
|
|
212
|
-
closed: () =>
|
|
282
|
+
error: () => Je.Continue,
|
|
283
|
+
closed: () => Ye.Restart
|
|
213
284
|
}
|
|
214
285
|
},
|
|
215
286
|
connectionProvider: {
|
|
216
|
-
get: () => Promise.resolve(
|
|
287
|
+
get: () => Promise.resolve(et)
|
|
217
288
|
}
|
|
218
289
|
});
|
|
219
|
-
|
|
290
|
+
Le.start(), a.current.__lspClient = Le;
|
|
220
291
|
}
|
|
221
|
-
} catch (
|
|
222
|
-
console.warn("LSP bridge failed to load:",
|
|
292
|
+
} catch (m) {
|
|
293
|
+
console.warn("LSP bridge failed to load:", m);
|
|
223
294
|
}
|
|
224
|
-
|
|
225
|
-
}).catch((
|
|
226
|
-
e && (
|
|
227
|
-
|
|
228
|
-
),
|
|
295
|
+
ie.current.onMount?.(y, c);
|
|
296
|
+
}).catch((c) => {
|
|
297
|
+
e && (je(
|
|
298
|
+
c.message ?? Se.current("codeEditor.failedToLoadEditor", "Failed to load editor")
|
|
299
|
+
), me(!1));
|
|
229
300
|
}), () => {
|
|
230
|
-
if (e = !1,
|
|
301
|
+
if (e = !1, a.current?.dispose(), H.current?.dispose(), a.current && a.current.__lspClient)
|
|
231
302
|
try {
|
|
232
|
-
|
|
303
|
+
a.current.__lspClient.stop();
|
|
233
304
|
} catch {
|
|
234
305
|
}
|
|
235
306
|
};
|
|
236
|
-
}, [
|
|
237
|
-
const e =
|
|
238
|
-
if (!
|
|
307
|
+
}, [Ue]), S(() => {
|
|
308
|
+
const e = a.current;
|
|
309
|
+
if (!ee || !e || _ === e.getValue())
|
|
239
310
|
return;
|
|
240
|
-
const
|
|
241
|
-
|
|
311
|
+
const s = e.getPosition();
|
|
312
|
+
l.current = !0;
|
|
242
313
|
try {
|
|
243
|
-
e.setValue(
|
|
314
|
+
e.setValue(_);
|
|
244
315
|
} finally {
|
|
245
|
-
|
|
316
|
+
l.current = !1;
|
|
246
317
|
}
|
|
247
|
-
|
|
248
|
-
}, [
|
|
249
|
-
const e =
|
|
250
|
-
if (e &&
|
|
251
|
-
const
|
|
252
|
-
|
|
318
|
+
s && e.setPosition(s);
|
|
319
|
+
}, [_, ee]), S(() => {
|
|
320
|
+
const e = a.current, s = N.current;
|
|
321
|
+
if (e && s) {
|
|
322
|
+
const c = e.getModel();
|
|
323
|
+
c && s.editor.setModelLanguage(c, p);
|
|
253
324
|
}
|
|
254
|
-
}, [
|
|
255
|
-
const e =
|
|
256
|
-
if (!e ||
|
|
325
|
+
}, [p]), S(() => {
|
|
326
|
+
const e = N.current;
|
|
327
|
+
if (!e || T || !w || w.length === 0 || p !== "javascript" && p !== "typescript")
|
|
257
328
|
return;
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
329
|
+
const s = e.languages?.typescript;
|
|
330
|
+
if (!s)
|
|
260
331
|
return;
|
|
261
|
-
const
|
|
332
|
+
const c = [];
|
|
262
333
|
try {
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
334
|
+
w.forEach((h, y) => {
|
|
335
|
+
const m = h.filePath ?? `inmemory://model/nice-extralib-${y}.d.ts`, A = s.typescriptDefaults?.addExtraLib(h.content, m);
|
|
336
|
+
A && c.push(A);
|
|
337
|
+
const te = s.javascriptDefaults?.addExtraLib(h.content, m);
|
|
338
|
+
te && c.push(te);
|
|
268
339
|
});
|
|
269
|
-
} catch (
|
|
270
|
-
console.warn("Failed to register extraLibs:",
|
|
340
|
+
} catch (h) {
|
|
341
|
+
console.warn("Failed to register extraLibs:", h);
|
|
271
342
|
}
|
|
272
343
|
return () => {
|
|
273
|
-
|
|
344
|
+
c.forEach((h) => {
|
|
274
345
|
try {
|
|
275
|
-
|
|
346
|
+
h.dispose();
|
|
276
347
|
} catch {
|
|
277
348
|
}
|
|
278
349
|
});
|
|
279
350
|
};
|
|
280
|
-
}, [
|
|
281
|
-
const e =
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (n) {
|
|
303
|
-
const m = D.map((v) => ({
|
|
304
|
-
startLineNumber: v.startLineNumber,
|
|
305
|
-
startColumn: v.startColumn,
|
|
306
|
-
endLineNumber: v.endLineNumber,
|
|
307
|
-
endColumn: v.endColumn,
|
|
308
|
-
message: v.message,
|
|
309
|
-
severity: v.severity
|
|
351
|
+
}, [w, p, T]), S(() => {
|
|
352
|
+
const e = N.current;
|
|
353
|
+
if (e && (e.editor.setTheme(le(e, b, g.current)), !(b !== "auto" || typeof document > "u")))
|
|
354
|
+
return ze(g.current, () => {
|
|
355
|
+
const s = N.current;
|
|
356
|
+
s?.editor.setTheme(le(s, "auto", g.current));
|
|
357
|
+
});
|
|
358
|
+
}, [b, T]), S(() => {
|
|
359
|
+
const e = a.current;
|
|
360
|
+
e && e.updateOptions(ae);
|
|
361
|
+
}, [ae]), S(() => {
|
|
362
|
+
const e = a.current, s = N.current;
|
|
363
|
+
if (e && s) {
|
|
364
|
+
const c = e.getModel();
|
|
365
|
+
if (c) {
|
|
366
|
+
const h = L.map((y) => ({
|
|
367
|
+
startLineNumber: y.startLineNumber,
|
|
368
|
+
startColumn: y.startColumn,
|
|
369
|
+
endLineNumber: y.endLineNumber,
|
|
370
|
+
endColumn: y.endColumn,
|
|
371
|
+
message: y.message,
|
|
372
|
+
severity: y.severity
|
|
310
373
|
}));
|
|
311
|
-
|
|
374
|
+
s.editor.setModelMarkers(c, "owner", h);
|
|
312
375
|
}
|
|
313
376
|
}
|
|
314
|
-
}, [
|
|
315
|
-
const e =
|
|
316
|
-
if (e &&
|
|
317
|
-
const
|
|
377
|
+
}, [L]), S(() => {
|
|
378
|
+
const e = a.current;
|
|
379
|
+
if (e && R.length > 0) {
|
|
380
|
+
const s = R.map((c) => ({
|
|
318
381
|
range: {
|
|
319
|
-
startLineNumber:
|
|
320
|
-
startColumn:
|
|
321
|
-
endLineNumber:
|
|
322
|
-
endColumn:
|
|
382
|
+
startLineNumber: c.range.startLineNumber,
|
|
383
|
+
startColumn: c.range.startColumn,
|
|
384
|
+
endLineNumber: c.range.endLineNumber,
|
|
385
|
+
endColumn: c.range.endColumn
|
|
323
386
|
},
|
|
324
387
|
options: {
|
|
325
|
-
className:
|
|
326
|
-
glyphMarginClassName:
|
|
327
|
-
hoverMessage:
|
|
328
|
-
isWholeLine:
|
|
388
|
+
className: c.className,
|
|
389
|
+
glyphMarginClassName: c.glyphMarginClassName,
|
|
390
|
+
hoverMessage: c.hoverMessage ? { value: c.hoverMessage } : void 0,
|
|
391
|
+
isWholeLine: c.isWholeLine
|
|
329
392
|
}
|
|
330
393
|
}));
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
394
|
+
F.current = e.deltaDecorations(
|
|
395
|
+
F.current,
|
|
396
|
+
s
|
|
334
397
|
);
|
|
335
398
|
}
|
|
336
|
-
}, [
|
|
337
|
-
const e =
|
|
338
|
-
if (!e || !
|
|
399
|
+
}, [R]), S(() => {
|
|
400
|
+
const e = N.current;
|
|
401
|
+
if (!e || !f)
|
|
339
402
|
return;
|
|
340
403
|
H.current?.dispose();
|
|
341
|
-
const
|
|
404
|
+
const s = {
|
|
342
405
|
text: 0,
|
|
343
406
|
method: 1,
|
|
344
407
|
function: 2,
|
|
@@ -356,119 +419,119 @@ const ut = /* @__PURE__ */ Xe(
|
|
|
356
419
|
reference: 17,
|
|
357
420
|
folder: 18
|
|
358
421
|
};
|
|
359
|
-
return H.current = e.languages.registerCompletionItemProvider(
|
|
360
|
-
provideCompletionItems: async (
|
|
361
|
-
suggestions: (await
|
|
362
|
-
label:
|
|
363
|
-
kind:
|
|
364
|
-
insertText:
|
|
365
|
-
insertTextRules:
|
|
366
|
-
documentation:
|
|
367
|
-
detail:
|
|
422
|
+
return H.current = e.languages.registerCompletionItemProvider(p, {
|
|
423
|
+
provideCompletionItems: async (c, h) => ({
|
|
424
|
+
suggestions: (await f(c, h)).map((m) => ({
|
|
425
|
+
label: m.label,
|
|
426
|
+
kind: s[m.kind] ?? 0,
|
|
427
|
+
insertText: m.insertText,
|
|
428
|
+
insertTextRules: m.insertTextRules === "insertAsSnippet" ? 4 : void 0,
|
|
429
|
+
documentation: m.documentation,
|
|
430
|
+
detail: m.detail,
|
|
368
431
|
range: {
|
|
369
|
-
startLineNumber:
|
|
370
|
-
startColumn:
|
|
371
|
-
endLineNumber:
|
|
372
|
-
endColumn:
|
|
432
|
+
startLineNumber: h.lineNumber,
|
|
433
|
+
startColumn: h.column,
|
|
434
|
+
endLineNumber: h.lineNumber,
|
|
435
|
+
endColumn: h.column
|
|
373
436
|
}
|
|
374
437
|
}))
|
|
375
438
|
})
|
|
376
439
|
}), () => {
|
|
377
440
|
H.current?.dispose();
|
|
378
441
|
};
|
|
379
|
-
}, [
|
|
380
|
-
|
|
442
|
+
}, [p, f]), it(
|
|
443
|
+
d,
|
|
381
444
|
() => ({
|
|
382
|
-
getEditor: () =>
|
|
383
|
-
getMonaco: () =>
|
|
384
|
-
focus: () =>
|
|
385
|
-
getValue: () =>
|
|
386
|
-
setValue: (e) =>
|
|
445
|
+
getEditor: () => a.current,
|
|
446
|
+
getMonaco: () => N.current,
|
|
447
|
+
focus: () => a.current?.focus(),
|
|
448
|
+
getValue: () => a.current?.getValue() ?? "",
|
|
449
|
+
setValue: (e) => a.current?.setValue(e),
|
|
387
450
|
getSelection: () => {
|
|
388
|
-
const e =
|
|
451
|
+
const e = a.current;
|
|
389
452
|
if (!e)
|
|
390
453
|
return "";
|
|
391
|
-
const
|
|
392
|
-
return
|
|
454
|
+
const s = e.getSelection();
|
|
455
|
+
return s ? e.getModel()?.getValueInRange(s) ?? "" : "";
|
|
393
456
|
},
|
|
394
457
|
insertText: (e) => {
|
|
395
|
-
const
|
|
396
|
-
if (!
|
|
458
|
+
const s = a.current;
|
|
459
|
+
if (!s)
|
|
397
460
|
return;
|
|
398
|
-
const
|
|
399
|
-
|
|
461
|
+
const c = s.getSelection();
|
|
462
|
+
c && s.executeEdits("", [{ range: c, text: e }]);
|
|
400
463
|
},
|
|
401
464
|
formatDocument: () => {
|
|
402
|
-
|
|
465
|
+
a.current?.getAction("editor.action.formatDocument")?.run();
|
|
403
466
|
},
|
|
404
|
-
goToLine: (e,
|
|
405
|
-
const
|
|
406
|
-
|
|
467
|
+
goToLine: (e, s = 1) => {
|
|
468
|
+
const c = a.current;
|
|
469
|
+
c && (c.setPosition({ lineNumber: e, column: s }), c.revealLineInCenter(e), c.focus());
|
|
407
470
|
},
|
|
408
471
|
findReplace: () => {
|
|
409
|
-
|
|
472
|
+
a.current?.getAction("editor.action.startFindReplaceAction")?.run();
|
|
410
473
|
},
|
|
411
474
|
undo: () => {
|
|
412
|
-
|
|
475
|
+
a.current?.trigger("keyboard", "undo", null);
|
|
413
476
|
},
|
|
414
477
|
redo: () => {
|
|
415
|
-
|
|
478
|
+
a.current?.trigger("keyboard", "redo", null);
|
|
416
479
|
},
|
|
417
480
|
getCursorPosition: () => {
|
|
418
|
-
const e =
|
|
481
|
+
const e = a.current?.getPosition();
|
|
419
482
|
return { lineNumber: e?.lineNumber ?? 1, column: e?.column ?? 1 };
|
|
420
483
|
},
|
|
421
484
|
setMarkers: (e) => {
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
const
|
|
427
|
-
startLineNumber:
|
|
428
|
-
startColumn:
|
|
429
|
-
endLineNumber:
|
|
430
|
-
endColumn:
|
|
431
|
-
message:
|
|
432
|
-
severity:
|
|
485
|
+
const s = a.current, c = N.current;
|
|
486
|
+
if (s && c) {
|
|
487
|
+
const h = s.getModel();
|
|
488
|
+
if (h) {
|
|
489
|
+
const y = e.map((m) => ({
|
|
490
|
+
startLineNumber: m.startLineNumber,
|
|
491
|
+
startColumn: m.startColumn,
|
|
492
|
+
endLineNumber: m.endLineNumber,
|
|
493
|
+
endColumn: m.endColumn,
|
|
494
|
+
message: m.message,
|
|
495
|
+
severity: m.severity
|
|
433
496
|
}));
|
|
434
|
-
|
|
497
|
+
c.editor.setModelMarkers(h, "owner", y);
|
|
435
498
|
}
|
|
436
499
|
}
|
|
437
500
|
}
|
|
438
501
|
}),
|
|
439
502
|
[]
|
|
440
503
|
);
|
|
441
|
-
const
|
|
504
|
+
const J = Te(
|
|
442
505
|
() => ({
|
|
443
|
-
format: () =>
|
|
444
|
-
undo: () =>
|
|
445
|
-
redo: () =>
|
|
446
|
-
find: () =>
|
|
506
|
+
format: () => a.current?.getAction("editor.action.formatDocument")?.run(),
|
|
507
|
+
undo: () => a.current?.trigger("keyboard", "undo", null),
|
|
508
|
+
redo: () => a.current?.trigger("keyboard", "redo", null),
|
|
509
|
+
find: () => a.current?.getAction("editor.action.startFindReplaceAction")?.run(),
|
|
447
510
|
toggleWordWrap: () => {
|
|
448
|
-
const e = !
|
|
449
|
-
|
|
511
|
+
const e = !pe;
|
|
512
|
+
Be(e), a.current?.updateOptions({ wordWrap: e ? "on" : "off" });
|
|
450
513
|
},
|
|
451
514
|
toggleMinimap: () => {
|
|
452
|
-
const e =
|
|
453
|
-
|
|
515
|
+
const e = a.current?.getOption?.(
|
|
516
|
+
N.current?.editor?.EditorOption?.minimap
|
|
454
517
|
);
|
|
455
|
-
|
|
518
|
+
a.current?.updateOptions({ minimap: { enabled: !e?.enabled } });
|
|
456
519
|
},
|
|
457
|
-
foldAll: () =>
|
|
458
|
-
unfoldAll: () =>
|
|
520
|
+
foldAll: () => a.current?.getAction("editor.foldAll")?.run(),
|
|
521
|
+
unfoldAll: () => a.current?.getAction("editor.unfoldAll")?.run()
|
|
459
522
|
}),
|
|
460
|
-
[
|
|
461
|
-
),
|
|
462
|
-
`).length,
|
|
463
|
-
return /* @__PURE__ */
|
|
523
|
+
[pe]
|
|
524
|
+
), Ke = _.split(`
|
|
525
|
+
`).length, qe = _.length;
|
|
526
|
+
return /* @__PURE__ */ W(
|
|
464
527
|
"div",
|
|
465
528
|
{
|
|
466
|
-
className: `nice-code-editor-wrap nice-editor--${
|
|
467
|
-
style: { height:
|
|
468
|
-
"data-testid":
|
|
529
|
+
className: `nice-code-editor-wrap nice-editor--${K} ${Z ?? ""}`,
|
|
530
|
+
style: { height: B, width: M, display: "flex", flexDirection: "column", position: "relative" },
|
|
531
|
+
"data-testid": q,
|
|
469
532
|
children: [
|
|
470
|
-
/* @__PURE__ */
|
|
471
|
-
|
|
533
|
+
/* @__PURE__ */ o("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 20 }, children: /* @__PURE__ */ o(tt, { steps: rt(G, at) }) }),
|
|
534
|
+
ne && /* @__PURE__ */ W(
|
|
472
535
|
"div",
|
|
473
536
|
{
|
|
474
537
|
className: "nice-code-editor__error",
|
|
@@ -479,24 +542,24 @@ const ut = /* @__PURE__ */ Xe(
|
|
|
479
542
|
background: "var(--nice-bg-primary, #fff)"
|
|
480
543
|
},
|
|
481
544
|
children: [
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ W("span", { children: [
|
|
546
|
+
/* @__PURE__ */ o(O, { name: "warning", size: 16 }),
|
|
484
547
|
" ",
|
|
485
|
-
|
|
548
|
+
ne
|
|
486
549
|
] }),
|
|
487
|
-
/* @__PURE__ */
|
|
550
|
+
/* @__PURE__ */ o(
|
|
488
551
|
"textarea",
|
|
489
552
|
{
|
|
490
|
-
value:
|
|
491
|
-
onChange: (e) =>
|
|
492
|
-
readOnly:
|
|
553
|
+
value: _,
|
|
554
|
+
onChange: (e) => X(e.target.value),
|
|
555
|
+
readOnly: $ || n.readOnly,
|
|
493
556
|
style: { width: "100%", height: "100%", fontFamily: "monospace" }
|
|
494
557
|
}
|
|
495
558
|
)
|
|
496
559
|
]
|
|
497
560
|
}
|
|
498
561
|
),
|
|
499
|
-
|
|
562
|
+
T && !ne && /* @__PURE__ */ o(
|
|
500
563
|
"div",
|
|
501
564
|
{
|
|
502
565
|
className: "nice-code-editor__loader-overlay",
|
|
@@ -509,108 +572,108 @@ const ut = /* @__PURE__ */ Xe(
|
|
|
509
572
|
justifyContent: "center",
|
|
510
573
|
background: "var(--nice-bg-primary, #fff)"
|
|
511
574
|
},
|
|
512
|
-
children:
|
|
575
|
+
children: V ?? /* @__PURE__ */ o("div", { className: "nice-code-editor__loader", children: t("codeEditor.loadingEditor", "Loading editor...") })
|
|
513
576
|
}
|
|
514
577
|
),
|
|
515
|
-
|
|
516
|
-
/* @__PURE__ */
|
|
578
|
+
Q && /* @__PURE__ */ W("div", { className: "nice-code-editor__toolbar", children: [
|
|
579
|
+
/* @__PURE__ */ o(
|
|
517
580
|
"button",
|
|
518
581
|
{
|
|
519
582
|
className: "nice-code-editor__toolbar-btn",
|
|
520
|
-
onClick:
|
|
521
|
-
title:
|
|
522
|
-
"aria-label":
|
|
523
|
-
children: /* @__PURE__ */
|
|
583
|
+
onClick: J.undo,
|
|
584
|
+
title: t("codeEditor.undoCtrlZ", "Undo (Ctrl+Z)"),
|
|
585
|
+
"aria-label": t("codeEditor.undo", "Undo"),
|
|
586
|
+
children: /* @__PURE__ */ o(O, { name: "reply", size: 16 })
|
|
524
587
|
}
|
|
525
588
|
),
|
|
526
|
-
/* @__PURE__ */
|
|
589
|
+
/* @__PURE__ */ o(
|
|
527
590
|
"button",
|
|
528
591
|
{
|
|
529
592
|
className: "nice-code-editor__toolbar-btn",
|
|
530
|
-
onClick:
|
|
531
|
-
title:
|
|
532
|
-
"aria-label":
|
|
533
|
-
children: /* @__PURE__ */
|
|
593
|
+
onClick: J.redo,
|
|
594
|
+
title: t("codeEditor.redoCtrlY", "Redo (Ctrl+Y)"),
|
|
595
|
+
"aria-label": t("codeEditor.redo", "Redo"),
|
|
596
|
+
children: /* @__PURE__ */ o(O, { name: "forward", size: 16 })
|
|
534
597
|
}
|
|
535
598
|
),
|
|
536
|
-
/* @__PURE__ */
|
|
537
|
-
/* @__PURE__ */
|
|
599
|
+
/* @__PURE__ */ o("span", { className: "nice-code-editor__toolbar-sep" }),
|
|
600
|
+
/* @__PURE__ */ o(
|
|
538
601
|
"button",
|
|
539
602
|
{
|
|
540
603
|
className: "nice-code-editor__toolbar-btn",
|
|
541
|
-
onClick:
|
|
542
|
-
title:
|
|
543
|
-
"aria-label":
|
|
544
|
-
children: /* @__PURE__ */
|
|
604
|
+
onClick: J.format,
|
|
605
|
+
title: t("codeEditor.formatShiftAltF", "Format (Shift+Alt+F)"),
|
|
606
|
+
"aria-label": t("codeEditor.format", "Format"),
|
|
607
|
+
children: /* @__PURE__ */ o(O, { name: "type", size: 16 })
|
|
545
608
|
}
|
|
546
609
|
),
|
|
547
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ o(
|
|
548
611
|
"button",
|
|
549
612
|
{
|
|
550
613
|
className: "nice-code-editor__toolbar-btn",
|
|
551
|
-
onClick:
|
|
552
|
-
title:
|
|
553
|
-
"aria-label":
|
|
554
|
-
children: /* @__PURE__ */
|
|
614
|
+
onClick: J.find,
|
|
615
|
+
title: t("codeEditor.findReplaceCtrlH", "Find & Replace (Ctrl+H)"),
|
|
616
|
+
"aria-label": t("codeEditor.findReplace", "Find & Replace"),
|
|
617
|
+
children: /* @__PURE__ */ o(O, { name: "search", size: 16 })
|
|
555
618
|
}
|
|
556
619
|
),
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
-
/* @__PURE__ */
|
|
620
|
+
/* @__PURE__ */ o("span", { className: "nice-code-editor__toolbar-sep" }),
|
|
621
|
+
/* @__PURE__ */ o(
|
|
559
622
|
"button",
|
|
560
623
|
{
|
|
561
|
-
className: `nice-code-editor__toolbar-btn${
|
|
562
|
-
onClick:
|
|
563
|
-
title:
|
|
564
|
-
"aria-label":
|
|
565
|
-
children: /* @__PURE__ */
|
|
624
|
+
className: `nice-code-editor__toolbar-btn${pe ? " nice-code-editor__toolbar-btn--active" : ""}`,
|
|
625
|
+
onClick: J.toggleWordWrap,
|
|
626
|
+
title: t("codeEditor.toggleWordWrap", "Toggle Word Wrap"),
|
|
627
|
+
"aria-label": t("codeEditor.toggleWordWrap", "Toggle Word Wrap"),
|
|
628
|
+
children: /* @__PURE__ */ o(O, { name: "align-left", size: 16 })
|
|
566
629
|
}
|
|
567
630
|
),
|
|
568
|
-
/* @__PURE__ */
|
|
631
|
+
/* @__PURE__ */ o(
|
|
569
632
|
"button",
|
|
570
633
|
{
|
|
571
634
|
className: "nice-code-editor__toolbar-btn",
|
|
572
|
-
onClick:
|
|
573
|
-
title:
|
|
574
|
-
"aria-label":
|
|
575
|
-
children: /* @__PURE__ */
|
|
635
|
+
onClick: J.toggleMinimap,
|
|
636
|
+
title: t("codeEditor.toggleMinimap", "Toggle Minimap"),
|
|
637
|
+
"aria-label": t("codeEditor.toggleMinimap", "Toggle Minimap"),
|
|
638
|
+
children: /* @__PURE__ */ o(O, { name: "columns", size: 16 })
|
|
576
639
|
}
|
|
577
640
|
),
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ o("span", { className: "nice-code-editor__toolbar-sep" }),
|
|
642
|
+
/* @__PURE__ */ o(
|
|
580
643
|
"button",
|
|
581
644
|
{
|
|
582
645
|
className: "nice-code-editor__toolbar-btn",
|
|
583
|
-
onClick:
|
|
584
|
-
title:
|
|
585
|
-
"aria-label":
|
|
586
|
-
children: /* @__PURE__ */
|
|
646
|
+
onClick: J.foldAll,
|
|
647
|
+
title: t("codeEditor.foldAll", "Fold All"),
|
|
648
|
+
"aria-label": t("codeEditor.foldAll", "Fold All"),
|
|
649
|
+
children: /* @__PURE__ */ o(O, { name: "collapse", size: 16 })
|
|
587
650
|
}
|
|
588
651
|
),
|
|
589
|
-
/* @__PURE__ */
|
|
652
|
+
/* @__PURE__ */ o(
|
|
590
653
|
"button",
|
|
591
654
|
{
|
|
592
655
|
className: "nice-code-editor__toolbar-btn",
|
|
593
|
-
onClick:
|
|
594
|
-
title:
|
|
595
|
-
"aria-label":
|
|
596
|
-
children: /* @__PURE__ */
|
|
656
|
+
onClick: J.unfoldAll,
|
|
657
|
+
title: t("codeEditor.unfoldAll", "Unfold All"),
|
|
658
|
+
"aria-label": t("codeEditor.unfoldAll", "Unfold All"),
|
|
659
|
+
children: /* @__PURE__ */ o(O, { name: "expand", size: 16 })
|
|
597
660
|
}
|
|
598
661
|
)
|
|
599
662
|
] }),
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
j && /* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
-
|
|
663
|
+
/* @__PURE__ */ o("div", { ref: g, className: "nice-code-editor", style: { flex: 1, minHeight: 0 } }),
|
|
664
|
+
j && /* @__PURE__ */ W("div", { className: "nice-code-editor__statusbar", children: [
|
|
665
|
+
/* @__PURE__ */ o("span", { children: t("codeEditor.lnCol", "Ln {lineNumber}, Col {column}").replace("{lineNumber}", String(xe.lineNumber)).replace("{column}", String(xe.column)) }),
|
|
666
|
+
we.length > 0 && /* @__PURE__ */ o("span", { children: t("codeEditor.selected", "({selectionText} selected)").replace(
|
|
604
667
|
"{selectionText}",
|
|
605
|
-
String(
|
|
668
|
+
String(we.length)
|
|
606
669
|
) }),
|
|
607
|
-
/* @__PURE__ */
|
|
608
|
-
/* @__PURE__ */
|
|
609
|
-
/* @__PURE__ */
|
|
610
|
-
|
|
611
|
-
/* @__PURE__ */
|
|
670
|
+
/* @__PURE__ */ o("span", { className: "nice-code-editor__statusbar-spacer" }),
|
|
671
|
+
/* @__PURE__ */ o("span", { children: t("codeEditor.linesChars", "{lineCount} lines · {charCount} chars").replace("{lineCount}", String(Ke)).replace("{charCount}", String(qe)) }),
|
|
672
|
+
/* @__PURE__ */ o("span", { className: "nice-code-editor__statusbar-lang", children: p }),
|
|
673
|
+
L.length > 0 && /* @__PURE__ */ W("span", { className: "nice-code-editor__statusbar-markers", children: [
|
|
674
|
+
/* @__PURE__ */ o(O, { name: "warning", size: 14 }),
|
|
612
675
|
" ",
|
|
613
|
-
|
|
676
|
+
L.length
|
|
614
677
|
] })
|
|
615
678
|
] })
|
|
616
679
|
]
|
|
@@ -618,120 +681,112 @@ const ut = /* @__PURE__ */ Xe(
|
|
|
618
681
|
);
|
|
619
682
|
}
|
|
620
683
|
);
|
|
621
|
-
function
|
|
622
|
-
const { t:
|
|
623
|
-
|
|
684
|
+
function yt(r) {
|
|
685
|
+
const { t: i } = ke();
|
|
686
|
+
ye(ve, Ce);
|
|
624
687
|
const {
|
|
625
|
-
original:
|
|
626
|
-
defaultOriginal:
|
|
627
|
-
modified:
|
|
628
|
-
defaultModified:
|
|
629
|
-
language:
|
|
630
|
-
theme:
|
|
631
|
-
height:
|
|
632
|
-
width:
|
|
633
|
-
inline:
|
|
634
|
-
renderSideBySide:
|
|
635
|
-
originalEditable:
|
|
636
|
-
modifiedEditable:
|
|
637
|
-
onOriginalChange:
|
|
688
|
+
original: d,
|
|
689
|
+
defaultOriginal: t,
|
|
690
|
+
modified: u,
|
|
691
|
+
defaultModified: C,
|
|
692
|
+
language: x = "plaintext",
|
|
693
|
+
theme: p = "auto",
|
|
694
|
+
height: b = 400,
|
|
695
|
+
width: n = "100%",
|
|
696
|
+
inline: B = !1,
|
|
697
|
+
renderSideBySide: M = !0,
|
|
698
|
+
originalEditable: L = !1,
|
|
699
|
+
modifiedEditable: R = !1,
|
|
700
|
+
onOriginalChange: f,
|
|
638
701
|
onModifiedChange: z,
|
|
639
702
|
loading: E,
|
|
640
|
-
className:
|
|
641
|
-
"data-testid":
|
|
642
|
-
} =
|
|
643
|
-
value:
|
|
644
|
-
defaultValue:
|
|
703
|
+
className: I,
|
|
704
|
+
"data-testid": U
|
|
705
|
+
} = r, [V, $, Q] = de({
|
|
706
|
+
value: d,
|
|
707
|
+
defaultValue: t,
|
|
645
708
|
fallbackValue: "",
|
|
646
|
-
onChange:
|
|
709
|
+
onChange: f,
|
|
647
710
|
componentName: "NiceCodeDiffEditor.original"
|
|
648
|
-
}), [j,
|
|
649
|
-
value:
|
|
650
|
-
defaultValue:
|
|
711
|
+
}), [j, K, Z] = de({
|
|
712
|
+
value: u,
|
|
713
|
+
defaultValue: C,
|
|
651
714
|
fallbackValue: "",
|
|
652
715
|
onChange: z,
|
|
653
716
|
componentName: "NiceCodeDiffEditor.modified"
|
|
654
|
-
}),
|
|
655
|
-
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
const
|
|
659
|
-
return
|
|
660
|
-
if (!
|
|
717
|
+
}), q = v({ currentOriginal: V, currentModified: j, setOriginal: $, setModified: K });
|
|
718
|
+
q.current = { currentOriginal: V, currentModified: j, setOriginal: $, setModified: K };
|
|
719
|
+
const P = v(!1), w = v(null);
|
|
720
|
+
$e(w);
|
|
721
|
+
const G = v(null), _ = v(null), [X, ee] = D(!0), [Y, k] = D(null);
|
|
722
|
+
return S(() => {
|
|
723
|
+
if (!w.current)
|
|
661
724
|
return;
|
|
662
|
-
let
|
|
663
|
-
return
|
|
664
|
-
if (!
|
|
725
|
+
let l = !0;
|
|
726
|
+
return Ve().then((g) => {
|
|
727
|
+
if (!l || !w.current)
|
|
665
728
|
return;
|
|
666
|
-
|
|
667
|
-
const { currentOriginal:
|
|
729
|
+
_.current = g;
|
|
730
|
+
const { currentOriginal: a, currentModified: N } = q.current, F = g.editor.createModel(a, x), H = g.editor.createModel(N, x), T = g.editor.createDiffEditor(w.current, {
|
|
668
731
|
automaticLayout: !0,
|
|
669
|
-
theme:
|
|
670
|
-
renderSideBySide: !
|
|
671
|
-
originalEditable:
|
|
672
|
-
readOnly: !
|
|
732
|
+
theme: se(p),
|
|
733
|
+
renderSideBySide: !B && M,
|
|
734
|
+
originalEditable: L,
|
|
735
|
+
readOnly: !R
|
|
673
736
|
});
|
|
674
|
-
|
|
675
|
-
original:
|
|
737
|
+
T.setModel({
|
|
738
|
+
original: F,
|
|
676
739
|
modified: H
|
|
677
|
-
}),
|
|
678
|
-
|
|
679
|
-
}),
|
|
680
|
-
|
|
740
|
+
}), G.current = T, ee(!1), L && F.onDidChangeContent(() => {
|
|
741
|
+
P.current || q.current.setOriginal(F.getValue());
|
|
742
|
+
}), R && H.onDidChangeContent(() => {
|
|
743
|
+
P.current || q.current.setModified(H.getValue());
|
|
681
744
|
});
|
|
682
|
-
}).catch((
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
),
|
|
745
|
+
}).catch((g) => {
|
|
746
|
+
l && (k(
|
|
747
|
+
g.message ?? i("codeEditor.failedToLoadDiffEditor", "Failed to load diff editor")
|
|
748
|
+
), ee(!1));
|
|
686
749
|
}), () => {
|
|
687
|
-
|
|
750
|
+
l = !1, G.current?.dispose();
|
|
688
751
|
};
|
|
689
|
-
}, [
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
|
|
752
|
+
}, [i]), S(() => {
|
|
753
|
+
const l = G.current?.getModel();
|
|
754
|
+
if (l) {
|
|
755
|
+
P.current = !0;
|
|
693
756
|
try {
|
|
694
|
-
|
|
757
|
+
Q && l.original.getValue() !== V && l.original.setValue(V), Z && l.modified.getValue() !== j && l.modified.setValue(j);
|
|
695
758
|
} finally {
|
|
696
|
-
|
|
759
|
+
P.current = !1;
|
|
697
760
|
}
|
|
698
761
|
}
|
|
699
|
-
}, [
|
|
700
|
-
const
|
|
701
|
-
if (
|
|
702
|
-
return
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
attributes: !0,
|
|
708
|
-
attributeFilter: ["data-theme", "class"]
|
|
709
|
-
});
|
|
710
|
-
const w = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
711
|
-
return w?.addEventListener?.("change", b), () => {
|
|
712
|
-
o.disconnect(), w?.removeEventListener?.("change", b);
|
|
713
|
-
};
|
|
714
|
-
}, [f, $]), u ? /* @__PURE__ */ t(
|
|
762
|
+
}, [V, j, Q, Z]), S(() => {
|
|
763
|
+
const l = _.current;
|
|
764
|
+
if (l && (l.editor.setTheme(le(l, p, w.current)), !(p !== "auto" || typeof document > "u")))
|
|
765
|
+
return ze(w.current, () => {
|
|
766
|
+
const g = _.current;
|
|
767
|
+
g?.editor.setTheme(le(g, "auto", w.current));
|
|
768
|
+
});
|
|
769
|
+
}, [p, X]), Y ? /* @__PURE__ */ o(
|
|
715
770
|
"div",
|
|
716
771
|
{
|
|
717
|
-
className: `nice-code-diff-editor nice-code-diff-editor--error ${
|
|
718
|
-
style: { height:
|
|
719
|
-
"data-testid":
|
|
720
|
-
children: /* @__PURE__ */
|
|
721
|
-
/* @__PURE__ */
|
|
772
|
+
className: `nice-code-diff-editor nice-code-diff-editor--error ${I ?? ""}`,
|
|
773
|
+
style: { height: b, width: n },
|
|
774
|
+
"data-testid": U,
|
|
775
|
+
children: /* @__PURE__ */ o("div", { className: "nice-code-editor__error", children: /* @__PURE__ */ W("span", { children: [
|
|
776
|
+
/* @__PURE__ */ o(O, { name: "warning", size: 16 }),
|
|
722
777
|
" ",
|
|
723
|
-
|
|
778
|
+
Y
|
|
724
779
|
] }) })
|
|
725
780
|
}
|
|
726
|
-
) : /* @__PURE__ */
|
|
781
|
+
) : /* @__PURE__ */ W(
|
|
727
782
|
"div",
|
|
728
783
|
{
|
|
729
|
-
className: `nice-code-diff-editor ${
|
|
730
|
-
style: { height:
|
|
731
|
-
"data-testid":
|
|
784
|
+
className: `nice-code-diff-editor ${I ?? ""}`,
|
|
785
|
+
style: { height: b, width: n, position: "relative" },
|
|
786
|
+
"data-testid": U,
|
|
732
787
|
children: [
|
|
733
|
-
/* @__PURE__ */
|
|
734
|
-
|
|
788
|
+
/* @__PURE__ */ o("div", { ref: w, style: { position: "absolute", inset: 0 } }),
|
|
789
|
+
X && /* @__PURE__ */ o(
|
|
735
790
|
"div",
|
|
736
791
|
{
|
|
737
792
|
style: {
|
|
@@ -743,16 +798,16 @@ function mt(a) {
|
|
|
743
798
|
background: "var(--nice-bg-primary, #fff)",
|
|
744
799
|
zIndex: 2
|
|
745
800
|
},
|
|
746
|
-
children: E ?? /* @__PURE__ */
|
|
801
|
+
children: E ?? /* @__PURE__ */ o("div", { className: "nice-code-editor__loader", children: i("codeEditor.loadingDiffEditor", "Loading diff editor...") })
|
|
747
802
|
}
|
|
748
803
|
)
|
|
749
804
|
]
|
|
750
805
|
}
|
|
751
806
|
);
|
|
752
807
|
}
|
|
753
|
-
const
|
|
754
|
-
let
|
|
755
|
-
const
|
|
808
|
+
const mt = "1.29.0", Ae = `https://cdn.jsdelivr.net/npm/prismjs@${mt}`;
|
|
809
|
+
let ge = null;
|
|
810
|
+
const he = {
|
|
756
811
|
javascript: "javascript",
|
|
757
812
|
typescript: "typescript",
|
|
758
813
|
json: "json",
|
|
@@ -777,151 +832,136 @@ const ge = {
|
|
|
777
832
|
powershell: "powershell",
|
|
778
833
|
plaintext: "plain"
|
|
779
834
|
};
|
|
780
|
-
function
|
|
781
|
-
return new Promise((
|
|
782
|
-
if (document.querySelector(`script[data-prism-src="${
|
|
783
|
-
|
|
835
|
+
function ue(r) {
|
|
836
|
+
return new Promise((i, d) => {
|
|
837
|
+
if (document.querySelector(`script[data-prism-src="${r}"]`)) {
|
|
838
|
+
i();
|
|
784
839
|
return;
|
|
785
840
|
}
|
|
786
|
-
const
|
|
787
|
-
|
|
841
|
+
const t = document.createElement("script");
|
|
842
|
+
t.src = r, t.async = !0, t.dataset.prismSrc = r, t.onload = () => i(), t.onerror = () => d(new Error(`Failed to load ${r}`)), document.head.appendChild(t);
|
|
788
843
|
});
|
|
789
844
|
}
|
|
790
|
-
function
|
|
845
|
+
function pt(r) {
|
|
791
846
|
if (typeof window > "u")
|
|
792
847
|
return Promise.resolve(null);
|
|
793
|
-
const
|
|
794
|
-
if (
|
|
848
|
+
const i = window, d = he[r] ?? "plain", t = async () => {
|
|
849
|
+
if (d !== "plain" && !i.Prism?.languages?.[d])
|
|
795
850
|
try {
|
|
796
|
-
await
|
|
851
|
+
await ue(`${Ae}/components/prism-${d}.min.js`);
|
|
797
852
|
} catch {
|
|
798
853
|
}
|
|
799
854
|
};
|
|
800
|
-
return
|
|
855
|
+
return i.Prism?.languages ? t().then(() => i.Prism) : (ge || (ge = (async () => (window.Prism = { manual: !0 }, await ue(`${Ae}/prism.min.js`), window.Prism))()), ge.then(async () => (await t(), window.Prism)));
|
|
801
856
|
}
|
|
802
|
-
function
|
|
803
|
-
return
|
|
857
|
+
function fe(r) {
|
|
858
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
804
859
|
}
|
|
805
|
-
function
|
|
806
|
-
|
|
860
|
+
function vt(r) {
|
|
861
|
+
ye(ve, Ce);
|
|
807
862
|
const {
|
|
808
|
-
value:
|
|
809
|
-
defaultValue:
|
|
810
|
-
onChange:
|
|
811
|
-
language:
|
|
812
|
-
height:
|
|
813
|
-
width:
|
|
814
|
-
readOnly:
|
|
815
|
-
tabSize:
|
|
816
|
-
lineNumbers:
|
|
817
|
-
placeholder:
|
|
818
|
-
theme:
|
|
819
|
-
className:
|
|
820
|
-
"data-testid":
|
|
821
|
-
} =
|
|
822
|
-
value:
|
|
823
|
-
defaultValue:
|
|
863
|
+
value: i,
|
|
864
|
+
defaultValue: d,
|
|
865
|
+
onChange: t,
|
|
866
|
+
language: u = "plaintext",
|
|
867
|
+
height: C = 300,
|
|
868
|
+
width: x = "100%",
|
|
869
|
+
readOnly: p = !1,
|
|
870
|
+
tabSize: b = 2,
|
|
871
|
+
lineNumbers: n = !0,
|
|
872
|
+
placeholder: B,
|
|
873
|
+
theme: M = "auto",
|
|
874
|
+
className: L,
|
|
875
|
+
"data-testid": R
|
|
876
|
+
} = r, [f, z] = de({
|
|
877
|
+
value: i,
|
|
878
|
+
defaultValue: d,
|
|
824
879
|
fallbackValue: "",
|
|
825
|
-
onChange:
|
|
880
|
+
onChange: t,
|
|
826
881
|
componentName: "NiceSimpleCodeEditor"
|
|
827
|
-
}), E =
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
};
|
|
837
|
-
if (F(l()), U !== "auto" || typeof document > "u")
|
|
838
|
-
return;
|
|
839
|
-
const u = () => F(l()), C = new MutationObserver(u);
|
|
840
|
-
C.observe(document.documentElement, {
|
|
841
|
-
attributes: !0,
|
|
842
|
-
attributeFilter: ["data-theme", "class"]
|
|
843
|
-
});
|
|
844
|
-
const p = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
845
|
-
return p?.addEventListener?.("change", u), () => {
|
|
846
|
-
C.disconnect(), p?.removeEventListener?.("change", u);
|
|
847
|
-
};
|
|
848
|
-
}, [U]), _(() => {
|
|
849
|
-
let l = !0;
|
|
850
|
-
return ct(y).then((u) => {
|
|
851
|
-
if (!l)
|
|
882
|
+
}), E = v(null), I = v(null), U = v(null), { t: V } = ke(), $ = ct(), [Q] = D(We), [j, K] = D(() => fe(f)), Z = v(null), [q] = D(() => ({
|
|
883
|
+
get current() {
|
|
884
|
+
return Z.current?.parentElement ?? null;
|
|
885
|
+
}
|
|
886
|
+
})), P = ot(q), w = M === "auto" ? P ? "dark" : "light" : M;
|
|
887
|
+
S(() => {
|
|
888
|
+
let k = !0;
|
|
889
|
+
return pt(u).then((l) => {
|
|
890
|
+
if (!k)
|
|
852
891
|
return;
|
|
853
|
-
const
|
|
854
|
-
if (
|
|
892
|
+
const g = he[u] ?? "plain";
|
|
893
|
+
if (l?.languages?.[g])
|
|
855
894
|
try {
|
|
856
|
-
const
|
|
857
|
-
|
|
895
|
+
const a = l.highlight(f, l.languages[g], g);
|
|
896
|
+
K(a);
|
|
858
897
|
return;
|
|
859
898
|
} catch {
|
|
860
899
|
}
|
|
861
|
-
|
|
900
|
+
K(fe(f));
|
|
862
901
|
}).catch(() => {
|
|
863
|
-
|
|
902
|
+
k && K(fe(f));
|
|
864
903
|
}), () => {
|
|
865
|
-
|
|
904
|
+
k = !1;
|
|
866
905
|
};
|
|
867
|
-
}, [
|
|
868
|
-
const
|
|
869
|
-
if (!
|
|
906
|
+
}, [f, u]);
|
|
907
|
+
const G = Oe(() => {
|
|
908
|
+
if (!I.current || !E.current)
|
|
870
909
|
return;
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
if (
|
|
874
|
-
const
|
|
875
|
-
|
|
910
|
+
I.current.scrollTop = E.current.scrollTop, I.current.scrollLeft = E.current.scrollLeft;
|
|
911
|
+
const k = U.current;
|
|
912
|
+
if (k) {
|
|
913
|
+
const l = E.current.offsetHeight - E.current.clientHeight;
|
|
914
|
+
k.style.paddingBottom = `calc(var(--nice-space-2, 8px) + ${l}px)`, k.scrollTop = E.current.scrollTop;
|
|
876
915
|
}
|
|
877
|
-
}, []),
|
|
878
|
-
(
|
|
879
|
-
if (!
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
if (
|
|
883
|
-
const T =
|
|
916
|
+
}, []), _ = Oe(
|
|
917
|
+
(k) => {
|
|
918
|
+
if (!Q(k) && k.key === "Tab" && !p) {
|
|
919
|
+
k.preventDefault();
|
|
920
|
+
const l = k.currentTarget, g = l.selectionStart, a = l.selectionEnd, N = " ".repeat(b);
|
|
921
|
+
if (k.shiftKey) {
|
|
922
|
+
const T = f.substring(0, g).lastIndexOf(`
|
|
884
923
|
`) + 1;
|
|
885
|
-
if ((
|
|
886
|
-
const
|
|
887
|
-
z(
|
|
888
|
-
|
|
924
|
+
if ((f.substring(T, g).match(/^(\s*)/)?.[1] ?? "").length >= b) {
|
|
925
|
+
const ne = f.substring(0, T) + f.substring(T + b);
|
|
926
|
+
z(ne), setTimeout(() => {
|
|
927
|
+
l.selectionStart = l.selectionEnd = g - b;
|
|
889
928
|
}, 0);
|
|
890
929
|
}
|
|
891
930
|
} else {
|
|
892
|
-
const
|
|
893
|
-
z(
|
|
894
|
-
|
|
931
|
+
const F = f.substring(0, g) + N + f.substring(a);
|
|
932
|
+
z(F), setTimeout(() => {
|
|
933
|
+
l.selectionStart = l.selectionEnd = g + b;
|
|
895
934
|
}, 0);
|
|
896
935
|
}
|
|
897
936
|
}
|
|
898
937
|
},
|
|
899
|
-
[
|
|
900
|
-
),
|
|
901
|
-
`).length,
|
|
902
|
-
return /* @__PURE__ */
|
|
938
|
+
[f, z, b, Q, p]
|
|
939
|
+
), ee = f.split(`
|
|
940
|
+
`).length, Y = he[u] ?? "plain";
|
|
941
|
+
return /* @__PURE__ */ W(
|
|
903
942
|
"div",
|
|
904
943
|
{
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
"data-
|
|
909
|
-
"data-
|
|
944
|
+
ref: Z,
|
|
945
|
+
className: `nice-simple-code-editor nice-simple-code-editor--${w}${M === "auto" ? " nice-simple-code-editor--auto" : ""} ${L ?? ""}`,
|
|
946
|
+
style: { height: C, width: x },
|
|
947
|
+
"data-testid": R,
|
|
948
|
+
"data-language": u,
|
|
949
|
+
"data-theme": w,
|
|
910
950
|
children: [
|
|
911
|
-
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
/* @__PURE__ */
|
|
951
|
+
n && /* @__PURE__ */ o("div", { ref: U, className: "nice-simple-code-editor__line-numbers", children: Array.from({ length: ee }, (k, l) => /* @__PURE__ */ o("div", { className: "nice-simple-code-editor__line-number", children: l + 1 }, l)) }),
|
|
952
|
+
/* @__PURE__ */ W("div", { className: "nice-simple-code-editor__editor-area", children: [
|
|
953
|
+
/* @__PURE__ */ o(
|
|
914
954
|
"pre",
|
|
915
955
|
{
|
|
916
|
-
ref:
|
|
956
|
+
ref: I,
|
|
917
957
|
"aria-hidden": "true",
|
|
918
|
-
className: `nice-simple-code-editor__highlight language-${
|
|
919
|
-
children: /* @__PURE__ */
|
|
958
|
+
className: `nice-simple-code-editor__highlight language-${Y}`,
|
|
959
|
+
children: /* @__PURE__ */ o(
|
|
920
960
|
"code",
|
|
921
961
|
{
|
|
922
|
-
className: `language-${
|
|
962
|
+
className: `language-${Y}`,
|
|
923
963
|
dangerouslySetInnerHTML: {
|
|
924
|
-
__html: j + (
|
|
964
|
+
__html: j + (f.endsWith(`
|
|
925
965
|
`) ? `
|
|
926
966
|
` : "")
|
|
927
967
|
}
|
|
@@ -929,30 +969,30 @@ function pt(a) {
|
|
|
929
969
|
)
|
|
930
970
|
}
|
|
931
971
|
),
|
|
932
|
-
/* @__PURE__ */
|
|
972
|
+
/* @__PURE__ */ o(
|
|
933
973
|
"textarea",
|
|
934
974
|
{
|
|
935
975
|
ref: E,
|
|
936
976
|
className: "nice-simple-code-editor__textarea",
|
|
937
|
-
value:
|
|
938
|
-
onChange: (
|
|
939
|
-
onKeyDown:
|
|
940
|
-
onScroll:
|
|
941
|
-
readOnly:
|
|
942
|
-
placeholder:
|
|
977
|
+
value: f,
|
|
978
|
+
onChange: (k) => z(k.target.value),
|
|
979
|
+
onKeyDown: _,
|
|
980
|
+
onScroll: G,
|
|
981
|
+
readOnly: p,
|
|
982
|
+
placeholder: B,
|
|
943
983
|
spellCheck: !1,
|
|
944
984
|
autoCapitalize: "off",
|
|
945
985
|
autoCorrect: "off",
|
|
946
|
-
"aria-describedby":
|
|
986
|
+
"aria-describedby": p ? void 0 : $
|
|
947
987
|
}
|
|
948
988
|
),
|
|
949
|
-
!
|
|
989
|
+
!p && /* @__PURE__ */ o("span", { id: $, className: "nice-sr-only", children: V("input.tabEscapeHint", "Tab indents. To leave the editor, press Escape, then Tab.") })
|
|
950
990
|
] })
|
|
951
991
|
]
|
|
952
992
|
}
|
|
953
993
|
);
|
|
954
994
|
}
|
|
955
|
-
const
|
|
995
|
+
const ve = "nice-code-editor-styles", Ce = `
|
|
956
996
|
.nice-code-editor,
|
|
957
997
|
.nice-code-diff-editor {
|
|
958
998
|
border: 1px solid var(--nice-border, #e0e0e0);
|
|
@@ -1074,6 +1114,27 @@ const be = "nice-code-editor-styles", ve = `
|
|
|
1074
1114
|
color: var(--nice-text-muted, #858585);
|
|
1075
1115
|
-webkit-text-fill-color: var(--nice-text-muted, #858585);
|
|
1076
1116
|
}
|
|
1117
|
+
/* theme="auto": the page's theme colours in both light and dark (R43) — the --dark rules above
|
|
1118
|
+
are for an explicit theme="dark" on a light page */
|
|
1119
|
+
.nice-simple-code-editor--auto.nice-simple-code-editor--dark {
|
|
1120
|
+
background: var(--nice-bg-primary);
|
|
1121
|
+
color: var(--nice-text-primary);
|
|
1122
|
+
}
|
|
1123
|
+
.nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
1124
|
+
background: var(--nice-bg-secondary);
|
|
1125
|
+
border-right-color: var(--nice-border-color);
|
|
1126
|
+
color: var(--nice-text-secondary);
|
|
1127
|
+
}
|
|
1128
|
+
.nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
1129
|
+
caret-color: var(--nice-text-primary);
|
|
1130
|
+
}
|
|
1131
|
+
.nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
1132
|
+
color: var(--nice-text-secondary);
|
|
1133
|
+
-webkit-text-fill-color: var(--nice-text-secondary);
|
|
1134
|
+
}
|
|
1135
|
+
.nice-simple-code-editor--auto.nice-simple-code-editor--dark .token.punctuation {
|
|
1136
|
+
color: var(--nice-text-primary);
|
|
1137
|
+
}
|
|
1077
1138
|
|
|
1078
1139
|
/* Prism token colors — light */
|
|
1079
1140
|
.nice-simple-code-editor .token.comment,
|
|
@@ -1216,7 +1277,7 @@ const be = "nice-code-editor-styles", ve = `
|
|
|
1216
1277
|
}
|
|
1217
1278
|
`;
|
|
1218
1279
|
export {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1280
|
+
yt as NiceCodeDiffEditor,
|
|
1281
|
+
kt as NiceCodeEditor,
|
|
1282
|
+
vt as NiceSimpleCodeEditor
|
|
1222
1283
|
};
|