From c4838b129f0edb808e69ac2294ede086f03fab7d Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Thu, 24 Jun 2021 11:14:25 -0500 Subject: [PATCH] document title improvements --- src/js/Canvas.js | 1 + src/js/Import.js | 1 + src/js/Title.js | 5 +---- src/js/start.js | 5 ++++- src/js/svgcanvas.js | 4 +++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/Canvas.js b/src/js/Canvas.js index 7f51f62..031f05b 100644 --- a/src/js/Canvas.js +++ b/src/js/Canvas.js @@ -146,6 +146,7 @@ MD.Canvas = function(){ function rename(str) { if (str.length) { + $('#canvas_title').val(str); svgCanvas.setDocumentTitle(str); } } diff --git a/src/js/Import.js b/src/js/Import.js index 77b7f73..3e2f4fa 100644 --- a/src/js/Import.js +++ b/src/js/Import.js @@ -82,6 +82,7 @@ MD.Import = function(){ if(success) { callback(true); editor.saveCanvas(); + state.set("canvasTitle", svgCanvas.getDocumentTitle()); } else { $.alert("Error: Unable to load SVG data", function() { callback(false); diff --git a/src/js/Title.js b/src/js/Title.js index 2d8eee8..5b26e51 100644 --- a/src/js/Title.js +++ b/src/js/Title.js @@ -1,7 +1,6 @@ MD.Title = function(){ $('#canvas_title') - .val(state.get("canvasTitle")) .keydown(function(e){ e.stopPropagation(); if (e.key === "Escape") { @@ -14,13 +13,11 @@ MD.Title = function(){ .keyup(function(e){ e.stopPropagation(); svgCanvas.setDocumentTitle(this.value); + state.set("canvasTitle", this.value); }) .click(function(e) { this.focus(); this.select(); }) - .blur(function(e){ - state.set("canvasTitle", this.value); - }); } \ No newline at end of file diff --git a/src/js/start.js b/src/js/start.js index 0fdeec6..7e8867e 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -119,8 +119,11 @@ const eyedropper = svgCanvas.addExtension.apply(this, ["eyedropper", MD.Eyedropp state.set("canvasId", t("Untitled")); state.set("canvasMode", state.get("canvasMode")); svgCanvas.setSvgString(state.get("canvasContent")); +state.set("canvasTitle", svgCanvas.getDocumentTitle()); + //editor.paintBox.fill.setPaint(state.get("canvasFill")); //editor.paintBox.stroke.setPaint(state.get("canvasStroke")); //editor.paintBox.canvas.setPaint(state.get("canvasBackground")); + document.body.classList.remove("loading"); -document.getElementById("workarea").removeAttribute("title"); \ No newline at end of file +document.getElementById("svgcanvas").removeAttribute("title"); \ No newline at end of file diff --git a/src/js/svgcanvas.js b/src/js/svgcanvas.js index a24a0ae..1204987 100644 --- a/src/js/svgcanvas.js +++ b/src/js/svgcanvas.js @@ -6061,7 +6061,8 @@ this.importSvgString = function(xmlString) { setUseData(svg); convertGradients(svg); - + + // recalculate dimensions on the top-level children so that unnecessary transforms // are removed svgedit.utilities.walkTreePost(svgcontent, function(n){try{recalculateDimensions(n)}catch(e){console.log(e)}}); @@ -6088,6 +6089,7 @@ this.importSvgString = function(xmlString) { } layer.appendChild(g); batchCmd.addSubCommand(new InsertElementCommand(g)); + clearSelection(); addToSelection([g]);