@thebuoyant-tsdev/mui-ts-library 3.27.1 → 3.28.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/README.de.md +8 -1
- package/README.md +8 -1
- package/dist/components/sql-editor/SqlEditor.js +65 -37
- package/dist/components/sql-editor/SqlEditorContent.d.ts +2 -1
- package/dist/components/sql-editor/SqlEditorContent.js +66 -60
- package/dist/components/sql-editor/SqlEditorToolbar.js +4 -4
- package/dist/index.cjs +2 -2
- package/package.json +1 -1
package/README.de.md
CHANGED
|
@@ -191,7 +191,7 @@ import { RichTextEditor } from '@thebuoyant-tsdev/mui-ts-library';
|
|
|
191
191
|
|
|
192
192
|
### SqlEditor
|
|
193
193
|
|
|
194
|
-
SQL-Code-Editor mit Syntax-Highlighting, dialektbewusstem Autocomplete und Inline-Linting. Konzipiert für Developer-Tools, Datenbank-Clients und Admin-Panels — mit `Cmd+Enter
|
|
194
|
+
SQL-Code-Editor mit Syntax-Highlighting, dialektbewusstem Autocomplete und Inline-Linting. Konzipiert für Developer-Tools, Datenbank-Clients und Admin-Panels — mit `Cmd+Enter` (Ausführen) und `Shift+Alt+F` (SQL formatieren) als Tastenkürzel, Multi-Dialekt-Support (MySQL, PostgreSQL, SQLite, MSSQL) und Schema-basiertem Autocomplete.
|
|
195
195
|
|
|
196
196
|
```tsx
|
|
197
197
|
import { SqlEditor } from '@thebuoyant-tsdev/mui-ts-library';
|
|
@@ -483,6 +483,13 @@ Dieses Projekt folgt [Semantic Versioning](https://semver.org/):
|
|
|
483
483
|
|
|
484
484
|
## Changelog
|
|
485
485
|
|
|
486
|
+
### [Unveröffentlicht]
|
|
487
|
+
|
|
488
|
+
**Hinzugefügt**
|
|
489
|
+
- `SqlEditor`: `Shift+Alt+F` Tastenkürzel — löst den vorhandenen SQL-Format-Button direkt aus dem Editor heraus aus (respektiert `readonly` und `toolbarConfig.showFormat`). Keine API-Änderung.
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
486
493
|
### [3.27.1] — 2026-07-14
|
|
487
494
|
|
|
488
495
|
**Behoben**
|
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ import { RichTextEditor } from '@thebuoyant-tsdev/mui-ts-library';
|
|
|
191
191
|
|
|
192
192
|
### SqlEditor
|
|
193
193
|
|
|
194
|
-
SQL code editor with syntax highlighting, dialect-aware autocomplete, and inline linting. Designed for developer tools, database clients, and admin panels where users write and execute SQL queries — with `Cmd+Enter`
|
|
194
|
+
SQL code editor with syntax highlighting, dialect-aware autocomplete, and inline linting. Designed for developer tools, database clients, and admin panels where users write and execute SQL queries — with `Cmd+Enter` (Execute) and `Shift+Alt+F` (Format SQL) shortcuts, multi-dialect support (MySQL, PostgreSQL, SQLite, MSSQL), and schema-based autocomplete.
|
|
195
195
|
|
|
196
196
|
```tsx
|
|
197
197
|
import { SqlEditor } from '@thebuoyant-tsdev/mui-ts-library';
|
|
@@ -483,6 +483,13 @@ This project follows [Semantic Versioning](https://semver.org/):
|
|
|
483
483
|
|
|
484
484
|
## Changelog
|
|
485
485
|
|
|
486
|
+
### [Unreleased]
|
|
487
|
+
|
|
488
|
+
**Added**
|
|
489
|
+
- `SqlEditor`: `Shift+Alt+F` keyboard shortcut — triggers the existing SQL Format button directly from the editor (respects `readonly` and `toolbarConfig.showFormat`). No API change.
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
486
493
|
### [3.27.1] — 2026-07-14
|
|
487
494
|
|
|
488
495
|
**Fixed**
|
|
@@ -2,78 +2,105 @@ import { normalizeSize as e } from "../shared/normalizeSize.js";
|
|
|
2
2
|
import { DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG as t, DEFAULT_SQL_EDITOR_TRANSLATION as n } from "./SqlEditor.types.js";
|
|
3
3
|
import { SqlEditorContent as r } from "./SqlEditorContent.js";
|
|
4
4
|
import { SqlEditorToolbar as i } from "./SqlEditorToolbar.js";
|
|
5
|
-
import { SqlEditorFooter as
|
|
6
|
-
import { useSqlQueryHistory as
|
|
7
|
-
import { useCallback as s, useRef as c, useState as l } from "react";
|
|
8
|
-
import { Box as u, Divider as d, Paper as
|
|
9
|
-
import { Fragment as
|
|
5
|
+
import { SqlEditorFooter as ee } from "./SqlEditorFooter.js";
|
|
6
|
+
import { useSqlQueryHistory as a } from "./useSqlQueryHistory.js";
|
|
7
|
+
import { useCallback as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
8
|
+
import { Box as u, Divider as d, Paper as te } from "@mui/material";
|
|
9
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
|
+
import { format as h } from "sql-formatter";
|
|
10
11
|
//#region src/components/sql-editor/SqlEditor.tsx
|
|
11
|
-
|
|
12
|
+
var ne = {
|
|
13
|
+
standard: "sql",
|
|
14
|
+
mysql: "mysql",
|
|
15
|
+
postgresql: "postgresql",
|
|
16
|
+
sqlite: "sqlite",
|
|
17
|
+
mssql: "tsql"
|
|
18
|
+
};
|
|
19
|
+
function g({ value: g, onChange: _, placeholder: re, height: v, width: y, disabled: b = !1, readonly: x = !1, error: S = !1, helperText: C, name: w, dialect: T = "standard", showLineNumbers: E = !0, showLineColumn: D = !0, showErrorCount: O = !1, toolbarConfig: k, translation: A, highlightColors: j, schema: M, queryHistoryKey: N = "sql-editor-query-history", queryHistoryMaxEntries: P = 20, onExecute: F, onLint: I, onBlur: L, onFocus: R }) {
|
|
12
20
|
let z = {
|
|
13
21
|
...n,
|
|
14
22
|
...A
|
|
15
23
|
}, B = {
|
|
16
24
|
...t,
|
|
17
25
|
...k
|
|
18
|
-
}, { history:
|
|
26
|
+
}, { history: V, addEntry: H, clearHistory: U } = a(N, P), W = e(v), G = e(y), K = W === "auto", q = K ? void 0 : W ?? 300, J = c(null), [Y, X] = l(null), [Z, ie] = l({
|
|
19
27
|
line: 1,
|
|
20
28
|
col: 1
|
|
21
|
-
}), [
|
|
22
|
-
|
|
23
|
-
}, []),
|
|
24
|
-
|
|
29
|
+
}), [ae, Q] = l(0), oe = o((e) => {
|
|
30
|
+
J.current = e, X(e);
|
|
31
|
+
}, []), se = o((e, t) => {
|
|
32
|
+
ie({
|
|
25
33
|
line: e,
|
|
26
34
|
col: t
|
|
27
35
|
});
|
|
28
|
-
}, []),
|
|
29
|
-
|
|
36
|
+
}, []), ce = o((e) => {
|
|
37
|
+
Q(e);
|
|
30
38
|
}, []), $ = F ? (e) => {
|
|
31
|
-
|
|
32
|
-
} : void 0,
|
|
33
|
-
|
|
39
|
+
H(e), F(e);
|
|
40
|
+
} : void 0, le = s(() => {
|
|
41
|
+
if (!(x || !B.showFormat)) return () => {
|
|
42
|
+
let e = J.current;
|
|
43
|
+
if (!e) return;
|
|
44
|
+
let t = e.state.doc.toString();
|
|
45
|
+
try {
|
|
46
|
+
let n = h(t, { language: ne[T] });
|
|
47
|
+
e.dispatch({ changes: {
|
|
48
|
+
from: 0,
|
|
49
|
+
to: e.state.doc.length,
|
|
50
|
+
insert: n
|
|
51
|
+
} });
|
|
52
|
+
} catch {}
|
|
53
|
+
e.focus();
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
T,
|
|
57
|
+
x,
|
|
58
|
+
B.showFormat
|
|
59
|
+
]), ue = o((e) => {
|
|
60
|
+
let t = J.current;
|
|
34
61
|
t && (t.dispatch({ changes: {
|
|
35
62
|
from: 0,
|
|
36
63
|
to: t.state.doc.length,
|
|
37
64
|
insert: e
|
|
38
65
|
} }), t.focus()), _?.(e);
|
|
39
|
-
}, [_]),
|
|
40
|
-
return /* @__PURE__ */
|
|
66
|
+
}, [_]), de = D || O || !!C;
|
|
67
|
+
return /* @__PURE__ */ m(u, {
|
|
41
68
|
sx: {
|
|
42
|
-
width:
|
|
43
|
-
...
|
|
69
|
+
width: G ?? "100%",
|
|
70
|
+
...K ? {
|
|
44
71
|
display: "flex",
|
|
45
72
|
flexDirection: "column",
|
|
46
73
|
flex: 1
|
|
47
74
|
} : {}
|
|
48
75
|
},
|
|
49
76
|
children: [
|
|
50
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ m(te, {
|
|
51
78
|
variant: "outlined",
|
|
52
79
|
sx: {
|
|
53
80
|
display: "flex",
|
|
54
81
|
flexDirection: "column",
|
|
55
82
|
overflow: "hidden",
|
|
56
|
-
...
|
|
83
|
+
...K ? { flex: 1 } : { height: q },
|
|
57
84
|
borderColor: S ? "error.main" : void 0,
|
|
58
85
|
"&:focus-within": {
|
|
59
86
|
borderColor: S ? "error.main" : "primary.main",
|
|
60
87
|
borderWidth: 2
|
|
61
88
|
}
|
|
62
89
|
},
|
|
63
|
-
children: [!x && /* @__PURE__ */
|
|
64
|
-
editorView:
|
|
90
|
+
children: [!x && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(i, {
|
|
91
|
+
editorView: Y,
|
|
65
92
|
toolbarConfig: B,
|
|
66
93
|
translation: z,
|
|
67
94
|
dialect: T,
|
|
68
95
|
disabled: b,
|
|
69
96
|
onExecute: $,
|
|
70
|
-
queryHistory:
|
|
71
|
-
onSelectHistoryEntry:
|
|
72
|
-
onClearHistory:
|
|
73
|
-
}), /* @__PURE__ */
|
|
97
|
+
queryHistory: V,
|
|
98
|
+
onSelectHistoryEntry: ue,
|
|
99
|
+
onClearHistory: U
|
|
100
|
+
}), /* @__PURE__ */ p(d, {})] }), /* @__PURE__ */ p(r, {
|
|
74
101
|
value: g,
|
|
75
102
|
onChange: _,
|
|
76
|
-
placeholder:
|
|
103
|
+
placeholder: re,
|
|
77
104
|
disabled: b,
|
|
78
105
|
readonly: x,
|
|
79
106
|
showLineNumbers: E,
|
|
@@ -83,25 +110,26 @@ function g({ value: g, onChange: _, placeholder: ee, height: v, width: y, disabl
|
|
|
83
110
|
identifierColor: j?.identifier,
|
|
84
111
|
schema: M,
|
|
85
112
|
onExecute: $,
|
|
113
|
+
onFormat: le,
|
|
86
114
|
onLint: I,
|
|
87
|
-
onDiagnosticsChange: I ?
|
|
88
|
-
onViewReady:
|
|
89
|
-
onCursorChange:
|
|
115
|
+
onDiagnosticsChange: I ? ce : void 0,
|
|
116
|
+
onViewReady: oe,
|
|
117
|
+
onCursorChange: se,
|
|
90
118
|
onBlur: L,
|
|
91
119
|
onFocus: R
|
|
92
120
|
})]
|
|
93
121
|
}),
|
|
94
|
-
|
|
122
|
+
de && /* @__PURE__ */ p(ee, {
|
|
95
123
|
helperText: C,
|
|
96
124
|
error: S,
|
|
97
125
|
showLineColumn: D,
|
|
98
126
|
showErrorCount: O,
|
|
99
|
-
diagnosticsCount:
|
|
100
|
-
cursorLine:
|
|
101
|
-
cursorCol:
|
|
127
|
+
diagnosticsCount: ae,
|
|
128
|
+
cursorLine: Z.line,
|
|
129
|
+
cursorCol: Z.col,
|
|
102
130
|
translation: z
|
|
103
131
|
}),
|
|
104
|
-
w && /* @__PURE__ */
|
|
132
|
+
w && /* @__PURE__ */ p("input", {
|
|
105
133
|
type: "hidden",
|
|
106
134
|
name: w,
|
|
107
135
|
value: g ?? ""
|
|
@@ -13,6 +13,7 @@ type SqlEditorContentProps = {
|
|
|
13
13
|
identifierColor?: string;
|
|
14
14
|
schema?: SqlSchema;
|
|
15
15
|
onExecute?: (sql: string) => void;
|
|
16
|
+
onFormat?: () => void;
|
|
16
17
|
onLint?: (sql: string) => Promise<SqlLintError[]> | SqlLintError[];
|
|
17
18
|
onDiagnosticsChange?: (count: number) => void;
|
|
18
19
|
onViewReady: (view: EditorView | null) => void;
|
|
@@ -20,5 +21,5 @@ type SqlEditorContentProps = {
|
|
|
20
21
|
onBlur?: () => void;
|
|
21
22
|
onFocus?: () => void;
|
|
22
23
|
};
|
|
23
|
-
export declare function SqlEditorContent({ value, onChange, placeholder, disabled, readonly, showLineNumbers, dialect, keywordColor, stringColor, identifierColor, schema, onExecute, onLint, onDiagnosticsChange, onViewReady, onCursorChange, onBlur, onFocus, }: SqlEditorContentProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function SqlEditorContent({ value, onChange, placeholder, disabled, readonly, showLineNumbers, dialect, keywordColor, stringColor, identifierColor, schema, onExecute, onFormat, onLint, onDiagnosticsChange, onViewReady, onCursorChange, onBlur, onFocus, }: SqlEditorContentProps): import("react/jsx-runtime").JSX.Element;
|
|
24
25
|
export {};
|
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
import { useEffect as e, useRef as t } from "react";
|
|
2
2
|
import { Box as n, useTheme as r } from "@mui/material";
|
|
3
3
|
import { jsx as i } from "react/jsx-runtime";
|
|
4
|
-
import { EditorView as a, highlightActiveLine as
|
|
5
|
-
import { Compartment as
|
|
6
|
-
import { defaultKeymap as
|
|
7
|
-
import { HighlightStyle as
|
|
4
|
+
import { EditorView as a, highlightActiveLine as ee, highlightActiveLineGutter as te, keymap as o, lineNumbers as s, placeholder as c } from "@codemirror/view";
|
|
5
|
+
import { Compartment as l, EditorState as u } from "@codemirror/state";
|
|
6
|
+
import { defaultKeymap as ne, history as d, historyKeymap as f } from "@codemirror/commands";
|
|
7
|
+
import { HighlightStyle as p, syntaxHighlighting as m } from "@codemirror/language";
|
|
8
8
|
import { lintGutter as h, linter as g } from "@codemirror/lint";
|
|
9
9
|
import { tags as _ } from "@lezer/highlight";
|
|
10
|
-
import { MSSQL as v, MySQL as y, PostgreSQL as b, SQLite as x, StandardSQL as S, sql as
|
|
11
|
-
import { autocompletion as
|
|
10
|
+
import { MSSQL as v, MySQL as y, PostgreSQL as b, SQLite as x, StandardSQL as S, sql as re } from "@codemirror/lang-sql";
|
|
11
|
+
import { autocompletion as ie, completionKeymap as ae } from "@codemirror/autocomplete";
|
|
12
12
|
//#region src/components/sql-editor/SqlEditorContent.tsx
|
|
13
|
-
var
|
|
13
|
+
var C = {
|
|
14
14
|
standard: S,
|
|
15
15
|
mysql: y,
|
|
16
16
|
postgresql: b,
|
|
17
17
|
sqlite: x,
|
|
18
18
|
mssql: v
|
|
19
19
|
};
|
|
20
|
-
function
|
|
21
|
-
let z = t(null), B = t(
|
|
20
|
+
function w({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly: S = !1, showLineNumbers: w = !0, dialect: T = "standard", keywordColor: E, stringColor: D, identifierColor: O, schema: k, onExecute: A, onFormat: j, onLint: M, onDiagnosticsChange: N, onViewReady: P, onCursorChange: F, onBlur: I, onFocus: L }) {
|
|
21
|
+
let R = t(null), z = t(null), B = t(y), V = t(F), H = t(I), U = t(L), W = t(P), G = t(A), K = t(j), q = t(M), J = t(N), Y = t(new l()), X = t(new l()), Z = r(), Q = Z.palette.mode === "dark", $ = !!M, oe = JSON.stringify(k);
|
|
22
22
|
return e(() => {
|
|
23
|
-
|
|
23
|
+
B.current = y;
|
|
24
24
|
}, [y]), e(() => {
|
|
25
|
+
V.current = F;
|
|
26
|
+
}, [F]), e(() => {
|
|
25
27
|
H.current = I;
|
|
26
28
|
}, [I]), e(() => {
|
|
27
29
|
U.current = L;
|
|
28
30
|
}, [L]), e(() => {
|
|
29
|
-
W.current =
|
|
30
|
-
}, [
|
|
31
|
-
G.current =
|
|
32
|
-
}, [
|
|
33
|
-
K.current =
|
|
31
|
+
W.current = P;
|
|
32
|
+
}, [P]), e(() => {
|
|
33
|
+
G.current = A;
|
|
34
|
+
}, [A]), e(() => {
|
|
35
|
+
K.current = j;
|
|
36
|
+
}, [j]), e(() => {
|
|
37
|
+
q.current = M;
|
|
34
38
|
}, [M]), e(() => {
|
|
35
|
-
|
|
39
|
+
J.current = N;
|
|
36
40
|
}, [N]), e(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!z.current) return;
|
|
40
|
-
let e = B.current?.state.doc.toString() ?? v ?? "", t = O ?? Z.palette.primary.main, n = k ?? Z.palette.success.main, r = A ?? Z.palette.info.main, i = te.define([
|
|
41
|
+
if (!R.current) return;
|
|
42
|
+
let e = z.current?.state.doc.toString() ?? v ?? "", t = E ?? Z.palette.primary.main, n = D ?? Z.palette.success.main, r = O ?? Z.palette.info.main, i = p.define([
|
|
41
43
|
{
|
|
42
44
|
tag: _.keyword,
|
|
43
45
|
color: t,
|
|
@@ -78,7 +80,7 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
|
|
|
78
80
|
color: Z.palette.error.main,
|
|
79
81
|
textDecoration: "underline wavy"
|
|
80
82
|
}
|
|
81
|
-
]),
|
|
83
|
+
]), l = a.theme({
|
|
82
84
|
"&": {
|
|
83
85
|
height: "100%",
|
|
84
86
|
fontFamily: "'Fira Code', 'JetBrains Mono', 'Consolas', monospace",
|
|
@@ -139,11 +141,11 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
|
|
|
139
141
|
".cm-diagnostic-error": { borderLeft: `3px solid ${Z.palette.error.main}` },
|
|
140
142
|
".cm-diagnostic-warning": { borderLeft: `3px solid ${Z.palette.warning.main}` },
|
|
141
143
|
".cm-diagnostic-info": { borderLeft: `3px solid ${Z.palette.info.main}` }
|
|
142
|
-
}, { dark: Q }), y =
|
|
144
|
+
}, { dark: Q }), y = k ? Object.fromEntries(k.tables.map((e) => [e.name, (e.columns ?? []).map((e) => ({
|
|
143
145
|
label: e.name,
|
|
144
146
|
detail: e.type,
|
|
145
147
|
type: "property"
|
|
146
|
-
}))])) : void 0,
|
|
148
|
+
}))])) : void 0, A = async (e) => {
|
|
147
149
|
let t = q.current;
|
|
148
150
|
if (!t) return [];
|
|
149
151
|
let n = e.state.doc.toString();
|
|
@@ -161,63 +163,67 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
|
|
|
161
163
|
} catch {
|
|
162
164
|
return [];
|
|
163
165
|
}
|
|
164
|
-
},
|
|
166
|
+
}, j = o.of([{
|
|
165
167
|
key: "Mod-Enter",
|
|
166
|
-
run: (e) => (
|
|
167
|
-
}]),
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
run: (e) => (G.current?.(e.state.doc.toString()), !0)
|
|
169
|
+
}]), M = o.of([{
|
|
170
|
+
key: "Shift-Alt-f",
|
|
171
|
+
run: () => (K.current?.(), !0)
|
|
172
|
+
}]), N = [
|
|
173
|
+
l,
|
|
174
|
+
m(i),
|
|
175
|
+
re({
|
|
176
|
+
dialect: C[T],
|
|
172
177
|
schema: y
|
|
173
178
|
}),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
...
|
|
180
|
-
...
|
|
179
|
+
d(),
|
|
180
|
+
ie(),
|
|
181
|
+
j,
|
|
182
|
+
M,
|
|
183
|
+
o.of([
|
|
184
|
+
...ne,
|
|
185
|
+
...f,
|
|
186
|
+
...ae
|
|
181
187
|
]),
|
|
182
188
|
Y.current.of(a.editable.of(!x && !S)),
|
|
183
|
-
X.current.of(
|
|
184
|
-
|
|
185
|
-
...
|
|
186
|
-
...b ? [
|
|
187
|
-
...$ ? [h(), g(
|
|
189
|
+
X.current.of(u.readOnly.of(S)),
|
|
190
|
+
ee(),
|
|
191
|
+
...w ? [s(), te()] : [],
|
|
192
|
+
...b ? [c(b)] : [],
|
|
193
|
+
...$ ? [h(), g(A, { delay: 600 })] : [],
|
|
188
194
|
a.updateListener.of((e) => {
|
|
189
|
-
e.docChanged &&
|
|
195
|
+
e.docChanged && B.current?.(e.state.doc.toString());
|
|
190
196
|
let t = e.state.selection.main.head, n = e.state.doc.lineAt(t);
|
|
191
|
-
|
|
197
|
+
V.current(n.number, t - n.from + 1);
|
|
192
198
|
}),
|
|
193
199
|
a.domEventHandlers({
|
|
194
200
|
blur: () => {
|
|
195
|
-
|
|
201
|
+
H.current?.();
|
|
196
202
|
},
|
|
197
203
|
focus: () => {
|
|
198
|
-
|
|
204
|
+
U.current?.();
|
|
199
205
|
}
|
|
200
206
|
})
|
|
201
|
-
],
|
|
202
|
-
state:
|
|
207
|
+
], P = new a({
|
|
208
|
+
state: u.create({
|
|
203
209
|
doc: e,
|
|
204
|
-
extensions:
|
|
210
|
+
extensions: N
|
|
205
211
|
}),
|
|
206
|
-
parent:
|
|
212
|
+
parent: R.current
|
|
207
213
|
});
|
|
208
|
-
return
|
|
209
|
-
|
|
214
|
+
return z.current = P, W.current(P), () => {
|
|
215
|
+
W.current(null), P.destroy(), z.current = null;
|
|
210
216
|
};
|
|
211
217
|
}, [
|
|
212
218
|
Q,
|
|
213
|
-
|
|
219
|
+
T,
|
|
214
220
|
$,
|
|
221
|
+
E,
|
|
222
|
+
D,
|
|
215
223
|
O,
|
|
216
|
-
|
|
217
|
-
A,
|
|
218
|
-
ie
|
|
224
|
+
oe
|
|
219
225
|
]), e(() => {
|
|
220
|
-
let e =
|
|
226
|
+
let e = z.current;
|
|
221
227
|
if (!e) return;
|
|
222
228
|
let t = e.state.doc.toString();
|
|
223
229
|
t !== (v ?? "") && e.dispatch({ changes: {
|
|
@@ -226,9 +232,9 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
|
|
|
226
232
|
insert: v ?? ""
|
|
227
233
|
} });
|
|
228
234
|
}, [v]), e(() => {
|
|
229
|
-
|
|
235
|
+
z.current?.dispatch({ effects: [Y.current.reconfigure(a.editable.of(!x && !S)), X.current.reconfigure(u.readOnly.of(S))] });
|
|
230
236
|
}, [x, S]), /* @__PURE__ */ i(n, {
|
|
231
|
-
ref:
|
|
237
|
+
ref: R,
|
|
232
238
|
sx: {
|
|
233
239
|
flex: 1,
|
|
234
240
|
overflow: "hidden",
|
|
@@ -245,4 +251,4 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
|
|
|
245
251
|
});
|
|
246
252
|
}
|
|
247
253
|
//#endregion
|
|
248
|
-
export {
|
|
254
|
+
export { w as SqlEditorContent };
|
|
@@ -10,8 +10,8 @@ import f from "@mui/icons-material/Delete";
|
|
|
10
10
|
import p from "@mui/icons-material/Undo";
|
|
11
11
|
import m from "@mui/icons-material/Redo";
|
|
12
12
|
import h from "@mui/icons-material/AutoFixHigh";
|
|
13
|
-
import g from "
|
|
14
|
-
import
|
|
13
|
+
import { format as g } from "sql-formatter";
|
|
14
|
+
import _ from "@mui/icons-material/PlayArrow";
|
|
15
15
|
//#region src/components/sql-editor/SqlEditorToolbar.tsx
|
|
16
16
|
var v = {
|
|
17
17
|
standard: "sql",
|
|
@@ -49,7 +49,7 @@ function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabl
|
|
|
49
49
|
if (!e) return;
|
|
50
50
|
let t = e.state.doc.toString();
|
|
51
51
|
try {
|
|
52
|
-
let n =
|
|
52
|
+
let n = g(t, { language: v[S] });
|
|
53
53
|
e.dispatch({ changes: {
|
|
54
54
|
from: 0,
|
|
55
55
|
to: e.state.doc.length,
|
|
@@ -151,7 +151,7 @@ function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabl
|
|
|
151
151
|
sx: { mx: .5 }
|
|
152
152
|
}), /* @__PURE__ */ o(e, {
|
|
153
153
|
label: x.execute,
|
|
154
|
-
icon: /* @__PURE__ */ o(
|
|
154
|
+
icon: /* @__PURE__ */ o(_, { fontSize: "small" }),
|
|
155
155
|
onClick: I,
|
|
156
156
|
disabled: A
|
|
157
157
|
})] }),
|