@fc-components/monaco-editor 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/monaco-editor.cjs.development.js +13 -2
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +13 -2
- package/dist/monaco-editor.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/sql/format.ts +4 -1
- package/src/sql/index.tsx +3 -1
package/package.json
CHANGED
package/src/sql/format.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { format } from 'sql-formatter';
|
|
|
2
2
|
|
|
3
3
|
export function formatSql(sql: string): string {
|
|
4
4
|
try {
|
|
5
|
-
|
|
5
|
+
const formatted = format(sql, {
|
|
6
6
|
tabWidth: 2,
|
|
7
7
|
keywordCase: 'upper',
|
|
8
8
|
// Treat custom $__ prefixed macros (like $__timeFilter, $__timeRange, etc.)
|
|
@@ -11,6 +11,9 @@ export function formatSql(sql: string): string {
|
|
|
11
11
|
custom: [{ regex: String.raw`\$__[a-zA-Z_][a-zA-Z0-9_]*` }],
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
|
+
// sql-formatter treats $__xxx as a placeholder and inserts a space before '('.
|
|
15
|
+
// Remove that extra space so $__timeFilter( stays intact as a function call.
|
|
16
|
+
return formatted.replace(/(\$__[a-zA-Z_][a-zA-Z0-9_]*)\s+\(/g, '$1(');
|
|
14
17
|
} catch {
|
|
15
18
|
// If formatting fails, return the original SQL
|
|
16
19
|
return sql;
|
package/src/sql/index.tsx
CHANGED
|
@@ -335,7 +335,9 @@ const SqlEditor = forwardRef<SqlEditorHandle, SqlEditorProps>((props, ref) => {
|
|
|
335
335
|
</div>
|
|
336
336
|
{enableFormat &&
|
|
337
337
|
(renderFormatButton ? (
|
|
338
|
-
|
|
338
|
+
<div style={{ position: 'absolute', top: 4, right: 4, zIndex: 10 }} onClick={handleFormat}>
|
|
339
|
+
{renderFormatButton(handleFormat)}
|
|
340
|
+
</div>
|
|
339
341
|
) : (
|
|
340
342
|
<button
|
|
341
343
|
onClick={handleFormat}
|