diff --git a/editor/svg-editor.css b/editor/svg-editor.css index 3afee9fb..4a23b251 100644 --- a/editor/svg-editor.css +++ b/editor/svg-editor.css @@ -752,7 +752,7 @@ span.zoom_tool { #option_lists ul { display: none; position: absolute; - height: 90px; + height: auto; z-index: 3; margin: 0; list-style: none; diff --git a/editor/svg-editor.js b/editor/svg-editor.js index a0075d9c..b1121fa8 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1711,10 +1711,6 @@ } }, true); -// $('#cur_linecap').mousedown(function() { -// $('#linecap_opts').show(); -// }); - addAltDropDown('#stroke_linecap', '#linecap_opts', function() { var val = this.id.split('_')[1]; svgCanvas.setStrokeAttr('stroke-linecap', val); @@ -2267,7 +2263,8 @@ 'line-height': {s: '15px'} }, "#tools_bottom_2": { - 'width': {l: '295px', xl: '355px'} + 'width': {l: '295px', xl: '355px'}, + 'top': {s: '4px'} }, "#tools_top > div, #tools_top": { 'line-height': {s: '17px', l: '34px', xl: '50px'} diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 628ca335..32b12892 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1140,6 +1140,7 @@ function BatchCommand(text) { var handle = svgroot.suspendRedraw(60); var defaults = { 'fill-opacity':1, + 'stop-opacity':1, 'opacity':1, 'stroke':'none', 'stroke-dasharray':'none', @@ -1600,15 +1601,40 @@ function BatchCommand(text) { // Process root element separately var res = canvas.getResolution(); out.push(' width="' + res.w + '" height="' + res.h + '" xmlns="'+svgns+'"'); + + var nsuris = {}; + + // Check elements for namespaces, add if found + $(elem).find('*').andSelf().each(function() { + var el = this; + $.each(this.attributes, function(i, attr) { + var uri = attr.namespaceURI; + if(uri && !nsuris[uri] && nsMap[uri] !== 'xmlns') { + nsuris[uri] = true; +// console.log('add', nsMap[uri]); +// if(nsMap[uri] == 'xmlns') { +// console.log('hm',el, attr.nodeName); +// } + out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"'); + } + }); + }); + var i = attrs.length; while (i--) { attr = attrs.item(i); var attrVal = toXml(attr.nodeValue); + + // Namespaces have already been dealt with, so skip + if(attr.nodeName.indexOf('xmlns:') === 0) continue; + // only serialize attributes we don't use internally if (attrVal != "" && $.inArray(attr.localName, ['width','height','xmlns','x','y','viewBox','id','overflow']) == -1) { + if(!attr.namespaceURI || nsMap[attr.namespaceURI]) { + console.log(!attr.namespaceURI, nsMap[attr.namespaceURI]); out.push(' '); out.push(attr.nodeName); out.push("=\""); out.push(attrVal); out.push("\""); @@ -5982,6 +6008,9 @@ function BatchCommand(text) { } content.attr(attrs); + this.contentW = attrs['width']; + this.contentH = attrs['height']; + batchCmd.addSubCommand(new InsertElementCommand(svgcontent)); // update root to the correct size var changes = content.attr(["width", "height"]); @@ -6949,9 +6978,7 @@ function BatchCommand(text) { if(diff) continue; } - this.contentW = attrs['width']; - this.contentH = attrs['height']; - + // else could be a duplicate, iterate through stops var stops = grad.getElementsByTagNameNS(svgns, "stop"); var ostops = og.getElementsByTagNameNS(svgns, "stop");