Monaco Popup: Add metadata, store window instance

This commit is contained in:
Vendicated 2022-12-20 17:43:55 +01:00
parent 9dcafbf468
commit 103c499310
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905

View file

@ -29,7 +29,12 @@ const setCss = debounce((css: string) => {
}); });
export async function launchMonacoEditor() { export async function launchMonacoEditor() {
const win = open("about:blank", void 0, "popup,width=1000,height=1000")!; const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`;
const win = open("about:blank", "VencordQuickCss", features);
if (!win) {
alert("Failed to open QuickCSS popup. Make sure to allow popups!");
return;
}
win.setCss = setCss; win.setCss = setCss;
win.getCurrentCss = () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS); win.getCurrentCss = () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS);
@ -41,4 +46,6 @@ export async function launchMonacoEditor() {
: "vs-dark"; : "vs-dark";
win.document.write(monacoHtml); win.document.write(monacoHtml);
window.__VENCORD_MONACO_WIN__ = new WeakRef(win);
} }