@floegence/floe-webapp-core 0.35.15 → 0.35.16
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/editor/CodeEditor.d.ts +23 -0
- package/dist/components/editor/CodeEditor.js +118 -0
- package/dist/components/editor/index.d.ts +2 -0
- package/dist/components/editor/languages.d.ts +6 -0
- package/dist/components/editor/languages.js +110 -0
- package/dist/components/editor/monacoEnvironment.d.ts +1 -0
- package/dist/components/editor/monacoEnvironment.js +14 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +7 -0
- package/package.json +6 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
3
|
+
import 'monaco-editor/min/vs/editor/editor.main.css';
|
|
4
|
+
export interface CodeEditorProps {
|
|
5
|
+
path: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
value: string;
|
|
8
|
+
options?: monaco.editor.IStandaloneEditorConstructionOptions;
|
|
9
|
+
class?: string;
|
|
10
|
+
style?: JSX.CSSProperties;
|
|
11
|
+
onReady?: (api: CodeEditorApi) => void;
|
|
12
|
+
onContentChange?: (e: monaco.editor.IModelContentChangedEvent, api: CodeEditorApi) => void;
|
|
13
|
+
onSelectionChange?: (selectionText: string, api: CodeEditorApi) => void;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface CodeEditorApi {
|
|
17
|
+
editor: monaco.editor.IStandaloneCodeEditor;
|
|
18
|
+
model: monaco.editor.ITextModel;
|
|
19
|
+
getValue: () => string;
|
|
20
|
+
getSelectedText: () => string;
|
|
21
|
+
focus: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function CodeEditor(props: CodeEditorProps): JSX.Element;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { use as R, effect as L, className as D, style as O, template as V } from "solid-js/web";
|
|
2
|
+
import { onMount as b, createEffect as g, onCleanup as q } from "solid-js";
|
|
3
|
+
import { useTheme as A } from "../../context/ThemeContext.js";
|
|
4
|
+
import { useResizeObserver as F } from "../../hooks/useResizeObserver.js";
|
|
5
|
+
import * as f from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
6
|
+
import "monaco-editor/min/vs/editor/editor.main.css";
|
|
7
|
+
import { resolveCodeEditorLanguageSpec as U } from "./languages.js";
|
|
8
|
+
import { ensureMonacoEnvironment as p } from "./monacoEnvironment.js";
|
|
9
|
+
var z = /* @__PURE__ */ V("<div>");
|
|
10
|
+
const M = {
|
|
11
|
+
readOnly: !0,
|
|
12
|
+
automaticLayout: !1,
|
|
13
|
+
minimap: {
|
|
14
|
+
enabled: !1
|
|
15
|
+
},
|
|
16
|
+
scrollBeyondLastLine: !1,
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
lineHeight: 18,
|
|
19
|
+
tabSize: 2,
|
|
20
|
+
fontFamily: "var(--font-mono)"
|
|
21
|
+
};
|
|
22
|
+
let w = 0;
|
|
23
|
+
function N(e, c) {
|
|
24
|
+
return f.Uri.parse(`inmemory://model/${e}/${encodeURIComponent(c)}`);
|
|
25
|
+
}
|
|
26
|
+
function _(e, c) {
|
|
27
|
+
if (!e || !c) return "";
|
|
28
|
+
const r = e.getSelection();
|
|
29
|
+
return !r || r.isEmpty() ? "" : c.getValueInRange(r);
|
|
30
|
+
}
|
|
31
|
+
function J(e) {
|
|
32
|
+
const c = A();
|
|
33
|
+
let r;
|
|
34
|
+
const x = ++w;
|
|
35
|
+
let n, o, s, S = null, v = 0;
|
|
36
|
+
const E = F(() => r), y = () => {
|
|
37
|
+
f.editor.setTheme(c.resolvedTheme() === "dark" ? "vs-dark" : "vs");
|
|
38
|
+
}, m = () => !n || !o ? null : {
|
|
39
|
+
editor: n,
|
|
40
|
+
model: o,
|
|
41
|
+
getValue: () => n.getValue(),
|
|
42
|
+
getSelectedText: () => _(n, o),
|
|
43
|
+
focus: () => n.focus()
|
|
44
|
+
}, C = () => {
|
|
45
|
+
const t = m();
|
|
46
|
+
if (!t) return;
|
|
47
|
+
const a = t.model.uri.toString();
|
|
48
|
+
a !== S && (S = a, e.onReady?.(t));
|
|
49
|
+
}, I = () => {
|
|
50
|
+
const t = m();
|
|
51
|
+
t && e.onSelectionChange?.(t.getSelectedText(), t);
|
|
52
|
+
}, T = async () => {
|
|
53
|
+
if (!n) return;
|
|
54
|
+
const t = ++v, a = U(e.language);
|
|
55
|
+
let i = a.id;
|
|
56
|
+
try {
|
|
57
|
+
await a.load?.();
|
|
58
|
+
} catch {
|
|
59
|
+
if (t !== v) return;
|
|
60
|
+
i = "plaintext";
|
|
61
|
+
}
|
|
62
|
+
if (!n || t !== v) return;
|
|
63
|
+
const l = N(x, e.path);
|
|
64
|
+
if (o && o.uri.toString() === l.toString()) {
|
|
65
|
+
o.getLanguageId() !== i && f.editor.setModelLanguage(o, i), o.getValue() !== e.value && o.setValue(e.value), C(), I();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const d = f.editor.createModel(e.value, i, l);
|
|
69
|
+
o?.dispose(), o = d, n.setModel(o), C(), I();
|
|
70
|
+
};
|
|
71
|
+
return b(() => {
|
|
72
|
+
if (!r) return;
|
|
73
|
+
p(), n = f.editor.create(r, {
|
|
74
|
+
model: null,
|
|
75
|
+
...M,
|
|
76
|
+
...e.options ?? {}
|
|
77
|
+
}), y(), T();
|
|
78
|
+
const t = e.onContentChange, a = e.onChange, i = e.onSelectionChange, l = n.onDidChangeModelContent((u) => {
|
|
79
|
+
const h = m();
|
|
80
|
+
h && (t?.(u, h), a && a(h.getValue()));
|
|
81
|
+
}), d = n.onDidChangeCursorSelection(() => {
|
|
82
|
+
const u = m();
|
|
83
|
+
u && i?.(u.getSelectedText(), u);
|
|
84
|
+
});
|
|
85
|
+
q(() => {
|
|
86
|
+
l.dispose(), d.dispose(), s && cancelAnimationFrame(s), n?.dispose(), o?.dispose(), n = void 0, o = void 0;
|
|
87
|
+
});
|
|
88
|
+
}), g(() => {
|
|
89
|
+
y();
|
|
90
|
+
}), g(() => {
|
|
91
|
+
n && n.updateOptions({
|
|
92
|
+
...M,
|
|
93
|
+
...e.options ?? {}
|
|
94
|
+
});
|
|
95
|
+
}), g(() => {
|
|
96
|
+
e.path, e.language, e.value, T();
|
|
97
|
+
}), g(() => {
|
|
98
|
+
const t = E();
|
|
99
|
+
!t || !n || (s && cancelAnimationFrame(s), s = requestAnimationFrame(() => {
|
|
100
|
+
n?.layout({
|
|
101
|
+
width: t.width,
|
|
102
|
+
height: t.height
|
|
103
|
+
});
|
|
104
|
+
}));
|
|
105
|
+
}), (() => {
|
|
106
|
+
var t = z(), a = r;
|
|
107
|
+
return typeof a == "function" ? R(a, t) : r = t, L((i) => {
|
|
108
|
+
var l = e.class, d = e.style;
|
|
109
|
+
return l !== i.e && D(t, i.e = l), i.t = O(t, d, i.t), i;
|
|
110
|
+
}, {
|
|
111
|
+
e: void 0,
|
|
112
|
+
t: void 0
|
|
113
|
+
}), t;
|
|
114
|
+
})();
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
J as CodeEditor
|
|
118
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type CodeEditorLanguageSpec = {
|
|
2
|
+
id: string;
|
|
3
|
+
load?: () => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveCodeEditorLanguageSpec(language?: string | null): CodeEditorLanguageSpec;
|
|
6
|
+
export declare function isCodeEditorLanguageSupported(language?: string | null): boolean;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const s = {
|
|
2
|
+
"": "plaintext",
|
|
3
|
+
text: "plaintext",
|
|
4
|
+
plaintext: "plaintext",
|
|
5
|
+
txt: "plaintext",
|
|
6
|
+
js: "javascript",
|
|
7
|
+
jsx: "javascript",
|
|
8
|
+
javascriptreact: "javascript",
|
|
9
|
+
ts: "typescript",
|
|
10
|
+
tsx: "typescript",
|
|
11
|
+
typescriptreact: "typescript",
|
|
12
|
+
py: "python",
|
|
13
|
+
rb: "ruby",
|
|
14
|
+
rs: "rust",
|
|
15
|
+
sh: "shell",
|
|
16
|
+
bash: "shell",
|
|
17
|
+
zsh: "shell",
|
|
18
|
+
fish: "shell",
|
|
19
|
+
shell: "shell",
|
|
20
|
+
shellscript: "shell",
|
|
21
|
+
yml: "yaml",
|
|
22
|
+
md: "markdown",
|
|
23
|
+
cs: "csharp",
|
|
24
|
+
fs: "fsharp",
|
|
25
|
+
docker: "dockerfile",
|
|
26
|
+
c: "cpp",
|
|
27
|
+
cc: "cpp",
|
|
28
|
+
cxx: "cpp",
|
|
29
|
+
h: "cpp",
|
|
30
|
+
hpp: "cpp",
|
|
31
|
+
hxx: "cpp",
|
|
32
|
+
objectivec: "objective-c",
|
|
33
|
+
"objective-cpp": "objective-c",
|
|
34
|
+
conf: "ini",
|
|
35
|
+
config: "ini",
|
|
36
|
+
env: "ini",
|
|
37
|
+
make: "plaintext",
|
|
38
|
+
makefile: "plaintext",
|
|
39
|
+
cmake: "plaintext",
|
|
40
|
+
toml: "plaintext",
|
|
41
|
+
latex: "plaintext",
|
|
42
|
+
tex: "plaintext",
|
|
43
|
+
vue: "plaintext",
|
|
44
|
+
svelte: "plaintext",
|
|
45
|
+
groovy: "plaintext"
|
|
46
|
+
}, n = {
|
|
47
|
+
javascript: () => import("monaco-editor/esm/vs/language/typescript/monaco.contribution.js"),
|
|
48
|
+
typescript: () => import("monaco-editor/esm/vs/language/typescript/monaco.contribution.js"),
|
|
49
|
+
json: () => import("monaco-editor/esm/vs/language/json/monaco.contribution.js"),
|
|
50
|
+
html: () => import("monaco-editor/esm/vs/language/html/monaco.contribution.js"),
|
|
51
|
+
css: () => import("monaco-editor/esm/vs/language/css/monaco.contribution.js"),
|
|
52
|
+
scss: () => import("monaco-editor/esm/vs/language/css/monaco.contribution.js"),
|
|
53
|
+
less: () => import("monaco-editor/esm/vs/language/css/monaco.contribution.js"),
|
|
54
|
+
markdown: () => import("monaco-editor/esm/vs/basic-languages/markdown/markdown.contribution.js"),
|
|
55
|
+
yaml: () => import("monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js"),
|
|
56
|
+
ini: () => import("monaco-editor/esm/vs/basic-languages/ini/ini.contribution.js"),
|
|
57
|
+
xml: () => import("monaco-editor/esm/vs/basic-languages/xml/xml.contribution.js"),
|
|
58
|
+
python: () => import("monaco-editor/esm/vs/basic-languages/python/python.contribution.js"),
|
|
59
|
+
java: () => import("monaco-editor/esm/vs/basic-languages/java/java.contribution.js"),
|
|
60
|
+
kotlin: () => import("monaco-editor/esm/vs/basic-languages/kotlin/kotlin.contribution.js"),
|
|
61
|
+
scala: () => import("monaco-editor/esm/vs/basic-languages/scala/scala.contribution.js"),
|
|
62
|
+
go: () => import("monaco-editor/esm/vs/basic-languages/go/go.contribution.js"),
|
|
63
|
+
rust: () => import("monaco-editor/esm/vs/basic-languages/rust/rust.contribution.js"),
|
|
64
|
+
cpp: () => import("monaco-editor/esm/vs/basic-languages/cpp/cpp.contribution.js"),
|
|
65
|
+
csharp: () => import("monaco-editor/esm/vs/basic-languages/csharp/csharp.contribution.js"),
|
|
66
|
+
fsharp: () => import("monaco-editor/esm/vs/basic-languages/fsharp/fsharp.contribution.js"),
|
|
67
|
+
php: () => import("monaco-editor/esm/vs/basic-languages/php/php.contribution.js"),
|
|
68
|
+
ruby: () => import("monaco-editor/esm/vs/basic-languages/ruby/ruby.contribution.js"),
|
|
69
|
+
perl: () => import("monaco-editor/esm/vs/basic-languages/perl/perl.contribution.js"),
|
|
70
|
+
shell: () => import("monaco-editor/esm/vs/basic-languages/shell/shell.contribution.js"),
|
|
71
|
+
swift: () => import("monaco-editor/esm/vs/basic-languages/swift/swift.contribution.js"),
|
|
72
|
+
"objective-c": () => import("monaco-editor/esm/vs/basic-languages/objective-c/objective-c.contribution.js"),
|
|
73
|
+
r: () => import("monaco-editor/esm/vs/basic-languages/r/r.contribution.js"),
|
|
74
|
+
sql: () => import("monaco-editor/esm/vs/basic-languages/sql/sql.contribution.js"),
|
|
75
|
+
lua: () => import("monaco-editor/esm/vs/basic-languages/lua/lua.contribution.js"),
|
|
76
|
+
dart: () => import("monaco-editor/esm/vs/basic-languages/dart/dart.contribution.js"),
|
|
77
|
+
dockerfile: () => import("monaco-editor/esm/vs/basic-languages/dockerfile/dockerfile.contribution.js"),
|
|
78
|
+
bat: () => import("monaco-editor/esm/vs/basic-languages/bat/bat.contribution.js"),
|
|
79
|
+
powershell: () => import("monaco-editor/esm/vs/basic-languages/powershell/powershell.contribution.js")
|
|
80
|
+
}, e = /* @__PURE__ */ new Map();
|
|
81
|
+
function o(p) {
|
|
82
|
+
const t = String(p ?? "").trim().toLowerCase();
|
|
83
|
+
return (s[t] ?? t) || "plaintext";
|
|
84
|
+
}
|
|
85
|
+
function a(p, t) {
|
|
86
|
+
if (t)
|
|
87
|
+
return () => {
|
|
88
|
+
const i = e.get(p);
|
|
89
|
+
if (i) return i;
|
|
90
|
+
const r = t().then(() => {
|
|
91
|
+
}).catch((c) => {
|
|
92
|
+
throw e.delete(p), c;
|
|
93
|
+
});
|
|
94
|
+
return e.set(p, r), r;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function l(p) {
|
|
98
|
+
const t = o(p), i = a(t, n[t]);
|
|
99
|
+
return {
|
|
100
|
+
id: t,
|
|
101
|
+
load: i
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function m(p) {
|
|
105
|
+
return l(p).id !== "plaintext" || o(p) === "plaintext";
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
m as isCodeEditorLanguageSupported,
|
|
109
|
+
l as resolveCodeEditorLanguageSpec
|
|
110
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureMonacoEnvironment(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import n from "monaco-editor/esm/vs/editor/editor.worker.js?worker";
|
|
2
|
+
import t from "monaco-editor/esm/vs/language/typescript/ts.worker.js?worker";
|
|
3
|
+
import e from "monaco-editor/esm/vs/language/json/json.worker.js?worker";
|
|
4
|
+
import i from "monaco-editor/esm/vs/language/html/html.worker.js?worker";
|
|
5
|
+
import s from "monaco-editor/esm/vs/language/css/css.worker.js?worker";
|
|
6
|
+
const o = globalThis;
|
|
7
|
+
function W() {
|
|
8
|
+
o.MonacoEnvironment || (o.MonacoEnvironment = {
|
|
9
|
+
getWorker: (m, r) => r === "typescript" || r === "javascript" ? new t() : r === "json" ? new e() : r === "html" || r === "handlebars" || r === "razor" ? new i() : r === "css" || r === "scss" || r === "less" ? new s() : new n()
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
W as ensureMonacoEnvironment
|
|
14
|
+
};
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/editor';
|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CodeEditor as r } from "./components/editor/CodeEditor.js";
|
|
2
|
+
import { isCodeEditorLanguageSupported as t, resolveCodeEditorLanguageSpec as p } from "./components/editor/languages.js";
|
|
3
|
+
export {
|
|
4
|
+
r as CodeEditor,
|
|
5
|
+
t as isCodeEditorLanguageSupported,
|
|
6
|
+
p as resolveCodeEditorLanguageSpec
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-core",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
"types": "./dist/chat.d.ts",
|
|
57
57
|
"import": "./dist/chat.js"
|
|
58
58
|
},
|
|
59
|
+
"./editor": {
|
|
60
|
+
"types": "./dist/editor.d.ts",
|
|
61
|
+
"import": "./dist/editor.js"
|
|
62
|
+
},
|
|
59
63
|
"./widgets": {
|
|
60
64
|
"types": "./dist/widgets.d.ts",
|
|
61
65
|
"import": "./dist/widgets.js"
|
|
@@ -86,6 +90,7 @@
|
|
|
86
90
|
"diff": "^8.0.3",
|
|
87
91
|
"marked": "^17.0.1",
|
|
88
92
|
"mermaid": "^11.12.3",
|
|
93
|
+
"monaco-editor": "^0.55.1",
|
|
89
94
|
"shiki": "^3.21.0",
|
|
90
95
|
"solid-motionone": "^1.0.4",
|
|
91
96
|
"tailwind-merge": "^3.4.0"
|