load svg with parameter

main
Mark MacKay 2021-10-23 14:26:51 -05:00
parent 46c7a78324
commit 1e029fa536
1 changed files with 23 additions and 1 deletions

View File

@ -32,7 +32,29 @@ const shapeLib = svgCanvas.addExtension.apply(this, ["shapes", MD.Shapelib]);
const eyedropper = svgCanvas.addExtension.apply(this, ["eyedropper", MD.Eyedropper]);
state.set("canvasId", t("Untitled"));
state.set("canvasMode", state.get("canvasMode"));
svgCanvas.setSvgString(state.get("canvasContent"));
// load from param
console.log(window.location.search)
if (!window.location.search.includes("?load=")) {
svgCanvas.setSvgString(state.get("canvasContent"));
}
else {
const error = function(err) {
console.log(err);
svgCanvas.setSvgString(state.get("canvasContent"));
}
const url = utils.findGetParameter("load");
fetch(url)
.then(r => r.text())
.then(text => {
if (text.includes("Error response")) return error("Error response");
svgCanvas.setSvgString(text);
})
.catch(error);
}
state.set("canvasTitle", svgCanvas.getDocumentTitle());
//editor.paintBox.fill.setPaint(state.get("canvasFill"));