From c71ee21d29084cd526e6df4e401fdf8af946f0de Mon Sep 17 00:00:00 2001 From: ItsLap <74074061+ItsLap@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:27:14 +0100 Subject: [PATCH] QOL DevEnv features --- pkgs/apps/DevEnv.js | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/pkgs/apps/DevEnv.js b/pkgs/apps/DevEnv.js index 50b04cd..41e05f7 100644 --- a/pkgs/apps/DevEnv.js +++ b/pkgs/apps/DevEnv.js @@ -297,14 +297,35 @@ export default { DvSettings.fontSize = Number(editorSize.toString()); DvSaveSettings(); }, - run: () => { - Root.Core.startPkg( - URL.createObjectURL( - new Blob([editor.getValue()], { type: "application/javascript" }) - ), - // URL.createObjectURL(["data:text/javascript," + encodeURIComponent(`/*${currentDocument.path}*/` +editor.getValue())], {type:'text/plain'}), - false - ); + run: async () => { + if (currentDocument.dirty === true) { + modal( + new Html("div").appendMany( + new Html("span").text( + "You have unsaved changes. Save your work before running the app." + ) + ), + true, + Root.Lib.getString("error") + ); + return; + } + + if (currentDocument.path.endsWith(".app")) { + Root.Core.startPkg( + URL.createObjectURL( + new Blob([editor.getValue()], { type: "application/javascript" }) + ), + // URL.createObjectURL(["data:text/javascript," + encodeURIComponent(`/*${currentDocument.path}*/` +editor.getValue())], {type:'text/plain'}), + false + ); + } else if (currentDocument.path.endsWith(".pml")) { + let x = await Root.Core.startPkg("apps:PML", true, true); + x.proc.send({ + type: "loadFile", + path: currentDocument.path, + }); + } }, prettify: async () => { try {