Fix for importing svg files where grabber just selects nothing as it doesnt know the svg to select

master
ibrierley 2015-07-16 15:45:48 +02:00
parent 85a68c3f42
commit 4d745dc05b
2 changed files with 6 additions and 3 deletions

View File

@ -4745,7 +4745,7 @@ TODOS
$('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom }) $('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom })
// Set default zoom // Set default zoom
.val(svgCanvas.getZoom() * 100); .val(svgCanvas.getZoom() * 100);
///EDITED
$('#workarea').contextMenu({ $('#workarea').contextMenu({
menu: 'cmenu_canvas', menu: 'cmenu_canvas',
inSpeed: 0 inSpeed: 0
@ -4904,12 +4904,14 @@ TODOS
if (file.type.indexOf('svg') != -1) { if (file.type.indexOf('svg') != -1) {
reader = new FileReader(); reader = new FileReader();
reader.onloadend = function(e) { reader.onloadend = function(e) {
svgCanvas.importSvgString(e.target.result, true); var newElement = svgCanvas.importSvgString(e.target.result, true);
svgCanvas.ungroupSelectedElement(); svgCanvas.ungroupSelectedElement();
svgCanvas.ungroupSelectedElement(); svgCanvas.ungroupSelectedElement();
svgCanvas.groupSelectedElements(); svgCanvas.groupSelectedElements();
svgCanvas.alignSelectedElements('m', 'page'); svgCanvas.alignSelectedElements('m', 'page');
svgCanvas.alignSelectedElements('c', 'page'); svgCanvas.alignSelectedElements('c', 'page');
// highlight imported element, otherwise we get strange empty selectbox
svgCanvas.selectOnly([newElement]);
$('#dialog_box').hide(); $('#dialog_box').hide();
}; };
reader.readAsText(file); reader.readAsText(file);

View File

@ -5083,7 +5083,8 @@ this.importSvgString = function(xmlString) {
return false; return false;
} }
return true; // we want to return the element so we can automatically select it
return use_el;
}; };
// TODO(codedread): Move all layer/context functions in draw.js // TODO(codedread): Move all layer/context functions in draw.js