Fix Monaco

This commit is contained in:
thororen1234 2024-06-22 09:59:51 -04:00
commit a40ef29b3a
6 changed files with 74 additions and 40 deletions

View file

@ -4,6 +4,9 @@
<head>
<meta charset="utf-8" />
<title>Equicord QuickCSS Editor</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs/editor/editor.main.css"
integrity="sha256-tiJPQ2O04z/pZ/AwdyIghrOMzewf+PIvEl1YKbQvsZk=" crossorigin="anonymous"
referrerpolicy="no-referrer" />
<style>
html,
body,
@ -22,18 +25,37 @@
<body>
<div id="container"></div>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs/loader.js"
integrity="sha256-KcU48TGr84r7unF7J5IgBo95aeVrEbrGe04S7TcFUjs=" crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script>
const script = document.createElement("script");
script.src = new URL("/dist/monaco/index.js", baseUrl);
require.config({
paths: {
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs",
},
});
const style = document.createElement("link");
style.type = "text/css";
style.rel = "stylesheet";
style.href = new URL("/dist/monaco/index.css", baseUrl);
document.body.append(style, script);
require(["vs/editor/editor.main"], () => {
getCurrentCss().then((css) => {
var editor = monaco.editor.create(
document.getElementById("container"),
{
value: css,
language: "css",
theme: getTheme(),
}
);
editor.onDidChangeModelContent(() =>
setCss(editor.getValue())
);
window.addEventListener("resize", () => {
// make monaco re-layout
editor.layout();
});
});
});
</script>
</body>
</html>
</html>

View file

@ -8,7 +8,12 @@ export let EXTENSION_BASE_URL: string;
export let EXTENSION_VERSION: string;
if (IS_EXTENSION) {
const script = document.querySelector("#vencord-script") as HTMLScriptElement;
EXTENSION_BASE_URL = script.dataset.extensionBaseUrl!;
EXTENSION_VERSION = script.dataset.version!;
const listener = (e: MessageEvent) => {
if (e.data?.type === "vencord:meta") {
({ EXTENSION_BASE_URL, EXTENSION_VERSION } = e.data.meta);
window.removeEventListener("message", listener);
}
};
window.addEventListener("message", listener);
}