From 02fc6918f954682b9579d8282e013a8e2104e796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20=C3=85sberg?= Date: Sat, 20 Mar 2021 17:07:09 +0100 Subject: [PATCH] Export data in blob URL --- scripts/engine/Editor.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/engine/Editor.js b/scripts/engine/Editor.js index c84d8f5..e314882 100644 --- a/scripts/engine/Editor.js +++ b/scripts/engine/Editor.js @@ -180,7 +180,14 @@ Editor.create = function(){ exportModel.id = "save_changes"; exportModel.innerHTML = "{}export model"; exportModel.onclick = function(){ - window.open("data:text/json;charset=utf-8,"+JSON.stringify(Model.data)); + var blob = new Blob([JSON.stringify(Model.data)], { type: "text/json" }); + var objectURL = URL.createObjectURL(blob); + var newWindow = window.open(objectURL); + function cleanUpCallback() { + URL.revokeObjectURL(objectURL); + newWindow.removeEventListener("load", cleanUpCallback, true); + } + newWindow.addEventListener("load", cleanUpCallback, true); }; Editor.dom.appendChild(exportModel);