@lobb-js/studio 0.1.40 → 0.1.42
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/components/codeEditor.svelte +152 -0
- package/dist/components/codeEditor.svelte.d.ts +13 -0
- package/dist/components/createManyButton.svelte +2 -2
- package/dist/components/detailView/fieldCustomInput.svelte +2 -2
- package/dist/components/diffViewer.svelte +69 -66
- package/dist/components/diffViewer.svelte.d.ts +1 -1
- package/dist/components/routes/data_model/syncManager.svelte +3 -3
- package/dist/components/routes/home.svelte +3 -1
- package/dist/components/workflowEditor.svelte +2 -2
- package/dist/store.svelte.js +5 -2
- package/dist/store.types.d.ts +1 -1
- package/package.json +13 -6
- package/dist/components/monacoEditor.svelte +0 -181
- package/dist/components/monacoEditor.svelte.d.ts +0 -13
- package/dist/components/ui/range-calendar/range-calendar-day.svelte.d.ts +0 -6
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { keymap } from '@codemirror/view';
|
|
4
|
+
import { EditorState } from '@codemirror/state';
|
|
5
|
+
import { basicSetup, EditorView } from 'codemirror';
|
|
6
|
+
import { javascript } from '@codemirror/lang-javascript';
|
|
7
|
+
import { sql } from '@codemirror/lang-sql';
|
|
8
|
+
import { oneDark } from '@codemirror/theme-one-dark';
|
|
9
|
+
import { cn } from '../utils.js';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
type: 'javascript' | 'typescript' | 'json' | 'sql';
|
|
13
|
+
name: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
default?: string;
|
|
16
|
+
types?: string;
|
|
17
|
+
class?: string;
|
|
18
|
+
handleCtrlSave?: () => void;
|
|
19
|
+
onChange?: (value: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
type,
|
|
24
|
+
name,
|
|
25
|
+
value = $bindable(''),
|
|
26
|
+
class: className,
|
|
27
|
+
types,
|
|
28
|
+
handleCtrlSave,
|
|
29
|
+
onChange,
|
|
30
|
+
...props
|
|
31
|
+
}: Props = $props();
|
|
32
|
+
|
|
33
|
+
if (props.default) {
|
|
34
|
+
value = props.default;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let editorContainer: HTMLDivElement;
|
|
38
|
+
let editorView: EditorView | null = null;
|
|
39
|
+
|
|
40
|
+
const getLanguageExtension = () => {
|
|
41
|
+
switch (type) {
|
|
42
|
+
case 'javascript':
|
|
43
|
+
case 'typescript':
|
|
44
|
+
case 'json':
|
|
45
|
+
return javascript();
|
|
46
|
+
case 'sql':
|
|
47
|
+
return sql();
|
|
48
|
+
default:
|
|
49
|
+
return javascript();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const createEditor = () => {
|
|
54
|
+
if (!editorContainer) return;
|
|
55
|
+
|
|
56
|
+
const extensions = [
|
|
57
|
+
basicSetup,
|
|
58
|
+
getLanguageExtension(),
|
|
59
|
+
EditorView.updateListener.of((update) => {
|
|
60
|
+
if (update.docChanged) {
|
|
61
|
+
const newValue = update.state.doc.toString();
|
|
62
|
+
value = newValue;
|
|
63
|
+
onChange?.(newValue);
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
EditorView.theme({
|
|
67
|
+
'&': {
|
|
68
|
+
backgroundColor: 'transparent',
|
|
69
|
+
},
|
|
70
|
+
'.cm-gutters': {
|
|
71
|
+
backgroundColor: 'transparent',
|
|
72
|
+
border: 'none',
|
|
73
|
+
},
|
|
74
|
+
'.cm-content': {
|
|
75
|
+
paddingTop: '10px',
|
|
76
|
+
paddingBottom: '1px',
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
// Add Ctrl+S / Cmd+S handler if provided
|
|
82
|
+
if (handleCtrlSave) {
|
|
83
|
+
extensions.push(
|
|
84
|
+
keymap.of([
|
|
85
|
+
{
|
|
86
|
+
key: 'Mod-s',
|
|
87
|
+
run: () => {
|
|
88
|
+
handleCtrlSave();
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
])
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const state = EditorState.create({
|
|
97
|
+
doc: value,
|
|
98
|
+
extensions
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
editorView = new EditorView({
|
|
102
|
+
state,
|
|
103
|
+
parent: editorContainer
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const updateEditor = () => {
|
|
108
|
+
if (!editorView) return;
|
|
109
|
+
|
|
110
|
+
const currentValue = editorView.state.doc.toString();
|
|
111
|
+
if (currentValue !== value) {
|
|
112
|
+
editorView.dispatch({
|
|
113
|
+
changes: {
|
|
114
|
+
from: 0,
|
|
115
|
+
to: currentValue.length,
|
|
116
|
+
insert: value
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
onMount(() => {
|
|
123
|
+
createEditor();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
onDestroy(() => {
|
|
127
|
+
editorView?.destroy();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
$effect(() => {
|
|
131
|
+
updateEditor();
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<div class={cn('resize-y rounded-md border bg-soft shadow-sm h-60', className)}>
|
|
136
|
+
<div bind:this={editorContainer} class="h-full w-full pl-2" />
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<style>
|
|
140
|
+
:global(.cm-editor) {
|
|
141
|
+
height: 100%;
|
|
142
|
+
font-size: 14px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:global(.cm-scroller) {
|
|
146
|
+
overflow: auto;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
:global(.cm-focused) {
|
|
150
|
+
outline: none !important;
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
type: 'javascript' | 'typescript' | 'json' | 'sql';
|
|
3
|
+
name: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
default?: string;
|
|
6
|
+
types?: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
handleCtrlSave?: () => void;
|
|
9
|
+
onChange?: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const CodeEditor: import("svelte").Component<Props, {}, "value">;
|
|
12
|
+
type CodeEditor = ReturnType<typeof CodeEditor>;
|
|
13
|
+
export default CodeEditor;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ArrowLeft, Plus, X } from "lucide-svelte";
|
|
4
4
|
import Button, { type ButtonProps } from "./ui/button/button.svelte";
|
|
5
5
|
import { toast } from "svelte-sonner";
|
|
6
|
-
import
|
|
6
|
+
import CodeEditor from "./codeEditor.svelte";
|
|
7
7
|
import { lobb } from "..";
|
|
8
8
|
import { calculateDrawerWidth } from "../utils";
|
|
9
9
|
import Drawer from "./drawer.svelte";
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
</div>
|
|
77
77
|
</div>
|
|
78
78
|
<div class="flex-1 overflow-y-auto">
|
|
79
|
-
<
|
|
79
|
+
<CodeEditor
|
|
80
80
|
name={collectionName}
|
|
81
81
|
type="json"
|
|
82
82
|
bind:value={createManyPayload}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import CodeEditor from "../codeEditor.svelte";
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
value: any;
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
{#if type === "code"}
|
|
22
|
-
<
|
|
22
|
+
<CodeEditor name={field.key} {...args} bind:value />
|
|
23
23
|
{/if}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, onDestroy } from "svelte";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
3
|
+
import { MergeView } from "@codemirror/merge";
|
|
4
|
+
import { EditorView } from "@codemirror/view";
|
|
5
|
+
import { EditorState } from "@codemirror/state";
|
|
6
|
+
import { basicSetup } from "codemirror";
|
|
7
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
8
|
+
import { sql } from "@codemirror/lang-sql";
|
|
9
9
|
import { cn } from "../utils";
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
|
-
type: "javascript" | "typescript" | "json";
|
|
12
|
+
type: "javascript" | "typescript" | "json" | "sql";
|
|
13
13
|
original: string;
|
|
14
14
|
modified: string;
|
|
15
15
|
class?: string;
|
|
@@ -24,76 +24,79 @@
|
|
|
24
24
|
}: Props = $props();
|
|
25
25
|
|
|
26
26
|
let editorContainer: HTMLDivElement;
|
|
27
|
-
let
|
|
28
|
-
let originalModel: monaco.editor.ITextModel;
|
|
29
|
-
let modifiedModel: monaco.editor.ITextModel;
|
|
27
|
+
let mergeView: MergeView | null = null;
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
label === "razor"
|
|
43
|
-
) {
|
|
44
|
-
return new htmlWorker();
|
|
45
|
-
}
|
|
46
|
-
if (label === "typescript" || label === "javascript") {
|
|
47
|
-
return new tsWorker();
|
|
48
|
-
}
|
|
49
|
-
return new editorWorker();
|
|
50
|
-
},
|
|
29
|
+
const getLanguageExtension = () => {
|
|
30
|
+
switch (type) {
|
|
31
|
+
case 'javascript':
|
|
32
|
+
case 'typescript':
|
|
33
|
+
case 'json':
|
|
34
|
+
return javascript();
|
|
35
|
+
case 'sql':
|
|
36
|
+
return sql();
|
|
37
|
+
default:
|
|
38
|
+
return javascript();
|
|
39
|
+
}
|
|
51
40
|
};
|
|
52
41
|
|
|
53
|
-
onMount(
|
|
54
|
-
|
|
55
|
-
base: "vs",
|
|
56
|
-
inherit: true,
|
|
57
|
-
rules: [],
|
|
58
|
-
colors: {
|
|
59
|
-
"editor.background": "#EFEFEF00",
|
|
60
|
-
focusBorder: "#00000000",
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
originalModel = monaco.editor.createModel(original, type);
|
|
65
|
-
|
|
66
|
-
modifiedModel = monaco.editor.createModel(modified, type);
|
|
42
|
+
onMount(() => {
|
|
43
|
+
const langExtension = getLanguageExtension();
|
|
67
44
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
45
|
+
mergeView = new MergeView({
|
|
46
|
+
a: {
|
|
47
|
+
doc: original,
|
|
48
|
+
extensions: [
|
|
49
|
+
basicSetup,
|
|
50
|
+
langExtension,
|
|
51
|
+
EditorView.editable.of(false),
|
|
52
|
+
EditorState.readOnly.of(true),
|
|
53
|
+
EditorView.theme({
|
|
54
|
+
'&': {
|
|
55
|
+
backgroundColor: 'transparent',
|
|
56
|
+
},
|
|
57
|
+
'.cm-gutters': {
|
|
58
|
+
backgroundColor: 'transparent',
|
|
59
|
+
border: 'none',
|
|
60
|
+
},
|
|
61
|
+
'.cm-content': {
|
|
62
|
+
paddingTop: '10px',
|
|
63
|
+
paddingBottom: '1px',
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
b: {
|
|
69
|
+
doc: modified,
|
|
70
|
+
extensions: [
|
|
71
|
+
basicSetup,
|
|
72
|
+
langExtension,
|
|
73
|
+
EditorView.editable.of(false),
|
|
74
|
+
EditorState.readOnly.of(true),
|
|
75
|
+
EditorView.theme({
|
|
76
|
+
'&': {
|
|
77
|
+
backgroundColor: 'transparent',
|
|
78
|
+
},
|
|
79
|
+
'.cm-gutters': {
|
|
80
|
+
backgroundColor: 'transparent',
|
|
81
|
+
border: 'none',
|
|
82
|
+
},
|
|
83
|
+
'.cm-content': {
|
|
84
|
+
paddingTop: '10px',
|
|
85
|
+
paddingBottom: '1px',
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
parent: editorContainer
|
|
86
91
|
});
|
|
87
92
|
});
|
|
88
93
|
|
|
89
94
|
onDestroy(() => {
|
|
90
|
-
|
|
91
|
-
originalModel.dispose();
|
|
92
|
-
modifiedModel.dispose();
|
|
95
|
+
mergeView?.destroy();
|
|
93
96
|
});
|
|
94
97
|
</script>
|
|
95
98
|
|
|
96
|
-
<div class={cn("resize-y rounded-md border bg-soft shadow-sm
|
|
99
|
+
<div class={cn("w-full resize-y rounded-md border bg-soft shadow-sm", className)}>
|
|
97
100
|
<div
|
|
98
101
|
bind:this={editorContainer}
|
|
99
102
|
class="editor pl-2"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ctx } from "../../../store.svelte";
|
|
4
4
|
import { onMount } from "svelte";
|
|
5
5
|
import stringify from "json-stable-stringify";
|
|
6
|
-
import
|
|
6
|
+
import CodeEditor from "../../codeEditor.svelte";
|
|
7
7
|
import Table from "../../dataTable/table.svelte";
|
|
8
8
|
import Button from "../../ui/button/button.svelte";
|
|
9
9
|
import { LoaderCircle, SendHorizontal } from "lucide-svelte";
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
|
-
<div class="h-[50%] border-b">
|
|
44
|
+
<div class="h-[50%] border-b overflow-auto">
|
|
45
45
|
{#if configSchema && dbSchema}
|
|
46
46
|
<DiffViewer
|
|
47
47
|
type="json"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
Execute
|
|
71
71
|
</Button>
|
|
72
72
|
</div>
|
|
73
|
-
<
|
|
73
|
+
<CodeEditor
|
|
74
74
|
type="sql"
|
|
75
75
|
name="prompt"
|
|
76
76
|
bind:value={sqlPrompt}
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
</div>
|
|
30
30
|
<div class="flex justify-end p-2 text-xs text-muted-foreground/50">
|
|
31
31
|
<div class="flex flex-col text-end">
|
|
32
|
-
|
|
32
|
+
{#if ctx.studioVersion}
|
|
33
|
+
<div>studio: v{ctx.studioVersion}</div>
|
|
34
|
+
{/if}
|
|
33
35
|
<div>core: v{ctx.meta.version}</div>
|
|
34
36
|
</div>
|
|
35
37
|
</div>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
<script lang="ts">
|
|
14
14
|
import { lobb } from "..";
|
|
15
|
-
import
|
|
15
|
+
import CodeEditor from "./codeEditor.svelte";
|
|
16
16
|
import Button from "./ui/button/button.svelte";
|
|
17
17
|
import Input from "./ui/input/input.svelte";
|
|
18
18
|
import { ctx } from "../store.svelte";
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
</div>
|
|
176
176
|
</div>
|
|
177
177
|
{#key types}
|
|
178
|
-
<
|
|
178
|
+
<CodeEditor
|
|
179
179
|
type="typescript"
|
|
180
180
|
name="workflow"
|
|
181
181
|
class="h-full rounded-none border-none"
|
package/dist/store.svelte.js
CHANGED
|
@@ -36,15 +36,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { Lobb } from './Lobb';
|
|
38
38
|
import { toast } from 'svelte-sonner';
|
|
39
|
-
import pkg from '../../package.json';
|
|
40
39
|
if (!window.APP_ENV) {
|
|
41
40
|
window.APP_ENV = {};
|
|
42
41
|
}
|
|
43
42
|
if (window.APP_ENV.LOBB_URL === '%LOBB_URL%') {
|
|
44
43
|
window.APP_ENV.LOBB_URL = null;
|
|
45
44
|
}
|
|
45
|
+
// TODO: this state should be passed to the Studio component in the App.svelte it should be its paramters
|
|
46
|
+
// TODO: using a global variable is not good to pass data to children components. using the context api is better for only components builder or wrappers
|
|
47
|
+
// TODO: you should totally remove this file
|
|
48
|
+
// TODO: when you finish doind that add the studioVersion back
|
|
46
49
|
export var ctx = $state.raw({
|
|
47
|
-
studioVersion: pkg.version,
|
|
50
|
+
// studioVersion: pkg.version,
|
|
48
51
|
lobbUrl: window.APP_ENV.LOBB_URL || localStorage.getItem("lobb_url"),
|
|
49
52
|
extensions: {},
|
|
50
53
|
meta: {
|
package/dist/store.types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobb-js/studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -46,31 +46,38 @@
|
|
|
46
46
|
"@storybook/svelte-vite": "^10.0.1",
|
|
47
47
|
"@sveltejs/package": "^2.5.7",
|
|
48
48
|
"@sveltejs/vite-plugin-svelte": "6.2.1",
|
|
49
|
+
"@tsconfig/svelte": "^5.0.6",
|
|
49
50
|
"@types/lodash": "^4.17.17",
|
|
50
51
|
"@types/mustache": "^4.2.6",
|
|
51
52
|
"@types/node": "^24.10.1",
|
|
52
53
|
"@types/qs": "^6.9.18",
|
|
53
|
-
"@tsconfig/svelte": "^5.0.6",
|
|
54
54
|
"@vitest/browser-playwright": "^4.0.5",
|
|
55
55
|
"@vitest/coverage-v8": "^4.0.5",
|
|
56
56
|
"autoprefixer": "^10.4.23",
|
|
57
57
|
"dts-bundle-generator": "^9.5.1",
|
|
58
58
|
"playwright": "^1.56.1",
|
|
59
59
|
"storybook": "^10.0.1",
|
|
60
|
+
"svelte": "^5.49.1",
|
|
60
61
|
"svelte-check": "^4.3.4",
|
|
62
|
+
"tailwindcss": "4.1.18",
|
|
61
63
|
"tailwindcss-animate": "^1.0.7",
|
|
62
64
|
"tw-animate-css": "^1.4.0",
|
|
63
65
|
"typescript": "~5.9.3",
|
|
66
|
+
"vite": "6.3.3",
|
|
64
67
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
65
|
-
"vitest": "^4.0.5"
|
|
66
|
-
"tailwindcss": "4.1.18",
|
|
67
|
-
"vite": "6.3.3"
|
|
68
|
+
"vitest": "^4.0.5"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"svelte": "^5.0.0"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
74
|
"@andrewbranch/untar.js": "^1.0.3",
|
|
75
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
76
|
+
"@codemirror/lang-sql": "^6.10.0",
|
|
77
|
+
"@codemirror/merge": "^6.11.2",
|
|
78
|
+
"@codemirror/state": "^6.5.4",
|
|
79
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
80
|
+
"@codemirror/view": "^6.39.12",
|
|
74
81
|
"@dagrejs/dagre": "^1.1.5",
|
|
75
82
|
"@lucide/svelte": "^0.563.1",
|
|
76
83
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -78,12 +85,12 @@
|
|
|
78
85
|
"@xyflow/svelte": "^1.2.0",
|
|
79
86
|
"bits-ui": "^1.8.0",
|
|
80
87
|
"clsx": "^2.1.1",
|
|
88
|
+
"codemirror": "^6.0.2",
|
|
81
89
|
"fflate": "^0.8.2",
|
|
82
90
|
"json-stable-stringify": "^1.3.0",
|
|
83
91
|
"lodash": "^4.17.21",
|
|
84
92
|
"lucide-svelte": "^0.488.0",
|
|
85
93
|
"mode-watcher": "^0.5.1",
|
|
86
|
-
"monaco-editor": "^0.52.2",
|
|
87
94
|
"mustache": "^4.2.0",
|
|
88
95
|
"qs": "^6.14.1",
|
|
89
96
|
"svelte-sonner": "^0.3.28",
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount, onDestroy } from "svelte";
|
|
3
|
-
import * as monaco from "monaco-editor";
|
|
4
|
-
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
|
5
|
-
import jsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker";
|
|
6
|
-
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
|
|
7
|
-
import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker";
|
|
8
|
-
import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker";
|
|
9
|
-
import { cn } from "../utils";
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
type: "javascript" | "typescript" | "json" | "sql";
|
|
13
|
-
name: string;
|
|
14
|
-
value?: string;
|
|
15
|
-
default?: string;
|
|
16
|
-
types?: string;
|
|
17
|
-
class?: string;
|
|
18
|
-
handleCtrlSave?: () => void;
|
|
19
|
-
onChange?: (value: string) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let {
|
|
23
|
-
type,
|
|
24
|
-
name,
|
|
25
|
-
value = $bindable(""),
|
|
26
|
-
class: className,
|
|
27
|
-
types,
|
|
28
|
-
handleCtrlSave,
|
|
29
|
-
onChange,
|
|
30
|
-
...props
|
|
31
|
-
}: Props = $props();
|
|
32
|
-
|
|
33
|
-
let editorContainer: HTMLDivElement;
|
|
34
|
-
let editor: monaco.editor.IStandaloneCodeEditor;
|
|
35
|
-
let model: monaco.editor.ITextModel;
|
|
36
|
-
|
|
37
|
-
if (props.default) {
|
|
38
|
-
value = props.default;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
$effect(() => {
|
|
42
|
-
if (value !== undefined && editor && value !== editor.getValue()) {
|
|
43
|
-
editor.setValue(value);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
self.MonacoEnvironment = {
|
|
48
|
-
getWorker(_, label) {
|
|
49
|
-
if (label === "json") {
|
|
50
|
-
return new jsonWorker();
|
|
51
|
-
}
|
|
52
|
-
if (label === "css" || label === "scss" || label === "less") {
|
|
53
|
-
return new cssWorker();
|
|
54
|
-
}
|
|
55
|
-
if (
|
|
56
|
-
label === "html" ||
|
|
57
|
-
label === "handlebars" ||
|
|
58
|
-
label === "razor"
|
|
59
|
-
) {
|
|
60
|
-
return new htmlWorker();
|
|
61
|
-
}
|
|
62
|
-
if (label === "typescript" || label === "javascript") {
|
|
63
|
-
return new tsWorker();
|
|
64
|
-
}
|
|
65
|
-
return new editorWorker();
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
onMount(async () => {
|
|
70
|
-
monaco.editor.defineTheme("transparentTheme", {
|
|
71
|
-
base: "vs",
|
|
72
|
-
inherit: true,
|
|
73
|
-
rules: [],
|
|
74
|
-
colors: {
|
|
75
|
-
"editor.background": "#EFEFEF00",
|
|
76
|
-
focusBorder: "#00000000",
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (type === "typescript") {
|
|
81
|
-
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
82
|
-
target: monaco.languages.typescript.ScriptTarget.ESNext,
|
|
83
|
-
moduleResolution:
|
|
84
|
-
monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
85
|
-
esModuleInterop: true,
|
|
86
|
-
});
|
|
87
|
-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
|
|
88
|
-
types ?? "",
|
|
89
|
-
"file:///global.d.ts",
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// this is an example of importing the picocolors library types
|
|
93
|
-
// with this you can easily use the picolo types in the web editor like this
|
|
94
|
-
// import type Pico from "picocolors"
|
|
95
|
-
// function work(pc: typeof Pico) {
|
|
96
|
-
// pc.bold(`How are ${pc.italic(`you`)} doing?`)
|
|
97
|
-
// }
|
|
98
|
-
|
|
99
|
-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
|
|
100
|
-
`export type Formatter = (input: string | number | null | undefined) => string
|
|
101
|
-
export interface Colors {
|
|
102
|
-
isColorSupported: boolean
|
|
103
|
-
|
|
104
|
-
reset: Formatter
|
|
105
|
-
bold: Formatter
|
|
106
|
-
dim: Formatter
|
|
107
|
-
italic: Formatter
|
|
108
|
-
underline: Formatter
|
|
109
|
-
inverse: Formatter
|
|
110
|
-
hidden: Formatter
|
|
111
|
-
strikethrough: Formatter
|
|
112
|
-
}`,
|
|
113
|
-
"file:///node_modules/picocolors/types.d.ts",
|
|
114
|
-
);
|
|
115
|
-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
|
|
116
|
-
`import { Colors } from "./types.d.ts"
|
|
117
|
-
declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors }
|
|
118
|
-
export = picocolors`,
|
|
119
|
-
"file:///node_modules/picocolors/index.d.ts",
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
model = monaco.editor.createModel(
|
|
124
|
-
value,
|
|
125
|
-
type,
|
|
126
|
-
monaco.Uri.parse(`file:///${name}.ts`),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
editor = monaco.editor.create(editorContainer, {
|
|
130
|
-
model: model,
|
|
131
|
-
value: value,
|
|
132
|
-
language: type,
|
|
133
|
-
automaticLayout: true,
|
|
134
|
-
theme: "transparentTheme",
|
|
135
|
-
minimap: { enabled: false },
|
|
136
|
-
glyphMargin: false,
|
|
137
|
-
overviewRulerLanes: 0,
|
|
138
|
-
hideCursorInOverviewRuler: true,
|
|
139
|
-
stickyScroll: { enabled: false },
|
|
140
|
-
lineNumbersMinChars: 2,
|
|
141
|
-
scrollBeyondLastLine: false,
|
|
142
|
-
padding: { top: 10, bottom: 1 },
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
editor.onDidChangeModelContent(() => {
|
|
146
|
-
value = editor.getValue();
|
|
147
|
-
if (onChange) {
|
|
148
|
-
onChange(value);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// adding duplicate line shortcut
|
|
153
|
-
editor.addCommand(
|
|
154
|
-
monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.DownArrow,
|
|
155
|
-
() => editor.trigger("", "editor.action.copyLinesDownAction", null),
|
|
156
|
-
);
|
|
157
|
-
editor.addCommand(
|
|
158
|
-
monaco.KeyMod.Shift | monaco.KeyMod.Alt | monaco.KeyCode.UpArrow,
|
|
159
|
-
() => editor.trigger("", "editor.action.copyLinesUpAction", null),
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => {
|
|
163
|
-
if (handleCtrlSave) {
|
|
164
|
-
handleCtrlSave();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
onDestroy(() => {
|
|
170
|
-
editor?.dispose();
|
|
171
|
-
model.dispose();
|
|
172
|
-
});
|
|
173
|
-
</script>
|
|
174
|
-
|
|
175
|
-
<div class={cn("resize-y rounded-md border bg-soft shadow-sm h-60", className)}>
|
|
176
|
-
<div
|
|
177
|
-
bind:this={editorContainer}
|
|
178
|
-
class="editor pl-2"
|
|
179
|
-
style="height: 100%; width: 100%;"
|
|
180
|
-
></div>
|
|
181
|
-
</div>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface Props {
|
|
2
|
-
type: "javascript" | "typescript" | "json" | "sql";
|
|
3
|
-
name: string;
|
|
4
|
-
value?: string;
|
|
5
|
-
default?: string;
|
|
6
|
-
types?: string;
|
|
7
|
-
class?: string;
|
|
8
|
-
handleCtrlSave?: () => void;
|
|
9
|
-
onChange?: (value: string) => void;
|
|
10
|
-
}
|
|
11
|
-
declare const MonacoEditor: import("svelte").Component<Props, {}, "value">;
|
|
12
|
-
type MonacoEditor = ReturnType<typeof MonacoEditor>;
|
|
13
|
-
export default MonacoEditor;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
|
|
2
|
-
declare const RangeCalendarDay: import("svelte").Component<RangeCalendarPrimitive.DayProps, {
|
|
3
|
-
class: import("svelte/elements").ClassValue;
|
|
4
|
-
}, "ref">;
|
|
5
|
-
type RangeCalendarDay = ReturnType<typeof RangeCalendarDay>;
|
|
6
|
-
export default RangeCalendarDay;
|