From 1d8318cfd2f58b5f70f31513fb73bcdac48d15fe Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 10 Feb 2010 11:37:26 -0600 Subject: [PATCH] foreignObject are now selectable, etc They are now selectable, draggable, resizable and rotatable. The MathML content behave strangely when you resize, but snaps back to its correct size when you let go of the mouse. (Resizing the MathML involves changing the font-size on the containing foreignObject. No interface for that, yet.) --- public/svg-edit/editor/images/logo.png | Bin 2877 -> 3983 bytes .../svg-edit/editor/images/svg_edit_icons.svg | 133 +++++------------- public/svg-edit/editor/svg-editor.css | 4 +- public/svg-edit/editor/svgcanvas.js | 17 ++- public/svg-edit/test/test1.html | 9 +- 5 files changed, 58 insertions(+), 105 deletions(-) diff --git a/public/svg-edit/editor/images/logo.png b/public/svg-edit/editor/images/logo.png index c9c61ae996ea0c10652d020edddcf5dca6decfb8..7c04931c3429ea744666949a0be7c11d3ebb57f1 100644 GIT binary patch literal 3983 zcmV;A4{-2_P)F-b&0RCwCVSqXGhRkq!)>eW1CCV_+` zG9*l57!+6x2?(nZ8jy%$14^sVGPJg?9#*gZ{-v#dvFujCwnhI3QBVOv2AQJWcH0ez z5sVB5WQ>pj2oN&WT=ibn-}hA|sfgMrLA`6;RMi{zIrp4>_PLQQW((p+I1+);V1%rf z;r6=QPVjg*9EMJ()6RQ*o_6Ne3lsR>AQy=>jLuz?nY#KOsasCU) zGXd!tKvg49nI1ic9s&Yq9j7(!y)u3zBf!}Uc&ZODpT;EwiM0tRy#y>L@OMLB16KEA z054X<4?ItxkLj(>l*FEcQl&LGPe!}FG~ieOy)OL0>d_u|+wiJ7#Fnf9QwPha#}@&c@GBf`x*BJo+y zRAl!pL~>RioUbf*X87HAGLI_G0f%*Q&-|f0FBANVW_mTPZ)f!W>k=g9F;&fBghGBO z;UEG5H@x0@r1uzvvG*;8Bcq3D5b#!y1B)m_Da06wD1I%JL`W%W5Fs^y z?t{leC+Uy`+^_qdz}v}8>j-{I_hGPbZW$I!&guC17MgZgg%na_tdTTEx@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*qoM6N<$f - + diff --git a/public/svg-edit/editor/svg-editor.css b/public/svg-edit/editor/svg-editor.css index 00e5c941..7b9116ba 100644 --- a/public/svg-edit/editor/svg-editor.css +++ b/public/svg-edit/editor/svg-editor.css @@ -29,13 +29,13 @@ body { } #svg_editor #svgcanvas { + line-height: normal; display: inline-block; background-color: #A0A0A0; text-align: center; vertical-align: middle; width: 640px; height: 480px; - line-height:normal; -apple-dashboard-region:dashboard-region(control rectangle 0px 0px 0px 0px); /* for widget regions that shouldn't react to dragging */ position: relative; /* @@ -958,4 +958,4 @@ button#tool_docprops_cancel { -webkit-border-radius: 0px; } -foreignObject { line-height:1.0; } \ No newline at end of file +foreignObject { line-height:1.0; } diff --git a/public/svg-edit/editor/svgcanvas.js b/public/svg-edit/editor/svgcanvas.js index 6d50f233..9c9d66b1 100644 --- a/public/svg-edit/editor/svgcanvas.js +++ b/public/svg-edit/editor/svgcanvas.js @@ -87,6 +87,8 @@ function SvgCanvas(container) var isOpera = !!window.opera, isWebkit = navigator.userAgent.indexOf("AppleWebKit") != -1, support = {}, + htmlns = "http://www.w3.org/1999/xhtml", + mathns = "http://www.w3.org/1998/Math/MathML", // this defines which elements and attributes that we support svgWhiteList = { @@ -1064,7 +1066,7 @@ function BatchCommand(text) { } for(var attr in defaults) { var val = defaults[attr]; - if(element.localName != 'math' && element.getAttribute(attr) == val) { + if(element.getAttribute(attr) == val) { element.removeAttribute(attr); } } @@ -2718,6 +2720,13 @@ function BatchCommand(text) { if (mouse_target.correspondingUseElement) mouse_target = mouse_target.correspondingUseElement; + // for foreign content, go up until we find the foreignObject + if ($.inArray(mouse_target.namespaceURI, [mathns, htmlns]) != -1) { + while (mouse_target.nodeName != "foreignObject") { + mouse_target = mouse_target.parentNode; + } + } + // go up until we hit a child of a layer while (mouse_target.parentNode.parentNode.tagName == "g") { mouse_target = mouse_target.parentNode; @@ -6495,6 +6504,10 @@ function BatchCommand(text) { ret = selected.getBBox(); ret.x += parseFloat(selected.getAttribute('x')); ret.y += parseFloat(selected.getAttribute('y')); + } else if(elem.nodeName == 'foreignObject') { + ret = selected.getBBox(); + ret.x += parseFloat(selected.getAttribute('x')); + ret.y += parseFloat(selected.getAttribute('y')); } else { try { ret = selected.getBBox(); } catch(e) { ret = null; } @@ -7618,7 +7631,7 @@ function BatchCommand(text) { // Function: getVersion // Returns a string which describes the revision number of SvgCanvas. this.getVersion = function() { - return "svgcanvas.js ($Rev: 1367 $)"; + return "svgcanvas.js ($Rev: 1369 $)"; }; this.setUiStrings = function(strs) { diff --git a/public/svg-edit/test/test1.html b/public/svg-edit/test/test1.html index 873f5f5c..f7520049 100644 --- a/public/svg-edit/test/test1.html +++ b/public/svg-edit/test/test1.html @@ -45,10 +45,11 @@ // TODO: Test these paths: // "m400.00491,625.01379a1.78688,1.78688 0 1 1-3.57373,0a1.78688,1.78688 0 1 13.57373,0z" // "m36.812,15.8566c-28.03099,0 -26.28099,12.15601 -26.28099,12.15601l0.03099,12.59399h26.75v3.781h-37.37399c0,0 -17.938,-2.034 -133.00001,26.25c115.06201,28.284 130.71801,27.281 130.71801,27.281h9.34399v-13.125c0,0 -0.504,-15.656 15.40601,-15.656h26.532c0,0 14.90599,0.241 14.90599,-14.406v-24.219c0,0 2.263,-14.65601 -27.032,-14.65601zm-14.75,8.4684c2.662,0 4.813,2.151 4.813,4.813c0,2.661 -2.151,4.812 -4.813,4.812c-2.661,0 -4.812,-2.151 -4.812,-4.812c0,-2.662 2.151,-4.813 4.812,-4.813z" + // "m 0,0 l 200,0 l 0,100 L 0,100" svgCanvas.setSvgString("" + "" + - "" + + "" + ""); var p1 = document.getElementById("p1"), @@ -72,6 +73,12 @@ // convert and verify segments var d = convert(p1, true); equals(d, "m100,100l100,0z", "Converted path to relative string"); + + // TODO: see why this isn't working in SVG-edit + d = convert(p2, true); + QUnit.log(d); + d = convert(p2, false); + QUnit.log(d); }); module("Transform Module");