document title improvements

master
Mark MacKay 2021-06-24 11:14:25 -05:00
parent 152de8d9a6
commit c4838b129f
5 changed files with 10 additions and 6 deletions

View File

@ -146,6 +146,7 @@ MD.Canvas = function(){
function rename(str) { function rename(str) {
if (str.length) { if (str.length) {
$('#canvas_title').val(str);
svgCanvas.setDocumentTitle(str); svgCanvas.setDocumentTitle(str);
} }
} }

View File

@ -82,6 +82,7 @@ MD.Import = function(){
if(success) { if(success) {
callback(true); callback(true);
editor.saveCanvas(); editor.saveCanvas();
state.set("canvasTitle", svgCanvas.getDocumentTitle());
} else { } else {
$.alert("Error: Unable to load SVG data", function() { $.alert("Error: Unable to load SVG data", function() {
callback(false); callback(false);

View File

@ -1,7 +1,6 @@
MD.Title = function(){ MD.Title = function(){
$('#canvas_title') $('#canvas_title')
.val(state.get("canvasTitle"))
.keydown(function(e){ .keydown(function(e){
e.stopPropagation(); e.stopPropagation();
if (e.key === "Escape") { if (e.key === "Escape") {
@ -14,13 +13,11 @@ MD.Title = function(){
.keyup(function(e){ .keyup(function(e){
e.stopPropagation(); e.stopPropagation();
svgCanvas.setDocumentTitle(this.value); svgCanvas.setDocumentTitle(this.value);
state.set("canvasTitle", this.value);
}) })
.click(function(e) { .click(function(e) {
this.focus(); this.focus();
this.select(); this.select();
}) })
.blur(function(e){
state.set("canvasTitle", this.value);
});
} }

View File

@ -119,8 +119,11 @@ const eyedropper = svgCanvas.addExtension.apply(this, ["eyedropper", MD.Eyedropp
state.set("canvasId", t("Untitled")); state.set("canvasId", t("Untitled"));
state.set("canvasMode", state.get("canvasMode")); state.set("canvasMode", state.get("canvasMode"));
svgCanvas.setSvgString(state.get("canvasContent")); svgCanvas.setSvgString(state.get("canvasContent"));
state.set("canvasTitle", svgCanvas.getDocumentTitle());
//editor.paintBox.fill.setPaint(state.get("canvasFill")); //editor.paintBox.fill.setPaint(state.get("canvasFill"));
//editor.paintBox.stroke.setPaint(state.get("canvasStroke")); //editor.paintBox.stroke.setPaint(state.get("canvasStroke"));
//editor.paintBox.canvas.setPaint(state.get("canvasBackground")); //editor.paintBox.canvas.setPaint(state.get("canvasBackground"));
document.body.classList.remove("loading"); document.body.classList.remove("loading");
document.getElementById("workarea").removeAttribute("title"); document.getElementById("svgcanvas").removeAttribute("title");

View File

@ -6062,6 +6062,7 @@ this.importSvgString = function(xmlString) {
convertGradients(svg); convertGradients(svg);
// recalculate dimensions on the top-level children so that unnecessary transforms // recalculate dimensions on the top-level children so that unnecessary transforms
// are removed // are removed
svgedit.utilities.walkTreePost(svgcontent, function(n){try{recalculateDimensions(n)}catch(e){console.log(e)}}); svgedit.utilities.walkTreePost(svgcontent, function(n){try{recalculateDimensions(n)}catch(e){console.log(e)}});
@ -6089,6 +6090,7 @@ this.importSvgString = function(xmlString) {
layer.appendChild(g); layer.appendChild(g);
batchCmd.addSubCommand(new InsertElementCommand(g)); batchCmd.addSubCommand(new InsertElementCommand(g));
clearSelection(); clearSelection();
addToSelection([g]); addToSelection([g]);
addCommandToHistory(batchCmd); addCommandToHistory(batchCmd);