@floegence/floe-webapp-core 0.101.11 → 0.101.12
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { effect as V, className as q, style as U, template as $, use as k } from "solid-js/web";
|
|
2
2
|
import { useContextMenuActions as B } from "../ui/ContextMenuActions.js";
|
|
3
|
-
import { onMount as N, onCleanup as P, createEffect as
|
|
3
|
+
import { onMount as N, onCleanup as P, createEffect as C } from "solid-js";
|
|
4
4
|
import { useTheme as _ } from "../../context/ThemeContext.js";
|
|
5
5
|
import { useResizeObserver as H } from "../../hooks/useResizeObserver.js";
|
|
6
6
|
import { resolveCodeEditorLanguageSpec as K } from "./languages.js";
|
|
@@ -9,7 +9,7 @@ import { ensureMonacoEnvironment as X } from "./monacoEnvironment.js";
|
|
|
9
9
|
import { loadMonacoEditorApi as Y } from "./monacoStandaloneRuntime.js";
|
|
10
10
|
import { ensureFloeMonacoHover as j } from "./monacoHover.js";
|
|
11
11
|
var J = /* @__PURE__ */ $("<div>");
|
|
12
|
-
const
|
|
12
|
+
const w = {
|
|
13
13
|
readOnly: !0,
|
|
14
14
|
automaticLayout: !1,
|
|
15
15
|
minimap: {
|
|
@@ -22,69 +22,69 @@ const A = {
|
|
|
22
22
|
fontFamily: "var(--font-mono)"
|
|
23
23
|
};
|
|
24
24
|
let Q = 0;
|
|
25
|
-
function W(t, f,
|
|
26
|
-
return t.Uri.parse(`inmemory://model/${f}/${encodeURIComponent(
|
|
25
|
+
function W(t, f, s) {
|
|
26
|
+
return t.Uri.parse(`inmemory://model/${f}/${encodeURIComponent(s)}`);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function A(t, f) {
|
|
29
29
|
if (!t || !f) return "";
|
|
30
|
-
const
|
|
31
|
-
return !
|
|
30
|
+
const s = t.getSelection();
|
|
31
|
+
return !s || s.isEmpty() ? "" : f.getValueInRange(s);
|
|
32
32
|
}
|
|
33
33
|
function ue(t) {
|
|
34
|
-
const f = _(),
|
|
34
|
+
const f = _(), s = B();
|
|
35
35
|
let m;
|
|
36
|
-
const
|
|
37
|
-
let
|
|
38
|
-
const
|
|
36
|
+
const R = ++Q;
|
|
37
|
+
let d, o, i, h, x = null, M = 0;
|
|
38
|
+
const F = H(() => m), S = () => {
|
|
39
39
|
const e = f.resolvedTheme(), a = f.shellPreset();
|
|
40
|
-
|
|
40
|
+
d && G(d.editor, e, a);
|
|
41
41
|
}, y = () => !o || !i ? null : {
|
|
42
42
|
editor: o,
|
|
43
43
|
model: i,
|
|
44
44
|
getValue: () => o.getValue(),
|
|
45
|
-
getSelectedText: () =>
|
|
45
|
+
getSelectedText: () => A(o, i),
|
|
46
46
|
focus: () => o.focus()
|
|
47
|
-
},
|
|
47
|
+
}, p = () => {
|
|
48
48
|
const e = y();
|
|
49
49
|
if (!e) return;
|
|
50
50
|
const a = e.model.uri.toString();
|
|
51
|
-
a !==
|
|
52
|
-
},
|
|
51
|
+
a !== x && (x = a, t.onReady?.(e));
|
|
52
|
+
}, L = () => {
|
|
53
53
|
const e = y();
|
|
54
54
|
e && t.onSelectionChange?.(e.getSelectedText(), e);
|
|
55
|
-
},
|
|
56
|
-
if (!o || !
|
|
57
|
-
const e = ++
|
|
55
|
+
}, b = async () => {
|
|
56
|
+
if (!o || !d) return;
|
|
57
|
+
const e = ++M, a = K(t.language);
|
|
58
58
|
let l = a.id;
|
|
59
59
|
try {
|
|
60
60
|
await a.load?.();
|
|
61
61
|
} catch {
|
|
62
|
-
if (e !==
|
|
62
|
+
if (e !== M) return;
|
|
63
63
|
l = "plaintext";
|
|
64
64
|
}
|
|
65
|
-
if (!o || e !==
|
|
66
|
-
const u = W(
|
|
65
|
+
if (!o || e !== M) return;
|
|
66
|
+
const u = W(d, R, t.path);
|
|
67
67
|
if (i && i.uri.toString() === u.toString()) {
|
|
68
|
-
i.getLanguageId() !== l &&
|
|
68
|
+
i.getLanguageId() !== l && d.editor.setModelLanguage(i, l), i.getValue() !== t.value && i.setValue(t.value), p(), L();
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const g =
|
|
72
|
-
i?.dispose(), i = g, o.setModel(i),
|
|
71
|
+
const g = d.editor.createModel(t.value, l, u);
|
|
72
|
+
i?.dispose(), i = g, o.setModel(i), p(), L();
|
|
73
73
|
};
|
|
74
74
|
return N(() => {
|
|
75
|
-
let e = !1, a, l, u, g = [],
|
|
75
|
+
let e = !1, a, l, u, g = [], E = [];
|
|
76
76
|
(async () => {
|
|
77
|
-
if (!m || (X(), j(),
|
|
78
|
-
o =
|
|
77
|
+
if (!m || (X(), j(), d = await Y(t.runtimeOptions), e || !m)) return;
|
|
78
|
+
o = d.editor.create(m, {
|
|
79
79
|
model: null,
|
|
80
|
-
...
|
|
80
|
+
...w,
|
|
81
81
|
...t.options ?? {}
|
|
82
82
|
});
|
|
83
|
-
const r = m,
|
|
84
|
-
g = (
|
|
83
|
+
const r = m, I = r.getBoundingClientRect();
|
|
84
|
+
g = (s?.resolve({
|
|
85
85
|
target: r,
|
|
86
|
-
x:
|
|
87
|
-
y:
|
|
86
|
+
x: I.left,
|
|
87
|
+
y: I.top,
|
|
88
88
|
selection: ""
|
|
89
89
|
}) ?? []).map((n) => o.addAction({
|
|
90
90
|
id: n.id,
|
|
@@ -92,47 +92,48 @@ function ue(t) {
|
|
|
92
92
|
contextMenuGroupId: "navigation",
|
|
93
93
|
contextMenuOrder: 0,
|
|
94
94
|
run: () => {
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
const c = E.find((D) => D.id === n.id);
|
|
96
|
+
c && !c.disabled && c.onSelect();
|
|
97
97
|
}
|
|
98
98
|
}));
|
|
99
99
|
const v = (n) => {
|
|
100
100
|
if (n instanceof KeyboardEvent && n.key !== "ContextMenu" && !(n.shiftKey && n.key === "F10") || n instanceof MouseEvent && n.type === "pointerdown" && n.button !== 2) return;
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
s?.claim();
|
|
102
|
+
const c = r.getBoundingClientRect();
|
|
103
|
+
E = s?.resolve({
|
|
103
104
|
target: r,
|
|
104
|
-
x: n instanceof MouseEvent ? n.clientX :
|
|
105
|
-
y: n instanceof MouseEvent ? n.clientY :
|
|
106
|
-
selection:
|
|
105
|
+
x: n instanceof MouseEvent ? n.clientX : c.left + 8,
|
|
106
|
+
y: n instanceof MouseEvent ? n.clientY : c.top + 24,
|
|
107
|
+
selection: A(o, i)
|
|
107
108
|
}) ?? [];
|
|
108
109
|
};
|
|
109
110
|
if (r.addEventListener("pointerdown", v, !0), r.addEventListener("contextmenu", v, !0), r.addEventListener("keydown", v, !0), u = () => {
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
const
|
|
111
|
+
E = [], r.removeEventListener("pointerdown", v, !0), r.removeEventListener("contextmenu", v, !0), r.removeEventListener("keydown", v, !0);
|
|
112
|
+
}, S(), await b(), e || !o) return;
|
|
113
|
+
const O = t.onContentChange, T = t.onChange, z = t.onSelectionChange;
|
|
113
114
|
a = o.onDidChangeModelContent((n) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
115
|
+
const c = y();
|
|
116
|
+
c && (O?.(n, c), T && T(c.getValue()));
|
|
116
117
|
}), l = o.onDidChangeCursorSelection(() => {
|
|
117
118
|
const n = y();
|
|
118
|
-
n &&
|
|
119
|
+
n && z?.(n.getSelectedText(), n);
|
|
119
120
|
});
|
|
120
121
|
})().catch((r) => {
|
|
121
122
|
console.error("Failed to initialize Monaco editor runtime", r);
|
|
122
123
|
}), P(() => {
|
|
123
|
-
e = !0, a?.dispose(), l?.dispose(), u?.(), g.forEach((r) => r.dispose()), h && cancelAnimationFrame(h), o?.dispose(), i?.dispose(),
|
|
124
|
+
e = !0, a?.dispose(), l?.dispose(), u?.(), g.forEach((r) => r.dispose()), h && cancelAnimationFrame(h), o?.dispose(), i?.dispose(), d = void 0, o = void 0, i = void 0;
|
|
124
125
|
});
|
|
125
|
-
}),
|
|
126
|
-
|
|
127
|
-
}),
|
|
126
|
+
}), C(() => {
|
|
127
|
+
S();
|
|
128
|
+
}), C(() => {
|
|
128
129
|
o && o.updateOptions({
|
|
129
|
-
...
|
|
130
|
+
...w,
|
|
130
131
|
...t.options ?? {}
|
|
131
132
|
});
|
|
132
|
-
}),
|
|
133
|
-
t.path, t.language, t.value,
|
|
134
|
-
}),
|
|
135
|
-
const e =
|
|
133
|
+
}), C(() => {
|
|
134
|
+
t.path, t.language, t.value, b();
|
|
135
|
+
}), C(() => {
|
|
136
|
+
const e = F();
|
|
136
137
|
!e || !o || (h && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
|
|
137
138
|
o?.layout({
|
|
138
139
|
width: e.width,
|